@zuplo/cli 7.4.5 → 7.4.6
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/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/types/jwks/remote.d.ts +4 -4
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/types/jws/general/verify.d.ts +3 -3
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/types/jwt/encrypt.d.ts +8 -14
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/types/jwt/sign.d.ts +8 -14
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/types/jwt/unsecured.d.ts +9 -15
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/jwe/compact/encrypt.js +30 -8
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/jwe/flattened/decrypt.js +8 -4
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/jwe/flattened/encrypt.js +6 -13
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/jwe/general/decrypt.js +19 -19
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/jwe/general/encrypt.js +27 -20
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/jwk/embedded.js +15 -1
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/jwk/thumbprint.js +11 -5
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/jwks/local.js +45 -53
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/jwks/remote.js +82 -103
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/jws/compact/sign.js +10 -9
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/jws/flattened/sign.js +2 -1
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/jws/flattened/verify.js +8 -7
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/jws/general/sign.js +5 -3
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/jws/general/verify.js +51 -21
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/jwt/decrypt.js +7 -9
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/jwt/encrypt.js +21 -50
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/jwt/sign.js +8 -41
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/jwt/unsecured.js +21 -42
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/key/generate_key_pair.js +6 -2
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/key/generate_secret.js +7 -6
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/key/import.js +16 -12
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/lib/asn1.js +7 -2
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/lib/content_encryption.js +7 -15
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/lib/deflate.js +8 -0
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/lib/helpers.js +1 -1
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/lib/jwe_decrypt.js +85 -28
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/lib/jwe_encrypt.js +40 -12
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/lib/jwk_metadata.js +20 -0
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/lib/jws_sign.js +47 -36
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/lib/jws_verify.js +77 -45
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/lib/jwt_claims_set.js +82 -47
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/lib/key.js +24 -9
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/lib/key_management.js +10 -4
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/lib/key_options.js +6 -0
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/lib/options.js +26 -0
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/lib/type_checks.js +11 -13
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/package.json +1 -1
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/jwks/remote.d.ts +4 -4
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/jws/general/verify.d.ts +3 -3
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/jwt/encrypt.d.ts +8 -14
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/jwt/sign.d.ts +8 -14
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/jwt/unsecured.d.ts +9 -15
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jwe/compact/encrypt.js +30 -8
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jwe/flattened/decrypt.js +8 -4
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jwe/flattened/encrypt.js +6 -13
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jwe/general/decrypt.js +19 -19
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jwe/general/encrypt.js +27 -20
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jwk/embedded.js +15 -1
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jwk/thumbprint.js +11 -5
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jwks/local.js +45 -53
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jwks/remote.js +82 -103
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jws/compact/sign.js +10 -9
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jws/flattened/sign.js +2 -1
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jws/flattened/verify.js +8 -7
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jws/general/sign.js +5 -3
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jws/general/verify.js +51 -21
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jwt/decrypt.js +7 -9
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jwt/encrypt.js +21 -50
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jwt/sign.js +8 -41
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jwt/unsecured.js +21 -42
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/key/generate_key_pair.js +6 -2
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/key/generate_secret.js +7 -6
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/key/import.js +16 -12
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/asn1.js +7 -2
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/content_encryption.js +7 -15
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/deflate.js +8 -0
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/helpers.js +1 -1
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/jwe_decrypt.js +85 -28
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/jwe_encrypt.js +40 -12
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/jwk_metadata.js +20 -0
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/jws_sign.js +47 -36
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/jws_verify.js +77 -45
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/jwt_claims_set.js +82 -47
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/key.js +24 -9
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/key_management.js +10 -4
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/key_options.js +6 -0
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/options.js +26 -0
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/type_checks.js +11 -13
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/package.json +1 -1
- package/node_modules/@posthog/core/dist/posthog-core-stateless.d.ts +12 -18
- package/node_modules/@posthog/core/dist/posthog-core-stateless.d.ts.map +1 -1
- package/node_modules/@posthog/core/dist/posthog-core-stateless.js +15 -47
- package/node_modules/@posthog/core/dist/posthog-core-stateless.mjs +15 -47
- package/node_modules/@posthog/core/dist/types.d.ts +4 -1
- package/node_modules/@posthog/core/dist/types.d.ts.map +1 -1
- package/node_modules/@posthog/core/package.json +2 -2
- package/node_modules/@posthog/core/src/logs/index.spec.ts +77 -0
- package/node_modules/@posthog/core/src/logs/index.ts +1 -1
- package/node_modules/@posthog/core/src/posthog-core-stateless.ts +40 -65
- package/node_modules/@posthog/core/src/types.ts +3 -1
- package/node_modules/@posthog/types/dist/index.d.ts +1 -1
- package/node_modules/@posthog/types/dist/index.d.ts.map +1 -1
- package/node_modules/@posthog/types/dist/posthog-config.d.ts +20 -5
- package/node_modules/@posthog/types/dist/posthog-config.d.ts.map +1 -1
- package/node_modules/@posthog/types/package.json +1 -1
- package/node_modules/@posthog/types/src/index.ts +1 -0
- package/node_modules/@posthog/types/src/posthog-config.ts +21 -5
- package/node_modules/@zuplo/core/customer.cli.minified.js +1 -1
- package/node_modules/@zuplo/core/index.minified.js +1 -1
- package/node_modules/@zuplo/core/package.json +1 -1
- package/node_modules/@zuplo/graphql/package.json +1 -1
- package/node_modules/@zuplo/openapi-tools/package.json +1 -1
- package/node_modules/@zuplo/otel/package.json +1 -1
- package/node_modules/@zuplo/runtime/out/esm/{chunk-IZE65N7D.js → chunk-CUK3VROF.js} +2 -2
- package/node_modules/@zuplo/runtime/out/esm/{chunk-4CDML74A.js → chunk-K4TBJG47.js} +2 -2
- package/node_modules/@zuplo/runtime/out/esm/{chunk-4VE55TG3.js → chunk-S4EBLGSU.js} +2 -2
- package/node_modules/@zuplo/runtime/out/esm/{chunk-4POCC75H.js → chunk-XF3IIUDX.js} +4 -4
- package/node_modules/@zuplo/runtime/out/esm/{chunk-4POCC75H.js.map → chunk-XF3IIUDX.js.map} +1 -1
- package/node_modules/@zuplo/runtime/out/esm/chunk-ZPOD3IK4.js +403 -0
- package/node_modules/@zuplo/runtime/out/esm/chunk-ZPOD3IK4.js.map +1 -0
- package/node_modules/@zuplo/runtime/out/esm/index.js +1 -1
- package/node_modules/@zuplo/runtime/out/esm/internal/index.js +1 -1
- package/node_modules/@zuplo/runtime/out/esm/mcp-gateway/index.js +1 -1
- package/node_modules/@zuplo/runtime/out/esm/mocks/index.js +1 -1
- package/node_modules/@zuplo/runtime/out/esm/sdks/aws/index.js +1 -1
- package/node_modules/@zuplo/runtime/package.json +1 -1
- package/node_modules/fast-uri/index.js +201 -48
- package/node_modules/fast-uri/lib/schemes.js +9 -4
- package/node_modules/fast-uri/lib/utils.js +388 -91
- package/node_modules/fast-uri/package.json +1 -1
- package/node_modules/fast-uri/test/component-safe-serialization.test.js +105 -0
- package/node_modules/fast-uri/test/equal.test.js +31 -3
- package/node_modules/fast-uri/test/fixtures/uri-js-parse.json +2 -0
- package/node_modules/fast-uri/test/ipv6-canonical.test.js +34 -0
- package/node_modules/fast-uri/test/ipv6-validation.test.js +90 -0
- package/node_modules/fast-uri/test/malformed-percent.test.js +77 -0
- package/node_modules/fast-uri/test/malformed-urn.test.js +61 -0
- package/node_modules/fast-uri/test/parse.test.js +7 -3
- package/node_modules/fast-uri/test/query-fragment-normalization.test.js +33 -0
- package/node_modules/fast-uri/test/reserved-path-normalization.test.js +109 -0
- package/node_modules/fast-uri/test/scheme-validation.test.js +124 -0
- package/node_modules/fast-uri/test/security-normalization.test.js +101 -0
- package/node_modules/fast-uri/test/security.test.js +75 -3
- package/node_modules/fast-uri/test/urn-full-input.test.js +29 -0
- package/node_modules/fast-uri/test/websocket-query-preservation.test.js +24 -0
- package/node_modules/hono/dist/cjs/client/client.js +25 -11
- package/node_modules/hono/dist/cjs/client/utils.js +3 -0
- package/node_modules/hono/dist/cjs/helper/accepts/accepts.js +36 -2
- package/node_modules/hono/dist/cjs/jsx/dom/render.js +2 -0
- package/node_modules/hono/dist/cjs/middleware/etag/index.js +1 -1
- package/node_modules/hono/dist/cjs/request.js +8 -4
- package/node_modules/hono/dist/cjs/router/reg-exp-router/node.js +10 -3
- package/node_modules/hono/dist/cjs/router/reg-exp-router/router.js +47 -83
- package/node_modules/hono/dist/cjs/router/reg-exp-router/trie.js +2 -1
- package/node_modules/hono/dist/cjs/router/trie-router/node.js +4 -3
- package/node_modules/hono/dist/cjs/router/utils.js +27 -0
- package/node_modules/hono/dist/cjs/utils/cookie.js +1 -1
- package/node_modules/hono/dist/cjs/utils/stream.js +7 -1
- package/node_modules/hono/dist/client/client.js +25 -11
- package/node_modules/hono/dist/client/utils.js +3 -0
- package/node_modules/hono/dist/helper/accepts/accepts.js +36 -2
- package/node_modules/hono/dist/jsx/dom/render.js +2 -0
- package/node_modules/hono/dist/middleware/etag/index.js +1 -1
- package/node_modules/hono/dist/request.js +8 -4
- package/node_modules/hono/dist/router/reg-exp-router/node.js +6 -2
- package/node_modules/hono/dist/router/reg-exp-router/router.js +53 -84
- package/node_modules/hono/dist/router/reg-exp-router/trie.js +2 -1
- package/node_modules/hono/dist/router/trie-router/node.js +4 -3
- package/node_modules/hono/dist/router/utils.js +5 -0
- package/node_modules/hono/dist/types/router/reg-exp-router/node.d.ts +3 -0
- package/node_modules/hono/dist/types/router/utils.d.ts +1 -0
- package/node_modules/hono/dist/utils/cookie.js +1 -1
- package/node_modules/hono/dist/utils/stream.js +7 -1
- package/node_modules/hono/package.json +1 -1
- package/package.json +11 -11
- package/node_modules/@zuplo/runtime/out/esm/chunk-4SX4HBWT.js +0 -409
- package/node_modules/@zuplo/runtime/out/esm/chunk-4SX4HBWT.js.map +0 -1
- /package/node_modules/@zuplo/runtime/out/esm/{chunk-IZE65N7D.js.map → chunk-CUK3VROF.js.map} +0 -0
- /package/node_modules/@zuplo/runtime/out/esm/{chunk-4CDML74A.js.map → chunk-K4TBJG47.js.map} +0 -0
- /package/node_modules/@zuplo/runtime/out/esm/{chunk-4VE55TG3.js.map → chunk-S4EBLGSU.js.map} +0 -0
- /package/node_modules/@zuplo/runtime/out/esm/{chunk-4POCC75H.js.LEGAL.txt → chunk-XF3IIUDX.js.LEGAL.txt} +0 -0
- /package/node_modules/@zuplo/runtime/out/esm/{chunk-4SX4HBWT.js.LEGAL.txt → chunk-ZPOD3IK4.js.LEGAL.txt} +0 -0
package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/jwks/remote.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { JOSEError, JWKSNoMatchingKey, JWKSTimeout } from '../util/errors.js';
|
|
2
2
|
import { createLocalJWKSet } from './local.js';
|
|
3
|
-
import {
|
|
3
|
+
import { isJwkSet } from '../lib/type_checks.js';
|
|
4
4
|
function isCloudflareWorkers() {
|
|
5
5
|
return (typeof WebSocketPair !== 'undefined' ||
|
|
6
6
|
(typeof navigator !== 'undefined' && navigator.userAgent === 'Cloudflare-Workers') ||
|
|
@@ -9,7 +9,7 @@ function isCloudflareWorkers() {
|
|
|
9
9
|
let USER_AGENT;
|
|
10
10
|
if (typeof navigator === 'undefined' || !navigator.userAgent?.startsWith?.('Mozilla/5.0 ')) {
|
|
11
11
|
const NAME = 'jose';
|
|
12
|
-
const VERSION = 'v6.2.
|
|
12
|
+
const VERSION = 'v6.2.10';
|
|
13
13
|
USER_AGENT = `${NAME}/${VERSION}`;
|
|
14
14
|
}
|
|
15
15
|
export const customFetch = Symbol();
|
|
@@ -36,135 +36,114 @@ async function fetchJwks(url, headers, signal, fetchImpl = fetch) {
|
|
|
36
36
|
}
|
|
37
37
|
}
|
|
38
38
|
export const jwksCache = Symbol();
|
|
39
|
-
function
|
|
40
|
-
|
|
41
|
-
return false;
|
|
42
|
-
}
|
|
43
|
-
if (!('uat' in input) || typeof input.uat !== 'number' || Date.now() - input.uat >= cacheMaxAge) {
|
|
44
|
-
return false;
|
|
45
|
-
}
|
|
46
|
-
if (!('jwks' in input) ||
|
|
47
|
-
!isObject(input.jwks) ||
|
|
48
|
-
!Array.isArray(input.jwks.keys) ||
|
|
49
|
-
!Array.prototype.every.call(input.jwks.keys, isObject)) {
|
|
50
|
-
return false;
|
|
51
|
-
}
|
|
52
|
-
return true;
|
|
39
|
+
function isFreshFor(timestamp, duration) {
|
|
40
|
+
return Number.isFinite(timestamp) && Date.now() < timestamp + duration;
|
|
53
41
|
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
#cooldownDuration;
|
|
58
|
-
#cacheMaxAge;
|
|
59
|
-
#jwksTimestamp;
|
|
60
|
-
#pendingFetch;
|
|
61
|
-
#headers;
|
|
62
|
-
#customFetch;
|
|
63
|
-
#local;
|
|
64
|
-
#cache;
|
|
65
|
-
constructor(url, options) {
|
|
66
|
-
if (!(url instanceof URL)) {
|
|
67
|
-
throw new TypeError('url must be an instance of URL');
|
|
68
|
-
}
|
|
69
|
-
this.#url = new URL(url.href);
|
|
70
|
-
const opts = options ?? {};
|
|
71
|
-
this.#timeoutDuration = typeof opts.timeoutDuration === 'number' ? opts.timeoutDuration : 5000;
|
|
72
|
-
this.#cooldownDuration =
|
|
73
|
-
typeof opts.cooldownDuration === 'number' ? opts.cooldownDuration : 30000;
|
|
74
|
-
this.#cacheMaxAge = typeof opts.cacheMaxAge === 'number' ? opts.cacheMaxAge : 600000;
|
|
75
|
-
this.#headers = new Headers(opts.headers);
|
|
76
|
-
if (USER_AGENT && !this.#headers.has('User-Agent')) {
|
|
77
|
-
this.#headers.set('User-Agent', USER_AGENT);
|
|
78
|
-
}
|
|
79
|
-
if (!this.#headers.has('accept')) {
|
|
80
|
-
this.#headers.set('accept', 'application/json');
|
|
81
|
-
this.#headers.append('accept', 'application/jwk-set+json');
|
|
82
|
-
}
|
|
83
|
-
this.#customFetch = opts[customFetch];
|
|
84
|
-
const cache = opts[jwksCache];
|
|
85
|
-
if (cache !== undefined) {
|
|
86
|
-
this.#cache = cache;
|
|
87
|
-
if (isFreshJwksCache(cache, this.#cacheMaxAge)) {
|
|
88
|
-
this.#jwksTimestamp = this.#cache.uat;
|
|
89
|
-
this.#local = createLocalJWKSet(this.#cache.jwks);
|
|
90
|
-
}
|
|
91
|
-
}
|
|
42
|
+
function validateDuration(value, fallback, option) {
|
|
43
|
+
if (Number.isNaN(value)) {
|
|
44
|
+
throw new TypeError(`"${option}" option must not be NaN`);
|
|
92
45
|
}
|
|
93
|
-
|
|
94
|
-
|
|
46
|
+
return typeof value === 'number' ? value : fallback;
|
|
47
|
+
}
|
|
48
|
+
export function createRemoteJWKSet(url, options) {
|
|
49
|
+
if (!(url instanceof URL)) {
|
|
50
|
+
throw new TypeError('url must be an instance of URL');
|
|
95
51
|
}
|
|
96
|
-
|
|
97
|
-
|
|
52
|
+
const href = new URL(url.href).href;
|
|
53
|
+
const opts = options ?? {};
|
|
54
|
+
const timeoutOption = opts.timeoutDuration;
|
|
55
|
+
if (typeof timeoutOption === 'number' &&
|
|
56
|
+
(!Number.isInteger(timeoutOption) || timeoutOption < 0)) {
|
|
57
|
+
throw new TypeError('"timeoutDuration" option must be a non-negative integer');
|
|
98
58
|
}
|
|
99
|
-
|
|
100
|
-
|
|
59
|
+
const timeoutDuration = typeof timeoutOption === 'number' ? timeoutOption : 5000;
|
|
60
|
+
const cooldownDuration = validateDuration(opts.cooldownDuration, 30000, 'cooldownDuration');
|
|
61
|
+
const cacheMaxAge = validateDuration(opts.cacheMaxAge, 600000, 'cacheMaxAge');
|
|
62
|
+
const headers = new Headers(opts.headers);
|
|
63
|
+
if (USER_AGENT && !headers.has('User-Agent')) {
|
|
64
|
+
headers.set('User-Agent', USER_AGENT);
|
|
101
65
|
}
|
|
102
|
-
|
|
103
|
-
|
|
66
|
+
if (!headers.has('accept')) {
|
|
67
|
+
headers.set('accept', 'application/json, application/jwk-set+json');
|
|
104
68
|
}
|
|
105
|
-
|
|
106
|
-
|
|
69
|
+
const fetchImpl = opts[customFetch];
|
|
70
|
+
const cache = opts[jwksCache];
|
|
71
|
+
let jwksTimestamp;
|
|
72
|
+
let pendingFetch;
|
|
73
|
+
let reloadSequence = 0;
|
|
74
|
+
let appliedSequence = 0;
|
|
75
|
+
let local;
|
|
76
|
+
if (cache && typeof cache === 'object') {
|
|
77
|
+
const { uat, jwks } = cache;
|
|
78
|
+
if (isFreshFor(uat, cacheMaxAge) && isJwkSet(jwks)) {
|
|
79
|
+
jwksTimestamp = uat;
|
|
80
|
+
local = createLocalJWKSet(jwks);
|
|
81
|
+
}
|
|
107
82
|
}
|
|
108
|
-
async
|
|
109
|
-
if (
|
|
110
|
-
|
|
83
|
+
const reload = async () => {
|
|
84
|
+
if (pendingFetch && isCloudflareWorkers()) {
|
|
85
|
+
pendingFetch = undefined;
|
|
86
|
+
}
|
|
87
|
+
if (!pendingFetch) {
|
|
88
|
+
const sequence = ++reloadSequence;
|
|
89
|
+
const current = (pendingFetch = fetchJwks(href, headers, AbortSignal.timeout(timeoutDuration), fetchImpl)
|
|
90
|
+
.then((json) => {
|
|
91
|
+
const next = createLocalJWKSet(json);
|
|
92
|
+
if (sequence <= appliedSequence) {
|
|
93
|
+
return;
|
|
94
|
+
}
|
|
95
|
+
local = next;
|
|
96
|
+
const updatedAt = Date.now();
|
|
97
|
+
if (cache) {
|
|
98
|
+
cache.uat = updatedAt;
|
|
99
|
+
cache.jwks = json;
|
|
100
|
+
}
|
|
101
|
+
jwksTimestamp = updatedAt;
|
|
102
|
+
appliedSequence = sequence;
|
|
103
|
+
})
|
|
104
|
+
.finally(() => {
|
|
105
|
+
if (pendingFetch === current) {
|
|
106
|
+
pendingFetch = undefined;
|
|
107
|
+
}
|
|
108
|
+
}));
|
|
109
|
+
}
|
|
110
|
+
await pendingFetch;
|
|
111
|
+
};
|
|
112
|
+
const remoteJWKSet = async (protectedHeader, token) => {
|
|
113
|
+
if (!local || !isFreshFor(jwksTimestamp, cacheMaxAge)) {
|
|
114
|
+
await reload();
|
|
111
115
|
}
|
|
112
116
|
try {
|
|
113
|
-
return await
|
|
117
|
+
return await local(protectedHeader, token);
|
|
114
118
|
}
|
|
115
119
|
catch (err) {
|
|
116
|
-
if (err instanceof JWKSNoMatchingKey) {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
return this.#local(protectedHeader, token);
|
|
120
|
-
}
|
|
120
|
+
if (err instanceof JWKSNoMatchingKey && !isFreshFor(jwksTimestamp, cooldownDuration)) {
|
|
121
|
+
await reload();
|
|
122
|
+
return local(protectedHeader, token);
|
|
121
123
|
}
|
|
122
124
|
throw err;
|
|
123
125
|
}
|
|
124
|
-
}
|
|
125
|
-
|
|
126
|
-
if (this.#pendingFetch && isCloudflareWorkers()) {
|
|
127
|
-
this.#pendingFetch = undefined;
|
|
128
|
-
}
|
|
129
|
-
this.#pendingFetch ||= fetchJwks(this.#url.href, this.#headers, AbortSignal.timeout(this.#timeoutDuration), this.#customFetch)
|
|
130
|
-
.then((json) => {
|
|
131
|
-
this.#local = createLocalJWKSet(json);
|
|
132
|
-
if (this.#cache) {
|
|
133
|
-
this.#cache.uat = Date.now();
|
|
134
|
-
this.#cache.jwks = json;
|
|
135
|
-
}
|
|
136
|
-
this.#jwksTimestamp = Date.now();
|
|
137
|
-
})
|
|
138
|
-
.finally(() => {
|
|
139
|
-
this.#pendingFetch = undefined;
|
|
140
|
-
});
|
|
141
|
-
await this.#pendingFetch;
|
|
142
|
-
}
|
|
143
|
-
}
|
|
144
|
-
export function createRemoteJWKSet(url, options) {
|
|
145
|
-
const set = new RemoteJWKSetImpl(url, options);
|
|
146
|
-
const remoteJWKSet = async (protectedHeader, token) => set.getKey(protectedHeader, token);
|
|
147
|
-
Object.defineProperties(remoteJWKSet, {
|
|
126
|
+
};
|
|
127
|
+
return Object.defineProperties(remoteJWKSet, {
|
|
148
128
|
coolingDown: {
|
|
149
|
-
get: () =>
|
|
129
|
+
get: () => isFreshFor(jwksTimestamp, cooldownDuration),
|
|
150
130
|
enumerable: true,
|
|
151
131
|
},
|
|
152
132
|
fresh: {
|
|
153
|
-
get: () =>
|
|
133
|
+
get: () => isFreshFor(jwksTimestamp, cacheMaxAge),
|
|
154
134
|
enumerable: true,
|
|
155
135
|
},
|
|
156
136
|
reload: {
|
|
157
|
-
value:
|
|
137
|
+
value: reload,
|
|
158
138
|
enumerable: true,
|
|
159
139
|
},
|
|
160
140
|
reloading: {
|
|
161
|
-
get: () =>
|
|
141
|
+
get: () => !!pendingFetch,
|
|
162
142
|
enumerable: true,
|
|
163
143
|
},
|
|
164
144
|
jwks: {
|
|
165
|
-
value: () =>
|
|
145
|
+
value: () => local?.jwks(),
|
|
166
146
|
enumerable: true,
|
|
167
147
|
},
|
|
168
148
|
});
|
|
169
|
-
return remoteJWKSet;
|
|
170
149
|
}
|
package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/jws/compact/sign.js
CHANGED
|
@@ -1,21 +1,22 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { createCompactSignature } from '../../lib/jws_sign.js';
|
|
2
|
+
import { assertNotSet } from '../../lib/helpers.js';
|
|
3
3
|
export class CompactSign {
|
|
4
|
-
#
|
|
4
|
+
#payload;
|
|
5
5
|
#protectedHeader;
|
|
6
6
|
constructor(payload) {
|
|
7
|
-
|
|
7
|
+
if (!(payload instanceof Uint8Array)) {
|
|
8
|
+
throw new TypeError('payload must be an instance of Uint8Array');
|
|
9
|
+
}
|
|
10
|
+
this.#payload = payload;
|
|
8
11
|
}
|
|
9
12
|
setProtectedHeader(protectedHeader) {
|
|
10
|
-
this.#
|
|
13
|
+
assertNotSet(this.#protectedHeader, 'setProtectedHeader');
|
|
11
14
|
this.#protectedHeader = protectedHeader;
|
|
12
15
|
return this;
|
|
13
16
|
}
|
|
14
17
|
async sign(key, options) {
|
|
15
|
-
|
|
18
|
+
return createCompactSignature(this.#payload, this.#protectedHeader, options?.crit, key, () => {
|
|
16
19
|
throw new TypeError('use the flattened module for creating JWS with b64: false');
|
|
17
|
-
}
|
|
18
|
-
const jws = await this.#flattened.sign(key, options);
|
|
19
|
-
return `${jws.protected}.${jws.payload}.${jws.signature}`;
|
|
20
|
+
});
|
|
20
21
|
}
|
|
21
22
|
}
|
|
@@ -21,11 +21,12 @@ export class FlattenedSign {
|
|
|
21
21
|
return this;
|
|
22
22
|
}
|
|
23
23
|
async sign(key, options) {
|
|
24
|
-
|
|
24
|
+
const [jws] = await createSignature({
|
|
25
25
|
payload: this.#payload,
|
|
26
26
|
protectedHeader: this.#protectedHeader,
|
|
27
27
|
unprotectedHeader: this.#unprotectedHeader,
|
|
28
28
|
crit: options?.crit,
|
|
29
29
|
}, key);
|
|
30
|
+
return jws;
|
|
30
31
|
}
|
|
31
32
|
}
|
|
@@ -1,24 +1,25 @@
|
|
|
1
1
|
import { JWSInvalid } from '../../util/errors.js';
|
|
2
2
|
import { isObject } from '../../lib/type_checks.js';
|
|
3
|
-
import { prepareVerify, verifySignature, verifyResult } from '../../lib/jws_verify.js';
|
|
3
|
+
import { encodeJsonUnencodedPayload, prepareVerify, snapshotJws, verifySignature, verifyResult, } from '../../lib/jws_verify.js';
|
|
4
4
|
export async function flattenedVerify(jws, key, options) {
|
|
5
5
|
if (!isObject(jws)) {
|
|
6
6
|
throw new JWSInvalid('Flattened JWS must be an object');
|
|
7
7
|
}
|
|
8
|
-
|
|
8
|
+
const snapshot = snapshotJws(jws);
|
|
9
|
+
if (snapshot.protected === undefined && snapshot.header === undefined) {
|
|
9
10
|
throw new JWSInvalid('Flattened JWS must have either of the "protected" or "header" members');
|
|
10
11
|
}
|
|
11
|
-
if (
|
|
12
|
+
if (snapshot.protected !== undefined && typeof snapshot.protected !== 'string') {
|
|
12
13
|
throw new JWSInvalid('JWS Protected Header incorrect type');
|
|
13
14
|
}
|
|
14
|
-
if (
|
|
15
|
+
if (snapshot.payload === undefined) {
|
|
15
16
|
throw new JWSInvalid('JWS Payload missing');
|
|
16
17
|
}
|
|
17
|
-
if (typeof
|
|
18
|
+
if (typeof snapshot.signature !== 'string') {
|
|
18
19
|
throw new JWSInvalid('JWS Signature missing or incorrect type');
|
|
19
20
|
}
|
|
20
|
-
if (
|
|
21
|
+
if (snapshot.header !== undefined && !isObject(snapshot.header)) {
|
|
21
22
|
throw new JWSInvalid('JWS Unprotected Header incorrect type');
|
|
22
23
|
}
|
|
23
|
-
return verifyResult(
|
|
24
|
+
return verifyResult(snapshot, await verifySignature(snapshot, prepareVerify(options), key, encodeJsonUnencodedPayload));
|
|
24
25
|
}
|
package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/jws/general/sign.js
CHANGED
|
@@ -51,20 +51,22 @@ export class GeneralSign {
|
|
|
51
51
|
payload: '',
|
|
52
52
|
};
|
|
53
53
|
const encoded = [];
|
|
54
|
+
let b64;
|
|
54
55
|
for (let i = 0; i < this.#signatures.length; i++) {
|
|
55
56
|
const signature = this.#signatures[i];
|
|
56
57
|
const [protectedHeader, unprotectedHeader, key, crit] = signature.state;
|
|
57
|
-
const { payload, ...rest } = await createSignature({
|
|
58
|
+
const [{ payload, ...rest }, signatureB64] = await createSignature({
|
|
58
59
|
payload: this.#payload,
|
|
59
60
|
protectedHeader,
|
|
60
61
|
unprotectedHeader,
|
|
61
62
|
crit,
|
|
62
63
|
encoded,
|
|
63
64
|
}, key);
|
|
64
|
-
if (
|
|
65
|
+
if (b64 === undefined) {
|
|
66
|
+
b64 = signatureB64;
|
|
65
67
|
jws.payload = payload;
|
|
66
68
|
}
|
|
67
|
-
else if (
|
|
69
|
+
else if (b64 !== signatureB64) {
|
|
68
70
|
throw new JWSInvalid('inconsistent use of JWS Unencoded Payload (RFC7797)');
|
|
69
71
|
}
|
|
70
72
|
jws.signatures.push(rest);
|
|
@@ -1,41 +1,71 @@
|
|
|
1
|
-
import { prepareVerify, verifySignature, verifyResult } from '../../lib/jws_verify.js';
|
|
1
|
+
import { encodeJsonUnencodedPayload, parseProtectedHeader, prepareVerify, snapshotJws, verifySignature, verifyResult, } from '../../lib/jws_verify.js';
|
|
2
2
|
import { JWSInvalid, JWSSignatureVerificationFailed } from '../../util/errors.js';
|
|
3
3
|
import { isObject } from '../../lib/type_checks.js';
|
|
4
|
+
function snapshotSignature(signature, payload) {
|
|
5
|
+
try {
|
|
6
|
+
const jws = snapshotJws(signature, [payload]);
|
|
7
|
+
const { protected: encodedProtected, header, signature: encodedSignature } = jws;
|
|
8
|
+
if (encodedProtected === undefined && header === undefined)
|
|
9
|
+
return undefined;
|
|
10
|
+
if (encodedProtected !== undefined && typeof encodedProtected !== 'string')
|
|
11
|
+
return undefined;
|
|
12
|
+
if (typeof encodedSignature !== 'string')
|
|
13
|
+
return undefined;
|
|
14
|
+
if (header !== undefined && !isObject(header))
|
|
15
|
+
return undefined;
|
|
16
|
+
const protectedHeader = parseProtectedHeader(encodedProtected);
|
|
17
|
+
const { b64, crit } = protectedHeader;
|
|
18
|
+
return [
|
|
19
|
+
jws,
|
|
20
|
+
protectedHeader,
|
|
21
|
+
Array.isArray(crit) && crit.includes('b64')
|
|
22
|
+
? typeof b64 === 'boolean'
|
|
23
|
+
? b64
|
|
24
|
+
? 1
|
|
25
|
+
: 2
|
|
26
|
+
: 0
|
|
27
|
+
: 1,
|
|
28
|
+
];
|
|
29
|
+
}
|
|
30
|
+
catch {
|
|
31
|
+
return undefined;
|
|
32
|
+
}
|
|
33
|
+
}
|
|
4
34
|
export async function generalVerify(jws, key, options) {
|
|
5
35
|
if (!isObject(jws)) {
|
|
6
36
|
throw new JWSInvalid('General JWS must be an object');
|
|
7
37
|
}
|
|
8
|
-
const { signatures, payload } = jws;
|
|
9
|
-
if (!Array.isArray(signatures)
|
|
38
|
+
const { signatures, payload: inputPayload } = jws;
|
|
39
|
+
if (!Array.isArray(signatures)) {
|
|
40
|
+
throw new JWSInvalid('JWS Signatures missing or incorrect type');
|
|
41
|
+
}
|
|
42
|
+
const signatureEntries = Array.from(signatures);
|
|
43
|
+
if (!signatureEntries.every(isObject)) {
|
|
10
44
|
throw new JWSInvalid('JWS Signatures missing or incorrect type');
|
|
11
45
|
}
|
|
12
46
|
let shared;
|
|
13
47
|
try {
|
|
14
|
-
if (
|
|
48
|
+
if (inputPayload === undefined)
|
|
15
49
|
throw new Error();
|
|
16
50
|
shared = prepareVerify(options);
|
|
17
51
|
}
|
|
18
52
|
catch {
|
|
19
53
|
throw new JWSSignatureVerificationFailed();
|
|
20
54
|
}
|
|
21
|
-
|
|
55
|
+
const payload = inputPayload instanceof Uint8Array ? new Uint8Array(inputPayload) : inputPayload;
|
|
56
|
+
const candidates = signatureEntries
|
|
57
|
+
.map((signature) => snapshotSignature(signature, payload))
|
|
58
|
+
.filter((candidate) => candidate !== undefined);
|
|
59
|
+
let modes = 0;
|
|
60
|
+
for (const [, , mode] of candidates) {
|
|
61
|
+
modes |= mode;
|
|
62
|
+
if (modes === 3) {
|
|
63
|
+
throw new JWSInvalid('inconsistent use of JWS Unencoded Payload (RFC7797)');
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
for (const candidate of candidates) {
|
|
22
67
|
try {
|
|
23
|
-
|
|
24
|
-
if (encodedProtected === undefined && header === undefined)
|
|
25
|
-
throw new Error();
|
|
26
|
-
if (encodedProtected !== undefined && typeof encodedProtected !== 'string') {
|
|
27
|
-
throw new Error();
|
|
28
|
-
}
|
|
29
|
-
if (typeof encodedSignature !== 'string')
|
|
30
|
-
throw new Error();
|
|
31
|
-
if (header !== undefined && !isObject(header))
|
|
32
|
-
throw new Error();
|
|
33
|
-
return verifyResult(signature, await verifySignature({
|
|
34
|
-
header,
|
|
35
|
-
payload,
|
|
36
|
-
protected: encodedProtected,
|
|
37
|
-
signature: encodedSignature,
|
|
38
|
-
}, shared, key));
|
|
68
|
+
return verifyResult(candidate[0], await verifySignature(candidate[0], shared, key, encodeJsonUnencodedPayload, candidate[1]));
|
|
39
69
|
}
|
|
40
70
|
catch {
|
|
41
71
|
}
|
package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/jwt/decrypt.js
CHANGED
|
@@ -5,15 +5,13 @@ export async function jwtDecrypt(jwt, key, options) {
|
|
|
5
5
|
const decrypted = await decryptCompact(jwt, prepareDecrypt(options), key);
|
|
6
6
|
const protectedHeader = decrypted[1];
|
|
7
7
|
const payload = validateClaimsSet(protectedHeader, decrypted[0], options);
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
JSON.stringify(protectedHeader.aud) !== JSON.stringify(payload.aud)) {
|
|
16
|
-
throw new JWTClaimValidationFailed('replicated "aud" claim header parameter mismatch', payload, 'aud', 'mismatch');
|
|
8
|
+
for (const claim of ['iss', 'sub', 'aud']) {
|
|
9
|
+
if (protectedHeader[claim] !== undefined &&
|
|
10
|
+
(claim === 'aud'
|
|
11
|
+
? JSON.stringify(protectedHeader.aud) !== JSON.stringify(payload.aud)
|
|
12
|
+
: protectedHeader[claim] !== payload[claim])) {
|
|
13
|
+
throw new JWTClaimValidationFailed(`replicated "${claim}" claim header parameter mismatch`, payload, claim, 'mismatch');
|
|
14
|
+
}
|
|
17
15
|
}
|
|
18
16
|
const result = { payload, protectedHeader };
|
|
19
17
|
if (typeof key === 'function') {
|
package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/jwt/encrypt.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { JWTClaimsBuilder } from '../lib/jwt_claims_set.js';
|
|
1
|
+
import { createJWE } from '../lib/jwe_encrypt.js';
|
|
2
|
+
import { JWTClaimsBuilder, jwtClaim, jwtData } from '../lib/jwt_claims_set.js';
|
|
3
3
|
import { assertNotSet } from '../lib/helpers.js';
|
|
4
|
-
|
|
4
|
+
const EncryptJWT_base = JWTClaimsBuilder;
|
|
5
|
+
export class EncryptJWT extends EncryptJWT_base {
|
|
5
6
|
#cek;
|
|
6
7
|
#iv;
|
|
7
8
|
#keyManagementParameters;
|
|
@@ -9,38 +10,6 @@ export class EncryptJWT {
|
|
|
9
10
|
#replicateIssuerAsHeader;
|
|
10
11
|
#replicateSubjectAsHeader;
|
|
11
12
|
#replicateAudienceAsHeader;
|
|
12
|
-
#jwt;
|
|
13
|
-
constructor(payload = {}) {
|
|
14
|
-
this.#jwt = new JWTClaimsBuilder(payload);
|
|
15
|
-
}
|
|
16
|
-
setIssuer(issuer) {
|
|
17
|
-
this.#jwt.iss = issuer;
|
|
18
|
-
return this;
|
|
19
|
-
}
|
|
20
|
-
setSubject(subject) {
|
|
21
|
-
this.#jwt.sub = subject;
|
|
22
|
-
return this;
|
|
23
|
-
}
|
|
24
|
-
setAudience(audience) {
|
|
25
|
-
this.#jwt.aud = audience;
|
|
26
|
-
return this;
|
|
27
|
-
}
|
|
28
|
-
setJti(jwtId) {
|
|
29
|
-
this.#jwt.jti = jwtId;
|
|
30
|
-
return this;
|
|
31
|
-
}
|
|
32
|
-
setNotBefore(input) {
|
|
33
|
-
this.#jwt.nbf = input;
|
|
34
|
-
return this;
|
|
35
|
-
}
|
|
36
|
-
setExpirationTime(input) {
|
|
37
|
-
this.#jwt.exp = input;
|
|
38
|
-
return this;
|
|
39
|
-
}
|
|
40
|
-
setIssuedAt(input) {
|
|
41
|
-
this.#jwt.iat = input;
|
|
42
|
-
return this;
|
|
43
|
-
}
|
|
44
13
|
setProtectedHeader(protectedHeader) {
|
|
45
14
|
assertNotSet(this.#protectedHeader, 'setProtectedHeader');
|
|
46
15
|
this.#protectedHeader = protectedHeader;
|
|
@@ -74,28 +43,30 @@ export class EncryptJWT {
|
|
|
74
43
|
return this;
|
|
75
44
|
}
|
|
76
45
|
async encrypt(key, options) {
|
|
77
|
-
const
|
|
46
|
+
const plaintext = jwtData(this);
|
|
78
47
|
if (this.#protectedHeader &&
|
|
79
48
|
(this.#replicateIssuerAsHeader ||
|
|
80
49
|
this.#replicateSubjectAsHeader ||
|
|
81
50
|
this.#replicateAudienceAsHeader)) {
|
|
82
51
|
this.#protectedHeader = {
|
|
83
52
|
...this.#protectedHeader,
|
|
84
|
-
iss: this.#replicateIssuerAsHeader ? this
|
|
85
|
-
sub: this.#replicateSubjectAsHeader ? this
|
|
86
|
-
aud: this.#replicateAudienceAsHeader ? this
|
|
53
|
+
iss: this.#replicateIssuerAsHeader ? jwtClaim(this, 'iss') : undefined,
|
|
54
|
+
sub: this.#replicateSubjectAsHeader ? jwtClaim(this, 'sub') : undefined,
|
|
55
|
+
aud: this.#replicateAudienceAsHeader ? jwtClaim(this, 'aud') : undefined,
|
|
87
56
|
};
|
|
88
57
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
58
|
+
const jwe = await createJWE([
|
|
59
|
+
plaintext,
|
|
60
|
+
this.#protectedHeader,
|
|
61
|
+
undefined,
|
|
62
|
+
undefined,
|
|
63
|
+
undefined,
|
|
64
|
+
this.#cek,
|
|
65
|
+
this.#iv,
|
|
66
|
+
this.#keyManagementParameters,
|
|
67
|
+
undefined,
|
|
68
|
+
false,
|
|
69
|
+
], key, options);
|
|
70
|
+
return [jwe.protected, jwe.encrypted_key, jwe.iv, jwe.ciphertext, jwe.tag].join('.');
|
|
100
71
|
}
|
|
101
72
|
}
|
|
@@ -1,51 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { unencodedPayload } from '../lib/jws_sign.js';
|
|
1
|
+
import { createCompactSignature } from '../lib/jws_sign.js';
|
|
3
2
|
import { JWTInvalid } from '../util/errors.js';
|
|
4
|
-
import { JWTClaimsBuilder } from '../lib/jwt_claims_set.js';
|
|
5
|
-
|
|
3
|
+
import { JWTClaimsBuilder, jwtData } from '../lib/jwt_claims_set.js';
|
|
4
|
+
import { assertNotSet } from '../lib/helpers.js';
|
|
5
|
+
const SignJWT_base = JWTClaimsBuilder;
|
|
6
|
+
export class SignJWT extends SignJWT_base {
|
|
6
7
|
#protectedHeader;
|
|
7
|
-
#jwt;
|
|
8
|
-
constructor(payload = {}) {
|
|
9
|
-
this.#jwt = new JWTClaimsBuilder(payload);
|
|
10
|
-
}
|
|
11
|
-
setIssuer(issuer) {
|
|
12
|
-
this.#jwt.iss = issuer;
|
|
13
|
-
return this;
|
|
14
|
-
}
|
|
15
|
-
setSubject(subject) {
|
|
16
|
-
this.#jwt.sub = subject;
|
|
17
|
-
return this;
|
|
18
|
-
}
|
|
19
|
-
setAudience(audience) {
|
|
20
|
-
this.#jwt.aud = audience;
|
|
21
|
-
return this;
|
|
22
|
-
}
|
|
23
|
-
setJti(jwtId) {
|
|
24
|
-
this.#jwt.jti = jwtId;
|
|
25
|
-
return this;
|
|
26
|
-
}
|
|
27
|
-
setNotBefore(input) {
|
|
28
|
-
this.#jwt.nbf = input;
|
|
29
|
-
return this;
|
|
30
|
-
}
|
|
31
|
-
setExpirationTime(input) {
|
|
32
|
-
this.#jwt.exp = input;
|
|
33
|
-
return this;
|
|
34
|
-
}
|
|
35
|
-
setIssuedAt(input) {
|
|
36
|
-
this.#jwt.iat = input;
|
|
37
|
-
return this;
|
|
38
|
-
}
|
|
39
8
|
setProtectedHeader(protectedHeader) {
|
|
9
|
+
assertNotSet(this.#protectedHeader, 'setProtectedHeader');
|
|
40
10
|
this.#protectedHeader = protectedHeader;
|
|
41
11
|
return this;
|
|
42
12
|
}
|
|
43
13
|
async sign(key, options) {
|
|
44
|
-
|
|
45
|
-
sig.setProtectedHeader(this.#protectedHeader);
|
|
46
|
-
if (unencodedPayload(this.#protectedHeader)) {
|
|
14
|
+
return createCompactSignature(jwtData(this), this.#protectedHeader, options?.crit, key, () => {
|
|
47
15
|
throw new JWTInvalid('JWTs MUST NOT use unencoded payload');
|
|
48
|
-
}
|
|
49
|
-
return sig.sign(key, options);
|
|
16
|
+
});
|
|
50
17
|
}
|
|
51
18
|
}
|