Updated tests to reflect jwks-rsa v2 changes

refs https://github.com/auth0/node-jwks-rsa/blob/master/CHANGELOG.md#200---2021-03-01

- `jwks-rsa` switches from callbacks to async-await and so we need to
  change the tests to reflect this
- this commit moves from `getSigningKey` containing a callback to it
  being part of the async-await flow
This commit is contained in:
Daniel Lockyer 2021-04-16 09:13:04 +01:00
parent 7c7f46cbf1
commit d01d8988e2
2 changed files with 8 additions and 10 deletions

View File

@ -16,11 +16,10 @@ const verifyJWKS = (endpoint, token) => {
jwksUri: endpoint
});
function getKey(header, callback){
client.getSigningKey(header.kid, (err, key) => {
let signingKey = key.publicKey || key.rsaPublicKey;
callback(null, signingKey);
});
async function getKey(header, callback) {
const key = await client.getSigningKey(header.kid);
let signingKey = key.publicKey || key.rsaPublicKey;
callback(null, signingKey);
}
jwt.verify(token, getKey, {}, (err, decoded) => {

View File

@ -16,11 +16,10 @@ const verifyJWKS = (endpoint, token) => {
jwksUri: endpoint
});
function getKey(header, callback){
client.getSigningKey(header.kid, (err, key) => {
let signingKey = key.publicKey || key.rsaPublicKey;
callback(null, signingKey);
});
async function getKey(header, callback) {
const key = await client.getSigningKey(header.kid);
let signingKey = key.publicKey || key.rsaPublicKey;
callback(null, signingKey);
}
jwt.verify(token, getKey, {}, (err, decoded) => {