@orangecheck/me-client 0.64.0 → 0.65.0
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/CHANGELOG.md +9 -0
- package/dist/index.js +7 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +7 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -1209,7 +1209,7 @@ function isIsoTime(v) {
|
|
|
1209
1209
|
const t = Date.parse(v);
|
|
1210
1210
|
return Number.isFinite(t) && new Date(t).toISOString().slice(0, 19) === v.slice(0, 19);
|
|
1211
1211
|
}
|
|
1212
|
-
function signedFields(msg, options) {
|
|
1212
|
+
function signedFields(msg, options, maxAgeSeconds) {
|
|
1213
1213
|
let parsed;
|
|
1214
1214
|
try {
|
|
1215
1215
|
parsed = JSON.parse(new TextDecoder().decode(msg));
|
|
@@ -1227,7 +1227,7 @@ function signedFields(msg, options) {
|
|
|
1227
1227
|
return { ok: false, reason: `signed for another project (${project_key})` };
|
|
1228
1228
|
}
|
|
1229
1229
|
const age = Date.now() - Date.parse(issued_at);
|
|
1230
|
-
if (age >
|
|
1230
|
+
if (age > maxAgeSeconds * 1e3) {
|
|
1231
1231
|
return { ok: false, reason: "older than the accepted age (issued_at)" };
|
|
1232
1232
|
}
|
|
1233
1233
|
if (-age > FUTURE_SKEW_MS) return { ok: false, reason: "issued_at is in the future" };
|
|
@@ -1309,6 +1309,10 @@ async function verifyEd25519(key, sig2, msg) {
|
|
|
1309
1309
|
}
|
|
1310
1310
|
async function verify2(rawBody, sigHex, kid, options = {}) {
|
|
1311
1311
|
if (options.project === void 0) warnNoProjectOnce();
|
|
1312
|
+
const maxAgeSeconds = options.maxAgeSeconds === void 0 ? DEFAULT_MAX_AGE_SECONDS : options.maxAgeSeconds;
|
|
1313
|
+
if (!Number.isFinite(maxAgeSeconds) || maxAgeSeconds <= 0) {
|
|
1314
|
+
return { ok: false, reason: "maxAgeSeconds must be a finite number above 0" };
|
|
1315
|
+
}
|
|
1312
1316
|
if (!sigHex) return { ok: false, reason: "missing signature" };
|
|
1313
1317
|
if (!kid) return { ok: false, reason: "missing kid" };
|
|
1314
1318
|
const sig2 = hexToBytes(sigHex);
|
|
@@ -1343,7 +1347,7 @@ async function verify2(rawBody, sigHex, kid, options = {}) {
|
|
|
1343
1347
|
if (!key) return { ok: false, reason: `kid ${kid} not in JWKS` };
|
|
1344
1348
|
}
|
|
1345
1349
|
if (!await verifyEd25519(key, sig2, msg)) return { ok: false, reason: "signature does not match" };
|
|
1346
|
-
return signedFields(msg, options);
|
|
1350
|
+
return signedFields(msg, options, maxAgeSeconds);
|
|
1347
1351
|
}
|
|
1348
1352
|
async function fetchJwksForce(issuer = DEFAULT_ISSUER) {
|
|
1349
1353
|
const origin2 = issuerOrigin(issuer, "webhook.fetchJwks: issuer");
|