@ftptech/canton-agent-wallet 0.1.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.
Files changed (63) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +134 -0
  3. package/dist/canton-hash.d.ts +61 -0
  4. package/dist/canton-hash.d.ts.map +1 -0
  5. package/dist/canton-hash.js +108 -0
  6. package/dist/canton-hash.js.map +1 -0
  7. package/dist/cli-args.d.ts +31 -0
  8. package/dist/cli-args.d.ts.map +1 -0
  9. package/dist/cli-args.js +56 -0
  10. package/dist/cli-args.js.map +1 -0
  11. package/dist/cli.d.ts +3 -0
  12. package/dist/cli.d.ts.map +1 -0
  13. package/dist/cli.js +123 -0
  14. package/dist/cli.js.map +1 -0
  15. package/dist/hash-binding.d.ts +40 -0
  16. package/dist/hash-binding.d.ts.map +1 -0
  17. package/dist/hash-binding.js +20 -0
  18. package/dist/hash-binding.js.map +1 -0
  19. package/dist/index.d.ts +13 -0
  20. package/dist/index.d.ts.map +1 -0
  21. package/dist/index.js +13 -0
  22. package/dist/index.js.map +1 -0
  23. package/dist/keys.d.ts +26 -0
  24. package/dist/keys.d.ts.map +1 -0
  25. package/dist/keys.js +38 -0
  26. package/dist/keys.js.map +1 -0
  27. package/dist/onboard.d.ts +12 -0
  28. package/dist/onboard.d.ts.map +1 -0
  29. package/dist/onboard.js +152 -0
  30. package/dist/onboard.js.map +1 -0
  31. package/dist/pay.d.ts +16 -0
  32. package/dist/pay.d.ts.map +1 -0
  33. package/dist/pay.js +19 -0
  34. package/dist/pay.js.map +1 -0
  35. package/dist/relay-client.d.ts +128 -0
  36. package/dist/relay-client.d.ts.map +1 -0
  37. package/dist/relay-client.js +67 -0
  38. package/dist/relay-client.js.map +1 -0
  39. package/dist/relay-signer.d.ts +33 -0
  40. package/dist/relay-signer.d.ts.map +1 -0
  41. package/dist/relay-signer.js +44 -0
  42. package/dist/relay-signer.js.map +1 -0
  43. package/dist/store.d.ts +15 -0
  44. package/dist/store.d.ts.map +1 -0
  45. package/dist/store.js +33 -0
  46. package/dist/store.js.map +1 -0
  47. package/dist/trusted-dso.d.ts +33 -0
  48. package/dist/trusted-dso.d.ts.map +1 -0
  49. package/dist/trusted-dso.js +36 -0
  50. package/dist/trusted-dso.js.map +1 -0
  51. package/dist/tx.d.ts +102 -0
  52. package/dist/tx.d.ts.map +1 -0
  53. package/dist/tx.js +328 -0
  54. package/dist/tx.js.map +1 -0
  55. package/dist/verify-prepared.d.ts +361 -0
  56. package/dist/verify-prepared.d.ts.map +1 -0
  57. package/dist/verify-prepared.js +2235 -0
  58. package/dist/verify-prepared.js.map +1 -0
  59. package/dist/withdraw.d.ts +18 -0
  60. package/dist/withdraw.d.ts.map +1 -0
  61. package/dist/withdraw.js +31 -0
  62. package/dist/withdraw.js.map +1 -0
  63. package/package.json +33 -0
@@ -0,0 +1,128 @@
1
+ /**
2
+ * HTTP client for the facilitator's agent-wallet relay. The agent talks ONLY to
3
+ * this — plain HTTP, no Canton auth. The relay bridges to the participant using
4
+ * the validator token (onboarding + interactive submission) and proxies the
5
+ * public Scan registry resolves (the agent has no Scan access).
6
+ */
7
+ export interface RelayPublicKey {
8
+ format: string;
9
+ keyData: string;
10
+ keySpec: string;
11
+ }
12
+ export interface RelaySignature {
13
+ format: string;
14
+ signature: string;
15
+ signingAlgorithmSpec: string;
16
+ signedBy: string;
17
+ }
18
+ export interface OnboardPrepareResult {
19
+ party: string;
20
+ publicKeyFingerprint: string;
21
+ onboardingTransactions: string[];
22
+ hashToSign: string;
23
+ }
24
+ export interface BalanceResult {
25
+ party: string;
26
+ amulet: number;
27
+ cc: string;
28
+ holdings: Array<{
29
+ cid: string;
30
+ amount: string;
31
+ }>;
32
+ }
33
+ export interface ResolveFactoryResult {
34
+ factoryId: string;
35
+ transferKind: string;
36
+ transferFactoryTemplateId: string;
37
+ instrumentId: {
38
+ admin: string;
39
+ id: string;
40
+ };
41
+ choiceContextData: unknown;
42
+ disclosedContracts: unknown[];
43
+ }
44
+ export interface ResolveAcceptResult {
45
+ choiceContextData: unknown;
46
+ disclosedContracts: unknown[];
47
+ }
48
+ export interface PendingResult {
49
+ party: string;
50
+ pending: Array<{
51
+ cid: string;
52
+ amount?: string;
53
+ sender?: string;
54
+ }>;
55
+ }
56
+ /** v1 (external-party-amulet-rules): everything the agent needs to BUILD an
57
+ * `ExternalPartyAmuletRules_CreateTransferCommand` exercise. The agent pins
58
+ * sender/receiver/amount/delegate to its OWN intent in verify-before-sign —
59
+ * these refs widen nothing it will sign. */
60
+ export interface ResolveTransferCommandResult {
61
+ externalPartyAmuletRules: {
62
+ contractId: string;
63
+ /** EPAR's OWN resolved templateId (matches createdEventBlob's package). */
64
+ templateId: string;
65
+ createdEventBlob: string;
66
+ };
67
+ /** Resolved templateId for the CreateTransferCommand EXERCISE target. */
68
+ exerciseTemplateId: string;
69
+ /** The facilitator/delegate party (relay-supplied; the agent ALSO pins this
70
+ * to the 402's extra.facilitatorParty before signing). */
71
+ delegate: string;
72
+ /** Authoritative DSO party for the command's expectedDso field. */
73
+ expectedDso: string;
74
+ synchronizerId: string;
75
+ /** The agent's next-expected nonce (Daml Int as a string). */
76
+ nextNonce: string;
77
+ }
78
+ export interface TransferCommandCidResult {
79
+ party: string;
80
+ nonce: string;
81
+ transferCommandCid: string;
82
+ }
83
+ export declare class RelayClient {
84
+ private readonly opts;
85
+ constructor(opts: {
86
+ relayUrl: string;
87
+ apiKey?: string | undefined;
88
+ });
89
+ private headers;
90
+ private req;
91
+ onboardPrepare(b: {
92
+ publicKey: RelayPublicKey;
93
+ partyHint: string;
94
+ }): Promise<OnboardPrepareResult>;
95
+ onboardFinalize(b: {
96
+ onboardingTransactions: string[];
97
+ multiHashSignatures: RelaySignature[];
98
+ }): Promise<{
99
+ party: string;
100
+ }>;
101
+ submitPrepare(b: unknown): Promise<{
102
+ preparedTransaction: string;
103
+ hash: string;
104
+ }>;
105
+ submitExecute(b: unknown): Promise<{
106
+ updateId: string;
107
+ }>;
108
+ balance(party: string): Promise<BalanceResult>;
109
+ pending(party: string): Promise<PendingResult>;
110
+ resolveTransferFactory(b: {
111
+ sender: string;
112
+ receiver: string;
113
+ amount: string;
114
+ meta?: Record<string, string>;
115
+ }): Promise<ResolveFactoryResult>;
116
+ resolveAccept(b: {
117
+ instructionCid: string;
118
+ }): Promise<ResolveAcceptResult>;
119
+ /** v1: resolve the refs needed to build a CreateTransferCommand exercise. */
120
+ resolveTransferCommand(b: {
121
+ payerParty: string;
122
+ }): Promise<ResolveTransferCommandResult>;
123
+ /** v1: ACS-poll the relay for the cid of the just-created TransferCommand,
124
+ * matched by (sender, nonce). The relay bounds the poll and returns 404 if it
125
+ * never appears (surfaced here as a thrown relay error). */
126
+ transferCommandCid(party: string, nonce: string): Promise<TransferCommandCidResult>;
127
+ }
128
+ //# sourceMappingURL=relay-client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relay-client.d.ts","sourceRoot":"","sources":["../src/relay-client.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AACD,MAAM,WAAW,cAAc;IAC7B,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,QAAQ,EAAE,MAAM,CAAC;CAClB;AACD,MAAM,WAAW,oBAAoB;IACnC,KAAK,EAAE,MAAM,CAAC;IACd,oBAAoB,EAAE,MAAM,CAAC;IAC7B,sBAAsB,EAAE,MAAM,EAAE,CAAC;IACjC,UAAU,EAAE,MAAM,CAAC;CACpB;AACD,MAAM,WAAW,aAAa;IAC5B,KAAK,EAAE,MAAM,CAAC;IACd,MAAM,EAAE,MAAM,CAAC;IACf,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,KAAK,CAAC;QAAE,GAAG,EA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,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE;QAAE,QAAQ,EAAE,MAAM,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;KAAE;IAG1E,OAAO,CAAC,OAAO;YAMD,GAAG;IAoBjB,cAAc,CAAC,CAAC,EAAE;QAAE,SAAS,EAAE,cAAc,CAAC;QAAC,SAAS,EAAE,MAAM,CAAA;KAAE;IAGlE,eAAe,CAAC,CAAC,EAAE;QACjB,sBAAsB,EAAE,MAAM,EAAE,CAAC;QACjC,mBAAmB,EAAE,cAAc,EAAE,CAAC;KACvC;eAC0B,MAAM;;IAEjC,aAAa,CAAC,CAAC,EAAE,OAAO;6BACiB,MAAM;cAAQ,MAAM;;IAM7D,aAAa,CAAC,CAAC,EAAE,OAAO;kBACM,MAAM;;IAEpC,OAAO,CAAC,KAAK,EAAE,MAAM;IAMrB,OAAO,CAAC,KAAK,EAAE,MAAM;IAMrB,sBAAsB,CAAC,CAAC,EAAE;QACxB,MAAM,EAAE,MAAM,CAAC;QACf,QAAQ,EAAE,MAAM,CAAC;QACjB,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KAC/B;IAOD,aAAa,CAAC,CAAC,EAAE;QAAE,cAAc,EAAE,MAAM,CAAA;KAAE;IAG3C,6EAA6E;IAC7E,sBAAsB,CAAC,CAAC,EAAE;QAAE,UAAU,EAAE,MAAM,CAAA;KAAE;IAOhD;;iEAE6D;IAC7D,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM;CAMhD"}
@@ -0,0 +1,67 @@
1
+ export class RelayClient {
2
+ opts;
3
+ constructor(opts) {
4
+ this.opts = opts;
5
+ }
6
+ headers() {
7
+ const h = { "content-type": "application/json" };
8
+ if (this.opts.apiKey)
9
+ h["x-agent-key"] = this.opts.apiKey;
10
+ return h;
11
+ }
12
+ async req(method, path, body) {
13
+ const url = this.opts.relayUrl.replace(/\/$/, "") + path;
14
+ const r = await fetch(url, {
15
+ method,
16
+ headers: this.headers(),
17
+ ...(body !== undefined ? { body: JSON.stringify(body) } : {}),
18
+ });
19
+ const text = await r.text();
20
+ let json;
21
+ try {
22
+ json = JSON.parse(text);
23
+ }
24
+ catch {
25
+ /* leave undefined */
26
+ }
27
+ if (!r.ok) {
28
+ throw new Error(`relay ${method} ${path} -> ${r.status} ${text.slice(0, 200)}`);
29
+ }
30
+ return json;
31
+ }
32
+ onboardPrepare(b) {
33
+ return this.req("POST", "/v1/wallet/onboard/prepare", b);
34
+ }
35
+ onboardFinalize(b) {
36
+ return this.req("POST", "/v1/wallet/onboard/finalize", b);
37
+ }
38
+ submitPrepare(b) {
39
+ return this.req("POST", "/v1/wallet/submit/prepare", b);
40
+ }
41
+ submitExecute(b) {
42
+ return this.req("POST", "/v1/wallet/submit/execute", b);
43
+ }
44
+ balance(party) {
45
+ return this.req("GET", `/v1/wallet/${encodeURIComponent(party)}/balance`);
46
+ }
47
+ pending(party) {
48
+ return this.req("GET", `/v1/wallet/${encodeURIComponent(party)}/pending`);
49
+ }
50
+ resolveTransferFactory(b) {
51
+ return this.req("POST", "/v1/wallet/resolve/transfer-factory", b);
52
+ }
53
+ resolveAccept(b) {
54
+ return this.req("POST", "/v1/wallet/resolve/accept", b);
55
+ }
56
+ /** v1: resolve the refs needed to build a CreateTransferCommand exercise. */
57
+ resolveTransferCommand(b) {
58
+ return this.req("POST", "/v1/wallet/resolve/transfer-command", b);
59
+ }
60
+ /** v1: ACS-poll the relay for the cid of the just-created TransferCommand,
61
+ * matched by (sender, nonce). The relay bounds the poll and returns 404 if it
62
+ * never appears (surfaced here as a thrown relay error). */
63
+ transferCommandCid(party, nonce) {
64
+ return this.req("GET", `/v1/wallet/${encodeURIComponent(party)}/transfer-command?nonce=${encodeURIComponent(nonce)}`);
65
+ }
66
+ }
67
+ //# sourceMappingURL=relay-client.js.map
@@ -0,0 +1 @@
1
+ {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GAAG,CACb,KAAK,EACL,cAAc,kBAAkB,CAAC,KAAK,CAAC,2BAA2B,kBAAkB,CAAC,KAAK,CAAC,EAAE,CAC9F,CAAC;IACJ,CAAC;CACF"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * makeRelaySigner — a CantonSigner backed by the facilitator relay + the agent's
3
+ * self-custody key. It implements BOTH x402 transfer methods so the x402 client
4
+ * (`ExactCantonScheme`) can pick the right arm from the 402's advertised method:
5
+ *
6
+ * - `signCip56Transfer` (cip56-transfer-factory): resolve the factory (+ its
7
+ * disclosed contracts / choice context) via the relay, build
8
+ * TransferFactory_Transfer, verify-before-sign, sign locally, execute.
9
+ * - `signTransferCommand` (external-party-amulet-rules, v1 / mainnet-primary):
10
+ * resolve the EPAR refs via the relay, build
11
+ * ExternalPartyAmuletRules_CreateTransferCommand, verify-before-sign, sign
12
+ * locally, execute, then read back the created TransferCommand cid.
13
+ *
14
+ * Method SELECTION is the x402 client's job: it calls `signTransferCommand` iff
15
+ * the 402's `extra.transferMethod === "external-party-amulet-rules"` and
16
+ * `signCip56Transfer` iff `=== "cip56-transfer-factory"` (see scheme.ts). In
17
+ * BOTH cases the relay only prepares + forwards; it never holds the key, so it
18
+ * can never move the agent's funds, and verify-before-sign + hash-binding keep
19
+ * the self-custody guarantee on each path.
20
+ */
21
+ import type { CantonSigner } from "@ftptech/x402-canton-client";
22
+ import type { AgentWallet } from "./store.js";
23
+ import type { HashBindingOptions } from "./verify-prepared.js";
24
+ export declare function makeRelaySigner(wallet: AgentWallet, opts?: {
25
+ apiKey?: string | undefined;
26
+ hashBinding?: HashBindingOptions;
27
+ /** Independently-trusted Amulet DSO (instrument admin / expectedDso) to pin
28
+ * on both arms. Defaults to CANTON_AGENT_DSO_PARTY (see trusted-dso.ts).
29
+ * Without it, a relay-prepared tx that carries the DSO outside the root
30
+ * choice arg fails closed (the round-3 no-pin-fallback removal). */
31
+ trustedDso?: string;
32
+ }): CantonSigner;
33
+ //# sourceMappingURL=relay-signer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relay-signer.d.ts","sourceRoot":"","sources":["../src/relay-signer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,6BAA6B,CAAC;AAKhE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,KAAK,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE/D,wBAAgB,eAAe,CAC7B,MAAM,EAAE,WAAW,EACnB,IAAI,GAAE;IACJ,MAAM,CAAC,EAAE,MAAM,GAAG,SAAS,CAAC;IAC5B,WAAW,CAAC,EAAE,kBAAkB,CAAC;IACjC;;;yEAGqE;IACrE,UAAU,CAAC,EAAE,MAAM,CAAC;CAChB,GACL,YAAY,CAsCd"}
@@ -0,0 +1,44 @@
1
+ import { RelayClient } from "./relay-client.js";
2
+ import { transfer, createTransferCommand } from "./tx.js";
3
+ import { resolveHashBinding } from "./hash-binding.js";
4
+ import { resolveTrustedDsoParty } from "./trusted-dso.js";
5
+ export function makeRelaySigner(wallet, opts = {}) {
6
+ const relay = new RelayClient({ relayUrl: wallet.relayUrl, apiKey: opts.apiKey });
7
+ // Default to the env-resolved binding: the REAL conformant V2 hash recompute
8
+ // (canton-hash.ts) unless the operator explicitly sets the
9
+ // CANTON_AGENT_TRUST_RELAY_HASH escape hatch. A programmatic caller may pass a
10
+ // different `recomputeHash` instead.
11
+ const hashBinding = opts.hashBinding ?? resolveHashBinding();
12
+ // The network-constant Amulet DSO, resolved OUT-OF-BAND (never from the relay):
13
+ // pins the instrument admin / expectedDso so the foreign-party backstop can
14
+ // safely exclude the honest DSO that legitimately appears in the transfer's
15
+ // consequence. Without it, value-moving prepared bytes carrying the DSO outside
16
+ // the root choice arg are refused (fail-closed).
17
+ const trustedDso = opts.trustedDso ?? resolveTrustedDsoParty();
18
+ return {
19
+ party: wallet.party,
20
+ async signCip56Transfer(input) {
21
+ const updateId = await transfer(relay, wallet, {
22
+ receiver: input.receiver,
23
+ amount: input.amount,
24
+ ...(input.transferMeta ? { meta: input.transferMeta } : {}),
25
+ hashBinding,
26
+ ...(trustedDso !== undefined ? { expectInstrumentAdmin: trustedDso } : {}),
27
+ });
28
+ return { payerParty: wallet.party, updateId, transferInstructionCid: null };
29
+ },
30
+ async signTransferCommand(input) {
31
+ return createTransferCommand(relay, wallet, {
32
+ receiver: input.receiver,
33
+ amount: input.amount,
34
+ delegate: input.delegate,
35
+ synchronizerId: input.synchronizerId,
36
+ description: input.description,
37
+ ...(input.expiresAtMs !== undefined ? { expiresAtMs: input.expiresAtMs } : {}),
38
+ hashBinding,
39
+ ...(trustedDso !== undefined ? { expectedDso: trustedDso } : {}),
40
+ });
41
+ },
42
+ };
43
+ }
44
+ //# sourceMappingURL=relay-signer.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"relay-signer.js","sourceRoot":"","sources":["../src/relay-signer.ts"],"names":[],"mappings":"AAqBA,OAAO,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AAChD,OAAO,EAAE,QAAQ,EAAE,qBAAqB,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,MAAM,mBAAmB,CAAC;AACvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,kBAAkB,CAAC;AAI1D,MAAM,UAAU,eAAe,CAC7B,MAAmB,EACnB,OAQI,EAAE;IAEN,MAAM,KAAK,GAAG,IAAI,WAAW,CAAC,EAAE,QAAQ,EAAE,MAAM,CAAC,QAAQ,EAAE,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,CAAC,CAAC;IAClF,6EAA6E;IAC7E,2DAA2D;IAC3D,+EAA+E;IAC/E,qCAAqC;IACrC,MAAM,WAAW,GAAG,IAAI,CAAC,WAAW,IAAI,kBAAkB,EAAE,CAAC;IAC7D,gFAAgF;IAChF,4EAA4E;IAC5E,4EAA4E;IAC5E,gFAAgF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AC,CAAC,CAAC,EAAE,CAAC;aACjE,CAAC,CAAC;QACL,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,15 @@
1
+ export interface AgentWallet {
2
+ network: string;
3
+ relayUrl: string;
4
+ party: string;
5
+ publicKeySpkiB64: string;
6
+ privateKeyPkcs8Pem: string;
7
+ /** Participant-supplied multihash fingerprint (signedBy for signatures). */
8
+ publicKeyFingerprint: string;
9
+ createdAt: string;
10
+ }
11
+ export declare function walletPath(): string;
12
+ export declare function walletExists(): boolean;
13
+ export declare function loadWallet(): AgentWallet | null;
14
+ export declare function saveWallet(w: AgentWallet): void;
15
+ //# sourceMappingURL=store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AAiBA,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,gBAAgB,EAAE,MAAM,CAAC;IACzB,kBAAkB,EAAE,MAAM,CAAC;IAC3B,4EAA4E;IAC5E,oBAAoB,EAAE,MAAM,CAAC;IAC7B,SAAS,EAAE,MAAM,CAAC;CACnB;AAMD,wBAAgB,UAAU,IAAI,MAAM,CAEnC;AAED,wBAAgB,YAAY,IAAI,OAAO,CAEtC;AAED,wBAAgB,UAAU,IAAI,WAAW,GAAG,IAAI,CAI/C;AAED,wBAAgB,UAAU,CAAC,CAAC,EAAE,WAAW,GAAG,IAAI,CAM/C"}
package/dist/store.js ADDED
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Persistent, self-custody wallet store at ~/.canton-agent/wallet.json (0600).
3
+ *
4
+ * This file IS the wallet — the agent reuses the same one forever and never
5
+ * silently creates a second. It must be backed up; losing it loses the funds.
6
+ * Override the directory with CANTON_AGENT_HOME (used by tests + power users).
7
+ */
8
+ import { homedir } from "node:os";
9
+ import { join } from "node:path";
10
+ import { existsSync, mkdirSync, readFileSync, writeFileSync, chmodSync, } from "node:fs";
11
+ function dir() {
12
+ return process.env.CANTON_AGENT_HOME || join(homedir(), ".canton-agent");
13
+ }
14
+ export function walletPath() {
15
+ return join(dir(), "wallet.json");
16
+ }
17
+ export function walletExists() {
18
+ return existsSync(walletPath());
19
+ }
20
+ export function loadWallet() {
21
+ const p = walletPath();
22
+ if (!existsSync(p))
23
+ return null;
24
+ return JSON.parse(readFileSync(p, "utf8"));
25
+ }
26
+ export function saveWallet(w) {
27
+ const d = dir();
28
+ mkdirSync(d, { recursive: true, mode: 0o700 });
29
+ const p = walletPath();
30
+ writeFileSync(p, JSON.stringify(w, null, 2) + "\n", { mode: 0o600 });
31
+ chmodSync(p, 0o600); // enforce even if the file pre-existed with looser perms
32
+ }
33
+ //# sourceMappingURL=store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"store.js","sourceRoot":"","sources":["../src/store.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EACL,UAAU,EACV,SAAS,EACT,YAAY,EACZ,aAAa,EACb,SAAS,GACV,MAAM,SAAS,CAAC;AAajB,SAAS,GAAG;IACV,OAAO,OAAO,CAAC,GAAG,CAAC,iBAAiB,IAAI,IAAI,CAAC,OAAO,EAAE,EAAE,eAAe,CAAC,CAAC;AAC3E,CAAC;AAED,MAAM,UAAU,UAAU;IACxB,OAAO,IAAI,CAAC,GAAG,EAAE,EAAE,aAAa,CAAC,CAAC;AACpC,CAAC;AAED,MAAM,UAAU,YAAY;IAC1B,OAAO,UAAU,CAAC,UAAU,EAAE,CAAC,CAAC;AAClC,CAAC;AAED,MAAM,UAAU,UAAU;IACxB,MAAM,CAAC,GAAG,UAAU,EAAE,CAAC;IACvB,IAAI,CAAC,UAAU,CAAC,CAAC,CAAC;QAAE,OAAO,IAAI,CAAC;IAChC,OAAO,IAAI,CAAC,KAAK,CAAC,YAAY,CAAC,CAAC,EAAE,MAAM,CAAC,CAAgB,CAAC;AAC5D,CAAC;AAED,MAAM,UAAU,UAAU,CAAC,CAAc;IACvC,MAAM,CAAC,GAAG,GAAG,EAAE,CAAC;IAChB,SAAS,CAAC,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IAC/C,MAAM,CAAC,GAAG,UAAU,EAAE,CAAC;IACvB,aAAa,CAAC,CAAC,EAAE,IAAI,CAAC,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC,GAAG,IAAI,EAAE,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,CAAC;IACrE,SAAS,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAC,yDAAyD;AAChF,CAAC"}
@@ -0,0 +1,33 @@
1
+ /**
2
+ * Resolve the agent's INDEPENDENTLY-TRUSTED Amulet DSO party (the instrument
3
+ * admin) from the environment, for the CLI / autopay / withdraw paths.
4
+ *
5
+ * WHY THIS EXISTS (self-custody, post round-3 fix). verify-before-sign pins the
6
+ * money-critical fields to caller intent and runs an all-nodes foreign-party
7
+ * backstop. The one party it reads-but-does-not-pin is the relay-supplied
8
+ * instrument admin / expectedDso (the DSO). The honest transfer choice's
9
+ * consequence (the created TransferCommand) legitimately carries that DSO as a
10
+ * payload party + signatory, OUTSIDE the root choice argument. To keep the
11
+ * backstop sound, an admin/dso value is excluded outside its root position ONLY
12
+ * when the caller pins it to an INDEPENDENTLY-TRUSTED value; otherwise a malicious
13
+ * relay could alias the unpinned admin/dso to an attacker and inject that same
14
+ * value as a consequence / node-metadata / input-contract party (the
15
+ * neutralization the round-3 fix closes by REMOVING the no-pin value-global
16
+ * fallback). Consequently a value-moving transfer whose prepared bytes carry the
17
+ * DSO outside the root now FAILS CLOSED unless this trusted pin is supplied.
18
+ *
19
+ * The Amulet DSO party is a NETWORK-WIDE CONSTANT (the same for every wallet on a
20
+ * given Canton network), so the operator can configure it out-of-band ONCE — it
21
+ * is NOT learned from the relay (anchoring on the relay's own resolve response
22
+ * would be circular and provide no security). Set CANTON_AGENT_DSO_PARTY to the
23
+ * network's Amulet DSO party id. When unset, value-moving transfers that carry
24
+ * the DSO outside the root refuse to sign (fail-closed, the secure default).
25
+ */
26
+ /** The env var an operator sets to the network's Amulet DSO (instrument admin). */
27
+ export declare const TRUSTED_DSO_PARTY_ENV = "CANTON_AGENT_DSO_PARTY";
28
+ /**
29
+ * The independently-trusted DSO/instrument-admin party id, or undefined when the
30
+ * operator has not configured one. Trimmed; empty ⇒ undefined.
31
+ */
32
+ export declare function resolveTrustedDsoParty(env?: NodeJS.ProcessEnv): string | undefined;
33
+ //# sourceMappingURL=trusted-dso.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trusted-dso.d.ts","sourceRoot":"","sources":["../src/trusted-dso.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,mFAAmF;AACnF,eAAO,MAAM,qBAAqB,2BAA2B,CAAC;AAE9D;;;GAGG;AACH,wBAAgB,sBAAsB,CACpC,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC,MAAM,GAAG,SAAS,CAGpB"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * Resolve the agent's INDEPENDENTLY-TRUSTED Amulet DSO party (the instrument
3
+ * admin) from the environment, for the CLI / autopay / withdraw paths.
4
+ *
5
+ * WHY THIS EXISTS (self-custody, post round-3 fix). verify-before-sign pins the
6
+ * money-critical fields to caller intent and runs an all-nodes foreign-party
7
+ * backstop. The one party it reads-but-does-not-pin is the relay-supplied
8
+ * instrument admin / expectedDso (the DSO). The honest transfer choice's
9
+ * consequence (the created TransferCommand) legitimately carries that DSO as a
10
+ * payload party + signatory, OUTSIDE the root choice argument. To keep the
11
+ * backstop sound, an admin/dso value is excluded outside its root position ONLY
12
+ * when the caller pins it to an INDEPENDENTLY-TRUSTED value; otherwise a malicious
13
+ * relay could alias the unpinned admin/dso to an attacker and inject that same
14
+ * value as a consequence / node-metadata / input-contract party (the
15
+ * neutralization the round-3 fix closes by REMOVING the no-pin value-global
16
+ * fallback). Consequently a value-moving transfer whose prepared bytes carry the
17
+ * DSO outside the root now FAILS CLOSED unless this trusted pin is supplied.
18
+ *
19
+ * The Amulet DSO party is a NETWORK-WIDE CONSTANT (the same for every wallet on a
20
+ * given Canton network), so the operator can configure it out-of-band ONCE — it
21
+ * is NOT learned from the relay (anchoring on the relay's own resolve response
22
+ * would be circular and provide no security). Set CANTON_AGENT_DSO_PARTY to the
23
+ * network's Amulet DSO party id. When unset, value-moving transfers that carry
24
+ * the DSO outside the root refuse to sign (fail-closed, the secure default).
25
+ */
26
+ /** The env var an operator sets to the network's Amulet DSO (instrument admin). */
27
+ export const TRUSTED_DSO_PARTY_ENV = "CANTON_AGENT_DSO_PARTY";
28
+ /**
29
+ * The independently-trusted DSO/instrument-admin party id, or undefined when the
30
+ * operator has not configured one. Trimmed; empty ⇒ undefined.
31
+ */
32
+ export function resolveTrustedDsoParty(env = process.env) {
33
+ const v = (env[TRUSTED_DSO_PARTY_ENV] ?? "").trim();
34
+ return v.length > 0 ? v : undefined;
35
+ }
36
+ //# sourceMappingURL=trusted-dso.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trusted-dso.js","sourceRoot":"","sources":["../src/trusted-dso.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AAEH,mFAAmF;AACnF,MAAM,CAAC,MAAM,qBAAqB,GAAG,wBAAwB,CAAC;AAE9D;;;GAGG;AACH,MAAM,UAAU,sBAAsB,CACpC,MAAyB,OAAO,CAAC,GAAG;IAEpC,MAAM,CAAC,GAAG,CAAC,GAAG,CAAC,qBAAqB,CAAC,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAC;IACpD,OAAO,CAAC,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC;AACtC,CAAC"}
package/dist/tx.d.ts ADDED
@@ -0,0 +1,102 @@
1
+ import type { RelayClient } from "./relay-client.js";
2
+ import type { AgentWallet } from "./store.js";
3
+ import { type HashBindingOptions } from "./verify-prepared.js";
4
+ /**
5
+ * Send CC from the agent to `receiver`. Returns the ledger updateId.
6
+ *
7
+ * `opts.expectInstrumentId` overrides the asset the verifier pins the prepared
8
+ * transfer to (defaults to Canton Coin / "Amulet"). It is CALLER INTENT, never
9
+ * taken from the relay.
10
+ */
11
+ export declare function transfer(relay: RelayClient, wallet: AgentWallet, opts: {
12
+ receiver: string;
13
+ amount: string;
14
+ meta?: Record<string, string>;
15
+ expectInstrumentId?: string;
16
+ /** Optional, caller-intent synchronizer id to PREPARE on and to pin the
17
+ * SIGNED Metadata.synchronizer_id to. When supplied, the relay cannot land
18
+ * the agent's signature on a domain of its choosing. */
19
+ expectSynchronizerId?: string;
20
+ /** Optional, independently-trusted instrument admin (DSO) to pin. When
21
+ * supplied it closes the unpinned-admin neutralization fully (the admin can
22
+ * no longer be aliased to an attacker and smuggled in as a consequence
23
+ * recipient). Omitted by default — the agent has no out-of-band DSO. */
24
+ expectInstrumentAdmin?: string;
25
+ /**
26
+ * How to bind the relay-returned hash to the validated bytes before signing.
27
+ * Defaults (when omitted) to fail-closed: a value-moving transfer refuses to
28
+ * sign unless a `recomputeHash` is supplied or `trustRelayHash` is explicitly
29
+ * set. See HashBindingOptions / verify-prepared.ts.
30
+ */
31
+ hashBinding?: HashBindingOptions;
32
+ }): Promise<string>;
33
+ /**
34
+ * v1 (external-party-amulet-rules) — create a Splice `TransferCommand` the
35
+ * facilitator will later settle (it pays the GS traffic fee). The agent signs
36
+ * only an INTENT here: no gas, no preapproval. Mirrors the cip56 `transfer`
37
+ * flow — resolve refs via relay → build the create exercise → VERIFY-before-sign
38
+ * over the EXACT prepared bytes → sign locally → execute via relay → read back
39
+ * the created cid (ACS-polled by the relay) — but produces the v1 payload the
40
+ * x402 client puts in PaymentPayload: `{transferCommandCid, payerParty, nonce}`.
41
+ *
42
+ * SECURITY: every money-critical field the verifier pins (sender == own party,
43
+ * receiver == merchant payTo, amount == required, delegate == facilitatorParty)
44
+ * is CALLER INTENT passed in `opts`, NOT taken from the relay's resolve
45
+ * response. The relay-resolved EPAR/exercise templateIds + expectedDso are used
46
+ * only to BUILD the exercise; they widen nothing the agent will sign. The cid
47
+ * returned by the relay moves no funds on its own — the facilitator independently
48
+ * re-validates sender/receiver/amount/delegate/nonce at /verify + /settle.
49
+ */
50
+ export declare function createTransferCommand(relay: RelayClient, wallet: AgentWallet, opts: {
51
+ /** Merchant party id (PaymentRequirements.payTo). CALLER INTENT. */
52
+ receiver: string;
53
+ /** Atomic amount string (PaymentRequirements.amount). CALLER INTENT. */
54
+ amount: string;
55
+ /** Facilitator/delegate party (extra.facilitatorParty). CALLER INTENT —
56
+ * pinned by exact equality at the prepared command's delegate position. */
57
+ delegate: string;
58
+ /** Synchronizer id (extra.synchronizerId). CALLER INTENT — used to pin the
59
+ * prepare's synchronizer to the merchant-advertised one, never the relay's. */
60
+ synchronizerId: string;
61
+ /** JSON-encoded {paymentId, resourceUrl, merchantContractCid?, x402Version}
62
+ * the facilitator's /verify matches against TransferCommand.description. */
63
+ description: string;
64
+ /** Command expiry (epoch ms). Defaults to now + 60s. */
65
+ expiresAtMs?: number;
66
+ /** Optional, independently-trusted DSO party. When supplied it is pinned to
67
+ * the command's expectedDso AND closes the unpinned-DSO neutralization fully
68
+ * (the DSO can no longer be aliased to an attacker and smuggled in as a
69
+ * consequence recipient). Omitted by default — the agent has no out-of-band
70
+ * DSO; the position-aware backstop + money-role check still apply. NOTE:
71
+ * pinning to the relay's own `r.expectedDso` would be circular and is
72
+ * deliberately NOT done — only an out-of-band value is a real anchor. */
73
+ expectedDso?: string;
74
+ /** Hash-binding policy; defaults to fail-closed (see HashBindingOptions). */
75
+ hashBinding?: HashBindingOptions;
76
+ }): Promise<{
77
+ transferCommandCid: string;
78
+ payerParty: string;
79
+ nonce: number;
80
+ createUpdateId: string;
81
+ }>;
82
+ /**
83
+ * Accept every pending incoming transfer (e.g. the agent's initial funding).
84
+ *
85
+ * SECURITY: even though this path is funds-IN, it is NOT exempt from
86
+ * verify-before-sign. A malicious relay returning an OUTBOUND drain
87
+ * (CreateTransferCommand / TransferFactory_Transfer sending the agent's balance
88
+ * to an attacker) instead of the accept the agent built would otherwise be
89
+ * blind-signed. We pass `kind: "accept"`, which structurally proves the prepared
90
+ * transaction is a single `TransferInstruction_Accept` submitted by the agent —
91
+ * any outbound leg is rejected — and we bind the signed hash to those bytes
92
+ * (fail-closed by default, exactly like the other paths). `opts.hashBinding`
93
+ * lets a programmatic caller supply a participant-conformant recompute; the CLI
94
+ * resolves it from the environment (default fail-closed).
95
+ */
96
+ export declare function claimAll(relay: RelayClient, wallet: AgentWallet, opts?: {
97
+ hashBinding?: HashBindingOptions;
98
+ }): Promise<{
99
+ claimed: number;
100
+ updateIds: string[];
101
+ }>;
102
+ //# sourceMappingURL=tx.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"tx.d.ts","sourceRoot":"","sources":["../src/tx.ts"],"names":[],"mappings":"AASA,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAKL,KAAK,kBAAkB,EAIxB,MAAM,sBAAsB,CAAC;AAiI9B;;;;;;GAMG;AACH,wBAAsB,QAAQ,CAC5B,KAAK,EAAE,WAAW,EAClB,MAAM,EAAE,WAAW,EACnB,IAAI,EAAE;IACJ,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAC5B;;6DAEyD;IACzD,oBAAoB,CAAC,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