@integraledger/terms 0.2.0 → 0.3.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 (41) hide show
  1. package/README.md +85 -51
  2. package/dist/agreement.d.ts +14 -4
  3. package/dist/agreement.js +139 -49
  4. package/dist/channels.d.ts +35 -13
  5. package/dist/channels.js +119 -66
  6. package/dist/gate.d.ts +31 -15
  7. package/dist/gate.js +56 -29
  8. package/dist/pairings/batch.d.ts +2 -5
  9. package/dist/pairings/batch.js +1 -11
  10. package/dist/pairings/card.js +0 -2
  11. package/dist/pairings/common.d.ts +4 -3
  12. package/dist/pairings/common.js +4 -3
  13. package/dist/pairings/lnbtc-request.d.ts +1 -1
  14. package/dist/pairings/lnbtc-request.js +1 -1
  15. package/dist/pairings/mpp-charge-hedera.d.ts +7 -7
  16. package/dist/pairings/mpp-charge-hedera.js +1 -1
  17. package/dist/pairings/mpp-charge-tempo-memo.d.ts +1 -9
  18. package/dist/pairings/mpp-charge-tempo-memo.js +3 -7
  19. package/dist/pairings/mpp-charge-tempo-push.d.ts +0 -1
  20. package/dist/pairings/mpp-charge-tempo-push.js +2 -10
  21. package/dist/pairings/mpp-charge-xrpl.js +3 -3
  22. package/dist/pairings/mpp-rails.d.ts +1 -1
  23. package/dist/pairings/mpp-session-xrpl.js +3 -4
  24. package/dist/pairings/mpp.d.ts +12 -16
  25. package/dist/pairings/mpp.js +31 -108
  26. package/dist/pairings/protocol-groups.d.ts +1 -1
  27. package/dist/pairings/x402-account-rails.d.ts +1 -1
  28. package/dist/pairings/x402-batch-settlement-solana.d.ts +2 -0
  29. package/dist/pairings/x402-batch-settlement-solana.js +2 -1
  30. package/dist/pairings/x402-exact-hedera.d.ts +4 -1
  31. package/dist/pairings/x402-exact-hedera.js +5 -2
  32. package/dist/pairings/x402-exact-solana.d.ts +4 -4
  33. package/dist/pairings/x402-exact-solana.js +3 -2
  34. package/dist/pairings/x402-exact-sui.js +3 -1
  35. package/dist/pairings/x402-exact-tvm.js +10 -2
  36. package/dist/pairings/x402-exact-xrpl.js +2 -4
  37. package/dist/pairings/x402-rail.d.ts +1 -1
  38. package/dist/transact.d.ts +3 -2
  39. package/dist/transact.js +9 -6
  40. package/dist/types.d.ts +6 -16
  41. package/package.json +11 -12
package/dist/transact.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { exchange } from "./agreement.js";
2
- import { confirm, declined, isObject, namespaceOf, pieceOf, signSteps, unsupported } from "./gate.js";
2
+ import { confirm, declined, hasAccount, isObject, namespaceOf, pieceOf, signSteps, unsupported } from "./gate.js";
3
3
  /**
4
4
  * `confirm`, then, for a pairing whose payment is not itself a public proof, the agreement, then the signer, then
5
5
  * `finish`. Without `approved`, an agreement not yet recorded is returned as `approve`, the agreement payment for the
@@ -8,13 +8,14 @@ import { confirm, declined, isObject, namespaceOf, pieceOf, signSteps, unsupport
8
8
  * the build is itself the payment the signer is not called; where the pairing has nothing for the buyer to sign,
9
9
  * `signed` is null after the comparison. `agreement` is the agreement's receipt, where the pairing needs one. `landed`
10
10
  * is `finish`'s, where it gives one. `signal` ends the agreement exchange. Options holding anything but `inputs`,
11
- * `agreementSigner`, `approved` and `signal` are declined before any fetch or signer call.
11
+ * `agreementSigner`, `approved` and `signal`, or a signer or agreement signer whose `account` is not a string, are
12
+ * declined `no-payable-option` with `<namespace>/input-malformed` before any fetch or signer call.
12
13
  */
13
14
  export async function transact(doc, binding, signer, fetch, options) {
14
15
  if (pieceOf(binding) === undefined)
15
16
  return unsupported(binding);
16
17
  const ns = namespaceOf(binding);
17
- if (!optionsOk(options))
18
+ if (!optionsOk(options) || !hasAccount(signer))
18
19
  return declined("no-payable-option", `${ns}/input-malformed`);
19
20
  const { inputs = {}, agreementSigner, approved, signal } = options ?? {};
20
21
  const confirmed = await confirm(doc, binding, signer.account, fetch, inputs);
@@ -37,8 +38,8 @@ export async function transact(doc, binding, signer, fetch, options) {
37
38
  const OPTION_KEYS = ["inputs", "agreementSigner", "approved", "signal"];
38
39
  /**
39
40
  * Whether `transact`'s options are absent, or an object holding only `inputs` (an object, or undefined),
40
- * `agreementSigner` (an object with a `sign` function, or undefined), `approved` (an object, or undefined) and `signal`
41
- * (an `AbortSignal`, or undefined).
41
+ * `agreementSigner` (an object with a `sign` function and a string `account`, or undefined), `approved` (an object, or
42
+ * undefined) and `signal` (an `AbortSignal`, or undefined).
42
43
  */
43
44
  function optionsOk(options) {
44
45
  if (options === undefined)
@@ -52,5 +53,7 @@ function optionsOk(options) {
52
53
  return false;
53
54
  if (signal !== undefined && !(signal instanceof AbortSignal))
54
55
  return false;
55
- return agreementSigner === undefined || (isObject(agreementSigner) && typeof agreementSigner["sign"] === "function");
56
+ if (agreementSigner === undefined)
57
+ return true;
58
+ return isObject(agreementSigner) && typeof agreementSigner["sign"] === "function" && hasAccount(agreementSigner);
56
59
  }
package/dist/types.d.ts CHANGED
@@ -68,22 +68,12 @@ export type SigningRequest = Extract<X402Unsigned, unknown>["request"] | Extract
68
68
  requests: readonly (BatchRequest | WithinSigningRequest)[];
69
69
  } | Extract<BatchRequest, {
70
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
- }
71
+ }>;
83
72
  /**
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`.
73
+ * The signer's answer, as JSON. Each kind's form is its buyer piece's: a signature for the kinds whose payment takes one
74
+ * signature, an object for the kinds whose payment takes several values, and a list, in order, for `batch`. Byte strings
75
+ * are `0x` hex, except where the signers guide names another form for the kind: base58, base64, or hex digits without
76
+ * `0x`.
87
77
  */
88
78
  export type Signature = Json;
89
79
  export interface Signer {
@@ -156,7 +146,7 @@ export interface Read {
156
146
  /**
157
147
  * The agreement payment, for the buyer's agent to approve before anything is signed: the agreement URL; `option`, the
158
148
  * option of the agreement URL's payment request that the gate pays, whose `amount`, `asset`, `payTo` and `network` are
159
- * what the payment moves; and `required`, that payment request as the agreement URL served it.
149
+ * the terms the agent approves; and `required`, that payment request as the agreement URL served it.
160
150
  */
161
151
  export interface AgreementPayment {
162
152
  readonly url: string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@integraledger/terms",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Buyer gate: compare the ATR hash with the served bytes, and build the payment with that hash, before signing.",
5
5
  "keywords": [
6
6
  "agentic-commerce",
@@ -16,7 +16,7 @@
16
16
  ],
17
17
  "license": "Apache-2.0",
18
18
  "engines": {
19
- "node": ">=26.10.0"
19
+ "node": ">=26.11.1"
20
20
  },
21
21
  "repository": {
22
22
  "type": "git",
@@ -39,22 +39,21 @@
39
39
  "dist",
40
40
  "LICENSE"
41
41
  ],
42
- "dependencies": {
43
- "@integraledger/lcp": "0.2.0"
42
+ "peerDependencies": {
43
+ "@integraledger/lcp": "~0.4.0"
44
44
  },
45
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",
46
+ "@integraledger/lcp": "0.4.0",
47
+ "@mysten/sui": "2.35.0",
48
+ "@solana/kit": "8.4.0",
49
+ "@stellar/stellar-sdk": "17.2.1",
52
50
  "@ton/core": "0.63.1",
53
51
  "algosdk": "3.8.0",
54
- "borsh": "1.0.0",
52
+ "borsh": "2.0.0",
55
53
  "esbuild": "0.28.2",
54
+ "near-api-js": "7.3.1",
56
55
  "ripple-binary-codec": "2.11.0",
57
- "viem": "2.56.8"
56
+ "viem": "2.57.4"
58
57
  },
59
58
  "scripts": {
60
59
  "build": "tsc -p tsconfig.json",