@cfworker/jwt 4.0.1 → 4.0.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/jwks.js +2 -9
- package/package.json +1 -1
- package/src/jwks.ts +2 -10
package/dist/jwks.js
CHANGED
|
@@ -32,18 +32,11 @@ export async function importKey(iss, jwk) {
|
|
|
32
32
|
importedKeys[iss] = importedKeys[iss] || {};
|
|
33
33
|
importedKeys[iss][jwk.kid ?? 'default'] = key;
|
|
34
34
|
}
|
|
35
|
-
const jwksImports = {};
|
|
36
35
|
export async function getKey(decoded) {
|
|
37
36
|
const { header: { kid = 'default' }, payload: { iss } } = decoded;
|
|
38
37
|
if (!importedKeys[iss]) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
.then(jwks => Promise.all(jwks.keys.map(jwk => importKey(iss, jwk))))
|
|
42
|
-
.finally(() => {
|
|
43
|
-
delete jwksImports[iss];
|
|
44
|
-
});
|
|
45
|
-
}
|
|
46
|
-
await jwksImports[iss];
|
|
38
|
+
const jwks = await getJwks(iss);
|
|
39
|
+
await Promise.all(jwks.keys.map(jwk => importKey(iss, jwk)));
|
|
47
40
|
}
|
|
48
41
|
const key = importedKeys[iss][kid];
|
|
49
42
|
if (!key) {
|
package/package.json
CHANGED
package/src/jwks.ts
CHANGED
|
@@ -65,8 +65,6 @@ export async function importKey(iss: string, jwk: JsonWebKey) {
|
|
|
65
65
|
importedKeys[iss][jwk.kid ?? 'default'] = key;
|
|
66
66
|
}
|
|
67
67
|
|
|
68
|
-
const jwksImports: Record<string, Promise<unknown>> = {};
|
|
69
|
-
|
|
70
68
|
/**
|
|
71
69
|
* Get the CryptoKey associated with the JWT's issuer.
|
|
72
70
|
*/
|
|
@@ -77,14 +75,8 @@ export async function getKey(decoded: DecodedJwt): Promise<CryptoKey> {
|
|
|
77
75
|
} = decoded;
|
|
78
76
|
|
|
79
77
|
if (!importedKeys[iss]) {
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
.then(jwks => Promise.all(jwks.keys.map(jwk => importKey(iss, jwk))))
|
|
83
|
-
.finally(() => {
|
|
84
|
-
delete jwksImports[iss];
|
|
85
|
-
});
|
|
86
|
-
}
|
|
87
|
-
await jwksImports[iss];
|
|
78
|
+
const jwks = await getJwks(iss);
|
|
79
|
+
await Promise.all(jwks.keys.map(jwk => importKey(iss, jwk)));
|
|
88
80
|
}
|
|
89
81
|
|
|
90
82
|
const key = importedKeys[iss][kid];
|