Skip to content

Commit 0cdd1c6

Browse files
committed
Bumped lru cache to version 10
1 parent 841b77d commit 0cdd1c6

File tree

9 files changed

+20
-24
lines changed

9 files changed

+20
-24
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,7 @@ npm-shrinkwrap.json
3737

3838
# TS test
3939
types/*.js
40+
41+
42+
# Editors
43+
.idea

lib/helpers/issuer.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ const inFlight = new WeakMap();
1313
const caches = new WeakMap();
1414
const lrus = (ctx) => {
1515
if (!caches.has(ctx)) {
16-
caches.set(ctx, new LRU({ max: 100 }));
16+
caches.set(ctx, new LRU.LRUCache({ max: 100 }));
1717
}
1818
return caches.get(ctx);
1919
};
@@ -28,7 +28,7 @@ async function getKeyStore(reload = false) {
2828
if (inFlight.has(this)) {
2929
return inFlight.get(this);
3030
}
31-
cache.reset();
31+
cache.clear();
3232
inFlight.set(
3333
this,
3434
(async () => {

lib/helpers/request.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ function send(req, body, contentType) {
5959
req.end();
6060
}
6161

62-
const nonces = new LRU({ max: 100 });
62+
const nonces = new LRU.LRUCache({ max: 100 });
6363

6464
module.exports = async function request(options, { accessToken, mTLS = false, DPoP } = {}) {
6565
let url;

lib/issuer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ class Issuer {
127127
const issuer = await this.discover(expectedIssuer);
128128

129129
if (issuer.issuer !== expectedIssuer) {
130-
registry.del(issuer.issuer);
130+
registry.delete(issuer.issuer);
131131
throw new RPError(
132132
'discovered issuer mismatch, expected %s, got: %s',
133133
expectedIssuer,

lib/issuer_registry.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
const LRU = require('lru-cache');
22

3-
module.exports = new LRU({ max: 100 });
3+
module.exports = new LRU.LRUCache({ max: 100 });

package-lock.json

Lines changed: 5 additions & 13 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@
4646
},
4747
"dependencies": {
4848
"jose": "^4.15.5",
49-
"lru-cache": "^6.0.0",
49+
"lru-cache": "^10.2.0",
5050
"object-hash": "^2.2.0",
5151
"oidc-token-hash": "^5.0.3"
5252
},

test/issuer/discover_webfinger.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ describe('Issuer#webfinger()', () => {
127127
});
128128

129129
it('validates the discovered issuer is the same as from webfinger', function () {
130-
Registry.reset();
130+
Registry.clear();
131131
const webfinger = nock('https://op.example.com')
132132
.get('/.well-known/webfinger')
133133
.query(function (query) {

test/issuer/issuer_instance.test.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ describe('Issuer', () => {
4444

4545
after(nock.cleanAll);
4646
afterEach(function () {
47-
if (LRU.prototype.get.restore) LRU.prototype.get.restore();
47+
if (LRU.LRUCache.prototype.get.restore) LRU.LRUCache.prototype.get.restore();
4848
});
4949

5050
it('does not refetch immidiately', function () {
@@ -69,7 +69,7 @@ describe('Issuer', () => {
6969
});
7070

7171
it('asks to fetch if the keystore is stale and new key definition is requested', function () {
72-
sinon.stub(LRU.prototype, 'get').returns(undefined);
72+
sinon.stub(LRU.LRUCache.prototype, 'get').returns(undefined);
7373
return issuerInternal.queryKeyStore
7474
.call(this.issuer, { use: 'sig', alg: 'RS256', kid: 'yeah' })
7575
.then(fail, () => {
@@ -94,7 +94,7 @@ describe('Issuer', () => {
9494
});
9595

9696
it('requires a kid is provided in definition if more keys are in the storage', function () {
97-
sinon.stub(LRU.prototype, 'get').returns(undefined);
97+
sinon.stub(LRU.LRUCache.prototype, 'get').returns(undefined);
9898
return this.keystore.generate('RSA').then(() => {
9999
nock('https://op.example.com').get('/certs').reply(200, this.keystore.toJWKS());
100100

@@ -110,7 +110,7 @@ describe('Issuer', () => {
110110
});
111111

112112
it('multiple keys can match the JWT header', function () {
113-
sinon.stub(LRU.prototype, 'get').returns(undefined);
113+
sinon.stub(LRU.LRUCache.prototype, 'get').returns(undefined);
114114
const { kid } = this.keystore.get({ kty: 'RSA' });
115115
return this.keystore.generate('RSA', undefined, { kid }).then(() => {
116116
nock('https://op.example.com').get('/certs').reply(200, this.keystore.toJWKS());

0 commit comments

Comments
 (0)