jose 5.6.3 → 5.7.0
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/browser/index.js +1 -1
- package/dist/browser/jwks/remote.js +6 -5
- package/dist/node/cjs/index.js +2 -1
- package/dist/node/cjs/jwks/remote.js +7 -6
- package/dist/node/esm/index.js +1 -1
- package/dist/node/esm/jwks/remote.js +6 -5
- package/dist/types/index.d.ts +1 -1
- package/dist/types/jwks/remote.d.ts +11 -8
- package/dist/types/types.d.ts +32 -11
- package/package.json +1 -1
package/dist/browser/index.js
CHANGED
|
@@ -17,7 +17,7 @@ export { EncryptJWT } from './jwt/encrypt.js';
|
|
|
17
17
|
export { calculateJwkThumbprint, calculateJwkThumbprintUri } from './jwk/thumbprint.js';
|
|
18
18
|
export { EmbeddedJWK } from './jwk/embedded.js';
|
|
19
19
|
export { createLocalJWKSet } from './jwks/local.js';
|
|
20
|
-
export { createRemoteJWKSet, experimental_jwksCache } from './jwks/remote.js';
|
|
20
|
+
export { createRemoteJWKSet, jwksCache, experimental_jwksCache } from './jwks/remote.js';
|
|
21
21
|
export { UnsecuredJWT } from './jwt/unsecured.js';
|
|
22
22
|
export { exportPKCS8, exportSPKI, exportJWK } from './key/export.js';
|
|
23
23
|
export { importSPKI, importPKCS8, importX509, importJWK } from './key/import.js';
|
|
@@ -10,10 +10,10 @@ function isCloudflareWorkers() {
|
|
|
10
10
|
let USER_AGENT;
|
|
11
11
|
if (typeof navigator === 'undefined' || !navigator.userAgent?.startsWith?.('Mozilla/5.0 ')) {
|
|
12
12
|
const NAME = 'jose';
|
|
13
|
-
const VERSION = 'v5.
|
|
13
|
+
const VERSION = 'v5.7.0';
|
|
14
14
|
USER_AGENT = `${NAME}/${VERSION}`;
|
|
15
15
|
}
|
|
16
|
-
export const
|
|
16
|
+
export const jwksCache = Symbol();
|
|
17
17
|
function isFreshJwksCache(input, cacheMaxAge) {
|
|
18
18
|
if (typeof input !== 'object' || input === null) {
|
|
19
19
|
return false;
|
|
@@ -41,9 +41,9 @@ class RemoteJWKSet {
|
|
|
41
41
|
this._cooldownDuration =
|
|
42
42
|
typeof options?.cooldownDuration === 'number' ? options?.cooldownDuration : 30000;
|
|
43
43
|
this._cacheMaxAge = typeof options?.cacheMaxAge === 'number' ? options?.cacheMaxAge : 600000;
|
|
44
|
-
if (options?.[
|
|
45
|
-
this._cache = options?.[
|
|
46
|
-
if (isFreshJwksCache(options?.[
|
|
44
|
+
if (options?.[jwksCache] !== undefined) {
|
|
45
|
+
this._cache = options?.[jwksCache];
|
|
46
|
+
if (isFreshJwksCache(options?.[jwksCache], this._cacheMaxAge)) {
|
|
47
47
|
this._jwksTimestamp = this._cache.uat;
|
|
48
48
|
this._local = createLocalJWKSet(this._cache.jwks);
|
|
49
49
|
}
|
|
@@ -136,3 +136,4 @@ export function createRemoteJWKSet(url, options) {
|
|
|
136
136
|
});
|
|
137
137
|
return remoteJWKSet;
|
|
138
138
|
}
|
|
139
|
+
export const experimental_jwksCache = jwksCache;
|
package/dist/node/cjs/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.cryptoRuntime = exports.base64url = exports.generateSecret = exports.generateKeyPair = exports.errors = exports.decodeJwt = exports.decodeProtectedHeader = exports.importJWK = exports.importX509 = exports.importPKCS8 = exports.importSPKI = exports.exportJWK = exports.exportSPKI = exports.exportPKCS8 = exports.UnsecuredJWT = exports.experimental_jwksCache = exports.createRemoteJWKSet = exports.createLocalJWKSet = exports.EmbeddedJWK = exports.calculateJwkThumbprintUri = exports.calculateJwkThumbprint = exports.EncryptJWT = exports.SignJWT = exports.GeneralSign = exports.FlattenedSign = exports.CompactSign = exports.FlattenedEncrypt = exports.CompactEncrypt = exports.jwtDecrypt = exports.jwtVerify = exports.generalVerify = exports.flattenedVerify = exports.compactVerify = exports.GeneralEncrypt = exports.generalDecrypt = exports.flattenedDecrypt = exports.compactDecrypt = void 0;
|
|
3
|
+
exports.cryptoRuntime = exports.base64url = exports.generateSecret = exports.generateKeyPair = exports.errors = exports.decodeJwt = exports.decodeProtectedHeader = exports.importJWK = exports.importX509 = exports.importPKCS8 = exports.importSPKI = exports.exportJWK = exports.exportSPKI = exports.exportPKCS8 = exports.UnsecuredJWT = exports.experimental_jwksCache = exports.jwksCache = exports.createRemoteJWKSet = exports.createLocalJWKSet = exports.EmbeddedJWK = exports.calculateJwkThumbprintUri = exports.calculateJwkThumbprint = exports.EncryptJWT = exports.SignJWT = exports.GeneralSign = exports.FlattenedSign = exports.CompactSign = exports.FlattenedEncrypt = exports.CompactEncrypt = exports.jwtDecrypt = exports.jwtVerify = exports.generalVerify = exports.flattenedVerify = exports.compactVerify = exports.GeneralEncrypt = exports.generalDecrypt = exports.flattenedDecrypt = exports.compactDecrypt = void 0;
|
|
4
4
|
var decrypt_js_1 = require("./jwe/compact/decrypt.js");
|
|
5
5
|
Object.defineProperty(exports, "compactDecrypt", { enumerable: true, get: function () { return decrypt_js_1.compactDecrypt; } });
|
|
6
6
|
var decrypt_js_2 = require("./jwe/flattened/decrypt.js");
|
|
@@ -42,6 +42,7 @@ var local_js_1 = require("./jwks/local.js");
|
|
|
42
42
|
Object.defineProperty(exports, "createLocalJWKSet", { enumerable: true, get: function () { return local_js_1.createLocalJWKSet; } });
|
|
43
43
|
var remote_js_1 = require("./jwks/remote.js");
|
|
44
44
|
Object.defineProperty(exports, "createRemoteJWKSet", { enumerable: true, get: function () { return remote_js_1.createRemoteJWKSet; } });
|
|
45
|
+
Object.defineProperty(exports, "jwksCache", { enumerable: true, get: function () { return remote_js_1.jwksCache; } });
|
|
45
46
|
Object.defineProperty(exports, "experimental_jwksCache", { enumerable: true, get: function () { return remote_js_1.experimental_jwksCache; } });
|
|
46
47
|
var unsecured_js_1 = require("./jwt/unsecured.js");
|
|
47
48
|
Object.defineProperty(exports, "UnsecuredJWT", { enumerable: true, get: function () { return unsecured_js_1.UnsecuredJWT; } });
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.createRemoteJWKSet = exports.
|
|
3
|
+
exports.experimental_jwksCache = exports.createRemoteJWKSet = exports.jwksCache = void 0;
|
|
4
4
|
const fetch_jwks_js_1 = require("../runtime/fetch_jwks.js");
|
|
5
5
|
const errors_js_1 = require("../util/errors.js");
|
|
6
6
|
const local_js_1 = require("./local.js");
|
|
@@ -13,10 +13,10 @@ function isCloudflareWorkers() {
|
|
|
13
13
|
let USER_AGENT;
|
|
14
14
|
if (typeof navigator === 'undefined' || !navigator.userAgent?.startsWith?.('Mozilla/5.0 ')) {
|
|
15
15
|
const NAME = 'jose';
|
|
16
|
-
const VERSION = 'v5.
|
|
16
|
+
const VERSION = 'v5.7.0';
|
|
17
17
|
USER_AGENT = `${NAME}/${VERSION}`;
|
|
18
18
|
}
|
|
19
|
-
exports.
|
|
19
|
+
exports.jwksCache = Symbol();
|
|
20
20
|
function isFreshJwksCache(input, cacheMaxAge) {
|
|
21
21
|
if (typeof input !== 'object' || input === null) {
|
|
22
22
|
return false;
|
|
@@ -53,9 +53,9 @@ class RemoteJWKSet {
|
|
|
53
53
|
this._cooldownDuration =
|
|
54
54
|
typeof options?.cooldownDuration === 'number' ? options?.cooldownDuration : 30000;
|
|
55
55
|
this._cacheMaxAge = typeof options?.cacheMaxAge === 'number' ? options?.cacheMaxAge : 600000;
|
|
56
|
-
if (options?.[exports.
|
|
57
|
-
this._cache = options?.[exports.
|
|
58
|
-
if (isFreshJwksCache(options?.[exports.
|
|
56
|
+
if (options?.[exports.jwksCache] !== undefined) {
|
|
57
|
+
this._cache = options?.[exports.jwksCache];
|
|
58
|
+
if (isFreshJwksCache(options?.[exports.jwksCache], this._cacheMaxAge)) {
|
|
59
59
|
this._jwksTimestamp = this._cache.uat;
|
|
60
60
|
this._local = (0, local_js_1.createLocalJWKSet)(this._cache.jwks);
|
|
61
61
|
}
|
|
@@ -149,3 +149,4 @@ function createRemoteJWKSet(url, options) {
|
|
|
149
149
|
return remoteJWKSet;
|
|
150
150
|
}
|
|
151
151
|
exports.createRemoteJWKSet = createRemoteJWKSet;
|
|
152
|
+
exports.experimental_jwksCache = exports.jwksCache;
|
package/dist/node/esm/index.js
CHANGED
|
@@ -17,7 +17,7 @@ export { EncryptJWT } from './jwt/encrypt.js';
|
|
|
17
17
|
export { calculateJwkThumbprint, calculateJwkThumbprintUri } from './jwk/thumbprint.js';
|
|
18
18
|
export { EmbeddedJWK } from './jwk/embedded.js';
|
|
19
19
|
export { createLocalJWKSet } from './jwks/local.js';
|
|
20
|
-
export { createRemoteJWKSet, experimental_jwksCache } from './jwks/remote.js';
|
|
20
|
+
export { createRemoteJWKSet, jwksCache, experimental_jwksCache } from './jwks/remote.js';
|
|
21
21
|
export { UnsecuredJWT } from './jwt/unsecured.js';
|
|
22
22
|
export { exportPKCS8, exportSPKI, exportJWK } from './key/export.js';
|
|
23
23
|
export { importSPKI, importPKCS8, importX509, importJWK } from './key/import.js';
|
|
@@ -10,10 +10,10 @@ function isCloudflareWorkers() {
|
|
|
10
10
|
let USER_AGENT;
|
|
11
11
|
if (typeof navigator === 'undefined' || !navigator.userAgent?.startsWith?.('Mozilla/5.0 ')) {
|
|
12
12
|
const NAME = 'jose';
|
|
13
|
-
const VERSION = 'v5.
|
|
13
|
+
const VERSION = 'v5.7.0';
|
|
14
14
|
USER_AGENT = `${NAME}/${VERSION}`;
|
|
15
15
|
}
|
|
16
|
-
export const
|
|
16
|
+
export const jwksCache = Symbol();
|
|
17
17
|
function isFreshJwksCache(input, cacheMaxAge) {
|
|
18
18
|
if (typeof input !== 'object' || input === null) {
|
|
19
19
|
return false;
|
|
@@ -50,9 +50,9 @@ class RemoteJWKSet {
|
|
|
50
50
|
this._cooldownDuration =
|
|
51
51
|
typeof options?.cooldownDuration === 'number' ? options?.cooldownDuration : 30000;
|
|
52
52
|
this._cacheMaxAge = typeof options?.cacheMaxAge === 'number' ? options?.cacheMaxAge : 600000;
|
|
53
|
-
if (options?.[
|
|
54
|
-
this._cache = options?.[
|
|
55
|
-
if (isFreshJwksCache(options?.[
|
|
53
|
+
if (options?.[jwksCache] !== undefined) {
|
|
54
|
+
this._cache = options?.[jwksCache];
|
|
55
|
+
if (isFreshJwksCache(options?.[jwksCache], this._cacheMaxAge)) {
|
|
56
56
|
this._jwksTimestamp = this._cache.uat;
|
|
57
57
|
this._local = createLocalJWKSet(this._cache.jwks);
|
|
58
58
|
}
|
|
@@ -145,3 +145,4 @@ export function createRemoteJWKSet(url, options) {
|
|
|
145
145
|
});
|
|
146
146
|
return remoteJWKSet;
|
|
147
147
|
}
|
|
148
|
+
export const experimental_jwksCache = jwksCache;
|
package/dist/types/index.d.ts
CHANGED
|
@@ -28,7 +28,7 @@ export { EncryptJWT } from './jwt/encrypt';
|
|
|
28
28
|
export { calculateJwkThumbprint, calculateJwkThumbprintUri } from './jwk/thumbprint';
|
|
29
29
|
export { EmbeddedJWK } from './jwk/embedded';
|
|
30
30
|
export { createLocalJWKSet } from './jwks/local';
|
|
31
|
-
export { createRemoteJWKSet, experimental_jwksCache } from './jwks/remote';
|
|
31
|
+
export { createRemoteJWKSet, jwksCache, experimental_jwksCache } from './jwks/remote';
|
|
32
32
|
export type { RemoteJWKSetOptions, JWKSCacheInput, ExportedJWKSCache } from './jwks/remote';
|
|
33
33
|
export { UnsecuredJWT } from './jwt/unsecured';
|
|
34
34
|
export type { UnsecuredResult } from './jwt/unsecured';
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import type { KeyLike, JWSHeaderParameters, FlattenedJWSInput, JSONWebKeySet } from '../types';
|
|
2
2
|
/**
|
|
3
|
-
* This is an experimental feature, it is not subject to semantic versioning rules. Non-backward
|
|
4
|
-
* compatible changes or removal may occur in any future release.
|
|
5
|
-
*
|
|
6
3
|
* DANGER ZONE - This option has security implications that must be understood, assessed for
|
|
7
4
|
* applicability, and accepted before use. It is critical that the JSON Web Key Set cache only be
|
|
8
5
|
* writable by your own code.
|
|
@@ -25,7 +22,7 @@ import type { KeyLike, JWSHeaderParameters, FlattenedJWSInput, JSONWebKeySet } f
|
|
|
25
22
|
* previously cached object from a low-latency key-value store offered by the cloud computing
|
|
26
23
|
* runtime it is executed on;
|
|
27
24
|
* - Default to an empty object `{}` instead when there's no previously cached value;
|
|
28
|
-
* - Pass it in as {@link RemoteJWKSetOptions[
|
|
25
|
+
* - Pass it in as {@link RemoteJWKSetOptions[jwksCache]};
|
|
29
26
|
* - Afterwards, update the key-value storage if the {@link ExportedJWKSCache.uat `uat`} property of
|
|
30
27
|
* the object has changed.
|
|
31
28
|
*
|
|
@@ -40,7 +37,7 @@ import type { KeyLike, JWSHeaderParameters, FlattenedJWSInput, JSONWebKeySet } f
|
|
|
40
37
|
* const { uat } = jwksCache
|
|
41
38
|
*
|
|
42
39
|
* const JWKS = jose.createRemoteJWKSet(url, {
|
|
43
|
-
* [jose.
|
|
40
|
+
* [jose.jwksCache]: jwksCache,
|
|
44
41
|
* })
|
|
45
42
|
*
|
|
46
43
|
* // Use JSON Web Key Set cache
|
|
@@ -52,7 +49,7 @@ import type { KeyLike, JWSHeaderParameters, FlattenedJWSInput, JSONWebKeySet } f
|
|
|
52
49
|
* }
|
|
53
50
|
* ```
|
|
54
51
|
*/
|
|
55
|
-
export declare const
|
|
52
|
+
export declare const jwksCache: unique symbol;
|
|
56
53
|
/** Options for the remote JSON Web Key Set. */
|
|
57
54
|
export interface RemoteJWKSetOptions {
|
|
58
55
|
/**
|
|
@@ -85,8 +82,8 @@ export interface RemoteJWKSetOptions {
|
|
|
85
82
|
* configuration would cause an unnecessary CORS preflight request.
|
|
86
83
|
*/
|
|
87
84
|
headers?: Record<string, string>;
|
|
88
|
-
/** See {@link
|
|
89
|
-
[
|
|
85
|
+
/** See {@link jwksCache}. */
|
|
86
|
+
[jwksCache]?: JWKSCacheInput;
|
|
90
87
|
}
|
|
91
88
|
export interface ExportedJWKSCache {
|
|
92
89
|
jwks: JSONWebKeySet;
|
|
@@ -127,3 +124,9 @@ export declare function createRemoteJWKSet<KeyLikeType extends KeyLike = KeyLike
|
|
|
127
124
|
/** @ignore */
|
|
128
125
|
jwks: () => JSONWebKeySet | undefined;
|
|
129
126
|
};
|
|
127
|
+
/**
|
|
128
|
+
* @ignore
|
|
129
|
+
*
|
|
130
|
+
* @deprecated Use {@link jwksCache}.
|
|
131
|
+
*/
|
|
132
|
+
export declare const experimental_jwksCache: symbol;
|
package/dist/types/types.d.ts
CHANGED
|
@@ -370,7 +370,11 @@ export interface EncryptOptions extends CritOption {}
|
|
|
370
370
|
|
|
371
371
|
/** JWT Claims Set verification options. */
|
|
372
372
|
export interface JWTClaimVerificationOptions {
|
|
373
|
-
/**
|
|
373
|
+
/**
|
|
374
|
+
* Expected JWT "aud" (Audience) Claim value(s).
|
|
375
|
+
*
|
|
376
|
+
* This option makes the JWT "aud" (Audience) Claim presence required.
|
|
377
|
+
*/
|
|
374
378
|
audience?: string | string[]
|
|
375
379
|
|
|
376
380
|
/**
|
|
@@ -381,7 +385,11 @@ export interface JWTClaimVerificationOptions {
|
|
|
381
385
|
*/
|
|
382
386
|
clockTolerance?: string | number
|
|
383
387
|
|
|
384
|
-
/**
|
|
388
|
+
/**
|
|
389
|
+
* Expected JWT "iss" (Issuer) Claim value(s).
|
|
390
|
+
*
|
|
391
|
+
* This option makes the JWT "iss" (Issuer) Claim presence required.
|
|
392
|
+
*/
|
|
385
393
|
issuer?: string | string[]
|
|
386
394
|
|
|
387
395
|
/**
|
|
@@ -389,13 +397,23 @@ export interface JWTClaimVerificationOptions {
|
|
|
389
397
|
*
|
|
390
398
|
* - In seconds when number (e.g. 5)
|
|
391
399
|
* - Parsed as seconds when a string (e.g. "5 seconds", "10 minutes", "2 hours").
|
|
400
|
+
*
|
|
401
|
+
* This option makes the JWT "iat" (Issued At) Claim presence required.
|
|
392
402
|
*/
|
|
393
403
|
maxTokenAge?: string | number
|
|
394
404
|
|
|
395
|
-
/**
|
|
405
|
+
/**
|
|
406
|
+
* Expected JWT "sub" (Subject) Claim value.
|
|
407
|
+
*
|
|
408
|
+
* This option makes the JWT "sub" (Subject) Claim presence required.
|
|
409
|
+
*/
|
|
396
410
|
subject?: string
|
|
397
411
|
|
|
398
|
-
/**
|
|
412
|
+
/**
|
|
413
|
+
* Expected JWT "typ" (Type) Header Parameter value.
|
|
414
|
+
*
|
|
415
|
+
* This option makes the JWT "typ" (Type) Header Parameter presence required.
|
|
416
|
+
*/
|
|
399
417
|
typ?: string
|
|
400
418
|
|
|
401
419
|
/** Date to use when comparing NumericDate claims, defaults to `new Date()`. */
|
|
@@ -403,11 +421,13 @@ export interface JWTClaimVerificationOptions {
|
|
|
403
421
|
|
|
404
422
|
/**
|
|
405
423
|
* Array of required Claim Names that must be present in the JWT Claims Set. Default is that: if
|
|
406
|
-
* the {@link JWTClaimVerificationOptions.issuer issuer option} is set, then "iss"
|
|
407
|
-
* if the {@link JWTClaimVerificationOptions.audience audience option} is
|
|
408
|
-
*
|
|
409
|
-
*
|
|
410
|
-
*
|
|
424
|
+
* the {@link JWTClaimVerificationOptions.issuer `issuer` option} is set, then JWT "iss" (Issuer)
|
|
425
|
+
* Claim must be present; if the {@link JWTClaimVerificationOptions.audience `audience` option} is
|
|
426
|
+
* set, then JWT "aud" (Audience) Claim must be present; if the
|
|
427
|
+
* {@link JWTClaimVerificationOptions.subject `subject` option} is set, then JWT "sub" (Subject)
|
|
428
|
+
* Claim must be present; if the
|
|
429
|
+
* {@link JWTClaimVerificationOptions.maxTokenAge `maxTokenAge` option} is set, then JWT "iat"
|
|
430
|
+
* (Issued At) Claim must be present.
|
|
411
431
|
*/
|
|
412
432
|
requiredClaims?: string[]
|
|
413
433
|
}
|
|
@@ -416,8 +436,9 @@ export interface JWTClaimVerificationOptions {
|
|
|
416
436
|
export interface VerifyOptions extends CritOption {
|
|
417
437
|
/**
|
|
418
438
|
* A list of accepted JWS "alg" (Algorithm) Header Parameter values. By default all "alg"
|
|
419
|
-
* (Algorithm) values applicable for the used key/secret are allowed.
|
|
420
|
-
*
|
|
439
|
+
* (Algorithm) values applicable for the used key/secret are allowed.
|
|
440
|
+
*
|
|
441
|
+
* Note: Unsecured JWTs (`{ "alg": "none" }`) are never accepted by this API.
|
|
421
442
|
*/
|
|
422
443
|
algorithms?: string[]
|
|
423
444
|
}
|