Code Monkey home page Code Monkey logo

vulcan-api-js's People

Contributors

avortybot avatar baderbc avatar capure avatar cooligus avatar maxidragon avatar phospo avatar sewe2000 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

vulcan-api-js's Issues

getLessons() and getGrades() are broken

You can't execute any of these functions.

It's an error code:

C:\Users\pewie\Documents\Muj Elektryk\node_modules\vulcan-api-js\lib\index.js:2486
        query["unitId"] = student.unit.id;
                                  ^

TypeError: Cannot read properties of undefined (reading 'unit')
    at ApiHelper.getList (C:\Users\pewie\Documents\Muj Elektryk\node_modules\vulcan-api-js\lib\index.js:2486:35)
    at VulcanHebe.getLessons (C:\Users\pewie\Documents\Muj Elektryk\node_modules\vulcan-api-js\lib\index.js:3876:40)
    at main (C:\Users\pewie\Documents\Muj Elektryk\index.js:14:18)
    at Object.<anonymous> (C:\Users\pewie\Documents\Muj Elektryk\index.js:23:1)
    at Module._compile (node:internal/modules/cjs/loader:1218:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1272:10)
    at Module.load (node:internal/modules/cjs/loader:1081:32)
    at Module._load (node:internal/modules/cjs/loader:922:12)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
    at node:internal/main/run_main_module:23:47

Node.js v18.13.0

New Version

It would be nice if we had created and published a new version to npm.

Problem z utworzeniem Keystore

Tworzę projekt z użyciem tego modułu, jednak nie mogę wygenerować Keystore, gdyż request do wygenerowania tokenu Firebase na adres url: https://android.clients.google.com/c2dm/register3 powoduje błąd związany z CORS (nie zwraca Access-Control-Allow-Origin). Ten błąd uniemożliwia korzystanie z API. Co w tym wypadku zrobić?

Access to XMLHttpRequest at 'https://android.clients.google.com/c2dm/register3' from origin 'http://localhost:3000' has been blocked by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.

SyntaxError: Unexpected end of input podczas kompilacji TypeScripta

Dzień dobry,
Piszę projekt nestJS w TypeScripcie i korzystam z Państwa biblioteki. Niestety w trakcie kompilacji pojawił mi się błąd: SyntaxError: Unexpected end of input związany z tą biblioteką.
image
Oto mój kod korzystający z vulcan-api-js:

import { ForbiddenException, Injectable } from '@nestjs/common';
import { AuthDto } from './dto';
import { DbService } from '../db/db.service';
import bcrypt from 'bcrypt';
import {
  AccountTools,
  Keystore,
  registerAccount,
  VulcanHebe,
} from 'vulcan-api-js';
import { PrismaClientKnownRequestError } from '@prisma/client/runtime';

@Injectable()
export class AuthService {
  constructor(private prisma: DbService) {}
  async signup(dto: AuthDto): Promise<object> {
    const keystore = new Keystore();
    await keystore.init();
    keystore.deviceModel = 'Muj Elektryk';
    const vulcanAccount = await registerAccount(
      keystore,
      dto.token,
      dto.symbol,
      dto.pin,
    );
    const vulcanClient = new VulcanHebe(
      keystore,
      AccountTools.loadFromObject(vulcanAccount),
    );
    await vulcanClient.selectStudent();

    const student = (await vulcanClient.getStudents())[0];
    const lesson = (await vulcanClient.getLessons(new Date('2022-09-02')))[0];
    const classNumber = student.periods.at(-1)?.level;

    const saltRounds = 10;
    let hashedPassword = '';
    bcrypt.genSalt(saltRounds, (err, salt) => {
      bcrypt.hash(dto.password, salt, (err, hash) => {
        hashedPassword = hash;
      });
    });

    try {
      const user = await this.prisma.user.create({
        data: {
          name: student.pupil.firstName,
          username: dto.username,
          surname: student.pupil.surname,
          class_name:
            classNumber && lesson.class?.symbol
              ? classNumber + lesson.class.symbol
              : '',
          passwordHash: hashedPassword,
          loginID: vulcanAccount.loginId,
          email: vulcanAccount.userLogin,
          certificate: keystore.certificate,
          fingerprint: keystore.fingerprint,
          privateKey: keystore.privateKey,
          firebaseToken: keystore.firebaseToken,
        },
      });

      return user;
    } catch (error: any) {
      if (error instanceof PrismaClientKnownRequestError) {
        if (error.code === 'P2002') {
          throw new ForbiddenException('Credentials taken!');
        }
      }
      throw error;
    }
  }
}

New version

It would be nice if we created a new version and publish it on npm.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.