@zuplo/cli 7.12.4 → 7.12.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/README.md +2 -2
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/types/jwe/compact/decrypt.d.ts +5 -4
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/types/jwe/compact/encrypt.d.ts +4 -4
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/types/jwe/flattened/decrypt.d.ts +5 -4
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/types/jwe/flattened/encrypt.d.ts +5 -5
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/types/jwe/general/decrypt.d.ts +5 -4
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/types/jwe/general/encrypt.d.ts +5 -5
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/types/jws/compact/sign.d.ts +5 -4
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/types/jws/compact/verify.d.ts +5 -5
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/types/jws/flattened/sign.d.ts +5 -4
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/types/jws/flattened/verify.d.ts +6 -5
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/types/jws/general/sign.d.ts +9 -6
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/types/jws/general/verify.d.ts +7 -5
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/types/jwt/decrypt.d.ts +7 -6
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/types/jwt/encrypt.d.ts +1 -1
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/types/jwt/sign.d.ts +1 -1
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/types/jwt/unsecured.d.ts +1 -1
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/types/jwt/verify.d.ts +3 -5
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/types/key/export.d.ts +1 -1
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/types/key/generate_secret.d.ts +1 -1
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/types/key/import.d.ts +2 -2
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/types/types.d.ts +165 -107
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/types/util/decode_jwt.d.ts +2 -2
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/types/util/errors.d.ts +1 -1
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/jwe/general/encrypt.js +3 -3
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/jwk/thumbprint.js +8 -8
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/jwks/local.js +2 -1
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/jwks/remote.js +4 -4
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/jws/general/sign.js +3 -3
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/jws/general/verify.js +3 -3
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/jwt/encrypt.js +2 -2
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/jwt/sign.js +2 -2
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/jwt/unsecured.js +3 -3
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/key/generate_secret.js +4 -4
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/lib/asn1.js +2 -2
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/lib/buffer_utils.js +4 -4
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/lib/content_encryption.js +8 -8
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/lib/jwe_decrypt.js +14 -14
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/lib/jwe_encrypt.js +3 -3
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/lib/jws_algorithms.js +2 -2
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/lib/jws_sign.js +11 -11
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/lib/jws_verify.js +19 -16
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/lib/jwt_claims_set.js +44 -43
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/lib/key.js +4 -4
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/lib/key_management.js +17 -17
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/lib/validate.js +10 -10
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/util/decode_jwt.js +12 -12
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/dist/webapi/util/decode_protected_header.js +5 -5
- package/node_modules/@modelcontextprotocol/client/node_modules/jose/package.json +1 -1
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/README.md +2 -2
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/jwe/compact/decrypt.d.ts +5 -4
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/jwe/compact/encrypt.d.ts +4 -4
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/jwe/flattened/decrypt.d.ts +5 -4
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/jwe/flattened/encrypt.d.ts +5 -5
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/jwe/general/decrypt.d.ts +5 -4
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/jwe/general/encrypt.d.ts +5 -5
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/jws/compact/sign.d.ts +5 -4
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/jws/compact/verify.d.ts +5 -5
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/jws/flattened/sign.d.ts +5 -4
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/jws/flattened/verify.d.ts +6 -5
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/jws/general/sign.d.ts +9 -6
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/jws/general/verify.d.ts +7 -5
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/jwt/decrypt.d.ts +7 -6
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/jwt/encrypt.d.ts +1 -1
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/jwt/sign.d.ts +1 -1
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/jwt/unsecured.d.ts +1 -1
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/jwt/verify.d.ts +3 -5
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/key/export.d.ts +1 -1
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/key/generate_secret.d.ts +1 -1
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/key/import.d.ts +2 -2
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/types.d.ts +165 -107
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/util/decode_jwt.d.ts +2 -2
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/types/util/errors.d.ts +1 -1
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jwe/general/encrypt.js +3 -3
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jwk/thumbprint.js +8 -8
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jwks/local.js +2 -1
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jwks/remote.js +4 -4
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jws/general/sign.js +3 -3
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jws/general/verify.js +3 -3
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jwt/encrypt.js +2 -2
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jwt/sign.js +2 -2
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jwt/unsecured.js +3 -3
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/key/generate_secret.js +4 -4
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/asn1.js +2 -2
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/buffer_utils.js +4 -4
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/content_encryption.js +8 -8
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/jwe_decrypt.js +14 -14
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/jwe_encrypt.js +3 -3
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/jws_algorithms.js +2 -2
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/jws_sign.js +11 -11
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/jws_verify.js +19 -16
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/jwt_claims_set.js +44 -43
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/key.js +4 -4
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/key_management.js +17 -17
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/validate.js +10 -10
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/util/decode_jwt.js +12 -12
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/util/decode_protected_header.js +5 -5
- package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/package.json +1 -1
- package/node_modules/@posthog/core/dist/featureFlagLocalEvaluation.d.ts.map +1 -1
- package/node_modules/@posthog/core/dist/featureFlagLocalEvaluation.js +11 -3
- package/node_modules/@posthog/core/dist/featureFlagLocalEvaluation.mjs +11 -3
- package/node_modules/@posthog/core/package.json +1 -1
- package/node_modules/@posthog/core/src/featureFlagLocalEvaluation.ts +17 -9
- package/node_modules/@zuplo/core/customer.cli.minified.js +231 -231
- package/node_modules/@zuplo/core/index.minified.js +254 -254
- 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-WTWRZT3M.js → chunk-N2ZQITZD.js} +96 -96
- package/node_modules/@zuplo/runtime/out/esm/chunk-N2ZQITZD.js.map +1 -0
- package/node_modules/@zuplo/runtime/out/esm/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/types/index.d.ts +10 -14
- package/node_modules/@zuplo/runtime/package.json +1 -1
- package/package.json +11 -11
- package/node_modules/@zuplo/runtime/out/esm/chunk-WTWRZT3M.js.map +0 -1
- /package/node_modules/@zuplo/runtime/out/esm/{chunk-WTWRZT3M.js.LEGAL.txt → chunk-N2ZQITZD.js.LEGAL.txt} +0 -0
package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jwk/thumbprint.js
CHANGED
|
@@ -19,30 +19,30 @@ async function calculateJwkThumbprint(key, digestAlgorithm) {
|
|
|
19
19
|
throw new TypeError(invalidKeyInput(key, "CryptoKey", "KeyObject", "JSON Web Key"));
|
|
20
20
|
if (digestAlgorithm ??= "sha256", digestAlgorithm !== "sha256" && digestAlgorithm !== "sha384" && digestAlgorithm !== "sha512")
|
|
21
21
|
throw new TypeError('digestAlgorithm must one of "sha256", "sha384", or "sha512"');
|
|
22
|
-
let
|
|
22
|
+
let requiredMembers;
|
|
23
23
|
switch (jwk.kty) {
|
|
24
24
|
case "AKP":
|
|
25
|
-
check(jwk.alg, '"alg" (Algorithm) Parameter'), check(jwk.pub, '"pub" (Public key) Parameter'),
|
|
25
|
+
check(jwk.alg, '"alg" (Algorithm) Parameter'), check(jwk.pub, '"pub" (Public key) Parameter'), requiredMembers = { alg: jwk.alg, kty: jwk.kty, pub: jwk.pub };
|
|
26
26
|
break;
|
|
27
27
|
case "EC":
|
|
28
|
-
check(jwk.crv, '"crv" (Curve) Parameter'), check(jwk.x, '"x" (X Coordinate) Parameter'), check(jwk.y, '"y" (Y Coordinate) Parameter'),
|
|
28
|
+
check(jwk.crv, '"crv" (Curve) Parameter'), check(jwk.x, '"x" (X Coordinate) Parameter'), check(jwk.y, '"y" (Y Coordinate) Parameter'), requiredMembers = { crv: jwk.crv, kty: jwk.kty, x: jwk.x, y: jwk.y };
|
|
29
29
|
break;
|
|
30
30
|
case "OKP":
|
|
31
|
-
check(jwk.crv, '"crv" (Subtype of Key Pair) Parameter'), check(jwk.x, '"x" (Public Key) Parameter'),
|
|
31
|
+
check(jwk.crv, '"crv" (Subtype of Key Pair) Parameter'), check(jwk.x, '"x" (Public Key) Parameter'), requiredMembers = { crv: jwk.crv, kty: jwk.kty, x: jwk.x };
|
|
32
32
|
break;
|
|
33
33
|
case "RSA":
|
|
34
|
-
check(jwk.e, '"e" (Exponent) Parameter'), check(jwk.n, '"n" (Modulus) Parameter'),
|
|
34
|
+
check(jwk.e, '"e" (Exponent) Parameter'), check(jwk.n, '"n" (Modulus) Parameter'), requiredMembers = { e: jwk.e, kty: jwk.kty, n: jwk.n };
|
|
35
35
|
break;
|
|
36
36
|
case "oct":
|
|
37
37
|
if (typeof jwk.k != "string")
|
|
38
38
|
throw new JWKInvalid('"k" (Key Value) Parameter missing or invalid');
|
|
39
|
-
|
|
39
|
+
requiredMembers = { k: jwk.k, kty: jwk.kty };
|
|
40
40
|
break;
|
|
41
41
|
default:
|
|
42
42
|
throw new JOSENotSupported('"kty" (Key Type) Parameter missing or unsupported');
|
|
43
43
|
}
|
|
44
|
-
const
|
|
45
|
-
return b64u(await digest(digestAlgorithm,
|
|
44
|
+
const thumbprintInput = encode(JSON.stringify(requiredMembers));
|
|
45
|
+
return b64u(await digest(digestAlgorithm, thumbprintInput));
|
|
46
46
|
}
|
|
47
47
|
async function calculateJwkThumbprintUri(key, digestAlgorithm) {
|
|
48
48
|
digestAlgorithm ??= "sha256";
|
|
@@ -24,7 +24,8 @@ function createLocalJWKSet(jwks) {
|
|
|
24
24
|
let snapshot;
|
|
25
25
|
try {
|
|
26
26
|
snapshot = structuredClone(jwks);
|
|
27
|
-
} catch {
|
|
27
|
+
} catch (cause) {
|
|
28
|
+
throw new JWKSInvalid("JSON Web Key Set malformed", { cause });
|
|
28
29
|
}
|
|
29
30
|
if (!isJwkSet(snapshot))
|
|
30
31
|
throw new JWKSInvalid("JSON Web Key Set malformed");
|
|
@@ -5,7 +5,7 @@ function isCloudflareWorkers() {
|
|
|
5
5
|
return typeof WebSocketPair < "u" || typeof navigator < "u" && navigator.userAgent === "Cloudflare-Workers" || typeof EdgeRuntime < "u" && EdgeRuntime === "vercel";
|
|
6
6
|
}
|
|
7
7
|
let USER_AGENT;
|
|
8
|
-
(typeof navigator > "u" || !navigator.userAgent?.startsWith?.("Mozilla/5.0 ")) && (USER_AGENT = "jose/v6.2.
|
|
8
|
+
(typeof navigator > "u" || !navigator.userAgent?.startsWith?.("Mozilla/5.0 ")) && (USER_AGENT = "jose/v6.2.13");
|
|
9
9
|
const customFetch = /* @__PURE__ */ Symbol();
|
|
10
10
|
async function fetchJwks(url, headers, signal, fetchImpl = fetch) {
|
|
11
11
|
const response = await fetchImpl(url, {
|
|
@@ -14,14 +14,14 @@ async function fetchJwks(url, headers, signal, fetchImpl = fetch) {
|
|
|
14
14
|
redirect: "manual",
|
|
15
15
|
headers
|
|
16
16
|
}).catch((err) => {
|
|
17
|
-
throw err.name === "TimeoutError" ? new JWKSTimeout() : err;
|
|
17
|
+
throw err.name === "TimeoutError" ? new JWKSTimeout(void 0, { cause: err }) : err;
|
|
18
18
|
});
|
|
19
19
|
if (response.status !== 200)
|
|
20
20
|
throw new JOSEError("Expected 200 OK from the JSON Web Key Set HTTP response");
|
|
21
21
|
try {
|
|
22
22
|
return await response.json();
|
|
23
|
-
} catch {
|
|
24
|
-
throw new JOSEError("Failed to parse the JSON Web Key Set HTTP response as JSON");
|
|
23
|
+
} catch (cause) {
|
|
24
|
+
throw new JOSEError("Failed to parse the JSON Web Key Set HTTP response as JSON", { cause });
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
27
|
const jwksCache = /* @__PURE__ */ Symbol();
|
package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jws/general/sign.js
CHANGED
|
@@ -40,15 +40,15 @@ class GeneralSign {
|
|
|
40
40
|
const jws = {
|
|
41
41
|
signatures: [],
|
|
42
42
|
payload: ""
|
|
43
|
-
},
|
|
43
|
+
}, encodedPayloadCache = [];
|
|
44
44
|
let b64;
|
|
45
45
|
for (const signature of this.#signatures) {
|
|
46
|
-
const [protectedHeader, unprotectedHeader, key, crit] = signature.state, [{ payload, ...
|
|
46
|
+
const [protectedHeader, unprotectedHeader, key, crit] = signature.state, [{ payload, ...signatureMembers }, signatureB64] = await createSignature([this.#payload, protectedHeader, unprotectedHeader, crit, encodedPayloadCache], key);
|
|
47
47
|
if (b64 === void 0)
|
|
48
48
|
b64 = signatureB64, jws.payload = payload;
|
|
49
49
|
else if (b64 !== signatureB64)
|
|
50
50
|
throw new JWSInvalid("inconsistent use of JWS Unencoded Payload (RFC7797)");
|
|
51
|
-
jws.signatures.push(
|
|
51
|
+
jws.signatures.push(signatureMembers);
|
|
52
52
|
}
|
|
53
53
|
return jws;
|
|
54
54
|
}
|
package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jws/general/verify.js
CHANGED
|
@@ -31,9 +31,9 @@ async function generalVerify(jws, key, options) {
|
|
|
31
31
|
throw new JWSSignatureVerificationFailed();
|
|
32
32
|
}
|
|
33
33
|
const payload = inputPayload instanceof Uint8Array ? new Uint8Array(inputPayload) : inputPayload, candidates = signatureEntries.map((signature) => snapshotSignature(signature, payload)).filter((candidate) => candidate !== void 0);
|
|
34
|
-
let
|
|
35
|
-
for (const [, ,
|
|
36
|
-
if (
|
|
34
|
+
let payloadEncodings = 0;
|
|
35
|
+
for (const [, , payloadEncoding] of candidates)
|
|
36
|
+
if (payloadEncodings |= payloadEncoding, payloadEncodings === 3)
|
|
37
37
|
throw new JWSInvalid("inconsistent use of JWS Unencoded Payload (RFC7797)");
|
|
38
38
|
for (const candidate of candidates)
|
|
39
39
|
try {
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { compactJWE, createJWE } from "../lib/jwe_encrypt.js";
|
|
2
|
-
import { JWTClaimsBuilder, jwtClaim,
|
|
2
|
+
import { JWTClaimsBuilder, jwtClaim, jwtClaimsSetBytes } from "../lib/jwt_claims_set.js";
|
|
3
3
|
import { assertNotSet } from "../lib/validate.js";
|
|
4
4
|
const EncryptJWT_base = JWTClaimsBuilder;
|
|
5
5
|
class EncryptJWT extends EncryptJWT_base {
|
|
@@ -29,7 +29,7 @@ class EncryptJWT extends EncryptJWT_base {
|
|
|
29
29
|
return this.#replicateAudienceAsHeader = !0, this;
|
|
30
30
|
}
|
|
31
31
|
async encrypt(key, options) {
|
|
32
|
-
const plaintext =
|
|
32
|
+
const plaintext = jwtClaimsSetBytes(this);
|
|
33
33
|
this.#input[1] && (this.#replicateIssuerAsHeader || this.#replicateSubjectAsHeader || this.#replicateAudienceAsHeader) && (this.#input[1] = {
|
|
34
34
|
...this.#input[1],
|
|
35
35
|
iss: this.#replicateIssuerAsHeader ? jwtClaim(this, "iss") : void 0,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createCompactSignature } from "../lib/jws_sign.js";
|
|
2
2
|
import { JWTInvalid } from "../util/errors.js";
|
|
3
|
-
import { JWTClaimsBuilder,
|
|
3
|
+
import { JWTClaimsBuilder, jwtClaimsSetBytes } from "../lib/jwt_claims_set.js";
|
|
4
4
|
import { assertNotSet } from "../lib/validate.js";
|
|
5
5
|
const SignJWT_base = JWTClaimsBuilder;
|
|
6
6
|
class SignJWT extends SignJWT_base {
|
|
@@ -9,7 +9,7 @@ class SignJWT extends SignJWT_base {
|
|
|
9
9
|
return assertNotSet(this.#protectedHeader, "setProtectedHeader"), this.#protectedHeader = protectedHeader, this;
|
|
10
10
|
}
|
|
11
11
|
async sign(key, options) {
|
|
12
|
-
return createCompactSignature(
|
|
12
|
+
return createCompactSignature(jwtClaimsSetBytes(this), this.#protectedHeader, options?.crit, key, () => {
|
|
13
13
|
throw new JWTInvalid("JWTs MUST NOT use unencoded payload");
|
|
14
14
|
});
|
|
15
15
|
}
|
package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/jwt/unsecured.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import * as b64u from "../util/base64url.js";
|
|
2
2
|
import { decodeBase64url, parseJoseHeader, JWS_RECOGNIZED, validateB64, validateCrit } from "../lib/validate.js";
|
|
3
3
|
import { JWSInvalid, JWTInvalid } from "../util/errors.js";
|
|
4
|
-
import { validateClaimsSet, JWTClaimsBuilder,
|
|
4
|
+
import { validateClaimsSet, JWTClaimsBuilder, jwtClaimsSetBytes } from "../lib/jwt_claims_set.js";
|
|
5
5
|
const UnsecuredJWT_base = JWTClaimsBuilder;
|
|
6
6
|
class UnsecuredJWT extends UnsecuredJWT_base {
|
|
7
7
|
encode() {
|
|
8
|
-
const
|
|
9
|
-
return `${
|
|
8
|
+
const encodedProtectedHeader = b64u.encode(JSON.stringify({ alg: "none" })), encodedPayload = b64u.encode(jwtClaimsSetBytes(this));
|
|
9
|
+
return `${encodedProtectedHeader}.${encodedPayload}.`;
|
|
10
10
|
}
|
|
11
11
|
static decode(jwt, options) {
|
|
12
12
|
if (typeof jwt != "string")
|
package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/key/generate_secret.js
CHANGED
|
@@ -2,12 +2,12 @@ import { unsupportedAlg, algArgument } from "../lib/key_algorithm.js";
|
|
|
2
2
|
import { validateExtractableOption } from "../lib/key.js";
|
|
3
3
|
async function generateSecret(alg, options) {
|
|
4
4
|
const extractable = validateExtractableOption(options?.extractable);
|
|
5
|
-
let
|
|
5
|
+
let keyLengthBits, algorithm, keyUsages;
|
|
6
6
|
switch (alg) {
|
|
7
7
|
case "HS256":
|
|
8
8
|
case "HS384":
|
|
9
9
|
case "HS512":
|
|
10
|
-
|
|
10
|
+
keyLengthBits = +alg.slice(-3), algorithm = { name: "HMAC", hash: `SHA-${keyLengthBits}`, length: keyLengthBits }, keyUsages = ["sign", "verify"];
|
|
11
11
|
break;
|
|
12
12
|
case "A128CBC-HS256":
|
|
13
13
|
case "A192CBC-HS384":
|
|
@@ -16,7 +16,7 @@ async function generateSecret(alg, options) {
|
|
|
16
16
|
case "A128KW":
|
|
17
17
|
case "A192KW":
|
|
18
18
|
case "A256KW":
|
|
19
|
-
|
|
19
|
+
keyLengthBits = +alg.slice(1, 4), algorithm = { name: "AES-KW", length: keyLengthBits }, keyUsages = ["wrapKey", "unwrapKey"];
|
|
20
20
|
break;
|
|
21
21
|
case "A128GCMKW":
|
|
22
22
|
case "A192GCMKW":
|
|
@@ -24,7 +24,7 @@ async function generateSecret(alg, options) {
|
|
|
24
24
|
case "A128GCM":
|
|
25
25
|
case "A192GCM":
|
|
26
26
|
case "A256GCM":
|
|
27
|
-
|
|
27
|
+
keyLengthBits = +alg.slice(1, 4), algorithm = { name: "AES-GCM", length: keyLengthBits }, keyUsages = ["encrypt", "decrypt"];
|
|
28
28
|
break;
|
|
29
29
|
default:
|
|
30
30
|
unsupportedAlg(algArgument);
|
|
@@ -94,8 +94,8 @@ const parseECAlgorithmIdentifier = (state) => {
|
|
|
94
94
|
try {
|
|
95
95
|
const state = createASN1State(keyData);
|
|
96
96
|
parseKeyHeader(state, keyFormat), algorithm = entry.resolve({ crv: parseECAlgorithmIdentifier(state) });
|
|
97
|
-
} catch {
|
|
98
|
-
throw new JOSENotSupported("Invalid or unsupported key format");
|
|
97
|
+
} catch (cause) {
|
|
98
|
+
throw new JOSENotSupported("Invalid or unsupported key format", { cause });
|
|
99
99
|
}
|
|
100
100
|
else
|
|
101
101
|
algorithm = entry.subtle;
|
package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/buffer_utils.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
const encoder = new TextEncoder(), decoder = new TextDecoder(), strictDecoder = new TextDecoder("utf-8", { fatal: !0 }),
|
|
1
|
+
const encoder = new TextEncoder(), decoder = new TextDecoder(), strictDecoder = new TextDecoder("utf-8", { fatal: !0 }), UINT32_RANGE = 2 ** 32;
|
|
2
2
|
function concat(...buffers) {
|
|
3
3
|
const size = buffers.reduce((acc, { length }) => acc + length, 0), buf = new Uint8Array(size);
|
|
4
4
|
let i = 0;
|
|
@@ -7,12 +7,12 @@ function concat(...buffers) {
|
|
|
7
7
|
return buf;
|
|
8
8
|
}
|
|
9
9
|
function writeUInt32BE(buf, value, offset) {
|
|
10
|
-
if (value < 0 || value >=
|
|
11
|
-
throw new RangeError(`value must be >= 0 and <= ${
|
|
10
|
+
if (value < 0 || value >= UINT32_RANGE)
|
|
11
|
+
throw new RangeError(`value must be >= 0 and <= ${UINT32_RANGE - 1}. Received ${value}`);
|
|
12
12
|
buf.set([value >>> 24, value >>> 16, value >>> 8, value & 255], offset);
|
|
13
13
|
}
|
|
14
14
|
function uint64be(value) {
|
|
15
|
-
const high = Math.floor(value /
|
|
15
|
+
const high = Math.floor(value / UINT32_RANGE), low = value % UINT32_RANGE, buf = new Uint8Array(8);
|
|
16
16
|
return writeUInt32BE(buf, high, 0), writeUInt32BE(buf, low, 4), buf;
|
|
17
17
|
}
|
|
18
18
|
function uint32be(value) {
|
|
@@ -15,20 +15,20 @@ function checkIvLength(enc, iv) {
|
|
|
15
15
|
async function cbcKeySetup(enc, cek, usage) {
|
|
16
16
|
if (!(cek instanceof Uint8Array))
|
|
17
17
|
throw new TypeError(invalidKeyInput(cek, "Uint8Array"));
|
|
18
|
-
const
|
|
19
|
-
hash: `SHA-${
|
|
18
|
+
const keyLengthBits = enc.cekBits >> 1, encKey = await crypto.subtle.importKey("raw", cek.subarray(keyLengthBits >> 3), "AES-CBC", !1, [usage]), macKey = await crypto.subtle.importKey("raw", cek.subarray(0, keyLengthBits >> 3), {
|
|
19
|
+
hash: `SHA-${keyLengthBits << 1}`,
|
|
20
20
|
name: "HMAC"
|
|
21
21
|
}, !1, ["sign"]);
|
|
22
|
-
return [encKey, macKey,
|
|
22
|
+
return [encKey, macKey, keyLengthBits];
|
|
23
23
|
}
|
|
24
|
-
async function cbcHmacTag(macKey, macData,
|
|
25
|
-
return new Uint8Array((await crypto.subtle.sign("HMAC", macKey, macData)).slice(0,
|
|
24
|
+
async function cbcHmacTag(macKey, macData, keyLengthBits) {
|
|
25
|
+
return new Uint8Array((await crypto.subtle.sign("HMAC", macKey, macData)).slice(0, keyLengthBits >> 3));
|
|
26
26
|
}
|
|
27
27
|
async function cbcEncrypt(enc, plaintext, cek, iv, aad) {
|
|
28
|
-
const [encKey, macKey,
|
|
28
|
+
const [encKey, macKey, keyLengthBits] = await cbcKeySetup(enc, cek, "encrypt"), ciphertext = new Uint8Array(await crypto.subtle.encrypt({
|
|
29
29
|
iv,
|
|
30
30
|
name: "AES-CBC"
|
|
31
|
-
}, encKey, plaintext)), macData = concat(aad, iv, ciphertext,
|
|
31
|
+
}, encKey, plaintext)), al = uint64be(aad.length * 8), macData = concat(aad, iv, ciphertext, al), tag = await cbcHmacTag(macKey, macData, keyLengthBits);
|
|
32
32
|
return { ciphertext, tag, iv };
|
|
33
33
|
}
|
|
34
34
|
async function timingSafeEqual(a, b) {
|
|
@@ -36,7 +36,7 @@ async function timingSafeEqual(a, b) {
|
|
|
36
36
|
return crypto.subtle.verify(algorithm, key, aHmac, b);
|
|
37
37
|
}
|
|
38
38
|
async function cbcDecrypt(enc, cek, ciphertext, iv, tag, aad) {
|
|
39
|
-
const [encKey, macKey,
|
|
39
|
+
const [encKey, macKey, keyLengthBits] = await cbcKeySetup(enc, cek, "decrypt"), al = uint64be(aad.length * 8), macData = concat(aad, iv, ciphertext, al), expectedTag = await cbcHmacTag(macKey, macData, keyLengthBits);
|
|
40
40
|
try {
|
|
41
41
|
if (await timingSafeEqual(tag, expectedTag))
|
|
42
42
|
return new Uint8Array(await crypto.subtle.decrypt({ iv, name: "AES-CBC" }, encKey, ciphertext));
|
package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/jwe_decrypt.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { decrypt, generateCek } from "./content_encryption.js";
|
|
2
|
-
import { decodeBase64url,
|
|
2
|
+
import { decodeBase64url, encodeAsciiMember, parseJoseHeader, isDisjoint, isObject, validateCrit, validateAlgorithms, JWE_RECOGNIZED } from "./validate.js";
|
|
3
3
|
import { JOSEAlgNotAllowed, JOSENotSupported, JWEInvalid } from "../util/errors.js";
|
|
4
4
|
import { decryptKeyManagement } from "./key_management.js";
|
|
5
5
|
import { decoder } from "./buffer_utils.js";
|
|
@@ -59,13 +59,13 @@ function checkRecipient(jwe) {
|
|
|
59
59
|
}
|
|
60
60
|
function shareJWE(jwe) {
|
|
61
61
|
const { protected: encodedProtected, ciphertext, iv, tag, aad } = jwe;
|
|
62
|
-
let
|
|
63
|
-
return encodedProtected !== void 0 && (
|
|
64
|
-
|
|
62
|
+
let protectedHeader;
|
|
63
|
+
return encodedProtected !== void 0 && (protectedHeader = parseJoseHeader(encodedProtected, JWEInvalid, "JWE Protected Header is invalid")), [
|
|
64
|
+
protectedHeader,
|
|
65
65
|
decodeBase64url(ciphertext, "ciphertext", JWEInvalid),
|
|
66
66
|
iv !== void 0 ? decodeBase64url(iv, "iv", JWEInvalid) : void 0,
|
|
67
67
|
tag !== void 0 ? decodeBase64url(tag, "tag", JWEInvalid) : void 0,
|
|
68
|
-
|
|
68
|
+
encodeAsciiMember((encodedProtected ?? "") + (aad !== void 0 ? `.${aad}` : ""), "aad", JWEInvalid)
|
|
69
69
|
];
|
|
70
70
|
}
|
|
71
71
|
function prepareDecrypt(options) {
|
|
@@ -78,16 +78,16 @@ function prepareDecrypt(options) {
|
|
|
78
78
|
];
|
|
79
79
|
}
|
|
80
80
|
async function decryptJWE(jwe, shared, key, token = shareJWE(jwe)) {
|
|
81
|
-
const [
|
|
81
|
+
const [protectedHeader, ciphertext, iv, tag, additionalAuthenticatedData] = token, { header, unprotected, aad } = jwe;
|
|
82
82
|
let joseHeader;
|
|
83
83
|
if (header !== void 0 || unprotected !== void 0) {
|
|
84
|
-
if (!isDisjoint(
|
|
84
|
+
if (!isDisjoint(protectedHeader, header, unprotected))
|
|
85
85
|
throw new JWEInvalid("JWE Protected, JWE Unprotected Header, and JWE Per-Recipient Unprotected Header Parameter names must be disjoint");
|
|
86
|
-
joseHeader = { ...
|
|
86
|
+
joseHeader = { ...protectedHeader, ...header, ...unprotected };
|
|
87
87
|
} else
|
|
88
|
-
joseHeader =
|
|
88
|
+
joseHeader = protectedHeader ?? {};
|
|
89
89
|
const [keyManagementAlgorithms, contentEncryptionAlgorithms, crit, maxPBES2Count, maxDecompressedLength] = shared, { encrypted_key: encodedKey } = jwe;
|
|
90
|
-
validateCrit(JWEInvalid, JWE_RECOGNIZED, crit,
|
|
90
|
+
validateCrit(JWEInvalid, JWE_RECOGNIZED, crit, protectedHeader, joseHeader), validateZip(joseHeader, protectedHeader);
|
|
91
91
|
const { alg, enc } = joseHeader;
|
|
92
92
|
if (typeof alg != "string" || !alg)
|
|
93
93
|
throw new JWEInvalid("missing JWE Algorithm (alg) in JWE Header");
|
|
@@ -122,13 +122,13 @@ async function decryptJWE(jwe, shared, key, token = shareJWE(jwe)) {
|
|
|
122
122
|
encryptedKey = new Uint8Array();
|
|
123
123
|
}
|
|
124
124
|
let resolvedKey = !1;
|
|
125
|
-
typeof key == "function" && (key = await key(
|
|
125
|
+
typeof key == "function" && (key = await key(protectedHeader, jwe), resolvedKey = !0);
|
|
126
126
|
const algEntry = selected ?? jweAlgorithm(alg);
|
|
127
127
|
isJWECEKTransport(algEntry) && encryptedKey === void 0 && (encryptedKey = new Uint8Array());
|
|
128
128
|
const k = await prepareKey(algEntry.mode === "direct-encryption" ? encEntry : algEntry, key, "decrypt");
|
|
129
129
|
let plaintext;
|
|
130
130
|
if (algEntry.mode === "integrated-encryption")
|
|
131
|
-
plaintext = await algEntry.decrypt(k, encryptedKey, ciphertext,
|
|
131
|
+
plaintext = await algEntry.decrypt(k, encryptedKey, ciphertext, additionalAuthenticatedData, protectedHeader, joseHeader);
|
|
132
132
|
else {
|
|
133
133
|
const encryption = encEntry;
|
|
134
134
|
let cek;
|
|
@@ -139,7 +139,7 @@ async function decryptJWE(jwe, shared, key, token = shareJWE(jwe)) {
|
|
|
139
139
|
throw err;
|
|
140
140
|
cek = generateCek(encryption);
|
|
141
141
|
}
|
|
142
|
-
plaintext = await decrypt(encryption, cek, ciphertext, iv, tag,
|
|
142
|
+
plaintext = await decrypt(encryption, cek, ciphertext, iv, tag, additionalAuthenticatedData);
|
|
143
143
|
}
|
|
144
144
|
if (joseHeader.zip === "DEF") {
|
|
145
145
|
const decompressionLimit = maxDecompressedLength ?? 25e4;
|
|
@@ -153,7 +153,7 @@ async function decryptJWE(jwe, shared, key, token = shareJWE(jwe)) {
|
|
|
153
153
|
}
|
|
154
154
|
return {
|
|
155
155
|
plaintext,
|
|
156
|
-
...
|
|
156
|
+
...protectedHeader && { protectedHeader },
|
|
157
157
|
...aad !== void 0 && {
|
|
158
158
|
additionalAuthenticatedData: decodeBase64url(aad, "aad", JWEInvalid)
|
|
159
159
|
},
|
package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/jwe_encrypt.js
CHANGED
|
@@ -48,17 +48,17 @@ async function encryptJWE(input, checked, key) {
|
|
|
48
48
|
const algEntry = selected ?? jweAlgorithm(joseHeader.alg);
|
|
49
49
|
let encryptedKey, parameters, cek;
|
|
50
50
|
algEntry.mode === "integrated-encryption" ? cek = await prepareKey(algEntry, key, "encrypt") : [cek, encryptedKey, parameters] = await encryptKeyManagement(algEntry, encEntry, key, joseHeader, providedCek, keyManagementParameters), parameters && (unprotectedParameters ? unprotectedHeader = unprotectedHeader ? { ...unprotectedHeader, ...parameters } : parameters : protectedHeader = protectedHeader ? { ...protectedHeader, ...parameters } : parameters, checkDisjoint(protectedHeader, unprotectedHeader, sharedUnprotectedHeader));
|
|
51
|
-
const
|
|
51
|
+
const encodedProtectedHeader = protectedHeader ? b64u(JSON.stringify(protectedHeader)) : "", encodedAad = aad?.byteLength ? b64u(aad) : void 0, additionalAuthenticatedData = encode(encodedAad ? `${encodedProtectedHeader}.${encodedAad}` : encodedProtectedHeader);
|
|
52
52
|
let plaintext = inputPlaintext;
|
|
53
53
|
joseHeader.zip === "DEF" && (plaintext = await compress(plaintext).catch((cause) => {
|
|
54
54
|
throw new JWEInvalid("Failed to compress plaintext", { cause });
|
|
55
55
|
}));
|
|
56
56
|
let ciphertext, tag, iv;
|
|
57
|
-
algEntry.mode === "integrated-encryption" ? [encryptedKey, ciphertext] = await algEntry.encrypt(cek, plaintext,
|
|
57
|
+
algEntry.mode === "integrated-encryption" ? [encryptedKey, ciphertext] = await algEntry.encrypt(cek, plaintext, additionalAuthenticatedData, protectedHeader, joseHeader, keyManagementParameters) : { ciphertext, tag, iv } = await encrypt(encEntry, plaintext, cek, inputIv, additionalAuthenticatedData);
|
|
58
58
|
const jwe = {
|
|
59
59
|
ciphertext: b64u(ciphertext)
|
|
60
60
|
};
|
|
61
|
-
return iv && (jwe.iv = b64u(iv)), tag && (jwe.tag = b64u(tag)), encryptedKey?.byteLength && (jwe.encrypted_key = b64u(encryptedKey)),
|
|
61
|
+
return iv && (jwe.iv = b64u(iv)), tag && (jwe.tag = b64u(tag)), encryptedKey?.byteLength && (jwe.encrypted_key = b64u(encryptedKey)), encodedAad && (jwe.aad = encodedAad), protectedHeader && (jwe.protected = encodedProtectedHeader), sharedUnprotectedHeader && (jwe.unprotected = sharedUnprotectedHeader), unprotectedHeader && (jwe.header = unprotectedHeader), jwe;
|
|
62
62
|
}
|
|
63
63
|
async function createJWE(input, key, options) {
|
|
64
64
|
return encryptJWE(input, checkEncryptHeaders(input, options), key);
|
package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/jws_sign.js
CHANGED
|
@@ -5,10 +5,10 @@ import { JWSInvalid } from "../util/errors.js";
|
|
|
5
5
|
import { concat, encode, encoder } from "./buffer_utils.js";
|
|
6
6
|
import { prepareKey, rawKey, checkModulusLength } from "./key.js";
|
|
7
7
|
async function createSignature(input, key, rejectUnencoded) {
|
|
8
|
-
let [payload, protectedHeader, unprotectedHeader, crit] = input,
|
|
8
|
+
let [payload, protectedHeader, unprotectedHeader, crit] = input, encodedProtectedHeader = "";
|
|
9
9
|
if (protectedHeader !== void 0) {
|
|
10
10
|
const normalized = serializeJoseHeader(JWSInvalid, protectedHeader);
|
|
11
|
-
protectedHeader = normalized[0],
|
|
11
|
+
protectedHeader = normalized[0], encodedProtectedHeader = b64u(normalized[1]);
|
|
12
12
|
}
|
|
13
13
|
if (unprotectedHeader !== void 0 && (unprotectedHeader = serializeJoseHeader(JWSInvalid, unprotectedHeader)[0]), !protectedHeader && !unprotectedHeader)
|
|
14
14
|
throw new JWSInvalid("either setProtectedHeader or setUnprotectedHeader must be called before #sign()");
|
|
@@ -22,19 +22,19 @@ async function createSignature(input, key, rejectUnencoded) {
|
|
|
22
22
|
if (typeof alg != "string" || !alg)
|
|
23
23
|
throw new JWSInvalid('JWS "alg" (Algorithm) Header Parameter missing or invalid');
|
|
24
24
|
const entry = jwsAlgorithm(alg);
|
|
25
|
-
let
|
|
25
|
+
let encodedPayload = "", signingPayload = payload, signingInput;
|
|
26
26
|
if (b64) {
|
|
27
|
-
const
|
|
28
|
-
|
|
27
|
+
const encodedPayloadCache = input[4];
|
|
28
|
+
encodedPayloadCache ? (encodedPayload = encodedPayloadCache[0] ??= b64u(payload), signingPayload = encodedPayloadCache[1] ??= encode(encodedPayload)) : (encodedPayload = b64u(payload), signingInput = encoder.encode(`${encodedProtectedHeader}.${encodedPayload}`));
|
|
29
29
|
}
|
|
30
|
-
|
|
31
|
-
const
|
|
32
|
-
entry.minRsaBits && checkModulusLength(entry.alg,
|
|
30
|
+
signingInput ??= concat(encode(encodedProtectedHeader), encode("."), signingPayload);
|
|
31
|
+
const signingKey = await rawKey(await prepareKey(entry, key, "sign"), entry.subtle, "sign");
|
|
32
|
+
entry.minRsaBits && checkModulusLength(entry.alg, signingKey);
|
|
33
33
|
const jws = {
|
|
34
|
-
signature: b64u(new Uint8Array(await crypto.subtle.sign(entry.signing,
|
|
35
|
-
payload:
|
|
34
|
+
signature: b64u(new Uint8Array(await crypto.subtle.sign(entry.signing, signingKey, signingInput))),
|
|
35
|
+
payload: encodedPayload
|
|
36
36
|
};
|
|
37
|
-
return protectedHeader && (jws.protected =
|
|
37
|
+
return protectedHeader && (jws.protected = encodedProtectedHeader), unprotectedHeader && (jws.header = unprotectedHeader), [jws, b64];
|
|
38
38
|
}
|
|
39
39
|
async function createCompactSignature(payload, protectedHeader, crit, key, rejectUnencoded) {
|
|
40
40
|
const [jws] = await createSignature([payload, protectedHeader, void 0, crit], key, rejectUnencoded);
|
package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/jws_verify.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
import { jwsAlgorithm } from "./jws_algorithms.js";
|
|
2
2
|
import { JOSEAlgNotAllowed, JWSInvalid, JWSSignatureVerificationFailed } from "../util/errors.js";
|
|
3
3
|
import { concat, decoder, encoder, encode } from "./buffer_utils.js";
|
|
4
|
-
import { decodeBase64url,
|
|
4
|
+
import { decodeBase64url, encodeAsciiMember, parseJoseHeader, isDisjoint, isObject, validateB64, validateCrit, validateAlgorithms, JWS_RECOGNIZED } from "./validate.js";
|
|
5
5
|
import { prepareKey, rawKey, checkModulusLength } from "./key.js";
|
|
6
6
|
function snapshotJws(jws, sharedPayload) {
|
|
7
|
-
const
|
|
7
|
+
const encodedProtectedHeader = jws.protected, inputHeader = jws.header, header = isObject(inputHeader) ? { ...inputHeader } : inputHeader;
|
|
8
8
|
let payload = sharedPayload ? sharedPayload[0] : jws.payload;
|
|
9
9
|
!sharedPayload && payload instanceof Uint8Array && (payload = new Uint8Array(payload));
|
|
10
10
|
const signature = jws.signature, snapshot = { payload, signature };
|
|
11
|
-
if (
|
|
11
|
+
if (encodedProtectedHeader !== void 0 && (snapshot.protected = encodedProtectedHeader), inputHeader !== void 0 && (snapshot.header = header), encodedProtectedHeader === void 0 && header === void 0)
|
|
12
12
|
throw new JWSInvalid('Flattened JWS must have either of the "protected" or "header" members');
|
|
13
|
-
if (
|
|
13
|
+
if (encodedProtectedHeader !== void 0 && typeof encodedProtectedHeader != "string")
|
|
14
14
|
throw new JWSInvalid("JWS Protected Header incorrect type");
|
|
15
15
|
if (payload === void 0)
|
|
16
16
|
throw new JWSInvalid("JWS Payload missing");
|
|
@@ -23,8 +23,8 @@ function snapshotJws(jws, sharedPayload) {
|
|
|
23
23
|
function prepareVerify(options) {
|
|
24
24
|
return [options && validateAlgorithms("algorithms", options.algorithms), options?.crit];
|
|
25
25
|
}
|
|
26
|
-
function parseProtectedHeader(
|
|
27
|
-
return
|
|
26
|
+
function parseProtectedHeader(encodedProtectedHeader) {
|
|
27
|
+
return encodedProtectedHeader === void 0 ? {} : parseJoseHeader(encodedProtectedHeader, JWSInvalid, "JWS Protected Header is invalid");
|
|
28
28
|
}
|
|
29
29
|
function encodeJsonUnencodedPayload(payload) {
|
|
30
30
|
const invalid = /[\p{Cs}\p{Cn}]/u.exec(payload)?.[0];
|
|
@@ -35,15 +35,17 @@ function encodeJsonUnencodedPayload(payload) {
|
|
|
35
35
|
function encodeCompactUnencodedPayload(payload) {
|
|
36
36
|
try {
|
|
37
37
|
return encode(payload);
|
|
38
|
-
} catch {
|
|
39
|
-
throw new JWSInvalid("JWS Compact Serialization payload must use only ASCII characters"
|
|
38
|
+
} catch (cause) {
|
|
39
|
+
throw new JWSInvalid("JWS Compact Serialization payload must use only ASCII characters", {
|
|
40
|
+
cause
|
|
41
|
+
});
|
|
40
42
|
}
|
|
41
43
|
}
|
|
42
44
|
async function verifySignature(jws, shared, key, encodeUnencodedPayload, parsedProtected) {
|
|
43
|
-
const { protected:
|
|
44
|
-
if (!isDisjoint(
|
|
45
|
+
const { protected: encodedProtectedHeader, header, payload: inputPayload } = jws, protectedHeader = parsedProtected ?? parseProtectedHeader(encodedProtectedHeader);
|
|
46
|
+
if (!isDisjoint(protectedHeader, header))
|
|
45
47
|
throw new JWSInvalid("JWS Protected and JWS Unprotected Header Parameter names must be disjoint");
|
|
46
|
-
const joseHeader = { ...
|
|
48
|
+
const joseHeader = { ...protectedHeader, ...header }, b64 = validateB64(protectedHeader, validateCrit(JWSInvalid, JWS_RECOGNIZED, shared[1], protectedHeader, joseHeader)), { alg } = joseHeader;
|
|
47
49
|
if (typeof alg != "string" || !alg)
|
|
48
50
|
throw new JWSInvalid('JWS "alg" (Algorithm) Header Parameter missing or invalid');
|
|
49
51
|
if (shared[0] && !shared[0].has(alg))
|
|
@@ -55,18 +57,19 @@ async function verifySignature(jws, shared, key, encodeUnencodedPayload, parsedP
|
|
|
55
57
|
throw new JWSInvalid("JWS Payload must be a string or an Uint8Array instance");
|
|
56
58
|
const signingPayload = b64 || typeof inputPayload != "string" ? inputPayload : encodeUnencodedPayload(inputPayload);
|
|
57
59
|
let resolvedKey = !1;
|
|
58
|
-
typeof key == "function" && (key = await key(
|
|
59
|
-
const entry = jwsAlgorithm(alg),
|
|
60
|
+
typeof key == "function" && (key = await key(protectedHeader, jws), resolvedKey = !0);
|
|
61
|
+
const entry = jwsAlgorithm(alg), signingInput = concat(encodedProtectedHeader !== void 0 ? encode(encodedProtectedHeader) : new Uint8Array(), encode("."), typeof signingPayload == "string" ? shared[2] ??= encodeAsciiMember(signingPayload, "payload", JWSInvalid) : signingPayload), signature = decodeBase64url(jws.signature, "signature", JWSInvalid), verificationKey = await prepareKey(entry, key, "verify"), cryptoKey = await rawKey(verificationKey, entry.subtle, "verify");
|
|
60
62
|
entry.minRsaBits && checkModulusLength(entry.alg, cryptoKey);
|
|
61
63
|
let verified = !1;
|
|
62
64
|
try {
|
|
63
|
-
verified = await crypto.subtle.verify(entry.signing, cryptoKey, signature,
|
|
64
|
-
} catch {
|
|
65
|
+
verified = await crypto.subtle.verify(entry.signing, cryptoKey, signature, signingInput);
|
|
66
|
+
} catch (cause) {
|
|
67
|
+
throw new JWSSignatureVerificationFailed(void 0, { cause });
|
|
65
68
|
}
|
|
66
69
|
if (!verified)
|
|
67
70
|
throw new JWSSignatureVerificationFailed();
|
|
68
71
|
const result = { payload: typeof signingPayload == "string" ? decodeBase64url(signingPayload, "payload", JWSInvalid) : signingPayload };
|
|
69
|
-
return
|
|
72
|
+
return encodedProtectedHeader !== void 0 && (result.protectedHeader = protectedHeader), header !== void 0 && (result.unprotectedHeader = header), resolvedKey ? [{ ...result, key: verificationKey }, b64] : [result, b64];
|
|
70
73
|
}
|
|
71
74
|
async function verifyCompact(jws, shared, key) {
|
|
72
75
|
if (jws instanceof Uint8Array && (jws = decoder.decode(jws)), typeof jws != "string")
|