@orangecheck/agent-core 1.2.0 → 2.0.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/dist/index.d.mts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +31 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +31 -0
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -4
- package/src/federation.test.ts +1 -0
- package/src/private-scope.test.ts +4 -3
- package/src/revocation-failclosed.test.ts +67 -0
- package/src/test-vectors.test.ts +5 -0
- package/src/verify.ts +56 -6
package/dist/index.mjs
CHANGED
|
@@ -496,6 +496,25 @@ async function verifyDelegation(input) {
|
|
|
496
496
|
const ok = await input.verifyBip322(env.id, env.sig.value, env.principal.address);
|
|
497
497
|
if (!ok) return err("E_BAD_SIG", "BIP-322 signature did not verify");
|
|
498
498
|
}
|
|
499
|
+
if (!input.skipRevocationCheck && !input.revocations) {
|
|
500
|
+
return err(
|
|
501
|
+
"E_MALFORMED",
|
|
502
|
+
"verifyDelegation requires `revocations` (fetch kind-30085 by #delegation) or an explicit skipRevocationCheck:true to state that revocation is not being checked"
|
|
503
|
+
);
|
|
504
|
+
}
|
|
505
|
+
if (input.revocations) {
|
|
506
|
+
for (const rev of input.revocations) {
|
|
507
|
+
if (rev.delegation_id !== env.id) continue;
|
|
508
|
+
const rr = await verifyRevocation({
|
|
509
|
+
envelope: rev,
|
|
510
|
+
delegation: env,
|
|
511
|
+
verifyBip322: input.verifyBip322,
|
|
512
|
+
skipSignatureVerification: input.skipSignatureVerification
|
|
513
|
+
});
|
|
514
|
+
if (!rr.ok) continue;
|
|
515
|
+
return err("E_REVOKED", `delegation ${env.id} was revoked by ${rev.id}`);
|
|
516
|
+
}
|
|
517
|
+
}
|
|
499
518
|
if (!input.skipTemporalCheck) {
|
|
500
519
|
const now = input.now ?? /* @__PURE__ */ new Date();
|
|
501
520
|
const issued = new Date(env.issued_at);
|
|
@@ -530,6 +549,12 @@ async function verifyAction(input) {
|
|
|
530
549
|
scopeMode: input.scopeMode,
|
|
531
550
|
skipTemporalCheck: true,
|
|
532
551
|
// action window check dominates
|
|
552
|
+
// Revocation is evaluated ONCE, below, across every link in the chain
|
|
553
|
+
// (root + subdelegations) against the action's effective time — a
|
|
554
|
+
// per-link check here would use the wrong clock and would also
|
|
555
|
+
// double-report. Forward the caller's decision so this inner call does
|
|
556
|
+
// not trip the fail-closed guard.
|
|
557
|
+
skipRevocationCheck: true,
|
|
533
558
|
...input.decryptScopesWith ? { decryptScopesWith: input.decryptScopesWith } : {}
|
|
534
559
|
});
|
|
535
560
|
if (!dr.ok) return dr;
|
|
@@ -599,6 +624,12 @@ async function verifyAction(input) {
|
|
|
599
624
|
return err("E_BAD_SCOPE_GRAMMAR", msg);
|
|
600
625
|
}
|
|
601
626
|
if (!accepted) return err("E_SCOPE_DENIED", `scope_exercised (${exercised}) not a sub-scope of any granted scope`);
|
|
627
|
+
if (!input.skipRevocationCheck && !input.revocations) {
|
|
628
|
+
return err(
|
|
629
|
+
"E_MALFORMED",
|
|
630
|
+
"verifyAction requires `revocations` (fetch kind-30085 by #delegation for every link in the chain) or an explicit skipRevocationCheck:true"
|
|
631
|
+
);
|
|
632
|
+
}
|
|
602
633
|
if (input.revocations && input.revocations.length > 0) {
|
|
603
634
|
const allLinks = [rootHydrated, ...hydratedChain];
|
|
604
635
|
for (const link of allLinks) {
|