@agenticprimitives/delegation 1.0.0-alpha.4 → 1.0.0-alpha.40
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/README.md +19 -2
- package/dist/authority-chain.d.ts +59 -0
- package/dist/authority-chain.d.ts.map +1 -0
- package/dist/authority-chain.js +70 -0
- package/dist/authority-chain.js.map +1 -0
- package/dist/caveats.d.ts +196 -1
- package/dist/caveats.d.ts.map +1 -1
- package/dist/caveats.js +374 -2
- package/dist/caveats.js.map +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/client.d.ts.map +1 -1
- package/dist/client.js +2 -2
- package/dist/client.js.map +1 -1
- package/dist/evaluator.d.ts +1 -1
- package/dist/evaluator.d.ts.map +1 -1
- package/dist/evaluator.js +102 -2
- package/dist/evaluator.js.map +1 -1
- package/dist/hash.d.ts +1 -1
- package/dist/hash.d.ts.map +1 -1
- package/dist/index.d.ts +38 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +43 -8
- package/dist/index.js.map +1 -1
- package/dist/invocation-proof.d.ts +133 -0
- package/dist/invocation-proof.d.ts.map +1 -0
- package/dist/invocation-proof.js +157 -0
- package/dist/invocation-proof.js.map +1 -0
- package/dist/lineage.d.ts +70 -0
- package/dist/lineage.d.ts.map +1 -0
- package/dist/lineage.js +65 -0
- package/dist/lineage.js.map +1 -0
- package/dist/mandate-handlers.d.ts +15 -0
- package/dist/mandate-handlers.d.ts.map +1 -0
- package/dist/mandate-handlers.js +279 -0
- package/dist/mandate-handlers.js.map +1 -0
- package/dist/mandate.d.ts +265 -0
- package/dist/mandate.d.ts.map +1 -0
- package/dist/mandate.js +275 -0
- package/dist/mandate.js.map +1 -0
- package/dist/method-authorization.d.ts +120 -0
- package/dist/method-authorization.d.ts.map +1 -0
- package/dist/method-authorization.js +173 -0
- package/dist/method-authorization.js.map +1 -0
- package/dist/onchain.d.ts +40 -4
- package/dist/onchain.d.ts.map +1 -1
- package/dist/onchain.js +140 -6
- package/dist/onchain.js.map +1 -1
- package/dist/presentation-release.d.ts +65 -0
- package/dist/presentation-release.d.ts.map +1 -0
- package/dist/presentation-release.js +81 -0
- package/dist/presentation-release.js.map +1 -0
- package/dist/quorum.d.ts +26 -0
- package/dist/quorum.d.ts.map +1 -0
- package/dist/quorum.js +80 -0
- package/dist/quorum.js.map +1 -0
- package/dist/session-delegation.d.ts +34 -0
- package/dist/session-delegation.d.ts.map +1 -0
- package/dist/session-delegation.js +33 -0
- package/dist/session-delegation.js.map +1 -0
- package/dist/session-manager.d.ts +1 -2
- package/dist/session-manager.d.ts.map +1 -1
- package/dist/session-manager.js +15 -6
- package/dist/session-manager.js.map +1 -1
- package/dist/standing.d.ts +101 -0
- package/dist/standing.d.ts.map +1 -0
- package/dist/standing.js +132 -0
- package/dist/standing.js.map +1 -0
- package/dist/token.d.ts +89 -1
- package/dist/token.d.ts.map +1 -1
- package/dist/token.js +485 -123
- package/dist/token.js.map +1 -1
- package/dist/types.d.ts +141 -0
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +7 -1
- package/dist/types.js.map +1 -1
- package/dist/verify-authorization.d.ts +28 -0
- package/dist/verify-authorization.d.ts.map +1 -0
- package/dist/verify-authorization.js +73 -0
- package/dist/verify-authorization.js.map +1 -0
- package/package.json +25 -16
package/README.md
CHANGED
|
@@ -1,12 +1,21 @@
|
|
|
1
1
|
# @agenticprimitives/delegation
|
|
2
2
|
|
|
3
|
-
|
|
3
|
+
> Part of **[Agentic Primitives](https://agenticprimitives.dev)** — the open-source trust substrate for agentic applications: identity that can sign, authority checked at act time, evidence the owner carries. [Developer kit](https://github.com/agentictrustlabs/agentic-primitives) · [All packages](https://agenticprimitives.dev/developers)
|
|
4
|
+
|
|
5
|
+
**One delegation model, everywhere — permissions, never keys.**
|
|
6
|
+
|
|
7
|
+
When an agent acts for a human, most stacks hand it a key and hope. This package hands it a delegation instead: an EIP-712 signed grant from a Smart Agent, constrained by caveats that on-chain enforcers actually check — time windows, value caps, allowed targets and methods, quorums — and revocable on-chain at any moment. The same primitive spans the whole stack: a web app session, an agent-to-agent call, and an MCP tool invocation all verify against the same `Delegation` struct. "This session may call these two tools until tomorrow, and I can kill it instantly" is one signed object, not three products.
|
|
8
|
+
|
|
9
|
+
The package also owns session lifecycle: `SessionManager` binds a delegation to its session-signing key, with the private key envelope-encrypted via `@agenticprimitives/key-custody` before it ever touches storage. Verification is fail-closed by design — an unknown enforcer is a rejection, not a warning — and minted tokens carry JTI replay protection. Because the principal is the Smart Agent address, not a credential, every delegation survives the issuer's credential rotation; and because custody is firewalled from delegation, no delegate can ever escalate into account control ([ADR-0011](../../docs/architecture/decisions/0011-credential-recovery-and-re-association.md)).
|
|
10
|
+
|
|
11
|
+
> Part of [agenticprimitives](../../README.md) — the trust substrate for the agent economy: one canonical Smart Agent identity with custody, delegation, naming, credentials, and audit evidence designed as one system.
|
|
4
12
|
|
|
5
13
|
See [`spec.md`](./spec.md) → [`specs/202-delegation.md`](../../specs/202-delegation.md) for the full contract: 8 on-chain enforcers, 3 off-chain sentinels, token envelope, cross-delegation, two session variants.
|
|
6
14
|
|
|
7
15
|
## Quick start
|
|
8
16
|
|
|
9
17
|
Browser (issuance):
|
|
18
|
+
|
|
10
19
|
```ts
|
|
11
20
|
import { DelegationClient, buildMcpToolScopeCaveat, encodeTimestampTerms, buildCaveat } from '@agenticprimitives/delegation';
|
|
12
21
|
|
|
@@ -21,6 +30,7 @@ const delegation = await client.issueDelegation({
|
|
|
21
30
|
```
|
|
22
31
|
|
|
23
32
|
Node (session lifecycle):
|
|
33
|
+
|
|
24
34
|
```ts
|
|
25
35
|
import { SessionManager } from '@agenticprimitives/delegation';
|
|
26
36
|
|
|
@@ -31,6 +41,7 @@ await sessions.package(sessionId, signedDelegation);
|
|
|
31
41
|
```
|
|
32
42
|
|
|
33
43
|
Node (token mint + verify):
|
|
44
|
+
|
|
34
45
|
```ts
|
|
35
46
|
import { mintDelegationToken, verifyDelegationToken } from '@agenticprimitives/delegation';
|
|
36
47
|
|
|
@@ -41,6 +52,12 @@ if ('error' in result) throw new Error(result.error);
|
|
|
41
52
|
const { principal, grants } = result;
|
|
42
53
|
```
|
|
43
54
|
|
|
55
|
+
`principal` is the verified delegator's Smart Agent address — every downstream action is attributable to a canonical on-chain identity, not an API key.
|
|
56
|
+
|
|
57
|
+
## How it's different
|
|
58
|
+
|
|
59
|
+
The closest neighbors are MetaMask's Delegation Toolkit and the session-key features in smart-account SDKs — both real, both well-built, and the caveat-enforcer shape here deliberately mirrors the ERC-7710 direction so the models stay interoperable. The differences are scope and posture. Session keys typically live and die inside one wallet stack and one transport; this delegation crosses transports — the token a browser session mints is the token an MCP server or A2A endpoint verifies, against the same on-chain enforcer registry. And the evaluator's posture is fail-closed as a hard invariant: unknown enforcer means reject, with no permissive default to quietly widen authority. Custody operations are structurally excluded — a delegation here cannot rotate credentials or change account control, ever, because that path doesn't exist in this package.
|
|
60
|
+
|
|
44
61
|
## Status
|
|
45
62
|
|
|
46
|
-
|
|
63
|
+
**Alpha track — testnet-only.** Spec + API stable; do not deploy to production until the gates listed in the root [`README.md` Status section](../../README.md#status) are cleared — including third-party contract audit and governance key rotation. Track every security finding live in [`docs/audits/findings.yaml`](../../docs/audits/findings.yaml).
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import type { Address, Hex } from 'viem';
|
|
2
|
+
import { type Delegation } from './types.js';
|
|
3
|
+
import { type MethodAuthorizationChecks } from './method-authorization.js';
|
|
4
|
+
import type { EnforcerAddresses } from './mandate.js';
|
|
5
|
+
export interface AuthorityChainLinkV1 {
|
|
6
|
+
/** The link's delegation digest (`hashDelegation`) — the receipt's reference for it. */
|
|
7
|
+
ref: Hex;
|
|
8
|
+
delegator: Address;
|
|
9
|
+
delegate: Address;
|
|
10
|
+
/** The link above it, or null at the root. */
|
|
11
|
+
parentRef: Hex | null;
|
|
12
|
+
}
|
|
13
|
+
/** The chain as evidence (spec 326 §3.4, kept to what the substrate can prove). Leaf first. */
|
|
14
|
+
export interface AuthorityChainV1 {
|
|
15
|
+
profile: 'ap-eip712-v1';
|
|
16
|
+
links: AuthorityChainLinkV1[];
|
|
17
|
+
/** The ROOT delegator — whose authority every link below attenuates (ADR-0052 accountability root). */
|
|
18
|
+
accountabilityRoot: Address;
|
|
19
|
+
/** The LEAF delegate — the party acting in this hop. */
|
|
20
|
+
actingAgent: Address;
|
|
21
|
+
depth: number;
|
|
22
|
+
/** keccak over the link refs, leaf → root: one digest a reader can cite for the whole chain. */
|
|
23
|
+
chainDigest: Hex;
|
|
24
|
+
}
|
|
25
|
+
export type AuthorityChainFailure = {
|
|
26
|
+
ok: false;
|
|
27
|
+
code: 'chain-parent-missing' | 'chain-broken' | 'chain-cycle' | 'chain-too-deep' | 'chain-link-dead';
|
|
28
|
+
reason: string;
|
|
29
|
+
};
|
|
30
|
+
export type AssembleAuthorityChainResult = {
|
|
31
|
+
ok: true;
|
|
32
|
+
chain: AuthorityChainV1;
|
|
33
|
+
delegations: Delegation[];
|
|
34
|
+
} | AuthorityChainFailure;
|
|
35
|
+
export declare const AUTHORITY_CHAIN_MAX_DEPTH = 4;
|
|
36
|
+
/** Assemble the chain from the leaf up through what was presented. Structural only — no chain reads. */
|
|
37
|
+
export declare function assembleAuthorityChain(input: {
|
|
38
|
+
leaf: Delegation;
|
|
39
|
+
/** Every wire the caller presented (the leaf may be among them). */
|
|
40
|
+
presented: readonly Delegation[];
|
|
41
|
+
/** How a link is referenced — `hashDelegation(d, chainId, manager)`; the verifier bundle's own digest
|
|
42
|
+
* function, so assembly and verification never disagree on what a link is called. */
|
|
43
|
+
digestOf: (d: Delegation) => Hex;
|
|
44
|
+
maxDepth?: number;
|
|
45
|
+
}): AssembleAuthorityChainResult;
|
|
46
|
+
/** Assemble AND verify every PARENT link as live — signed by its delegator, unrevoked, in window. The leaf
|
|
47
|
+
* is the mandate `verifyMandateForStep` judges in full; this proves the authority it claims to descend from. */
|
|
48
|
+
export declare function verifyAuthorityChain(input: {
|
|
49
|
+
leaf: Delegation;
|
|
50
|
+
presented: readonly Delegation[];
|
|
51
|
+
enforcers: EnforcerAddresses;
|
|
52
|
+
checks: MethodAuthorizationChecks;
|
|
53
|
+
now: number;
|
|
54
|
+
maxDepth?: number;
|
|
55
|
+
}): Promise<{
|
|
56
|
+
ok: true;
|
|
57
|
+
chain: AuthorityChainV1;
|
|
58
|
+
} | AuthorityChainFailure>;
|
|
59
|
+
//# sourceMappingURL=authority-chain.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authority-chain.d.ts","sourceRoot":"","sources":["../src/authority-chain.ts"],"names":[],"mappings":"AAcA,OAAO,KAAK,EAAE,OAAO,EAAE,GAAG,EAAE,MAAM,MAAM,CAAC;AAEzC,OAAO,EAAkB,KAAK,UAAU,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,EAAwB,KAAK,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AACjG,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAEtD,MAAM,WAAW,oBAAoB;IACnC,wFAAwF;IACxF,GAAG,EAAE,GAAG,CAAC;IACT,SAAS,EAAE,OAAO,CAAC;IACnB,QAAQ,EAAE,OAAO,CAAC;IAClB,8CAA8C;IAC9C,SAAS,EAAE,GAAG,GAAG,IAAI,CAAC;CACvB;AAED,+FAA+F;AAC/F,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,cAAc,CAAC;IACxB,KAAK,EAAE,oBAAoB,EAAE,CAAC;IAC9B,uGAAuG;IACvG,kBAAkB,EAAE,OAAO,CAAC;IAC5B,wDAAwD;IACxD,WAAW,EAAE,OAAO,CAAC;IACrB,KAAK,EAAE,MAAM,CAAC;IACd,gGAAgG;IAChG,WAAW,EAAE,GAAG,CAAC;CAClB;AAED,MAAM,MAAM,qBAAqB,GAAG;IAAE,EAAE,EAAE,KAAK,CAAC;IAAC,IAAI,EAAE,sBAAsB,GAAG,cAAc,GAAG,aAAa,GAAG,gBAAgB,GAAG,iBAAiB,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC;AACxK,MAAM,MAAM,4BAA4B,GAAG;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,gBAAgB,CAAC;IAAC,WAAW,EAAE,UAAU,EAAE,CAAA;CAAE,GAAG,qBAAqB,CAAC;AAGpI,eAAO,MAAM,yBAAyB,IAAI,CAAC;AAE3C,wGAAwG;AACxG,wBAAgB,sBAAsB,CAAC,KAAK,EAAE;IAC5C,IAAI,EAAE,UAAU,CAAC;IACjB,oEAAoE;IACpE,SAAS,EAAE,SAAS,UAAU,EAAE,CAAC;IACjC;0FACsF;IACtF,QAAQ,EAAE,CAAC,CAAC,EAAE,UAAU,KAAK,GAAG,CAAC;IACjC,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,GAAG,4BAA4B,CAwC/B;AAED;iHACiH;AACjH,wBAAsB,oBAAoB,CAAC,KAAK,EAAE;IAChD,IAAI,EAAE,UAAU,CAAC;IACjB,SAAS,EAAE,SAAS,UAAU,EAAE,CAAC;IACjC,SAAS,EAAE,iBAAiB,CAAC;IAC7B,MAAM,EAAE,yBAAyB,CAAC;IAClC,GAAG,EAAE,MAAM,CAAC;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB,GAAG,OAAO,CAAC;IAAE,EAAE,EAAE,IAAI,CAAC;IAAC,KAAK,EAAE,gBAAgB,CAAA;CAAE,GAAG,qBAAqB,CAAC,CAczE"}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
import { keccak256, toBytes } from 'viem';
|
|
2
|
+
import { ROOT_AUTHORITY } from './types.js';
|
|
3
|
+
import { verifyLiveDelegation } from './method-authorization.js';
|
|
4
|
+
const lc = (s) => s.toLowerCase();
|
|
5
|
+
export const AUTHORITY_CHAIN_MAX_DEPTH = 4;
|
|
6
|
+
/** Assemble the chain from the leaf up through what was presented. Structural only — no chain reads. */
|
|
7
|
+
export function assembleAuthorityChain(input) {
|
|
8
|
+
const maxDepth = input.maxDepth ?? AUTHORITY_CHAIN_MAX_DEPTH;
|
|
9
|
+
const digestOf = input.digestOf;
|
|
10
|
+
const byRef = new Map();
|
|
11
|
+
for (const d of input.presented)
|
|
12
|
+
byRef.set(lc(digestOf(d)), d);
|
|
13
|
+
const links = [];
|
|
14
|
+
const delegations = [];
|
|
15
|
+
const seen = new Set();
|
|
16
|
+
let cur = input.leaf;
|
|
17
|
+
for (;;) {
|
|
18
|
+
const ref = digestOf(cur);
|
|
19
|
+
if (seen.has(lc(ref)))
|
|
20
|
+
return { ok: false, code: 'chain-cycle', reason: `the chain cycles at ${ref.slice(0, 12)}…` };
|
|
21
|
+
seen.add(lc(ref));
|
|
22
|
+
if (links.length >= maxDepth)
|
|
23
|
+
return { ok: false, code: 'chain-too-deep', reason: `the chain is deeper than ${maxDepth} links` };
|
|
24
|
+
const isRoot = lc(String(cur.authority)) === lc(ROOT_AUTHORITY);
|
|
25
|
+
links.push({ ref, delegator: cur.delegator, delegate: cur.delegate, parentRef: isRoot ? null : cur.authority });
|
|
26
|
+
delegations.push(cur);
|
|
27
|
+
if (isRoot)
|
|
28
|
+
break;
|
|
29
|
+
const parent = byRef.get(lc(String(cur.authority)));
|
|
30
|
+
if (!parent) {
|
|
31
|
+
return { ok: false, code: 'chain-parent-missing', reason: `${ref.slice(0, 12)}… is a child whose parent ${String(cur.authority).slice(0, 12)}… was not presented — a child alone is not authority; the chain is verified whole or not at all` };
|
|
32
|
+
}
|
|
33
|
+
// CONTINUITY: a child is minted by the party the parent was granted TO. Anything else is two grants
|
|
34
|
+
// that happen to reference each other, not a chain of attenuation.
|
|
35
|
+
if (lc(parent.delegate) !== lc(cur.delegator)) {
|
|
36
|
+
return { ok: false, code: 'chain-broken', reason: `${ref.slice(0, 12)}… was minted by ${cur.delegator}, but its parent was granted to ${parent.delegate}` };
|
|
37
|
+
}
|
|
38
|
+
cur = parent;
|
|
39
|
+
}
|
|
40
|
+
const chainDigest = keccak256(toBytes(links.map((l) => lc(l.ref)).join(':')));
|
|
41
|
+
return {
|
|
42
|
+
ok: true,
|
|
43
|
+
chain: {
|
|
44
|
+
profile: 'ap-eip712-v1', links,
|
|
45
|
+
accountabilityRoot: lc(links[links.length - 1].delegator),
|
|
46
|
+
actingAgent: lc(links[0].delegate),
|
|
47
|
+
depth: links.length, chainDigest,
|
|
48
|
+
},
|
|
49
|
+
delegations,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
/** Assemble AND verify every PARENT link as live — signed by its delegator, unrevoked, in window. The leaf
|
|
53
|
+
* is the mandate `verifyMandateForStep` judges in full; this proves the authority it claims to descend from. */
|
|
54
|
+
export async function verifyAuthorityChain(input) {
|
|
55
|
+
const assembled = assembleAuthorityChain({ leaf: input.leaf, presented: input.presented, digestOf: input.checks.delegationDigest, maxDepth: input.maxDepth });
|
|
56
|
+
if (!assembled.ok)
|
|
57
|
+
return assembled;
|
|
58
|
+
for (let i = 1; i < assembled.delegations.length; i++) {
|
|
59
|
+
const link = assembled.delegations[i];
|
|
60
|
+
const child = assembled.delegations[i - 1];
|
|
61
|
+
const live = await verifyLiveDelegation({
|
|
62
|
+
delegation: link, expectedDelegate: child.delegator, enforcers: input.enforcers, checks: input.checks, now: input.now,
|
|
63
|
+
});
|
|
64
|
+
if (!live.ok) {
|
|
65
|
+
return { ok: false, code: 'chain-link-dead', reason: `link ${i + 1} of ${assembled.delegations.length} (${assembled.chain.links[i].ref.slice(0, 12)}…) is not live: ${live.reason}` };
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
return { ok: true, chain: assembled.chain };
|
|
69
|
+
}
|
|
70
|
+
//# sourceMappingURL=authority-chain.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"authority-chain.js","sourceRoot":"","sources":["../src/authority-chain.ts"],"names":[],"mappings":"AAeA,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,MAAM,CAAC;AAC1C,OAAO,E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EAAE,IAAI,EAAE,gBAAgB,EAAE,KAAK,CAAC,SAAS,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,KAAK,CAAC,MAAM,EAAE,GAAG,EAAE,KAAK,CAAC,GAAG;SACtH,CAAC,CAAC;QACH,IAAI,CAAC,IAAI,CAAC,EAAE,EAAE,CAAC;YACb,OAAO,EAAE,EAAE,EAAE,KAAK,EAAE,IAAI,EAAE,iBAAiB,EAAE,MAAM,EAAE,QAAQ,CAAC,GAAG,CAAC,OAAO,SAAS,CAAC,WAAW,CAAC,MAAM,KAAK,SAAS,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAE,CAAC,GAAG,CAAC,KAAK,CAAC,CAAC,EAAE,EAAE,CAAC,mBAAmB,IAAI,CAAC,MAAM,EAAE,EAAE,CAAC;QACzL,CAAC;IACH,CAAC;IACD,OAAO,EAAE,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,SAAS,CAAC,KAAK,EAAE,CAAC;AAC9C,CAAC"}
|
package/dist/caveats.d.ts
CHANGED
|
@@ -1,15 +1,98 @@
|
|
|
1
1
|
import { type Hex, type Address } from 'viem';
|
|
2
|
-
import type { Caveat, DataScopeGrant } from './types';
|
|
2
|
+
import type { Caveat, DataScopeGrant, VaultKeyUseGrant, VaultRecordScopeGrant } from './types.js';
|
|
3
3
|
export declare const MCP_TOOL_SCOPE_ENFORCER: Address;
|
|
4
4
|
export declare const DATA_SCOPE_ENFORCER: Address;
|
|
5
5
|
export declare const DELEGATE_BINDING_ENFORCER: Address;
|
|
6
|
+
/** Spec 278 — vault-key-use authorization sentinel. Off-chain only; the KAS
|
|
7
|
+
* (key-authorization) enforces the grant's scope. Inert in the on-chain evaluator. */
|
|
8
|
+
export declare const VAULT_KEY_USE_ENFORCER: Address;
|
|
9
|
+
/** Spec 317 — vault-record-scope sentinel. Off-chain only; the resource server (demo-mcp vault
|
|
10
|
+
* runtime) enforces the grant's resource+op scope on every vault op. Inert in the on-chain evaluator. */
|
|
11
|
+
export declare const VAULT_RECORD_SCOPE_ENFORCER: Address;
|
|
12
|
+
/** Spec 408 §2.1 (R917-P-2) — session-audience sentinel. Off-chain only: tags the DEL-001 session leaf
|
|
13
|
+
* with the DELEGATES the session key may present the principal's delegations to. Judged in
|
|
14
|
+
* `sessionDelegateBindingError`; shape-checked in the evaluator; never redeemed on chain. */
|
|
15
|
+
export declare const SESSION_AUDIENCE_ENFORCER: Address;
|
|
16
|
+
/** Spec 305 W2 / zkID alignment §3 (Z2) — presentation-scope sentinel. Off-chain only: the bounds of a
|
|
17
|
+
* `credential.present` wire — which verifier AUDIENCES, which PREDICATE programs (by digest), which ISSUER facets
|
|
18
|
+
* (by keyId) a delegate key may cause a device signature for. Judged by the presentation mandate handler
|
|
19
|
+
* (`presentationHandler.isSubset`) before the key signs; shape-checked in the evaluator; never redeemed on chain
|
|
20
|
+
* (a presentation never reaches the chain — the KEY is what enforces it, zkID alignment §3). */
|
|
21
|
+
export declare const PRESENTATION_SCOPE_ENFORCER: Address;
|
|
22
|
+
export interface PresentationScopeTerms {
|
|
23
|
+
/** Verifier audiences, exact strings (an origin, a verifier id, a session-bound policy hash). */
|
|
24
|
+
audiences: string[];
|
|
25
|
+
/** Digests of the predicate programs this wire covers (sha256 over the canonical compiled predicates). */
|
|
26
|
+
predicateDigests: Hex[];
|
|
27
|
+
/** Spec-304 issuer facet keyIds whose credentials may be presented. */
|
|
28
|
+
issuerKeyIds: string[];
|
|
29
|
+
/** 0 = unbounded within the window; the release counts against it when it holds a counter. */
|
|
30
|
+
maxPresentations: number;
|
|
31
|
+
}
|
|
32
|
+
export declare function encodePresentationScopeTerms(t: PresentationScopeTerms): Hex;
|
|
33
|
+
export declare function decodePresentationScopeTerms(terms: Hex): PresentationScopeTerms;
|
|
34
|
+
export declare function buildPresentationScopeCaveat(t: PresentationScopeTerms): Caveat;
|
|
6
35
|
export declare function buildCaveat(enforcer: Address, terms: Hex, args?: Hex): Caveat;
|
|
7
36
|
export declare function encodeTimestampTerms(validAfter: number, validUntil: number): Hex;
|
|
37
|
+
/**
|
|
38
|
+
* Read back what `encodeTimestampTerms` wrote.
|
|
39
|
+
*
|
|
40
|
+
* DECODERS LIVE WITH THEIR ENCODERS. These three were in `@agenticprimitives/a2a`, one package away
|
|
41
|
+
* from the functions that produce the bytes, under a comment reading "must mirror delegation's
|
|
42
|
+
* encoders byte-for-byte" — which is the comment you write when the compiler cannot check it for you.
|
|
43
|
+
* That split is not theoretical: `demo-sso-next` hand-rolled its own timestamp decode against a
|
|
44
|
+
* comment claiming `uint128`, when the encoder emits `uint256`.
|
|
45
|
+
*/
|
|
46
|
+
export declare function decodeTimestampTerms(terms: Hex): {
|
|
47
|
+
validAfter: bigint;
|
|
48
|
+
validUntil: bigint;
|
|
49
|
+
};
|
|
50
|
+
export declare function decodeAllowedTargetsTerms(terms: Hex): readonly Address[];
|
|
51
|
+
export declare function decodeAllowedMethodsTerms(terms: Hex): readonly Hex[];
|
|
8
52
|
export declare function encodeValueTerms(maxValue: bigint): Hex;
|
|
9
53
|
export declare function encodeAllowedTargetsTerms(targets: Address[]): Hex;
|
|
10
54
|
export declare function encodeAllowedMethodsTerms(selectors: Hex[]): Hex;
|
|
55
|
+
/** Exact-calldata pinning (CallDataHashEnforcer — ADR-0027 / spec 249 RW1-4b): terms =
|
|
56
|
+
* abi.encode(bytes32 keccak256(callData)). Binds a (sub-)delegation to EXACTLY one call so a
|
|
57
|
+
* registry checking `verifyAuthorizationForCall` authorizes only that precise payload — not
|
|
58
|
+
* merely its target + selector. Pass the exact `execute(...)`/inner calldata the grant permits. */
|
|
59
|
+
export declare function encodeCallDataHashTerms(callData: Hex): Hex;
|
|
11
60
|
export declare function buildMcpToolScopeCaveat(allowedTools: string[]): Caveat;
|
|
12
61
|
export declare function buildDataScopeCaveat(grants: DataScopeGrant[]): Caveat;
|
|
62
|
+
/** Decode a `DATA_SCOPE` caveat's terms back to its grants. Used OFF-CHAIN by the resource server (the
|
|
63
|
+
* vault/MCP runtime) to scope the field projection — the on-chain evaluator treats the sentinel as inert. */
|
|
64
|
+
export declare function decodeDataScopeTerms(terms: Hex): DataScopeGrant[];
|
|
65
|
+
export declare function buildVaultKeyUseCaveat(grant: VaultKeyUseGrant): Caveat;
|
|
66
|
+
/** Decode a `VAULT_KEY_USE` caveat's terms back to its grant. Used by the KAS
|
|
67
|
+
* (key-authorization, P2) to evaluate the authorization's scope against a request. */
|
|
68
|
+
export declare function decodeVaultKeyUseTerms(terms: Hex): VaultKeyUseGrant;
|
|
69
|
+
export declare function buildVaultRecordScopeCaveat(grants: VaultRecordScopeGrant[]): Caveat;
|
|
70
|
+
/** Decode a `VAULT_RECORD_SCOPE` caveat's terms back to its grants. Used OFF-CHAIN by the resource
|
|
71
|
+
* server (demo-mcp vault runtime) to gate each vault op — the on-chain evaluator treats it as inert. */
|
|
72
|
+
export declare function decodeVaultRecordScopeTerms(terms: Hex): VaultRecordScopeGrant[];
|
|
73
|
+
/**
|
|
74
|
+
* The CANONICAL off-chain enforcement decision for `VAULT_RECORD_SCOPE` grants (spec 317 §3.2). Every
|
|
75
|
+
* resource server MUST use this one matcher rather than re-implementing it — a divergent re-implementation
|
|
76
|
+
* is exactly where a widening bug creeps in (security-audit F3). Decision:
|
|
77
|
+
* - `recordScopes` absent/empty ⇒ `true` (the delegation carried no record-scope caveat → this gate is
|
|
78
|
+
* inert; the resource server's own per-owner authorization still applies — the two gates AND).
|
|
79
|
+
* - present ⇒ authorized ONLY if some grant (a) names `req.server` exactly (a grant for another server
|
|
80
|
+
* confers nothing here — F2), (b) whose `ops` include `req.op`, AND (c) whose `resources` cover
|
|
81
|
+
* `req.resource` by an ANCHORED match: exact string, or a single trailing-`*` prefix (`a.slice(0,-1)`
|
|
82
|
+
* is a `startsWith` prefix; a bare `*` is NOT honored). So `vault:message.body:*` matches
|
|
83
|
+
* `vault:message.body:<id>` but NOT `vault:message.body-evil` — F3. Deny-by-default otherwise.
|
|
84
|
+
* `req.resource`/`req.op` MUST be the server-recovered values (never client-supplied), and the grants MUST
|
|
85
|
+
* be the POST-VERIFY grants (decoded only after the delegation signature verified — never raw caveats).
|
|
86
|
+
*/
|
|
87
|
+
export declare function vaultRecordScopeAllows(recordScopes: VaultRecordScopeGrant[] | undefined, req: {
|
|
88
|
+
server: string;
|
|
89
|
+
resource: string;
|
|
90
|
+
op: 'read' | 'write' | 'delete';
|
|
91
|
+
}): boolean;
|
|
92
|
+
/** R917-P-8 (spec 408 §2.8): a trailing-`*` pattern is honoured only when its prefix names a record type —
|
|
93
|
+
* `vault:message.body:*` and `vault:message.body*` do; `*`, `v*` and `vault:*` (a whole namespace) do not.
|
|
94
|
+
* The prefix must have a non-empty namespace AND a non-empty type segment. */
|
|
95
|
+
export declare function wildcardPrefixNamesARecordType(prefix: string): boolean;
|
|
13
96
|
export declare function buildDelegateBindingCaveat(delegateSmartAccount: Address, delegatePersonAgent: Address): Caveat;
|
|
14
97
|
export interface QuorumCaveatOpts {
|
|
15
98
|
/**
|
|
@@ -47,4 +130,116 @@ export interface QuorumCaveatOpts {
|
|
|
47
130
|
* into the on-chain caveat evaluation.
|
|
48
131
|
*/
|
|
49
132
|
export declare function buildQuorumCaveat(opts: QuorumCaveatOpts): Caveat;
|
|
133
|
+
/** The ONLY method an x402 payment delegation may invoke: `IERC20.transfer(address,uint256)`. */
|
|
134
|
+
export declare const PAYMENT_TRANSFER_SELECTOR: Hex;
|
|
135
|
+
export interface PaymentMandateCaveatOpts {
|
|
136
|
+
/** Deployed enforcer addresses: the PaymentEnforcer + the timestamp / allowedTargets /
|
|
137
|
+
* allowedMethods enforcers it composes with (from `EnforcerAddressMap`). */
|
|
138
|
+
enforcers: {
|
|
139
|
+
payment: Address;
|
|
140
|
+
timestamp: Address;
|
|
141
|
+
allowedTargets: Address;
|
|
142
|
+
allowedMethods: Address;
|
|
143
|
+
};
|
|
144
|
+
/** Treasury SA that receives every charge (payee). */
|
|
145
|
+
payee: Address;
|
|
146
|
+
/** Fee asset (USDC). */
|
|
147
|
+
asset: Address;
|
|
148
|
+
/** Smallest-unit caps. `maxAggregate` is the session budget (X402-D5). */
|
|
149
|
+
maxAmountPerCharge: bigint;
|
|
150
|
+
maxAggregate: bigint;
|
|
151
|
+
maxRedemptionsPerWindow: number;
|
|
152
|
+
windowSeconds: number;
|
|
153
|
+
validAfter?: number;
|
|
154
|
+
validUntil: number;
|
|
155
|
+
}
|
|
156
|
+
/** Encode the immutable `PaymentEnforcer` terms. MUST match `PaymentEnforcer.sol` `abi.decode`
|
|
157
|
+
* order/types: (treasury, asset, maxAmountPerCharge, maxAggregate, maxRedemptionsPerWindow,
|
|
158
|
+
* windowSeconds) → 192 bytes. */
|
|
159
|
+
export declare function encodePaymentTerms(opts: {
|
|
160
|
+
payee: Address;
|
|
161
|
+
asset: Address;
|
|
162
|
+
maxAmountPerCharge: bigint;
|
|
163
|
+
maxAggregate: bigint;
|
|
164
|
+
maxRedemptionsPerWindow: number;
|
|
165
|
+
windowSeconds: number;
|
|
166
|
+
}): Hex;
|
|
167
|
+
/** The inverse — spec 358 W4's keyring selector reads WHICH payee a payment mandate binds, so a
|
|
168
|
+
* fanned-out step can be judged under the mandate that names ITS payee. Reading terms is not verifying
|
|
169
|
+
* them: the verifier still judges the selected mandate alone. */
|
|
170
|
+
export declare function decodePaymentTerms(terms: Hex): {
|
|
171
|
+
payee: Address;
|
|
172
|
+
asset: Address;
|
|
173
|
+
maxAmountPerCharge: bigint;
|
|
174
|
+
maxAggregate: bigint;
|
|
175
|
+
maxRedemptionsPerWindow: number;
|
|
176
|
+
windowSeconds: number;
|
|
177
|
+
};
|
|
178
|
+
/**
|
|
179
|
+
* PAY-DEL-1 — the caveat set for an x402 PAYMENT delegation (delegator = reader, delegate = the
|
|
180
|
+
* paid service agent). Composes the stateful `PaymentEnforcer` (spend + windowed-frequency cap +
|
|
181
|
+
* transfer-only + single-use nonce) with `timestamp` (expiry), `allowedTargets` (USDC only), and
|
|
182
|
+
* `allowedMethods` (transfer only) so the on-chain enforcers and the off-chain mandate agree.
|
|
183
|
+
*
|
|
184
|
+
* Caveat `args` are left `'0x'` at mint; the rail executor fills the PaymentEnforcer caveat's `args`
|
|
185
|
+
* with `abi.encode(mandateId, nonce, resourceHash)` at REDEMPTION time (terms = mint, args = redeem).
|
|
186
|
+
* Resource/skill binding rides the mandate's `contextBinding`, not an on-chain caveat (PAY-WIRE-5).
|
|
187
|
+
*/
|
|
188
|
+
export declare function buildPaymentMandateCaveats(opts: PaymentMandateCaveatOpts): Caveat[];
|
|
189
|
+
/** PAY-DEL-4 — human-readable consent for the connect UI ("Allow X to charge your agent wallet?").
|
|
190
|
+
* The UI renders THIS, never raw `delegate execute to contract`. Amounts are smallest-unit; the
|
|
191
|
+
* caller formats with the token's decimals. */
|
|
192
|
+
export interface PaymentMandateConsent {
|
|
193
|
+
recipient: Address;
|
|
194
|
+
asset: Address;
|
|
195
|
+
maxAmountPerCharge: bigint;
|
|
196
|
+
sessionBudget: bigint;
|
|
197
|
+
maxRedemptionsPerWindow: number;
|
|
198
|
+
windowSeconds: number;
|
|
199
|
+
expiresAt: number;
|
|
200
|
+
revocable: true;
|
|
201
|
+
}
|
|
202
|
+
export declare function describePaymentMandate(opts: PaymentMandateCaveatOpts): PaymentMandateConsent;
|
|
203
|
+
export type DigestBindingKind = 'intent' | 'projection' | 'offer' | 'plan';
|
|
204
|
+
/** The `kind` word in the terms — keccak256 of a short name, so a reader can tell bindings apart. */
|
|
205
|
+
export declare const DIGEST_BINDING_KIND: Record<DigestBindingKind, Hex>;
|
|
206
|
+
/** Reverse map for decoders (lowercased kind hash → name). */
|
|
207
|
+
export declare const DIGEST_KIND_NAMES: ReadonlyMap<string, DigestBindingKind>;
|
|
208
|
+
export declare function encodeDigestBindingTerms(kind: DigestBindingKind, digest: Hex): Hex;
|
|
209
|
+
export declare function decodeDigestBindingTerms(terms: Hex): {
|
|
210
|
+
kind: DigestBindingKind;
|
|
211
|
+
digest: Hex;
|
|
212
|
+
};
|
|
213
|
+
/** The `args` a redeemer supplies at redemption: the digest it is acting under AND the step's nonce
|
|
214
|
+
* (abi-encoded `(bytes32 presented, bytes32 stepNonce)`). Supplying the digest is the on-chain commitment;
|
|
215
|
+
* `DigestBindingEnforcer` refuses anything but the bound one. R917-C-4 (spec 408 §1.4): the nonce makes
|
|
216
|
+
* the redemption SINGLE-USE PER STEP — consumed on chain under (delegator, delegationHash, kind, nonce),
|
|
217
|
+
* so a replay of the same step reverts. Derive it with `digestBindingStepNonce`. */
|
|
218
|
+
export type DigestBindingArgsScheme = {
|
|
219
|
+
generation: 1;
|
|
220
|
+
} | {
|
|
221
|
+
generation: 2;
|
|
222
|
+
stepNonce: Hex;
|
|
223
|
+
};
|
|
224
|
+
export declare function encodeDigestBindingArgs(digest: Hex, scheme: DigestBindingArgsScheme): Hex;
|
|
225
|
+
/** THE ONE derivation of a step's redemption nonce: `keccak256("<intentDigest>:<operation>")` where `operation`
|
|
226
|
+
* is the step's LOGICAL request identity — its declared idempotency key when the step carries one, else its
|
|
227
|
+
* stable step ref (spec 410 §3). Two deliberately identical payments are two operations (distinct ids); one
|
|
228
|
+
* payment retried after a lost response is one (the same id, the same nonce, consumed once on chain). The same
|
|
229
|
+
* derivation `PaymentEnforcer`'s nonce uses, so a step's on-chain identity is one value everywhere. */
|
|
230
|
+
export declare function digestBindingStepNonce(intentDigest: Hex, operation: string): Hex;
|
|
231
|
+
/** terms = abi.encode(string[] classIris): what a write under this mandate MAY CARRY, as ontology classes. */
|
|
232
|
+
export declare function encodePayloadClassesTerms(classIris: readonly string[]): Hex;
|
|
233
|
+
export declare function decodePayloadClassesTerms(terms: Hex): string[];
|
|
234
|
+
export declare function buildPayloadClassesCaveat(enforcer: Address, classIris: readonly string[]): Caveat;
|
|
235
|
+
/** One digest-binding caveat. Args are NOT pre-filled: they are the redeemer's per-step commitment
|
|
236
|
+
* (`encodeDigestBindingArgs`), set at redemption — a pre-filled value would be one nonce for every step. */
|
|
237
|
+
export declare function buildDigestBindingCaveat(enforcer: Address, kind: DigestBindingKind, digest: Hex): Caveat;
|
|
238
|
+
/** Every digest binding a delegation carries, by kind. Empty ⇒ a standing capability, not a mandate. */
|
|
239
|
+
export declare function readDigestBindings(caveats: readonly Caveat[], enforcer: Address): Partial<Record<DigestBindingKind, Hex>>;
|
|
240
|
+
export declare function encodeSessionAudienceTerms(delegates: readonly Address[]): Hex;
|
|
241
|
+
export declare function decodeSessionAudienceTerms(terms: Hex): Address[];
|
|
242
|
+
export declare function buildSessionAudienceCaveat(delegates: readonly Address[]): Caveat;
|
|
243
|
+
/** The audience a leaf carries (lowercased), or null when it carries none — which the verifier refuses. */
|
|
244
|
+
export declare function readSessionAudience(caveats: readonly Caveat[]): string[] | null;
|
|
50
245
|
//# sourceMappingURL=caveats.d.ts.map
|
package/dist/caveats.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"caveats.d.ts","sourceRoot":"","sources":["../src/caveats.ts"],"names":[],"mappings":"AAQA,OAAO,
|
|
1
|
+
{"version":3,"file":"caveats.d.ts","sourceRoot":"","sources":["../src/caveats.ts"],"names":[],"mappings":"AAQA,OAAO,EAAuD,KAAK,GAAG,EAAE,KAAK,OAAO,EAAE,MAAM,MAAM,CAAC;AAEnG,OAAO,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,MAAM,YAAY,CAAC;AAWlG,eAAO,MAAM,uBAAuB,EAAE,OAA2D,CAAC;AAClG,eAAO,MAAM,mBAAmB,EAAE,OAAuD,CAAC;AAC1F,eAAO,MAAM,yBAAyB,EAAE,OAA6D,CAAC;AACtG;uFACuF;AACvF,eAAO,MAAM,sBAAsB,EAAE,OAA0D,CAAC;AAChG;0GAC0G;AAC1G,eAAO,MAAM,2BAA2B,EAAE,OAA+D,CAAC;AAC1G;;8FAE8F;AAC9F,eAAO,MAAM,yBAAyB,EAAE,OAA6D,CAAC;AACtG;;;;iGAIiG;AACjG,eAAO,MAAM,2BAA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