@arokodev/cli 0.1.0-alpha.5 → 0.1.0-alpha.8
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/@pairmesh/client/dist/build-info.generated.d.ts +12 -12
- package/node_modules/@pairmesh/client/dist/build-info.generated.js +6 -6
- package/node_modules/@pairmesh/client/dist/connectivity/relay/hosted-server.js +1 -1
- package/node_modules/@pairmesh/client/dist/session/schemas.d.ts +10 -10
- package/node_modules/@pairmesh/client/dist/session/schemas.d.ts.map +1 -1
- package/node_modules/@pairmesh/client/package.json +5 -5
- package/node_modules/@pairmesh/coordination/package.json +5 -5
- package/node_modules/@pairmesh/mcp/package.json +5 -5
- package/node_modules/@pairmesh/permissions/package.json +2 -2
- package/node_modules/@pairmesh/protocol/dist/action.d.ts +1 -1
- package/node_modules/@pairmesh/protocol/dist/inspection-execution.d.ts +1 -1
- package/node_modules/@pairmesh/protocol/dist/inspection-thread.d.ts +1 -1
- package/node_modules/@pairmesh/protocol/dist/inspection-thread.d.ts.map +1 -1
- package/node_modules/@pairmesh/protocol/dist/inspection.d.ts +2 -2
- package/node_modules/@pairmesh/protocol/dist/pairing.d.ts +1 -1
- package/node_modules/@pairmesh/protocol/dist/progress-event.d.ts +1 -1
- package/node_modules/@pairmesh/protocol/dist/progress-event.d.ts.map +1 -1
- package/node_modules/@pairmesh/protocol/package.json +2 -2
- package/node_modules/@pairmesh/shared/package.json +1 -1
- package/node_modules/body-parser/README.md +17 -13
- package/node_modules/body-parser/lib/read.js +74 -57
- package/node_modules/body-parser/lib/types/json.js +11 -11
- package/node_modules/body-parser/lib/types/urlencoded.js +5 -5
- package/node_modules/body-parser/lib/utils.js +0 -15
- package/node_modules/body-parser/package.json +7 -12
- package/node_modules/encodeurl/README.md +14 -0
- package/node_modules/encodeurl/index.js +9 -11
- package/node_modules/encodeurl/package.json +13 -6
- package/node_modules/jose/README.md +2 -2
- package/node_modules/jose/dist/types/jwe/compact/decrypt.d.ts +5 -4
- package/node_modules/jose/dist/types/jwe/compact/encrypt.d.ts +4 -4
- package/node_modules/jose/dist/types/jwe/flattened/decrypt.d.ts +5 -4
- package/node_modules/jose/dist/types/jwe/flattened/encrypt.d.ts +5 -5
- package/node_modules/jose/dist/types/jwe/general/decrypt.d.ts +5 -4
- package/node_modules/jose/dist/types/jwe/general/encrypt.d.ts +5 -5
- package/node_modules/jose/dist/types/jws/compact/sign.d.ts +5 -4
- package/node_modules/jose/dist/types/jws/compact/verify.d.ts +5 -5
- package/node_modules/jose/dist/types/jws/flattened/sign.d.ts +5 -4
- package/node_modules/jose/dist/types/jws/flattened/verify.d.ts +6 -5
- package/node_modules/jose/dist/types/jws/general/sign.d.ts +9 -6
- package/node_modules/jose/dist/types/jws/general/verify.d.ts +7 -5
- package/node_modules/jose/dist/types/jwt/decrypt.d.ts +10 -6
- package/node_modules/jose/dist/types/jwt/encrypt.d.ts +1 -1
- package/node_modules/jose/dist/types/jwt/sign.d.ts +1 -1
- package/node_modules/jose/dist/types/jwt/unsecured.d.ts +3 -1
- package/node_modules/jose/dist/types/jwt/verify.d.ts +6 -5
- package/node_modules/jose/dist/types/key/export.d.ts +1 -1
- package/node_modules/jose/dist/types/key/generate_secret.d.ts +1 -1
- package/node_modules/jose/dist/types/key/import.d.ts +2 -2
- package/node_modules/jose/dist/types/types.d.ts +173 -107
- package/node_modules/jose/dist/types/util/decode_jwt.d.ts +3 -2
- package/node_modules/jose/dist/types/util/errors.d.ts +1 -1
- package/node_modules/jose/dist/webapi/jwe/general/decrypt.js +3 -2
- package/node_modules/jose/dist/webapi/jwe/general/encrypt.js +3 -3
- package/node_modules/jose/dist/webapi/jwk/thumbprint.js +8 -8
- package/node_modules/jose/dist/webapi/jwks/local.js +2 -1
- package/node_modules/jose/dist/webapi/jwks/remote.js +6 -4
- package/node_modules/jose/dist/webapi/jws/general/sign.js +3 -3
- package/node_modules/jose/dist/webapi/jws/general/verify.js +5 -11
- package/node_modules/jose/dist/webapi/jwt/encrypt.js +6 -9
- package/node_modules/jose/dist/webapi/jwt/sign.js +2 -2
- package/node_modules/jose/dist/webapi/jwt/unsecured.js +3 -3
- package/node_modules/jose/dist/webapi/key/generate_secret.js +4 -4
- package/node_modules/jose/dist/webapi/lib/asn1.js +2 -2
- package/node_modules/jose/dist/webapi/lib/buffer_utils.js +4 -4
- package/node_modules/jose/dist/webapi/lib/content_encryption.js +8 -8
- package/node_modules/jose/dist/webapi/lib/deflate.js +2 -1
- package/node_modules/jose/dist/webapi/lib/jwe_decrypt.js +26 -23
- package/node_modules/jose/dist/webapi/lib/jwe_encrypt.js +5 -5
- package/node_modules/jose/dist/webapi/lib/jws_algorithms.js +2 -2
- package/node_modules/jose/dist/webapi/lib/jws_sign.js +11 -11
- package/node_modules/jose/dist/webapi/lib/jws_verify.js +19 -16
- package/node_modules/jose/dist/webapi/lib/jwt_claims_set.js +48 -44
- package/node_modules/jose/dist/webapi/lib/key.js +6 -4
- package/node_modules/jose/dist/webapi/lib/key_management.js +17 -18
- package/node_modules/jose/dist/webapi/lib/validate.js +10 -10
- package/node_modules/jose/dist/webapi/util/decode_jwt.js +12 -12
- package/node_modules/jose/dist/webapi/util/decode_protected_header.js +5 -5
- package/node_modules/jose/package.json +1 -1
- package/node_modules/object-inspect/CHANGELOG.md +31 -0
- package/node_modules/object-inspect/index.js +326 -24
- package/node_modules/object-inspect/package.json +22 -13
- package/node_modules/object-inspect/readme.markdown +4 -1
- package/node_modules/object-inspect/stringWidth.js +68 -0
- package/node_modules/object-inspect/stringWidthRanges.js +38 -0
- package/node_modules/on-finished/index.js +14 -2
- package/node_modules/on-finished/package.json +11 -7
- package/node_modules/qs/.editorconfig +1 -1
- package/node_modules/qs/.github/THREAT_MODEL.md +4 -2
- package/node_modules/qs/CHANGELOG.md +103 -14
- package/node_modules/qs/README.md +90 -9
- package/node_modules/qs/dist/qs.js +19 -19
- package/node_modules/qs/eslint.config.mjs +61 -50
- package/node_modules/qs/lib/formats.js +7 -2
- package/node_modules/qs/lib/parse.js +121 -12
- package/node_modules/qs/lib/stringify.js +9 -7
- package/node_modules/qs/lib/utils.js +158 -15
- package/node_modules/qs/package.json +8 -8
- package/node_modules/qs/test/parse.js +509 -2
- package/node_modules/qs/test/stringify.js +485 -33
- package/node_modules/qs/test/utils.js +245 -3
- package/node_modules/router/HISTORY.md +67 -52
- package/node_modules/router/README.md +222 -2
- package/node_modules/router/index.d.ts +188 -0
- package/node_modules/router/index.js +86 -50
- package/node_modules/router/lib/layer.js +154 -47
- package/node_modules/router/lib/param.js +47 -0
- package/node_modules/router/lib/route.d.ts +118 -0
- package/node_modules/router/lib/route.js +14 -8
- package/node_modules/router/lib/symbols.js +4 -0
- package/node_modules/router/lib/tracing.js +173 -0
- package/node_modules/router/package.json +24 -9
- package/node_modules/ws/README.md +22 -31
- package/node_modules/ws/lib/buffer-util.js +13 -2
- package/node_modules/ws/lib/receiver.js +8 -0
- package/node_modules/ws/lib/sender.js +4 -1
- package/node_modules/ws/lib/websocket-server.js +3 -0
- package/node_modules/ws/lib/websocket.js +66 -16
- package/node_modules/ws/package.json +1 -1
- package/node_modules/zod/package.json +1 -1
- package/node_modules/zod/src/v4/classic/tests/array.test.ts +27 -0
- package/node_modules/zod/src/v4/classic/tests/map.test.ts +7 -0
- package/node_modules/zod/src/v4/classic/tests/set.test.ts +6 -0
- package/node_modules/zod/src/v4/core/compile.ts +9 -0
- package/node_modules/zod/src/v4/core/schemas.ts +35 -1
- package/node_modules/zod/src/v4/core/util.ts +13 -0
- package/node_modules/zod/src/v4/core/versions.ts +1 -1
- package/node_modules/zod/v4/core/compile.cjs +8 -0
- package/node_modules/zod/v4/core/compile.js +8 -0
- package/node_modules/zod/v4/core/schemas.cjs +30 -0
- package/node_modules/zod/v4/core/schemas.d.cts +3 -1
- package/node_modules/zod/v4/core/schemas.d.ts +3 -1
- package/node_modules/zod/v4/core/schemas.js +30 -0
- package/node_modules/zod/v4/core/util.cjs +15 -0
- package/node_modules/zod/v4/core/util.d.cts +2 -0
- package/node_modules/zod/v4/core/util.d.ts +2 -0
- package/node_modules/zod/v4/core/util.js +14 -0
- package/node_modules/zod/v4/core/versions.cjs +1 -1
- package/node_modules/zod/v4/core/versions.js +1 -1
- package/package.json +7 -7
- package/node_modules/object-inspect/.eslintrc +0 -53
- package/node_modules/object-inspect/.nycrc +0 -13
- package/node_modules/object-inspect/example/all.js +0 -23
- package/node_modules/object-inspect/example/circular.js +0 -6
- package/node_modules/object-inspect/example/fn.js +0 -5
- package/node_modules/object-inspect/example/inspect.js +0 -10
- package/node_modules/object-inspect/test/bigint.js +0 -58
- package/node_modules/object-inspect/test/browser/dom.js +0 -15
- package/node_modules/object-inspect/test/circular.js +0 -16
- package/node_modules/object-inspect/test/deep.js +0 -12
- package/node_modules/object-inspect/test/element.js +0 -53
- package/node_modules/object-inspect/test/err.js +0 -48
- package/node_modules/object-inspect/test/fakes.js +0 -29
- package/node_modules/object-inspect/test/fn.js +0 -76
- package/node_modules/object-inspect/test/global.js +0 -17
- package/node_modules/object-inspect/test/has.js +0 -15
- package/node_modules/object-inspect/test/holes.js +0 -15
- package/node_modules/object-inspect/test/indent-option.js +0 -271
- package/node_modules/object-inspect/test/inspect.js +0 -139
- package/node_modules/object-inspect/test/lowbyte.js +0 -12
- package/node_modules/object-inspect/test/number.js +0 -58
- package/node_modules/object-inspect/test/quoteStyle.js +0 -26
- package/node_modules/object-inspect/test/toStringTag.js +0 -40
- package/node_modules/object-inspect/test/undef.js +0 -12
- package/node_modules/object-inspect/test/values.js +0 -261
- package/node_modules/object-inspect/test-core-js.js +0 -26
- package/node_modules/on-finished/HISTORY.md +0 -98
|
@@ -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]?.toLowerCase() === "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")
|
|
@@ -76,71 +77,74 @@ function validateClaimsSet(protectedHeader, encodedPayload, options = {}) {
|
|
|
76
77
|
throw new TypeError("Invalid clockTolerance option type");
|
|
77
78
|
tolerance = clockTolerance;
|
|
78
79
|
}
|
|
79
|
-
validateInput("clockTolerance option", tolerance)
|
|
80
|
-
|
|
80
|
+
if (validateInput("clockTolerance option", tolerance), tolerance < 0)
|
|
81
|
+
throw new TypeError("Invalid clockTolerance option input");
|
|
82
|
+
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
83
|
if (nbf !== void 0 && nbf > now + tolerance)
|
|
82
|
-
throw new JWTClaimValidationFailed('"nbf" claim timestamp check failed',
|
|
83
|
-
const exp = validateNumericDate(
|
|
84
|
+
throw new JWTClaimValidationFailed('"nbf" claim timestamp check failed', claimsSet, "nbf", checkFailed);
|
|
85
|
+
const exp = validateNumericDate(claimsSet, "exp");
|
|
84
86
|
if (exp !== void 0 && exp <= now - tolerance)
|
|
85
|
-
throw new JWTExpired('"exp" claim timestamp check failed',
|
|
87
|
+
throw new JWTExpired('"exp" claim timestamp check failed', claimsSet, "exp", checkFailed);
|
|
86
88
|
if (maxTokenAge !== void 0) {
|
|
87
89
|
const age = now - iat, max = validateInput("maxTokenAge option", typeof maxTokenAge == "number" ? maxTokenAge : secs(maxTokenAge));
|
|
90
|
+
if (max < 0)
|
|
91
|
+
throw new TypeError("Invalid maxTokenAge option input");
|
|
88
92
|
if (age - tolerance > max)
|
|
89
|
-
throw new JWTExpired('"iat" claim timestamp check failed (too far in the past)',
|
|
93
|
+
throw new JWTExpired('"iat" claim timestamp check failed (too far in the past)', claimsSet, "iat", checkFailed);
|
|
90
94
|
if (age < -tolerance)
|
|
91
|
-
throw new JWTClaimValidationFailed('"iat" claim timestamp check failed (it should be in the past)',
|
|
95
|
+
throw new JWTClaimValidationFailed('"iat" claim timestamp check failed (it should be in the past)', claimsSet, "iat", checkFailed);
|
|
92
96
|
}
|
|
93
|
-
return
|
|
97
|
+
return claimsSet;
|
|
94
98
|
}
|
|
95
|
-
let
|
|
96
|
-
function
|
|
97
|
-
return
|
|
99
|
+
let producerClaimsSets;
|
|
100
|
+
function producerClaimsSet(producer) {
|
|
101
|
+
return producerClaimsSets.get(producer);
|
|
98
102
|
}
|
|
99
|
-
function
|
|
100
|
-
const
|
|
103
|
+
function jwtClaimsSetBytes(producer) {
|
|
104
|
+
const claimsSet = producerClaimsSet(producer);
|
|
101
105
|
for (const claim of ["iat", "nbf", "exp"]) {
|
|
102
|
-
const value =
|
|
106
|
+
const value = claimsSet[claim];
|
|
103
107
|
if (typeof value == "number" && !Number.isFinite(value))
|
|
104
108
|
throw new TypeError(`"${claim}" claim must be a finite number`);
|
|
105
109
|
}
|
|
106
|
-
return encoder.encode(JSON.stringify(
|
|
110
|
+
return encoder.encode(JSON.stringify(claimsSet));
|
|
107
111
|
}
|
|
108
112
|
function jwtClaim(producer, claim) {
|
|
109
|
-
return
|
|
113
|
+
return producerClaimsSet(producer)[claim];
|
|
110
114
|
}
|
|
111
115
|
class JWTClaimsBuilder {
|
|
112
|
-
constructor(
|
|
113
|
-
if (!isObject(
|
|
116
|
+
constructor(claimsSet = {}) {
|
|
117
|
+
if (!isObject(claimsSet))
|
|
114
118
|
throw new TypeError("JWT Claims Set MUST be an object");
|
|
115
|
-
(
|
|
119
|
+
(producerClaimsSets ||= /* @__PURE__ */ new WeakMap()).set(this, structuredClone(claimsSet));
|
|
116
120
|
}
|
|
117
121
|
setIssuer(value) {
|
|
118
|
-
return validateStringClaim("iss", value),
|
|
122
|
+
return validateStringClaim("iss", value), producerClaimsSet(this).iss = value, this;
|
|
119
123
|
}
|
|
120
124
|
setSubject(value) {
|
|
121
|
-
return validateStringClaim("sub", value),
|
|
125
|
+
return validateStringClaim("sub", value), producerClaimsSet(this).sub = value, this;
|
|
122
126
|
}
|
|
123
127
|
setAudience(value) {
|
|
124
|
-
return validateAudienceClaim(value),
|
|
128
|
+
return validateAudienceClaim(value), producerClaimsSet(this).aud = value, this;
|
|
125
129
|
}
|
|
126
130
|
setJti(value) {
|
|
127
|
-
return validateStringClaim("jti", value),
|
|
131
|
+
return validateStringClaim("jti", value), producerClaimsSet(this).jti = value, this;
|
|
128
132
|
}
|
|
129
133
|
setNotBefore(value) {
|
|
130
|
-
return
|
|
134
|
+
return producerClaimsSet(this).nbf = numericDate(value, "setNotBefore"), this;
|
|
131
135
|
}
|
|
132
136
|
setExpirationTime(value) {
|
|
133
|
-
return
|
|
137
|
+
return producerClaimsSet(this).exp = numericDate(value, "setExpirationTime"), this;
|
|
134
138
|
}
|
|
135
139
|
setIssuedAt(value) {
|
|
136
|
-
const
|
|
137
|
-
return value === void 0 ?
|
|
140
|
+
const claimsSet = producerClaimsSet(this);
|
|
141
|
+
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
142
|
}
|
|
139
143
|
}
|
|
140
144
|
export {
|
|
141
145
|
JWTClaimsBuilder,
|
|
142
146
|
jwtClaim,
|
|
143
|
-
|
|
147
|
+
jwtClaimsSetBytes,
|
|
144
148
|
secs,
|
|
145
149
|
validateClaimsSet
|
|
146
150
|
};
|
|
@@ -8,6 +8,8 @@ const tag = (key) => key[Symbol.toStringTag], jwkMatchesOp = (entry, key, usage)
|
|
|
8
8
|
if (key.use !== expected)
|
|
9
9
|
throw new TypeError(`Invalid key for this operation, its "use" must be "${expected}" when present`);
|
|
10
10
|
}
|
|
11
|
+
if (key.kty === "AKP" && key.alg === void 0)
|
|
12
|
+
throw new TypeError('missing "alg" (Algorithm) Parameter value');
|
|
11
13
|
if (key.alg !== void 0 && key.alg !== alg)
|
|
12
14
|
throw new TypeError(`Invalid key for this operation, its "alg" must be "${alg}" when present`);
|
|
13
15
|
if (Array.isArray(key.key_ops)) {
|
|
@@ -17,15 +19,15 @@ const tag = (key) => key[Symbol.toStringTag], jwkMatchesOp = (entry, key, usage)
|
|
|
17
19
|
}
|
|
18
20
|
};
|
|
19
21
|
async function prepareKey(entry, key, usage) {
|
|
20
|
-
const { alg, secret } = entry,
|
|
22
|
+
const { alg, secret } = entry, requiresPrivateKey = usage === "decrypt" || usage === "sign";
|
|
21
23
|
if (secret && key instanceof Uint8Array)
|
|
22
24
|
return key;
|
|
23
25
|
let normalized, keyObject;
|
|
24
26
|
if (isObject(key)) {
|
|
25
27
|
if (normalized = normalizeJwk(key), typeof normalized.kty != "string")
|
|
26
28
|
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 ${
|
|
29
|
+
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)))
|
|
30
|
+
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
31
|
if (jwkMatchesOp(entry, normalized, usage), normalized.kty === "oct")
|
|
30
32
|
return decode(normalized.k);
|
|
31
33
|
if (!Object.isFrozen(key)) {
|
|
@@ -35,7 +37,7 @@ async function prepareKey(entry, key, usage) {
|
|
|
35
37
|
} else {
|
|
36
38
|
if (!isKeyLike(key))
|
|
37
39
|
throw invalidKeyType(alg, key, secret);
|
|
38
|
-
const expectedType = secret ? "secret" :
|
|
40
|
+
const expectedType = secret ? "secret" : requiresPrivateKey ? "private" : "public";
|
|
39
41
|
if (key.type !== expectedType && (secret || ["secret", "public", "private"].includes(key.type)))
|
|
40
42
|
throw new TypeError(`${tag(key)} instances must be of type "${expectedType}" for the ${alg} algorithm`);
|
|
41
43
|
if (isCryptoKey(key))
|
|
@@ -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":
|
|
@@ -111,7 +111,6 @@ async function decryptKeyManagement(entry, enc, key, encryptedKey, joseHeader, m
|
|
|
111
111
|
case "PBKDF2": {
|
|
112
112
|
if (typeof joseHeader.p2c != "number")
|
|
113
113
|
throw new JWEInvalid('JOSE Header "p2c" (PBES2 Count) missing or invalid');
|
|
114
|
-
validateMaxPBES2Count(maxPBES2Count);
|
|
115
114
|
const p2cLimit = maxPBES2Count ?? 1e4;
|
|
116
115
|
if (joseHeader.p2c > p2cLimit)
|
|
117
116
|
throw new JWEInvalid('JOSE Header "p2c" (PBES2 Count) out is of acceptable bounds');
|
|
@@ -153,19 +152,19 @@ async function encryptKeyManagement(entry, enc, inputKey, joseHeader, providedCe
|
|
|
153
152
|
providedApu !== void 0 && assertUint8Array(providedApu, '"apu"'), providedApv !== void 0 && assertUint8Array(providedApv, '"apv"');
|
|
154
153
|
const apu = providedApu ?? partyInfo(joseHeader, "apu"), apv = providedApv ?? partyInfo(joseHeader, "apv");
|
|
155
154
|
checkPartyInfo(apu, apv);
|
|
156
|
-
let
|
|
157
|
-
providedParameters.epk !== void 0 ?
|
|
155
|
+
let ephemeralPrivateKey;
|
|
156
|
+
providedParameters.epk !== void 0 ? ephemeralPrivateKey = await prepareKey(entry, providedParameters.epk, "decrypt") : ephemeralPrivateKey = (await crypto.subtle.generateKey(key.algorithm, !0, ["deriveBits"])).privateKey;
|
|
158
157
|
const subtle = crypto.subtle;
|
|
159
|
-
let exportableEpk =
|
|
158
|
+
let exportableEpk = ephemeralPrivateKey;
|
|
160
159
|
if (!exportableEpk.extractable) {
|
|
161
160
|
if (typeof subtle.getPublicKey != "function")
|
|
162
161
|
throw new TypeError('CryptoKey for "epk" must be extractable');
|
|
163
|
-
exportableEpk = await subtle.getPublicKey(
|
|
162
|
+
exportableEpk = await subtle.getPublicKey(ephemeralPrivateKey, []);
|
|
164
163
|
}
|
|
165
|
-
const { x, y, crv, kty } = await subtle.exportKey("jwk", exportableEpk), direct = mode === "direct-key-agreement",
|
|
164
|
+
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
165
|
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 =
|
|
166
|
+
return [derivedKey, void 0, parameters];
|
|
167
|
+
key = derivedKey;
|
|
169
168
|
break;
|
|
170
169
|
}
|
|
171
170
|
case "RSA-OAEP": {
|
|
@@ -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,
|
|
@@ -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
|
|
@@ -5,6 +5,37 @@ All notable changes to this project will be documented in this file.
|
|
|
5
5
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/)
|
|
6
6
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
7
|
|
|
8
|
+
## [v1.14.0](https://github.com/inspect-js/object-inspect/compare/v1.13.4...v1.14.0) - 2026-11-18
|
|
9
|
+
|
|
10
|
+
### Fixed
|
|
11
|
+
|
|
12
|
+
- [New] add `breakLength` option [`#47`](https://github.com/inspect-js/object-inspect/issues/47)
|
|
13
|
+
- [New] add `maxCollectionLength` option [`#44`](https://github.com/inspect-js/object-inspect/issues/44) [`#51`](https://github.com/inspect-js/object-inspect/issues/51)
|
|
14
|
+
|
|
15
|
+
### Commits
|
|
16
|
+
|
|
17
|
+
- [New] `breakLength`: measure array entries by display width, like `util.inspect` [`77a3946`](https://github.com/inspect-js/object-inspect/commit/77a394674a5ef46830c93869af28da57f6793263)
|
|
18
|
+
- [meta] add `generate:string-width` script, to regenerate the display width table [`6aabdb7`](https://github.com/inspect-js/object-inspect/commit/6aabdb75a5c5a908bcc371abdff52ccb392f647b)
|
|
19
|
+
- [Dev Deps] update `eslint` [`02726bd`](https://github.com/inspect-js/object-inspect/commit/02726bd9df6d829020438e5a5940cbf2f4fac1ce)
|
|
20
|
+
- [Fix] guard `toStringTag` with correct ternary precedence [`012c719`](https://github.com/inspect-js/object-inspect/commit/012c71960f9fcc70b59f180f355ec752e068dcb3)
|
|
21
|
+
- [Fix] only report a null prototype when the immediate prototype is `null` [`bc9b5bb`](https://github.com/inspect-js/object-inspect/commit/bc9b5bb99a25d10b5d1275c145dcd75b7d543b12)
|
|
22
|
+
- [New] add `multilineStrings` option, to print newlines in strings as line breaks [`59f64e0`](https://github.com/inspect-js/object-inspect/commit/59f64e0220b9bc079f177b4c3791f9a9f5c7f3f3)
|
|
23
|
+
- [Fix] avoid quadratic time when inspecting collections [`46f23b9`](https://github.com/inspect-js/object-inspect/commit/46f23b985fc62841140b9c816f812d831511d98f)
|
|
24
|
+
- [actions] update workflows [`f1d2734`](https://github.com/inspect-js/object-inspect/commit/f1d273499d0da648ab68e99709178f28cad0599b)
|
|
25
|
+
- [Tests] restore the require cache via `require-stash` instead of deleting [`4cf972c`](https://github.com/inspect-js/object-inspect/commit/4cf972c77e17cf64c7f9bc18e3e160c5d1472853)
|
|
26
|
+
- [Dev Deps] update `@ljharb/eslint-config`, `auto-changelog`, `mock-property`, `npmignore`, `semver`, `tape` [`aa960eb`](https://github.com/inspect-js/object-inspect/commit/aa960ebd1eba690196c3312919a7dc24660b574d)
|
|
27
|
+
- [meta] npmignore tests [`cf245d6`](https://github.com/inspect-js/object-inspect/commit/cf245d60882b25c5c9c020b95c8ede799b43e9cd)
|
|
28
|
+
- [Dev Deps] update `eslint` [`0c6b083`](https://github.com/inspect-js/object-inspect/commit/0c6b083853b4b04964276a434263dad6c604752f)
|
|
29
|
+
- [Dev Deps] update `@ljharb/eslint-config`, `eslint`, `npmignore` [`693b6e8`](https://github.com/inspect-js/object-inspect/commit/693b6e82d841985ce7aedab192654ed70df88d03)
|
|
30
|
+
- [Dev Deps] update `@ljharb/eslint-config`, `error-cause`, `for-each` [`01f6906`](https://github.com/inspect-js/object-inspect/commit/01f6906422395d7ec69ca93fdc46c9c6662f4115)
|
|
31
|
+
- [meta] sort `devDependencies` [`09ee536`](https://github.com/inspect-js/object-inspect/commit/09ee536fd3c3a41e6f0ad7c3dabb47ade1b8c6e5)
|
|
32
|
+
- [Fix] `maxStringLength`: error message should say "non-negative", since `0` is allowed [`8d669a8`](https://github.com/inspect-js/object-inspect/commit/8d669a804bb3cf84f62d9d2b1c145d032ffaae20)
|
|
33
|
+
- [meta] Fix broken repository URL in package.json [`195f7ea`](https://github.com/inspect-js/object-inspect/commit/195f7ea1d6ce0749cf687437c226303fe9e2d96b)
|
|
34
|
+
- [Dev Deps] update `@ljharb/eslint-config` [`f5eb186`](https://github.com/inspect-js/object-inspect/commit/f5eb186e5066e071895a5916dd1a67ea706512e6)
|
|
35
|
+
- [readme] replace runkit CI badge with shields.io check-runs badge [`c32b915`](https://github.com/inspect-js/object-inspect/commit/c32b91506b44ffba774812b16e46c8ac6bf4c242)
|
|
36
|
+
- [Dev Deps] add `keyv` [`711eca7`](https://github.com/inspect-js/object-inspect/commit/711eca7871f5b215521f7633be68f253d79a2e35)
|
|
37
|
+
- [New] add `breakLength` option for single-line output [`3504471`](https://github.com/inspect-js/object-inspect/commit/3504471482fef1b7c073d164f8d78298f2f29df7)
|
|
38
|
+
|
|
8
39
|
## [v1.13.4](https://github.com/inspect-js/object-inspect/compare/v1.13.3...v1.13.4) - 2025-02-04
|
|
9
40
|
|
|
10
41
|
### Commits
|