@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.
- package/README.md +85 -51
- package/dist/agreement.d.ts +14 -4
- package/dist/agreement.js +139 -49
- package/dist/channels.d.ts +35 -13
- package/dist/channels.js +119 -66
- package/dist/gate.d.ts +31 -15
- package/dist/gate.js +56 -29
- package/dist/pairings/batch.d.ts +2 -5
- package/dist/pairings/batch.js +1 -11
- package/dist/pairings/card.js +0 -2
- package/dist/pairings/common.d.ts +4 -3
- package/dist/pairings/common.js +4 -3
- package/dist/pairings/lnbtc-request.d.ts +1 -1
- package/dist/pairings/lnbtc-request.js +1 -1
- package/dist/pairings/mpp-charge-hedera.d.ts +7 -7
- package/dist/pairings/mpp-charge-hedera.js +1 -1
- package/dist/pairings/mpp-charge-tempo-memo.d.ts +1 -9
- package/dist/pairings/mpp-charge-tempo-memo.js +3 -7
- package/dist/pairings/mpp-charge-tempo-push.d.ts +0 -1
- package/dist/pairings/mpp-charge-tempo-push.js +2 -10
- package/dist/pairings/mpp-charge-xrpl.js +3 -3
- package/dist/pairings/mpp-rails.d.ts +1 -1
- package/dist/pairings/mpp-session-xrpl.js +3 -4
- package/dist/pairings/mpp.d.ts +12 -16
- package/dist/pairings/mpp.js +31 -108
- package/dist/pairings/protocol-groups.d.ts +1 -1
- package/dist/pairings/x402-account-rails.d.ts +1 -1
- package/dist/pairings/x402-batch-settlement-solana.d.ts +2 -0
- package/dist/pairings/x402-batch-settlement-solana.js +2 -1
- package/dist/pairings/x402-exact-hedera.d.ts +4 -1
- package/dist/pairings/x402-exact-hedera.js +5 -2
- package/dist/pairings/x402-exact-solana.d.ts +4 -4
- package/dist/pairings/x402-exact-solana.js +3 -2
- package/dist/pairings/x402-exact-sui.js +3 -1
- package/dist/pairings/x402-exact-tvm.js +10 -2
- package/dist/pairings/x402-exact-xrpl.js +2 -4
- package/dist/pairings/x402-rail.d.ts +1 -1
- package/dist/transact.d.ts +3 -2
- package/dist/transact.js +9 -6
- package/dist/types.d.ts +6 -16
- 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
|
|
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
|
|
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
|
-
|
|
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
|
-
}
|
|
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.
|
|
85
|
-
*
|
|
86
|
-
*
|
|
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
|
-
*
|
|
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.
|
|
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.
|
|
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
|
-
"
|
|
43
|
-
"@integraledger/lcp": "0.
|
|
42
|
+
"peerDependencies": {
|
|
43
|
+
"@integraledger/lcp": "~0.4.0"
|
|
44
44
|
},
|
|
45
45
|
"devDependencies": {
|
|
46
|
-
"@
|
|
47
|
-
"@
|
|
48
|
-
"@
|
|
49
|
-
"@
|
|
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": "
|
|
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
|
+
"viem": "2.57.4"
|
|
58
57
|
},
|
|
59
58
|
"scripts": {
|
|
60
59
|
"build": "tsc -p tsconfig.json",
|