Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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);
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);
});
});
};
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);
});
});