v1.1.4: fix fetching bug

This commit is contained in:
AJ ONeal 2019-02-25 16:17:26 -07:00
parent cfe814ebb0
commit 0f0d0807a0
3 changed files with 13 additions and 8 deletions

View File

@ -1,12 +1,16 @@
'use strict';
var keyfetch = require('./keyfetch.js');
var testUrl = "https://example.auth0.com";
keyfetch.init({});
keyfetch.oidcJwks("https://bigsquid.auth0.com").then(function (jwks) {
keyfetch.oidcJwks().then(function (jwks) {
keyfetch._clear();
console.log(jwks);
return keyfetch.oidcJwk(jwks[0].thumbprint, "https://bigsquid.auth0.com").then(function (jwk) {
console.log(jwk);
return keyfetch.oidcJwk(jwks[0].thumbprint, "https://example.auth0.com").then(function () {
return keyfetch.oidcJwk(jwks[0].thumbprint, "https://example.auth0.com").then(function (jwk) {
console.log(jwk);
});
});
}).catch(function (err) {
console.error(err);

View File

@ -22,6 +22,9 @@ function checkMinDefaultMax(opts, key, n, d, x) {
}
}
keyfetch._clear = function () {
keyCache = {};
};
keyfetch.init = function (opts) {
mincache = checkMinDefaultMax(opts, 'mincache',
1 * 60,
@ -113,7 +116,7 @@ keyfetch.oidcJwks = function (iss) {
};
function checkId(id) {
return function (results) {
var result = results.some(function (result) {
var result = results.filter(function (result) {
// we already checked iss above
return result.jwk.kid === id || result.thumbprint === id;
})[0];

View File

@ -10,9 +10,7 @@
},
"deprecated": false,
"description": "Lightweight support for fetching JWKs.",
"files": [
"keyfetch-test.js"
],
"files": [],
"keywords": [
"jwks",
"jwk",
@ -31,5 +29,5 @@
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"version": "1.1.3"
"version": "1.1.4"
}