@ftptech/x402-canton-client 0.1.5 → 0.2.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/fetch.d.ts CHANGED
@@ -63,4 +63,23 @@ export declare function wrapFetchWithCantonPayment(fetch: typeof globalThis.fetc
63
63
  * x402).
64
64
  */
65
65
  export declare function readPaymentResponseHeader<T = unknown>(response: Response): T | null;
66
+ /**
67
+ * Peek which on-ledger `transferMethod` `wrapFetchWithCantonPayment` WOULD choose
68
+ * for a given 402 response + signer, WITHOUT paying. Mirrors the exact selection
69
+ * `fetchWithPayment` runs (decode the PAYMENT-REQUIRED header → keep exact-canton
70
+ * entries the optional networkFilter allows → narrow to the methods THIS signer
71
+ * can produce → `selectRequirements ?? compatible[0]`). Returns the chosen
72
+ * `extra.transferMethod`, or `undefined` when it cannot tell (non-402, missing or
73
+ * malformed header, no compatible entry).
74
+ *
75
+ * The agent-wallet pay layer uses this to decide whether a pay needs the
76
+ * per-wallet serialization mutex: ONLY the v1 nonce path
77
+ * (`external-party-amulet-rules`) does; the no-nonce allocation/cip56 paths can
78
+ * run concurrently. `undefined` ("can't tell") must be treated as "serialize"
79
+ * (fail safe) by the caller, so an unparseable 402 never loses v1's protection.
80
+ *
81
+ * Kept in THIS module beside `fetchWithPayment` so the two selections cannot
82
+ * drift; a test pins that peek agrees with the method actually paid.
83
+ */
84
+ export declare function peekChosenTransferMethod(response: Response, signer: CantonSigner, options?: WrapFetchOptions): string | undefined;
66
85
  //# sourceMappingURL=fetch.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"fetch.d.ts","sourceRoot":"","sources":["../src/fetch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EAML,KAAK,mBAAmB,EACxB,KAAK,gBAAgB,EACrB,KAAK,aAAa,EACnB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,C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,MAAM,EAAE,YAAY,EACpB,OAAO,GAAE,gBAAqB,GAC7B,OAAO,UAAU,CAAC,KAAK,CA0JzB;AAqDD;;;;;GAKG;AACH,wBAAgB,yBAAyB,CAAC,CAAC,GAAG,OAAO,EACnD,QAAQ,EAAE,QAAQ,GACjB,CAAC,GAAG,IAAI,CAIV;AAED;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,QAAQ,EAClB,MAAM,EAAE,YAAY,EACpB,OAAO,GAAE,gBAAqB,GAC7B,MAAM,GAAG,SAAS,CAsBpB"}
package/dist/fetch.js CHANGED
@@ -23,12 +23,6 @@ import { ExactCantonScheme, SchemeMethodMismatchError } from "./scheme.js";
23
23
  /** Which on-ledger transfer methods a given signer can actually produce. */
24
24
  function signerMethods(signer) {
25
25
  const m = new Set();
26
- if (signer.signTransferCommand)
27
- m.add("external-party-amulet-rules");
28
- if (signer.signCip56Transfer)
29
- m.add("cip56-transfer-factory");
30
- if (signer.signAllocation)
31
- m.add("allocation-api");
32
26
  if (signer.signAllocationDirect)
33
27
  m.add("allocation-direct");
34
28
  return m;
@@ -237,4 +231,51 @@ export function readPaymentResponseHeader(response) {
237
231
  return null;
238
232
  return decodeBase64Json(header);
239
233
  }
234
+ /**
235
+ * Peek which on-ledger `transferMethod` `wrapFetchWithCantonPayment` WOULD choose
236
+ * for a given 402 response + signer, WITHOUT paying. Mirrors the exact selection
237
+ * `fetchWithPayment` runs (decode the PAYMENT-REQUIRED header → keep exact-canton
238
+ * entries the optional networkFilter allows → narrow to the methods THIS signer
239
+ * can produce → `selectRequirements ?? compatible[0]`). Returns the chosen
240
+ * `extra.transferMethod`, or `undefined` when it cannot tell (non-402, missing or
241
+ * malformed header, no compatible entry).
242
+ *
243
+ * The agent-wallet pay layer uses this to decide whether a pay needs the
244
+ * per-wallet serialization mutex: ONLY the v1 nonce path
245
+ * (`external-party-amulet-rules`) does; the no-nonce allocation/cip56 paths can
246
+ * run concurrently. `undefined` ("can't tell") must be treated as "serialize"
247
+ * (fail safe) by the caller, so an unparseable 402 never loses v1's protection.
248
+ *
249
+ * Kept in THIS module beside `fetchWithPayment` so the two selections cannot
250
+ * drift; a test pins that peek agrees with the method actually paid.
251
+ */
252
+ export function peekChosenTransferMethod(response, signer, options = {}) {
253
+ if (response.status !== 402)
254
+ return undefined;
255
+ const header = response.headers.get(HEADER_PAYMENT_REQUIRED_V2);
256
+ if (!header)
257
+ return undefined;
258
+ let required;
259
+ try {
260
+ required = decodeBase64Json(header);
261
+ }
262
+ catch {
263
+ return undefined;
264
+ }
265
+ if (!required || !Array.isArray(required.accepts))
266
+ return undefined;
267
+ const candidates = required.accepts.filter((a) => {
268
+ if (a.scheme !== "exact-canton")
269
+ return false;
270
+ if (options.networkFilter && !options.networkFilter(a.network))
271
+ return false;
272
+ return true;
273
+ });
274
+ const methods = signerMethods(signer);
275
+ const compatible = candidates.filter((a) => methods.has(a.extra.transferMethod));
276
+ if (compatible.length === 0)
277
+ return undefined;
278
+ const chosen = options.selectRequirements?.(compatible) ?? compatible[0];
279
+ return chosen?.extra.transferMethod;
280
+ }
240
281
  //# sourceMappingURL=fetch.js.map
package/dist/fetch.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"fetch.js","sourceRoot":"","sources":["../src/fetch.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;GAmBG;AAEH,OAAO,EACL,0BAA0B,EAC1B,2BAA2B,EAC3B,0BAA0B,EAC1B,gBAAgB,EAChB,gBAAgB,GAIjB,MAAM,2BAA2B,CAAC;AAEnC,OAAO,EAAE,iBAAiB,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAE3E,4EAA4E;AAC5E,SAAS,aAAa,CAAC,MAAoB;IACzC,MAAM,CAAC,GAAG,IAAI,GAAG,EAAU,CAAC;IAC5B,IAAI,MAAM,CAAC,mBAAmB;QAAE,CAAC,CAAC,GAAG,CAAC,6BAA6B,CAAC,CAAC;IACrE,I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B,CAAsB,MAAM,CAAC,CAAC;IAC3D,CAAC;IAAC,MAAM,CAAC;QACP,OAAO,SAAS,CAAC;IACnB,CAAC;IACD,IAAI,CAAC,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,OAAO,CAAC;QAAE,OAAO,SAAS,CAAC;IACpE,MAAM,UAAU,GAAG,QAAQ,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE;QAC/C,IAAI,CAAC,CAAC,MAAM,KAAK,cAAc;YAAE,OAAO,KAAK,CAAC;QAC9C,IAAI,OAAO,CAAC,aAAa,IAAI,CAAC,OAAO,CAAC,aAAa,CAAC,CAAC,CAAC,OAAO,CAAC;YAAE,OAAO,KAAK,CAAC;QAC7E,OAAO,IAAI,CAAC;IACd,CAAC,CAAC,CAAC;IACH,MAAM,OAAO,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;IACtC,MAAM,UAAU,GAAG,UAAU,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,KAAK,CAAC,cAAc,CAAC,CAAC,CAAC;IACjF,IAAI,UAAU,CAAC,MAAM,KAAK,CAAC;QAAE,OAAO,SAAS,CAAC;IAC9C,MAAM,MAAM,GACV,OAAO,CAAC,kBAAkB,EAAE,CAAC,UAAU,CAAC,IAAK,UAAU,CAAC,CAAC,CAAyB,CAAC;IACrF,OAAO,MAAM,EAAE,KAAK,CAAC,cAAc,CAAC;AACtC,CAAC"}
package/dist/index.d.ts CHANGED
@@ -1,6 +1,4 @@
1
1
  export * from "./signer.js";
2
2
  export * from "./scheme.js";
3
3
  export * from "./fetch.js";
4
- export * from "./keyfile-signer.js";
5
- export * from "./cip56-signer.js";
6
4
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC"}
package/dist/index.js CHANGED
@@ -1,6 +1,4 @@
1
1
  export * from "./signer.js";
2
2
  export * from "./scheme.js";
3
3
  export * from "./fetch.js";
4
- export * from "./keyfile-signer.js";
5
- export * from "./cip56-signer.js";
6
4
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC;AAC3B,cAAc,qBAAqB,CAAC;AACpC,cAAc,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,aAAa,CAAC;AAC5B,cAAc,aAAa,CAAC;AAC5B,cAAc,YAAY,CAAC"}
package/dist/scheme.d.ts CHANGED
@@ -29,9 +29,8 @@ export interface CantonPaymentEnvelope {
29
29
  }
30
30
  /**
31
31
  * Thrown when the resource advertises a transferMethod this signer cannot
32
- * service — e.g. a CIP-56-only wallet (the relay-backed agent wallet) facing a
33
- * resource that only accepts `external-party-amulet-rules` (the v1 Splice
34
- * TransferCommand path), or vice versa. Named + carrying both methods so the
32
+ * service — e.g. a resource whose 402 demands a method this signer does not
33
+ * implement. Named + carrying both the required and supported method so the
35
34
  * caller can branch (e.g. surface "fund a different wallet" vs a cryptic
36
35
  * "signer does not implement ..."), instead of leaking a bare Error.
37
36
  */
@@ -52,10 +51,11 @@ export declare class ExactCantonScheme {
52
51
  /**
53
52
  * Build the full PaymentPayload to send back in PAYMENT-SIGNATURE.
54
53
  *
55
- * Generates a fresh paymentId, stamps x402 metadata onto the
56
- * on-ledger Transfer.meta, delegates to signer.signCip56Transfer to
57
- * land the TransferFactory_Transfer, and wraps the result in the v2
58
- * envelope. Throws if the signer can't service the cip56 path.
54
+ * Generates a fresh paymentId, stamps x402 metadata onto the on-ledger
55
+ * transferLeg.meta, delegates to the signer's method arm for the 402's
56
+ * advertised transferMethod (allocation-direct via signer.signAllocationDirect,
57
+ * v1 via signer.signTransferCommand) to land the on-ledger artifact, and wraps
58
+ * the result in the v2 envelope. Throws if the signer can't service the method.
59
59
  */
60
60
  createPaymentPayload(requirements: PaymentRequirements, resource: X402ResourceInfo): Promise<CantonPaymentEnvelope>;
61
61
  }
@@ -1 +1 @@
1
- {"version":3,"file":"scheme.d.ts","sourceRoot":"","sources":["../src/scheme.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAGH,OAAO,KAAK,EACV,mBAAmB,EACnB,gBAAgB,EAChB,aAAa,EACb,oBAAoB,EACrB,MAAM,2BAA2B,CAAC;AACnC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,2BAA2B,CAAC;AAE7D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAEhD,MAAM,WAAW,qBAAqB;IACpC,WAAW,EAAE,CAAC,CAAC;IAOf,MAAM,EAAE,WAAW,CAAC;IACpB,OAAO,EAAE,aAAa,CAAC;IACvB,QAAQ,EAAE,gBAAgB,CAAC;IAC3B,QAAQ,EAAE,mBAAmB,CAAC;IAC9B,OAAO,EAAE,oBAAoB,CAAC;CAC/B;AAED;;;;;;;GAOG;AACH,qBAAa,yBAA0B,SAAQ,KAAK;IAEhD,wCAAwC;aACxB,QAAQ,EAAE,MAAM;IAChC,0CAA0C;aAC1B,SAAS,EAAE,MAAM;;IAHjC,wCAAwC;IACxB,QAAQ,EAAE,MAAM;IAChC,0CAA0C;IAC1B,SAAS,EAAE,MAA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8 @@ import { randomUUID } from "node:crypto";
20
20
  import { wireAmountToLedgerDecimal } from "@ftptech/x402-canton-core";
21
21
  /**
22
22
  * Thrown when the resource advertises a transferMethod this signer cannot
23
- * service — e.g. a CIP-56-only wallet (the relay-backed agent wallet) facing a
24
- * resource that only accepts `external-party-amulet-rules` (the v1 Splice
25
- * TransferCommand path), or vice versa. Named + carrying both methods so the
23
+ * service — e.g. a resource whose 402 demands a method this signer does not
24
+ * implement. Named + carrying both the required and supported method so the
26
25
  * caller can branch (e.g. surface "fund a different wallet" vs a cryptic
27
26
  * "signer does not implement ..."), instead of leaking a bare Error.
28
27
  */
@@ -34,14 +33,9 @@ export class SchemeMethodMismatchError extends Error {
34
33
  required,
35
34
  /** What this signer actually supports. */
36
35
  supported) {
37
- const hint = supported === "cip56-transfer-factory"
38
- ? " The agent-wallet relay signer is CIP-56-only " +
39
- "(cip56-transfer-factory) and cannot create a v1 " +
40
- "external-party-amulet-rules TransferCommand."
41
- : supported === "(none)"
42
- ? " This signer implements neither signCip56Transfer nor " +
43
- "signTransferCommand."
44
- : "";
36
+ const hint = supported === "(none)"
37
+ ? " This signer does not implement signAllocationDirect."
38
+ : "";
45
39
  super(`this wallet supports ${supported} only; the resource requires ` +
46
40
  `${required}.${hint}`);
47
41
  this.required = required;
@@ -57,10 +51,11 @@ export class ExactCantonScheme {
57
51
  /**
58
52
  * Build the full PaymentPayload to send back in PAYMENT-SIGNATURE.
59
53
  *
60
- * Generates a fresh paymentId, stamps x402 metadata onto the
61
- * on-ledger Transfer.meta, delegates to signer.signCip56Transfer to
62
- * land the TransferFactory_Transfer, and wraps the result in the v2
63
- * envelope. Throws if the signer can't service the cip56 path.
54
+ * Generates a fresh paymentId, stamps x402 metadata onto the on-ledger
55
+ * transferLeg.meta, delegates to the signer's method arm for the 402's
56
+ * advertised transferMethod (allocation-direct via signer.signAllocationDirect,
57
+ * v1 via signer.signTransferCommand) to land the on-ledger artifact, and wraps
58
+ * the result in the v2 envelope. Throws if the signer can't service the method.
64
59
  */
65
60
  async createPaymentPayload(requirements, resource) {
66
61
  const extra = requirements.extra;
@@ -78,193 +73,9 @@ export class ExactCantonScheme {
78
73
  // facilitator-first), so atomic only activates once an incoming 402 advertises
79
74
  // scheme "exact".
80
75
  const ledgerAmount = wireAmountToLedgerDecimal(requirements.scheme, requirements.amount);
81
- if (extra.transferMethod === "external-party-amulet-rules") {
82
- if (!this.signer.signTransferCommand) {
83
- // The signer advertised no v1 capability — most commonly the
84
- // CIP-56-only agent-wallet relay signer. Surface a named, branchable
85
- // error instead of a cryptic "does not implement ..." (plan §4.3).
86
- throw new SchemeMethodMismatchError("external-party-amulet-rules", this.signer.signCip56Transfer
87
- ? "cip56-transfer-factory"
88
- : "(none)");
89
- }
90
- // x402-ENVELOPE privacy (point 7): the TARGET is to stamp H(resourceUrl)
91
- // on-ledger instead of the plaintext URL. The client emits PLAINTEXT FOR
92
- // NOW; flipping to hashResourceUrl(resource.url) is GATED behind the
93
- // accept-both facilitator being DEPLOYED (the MainNet facilitator still
94
- // does strict plaintext equality, so emitting a hash before it ships would
95
- // get v1 payments REJECTED after the on-ledger command is signed = traffic
96
- // burn). The facilitator already accepts BOTH (resourceUrlMatchesStamp);
97
- // the client flip is a one-line follow-up once it is live — symmetry with
98
- // the held scheme/synchronizerId flips below.
99
- const description = JSON.stringify({
100
- paymentId,
101
- resourceUrl: resource.url,
102
- ...(extra.merchantContractCid !== undefined
103
- ? { merchantContractCid: extra.merchantContractCid }
104
- : {}),
105
- x402Version: 2,
106
- });
107
- const signed = await this.signer.signTransferCommand({
108
- receiver: requirements.payTo,
109
- delegate: extra.facilitatorParty,
110
- amount: ledgerAmount,
111
- synchronizerId: extra.synchronizerId,
112
- description,
113
- expiresAtMs: Date.now() + requirements.maxTimeoutSeconds * 1000,
114
- // The PAYMENT network lets a relay signer auto-pin the network-constant
115
- // DSO by the network being paid on (not the wallet's configured network).
116
- network: requirements.network,
117
- });
118
- return {
119
- x402Version: 2,
120
- scheme: "exact-canton",
121
- network: requirements.network,
122
- resource,
123
- accepted: requirements,
124
- payload: {
125
- transferMethod: "external-party-amulet-rules",
126
- transferCommandCid: signed.transferCommandCid,
127
- // PAYER FIELD (phdargen naming, accept-both): emit `payer` (primary,
128
- // aligns with SettleResponse/VerifyResponse) AND legacy `payerParty`
129
- // so the DEPLOYED v1 MainNet facilitator (reads `payerParty`) keeps
130
- // working until accept-both is deployed everywhere. See payloadPayer.
131
- payer: signed.payerParty,
132
- payerParty: signed.payerParty,
133
- nonce: signed.nonce,
134
- ...(signed.createUpdateId !== undefined
135
- ? { createUpdateId: signed.createUpdateId }
136
- : {}),
137
- },
138
- };
139
- }
140
- if (extra.transferMethod === "cip56-transfer-factory") {
141
- if (!this.signer.signCip56Transfer) {
142
- throw new SchemeMethodMismatchError("cip56-transfer-factory", this.signer.signTransferCommand
143
- ? "external-party-amulet-rules"
144
- : "(none)");
145
- }
146
- // Stash x402 metadata on the on-ledger Transfer.meta so the
147
- // facilitator's /verify can correlate even though there's no
148
- // dedicated `description` field on TransferFactory_Transfer.
149
- // `Map Text Text` encodes as a JSON object in Canton 3.4's
150
- // JSON Ledger API v2.
151
- // x402.facilitatorParty MUST be included in Transfer.meta so
152
- // that CIP-56 factory/registry implementations can add the
153
- // facilitator as an observer on the resulting TransferInstruction.
154
- // Without this, the facilitator cannot call getTransactionById
155
- // for the completed proof path (Canton only returns events the
156
- // requesting party is a stakeholder in). See scheme spec
157
- // §Facilitator Visibility for the full requirement.
158
- const transferMeta = {
159
- "x402.paymentId": paymentId,
160
- // x402-ENVELOPE privacy (point 7): TARGET is H(resourceUrl). Client emits
161
- // PLAINTEXT for now; the flip to hashResourceUrl(resource.url) is gated
162
- // behind the accept-both facilitator being DEPLOYED (deployed MainNet
163
- // facilitator still requires plaintext equality — emitting a hash early
164
- // = rejected payments / traffic burn). Facilitator already accepts both.
165
- "x402.resourceUrl": resource.url,
166
- "x402.version": "2",
167
- // NOTE: the on-ledger meta key x402.facilitatorParty is the registry's
168
- // observer-add hook (separate from the 402 `extra` rename to feePayer);
169
- // it stays as-is so the facilitator remains a stakeholder for the proof.
170
- "x402.facilitatorParty": extra.facilitatorParty,
171
- // Optional reconciliation metadata (e.g. an invoice id), mirroring the
172
- // optional x402.resourceUrl handling. Stamped only when the merchant set
173
- // extra.memo, so the key is omitted otherwise (keeps the meta minimal and
174
- // the "exactly these keys" guarantee when no memo is configured).
175
- ...(extra.memo ? { "x402.memo": extra.memo } : {}),
176
- };
177
- const signed = await this.signer.signCip56Transfer({
178
- receiver: requirements.payTo,
179
- transferFactoryCid: extra.transferFactoryCid,
180
- transferFactoryTemplateId: extra.transferFactoryTemplateId,
181
- factoryAdmin: extra.instrumentId.admin,
182
- instrumentId: extra.instrumentId,
183
- amount: ledgerAmount,
184
- synchronizerId: extra.synchronizerId,
185
- facilitatorParty: extra.facilitatorParty,
186
- transferMeta,
187
- });
188
- return {
189
- x402Version: 2,
190
- scheme: "exact-canton",
191
- network: requirements.network,
192
- resource,
193
- accepted: requirements,
194
- payload: {
195
- transferMethod: "cip56-transfer-factory",
196
- // PAYER FIELD (phdargen naming, accept-both): emit both — see the v1
197
- // arm above and payloadPayer.
198
- payer: signed.payerParty,
199
- payerParty: signed.payerParty,
200
- ...(signed.transferInstructionCid !== null
201
- ? { transferInstructionCid: signed.transferInstructionCid }
202
- : { updateId: signed.updateId }),
203
- },
204
- };
205
- }
206
- if (extra.transferMethod === "allocation-api") {
207
- if (!this.signer.signAllocation) {
208
- throw new SchemeMethodMismatchError("allocation-api", this.signer.signCip56Transfer
209
- ? "cip56-transfer-factory"
210
- : this.signer.signTransferCommand
211
- ? "external-party-amulet-rules"
212
- : "(none)");
213
- }
214
- // Stamp x402 metadata onto the on-ledger transferLeg.meta so the
215
- // facilitator's /verify can bind paymentId / resourceUrl / memo. Mirrors
216
- // the cip56 transferMeta. x402.facilitatorParty lets the registry add the
217
- // facilitator as the allocation's settlement.executor / observer.
218
- const transferMeta = {
219
- "x402.paymentId": paymentId,
220
- // x402-ENVELOPE privacy (point 7): TARGET is H(resourceUrl). Client emits
221
- // PLAINTEXT for now; the flip to hashResourceUrl(resource.url) is gated
222
- // behind the accept-both facilitator being DEPLOYED (deployed MainNet
223
- // facilitator still requires plaintext equality — emitting a hash early
224
- // = rejected payments / traffic burn). Facilitator already accepts both.
225
- "x402.resourceUrl": resource.url,
226
- "x402.version": "2",
227
- "x402.facilitatorParty": extra.facilitatorParty,
228
- ...(extra.memo ? { "x402.memo": extra.memo } : {}),
229
- };
230
- const signed = await this.signer.signAllocation({
231
- receiver: requirements.payTo,
232
- amount: ledgerAmount,
233
- instrumentId: extra.instrumentId,
234
- executor: extra.executor,
235
- synchronizerId: extra.synchronizerId,
236
- allocateBeforeSeconds: extra.allocateBeforeSeconds,
237
- settleBeforeSeconds: extra.settleBeforeSeconds,
238
- transferMeta,
239
- });
240
- return {
241
- x402Version: 2,
242
- scheme: "exact-canton",
243
- network: requirements.network,
244
- resource,
245
- accepted: requirements,
246
- payload: {
247
- transferMethod: "allocation-api",
248
- // PAYER FIELD (phdargen naming, accept-both): emit both — see the v1
249
- // arm above and payloadPayer.
250
- payer: signed.payerParty,
251
- payerParty: signed.payerParty,
252
- // Exactly one of allocationCid / allocationInstructionCid is set.
253
- ...(signed.allocationCid !== null
254
- ? { allocationCid: signed.allocationCid }
255
- : { allocationInstructionCid: signed.allocationInstructionCid ?? "" }),
256
- },
257
- };
258
- }
259
76
  if (extra.transferMethod === "allocation-direct") {
260
77
  if (!this.signer.signAllocationDirect) {
261
- throw new SchemeMethodMismatchError("allocation-direct", this.signer.signCip56Transfer
262
- ? "cip56-transfer-factory"
263
- : this.signer.signTransferCommand
264
- ? "external-party-amulet-rules"
265
- : this.signer.signAllocation
266
- ? "allocation-api"
267
- : "(none)");
78
+ throw new SchemeMethodMismatchError("allocation-direct", "(none)");
268
79
  }
269
80
  // The on-ledger lock is IDENTICAL to allocation-api (same
270
81
  // AllocationFactory_Allocate, receiver = merchant, executor = facilitator);
@@ -309,6 +120,13 @@ export class ExactCantonScheme {
309
120
  // The standing both-party consent cid — the facilitator's O(1) /settle
310
121
  // fast-path (it RESOLVES/MINTS its own otherwise; the cid moves no funds).
311
122
  directConsentCid: signed.directConsentCid,
123
+ // ATTRIBUTION (accept-both, forward-compatible): the ALLOCATE updateId is
124
+ // the create leg of this 2-tx DVP. Emit it as `createUpdateId` so the
125
+ // facilitator records the allocate's traffic burn alongside the settle's
126
+ // (mirrors the v1 arm above). Harmless to a facilitator that ignores it.
127
+ ...(signed.updateId !== undefined
128
+ ? { createUpdateId: signed.updateId }
129
+ : {}),
312
130
  // Exactly one of allocationCid / allocationInstructionCid is set.
313
131
  ...(signed.allocationCid !== null
314
132
  ? { allocationCid: signed.allocationCid }
@@ -1 +1 @@
1
- {"version":3,"file":"scheme.js","sourceRoot":"","sources":["../src/scheme.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAQzC,OAAO,EAAE,yBAAyB,EAAE,MAAM,2BAA2B,CAAC;AAkBtE;;;;;;;GAOG;AACH,MAAM,OAAO,yBAA0B,SAAQ,KAAK;IAGhC;IAEA;IAJlB;IACE,wCAAwC;IACxB,QAAgB;IAChC,0CAA0C;IAC1B,SAAiB;QAEjC,MAAM,IAAI,GACR,SAAS,KAAK,wBAAwB;YACpC,CAAC,CAAC,gDAAgD;gBAChD,kDAAkD;gBAClD,8CAA8C;YAChD,CAAC,CAAC,SAAS,KAAK,QAAQ;gBACtB,CAAC,CAAC,wDAAwD;oBACxD,sBAAsB;gBACxB,CAAC,CAAC,EAAE,CAAC;QACX,KAAK,CACH,wBAAwB,SAAS,+BAA+B;YAC9D,GAAG,QAAQ,IAAI,IAAI,EAAE,CACxB,CAAC;QAhBc,aAAQ,GAAR,QAAQ,CAAQ;QAEhB,cAAS,GAAT,SAAS,CAAQ;QAejC,IAAI,CAAC,IAAI,GAAG,2BAA2B,CAAC;IAC1C,CAAC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120 +1,20 @@
1
1
  /**
2
2
  * CantonSigner abstraction for the payer (agent) side.
3
3
  *
4
- * The signer lands the on-ledger artifact the facilitator later
5
- * verifies, via `signCip56Transfer` — any CIP-56 token (incl. Canton
6
- * Coin) through Splice's `TransferFactory_Transfer`. Settlement happens
7
- * directly between sender and receiver; the facilitator's role is just
8
- * verification (for a merchant with a TransferPreapproval the transfer
9
- * completes atomically).
4
+ * The signer lands the on-ledger artifact the facilitator later verifies, via
5
+ * `signAllocationDirect` — the payer LOCKS funds via `AllocationFactory_Allocate`
6
+ * (CIP-56 DVP "2-tx DIRECT", Design B) naming the merchant as receiver and the
7
+ * facilitator as executor; the facilitator settles in ONE tx via
8
+ * DirectSettlementConsent_Execute (no escrow, no facilitator custody).
10
9
  *
11
- * Implementation: `Cip56KeyfileSigner` production, Ed25519 PEM key,
12
- * interactive-submission/prepare+execute. Test stubs use vi.fn().
10
+ * Implementation: the agent-wallet relay signer (`makeRelaySigner`). Test stubs
11
+ * use vi.fn().
13
12
  */
14
- import type { CantonNetwork } from "@ftptech/x402-canton-core";
15
- export interface SignTransferCommandInput {
16
- /** Merchant party id. Same as PaymentRequirements.payTo. */
17
- receiver: string;
18
- /** Facilitator party id. Same as extra.facilitatorParty. */
19
- delegate: string;
20
- /** Daml Decimal amount string (e.g. "0.0100000000"), passed VERBATIM into the
21
- * on-ledger TransferCommand `amount : Decimal`. (Despite the x402-ENVELOPE
22
- * convention of atomic units on the wire, the deployed v1 path signs this
23
- * Decimal directly — there is no atomic→Decimal conversion on this path. An
24
- * earlier "Atomic units" note here was stale; see core `amount.ts`.) */
25
- amount: string;
26
- /** Global Synchronizer id. Same as extra.synchronizerId. */
27
- synchronizerId: string;
28
- /** JSON-encoded {paymentId, resourceUrl, merchantContractCid?, x402Version}. */
29
- description: string;
30
- /** Optional override for the TransferCommand expiry. Defaults to
31
- * now + 60s per the maxTimeoutSeconds convention. */
32
- expiresAtMs?: number;
33
- /** CAIP-2 network from the 402 challenge (PaymentRequirements.network). Lets a
34
- * relay signer resolve the network-constant DSO by the PAYMENT network rather
35
- * than the wallet's configured network, so auto-DSO works for any mainnet
36
- * payment regardless of how the wallet was created. Optional (back-compat). */
37
- network?: CantonNetwork;
38
- }
39
- export interface SignedTransferCommand {
40
- /** ContractId of the TransferCommand just created on-ledger. */
41
- transferCommandCid: string;
42
- /** The agent's own party id (the TransferCommand.sender). */
43
- payerParty: string;
44
- /** Monotonic nonce assigned to this TransferCommand. */
45
- nonce: number;
46
- /** updateId of the TransferCommand_Create transaction. Set when the agent
47
- * uses the relay path (submit/execute returns it); absent for direct
48
- * KeyfileSigner flows where the create updateId is not surfaced. */
49
- createUpdateId?: string;
50
- }
51
- export interface SignCip56TransferInput {
52
- /** Merchant party id. Same as PaymentRequirements.payTo. */
53
- receiver: string;
54
- /** CIP-56 TransferFactory cid the merchant advertised in
55
- * `extra.transferFactoryCid`. */
56
- transferFactoryCid: string;
57
- /** Hash-prefixed template id of the factory contract. The
58
- * signer can read this off Scan or pass through what the
59
- * merchant published. */
60
- transferFactoryTemplateId: string;
61
- /** The factory's admin party — clients should source from a
62
- * trusted location (Scan or the merchant's own published
63
- * metadata). Implementations check `expectedAdmin` matches the
64
- * factory's own admin field as a bait-defense. */
65
- factoryAdmin: string;
66
- /** `{admin, id}` of the instrument the merchant advertised in
67
- * `extra.instrumentId`. */
68
- instrumentId: {
69
- admin: string;
70
- id: string;
71
- };
72
- /** Daml Decimal string (matches the JSON Ledger API v2 / Token Standard
73
- * wire form), e.g. "0.1000000000". Compared by string equality. */
74
- amount: string;
75
- /** Global Synchronizer id. */
76
- synchronizerId: string;
77
- /** Optional override for the Transfer.executeBefore. Defaults
78
- * to now + 60s. */
79
- executeBeforeMs?: number;
80
- /** Token-specific extra context to pass into the factory choice's
81
- * `extraArgs`. For most CIP-56 tokens this is `{values: {}}` for
82
- * both `context` and `meta`; some implementations want
83
- * merchant-supplied factoryContext metadata. Canton 3.4 encodes
84
- * `Map Text Text` as a JSON object (not an array of pairs). */
85
- extraArgs?: {
86
- context: {
87
- values: Record<string, string>;
88
- };
89
- meta: {
90
- values: Record<string, string>;
91
- };
92
- };
93
- /** Facilitator party id from PaymentRequirements.extra.facilitatorParty.
94
- * MUST be included in Transfer.meta.values["x402.facilitatorParty"]
95
- * so that CIP-56 factories can add the facilitator as an observer
96
- * on the resulting TransferInstruction. Without observer status the
97
- * facilitator cannot verify or settle the payment. */
98
- facilitatorParty: string;
99
- /** Free-form metadata appended to the on-ledger Transfer.meta.
100
- * Will include x402 paymentId, resourceUrl, version, and
101
- * facilitatorParty (auto-added by ExactCantonScheme.sign). */
102
- transferMeta?: Record<string, string>;
103
- }
104
- export interface SignedCip56Transfer {
105
- payerParty: string;
106
- /** Canton ledger updateId of the TransferFactory_Transfer
107
- * submission. Always set; the client uses this as the
108
- * Completed-case proof in the PaymentPayload. */
109
- updateId: string;
110
- /** ContractId of the TransferInstruction the registry created,
111
- * IF the result was TransferInstructionResult_Pending. Null for
112
- * Completed results. */
113
- transferInstructionCid: string | null;
114
- }
115
- /** Input for the allocation-api (CIP-56 DVP) path: LOCK funds via
116
- * AllocationFactory_Allocate naming the facilitator as settlement.executor. */
117
- export interface SignAllocationInput {
13
+ /** Input for the allocation-direct (CIP-56 DVP "2-tx DIRECT", Design B) path: LOCK
14
+ * funds via `AllocationFactory_Allocate` with transferLeg.receiver = the MERCHANT
15
+ * (payTo) and settlement.executor = the facilitator. The facilitator settles in
16
+ * ONE tx via DirectSettlementConsent_Execute (a standing both-party consent). */
17
+ export interface SignAllocationDirectInput {
118
18
  /** Merchant party id. Same as PaymentRequirements.payTo. */
119
19
  receiver: string;
120
20
  /** Daml Decimal amount string, e.g. "0.1000000000". */
@@ -137,7 +37,7 @@ export interface SignAllocationInput {
137
37
  * version, memo?). */
138
38
  transferMeta?: Record<string, string>;
139
39
  }
140
- export interface SignedAllocation {
40
+ export interface SignedAllocationDirect {
141
41
  payerParty: string;
142
42
  /** ContractId of the live Allocation (the _Completed case — Amulet creates it
143
43
  * synchronously). Null when the registry returned a pending instruction. */
@@ -147,17 +47,6 @@ export interface SignedAllocation {
147
47
  allocationInstructionCid: string | null;
148
48
  /** Canton ledger updateId of the AllocationFactory_Allocate exercise. */
149
49
  updateId: string;
150
- }
151
- /** Input for the allocation-direct (CIP-56 DVP "2-tx DIRECT", Design B) path. The
152
- * on-ledger lock is IDENTICAL to allocation-api — `AllocationFactory_Allocate`
153
- * with transferLeg.receiver = the MERCHANT (payTo) and settlement.executor = the
154
- * facilitator — so the `extra` shape (and hence this input) is identical to
155
- * `SignAllocationInput`. The only difference is downstream: the facilitator
156
- * settles in ONE tx via DirectSettlementConsent_Execute (a standing both-party
157
- * consent) instead of a bare Allocation_ExecuteTransfer. (A type alias rather
158
- * than an empty `extends` interface — same fields, lint-clean.) */
159
- export type SignAllocationDirectInput = SignAllocationInput;
160
- export interface SignedAllocationDirect extends SignedAllocation {
161
50
  /** The standing both-party DirectSettlementConsent {sender, merchant} cid the
162
51
  * facilitator can exercise DirectSettlementConsent_Execute on. Captured from
163
52
  * the consent the signer ensured before locking; emitted into the payload as
@@ -169,42 +58,17 @@ export interface CantonSigner {
169
58
  /** Party this signer signs as. Same value the facilitator sees
170
59
  * in `payload.payerParty`. */
171
60
  readonly party: string;
172
- /**
173
- * Land a Splice TransferCommand on the agent's participant for the
174
- * Canton-Coin v1 path. Implementations call
175
- * /v2/interactive-submission/prepare -> sign the prepared-tx hash with
176
- * the agent's key -> /execute. Optional: signers that only support
177
- * CIP-56 may omit this method.
178
- */
179
- signTransferCommand?(input: SignTransferCommandInput): Promise<SignedTransferCommand>;
180
- /**
181
- * Exercise TransferFactory_Transfer on the agent's participant
182
- * for the CIP-56 path. Implementations submit the exercise,
183
- * extract the TransferInstructionResult from the resulting
184
- * transaction events, and return the updateId plus (if
185
- * applicable) the TransferInstruction cid. Optional: signers
186
- * that only support TransferCommand may omit this method.
187
- */
188
- signCip56Transfer?(input: SignCip56TransferInput): Promise<SignedCip56Transfer>;
189
- /**
190
- * Exercise AllocationFactory_Allocate on the agent's participant for the
191
- * allocation-api (CIP-56 DVP) path — LOCK funds into an Allocation naming the
192
- * facilitator as settlement.executor. The facilitator later submits
193
- * Allocation_ExecuteTransfer to settle (sponsored gas). Optional: signers that
194
- * only support other methods may omit this.
195
- */
196
- signAllocation?(input: SignAllocationInput): Promise<SignedAllocation>;
197
61
  /**
198
62
  * Exercise AllocationFactory_Allocate on the agent's participant for the
199
63
  * allocation-direct (CIP-56 DVP "2-tx DIRECT", Design B) path — LOCK funds into
200
64
  * an Allocation with transferLeg.receiver = the MERCHANT (payTo) and
201
- * settlement.executor = the facilitator, EXACTLY like `signAllocation`. The
202
- * difference is the standing both-party DirectSettlementConsent the signer must
203
- * ensure first (facilitator-alone onboarding): the facilitator then settles in
204
- * ONE tx via DirectSettlementConsent_Execute (no escrow, no forward, no
205
- * facilitator custody) instead of a bare Allocation_ExecuteTransfer. Returns the
206
- * same allocation proof plus the consent cid for the /settle fast-path. Optional:
207
- * signers that only support other methods may omit this.
65
+ * settlement.executor = the facilitator. The signer must first ensure the
66
+ * standing both-party DirectSettlementConsent (facilitator-alone onboarding): the
67
+ * facilitator then settles in ONE tx via DirectSettlementConsent_Execute (no
68
+ * escrow, no forward, no facilitator custody) instead of a bare
69
+ * Allocation_ExecuteTransfer. Returns the allocation proof plus the consent cid
70
+ * for the /settle fast-path. Optional: signers that only support other methods
71
+ * may omit this.
208
72
  */
209
73
  signAllocationDirect?(input: SignAllocationDirectInput): Promise<SignedAllocationDirect>;
210
74
  }
@@ -1 +1 @@
1
- {"version":3,"file":"signer.d.ts","sourceRoot":"","sources":["../src/signer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,2BAA2B,CAAC;AAE/D,MAAM,WAAW,wBAAwB;IACvC,4DAA4D;IAC5D,QAAQ,EAAE,MAAM,CAAC;IACjB,4DAA4D;IAC5D,QAAQ,EAAE,MAAM,CAAC;IACjB;;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D;IACjD,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,MAAM,WAAW,YAAY;IAC3B;mCAC+B;IAC/B,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IAEvB;;;;;;;;;;;OAWG;IACH,oBAAoB,CAAC,CACnB,KAAK,EAAE,yBAAyB,GAC/B,OAAO,CAAC,sBAAsB,CAAC,CAAC;CACpC"}
package/dist/signer.js CHANGED
@@ -1,15 +1,14 @@
1
1
  /**
2
2
  * CantonSigner abstraction for the payer (agent) side.
3
3
  *
4
- * The signer lands the on-ledger artifact the facilitator later
5
- * verifies, via `signCip56Transfer` — any CIP-56 token (incl. Canton
6
- * Coin) through Splice's `TransferFactory_Transfer`. Settlement happens
7
- * directly between sender and receiver; the facilitator's role is just
8
- * verification (for a merchant with a TransferPreapproval the transfer
9
- * completes atomically).
4
+ * The signer lands the on-ledger artifact the facilitator later verifies, via
5
+ * `signAllocationDirect` — the payer LOCKS funds via `AllocationFactory_Allocate`
6
+ * (CIP-56 DVP "2-tx DIRECT", Design B) naming the merchant as receiver and the
7
+ * facilitator as executor; the facilitator settles in ONE tx via
8
+ * DirectSettlementConsent_Execute (no escrow, no facilitator custody).
10
9
  *
11
- * Implementation: `Cip56KeyfileSigner` production, Ed25519 PEM key,
12
- * interactive-submission/prepare+execute. Test stubs use vi.fn().
10
+ * Implementation: the agent-wallet relay signer (`makeRelaySigner`). Test stubs
11
+ * use vi.fn().
13
12
  */
14
13
  export {};
15
14
  //# sourceMappingURL=signer.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"signer.js","sourceRoot":"","sources":["../src/signer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG"}
1
+ {"version":3,"file":"signer.js","sourceRoot":"","sources":["../src/signer.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ftptech/x402-canton-client",
3
- "version": "0.1.5",
3
+ "version": "0.2.0",
4
4
  "description": "Canton x402 client SDK — payer side. ExactCantonScheme + signer abstractions for autonomous agents.",
5
5
  "license": "Apache-2.0",
6
6
  "author": "FTP team",
@@ -37,8 +37,8 @@
37
37
  "LICENSE"
38
38
  ],
39
39
  "dependencies": {
40
- "@ftptech/x402-canton-core": "^0.1.0",
41
- "@ftptech/x402-canton-ledger": "^0.1.0"
40
+ "@ftptech/x402-canton-core": "^0.2.0",
41
+ "@ftptech/x402-canton-ledger": "^0.1.1"
42
42
  },
43
43
  "publishConfig": {
44
44
  "access": "public"