@zuplo/cli 7.12.4 → 7.12.5
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/@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/package.json +1 -1
- package/package.json +11 -11
package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/jwt_claims_set.js
CHANGED
|
@@ -16,8 +16,8 @@ function secs(str) {
|
|
|
16
16
|
typeof str != "string" && invalidDuration();
|
|
17
17
|
const matched = REGEX.exec(str);
|
|
18
18
|
(!matched || matched[4] && matched[1]) && invalidDuration();
|
|
19
|
-
const value = parseFloat(matched[2]),
|
|
20
|
-
return Number.isFinite(
|
|
19
|
+
const value = parseFloat(matched[2]), durationSeconds = Math.round(value * multipliers[matched[3][0].toLowerCase()]);
|
|
20
|
+
return Number.isFinite(durationSeconds) || invalidDuration(), matched[1] === "-" || matched[4] === "ago" ? -durationSeconds : durationSeconds;
|
|
21
21
|
}
|
|
22
22
|
function validateInput(label, input) {
|
|
23
23
|
if (!Number.isFinite(input))
|
|
@@ -39,34 +39,35 @@ const normalizeTyp = (value) => {
|
|
|
39
39
|
const normalized = value.toLowerCase();
|
|
40
40
|
return value.includes("/") ? normalized : `application/${normalized}`;
|
|
41
41
|
}, checkAudiencePresence = (audPayload, audOption) => typeof audPayload == "string" ? audOption.includes(audPayload) : Array.isArray(audPayload) ? audOption.some((aud) => audPayload.includes(aud)) : !1;
|
|
42
|
-
function validateNumericDate(
|
|
43
|
-
const value =
|
|
42
|
+
function validateNumericDate(claimsSet, claim, required = !1) {
|
|
43
|
+
const value = claimsSet[claim];
|
|
44
44
|
if (!(value === void 0 && !required)) {
|
|
45
45
|
if (typeof value != "number")
|
|
46
|
-
throw new JWTClaimValidationFailed(`"${claim}" claim must be a number`,
|
|
46
|
+
throw new JWTClaimValidationFailed(`"${claim}" claim must be a number`, claimsSet, claim, "invalid");
|
|
47
47
|
return value;
|
|
48
48
|
}
|
|
49
49
|
}
|
|
50
|
-
function unexpectedClaim(
|
|
51
|
-
throw new JWTClaimValidationFailed(`unexpected "${claim}" claim value`,
|
|
50
|
+
function unexpectedClaim(claimsSet, claim) {
|
|
51
|
+
throw new JWTClaimValidationFailed(`unexpected "${claim}" claim value`, claimsSet, claim, checkFailed);
|
|
52
52
|
}
|
|
53
|
-
function validateClaimsSet(protectedHeader,
|
|
54
|
-
let
|
|
53
|
+
function validateClaimsSet(protectedHeader, claimsSetBytes, options = {}) {
|
|
54
|
+
let claimsSet;
|
|
55
55
|
try {
|
|
56
|
-
|
|
57
|
-
} catch {
|
|
56
|
+
claimsSet = JSON.parse(strictDecoder.decode(claimsSetBytes));
|
|
57
|
+
} catch (cause) {
|
|
58
|
+
throw new JWTInvalid("JWT Claims Set must be a top-level JSON object", { cause });
|
|
58
59
|
}
|
|
59
|
-
if (!isObject(
|
|
60
|
+
if (!isObject(claimsSet))
|
|
60
61
|
throw new JWTInvalid("JWT Claims Set must be a top-level JSON object");
|
|
61
62
|
const { typ } = options;
|
|
62
63
|
if (typ !== void 0 && (typeof protectedHeader.typ != "string" || normalizeTyp(protectedHeader.typ) !== normalizeTyp(typ)))
|
|
63
|
-
throw new JWTClaimValidationFailed('unexpected "typ" JWT header value',
|
|
64
|
+
throw new JWTClaimValidationFailed('unexpected "typ" JWT header value', claimsSet, "typ", checkFailed);
|
|
64
65
|
const { requiredClaims = [], issuer, subject, audience, maxTokenAge } = options, presenceCheck = [...requiredClaims];
|
|
65
66
|
maxTokenAge !== void 0 && presenceCheck.push("iat"), audience !== void 0 && presenceCheck.push("aud"), subject !== void 0 && presenceCheck.push("sub"), issuer !== void 0 && presenceCheck.push("iss");
|
|
66
67
|
for (const claim of new Set(presenceCheck.reverse()))
|
|
67
|
-
if (!Object.hasOwn(
|
|
68
|
-
throw new JWTClaimValidationFailed(`missing required "${claim}" claim`,
|
|
69
|
-
issuer !== void 0 && !(Array.isArray(issuer) ? issuer : [issuer]).includes(
|
|
68
|
+
if (!Object.hasOwn(claimsSet, claim))
|
|
69
|
+
throw new JWTClaimValidationFailed(`missing required "${claim}" claim`, claimsSet, claim, "missing");
|
|
70
|
+
issuer !== void 0 && !(Array.isArray(issuer) ? issuer : [issuer]).includes(claimsSet.iss) && unexpectedClaim(claimsSet, "iss"), subject !== void 0 && claimsSet.sub !== subject && unexpectedClaim(claimsSet, "sub"), audience !== void 0 && !checkAudiencePresence(claimsSet.aud, typeof audience == "string" ? [audience] : audience) && unexpectedClaim(claimsSet, "aud");
|
|
70
71
|
const { clockTolerance } = options;
|
|
71
72
|
let tolerance = 0;
|
|
72
73
|
if (typeof clockTolerance == "string")
|
|
@@ -77,70 +78,70 @@ function validateClaimsSet(protectedHeader, encodedPayload, options = {}) {
|
|
|
77
78
|
tolerance = clockTolerance;
|
|
78
79
|
}
|
|
79
80
|
validateInput("clockTolerance option", tolerance);
|
|
80
|
-
const { currentDate } = options, now = validateInput("currentDate option", epoch(currentDate === void 0 ? /* @__PURE__ */ new Date() : currentDate)), iat = validateNumericDate(
|
|
81
|
+
const { currentDate } = options, now = validateInput("currentDate option", epoch(currentDate === void 0 ? /* @__PURE__ */ new Date() : currentDate)), iat = validateNumericDate(claimsSet, "iat", maxTokenAge !== void 0), nbf = validateNumericDate(claimsSet, "nbf");
|
|
81
82
|
if (nbf !== void 0 && nbf > now + tolerance)
|
|
82
|
-
throw new JWTClaimValidationFailed('"nbf" claim timestamp check failed',
|
|
83
|
-
const exp = validateNumericDate(
|
|
83
|
+
throw new JWTClaimValidationFailed('"nbf" claim timestamp check failed', claimsSet, "nbf", checkFailed);
|
|
84
|
+
const exp = validateNumericDate(claimsSet, "exp");
|
|
84
85
|
if (exp !== void 0 && exp <= now - tolerance)
|
|
85
|
-
throw new JWTExpired('"exp" claim timestamp check failed',
|
|
86
|
+
throw new JWTExpired('"exp" claim timestamp check failed', claimsSet, "exp", checkFailed);
|
|
86
87
|
if (maxTokenAge !== void 0) {
|
|
87
88
|
const age = now - iat, max = validateInput("maxTokenAge option", typeof maxTokenAge == "number" ? maxTokenAge : secs(maxTokenAge));
|
|
88
89
|
if (age - tolerance > max)
|
|
89
|
-
throw new JWTExpired('"iat" claim timestamp check failed (too far in the past)',
|
|
90
|
+
throw new JWTExpired('"iat" claim timestamp check failed (too far in the past)', claimsSet, "iat", checkFailed);
|
|
90
91
|
if (age < -tolerance)
|
|
91
|
-
throw new JWTClaimValidationFailed('"iat" claim timestamp check failed (it should be in the past)',
|
|
92
|
+
throw new JWTClaimValidationFailed('"iat" claim timestamp check failed (it should be in the past)', claimsSet, "iat", checkFailed);
|
|
92
93
|
}
|
|
93
|
-
return
|
|
94
|
+
return claimsSet;
|
|
94
95
|
}
|
|
95
|
-
let
|
|
96
|
-
function
|
|
97
|
-
return
|
|
96
|
+
let producerClaimsSets;
|
|
97
|
+
function producerClaimsSet(producer) {
|
|
98
|
+
return producerClaimsSets.get(producer);
|
|
98
99
|
}
|
|
99
|
-
function
|
|
100
|
-
const
|
|
100
|
+
function jwtClaimsSetBytes(producer) {
|
|
101
|
+
const claimsSet = producerClaimsSet(producer);
|
|
101
102
|
for (const claim of ["iat", "nbf", "exp"]) {
|
|
102
|
-
const value =
|
|
103
|
+
const value = claimsSet[claim];
|
|
103
104
|
if (typeof value == "number" && !Number.isFinite(value))
|
|
104
105
|
throw new TypeError(`"${claim}" claim must be a finite number`);
|
|
105
106
|
}
|
|
106
|
-
return encoder.encode(JSON.stringify(
|
|
107
|
+
return encoder.encode(JSON.stringify(claimsSet));
|
|
107
108
|
}
|
|
108
109
|
function jwtClaim(producer, claim) {
|
|
109
|
-
return
|
|
110
|
+
return producerClaimsSet(producer)[claim];
|
|
110
111
|
}
|
|
111
112
|
class JWTClaimsBuilder {
|
|
112
|
-
constructor(
|
|
113
|
-
if (!isObject(
|
|
113
|
+
constructor(claimsSet = {}) {
|
|
114
|
+
if (!isObject(claimsSet))
|
|
114
115
|
throw new TypeError("JWT Claims Set MUST be an object");
|
|
115
|
-
(
|
|
116
|
+
(producerClaimsSets ||= /* @__PURE__ */ new WeakMap()).set(this, structuredClone(claimsSet));
|
|
116
117
|
}
|
|
117
118
|
setIssuer(value) {
|
|
118
|
-
return validateStringClaim("iss", value),
|
|
119
|
+
return validateStringClaim("iss", value), producerClaimsSet(this).iss = value, this;
|
|
119
120
|
}
|
|
120
121
|
setSubject(value) {
|
|
121
|
-
return validateStringClaim("sub", value),
|
|
122
|
+
return validateStringClaim("sub", value), producerClaimsSet(this).sub = value, this;
|
|
122
123
|
}
|
|
123
124
|
setAudience(value) {
|
|
124
|
-
return validateAudienceClaim(value),
|
|
125
|
+
return validateAudienceClaim(value), producerClaimsSet(this).aud = value, this;
|
|
125
126
|
}
|
|
126
127
|
setJti(value) {
|
|
127
|
-
return validateStringClaim("jti", value),
|
|
128
|
+
return validateStringClaim("jti", value), producerClaimsSet(this).jti = value, this;
|
|
128
129
|
}
|
|
129
130
|
setNotBefore(value) {
|
|
130
|
-
return
|
|
131
|
+
return producerClaimsSet(this).nbf = numericDate(value, "setNotBefore"), this;
|
|
131
132
|
}
|
|
132
133
|
setExpirationTime(value) {
|
|
133
|
-
return
|
|
134
|
+
return producerClaimsSet(this).exp = numericDate(value, "setExpirationTime"), this;
|
|
134
135
|
}
|
|
135
136
|
setIssuedAt(value) {
|
|
136
|
-
const
|
|
137
|
-
return value === void 0 ?
|
|
137
|
+
const claimsSet = producerClaimsSet(this);
|
|
138
|
+
return value === void 0 ? claimsSet.iat = epoch(/* @__PURE__ */ new Date()) : typeof value == "string" ? claimsSet.iat = validateInput("setIssuedAt", epoch(/* @__PURE__ */ new Date()) + secs(value)) : claimsSet.iat = numericDate(value, "setIssuedAt"), this;
|
|
138
139
|
}
|
|
139
140
|
}
|
|
140
141
|
export {
|
|
141
142
|
JWTClaimsBuilder,
|
|
142
143
|
jwtClaim,
|
|
143
|
-
|
|
144
|
+
jwtClaimsSetBytes,
|
|
144
145
|
secs,
|
|
145
146
|
validateClaimsSet
|
|
146
147
|
};
|
|
@@ -17,15 +17,15 @@ const tag = (key) => key[Symbol.toStringTag], jwkMatchesOp = (entry, key, usage)
|
|
|
17
17
|
}
|
|
18
18
|
};
|
|
19
19
|
async function prepareKey(entry, key, usage) {
|
|
20
|
-
const { alg, secret } = entry,
|
|
20
|
+
const { alg, secret } = entry, requiresPrivateKey = usage === "decrypt" || usage === "sign";
|
|
21
21
|
if (secret && key instanceof Uint8Array)
|
|
22
22
|
return key;
|
|
23
23
|
let normalized, keyObject;
|
|
24
24
|
if (isObject(key)) {
|
|
25
25
|
if (normalized = normalizeJwk(key), typeof normalized.kty != "string")
|
|
26
26
|
throw invalidKeyType(alg, key, secret);
|
|
27
|
-
if (!(secret ? normalized.kty === "oct" && typeof normalized.k == "string" : normalized.kty !== "oct" && (
|
|
28
|
-
throw new TypeError(secret ? 'JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present' : `JSON Web Key for this operation must be a ${
|
|
27
|
+
if (!(secret ? normalized.kty === "oct" && typeof normalized.k == "string" : normalized.kty !== "oct" && (requiresPrivateKey ? normalized.kty === "AKP" && typeof normalized.priv == "string" || typeof normalized.d == "string" : normalized.d === void 0 && normalized.priv === void 0)))
|
|
28
|
+
throw new TypeError(secret ? 'JSON Web Key for symmetric algorithms must have JWK "kty" (Key Type) equal to "oct" and the JWK "k" (Key Value) present' : `JSON Web Key for this operation must be a ${requiresPrivateKey ? "private" : "public"} JWK`);
|
|
29
29
|
if (jwkMatchesOp(entry, normalized, usage), normalized.kty === "oct")
|
|
30
30
|
return decode(normalized.k);
|
|
31
31
|
if (!Object.isFrozen(key)) {
|
|
@@ -35,7 +35,7 @@ async function prepareKey(entry, key, usage) {
|
|
|
35
35
|
} else {
|
|
36
36
|
if (!isKeyLike(key))
|
|
37
37
|
throw invalidKeyType(alg, key, secret);
|
|
38
|
-
const expectedType = secret ? "secret" :
|
|
38
|
+
const expectedType = secret ? "secret" : requiresPrivateKey ? "private" : "public";
|
|
39
39
|
if (key.type !== expectedType && (secret || ["secret", "public", "private"].includes(key.type)))
|
|
40
40
|
throw new TypeError(`${tag(key)} instances must be of type "${expectedType}" for the ${alg} algorithm`);
|
|
41
41
|
if (isCryptoKey(key))
|
package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/key_management.js
CHANGED
|
@@ -26,32 +26,32 @@ async function deriveKey(p2s, alg, p2c, key) {
|
|
|
26
26
|
throw new JWEInvalid("PBES2 Salt Input must be 8 or more octets");
|
|
27
27
|
if (!Number.isSafeInteger(p2c) || Math.sign(p2c) !== 1)
|
|
28
28
|
throw new JWEInvalid("PBES2 Count Input must be a positive integer");
|
|
29
|
-
const salt = concat(encode(alg), Uint8Array.of(0), p2s),
|
|
29
|
+
const salt = concat(encode(alg), Uint8Array.of(0), p2s), keyLengthBits = parseInt(alg.slice(13, 16), 10), subtleAlg = {
|
|
30
30
|
hash: `SHA-${alg.slice(8, 11)}`,
|
|
31
31
|
iterations: p2c,
|
|
32
32
|
name: "PBKDF2",
|
|
33
33
|
salt
|
|
34
34
|
}, cryptoKey = await rawKey(key, jweAlgorithm(alg).subtle, "deriveBits");
|
|
35
|
-
return new Uint8Array(await crypto.subtle.deriveBits(subtleAlg, cryptoKey,
|
|
35
|
+
return new Uint8Array(await crypto.subtle.deriveBits(subtleAlg, cryptoKey, keyLengthBits));
|
|
36
36
|
}
|
|
37
37
|
function lengthAndInput(input) {
|
|
38
38
|
return concat(uint32be(input.length), input);
|
|
39
39
|
}
|
|
40
|
-
async function concatKdf(Z,
|
|
41
|
-
const dkLen =
|
|
40
|
+
async function concatKdf(Z, keyDataLength, OtherInfo) {
|
|
41
|
+
const dkLen = keyDataLength >> 3, hashLen = 32, reps = Math.ceil(dkLen / hashLen), dk = new Uint8Array(reps * hashLen);
|
|
42
42
|
for (let i = 1; i <= reps; i++) {
|
|
43
43
|
const hashResult = await digest("sha256", concat(uint32be(i), Z, OtherInfo));
|
|
44
44
|
dk.set(hashResult, (i - 1) * hashLen);
|
|
45
45
|
}
|
|
46
46
|
return dk.slice(0, dkLen);
|
|
47
47
|
}
|
|
48
|
-
async function ecdhesDeriveKey(publicKey, privateKey,
|
|
48
|
+
async function ecdhesDeriveKey(publicKey, privateKey, algorithmId, keyDataLength, apu = new Uint8Array(), apv = new Uint8Array()) {
|
|
49
49
|
checkEcdhCryptoKey(publicKey), checkEcdhCryptoKey(privateKey, "deriveBits");
|
|
50
|
-
const otherInfo = concat(lengthAndInput(encode(
|
|
50
|
+
const otherInfo = concat(lengthAndInput(encode(algorithmId)), lengthAndInput(apu), lengthAndInput(apv), uint32be(keyDataLength)), Z = new Uint8Array(await crypto.subtle.deriveBits({
|
|
51
51
|
name: publicKey.algorithm.name,
|
|
52
52
|
public: publicKey
|
|
53
53
|
}, privateKey, publicKey.algorithm.name === "X25519" ? 256 : Math.ceil(parseInt(publicKey.algorithm.namedCurve.slice(-3), 10) / 8) << 3));
|
|
54
|
-
return concatKdf(Z,
|
|
54
|
+
return concatKdf(Z, keyDataLength, otherInfo);
|
|
55
55
|
}
|
|
56
56
|
function assertEcdhKey(key) {
|
|
57
57
|
assertCryptoKey(key);
|
|
@@ -100,10 +100,10 @@ async function decryptKeyManagement(entry, enc, key, encryptedKey, joseHeader, m
|
|
|
100
100
|
assertEcdhKey(key);
|
|
101
101
|
const ephemeralPublicKey = await jwkToKey(entry, epk), partyUInfo = partyInfo(joseHeader, "apu"), partyVInfo = partyInfo(joseHeader, "apv");
|
|
102
102
|
checkPartyInfo(partyUInfo, partyVInfo);
|
|
103
|
-
const
|
|
103
|
+
const derivedKey = await ecdhesDeriveKey(ephemeralPublicKey, key, direct ? enc.alg : alg, direct ? enc.cekBits : parseInt(alg.slice(-5, -2), 10), partyUInfo, partyVInfo);
|
|
104
104
|
if (direct)
|
|
105
|
-
return
|
|
106
|
-
key =
|
|
105
|
+
return derivedKey;
|
|
106
|
+
key = derivedKey;
|
|
107
107
|
break;
|
|
108
108
|
}
|
|
109
109
|
case "RSA-OAEP":
|
|
@@ -153,19 +153,19 @@ async function encryptKeyManagement(entry, enc, inputKey, joseHeader, providedCe
|
|
|
153
153
|
providedApu !== void 0 && assertUint8Array(providedApu, '"apu"'), providedApv !== void 0 && assertUint8Array(providedApv, '"apv"');
|
|
154
154
|
const apu = providedApu ?? partyInfo(joseHeader, "apu"), apv = providedApv ?? partyInfo(joseHeader, "apv");
|
|
155
155
|
checkPartyInfo(apu, apv);
|
|
156
|
-
let
|
|
157
|
-
providedParameters.epk !== void 0 ?
|
|
156
|
+
let ephemeralPrivateKey;
|
|
157
|
+
providedParameters.epk !== void 0 ? ephemeralPrivateKey = await prepareKey(entry, providedParameters.epk, "decrypt") : ephemeralPrivateKey = (await crypto.subtle.generateKey(key.algorithm, !0, ["deriveBits"])).privateKey;
|
|
158
158
|
const subtle = crypto.subtle;
|
|
159
|
-
let exportableEpk =
|
|
159
|
+
let exportableEpk = ephemeralPrivateKey;
|
|
160
160
|
if (!exportableEpk.extractable) {
|
|
161
161
|
if (typeof subtle.getPublicKey != "function")
|
|
162
162
|
throw new TypeError('CryptoKey for "epk" must be extractable');
|
|
163
|
-
exportableEpk = await subtle.getPublicKey(
|
|
163
|
+
exportableEpk = await subtle.getPublicKey(ephemeralPrivateKey, []);
|
|
164
164
|
}
|
|
165
|
-
const { x, y, crv, kty } = await subtle.exportKey("jwk", exportableEpk), direct = mode === "direct-key-agreement",
|
|
165
|
+
const { x, y, crv, kty } = await subtle.exportKey("jwk", exportableEpk), direct = mode === "direct-key-agreement", derivedKey = await ecdhesDeriveKey(key, ephemeralPrivateKey, direct ? enc.alg : alg, direct ? enc.cekBits : parseInt(alg.slice(-5, -2), 10), apu, apv), epk = { x, crv, kty };
|
|
166
166
|
if (kty === "EC" && (epk.y = y), parameters = { epk }, providedApu !== void 0 && (parameters.apu = b64u(providedApu)), providedApv !== void 0 && (parameters.apv = b64u(providedApv)), direct)
|
|
167
|
-
return [
|
|
168
|
-
key =
|
|
167
|
+
return [derivedKey, void 0, parameters];
|
|
168
|
+
key = derivedKey;
|
|
169
169
|
break;
|
|
170
170
|
}
|
|
171
171
|
case "RSA-OAEP": {
|
package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/lib/validate.js
CHANGED
|
@@ -32,23 +32,23 @@ function assertNotSet(value, name) {
|
|
|
32
32
|
function decodeBase64url(value, label, ErrorClass) {
|
|
33
33
|
try {
|
|
34
34
|
return decode(value);
|
|
35
|
-
} catch {
|
|
36
|
-
throw new ErrorClass(`Failed to base64url decode the ${label}
|
|
35
|
+
} catch (cause) {
|
|
36
|
+
throw new ErrorClass(`Failed to base64url decode the ${label}`, { cause });
|
|
37
37
|
}
|
|
38
38
|
}
|
|
39
|
-
function
|
|
39
|
+
function encodeAsciiMember(value, label, ErrorClass) {
|
|
40
40
|
try {
|
|
41
41
|
return encode(value);
|
|
42
|
-
} catch {
|
|
43
|
-
throw new ErrorClass(`The ${label} is not a valid base64url string
|
|
42
|
+
} catch (cause) {
|
|
43
|
+
throw new ErrorClass(`The ${label} is not a valid base64url string`, { cause });
|
|
44
44
|
}
|
|
45
45
|
}
|
|
46
|
-
function parseJoseHeader(
|
|
46
|
+
function parseJoseHeader(encodedProtectedHeader, ErrorClass, message) {
|
|
47
47
|
let parsed;
|
|
48
48
|
try {
|
|
49
|
-
parsed = JSON.parse(strictDecoder.decode(decode(
|
|
50
|
-
} catch {
|
|
51
|
-
throw new ErrorClass(message);
|
|
49
|
+
parsed = JSON.parse(strictDecoder.decode(decode(encodedProtectedHeader)));
|
|
50
|
+
} catch (cause) {
|
|
51
|
+
throw new ErrorClass(message, { cause });
|
|
52
52
|
}
|
|
53
53
|
if (!isObject(parsed))
|
|
54
54
|
throw new ErrorClass(message);
|
|
@@ -109,7 +109,7 @@ export {
|
|
|
109
109
|
assertNotSet,
|
|
110
110
|
assertUint8Array,
|
|
111
111
|
decodeBase64url,
|
|
112
|
-
|
|
112
|
+
encodeAsciiMember,
|
|
113
113
|
isDisjoint,
|
|
114
114
|
isJwkSet,
|
|
115
115
|
isObject,
|
package/node_modules/@modelcontextprotocol/sdk/node_modules/jose/dist/webapi/util/decode_jwt.js
CHANGED
|
@@ -5,28 +5,28 @@ import { JWTInvalid } from "./errors.js";
|
|
|
5
5
|
function decodeJwt(jwt) {
|
|
6
6
|
if (typeof jwt != "string")
|
|
7
7
|
throw new JWTInvalid("JWTs must use Compact JWS serialization, JWT must be a string");
|
|
8
|
-
const { 1:
|
|
8
|
+
const { 1: encodedPayload, length } = jwt.split(".");
|
|
9
9
|
if (length === 5)
|
|
10
10
|
throw new JWTInvalid("Only JWTs using Compact JWS serialization can be decoded");
|
|
11
11
|
if (length !== 3)
|
|
12
12
|
throw new JWTInvalid("Invalid JWT");
|
|
13
|
-
if (!
|
|
13
|
+
if (!encodedPayload)
|
|
14
14
|
throw new JWTInvalid("JWTs must contain a payload");
|
|
15
|
-
let
|
|
15
|
+
let claimsSetBytes;
|
|
16
16
|
try {
|
|
17
|
-
|
|
18
|
-
} catch {
|
|
19
|
-
throw new JWTInvalid("Failed to base64url decode the payload");
|
|
17
|
+
claimsSetBytes = b64u(encodedPayload);
|
|
18
|
+
} catch (cause) {
|
|
19
|
+
throw new JWTInvalid("Failed to base64url decode the payload", { cause });
|
|
20
20
|
}
|
|
21
|
-
let
|
|
21
|
+
let claimsSet;
|
|
22
22
|
try {
|
|
23
|
-
|
|
24
|
-
} catch {
|
|
25
|
-
throw new JWTInvalid("Failed to parse the decoded payload as JSON");
|
|
23
|
+
claimsSet = JSON.parse(strictDecoder.decode(claimsSetBytes));
|
|
24
|
+
} catch (cause) {
|
|
25
|
+
throw new JWTInvalid("Failed to parse the decoded payload as JSON", { cause });
|
|
26
26
|
}
|
|
27
|
-
if (!isObject(
|
|
27
|
+
if (!isObject(claimsSet))
|
|
28
28
|
throw new JWTInvalid("Invalid JWT Claims Set");
|
|
29
|
-
return
|
|
29
|
+
return claimsSet;
|
|
30
30
|
}
|
|
31
31
|
export {
|
|
32
32
|
decodeJwt
|
|
@@ -1,18 +1,18 @@
|
|
|
1
1
|
import { parseJoseHeader } from "../lib/validate.js";
|
|
2
2
|
function decodeProtectedHeader(token) {
|
|
3
|
-
let
|
|
3
|
+
let encodedProtectedHeader;
|
|
4
4
|
if (typeof token == "string") {
|
|
5
5
|
const parts = token.split(".");
|
|
6
|
-
(parts.length === 3 || parts.length === 5) && ([
|
|
6
|
+
(parts.length === 3 || parts.length === 5) && ([encodedProtectedHeader] = parts);
|
|
7
7
|
} else if (typeof token == "object" && token)
|
|
8
8
|
if ("protected" in token)
|
|
9
|
-
|
|
9
|
+
encodedProtectedHeader = token.protected;
|
|
10
10
|
else
|
|
11
11
|
throw new TypeError("Token does not contain a Protected Header");
|
|
12
12
|
const invalid = "Invalid Token or Protected Header formatting";
|
|
13
|
-
if (typeof
|
|
13
|
+
if (typeof encodedProtectedHeader != "string" || !encodedProtectedHeader)
|
|
14
14
|
throw new TypeError(invalid);
|
|
15
|
-
return parseJoseHeader(
|
|
15
|
+
return parseJoseHeader(encodedProtectedHeader, TypeError, invalid);
|
|
16
16
|
}
|
|
17
17
|
export {
|
|
18
18
|
decodeProtectedHeader
|