@zuplo/cli 7.4.4 → 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/dist/common/settings.d.ts +1 -0
- package/dist/common/settings.d.ts.map +1 -1
- package/dist/common/settings.js +3 -0
- package/dist/common/settings.js.map +1 -1
- package/dist/deploy/classify-build-probe.d.ts +14 -0
- package/dist/deploy/classify-build-probe.d.ts.map +1 -0
- package/dist/deploy/classify-build-probe.js +35 -0
- package/dist/deploy/classify-build-probe.js.map +1 -0
- package/dist/deploy/classify-build-probe.test.d.ts +2 -0
- package/dist/deploy/classify-build-probe.test.d.ts.map +1 -0
- package/dist/deploy/classify-build-probe.test.js +51 -0
- package/dist/deploy/classify-build-probe.test.js.map +1 -0
- package/dist/deploy/handler.js +20 -5
- package/dist/deploy/handler.js.map +1 -1
- package/dist/deploy/poll-deployment.d.ts +8 -4
- package/dist/deploy/poll-deployment.d.ts.map +1 -1
- package/dist/deploy/poll-deployment.js +32 -4
- package/dist/deploy/poll-deployment.js.map +1 -1
- package/dist/deploy/poll-deployment.test.d.ts +2 -0
- package/dist/deploy/poll-deployment.test.d.ts.map +1 -0
- package/dist/deploy/poll-deployment.test.js +158 -0
- package/dist/deploy/poll-deployment.test.js.map +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -1
- 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/logs/index.js +1 -1
- package/node_modules/@posthog/core/dist/logs/index.mjs +1 -1
- package/node_modules/@posthog/core/dist/logs/logs-utils.d.ts +4 -13
- package/node_modules/@posthog/core/dist/logs/logs-utils.d.ts.map +1 -1
- package/node_modules/@posthog/core/dist/logs/logs-utils.js +160 -26
- package/node_modules/@posthog/core/dist/logs/logs-utils.mjs +160 -26
- package/node_modules/@posthog/core/dist/metrics/index.js +1 -1
- package/node_modules/@posthog/core/dist/metrics/index.mjs +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/posthog-core.d.ts.map +1 -1
- package/node_modules/@posthog/core/dist/posthog-core.js +12 -7
- package/node_modules/@posthog/core/dist/posthog-core.mjs +12 -7
- 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/dist/utils/index.d.ts +1 -1
- package/node_modules/@posthog/core/dist/utils/index.d.ts.map +1 -1
- package/node_modules/@posthog/core/dist/utils/index.js +14 -24
- package/node_modules/@posthog/core/dist/utils/index.mjs +2 -2
- package/node_modules/@posthog/core/dist/utils/json-utils.d.ts +15 -0
- package/node_modules/@posthog/core/dist/utils/json-utils.d.ts.map +1 -1
- package/node_modules/@posthog/core/dist/utils/json-utils.js +24 -0
- package/node_modules/@posthog/core/dist/utils/json-utils.mjs +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 +2 -2
- package/node_modules/@posthog/core/src/logs/logs-utils.spec.ts +314 -9
- package/node_modules/@posthog/core/src/logs/logs-utils.ts +215 -27
- package/node_modules/@posthog/core/src/metrics/index.spec.ts +15 -1
- package/node_modules/@posthog/core/src/metrics/index.ts +1 -1
- package/node_modules/@posthog/core/src/posthog-core-stateless.ts +40 -65
- package/node_modules/@posthog/core/src/posthog-core.ts +19 -12
- package/node_modules/@posthog/core/src/types.ts +3 -1
- package/node_modules/@posthog/core/src/utils/index.ts +3 -1
- package/node_modules/@posthog/core/src/utils/json-utils.ts +15 -8
- package/node_modules/@posthog/types/dist/capture-log.d.ts +10 -1
- package/node_modules/@posthog/types/dist/capture-log.d.ts.map +1 -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/capture-log.ts +8 -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
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { JWEInvalid } from '../../util/errors.js';
|
|
1
|
+
import { assertNotSet } from '../../lib/helpers.js';
|
|
3
2
|
import { createJWE } from '../../lib/jwe_encrypt.js';
|
|
4
|
-
import {
|
|
3
|
+
import { assertUint8Array } from '../../lib/type_checks.js';
|
|
5
4
|
export class FlattenedEncrypt {
|
|
6
5
|
#plaintext;
|
|
7
6
|
#protectedHeader;
|
|
@@ -12,9 +11,7 @@ export class FlattenedEncrypt {
|
|
|
12
11
|
#iv;
|
|
13
12
|
#keyManagementParameters;
|
|
14
13
|
constructor(plaintext) {
|
|
15
|
-
|
|
16
|
-
throw new TypeError('plaintext must be an instance of Uint8Array');
|
|
17
|
-
}
|
|
14
|
+
assertUint8Array(plaintext, 'plaintext');
|
|
18
15
|
this.#plaintext = plaintext;
|
|
19
16
|
}
|
|
20
17
|
setKeyManagementParameters(parameters) {
|
|
@@ -52,10 +49,6 @@ export class FlattenedEncrypt {
|
|
|
52
49
|
return this;
|
|
53
50
|
}
|
|
54
51
|
async encrypt(key, options) {
|
|
55
|
-
if (!this.#protectedHeader && !this.#unprotectedHeader && !this.#sharedUnprotectedHeader) {
|
|
56
|
-
throw new JWEInvalid('either setProtectedHeader, setUnprotectedHeader, or sharedUnprotectedHeader must be called before #encrypt()');
|
|
57
|
-
}
|
|
58
|
-
validateCritDuplicates(JWEInvalid, this.#protectedHeader);
|
|
59
52
|
return createJWE([
|
|
60
53
|
this.#plaintext,
|
|
61
54
|
this.#protectedHeader,
|
|
@@ -65,8 +58,8 @@ export class FlattenedEncrypt {
|
|
|
65
58
|
this.#cek,
|
|
66
59
|
this.#iv,
|
|
67
60
|
this.#keyManagementParameters,
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
], key);
|
|
61
|
+
undefined,
|
|
62
|
+
false,
|
|
63
|
+
], key, options);
|
|
71
64
|
}
|
|
72
65
|
}
|
package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jwe/general/decrypt.js
CHANGED
|
@@ -1,46 +1,46 @@
|
|
|
1
|
-
import { prepareDecrypt, shareJWE, decryptRecipient, decryptResult,
|
|
1
|
+
import { prepareDecrypt, shareJWE, decryptRecipient, decryptResult, checkRecipient, snapshotSharedJWE, snapshotRecipientJWE, } from '../../lib/jwe_decrypt.js';
|
|
2
2
|
import { JWEDecryptionFailed, JWEInvalid } from '../../util/errors.js';
|
|
3
3
|
import { isObject } from '../../lib/type_checks.js';
|
|
4
4
|
export async function generalDecrypt(jwe, key, options) {
|
|
5
5
|
if (!isObject(jwe)) {
|
|
6
6
|
throw new JWEInvalid('General JWE must be an object');
|
|
7
7
|
}
|
|
8
|
-
|
|
8
|
+
const inputRecipients = jwe.recipients;
|
|
9
|
+
if (!Array.isArray(inputRecipients)) {
|
|
9
10
|
throw new JWEInvalid('JWE Recipients missing or incorrect type');
|
|
10
11
|
}
|
|
11
|
-
|
|
12
|
+
const recipients = Array.from(inputRecipients);
|
|
13
|
+
if (!recipients.every(isObject)) {
|
|
14
|
+
throw new JWEInvalid('JWE Recipients missing or incorrect type');
|
|
15
|
+
}
|
|
16
|
+
if (!recipients.length) {
|
|
12
17
|
throw new JWEInvalid('JWE Recipients has no members');
|
|
13
18
|
}
|
|
14
19
|
let shared;
|
|
20
|
+
let sharedJwe;
|
|
15
21
|
let token;
|
|
16
22
|
try {
|
|
17
|
-
checkShared(jwe);
|
|
18
23
|
shared = prepareDecrypt(options);
|
|
19
|
-
|
|
24
|
+
sharedJwe = snapshotSharedJWE(jwe);
|
|
25
|
+
token = shareJWE(sharedJwe);
|
|
20
26
|
}
|
|
21
27
|
catch {
|
|
22
28
|
throw new JWEDecryptionFailed();
|
|
23
29
|
}
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
30
|
+
const recipientSnapshots = recipients.map((recipient) => snapshotRecipientJWE(recipient));
|
|
31
|
+
if (recipients.length > 1) {
|
|
32
|
+
for (const [, headerAlg] of recipientSnapshots) {
|
|
33
|
+
const alg = token[0]?.alg ?? headerAlg ?? sharedJwe.unprotected?.alg;
|
|
27
34
|
if (alg === 'dir' || alg === 'ECDH-ES') {
|
|
28
35
|
throw new JWEInvalid(`"${alg}" alg may only have a single recipient`);
|
|
29
36
|
}
|
|
30
37
|
}
|
|
31
38
|
}
|
|
32
|
-
for (const recipient of
|
|
39
|
+
for (const [recipient] of recipientSnapshots) {
|
|
40
|
+
if (!recipient)
|
|
41
|
+
continue;
|
|
33
42
|
try {
|
|
34
|
-
const flattened = {
|
|
35
|
-
aad: jwe.aad,
|
|
36
|
-
ciphertext: jwe.ciphertext,
|
|
37
|
-
encrypted_key: recipient.encrypted_key,
|
|
38
|
-
header: recipient.header,
|
|
39
|
-
iv: jwe.iv,
|
|
40
|
-
protected: jwe.protected,
|
|
41
|
-
tag: jwe.tag,
|
|
42
|
-
unprotected: jwe.unprotected,
|
|
43
|
-
};
|
|
43
|
+
const flattened = { ...sharedJwe, ...recipient };
|
|
44
44
|
checkRecipient(flattened);
|
|
45
45
|
return decryptResult(flattened, await decryptRecipient(flattened, token, shared, key));
|
|
46
46
|
}
|
package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jwe/general/encrypt.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import { FlattenedEncrypt } from '../flattened/encrypt.js';
|
|
2
1
|
import { assertNotSet } from '../../lib/helpers.js';
|
|
3
2
|
import { JWEInvalid } from '../../util/errors.js';
|
|
4
3
|
import { generateCek } from '../../lib/content_encryption.js';
|
|
5
4
|
import { encryptKeyManagement } from '../../lib/key_management.js';
|
|
6
5
|
import { encode as b64u } from '../../util/base64url.js';
|
|
7
|
-
import {
|
|
8
|
-
import { checkDisjoint, checkEncryptHeaders, encryptJWE } from '../../lib/jwe_encrypt.js';
|
|
6
|
+
import { checkDisjoint, checkEncryptHeaders, createJWE, encryptJWE } from '../../lib/jwe_encrypt.js';
|
|
9
7
|
import { prepareKey } from '../../lib/key.js';
|
|
10
8
|
import { jweAlgorithm } from '../../lib/jwe_algorithms.js';
|
|
9
|
+
import { assertUint8Array } from '../../lib/type_checks.js';
|
|
11
10
|
class IndividualRecipient {
|
|
12
11
|
#parent;
|
|
13
12
|
state;
|
|
@@ -78,19 +77,21 @@ export class GeneralEncrypt {
|
|
|
78
77
|
if (!this.#recipients.length) {
|
|
79
78
|
throw new JWEInvalid('at least one recipient must be added');
|
|
80
79
|
}
|
|
81
|
-
|
|
82
|
-
throw new TypeError('plaintext must be an instance of Uint8Array');
|
|
83
|
-
}
|
|
80
|
+
assertUint8Array(this.#plaintext, 'plaintext');
|
|
84
81
|
if (this.#recipients.length === 1) {
|
|
85
|
-
const [
|
|
86
|
-
const
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
82
|
+
const [unprotectedHeader, keyManagementParameters, key, crit] = this.#recipients[0].state;
|
|
83
|
+
const flattened = await createJWE([
|
|
84
|
+
this.#plaintext,
|
|
85
|
+
this.#protectedHeader,
|
|
86
|
+
unprotectedHeader,
|
|
87
|
+
this.#unprotectedHeader,
|
|
88
|
+
this.#aad,
|
|
89
|
+
undefined,
|
|
90
|
+
undefined,
|
|
91
|
+
keyManagementParameters,
|
|
92
|
+
crit,
|
|
93
|
+
false,
|
|
94
|
+
], key);
|
|
94
95
|
const jwe = {
|
|
95
96
|
ciphertext: flattened.ciphertext,
|
|
96
97
|
iv: flattened.iv,
|
|
@@ -102,8 +103,9 @@ export class GeneralEncrypt {
|
|
|
102
103
|
copyOptionalMembers(flattened, jwe, jwe.recipients[0]);
|
|
103
104
|
return jwe;
|
|
104
105
|
}
|
|
105
|
-
validateCritDuplicates(JWEInvalid, this.#protectedHeader);
|
|
106
106
|
let enc;
|
|
107
|
+
let protectedHeader = this.#protectedHeader;
|
|
108
|
+
let sharedUnprotectedHeader = this.#unprotectedHeader;
|
|
107
109
|
const inputs = [];
|
|
108
110
|
const checked = [];
|
|
109
111
|
for (let i = 0; i < this.#recipients.length; i++) {
|
|
@@ -111,9 +113,9 @@ export class GeneralEncrypt {
|
|
|
111
113
|
const [unprotectedHeader, keyManagementParameters, , crit] = recipient.state;
|
|
112
114
|
const input = [
|
|
113
115
|
this.#plaintext,
|
|
114
|
-
|
|
116
|
+
protectedHeader,
|
|
115
117
|
unprotectedHeader,
|
|
116
|
-
|
|
118
|
+
sharedUnprotectedHeader,
|
|
117
119
|
this.#aad,
|
|
118
120
|
undefined,
|
|
119
121
|
undefined,
|
|
@@ -124,6 +126,10 @@ export class GeneralEncrypt {
|
|
|
124
126
|
const headers = checkEncryptHeaders(input);
|
|
125
127
|
inputs.push(input);
|
|
126
128
|
checked.push(headers);
|
|
129
|
+
if (i === 0) {
|
|
130
|
+
protectedHeader = input[1];
|
|
131
|
+
sharedUnprotectedHeader = input[3];
|
|
132
|
+
}
|
|
127
133
|
if (headers[1] === 'dir' || headers[1] === 'ECDH-ES') {
|
|
128
134
|
throw new JWEInvalid(`"${headers[1]}" alg may only have a single recipient`);
|
|
129
135
|
}
|
|
@@ -141,7 +147,7 @@ export class GeneralEncrypt {
|
|
|
141
147
|
};
|
|
142
148
|
for (let i = 0; i < this.#recipients.length; i++) {
|
|
143
149
|
const recipient = this.#recipients[i];
|
|
144
|
-
const [
|
|
150
|
+
const [, keyManagementParameters, key] = recipient.state;
|
|
145
151
|
const target = {};
|
|
146
152
|
jwe.recipients.push(target);
|
|
147
153
|
if (i === 0) {
|
|
@@ -155,13 +161,14 @@ export class GeneralEncrypt {
|
|
|
155
161
|
continue;
|
|
156
162
|
}
|
|
157
163
|
const [, alg, , encEntry] = checked[i];
|
|
164
|
+
const unprotectedHeader = inputs[i][2];
|
|
158
165
|
const k = await prepareKey(jweAlgorithm(alg), key, 'encrypt');
|
|
159
166
|
const [, encryptedKey, parameters] = await encryptKeyManagement(alg, encEntry, k, cek, keyManagementParameters);
|
|
160
167
|
target.encrypted_key = b64u(encryptedKey);
|
|
161
168
|
if (unprotectedHeader || parameters) {
|
|
162
169
|
const header = { ...unprotectedHeader, ...parameters };
|
|
163
170
|
if (parameters)
|
|
164
|
-
checkDisjoint(
|
|
171
|
+
checkDisjoint(inputs[i][1], header, inputs[i][3]);
|
|
165
172
|
target.header = header;
|
|
166
173
|
}
|
|
167
174
|
}
|
package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jwk/embedded.js
CHANGED
|
@@ -2,6 +2,7 @@ import { jwkToKey } from '../lib/jwk_to_key.js';
|
|
|
2
2
|
import { jwsAlgorithm } from '../lib/jws_algorithms.js';
|
|
3
3
|
import { isObject } from '../lib/type_checks.js';
|
|
4
4
|
import { JWSInvalid } from '../util/errors.js';
|
|
5
|
+
import { normalizeJwk } from '../lib/jwk_metadata.js';
|
|
5
6
|
export async function EmbeddedJWK(protectedHeader, token) {
|
|
6
7
|
const joseHeader = {
|
|
7
8
|
...protectedHeader,
|
|
@@ -10,8 +11,21 @@ export async function EmbeddedJWK(protectedHeader, token) {
|
|
|
10
11
|
if (!isObject(joseHeader.jwk)) {
|
|
11
12
|
throw new JWSInvalid('"jwk" (JSON Web Key) Header Parameter must be a JSON object');
|
|
12
13
|
}
|
|
14
|
+
let jwk;
|
|
15
|
+
try {
|
|
16
|
+
jwk = normalizeJwk(joseHeader.jwk);
|
|
17
|
+
}
|
|
18
|
+
catch (cause) {
|
|
19
|
+
throw new JWSInvalid('Invalid Embedded JWK', { cause });
|
|
20
|
+
}
|
|
13
21
|
const entry = jwsAlgorithm(joseHeader.alg);
|
|
14
|
-
|
|
22
|
+
if (jwk.use !== undefined && jwk.use !== 'sig') {
|
|
23
|
+
throw new JWSInvalid('Invalid Embedded JWK, its "use" must be "sig" when present');
|
|
24
|
+
}
|
|
25
|
+
if (jwk.alg !== undefined && jwk.alg !== entry.alg) {
|
|
26
|
+
throw new JWSInvalid(`Invalid Embedded JWK, its "alg" must be "${entry.alg}" when present`);
|
|
27
|
+
}
|
|
28
|
+
const key = await jwkToKey(entry, { ...jwk, ext: true });
|
|
15
29
|
if (key.type !== 'public') {
|
|
16
30
|
throw new JWSInvalid('"jwk" (JSON Web Key) Header Parameter must be a public key');
|
|
17
31
|
}
|
package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jwk/thumbprint.js
CHANGED
|
@@ -3,9 +3,10 @@ import { encode as b64u } from '../util/base64url.js';
|
|
|
3
3
|
import { JOSENotSupported, JWKInvalid } from '../util/errors.js';
|
|
4
4
|
import { encode } from '../lib/buffer_utils.js';
|
|
5
5
|
import { isKeyLike } from '../lib/is_key_like.js';
|
|
6
|
-
import {
|
|
6
|
+
import { isObject } from '../lib/type_checks.js';
|
|
7
7
|
import { exportJWK } from '../key/export.js';
|
|
8
8
|
import { invalidKeyInput } from '../lib/invalid_key_input.js';
|
|
9
|
+
import { snapshotJwk } from '../lib/jwk_metadata.js';
|
|
9
10
|
const check = (value, description) => {
|
|
10
11
|
if (typeof value !== 'string' || !value) {
|
|
11
12
|
throw new JWKInvalid(`${description} missing or invalid`);
|
|
@@ -13,11 +14,14 @@ const check = (value, description) => {
|
|
|
13
14
|
};
|
|
14
15
|
export async function calculateJwkThumbprint(key, digestAlgorithm) {
|
|
15
16
|
let jwk;
|
|
16
|
-
if (
|
|
17
|
-
jwk = key;
|
|
17
|
+
if (isObject(key)) {
|
|
18
|
+
jwk = snapshotJwk(key);
|
|
19
|
+
if (typeof jwk.kty !== 'string') {
|
|
20
|
+
throw new TypeError(invalidKeyInput(key, 'CryptoKey', 'KeyObject', 'JSON Web Key'));
|
|
21
|
+
}
|
|
18
22
|
}
|
|
19
23
|
else if (isKeyLike(key)) {
|
|
20
|
-
jwk = await exportJWK(key);
|
|
24
|
+
jwk = snapshotJwk(await exportJWK(key));
|
|
21
25
|
}
|
|
22
26
|
else {
|
|
23
27
|
throw new TypeError(invalidKeyInput(key, 'CryptoKey', 'KeyObject', 'JSON Web Key'));
|
|
@@ -52,7 +56,9 @@ export async function calculateJwkThumbprint(key, digestAlgorithm) {
|
|
|
52
56
|
components = { e: jwk.e, kty: jwk.kty, n: jwk.n };
|
|
53
57
|
break;
|
|
54
58
|
case 'oct':
|
|
55
|
-
|
|
59
|
+
if (typeof jwk.k !== 'string') {
|
|
60
|
+
throw new JWKInvalid('"k" (Key Value) Parameter missing or invalid');
|
|
61
|
+
}
|
|
56
62
|
components = { k: jwk.k, kty: jwk.kty };
|
|
57
63
|
break;
|
|
58
64
|
default:
|
|
@@ -1,78 +1,70 @@
|
|
|
1
1
|
import { jwkToKey } from '../lib/jwk_to_key.js';
|
|
2
2
|
import { JWS } from '../lib/jws_algorithms.js';
|
|
3
3
|
import { JWKSInvalid, JOSENotSupported, JWKSNoMatchingKey, JWKSMultipleMatchingKeys, } from '../util/errors.js';
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
4
|
+
import { isJwkSet } from '../lib/type_checks.js';
|
|
5
|
+
import { snapshotJwk } from '../lib/jwk_metadata.js';
|
|
6
|
+
function isUsableJWK(jwk, entry, alg, kid) {
|
|
7
|
+
const { kty, key_ops, ext, kid: jwkKid, alg: jwkAlg, use, crv } = snapshotJwk(jwk);
|
|
8
|
+
const keyOps = Array.isArray(key_ops) ? [...key_ops] : key_ops;
|
|
9
|
+
return ((ext === undefined || typeof ext === 'boolean') &&
|
|
10
|
+
(keyOps === undefined ||
|
|
11
|
+
(Array.isArray(keyOps) &&
|
|
12
|
+
keyOps.every((operation, index) => typeof operation === 'string' && keyOps.indexOf(operation) === index) &&
|
|
13
|
+
keyOps.includes('verify'))) &&
|
|
14
|
+
entry.kty.includes(kty) &&
|
|
15
|
+
(kid === undefined || (typeof kid === 'string' && kid === jwkKid)) &&
|
|
16
|
+
(jwkAlg === undefined ? kty !== 'AKP' : alg === jwkAlg) &&
|
|
17
|
+
(use === undefined || use === 'sig') &&
|
|
18
|
+
(!entry.crv || crv === entry.crv));
|
|
11
19
|
}
|
|
12
|
-
function
|
|
13
|
-
|
|
14
|
-
|
|
20
|
+
async function importWithAlgCache(cache, jwk, entry) {
|
|
21
|
+
const cached = cache.get(jwk) || cache.set(jwk, {}).get(jwk);
|
|
22
|
+
const { alg } = entry;
|
|
23
|
+
if (cached[alg] === undefined) {
|
|
24
|
+
const key = await jwkToKey(entry, { ...jwk, alg, ext: true });
|
|
25
|
+
if (key.type !== 'public') {
|
|
26
|
+
throw new JWKSInvalid('JSON Web Key Set members must be public keys');
|
|
27
|
+
}
|
|
28
|
+
cached[alg] = key;
|
|
15
29
|
}
|
|
16
|
-
|
|
17
|
-
return Array.isArray(keys) && keys.every((isObject));
|
|
30
|
+
return cached[alg];
|
|
18
31
|
}
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
if (!isJWKSLike(jwks)) {
|
|
24
|
-
throw new JWKSInvalid('JSON Web Key Set malformed');
|
|
25
|
-
}
|
|
26
|
-
this.#jwks = structuredClone(jwks);
|
|
32
|
+
export function createLocalJWKSet(jwks) {
|
|
33
|
+
let snapshot;
|
|
34
|
+
try {
|
|
35
|
+
snapshot = structuredClone(jwks);
|
|
27
36
|
}
|
|
28
|
-
|
|
29
|
-
|
|
37
|
+
catch { }
|
|
38
|
+
if (!isJwkSet(snapshot)) {
|
|
39
|
+
throw new JWKSInvalid('JSON Web Key Set malformed');
|
|
30
40
|
}
|
|
31
|
-
|
|
41
|
+
const cached = new WeakMap();
|
|
42
|
+
const localJWKSet = async (protectedHeader, token) => {
|
|
32
43
|
const { alg, kid } = { ...protectedHeader, ...token?.header };
|
|
33
|
-
const entry =
|
|
34
|
-
|
|
35
|
-
(
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
(!Array.isArray(jwk.key_ops) || jwk.key_ops.includes('verify')) &&
|
|
39
|
-
(!entry.crv || jwk.crv === entry.crv));
|
|
44
|
+
const entry = typeof alg === 'string' ? JWS[alg] : undefined;
|
|
45
|
+
if (!entry || entry.secret) {
|
|
46
|
+
throw new JOSENotSupported('Unsupported "alg" value for a JSON Web Key Set');
|
|
47
|
+
}
|
|
48
|
+
const candidates = snapshot.keys.filter((jwk) => isUsableJWK(jwk, entry, alg, kid));
|
|
40
49
|
const { 0: jwk, length } = candidates;
|
|
41
|
-
if (length
|
|
50
|
+
if (!length) {
|
|
42
51
|
throw new JWKSNoMatchingKey();
|
|
43
52
|
}
|
|
44
53
|
if (length !== 1) {
|
|
45
54
|
const error = new JWKSMultipleMatchingKeys();
|
|
46
|
-
const _cached = this.#cached;
|
|
47
55
|
error[Symbol.asyncIterator] = async function* () {
|
|
48
56
|
for (const jwk of candidates) {
|
|
49
57
|
try {
|
|
50
|
-
yield await importWithAlgCache(
|
|
58
|
+
yield await importWithAlgCache(cached, jwk, entry);
|
|
51
59
|
}
|
|
52
60
|
catch { }
|
|
53
61
|
}
|
|
54
62
|
};
|
|
55
63
|
throw error;
|
|
56
64
|
}
|
|
57
|
-
return importWithAlgCache(
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
const cached = cache.get(jwk) || cache.set(jwk, { __proto__: null }).get(jwk);
|
|
62
|
-
if (cached[entry.alg] === undefined) {
|
|
63
|
-
const key = await jwkToKey(entry, { ...jwk, alg: entry.alg, ext: true });
|
|
64
|
-
if (key.type !== 'public') {
|
|
65
|
-
throw new JWKSInvalid('JSON Web Key Set members must be public keys');
|
|
66
|
-
}
|
|
67
|
-
cached[entry.alg] = key;
|
|
68
|
-
}
|
|
69
|
-
return cached[entry.alg];
|
|
70
|
-
}
|
|
71
|
-
export function createLocalJWKSet(jwks) {
|
|
72
|
-
const set = new LocalJWKSetImpl(jwks);
|
|
73
|
-
const localJWKSet = async (protectedHeader, token) => set.getKey(protectedHeader, token);
|
|
74
|
-
Object.defineProperty(localJWKSet, 'jwks', {
|
|
75
|
-
value: () => structuredClone(set.jwks()),
|
|
65
|
+
return importWithAlgCache(cached, jwk, entry);
|
|
66
|
+
};
|
|
67
|
+
return Object.defineProperty(localJWKSet, 'jwks', {
|
|
68
|
+
value: () => structuredClone(snapshot),
|
|
76
69
|
});
|
|
77
|
-
return localJWKSet;
|
|
78
70
|
}
|
|
@@ -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
|
}
|