@agenticprimitives/delegation 0.1.0-alpha.3 → 1.0.0-alpha.11

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.
Files changed (44) hide show
  1. package/README.md +17 -2
  2. package/dist/caveats.d.ts +72 -1
  3. package/dist/caveats.d.ts.map +1 -1
  4. package/dist/caveats.js +113 -2
  5. package/dist/caveats.js.map +1 -1
  6. package/dist/client.d.ts +1 -1
  7. package/dist/client.d.ts.map +1 -1
  8. package/dist/client.js +2 -2
  9. package/dist/client.js.map +1 -1
  10. package/dist/evaluator.d.ts +1 -1
  11. package/dist/evaluator.d.ts.map +1 -1
  12. package/dist/evaluator.js +4 -1
  13. package/dist/evaluator.js.map +1 -1
  14. package/dist/hash.d.ts +1 -1
  15. package/dist/hash.d.ts.map +1 -1
  16. package/dist/index.d.ts +20 -11
  17. package/dist/index.d.ts.map +1 -1
  18. package/dist/index.js +16 -8
  19. package/dist/index.js.map +1 -1
  20. package/dist/onchain.d.ts +17 -4
  21. package/dist/onchain.d.ts.map +1 -1
  22. package/dist/onchain.js +77 -6
  23. package/dist/onchain.js.map +1 -1
  24. package/dist/session-delegation.d.ts +30 -0
  25. package/dist/session-delegation.d.ts.map +1 -0
  26. package/dist/session-delegation.js +32 -0
  27. package/dist/session-delegation.js.map +1 -0
  28. package/dist/session-manager.d.ts +1 -2
  29. package/dist/session-manager.d.ts.map +1 -1
  30. package/dist/session-manager.js +14 -5
  31. package/dist/session-manager.js.map +1 -1
  32. package/dist/token.d.ts +13 -1
  33. package/dist/token.d.ts.map +1 -1
  34. package/dist/token.js +233 -96
  35. package/dist/token.js.map +1 -1
  36. package/dist/types.d.ts +56 -0
  37. package/dist/types.d.ts.map +1 -1
  38. package/dist/types.js +7 -1
  39. package/dist/types.js.map +1 -1
  40. package/dist/verify-authorization.d.ts +28 -0
  41. package/dist/verify-authorization.d.ts.map +1 -0
  42. package/dist/verify-authorization.js +73 -0
  43. package/dist/verify-authorization.js.map +1 -0
  44. package/package.json +11 -11
@@ -0,0 +1,28 @@
1
+ import type { Address } from '@agenticprimitives/types';
2
+ import type { PublicClient } from 'viem';
3
+ import type { Delegation } from './types.js';
4
+ export interface VerifyAuthorizationResult {
5
+ ok: boolean;
6
+ /** Empty when `ok = true`; otherwise the on-chain rejection reason. */
7
+ reason: string;
8
+ }
9
+ /**
10
+ * View-only verification of a delegation chain. Returns whether the chain
11
+ * authorizes `sender` to redeem WITHOUT executing it.
12
+ *
13
+ * ⚠️ DANGER — chain-only. This does NOT evaluate caveats, so a `true` result is
14
+ * NOT permission to perform any specific (target, value, calldata). To authorize a
15
+ * concrete call use `verifyAuthorizationForCall` (fail-closed, evaluates every
16
+ * caveat) or live redemption. Treating this boolean as call authorization re-opens
17
+ * the exact over-trust the caveats exist to prevent.
18
+ *
19
+ * Spec 242 §6 uses this to validate bilateral-consent delegations as signed
20
+ * authorization predicates rather than as cross-account execution.
21
+ */
22
+ export declare function verifyAuthorization(args: {
23
+ publicClient: PublicClient;
24
+ delegationManager: Address;
25
+ delegations: Delegation[];
26
+ sender: Address;
27
+ }): Promise<VerifyAuthorizationResult>;
28
+ //# sourceMappingURL=verify-authorization.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verify-authorization.d.ts","sourceRoot":"","sources":["../src/verify-authorization.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AACxD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,MAAM,CAAC;AAEzC,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAqC7C,MAAM,WAAW,yBAAyB;IACxC,EAAE,EAAE,OAAO,CAAC;IACZ,uEAAuE;IACvE,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;;;;;;;;;;;GAYG;AACH,wBAAsB,mBAAmB,CAAC,IAAI,EAAE;IAC9C,YAAY,EAAE,YAAY,CAAC;IAC3B,iBAAiB,EAAE,OAAO,CAAC;IAC3B,WAAW,EAAE,UAAU,EAAE,CAAC;IAC1B,MAAM,EAAE,OAAO,CAAC;CACjB,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAuBrC"}
@@ -0,0 +1,73 @@
1
+ // SDK helper for `DelegationManager.verifyAuthorization(...)` view-only entrypoint
2
+ // (spec 242 PD-9). Used by `@agenticprimitives/attestations` to construct + read
3
+ // authorization-predicate verifications.
4
+ const VERIFY_AUTHORIZATION_ABI = [
5
+ {
6
+ type: 'function',
7
+ name: 'verifyAuthorization',
8
+ stateMutability: 'view',
9
+ inputs: [
10
+ {
11
+ name: 'delegations',
12
+ type: 'tuple[]',
13
+ components: [
14
+ { name: 'delegator', type: 'address' },
15
+ { name: 'delegate', type: 'address' },
16
+ { name: 'authority', type: 'bytes32' },
17
+ {
18
+ name: 'caveats',
19
+ type: 'tuple[]',
20
+ components: [
21
+ { name: 'enforcer', type: 'address' },
22
+ { name: 'terms', type: 'bytes' },
23
+ { name: 'args', type: 'bytes' },
24
+ ],
25
+ },
26
+ { name: 'salt', type: 'uint256' },
27
+ { name: 'signature', type: 'bytes' },
28
+ ],
29
+ },
30
+ { name: 'sender', type: 'address' },
31
+ ],
32
+ outputs: [
33
+ { name: 'ok', type: 'bool' },
34
+ { name: 'reason', type: 'string' },
35
+ ],
36
+ },
37
+ ];
38
+ /**
39
+ * View-only verification of a delegation chain. Returns whether the chain
40
+ * authorizes `sender` to redeem WITHOUT executing it.
41
+ *
42
+ * ⚠️ DANGER — chain-only. This does NOT evaluate caveats, so a `true` result is
43
+ * NOT permission to perform any specific (target, value, calldata). To authorize a
44
+ * concrete call use `verifyAuthorizationForCall` (fail-closed, evaluates every
45
+ * caveat) or live redemption. Treating this boolean as call authorization re-opens
46
+ * the exact over-trust the caveats exist to prevent.
47
+ *
48
+ * Spec 242 §6 uses this to validate bilateral-consent delegations as signed
49
+ * authorization predicates rather than as cross-account execution.
50
+ */
51
+ export async function verifyAuthorization(args) {
52
+ const onchainDelegations = args.delegations.map((d) => ({
53
+ delegator: d.delegator,
54
+ delegate: d.delegate,
55
+ authority: d.authority,
56
+ caveats: d.caveats.map((c) => ({
57
+ enforcer: c.enforcer,
58
+ terms: c.terms,
59
+ // `args` is OPTIONAL in the off-chain shape; on-chain expects bytes.
60
+ args: (c.args ?? '0x'),
61
+ })),
62
+ salt: d.salt,
63
+ signature: d.signature,
64
+ }));
65
+ const [ok, reason] = (await args.publicClient.readContract({
66
+ address: args.delegationManager,
67
+ abi: VERIFY_AUTHORIZATION_ABI,
68
+ functionName: 'verifyAuthorization',
69
+ args: [onchainDelegations, args.sender],
70
+ }));
71
+ return { ok, reason };
72
+ }
73
+ //# sourceMappingURL=verify-authorization.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verify-authorization.js","sourceRoot":"","sources":["../src/verify-authorization.ts"],"names":[],"mappings":"AAAA,mFAAmF;AACnF,iFAAiF;AACjF,yCAAyC;AAOzC,MAAM,wBAAwB,GAAG;IAC/B;QACE,IAAI,EAAE,UAAU;QAChB,IAAI,EAAE,qBAAqB;QAC3B,eAAe,EAAE,MAAM;QACvB,MAAM,EAAE;YACN;gBACE,IAAI,EAAE,aAAa;gBACnB,IAAI,EAAE,SAAS;gBACf,UAAU,EAAE;oBACV,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,EAAE;oBACtC,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE;oBACrC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,SAAS,EAAE;oBACtC;wBACE,IAAI,EAAE,SAAS;wBACf,IAAI,EAAE,SAAS;wBACf,UAAU,EAAE;4BACV,EAAE,IAAI,EAAE,UAAU,EAAE,IAAI,EAAE,SAAS,EAAE;4BACrC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE;4BAChC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE;yBAChC;qBACF;oBACD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AC,MAAM,CAAC;KACxC,CAAC,CAA+B,CAAC;IAElC,OAAO,EAAE,EAAE,EAAE,MAAM,EAAE,CAAC;AACxB,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@agenticprimitives/delegation",
3
- "version": "0.1.0-alpha.3",
3
+ "version": "1.0.0-alpha.11",
4
4
  "description": "EIP-712 smart-account delegations with caveats; web→agent→MCP token flow; session lifecycle.",
5
5
  "license": "MIT",
6
6
  "repository": {
@@ -31,19 +31,19 @@
31
31
  "access": "public"
32
32
  },
33
33
  "dependencies": {
34
- "@noble/curves": "^1.6.0",
35
- "@noble/hashes": "^1.5.0"
34
+ "@noble/curves": "^2.2.0",
35
+ "@noble/hashes": "^2.2.0"
36
36
  },
37
37
  "peerDependencies": {
38
- "viem": "^2.50.0",
39
- "@agenticprimitives/agent-account": "0.1.0-alpha.3",
40
- "@agenticprimitives/audit": "0.1.0-alpha.3",
41
- "@agenticprimitives/connect-auth": "0.1.0-alpha.3",
42
- "@agenticprimitives/key-custody": "0.1.0-alpha.3",
43
- "@agenticprimitives/types": "0.1.0-alpha.3"
38
+ "viem": "^2.52.2",
39
+ "@agenticprimitives/audit": "1.0.0-alpha.11",
40
+ "@agenticprimitives/agent-account": "1.0.0-alpha.11",
41
+ "@agenticprimitives/connect-auth": "1.0.0-alpha.11",
42
+ "@agenticprimitives/key-custody": "1.0.0-alpha.11",
43
+ "@agenticprimitives/types": "1.0.0-alpha.11"
44
44
  },
45
45
  "devDependencies": {
46
- "vitest": "^2.1.0"
46
+ "vitest": "^4.1.8"
47
47
  },
48
48
  "keywords": [
49
49
  "delegation",
@@ -58,7 +58,7 @@
58
58
  "build": "tsc -p tsconfig.build.json",
59
59
  "typecheck": "tsc -p tsconfig.json --noEmit",
60
60
  "test": "vitest run",
61
- "test:unit": "vitest run test/unit",
61
+ "test:unit": "vitest run test/unit --passWithNoTests",
62
62
  "test:integration": "vitest run test/integration --passWithNoTests",
63
63
  "test:watch": "vitest",
64
64
  "clean": "rm -rf dist"