Press n or j to go to the next uncovered block, b, p or k for the previous block.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 | 2x 2x 2x 78x 39x 39x 39x 39x 22x 22x 13x 9x 9x 25x | import ms from 'ms';
import debug from 'debug';
import memoizer from 'lru-memoizer';
export default function(client, { cacheMaxEntries = 5, cacheMaxAge = ms('10m') } = options) {
const logger = debug('jwks');
const getSigningKey = client.getSigningKey;
logger(`Configured caching of singing keys. Max: ${cacheMaxEntries} / Age: ${cacheMaxAge}`);
return memoizer({
load: (kid, callback) => {
getSigningKey(kid, (err, key) => {
if (err) {
return callback(err);
}
logger(`Caching signing key for '${kid}':`, key);
return callback(null, key);
});
},
hash: (kid) => kid,
maxAge: cacheMaxAge,
max: cacheMaxEntries
});
}
|