How to use the @foal/jwt.InvalidTokenError function in @foal/jwt

To help you get started, we’ve selected a few @foal/jwt examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github FoalTS / foal / packages / jwks-rsa / src / get-rsa-public-key-from-jwks.ts View on Github external
return async ({ alg, kid }) => {
    if (alg !== 'RS256') {
      throw new InvalidTokenError('invalid algorithm');
    }
    if (kid === undefined) {
      throw new InvalidTokenError('missing kid');
    }

    const client = jwksClient(options);

    return new Promise((resolve, reject) => {
      client.getSigningKey(kid, (err, key) => {
        if (err) {
          return reject(err.name === 'SigningKeyNotFoundError' ? new InvalidTokenError('invalid kid') : err);
        }
        // "key.publicKey || key.rsaPublicKey" because of
        // https://github.com/auth0/node-jwks-rsa/blob/master/src/integrations/express.js#L36
        // The " || key.rsaPublicKey" part is currently not tested.
        resolve(key.publicKey || key.rsaPublicKey);
github FoalTS / foal / packages / jwks-rsa / src / get-rsa-public-key-from-jwks.ts View on Github external
return async ({ alg, kid }) => {
    if (alg !== 'RS256') {
      throw new InvalidTokenError('invalid algorithm');
    }
    if (kid === undefined) {
      throw new InvalidTokenError('missing kid');
    }

    const client = jwksClient(options);

    return new Promise((resolve, reject) => {
      client.getSigningKey(kid, (err, key) => {
        if (err) {
          return reject(err.name === 'SigningKeyNotFoundError' ? new InvalidTokenError('invalid kid') : err);
        }
        // "key.publicKey || key.rsaPublicKey" because of
        // https://github.com/auth0/node-jwks-rsa/blob/master/src/integrations/express.js#L36
        // The " || key.rsaPublicKey" part is currently not tested.
        resolve(key.publicKey || key.rsaPublicKey);
      });
    });
  };
github FoalTS / foal / packages / jwks-rsa / src / get-rsa-public-key-from-jwks.ts View on Github external
client.getSigningKey(kid, (err, key) => {
        if (err) {
          return reject(err.name === 'SigningKeyNotFoundError' ? new InvalidTokenError('invalid kid') : err);
        }
        // "key.publicKey || key.rsaPublicKey" because of
        // https://github.com/auth0/node-jwks-rsa/blob/master/src/integrations/express.js#L36
        // The " || key.rsaPublicKey" part is currently not tested.
        resolve(key.publicKey || key.rsaPublicKey);
      });
    });

@foal/jwt

Authentication with JWT for FoalTS

MIT
Latest version published 2 months ago

Package Health Score

78 / 100
Full package analysis