@peac/protocol 0.16.3 → 0.16.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/dist/_internal/address-policy.d.ts +28 -0
- package/dist/_internal/address-policy.d.ts.map +1 -0
- package/dist/_internal/record-core/validators/jose-hardening.d.ts +1 -1
- package/dist/_internal/record-core/validators/jose-hardening.d.ts.map +1 -1
- package/dist/_internal/test-helpers/fixture-manifest.d.ts.map +1 -1
- package/dist/index.cjs +383 -93
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +384 -94
- package/dist/index.mjs.map +1 -1
- package/dist/issue.d.ts +2 -2
- package/dist/issue.d.ts.map +1 -1
- package/dist/jwks-resolver.d.ts +1 -1
- package/dist/jwks-resolver.d.ts.map +1 -1
- package/dist/ssrf-safe-fetch.d.ts +18 -11
- package/dist/ssrf-safe-fetch.d.ts.map +1 -1
- package/dist/verifier-core.d.ts.map +1 -1
- package/dist/verify-local.cjs +21 -2
- package/dist/verify-local.cjs.map +1 -1
- package/dist/verify-local.mjs +21 -2
- package/dist/verify-local.mjs.map +1 -1
- package/package.json +5 -5
package/dist/verify-local.mjs
CHANGED
|
@@ -238,13 +238,32 @@ function validateTypeExtensionMappingInternal(input) {
|
|
|
238
238
|
}
|
|
239
239
|
|
|
240
240
|
// src/_internal/record-core/validators/jose-hardening.ts
|
|
241
|
-
var
|
|
241
|
+
var KID_MAX_UTF8_BYTES = 256;
|
|
242
|
+
function isAcceptableKid(kid) {
|
|
243
|
+
if (typeof kid !== "string" || kid.length === 0) return false;
|
|
244
|
+
let bytes = 0;
|
|
245
|
+
for (let i = 0; i < kid.length; i++) {
|
|
246
|
+
const c = kid.charCodeAt(i);
|
|
247
|
+
if (c < 128) bytes += 1;
|
|
248
|
+
else if (c < 2048) bytes += 2;
|
|
249
|
+
else if (c >= 55296 && c <= 56319) {
|
|
250
|
+
const next = i + 1 < kid.length ? kid.charCodeAt(i + 1) : 0;
|
|
251
|
+
if (next < 56320 || next > 57343) return false;
|
|
252
|
+
bytes += 4;
|
|
253
|
+
i++;
|
|
254
|
+
} else if (c >= 56320 && c <= 57343) {
|
|
255
|
+
return false;
|
|
256
|
+
} else bytes += 3;
|
|
257
|
+
if (bytes > KID_MAX_UTF8_BYTES) return false;
|
|
258
|
+
}
|
|
259
|
+
return true;
|
|
260
|
+
}
|
|
242
261
|
var ACCEPTED = { accepted: true };
|
|
243
262
|
function rejected(errorCode) {
|
|
244
263
|
return { accepted: false, errorCode };
|
|
245
264
|
}
|
|
246
265
|
function validateJoseHardeningInternal(header) {
|
|
247
|
-
if (!header.kid
|
|
266
|
+
if (!isAcceptableKid(header.kid)) {
|
|
248
267
|
return rejected("CRYPTO_JWS_MISSING_KID");
|
|
249
268
|
}
|
|
250
269
|
if (header.jwk !== void 0 || header.x5c !== void 0 || header.x5u !== void 0 || header.jku !== void 0) {
|