diff --git a/keyfetch-test.js b/keyfetch-test.js index e60cc61..a7f7f8e 100644 --- a/keyfetch-test.js +++ b/keyfetch-test.js @@ -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); diff --git a/keyfetch.js b/keyfetch.js index 996f6b6..9152e3f 100644 --- a/keyfetch.js +++ b/keyfetch.js @@ -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]; diff --git a/package.json b/package.json index 2b20389..70aec76 100644 --- a/package.json +++ b/package.json @@ -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" }