@integraledger/terms 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 (171) hide show
  1. package/LICENSE +202 -0
  2. package/README.md +539 -0
  3. package/dist/agreement.d.ts +23 -0
  4. package/dist/agreement.js +264 -0
  5. package/dist/channels.d.ts +49 -0
  6. package/dist/channels.js +395 -0
  7. package/dist/gate.d.ts +69 -0
  8. package/dist/gate.js +347 -0
  9. package/dist/index.d.ts +5 -0
  10. package/dist/index.js +4 -0
  11. package/dist/pairings/ack-payment-request.d.ts +1 -0
  12. package/dist/pairings/ack-payment-request.js +12 -0
  13. package/dist/pairings/acp-checkout-delegated.d.ts +2 -0
  14. package/dist/pairings/acp-checkout-delegated.js +28 -0
  15. package/dist/pairings/acp-checkout-undelegated.d.ts +1 -0
  16. package/dist/pairings/acp-checkout-undelegated.js +11 -0
  17. package/dist/pairings/ap2-checkout-mandate.d.ts +2 -0
  18. package/dist/pairings/ap2-checkout-mandate.js +23 -0
  19. package/dist/pairings/batch.d.ts +29 -0
  20. package/dist/pairings/batch.js +83 -0
  21. package/dist/pairings/card-mastercard-vi-autonomous.d.ts +1 -0
  22. package/dist/pairings/card-mastercard-vi-autonomous.js +3 -0
  23. package/dist/pairings/card-mastercard-vi-immediate.d.ts +1 -0
  24. package/dist/pairings/card-mastercard-vi-immediate.js +3 -0
  25. package/dist/pairings/card-seller-reference.d.ts +1 -0
  26. package/dist/pairings/card-seller-reference.js +3 -0
  27. package/dist/pairings/card-visa-tap.d.ts +1 -0
  28. package/dist/pairings/card-visa-tap.js +3 -0
  29. package/dist/pairings/card.d.ts +7 -0
  30. package/dist/pairings/card.js +68 -0
  31. package/dist/pairings/common.d.ts +54 -0
  32. package/dist/pairings/common.js +134 -0
  33. package/dist/pairings/evm-x402.d.ts +3 -0
  34. package/dist/pairings/evm-x402.js +49 -0
  35. package/dist/pairings/index.d.ts +3 -0
  36. package/dist/pairings/index.js +134 -0
  37. package/dist/pairings/lightning.d.ts +17 -0
  38. package/dist/pairings/lightning.js +112 -0
  39. package/dist/pairings/lnbtc-request.d.ts +24 -0
  40. package/dist/pairings/lnbtc-request.js +175 -0
  41. package/dist/pairings/mpp-charge-card.d.ts +1 -0
  42. package/dist/pairings/mpp-charge-card.js +3 -0
  43. package/dist/pairings/mpp-charge-evm-authorization.d.ts +1 -0
  44. package/dist/pairings/mpp-charge-evm-authorization.js +3 -0
  45. package/dist/pairings/mpp-charge-evm-hash.d.ts +1 -0
  46. package/dist/pairings/mpp-charge-evm-hash.js +3 -0
  47. package/dist/pairings/mpp-charge-evm-permit2.d.ts +1 -0
  48. package/dist/pairings/mpp-charge-evm-permit2.js +3 -0
  49. package/dist/pairings/mpp-charge-evm-transaction.d.ts +1 -0
  50. package/dist/pairings/mpp-charge-evm-transaction.js +3 -0
  51. package/dist/pairings/mpp-charge-hedera.d.ts +23 -0
  52. package/dist/pairings/mpp-charge-hedera.js +137 -0
  53. package/dist/pairings/mpp-charge-nearintents.d.ts +2 -0
  54. package/dist/pairings/mpp-charge-nearintents.js +19 -0
  55. package/dist/pairings/mpp-charge-solana.d.ts +1 -0
  56. package/dist/pairings/mpp-charge-solana.js +25 -0
  57. package/dist/pairings/mpp-charge-stellar.d.ts +1 -0
  58. package/dist/pairings/mpp-charge-stellar.js +16 -0
  59. package/dist/pairings/mpp-charge-stripe.d.ts +1 -0
  60. package/dist/pairings/mpp-charge-stripe.js +3 -0
  61. package/dist/pairings/mpp-charge-tempo-memo.d.ts +9 -0
  62. package/dist/pairings/mpp-charge-tempo-memo.js +10 -0
  63. package/dist/pairings/mpp-charge-tempo-push.d.ts +12 -0
  64. package/dist/pairings/mpp-charge-tempo-push.js +21 -0
  65. package/dist/pairings/mpp-charge-usdc-evm.d.ts +1 -0
  66. package/dist/pairings/mpp-charge-usdc-evm.js +6 -0
  67. package/dist/pairings/mpp-charge-usdc-gateway.d.ts +2 -0
  68. package/dist/pairings/mpp-charge-usdc-gateway.js +33 -0
  69. package/dist/pairings/mpp-charge-usdc-solana.d.ts +1 -0
  70. package/dist/pairings/mpp-charge-usdc-solana.js +25 -0
  71. package/dist/pairings/mpp-charge-usdc-stacks.d.ts +1 -0
  72. package/dist/pairings/mpp-charge-usdc-stacks.js +17 -0
  73. package/dist/pairings/mpp-charge-xrpl.d.ts +1 -0
  74. package/dist/pairings/mpp-charge-xrpl.js +20 -0
  75. package/dist/pairings/mpp-confirm-only.d.ts +2 -0
  76. package/dist/pairings/mpp-confirm-only.js +21 -0
  77. package/dist/pairings/mpp-rails.d.ts +48 -0
  78. package/dist/pairings/mpp-rails.js +71 -0
  79. package/dist/pairings/mpp-session-evm.d.ts +1 -0
  80. package/dist/pairings/mpp-session-evm.js +3 -0
  81. package/dist/pairings/mpp-session-hedera.d.ts +2 -0
  82. package/dist/pairings/mpp-session-hedera.js +41 -0
  83. package/dist/pairings/mpp-session-solana.d.ts +1 -0
  84. package/dist/pairings/mpp-session-solana.js +60 -0
  85. package/dist/pairings/mpp-session-tempo.d.ts +1 -0
  86. package/dist/pairings/mpp-session-tempo.js +3 -0
  87. package/dist/pairings/mpp-session-xrpl.d.ts +1 -0
  88. package/dist/pairings/mpp-session-xrpl.js +42 -0
  89. package/dist/pairings/mpp-session.d.ts +5 -0
  90. package/dist/pairings/mpp-session.js +65 -0
  91. package/dist/pairings/mpp-subscription-stripe.d.ts +1 -0
  92. package/dist/pairings/mpp-subscription-stripe.js +6 -0
  93. package/dist/pairings/mpp-subscription-tempo.d.ts +2 -0
  94. package/dist/pairings/mpp-subscription-tempo.js +2 -0
  95. package/dist/pairings/mpp.d.ts +43 -0
  96. package/dist/pairings/mpp.js +194 -0
  97. package/dist/pairings/protocol-groups.d.ts +17 -0
  98. package/dist/pairings/protocol-groups.js +27 -0
  99. package/dist/pairings/ucp-booking-ap2-mandate.d.ts +1 -0
  100. package/dist/pairings/ucp-booking-ap2-mandate.js +3 -0
  101. package/dist/pairings/ucp-booking-unsigned.d.ts +1 -0
  102. package/dist/pairings/ucp-booking-unsigned.js +3 -0
  103. package/dist/pairings/ucp-checkout-ap2-mandate.d.ts +1 -0
  104. package/dist/pairings/ucp-checkout-ap2-mandate.js +3 -0
  105. package/dist/pairings/ucp-checkout-unsigned.d.ts +1 -0
  106. package/dist/pairings/ucp-checkout-unsigned.js +3 -0
  107. package/dist/pairings/ucp.d.ts +5 -0
  108. package/dist/pairings/ucp.js +35 -0
  109. package/dist/pairings/x402-account-rails.d.ts +25 -0
  110. package/dist/pairings/x402-account-rails.js +52 -0
  111. package/dist/pairings/x402-auth-capture-eip155-eip3009.d.ts +1 -0
  112. package/dist/pairings/x402-auth-capture-eip155-eip3009.js +3 -0
  113. package/dist/pairings/x402-auth-capture-eip155-permit2.d.ts +1 -0
  114. package/dist/pairings/x402-auth-capture-eip155-permit2.js +3 -0
  115. package/dist/pairings/x402-batch-settlement-cloudflare.d.ts +2 -0
  116. package/dist/pairings/x402-batch-settlement-cloudflare.js +21 -0
  117. package/dist/pairings/x402-batch-settlement-eip155.d.ts +2 -0
  118. package/dist/pairings/x402-batch-settlement-eip155.js +32 -0
  119. package/dist/pairings/x402-batch-settlement-solana.d.ts +2 -0
  120. package/dist/pairings/x402-batch-settlement-solana.js +55 -0
  121. package/dist/pairings/x402-exact-algorand.d.ts +1 -0
  122. package/dist/pairings/x402-exact-algorand.js +37 -0
  123. package/dist/pairings/x402-exact-aptos.d.ts +1 -0
  124. package/dist/pairings/x402-exact-aptos.js +9 -0
  125. package/dist/pairings/x402-exact-cardano.d.ts +1 -0
  126. package/dist/pairings/x402-exact-cardano.js +7 -0
  127. package/dist/pairings/x402-exact-casper.d.ts +2 -0
  128. package/dist/pairings/x402-exact-casper.js +21 -0
  129. package/dist/pairings/x402-exact-ccd.d.ts +2 -0
  130. package/dist/pairings/x402-exact-ccd.js +20 -0
  131. package/dist/pairings/x402-exact-eip155-eip3009.d.ts +1 -0
  132. package/dist/pairings/x402-exact-eip155-eip3009.js +3 -0
  133. package/dist/pairings/x402-exact-eip155-erc7710-salt.d.ts +1 -0
  134. package/dist/pairings/x402-exact-eip155-erc7710-salt.js +3 -0
  135. package/dist/pairings/x402-exact-eip155-erc7710.d.ts +1 -0
  136. package/dist/pairings/x402-exact-eip155-erc7710.js +3 -0
  137. package/dist/pairings/x402-exact-eip155-permit2.d.ts +1 -0
  138. package/dist/pairings/x402-exact-eip155-permit2.js +3 -0
  139. package/dist/pairings/x402-exact-hedera-transfer-executor.d.ts +1 -0
  140. package/dist/pairings/x402-exact-hedera-transfer-executor.js +23 -0
  141. package/dist/pairings/x402-exact-hedera.d.ts +3 -0
  142. package/dist/pairings/x402-exact-hedera.js +46 -0
  143. package/dist/pairings/x402-exact-near.d.ts +2 -0
  144. package/dist/pairings/x402-exact-near.js +34 -0
  145. package/dist/pairings/x402-exact-polkadot-lcp-assets-remark.d.ts +2 -0
  146. package/dist/pairings/x402-exact-polkadot-lcp-assets-remark.js +20 -0
  147. package/dist/pairings/x402-exact-solana.d.ts +11 -0
  148. package/dist/pairings/x402-exact-solana.js +36 -0
  149. package/dist/pairings/x402-exact-starknet.d.ts +2 -0
  150. package/dist/pairings/x402-exact-starknet.js +20 -0
  151. package/dist/pairings/x402-exact-stellar.d.ts +1 -0
  152. package/dist/pairings/x402-exact-stellar.js +17 -0
  153. package/dist/pairings/x402-exact-sui.d.ts +1 -0
  154. package/dist/pairings/x402-exact-sui.js +10 -0
  155. package/dist/pairings/x402-exact-tron-lcp-trc20-memo.d.ts +2 -0
  156. package/dist/pairings/x402-exact-tron-lcp-trc20-memo.js +45 -0
  157. package/dist/pairings/x402-exact-tvm.d.ts +2 -0
  158. package/dist/pairings/x402-exact-tvm.js +35 -0
  159. package/dist/pairings/x402-exact-xrpl.d.ts +1 -0
  160. package/dist/pairings/x402-exact-xrpl.js +27 -0
  161. package/dist/pairings/x402-rail.d.ts +31 -0
  162. package/dist/pairings/x402-rail.js +65 -0
  163. package/dist/pairings/x402-upto-eip155-permit2.d.ts +1 -0
  164. package/dist/pairings/x402-upto-eip155-permit2.js +3 -0
  165. package/dist/pairings/x402-upto-solana.d.ts +1 -0
  166. package/dist/pairings/x402-upto-solana.js +42 -0
  167. package/dist/transact.d.ts +20 -0
  168. package/dist/transact.js +53 -0
  169. package/dist/types.d.ts +169 -0
  170. package/dist/types.js +2 -0
  171. package/package.json +64 -0
@@ -0,0 +1,53 @@
1
+ import { agree } from "./agreement.js";
2
+ import { confirm, declined, isObject, namespaceOf, pieceOf, signSteps, unsupported } from "./gate.js";
3
+ /**
4
+ * `confirm`, then, for a pairing whose payment is not itself a public proof, the agreement payment and its receipt,
5
+ * then the signer, then `finish`. On a decline before the signer the signer is never called. Where the build is itself
6
+ * the payment the signer is not called; where the pairing has nothing for the buyer to sign, `signed` is null after the
7
+ * comparison. When the agreement was paid first, `agreement` is its receipt. `landed` is `finish`'s, where it gives one.
8
+ * Options holding anything but `inputs` and `agreementSigner` are declined before any fetch or signer call.
9
+ */
10
+ export async function transact(doc, binding, signer, fetch, options) {
11
+ if (pieceOf(binding) === undefined)
12
+ return unsupported(binding);
13
+ if (!optionsOk(options))
14
+ return declined("no-payable-option", `${namespaceOf(binding)}/input-malformed`);
15
+ const given = options ?? {};
16
+ const inputs = given.inputs ?? {};
17
+ const agreementSigner = given.agreementSigner;
18
+ const confirmed = await confirm(doc, binding, signer.account, fetch, inputs);
19
+ if ("decline" in confirmed)
20
+ return confirmed;
21
+ const { bytes, chosen } = confirmed;
22
+ let receipt = {};
23
+ if (confirmed.agreement !== undefined) {
24
+ const agreed = await agree(confirmed.h, confirmed.agreement, agreementSigner ?? signer, fetch, {
25
+ bytes,
26
+ inputs,
27
+ ns: namespaceOf(binding),
28
+ });
29
+ if ("decline" in agreed)
30
+ return agreed;
31
+ receipt = { agreement: agreed.receipt };
32
+ }
33
+ const done = await signSteps(binding, chosen, confirmed.request, signer, bytes, confirmed.h);
34
+ if ("decline" in done)
35
+ return done;
36
+ const landed = done.landed === undefined ? {} : { landed: done.landed };
37
+ return { signed: done.signed, ...landed, bytes, h: done.h, ...receipt };
38
+ }
39
+ const OPTION_KEYS = ["inputs", "agreementSigner"];
40
+ /**
41
+ * Whether `transact`'s options are absent, or an object holding only `inputs` (an object, or undefined) and
42
+ * `agreementSigner` (an object with a `sign` function, or undefined).
43
+ */
44
+ function optionsOk(options) {
45
+ if (options === undefined)
46
+ return true;
47
+ if (!isObject(options) || !Object.keys(options).every((k) => OPTION_KEYS.includes(k)))
48
+ return false;
49
+ const { inputs, agreementSigner } = options;
50
+ if (inputs !== undefined && !isObject(inputs))
51
+ return false;
52
+ return agreementSigner === undefined || (isObject(agreementSigner) && typeof agreementSigner["sign"] === "function");
53
+ }
@@ -0,0 +1,169 @@
1
+ import type { AtrHash, Binding as LcpBinding, Json, Presented as LcpPresented, Refusal } from "@integraledger/lcp";
2
+ import type { AptosUnsigned } from "@integraledger/lcp/aptos";
3
+ import type { AvmUnsigned } from "@integraledger/lcp/avm";
4
+ import type { TapUnsigned, ViUnsigned } from "@integraledger/lcp/card";
5
+ import type { CardanoUnsigned } from "@integraledger/lcp/cardano";
6
+ import type { CasperUnsigned } from "@integraledger/lcp/casper";
7
+ import type { CcdUnsigned } from "@integraledger/lcp/ccd";
8
+ import type { LnUnsigned } from "@integraledger/lcp/lightning";
9
+ import type { exactHederaExecutor, HederaUnsigned } from "@integraledger/lcp/hedera";
10
+ import type { MPP_BINDINGS, MppCredential, MppUnsigned, RailSessionUnsigned, SessionUnsigned, UsdcUnsigned, WithinSigningRequest } from "@integraledger/lcp/mpp";
11
+ import type { NearUnsigned } from "@integraledger/lcp/near";
12
+ import type { PolkadotUnsigned } from "@integraledger/lcp/polkadot";
13
+ import type { StarknetUnsigned } from "@integraledger/lcp/starknet";
14
+ import type { StellarUnsigned } from "@integraledger/lcp/stellar";
15
+ import type { SuiUnsigned } from "@integraledger/lcp/sui";
16
+ import type { KeyAuthorizationUnsigned } from "@integraledger/lcp/tempo";
17
+ import type { TronUnsigned } from "@integraledger/lcp/tron";
18
+ import type { TvmUnsigned } from "@integraledger/lcp/tvm";
19
+ import type { Unsigned as UcpUnsigned } from "@integraledger/lcp/ucp";
20
+ import type { Unsigned as Ap2Unsigned } from "@integraledger/lcp/ap2";
21
+ import type { Unsigned as AcpUnsigned } from "@integraledger/lcp/acp";
22
+ import type { X402Unsigned } from "@integraledger/lcp/x402";
23
+ import type { SigningRequest as BatchRequest } from "@integraledger/lcp/x402-batch-settlement";
24
+ import type { SvmUnsigned } from "@integraledger/lcp/x402-exact-solana";
25
+ import type { XrplUnsigned } from "@integraledger/lcp/xrpl";
26
+ /** The largest ATR the gate fetches, hashes or checks: 1 MiB. */
27
+ export declare const MAX_ATR_BYTES = 1048576;
28
+ /** The pairing the caller names, as its binding. */
29
+ export type Binding = LcpBinding | (typeof MPP_BINDINGS)[number];
30
+ /** What the buyer presents as payment. */
31
+ export type Presented = LcpPresented | MppCredential;
32
+ /**
33
+ * WHATWG fetch, or anything with its call shape. The caller's network policy (proxy, egress rules) lives here. The gate
34
+ * asks with `redirect: "manual"` and reads a 3xx answer, or one of type `opaqueredirect`, as a redirect it does not
35
+ * follow.
36
+ */
37
+ export type Fetch = (url: string, init: {
38
+ method: "GET";
39
+ redirect: "manual";
40
+ signal: AbortSignal;
41
+ headers?: Record<string, string>;
42
+ }) => Promise<Response>;
43
+ /**
44
+ * What a signer is handed: the `request` of the pairing's `build` result, exactly as built, one kind per signing
45
+ * scheme. The protocol-group results that carry no kind of their own are tagged here: the TAP field (`tap-field`), VI's
46
+ * checkout mandate (`vi-checkout-mandate`), AP2's checkout-mandate content (`ap2-checkout-mandate`), the UCP checkout
47
+ * for the buyer's mandate issuer (`ucp-checkout`) and ACP's allowance (`acp-allowance`). `batch` is several requests,
48
+ * signed in order, as are the requests of an in-channel payment. `ed25519-raw` is raw Ed25519 over the bytes given.
49
+ * `tempo-calls` is a Tempo charge with splits: the calls, in order, of one `0x76` transaction.
50
+ */
51
+ export type SigningRequest = Extract<X402Unsigned, unknown>["request"] | Extract<MppUnsigned, unknown>["request"] | UsdcUnsigned["request"] | SessionUnsigned["funding"] | RailSessionUnsigned["request"] | KeyAuthorizationUnsigned["request"] | SvmUnsigned["request"] | StellarUnsigned["request"] | XrplUnsigned<unknown>["request"] | HederaUnsigned["request"] | Extract<Awaited<ReturnType<(typeof exactHederaExecutor)["build"]>>, {
52
+ request: unknown;
53
+ }>["request"] | AvmUnsigned["request"] | AptosUnsigned["request"] | CardanoUnsigned["request"] | SuiUnsigned["request"] | StarknetUnsigned["request"] | PolkadotUnsigned["request"] | TronUnsigned["request"] | TvmUnsigned["request"] | NearUnsigned["request"] | CasperUnsigned["request"] | CcdUnsigned["request"] | LnUnsigned["request"] | ({
54
+ kind: "tap-field";
55
+ } & TapUnsigned) | ({
56
+ kind: "vi-checkout-mandate";
57
+ } & ViUnsigned) | {
58
+ kind: "ap2-checkout-mandate";
59
+ content: Ap2Unsigned["content"];
60
+ } | {
61
+ kind: "ucp-checkout";
62
+ checkout: UcpUnsigned["checkout"];
63
+ } | {
64
+ kind: "acp-allowance";
65
+ allowance: AcpUnsigned["allowance"];
66
+ } | {
67
+ kind: "batch";
68
+ requests: readonly (BatchRequest | WithinSigningRequest)[];
69
+ } | Extract<BatchRequest, {
70
+ kind: "ed25519-raw";
71
+ }> | TempoCalls;
72
+ /** Several calls in one Tempo `0x76` transaction, in order, signed by the payer; broadcast by it where `broadcast`. */
73
+ export interface TempoCalls {
74
+ kind: "tempo-calls";
75
+ chainId: number;
76
+ calls: readonly {
77
+ to: `0x${string}`;
78
+ data: `0x${string}`;
79
+ }[];
80
+ validBefore: number;
81
+ broadcast: boolean;
82
+ }
83
+ /**
84
+ * The signer's answer, as JSON. Byte strings are `0x` hex. Each kind's form is its buyer piece's: a signature as hex
85
+ * for the kinds whose payment takes one signature, an object for the kinds whose payment takes several values, and a
86
+ * list, in order, for `batch`.
87
+ */
88
+ export type Signature = Json;
89
+ export interface Signer {
90
+ /** The payer, CAIP-10: `eip155:84532:0xf39F…2266`. */
91
+ readonly account: string;
92
+ /** Signs exactly `request`. */
93
+ sign(request: SigningRequest): Promise<Signature>;
94
+ }
95
+ /** The buyer's own values a pairing's build needs beside the offer, such as a recent block or an account nonce. */
96
+ export type Inputs = {
97
+ readonly [k: string]: Json;
98
+ };
99
+ /** What the gate chose to pay, as plain JSON data, so `finish` can rebuild the same request. */
100
+ export interface Chosen {
101
+ pairing: string;
102
+ choice: Json;
103
+ ref: string;
104
+ }
105
+ export type DeclineCode = "pairing-not-supported" | "offer-unreadable" | "no-payable-option" | "link-not-https" | "atr-unfetchable" | "atr-too-large" | "hash-mismatch" | "signer-failed" | "signed-not-bound" | "agreement-not-offered" | "agreement-pending" | "agreement-failed";
106
+ export interface Reason {
107
+ readonly code: DeclineCode;
108
+ readonly detail: string;
109
+ }
110
+ /**
111
+ * A decline. `moved` is present when the signer moved the payment before the decline: the payment as signed, in the
112
+ * protocol's own form, with the ATR bytes and their hash, for the buyer to keep and present again.
113
+ */
114
+ export type Declined = {
115
+ readonly decline: Reason;
116
+ readonly moved?: {
117
+ readonly signed: unknown;
118
+ readonly bytes: Uint8Array;
119
+ readonly h: AtrHash;
120
+ };
121
+ };
122
+ /** `transact`'s optional members: the buyer's own chain values, and the signer that pays the agreement. */
123
+ export interface TransactOptions {
124
+ readonly inputs?: Inputs | undefined;
125
+ readonly agreementSigner?: Signer | undefined;
126
+ }
127
+ /** The next request of a pairing signed in steps. */
128
+ export interface Next {
129
+ readonly next: SigningRequest;
130
+ }
131
+ /** What a binding's `read` gives the gate. */
132
+ export interface Read {
133
+ h: AtrHash;
134
+ link: string;
135
+ offer?: unknown;
136
+ }
137
+ /** The agreement resource's answer once the agreement payment carrying the ATR hash is recorded. */
138
+ export interface AgreementReceipt {
139
+ atrHash: AtrHash;
140
+ agreed: true;
141
+ network: string;
142
+ transaction: string;
143
+ }
144
+ /** Which option to pay, chosen from the read, the account, the buyer's inputs, the clock and the payment's `ref`. */
145
+ export type Choose = (read: Read, account: string, inputs: Inputs, now: number, ref: string, doc: unknown) => Chosen | Refusal;
146
+ /**
147
+ * One pairing's buyer piece: which option to pay, the build input it revives from `Chosen`, what the signer is handed,
148
+ * and how the signer's answer completes the payment.
149
+ */
150
+ export interface BuyerPiece {
151
+ /** `doc` is the seller's document as given, for pairings whose build takes it (card). */
152
+ choose(...args: Parameters<Choose>): ReturnType<Choose> | Promise<ReturnType<Choose>>;
153
+ /** The build's input, from `chosen` and, where the build reads the ATR itself, the bytes the gate compared. */
154
+ choice(chosen: Chosen, bytes: Uint8Array): unknown;
155
+ /** The pairing's build over that input, for a binding whose `build` takes other arguments than the input and the hash. */
156
+ build?(choice: unknown, h: AtrHash): Promise<unknown>;
157
+ /** The request for the signer, or null where the build is itself the payment and nothing is signed. */
158
+ request(unsigned: unknown): SigningRequest | null | Refusal;
159
+ /**
160
+ * The payment the answer completes, or, for a pairing signed in steps, the next request: the gate then calls the
161
+ * signer again and passes every answer so far, in order, as a list.
162
+ */
163
+ complete(unsigned: unknown, signature: Signature, chosen: Chosen): Promise<Presented | Next | Refusal>;
164
+ /** The payment as it is sent, once `bound` has read it, where the completion carries values only `bound` reads. */
165
+ sent?(signed: Presented): Presented;
166
+ /** True when the signer, handed this first request, moves the payment itself before the gate reads what was signed. */
167
+ moves?(request: SigningRequest): boolean;
168
+ }
169
+ export type { AtrHash };
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ /** The largest ATR the gate fetches, hashes or checks: 1 MiB. */
2
+ export const MAX_ATR_BYTES = 1_048_576;
package/package.json ADDED
@@ -0,0 +1,64 @@
1
+ {
2
+ "name": "@integraledger/terms",
3
+ "version": "0.1.0",
4
+ "description": "Buyer gate: compare the ATR hash with the served bytes, and build the payment with that hash, before signing.",
5
+ "keywords": [
6
+ "agentic-commerce",
7
+ "ai-agents",
8
+ "legal-context-protocol",
9
+ "lcp",
10
+ "atr",
11
+ "x402",
12
+ "mpp",
13
+ "payments",
14
+ "sha256",
15
+ "buyer"
16
+ ],
17
+ "license": "Apache-2.0",
18
+ "engines": {
19
+ "node": ">=26.10.0"
20
+ },
21
+ "repository": {
22
+ "type": "git",
23
+ "url": "git+https://github.com/IntegraLedger/integra-agentic-terms.git",
24
+ "directory": "agentic-terms"
25
+ },
26
+ "homepage": "https://github.com/IntegraLedger/integra-agentic-terms/tree/main/agentic-terms#readme",
27
+ "bugs": "https://github.com/IntegraLedger/integra-agentic-terms/issues",
28
+ "type": "module",
29
+ "publishConfig": {
30
+ "access": "public"
31
+ },
32
+ "exports": {
33
+ ".": {
34
+ "types": "./dist/index.d.ts",
35
+ "default": "./dist/index.js"
36
+ }
37
+ },
38
+ "files": [
39
+ "dist",
40
+ "LICENSE"
41
+ ],
42
+ "dependencies": {
43
+ "@integraledger/lcp": "0.1.0"
44
+ },
45
+ "devDependencies": {
46
+ "@mysten/sui": "2.31.3",
47
+ "@near-js/crypto": "2.5.1",
48
+ "@near-js/transactions": "2.5.1",
49
+ "@solana/kit": "8.3.0",
50
+ "@stacks/transactions": "7.6.0",
51
+ "@stellar/stellar-sdk": "17.1.0",
52
+ "@ton/core": "0.63.1",
53
+ "algosdk": "3.8.0",
54
+ "borsh": "1.0.0",
55
+ "esbuild": "0.28.2",
56
+ "ripple-binary-codec": "2.11.0",
57
+ "viem": "2.56.8"
58
+ },
59
+ "scripts": {
60
+ "build": "tsc -p tsconfig.json",
61
+ "typecheck": "tsc -p tsconfig.json --noEmit && tsc -p tsconfig.test.json",
62
+ "test": "vitest run"
63
+ }
64
+ }