@zkproofport-ai/sdk 0.2.10 → 0.2.11
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 +232 -18
- package/dist/arcWallet.d.ts +50 -0
- package/dist/arcWallet.d.ts.map +1 -0
- package/dist/arcWallet.js +158 -0
- package/dist/arcWallet.js.map +1 -0
- package/dist/attestation.d.ts +5 -1
- package/dist/attestation.d.ts.map +1 -1
- package/dist/attestation.js +21 -2
- package/dist/attestation.js.map +1 -1
- package/dist/cdp.d.ts +162 -0
- package/dist/cdp.d.ts.map +1 -0
- package/dist/cdp.js +78 -0
- package/dist/cdp.js.map +1 -0
- package/dist/circuits.d.ts +121 -0
- package/dist/circuits.d.ts.map +1 -0
- package/dist/circuits.js +129 -0
- package/dist/circuits.js.map +1 -0
- package/dist/constants.d.ts +8 -2
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +19 -4
- package/dist/constants.js.map +1 -1
- package/dist/delegation.d.ts +102 -0
- package/dist/delegation.d.ts.map +1 -0
- package/dist/delegation.js +121 -0
- package/dist/delegation.js.map +1 -0
- package/dist/extract.d.ts +46 -12
- package/dist/extract.d.ts.map +1 -1
- package/dist/extract.js +92 -30
- package/dist/extract.js.map +1 -1
- package/dist/flow.d.ts +13 -0
- package/dist/flow.d.ts.map +1 -1
- package/dist/flow.js +88 -3
- package/dist/flow.js.map +1 -1
- package/dist/index.d.ts +12 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +21 -0
- package/dist/index.js.map +1 -1
- package/dist/inputs.d.ts +12 -0
- package/dist/inputs.d.ts.map +1 -1
- package/dist/inputs.js +13 -2
- package/dist/inputs.js.map +1 -1
- package/dist/nanopayment.d.ts +71 -0
- package/dist/nanopayment.d.ts.map +1 -0
- package/dist/nanopayment.js +77 -0
- package/dist/nanopayment.js.map +1 -0
- package/dist/payment.d.ts +73 -0
- package/dist/payment.d.ts.map +1 -0
- package/dist/payment.js +167 -0
- package/dist/payment.js.map +1 -0
- package/dist/prove.d.ts +7 -0
- package/dist/prove.d.ts.map +1 -1
- package/dist/prove.js +2 -0
- package/dist/prove.js.map +1 -1
- package/dist/typedAction.d.ts +3 -0
- package/dist/typedAction.d.ts.map +1 -0
- package/dist/typedAction.js +50 -0
- package/dist/typedAction.js.map +1 -0
- package/dist/types.d.ts +146 -3
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +9 -6
- package/dist/types.js.map +1 -1
- package/dist/usdc.d.ts +63 -0
- package/dist/usdc.d.ts.map +1 -0
- package/dist/usdc.js +78 -0
- package/dist/usdc.js.map +1 -0
- package/dist/wallets.d.ts +96 -0
- package/dist/wallets.d.ts.map +1 -0
- package/dist/wallets.js +214 -0
- package/dist/wallets.js.map +1 -0
- package/package.json +40 -3
package/dist/payment.js
ADDED
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Paying for a proof.
|
|
3
|
+
*
|
|
4
|
+
* ## What happens
|
|
5
|
+
*
|
|
6
|
+
* 1. Ask for a proof with no payment. The service answers 402 with a list of
|
|
7
|
+
* chains it will take payment on (`accepts`), each with a price in that
|
|
8
|
+
* chain's USDC and a one-time nonce.
|
|
9
|
+
* 2. Pick a chain. Sign an EIP-3009 authorization for it. Send it back.
|
|
10
|
+
* 3. The service settles the authorization and returns the proof.
|
|
11
|
+
*
|
|
12
|
+
* The buyer signs. It never submits a transaction, so it needs no gas and no
|
|
13
|
+
* native balance on the chain it pays on -- only USDC. That holds on Base, on
|
|
14
|
+
* Ethereum and on Arc alike.
|
|
15
|
+
*
|
|
16
|
+
* ## Why this file is short
|
|
17
|
+
*
|
|
18
|
+
* Because the encoding is not written here. `@x402/evm`'s exact scheme builds
|
|
19
|
+
* and signs the authorization and `@x402/core`'s HTTP client encodes the
|
|
20
|
+
* header, which between them is the part that is easy to get subtly wrong --
|
|
21
|
+
* the v1 and v2 header formats differ, the USDC EIP-712 domain name differs
|
|
22
|
+
* between mainnet ("USD Coin") and testnets ("USDC"), and a wrong domain
|
|
23
|
+
* produces a valid signature over the wrong message that fails with no hint.
|
|
24
|
+
*
|
|
25
|
+
* This was written by hand twice before. In April a settle body was assembled
|
|
26
|
+
* field by field and posted to a facilitator; earlier today the authorization
|
|
27
|
+
* was skipped altogether in favour of the buyer sending its own transaction,
|
|
28
|
+
* which needs gas the buyer may not have and cannot work on a chain where no
|
|
29
|
+
* proof-of-payment is expected. Both were replaced by this.
|
|
30
|
+
*
|
|
31
|
+
* ## Which chains
|
|
32
|
+
*
|
|
33
|
+
* Any EVM chain the service offers. The v2 scheme registers as an `eip155:*`
|
|
34
|
+
* wildcard, so nothing here holds a chain list -- Arc included, which is the
|
|
35
|
+
* reason the offer is CAIP-2 (`eip155:5042002`) rather than a bare name. The
|
|
36
|
+
* bare names are a fixed 24-chain table inside `@x402/evm` and Arc is not in
|
|
37
|
+
* it.
|
|
38
|
+
*/
|
|
39
|
+
import { usdcSpendControls, isKnownUsdc, knownUsdc, DEFAULT_MAX_PAYMENT } from './usdc.js';
|
|
40
|
+
/**
|
|
41
|
+
* The chains a 402 answer will take payment on, in the order offered.
|
|
42
|
+
*
|
|
43
|
+
* Reading this before paying is what lets a caller choose -- "pay on Arc" is a
|
|
44
|
+
* filter over this list, not a separate code path.
|
|
45
|
+
*/
|
|
46
|
+
export function paymentOffers(challenge) {
|
|
47
|
+
const raw = (challenge.accepts ?? (challenge.payment ? [challenge.payment] : []));
|
|
48
|
+
return raw.map((r) => ({
|
|
49
|
+
network: String(r.network),
|
|
50
|
+
networkName: r.networkName ? String(r.networkName) : String(r.network),
|
|
51
|
+
// `amount` is the v2 name; `maxAmountRequired` was v1's. Both read, so
|
|
52
|
+
// an older service still parses.
|
|
53
|
+
amount: String(r.amount ?? r.maxAmountRequired ?? '0'),
|
|
54
|
+
asset: String(r.asset ?? ''),
|
|
55
|
+
payTo: String(r.payTo ?? ''),
|
|
56
|
+
raw: r,
|
|
57
|
+
}));
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Sign payment for one of the offers and return the headers to retry with.
|
|
61
|
+
*
|
|
62
|
+
* `network` names the chain to pay on, as either the CAIP-2 id
|
|
63
|
+
* (`eip155:5042002`) or the plain name (`arc-testnet`). Omitting it takes the
|
|
64
|
+
* first offer, which is the order the service listed its chains in.
|
|
65
|
+
*
|
|
66
|
+
* An unmatched name is an error listing what was offered. It is never a
|
|
67
|
+
* silent fall back to the first chain: paying on a chain the caller did not
|
|
68
|
+
* ask for spends real money in the wrong place, and the caller who typed
|
|
69
|
+
* `--network arc` would be told the payment succeeded.
|
|
70
|
+
*/
|
|
71
|
+
export function assertApprovedPayment(offer, approved) {
|
|
72
|
+
const extra = offer.raw.extra;
|
|
73
|
+
const sameAddress = (a, b) => typeof a === 'string' && /^0x[0-9a-fA-F]{40}$/.test(a) && a.toLowerCase() === b.toLowerCase();
|
|
74
|
+
if (offer.network !== approved.network || offer.raw.scheme !== approved.scheme || offer.amount !== approved.amount ||
|
|
75
|
+
!sameAddress(offer.asset, approved.asset) || !sameAddress(offer.payTo, approved.payTo) ||
|
|
76
|
+
extra?.name !== approved.extra.name || extra?.version !== approved.extra.version || !sameAddress(extra?.verifyingContract, approved.extra.verifyingContract)) {
|
|
77
|
+
throw Error('The actual payment offer differs from the user-approved amount, recipient, asset, network or signing domain. Refusing to sign.');
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
export async function signPayment(challenge, wallet, opts = {}) {
|
|
81
|
+
const offers = paymentOffers(challenge);
|
|
82
|
+
if (offers.length === 0) {
|
|
83
|
+
throw new Error('The service named no chains it takes payment on; nothing to pay');
|
|
84
|
+
}
|
|
85
|
+
let offer = offers[0];
|
|
86
|
+
if (opts.network) {
|
|
87
|
+
const wanted = opts.network.toLowerCase();
|
|
88
|
+
const found = offers.find((o) => o.network.toLowerCase() === wanted || o.networkName.toLowerCase() === wanted);
|
|
89
|
+
if (!found) {
|
|
90
|
+
throw new Error(`The service does not take payment on '${opts.network}'. It offers: ` +
|
|
91
|
+
offers.map((o) => `${o.networkName} (${o.network})`).join(', '));
|
|
92
|
+
}
|
|
93
|
+
offer = found;
|
|
94
|
+
}
|
|
95
|
+
if (opts.approvedPayment)
|
|
96
|
+
assertApprovedPayment(offer, opts.approvedPayment);
|
|
97
|
+
// Checked here so the refusal names the token. @x402/core would also
|
|
98
|
+
// refuse -- that is what spend controls are for -- but its message talks
|
|
99
|
+
// about allowedAssets and does not say what was asked for.
|
|
100
|
+
if (!isKnownUsdc(offer.network, offer.asset)) {
|
|
101
|
+
throw new Error(`${offer.networkName} payment was requested in token ${offer.asset}, which is not the USDC ` +
|
|
102
|
+
`this SDK knows for that chain` +
|
|
103
|
+
(knownUsdc(offer.network) ? ` (${knownUsdc(offer.network)})` : ' (no USDC known for it at all)') +
|
|
104
|
+
`. Refusing to sign: a 402 answer names the token it wants, and signing whatever it names ` +
|
|
105
|
+
`lets a service ask to be paid in anything.`);
|
|
106
|
+
}
|
|
107
|
+
// x402's top-level USD cap does not cover custom allowed assets such as
|
|
108
|
+
// Arc USDC. Enforce the same six-decimal limit on the selected offer here,
|
|
109
|
+
// before invoking any signer, whether or not exact terms were supplied.
|
|
110
|
+
const maximum = opts.maxPayment ?? DEFAULT_MAX_PAYMENT;
|
|
111
|
+
const match = /^\$?(\d+)(?:\.(\d{1,6}))?$/.exec(maximum);
|
|
112
|
+
if (!match)
|
|
113
|
+
throw new Error('Invalid maximum USDC payment: use a non-negative decimal with up to six places.');
|
|
114
|
+
const maximumUnits = BigInt(match[1]) * 1000000n + BigInt((match[2] ?? '').padEnd(6, '0'));
|
|
115
|
+
if (!/^\d+$/.test(offer.amount))
|
|
116
|
+
throw new Error('The USDC payment offer must use integer atomic units.');
|
|
117
|
+
if (BigInt(offer.amount) > maximumUnits) {
|
|
118
|
+
throw new Error(`The payment offer exceeds the maximum ${maximum} USDC payment. Refusing to sign.`);
|
|
119
|
+
}
|
|
120
|
+
const { x402Client, x402HTTPClient } = await import('@x402/core/client');
|
|
121
|
+
const { registerExactEvmScheme } = await import('@x402/evm/exact/client');
|
|
122
|
+
const { supportsBatching } = await import('@circle-fin/x402-batching');
|
|
123
|
+
const { registerBatchScheme } = await import('@circle-fin/x402-batching/client');
|
|
124
|
+
// Spend controls stay ON. Arc's USDC is not among the library's default
|
|
125
|
+
// assets, so paying there needs the assets named -- not the control
|
|
126
|
+
// disabled, which would allow any token on any chain.
|
|
127
|
+
const client = new x402Client();
|
|
128
|
+
client.setSpendControls(usdcSpendControls(opts.maxPayment));
|
|
129
|
+
// How the authorization gets signed depends on the offer.
|
|
130
|
+
//
|
|
131
|
+
// A batched offer is signed against Circle Gateway's wallet contract, not
|
|
132
|
+
// against USDC, and the two signatures are not interchangeable: registering
|
|
133
|
+
// the ordinary scheme and then the batched one leaves the ordinary one
|
|
134
|
+
// signing, which Gateway rejects as `unauthorized` -- a valid signature over
|
|
135
|
+
// the wrong thing. Circle's own way is to hand the ordinary scheme in as the
|
|
136
|
+
// fallback, so ONE composite scheme picks per offer.
|
|
137
|
+
if (supportsBatching(offer.raw)) {
|
|
138
|
+
const { ExactEvmScheme } = await import('@x402/evm/exact/client');
|
|
139
|
+
registerBatchScheme(client, {
|
|
140
|
+
signer: wallet,
|
|
141
|
+
fallbackScheme: new ExactEvmScheme(wallet),
|
|
142
|
+
});
|
|
143
|
+
}
|
|
144
|
+
else {
|
|
145
|
+
registerExactEvmScheme(client, { signer: wallet });
|
|
146
|
+
}
|
|
147
|
+
const http = new x402HTTPClient(client);
|
|
148
|
+
const payload = await client.createPaymentPayload({
|
|
149
|
+
x402Version: 2,
|
|
150
|
+
accepts: [offer.raw],
|
|
151
|
+
});
|
|
152
|
+
const headers = http.encodePaymentSignatureHeader(payload);
|
|
153
|
+
return {
|
|
154
|
+
headers: {
|
|
155
|
+
...headers,
|
|
156
|
+
// The service's own nonce, which ties this payment to the challenge it
|
|
157
|
+
// answers. Sent alongside the x402 header rather than inside it: the
|
|
158
|
+
// nonce is ours, not part of the standard, and it is what stops a
|
|
159
|
+
// settled payment being replayed against a second proof request.
|
|
160
|
+
...(challenge.nonce ? { 'X-Payment-Nonce': challenge.nonce } : {}),
|
|
161
|
+
},
|
|
162
|
+
paidOn: offer.networkName,
|
|
163
|
+
amount: offer.amount,
|
|
164
|
+
payer: wallet.address,
|
|
165
|
+
};
|
|
166
|
+
}
|
|
167
|
+
//# sourceMappingURL=payment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payment.js","sourceRoot":"","sources":["../src/payment.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAGH,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,SAAS,EAAE,mBAAmB,EAAE,MAAM,WAAW,CAAC;AAE3F;;;;;GAKG;AACH,MAAM,UAAU,aAAa,CAAC,SAI7B;IACC,MAAM,GAAG,GAAG,CAAC,SAAS,CAAC,OAAO,IAAI,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAE/E,CAAC;IACF,OAAO,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;QACrB,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;QAC1B,WAAW,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,OAAO,CAAC;QACtE,uEAAuE;QACvE,iCAAiC;QACjC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,iBAAiB,IAAI,GAAG,CAAC;QACtD,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;QAC5B,KAAK,EAAE,MAAM,CAAC,CAAC,CAAC,KAAK,IAAI,EAAE,CAAC;QAC5B,GAAG,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0EAA0E;IAC1E,4EAA4E;IAC5E,uEAAuE;IACvE,6EAA6E;IAC7E,6EAA6E;IAC7E,qDAAqD;IACrD,IAAI,gBAAgB,CAAC,KAAK,CAAC,GAA0C,CAAC,EAAE,CAAC;QACvE,MAAM,EAAE,cAAc,EAAE,GAAG,MAAM,MAAM,CAAC,wBAAwB,CAAC,CAAC;QAClE,mBAAmB,CAAC,MAAe,EAAE;YACnC,MAAM,EAAE,MAAe;YACvB,cAAc,EAAE,IAAK,cAAuD,CAAC,MAAM,CAAU;SACrF,CAAC,CAAC;IACd,CAAC;SAAM,CAAC;QACN,sBAAsB,CAAC,MAAM,EAAE,EAAE,MAAM,EAAE,MAAe,EAAE,CAAC,CAAC;IAC9D,CAAC;IACD,MAAM,IAAI,GAAG,IAAI,cAAc,CAAC,MAAM,CAAC,CAAC;IAExC,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,oBAAoB,CAAC;QAChD,WAAW,EAAE,CAAC;QACd,OAAO,EAAE,CAAC,KAAK,CAAC,GAAG,CAAC;KACZ,CAAC,CAAC;IACZ,MAAM,OAAO,GAAG,IAAI,CAAC,4BAA4B,CAAC,OAAO,CAAC,CAAC;IAE3D,OAAO;QACL,OAAO,EAAE;YACP,GAAG,OAAO;YACV,uEAAuE;YACvE,qEAAqE;YACrE,kEAAkE;YAClE,iEAAiE;YACjE,GAAG,CAAC,SAAS,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,iBAAiB,EAAE,SAAS,CAAC,KAAK,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SACnE;QACD,MAAM,EAAE,KAAK,CAAC,WAAW;QACzB,MAAM,EAAE,KAAK,CAAC,MAAM;QACpB,KAAK,EAAE,MAAM,CAAC,OAAO;KACtB,CAAC;AACJ,CAAC"}
|
package/dist/prove.d.ts
CHANGED
|
@@ -12,6 +12,12 @@ export declare function submitProof(config: ClientConfig, request: {
|
|
|
12
12
|
circuit: CircuitName;
|
|
13
13
|
inputs?: ProveInputs | Record<string, unknown>;
|
|
14
14
|
nonce?: string;
|
|
15
|
+
/**
|
|
16
|
+
* Payment headers from `signPayment` -- the x402 `X-Payment` header
|
|
17
|
+
* carrying a signed authorization. Absent against a service with payment
|
|
18
|
+
* disabled.
|
|
19
|
+
*/
|
|
20
|
+
paymentHeaders?: Record<string, string>;
|
|
15
21
|
}): Promise<ProveResponse>;
|
|
16
22
|
/**
|
|
17
23
|
* Submit an E2E encrypted proof request.
|
|
@@ -21,5 +27,6 @@ export declare function submitEncryptedProof(config: ClientConfig, request: {
|
|
|
21
27
|
circuit: CircuitName;
|
|
22
28
|
encryptedPayload: EncryptedEnvelope;
|
|
23
29
|
nonce?: string;
|
|
30
|
+
paymentHeaders?: Record<string, string>;
|
|
24
31
|
}): Promise<ProveResponse>;
|
|
25
32
|
//# sourceMappingURL=prove.d.ts.map
|
package/dist/prove.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prove.d.ts","sourceRoot":"","sources":["../src/prove.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACxF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAElD;;;;;;;GAOG;AACH,wBAAsB,WAAW,CAC/B,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE;IACP,OAAO,EAAE,WAAW,CAAC;IACrB,MAAM,CAAC,EAAE,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/C,KAAK,CAAC,EAAE,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"prove.d.ts","sourceRoot":"","sources":["../src/prove.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,YAAY,CAAC;AACxF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,UAAU,CAAC;AAElD;;;;;;;GAOG;AACH,wBAAsB,WAAW,CAC/B,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE;IACP,OAAO,EAAE,WAAW,CAAC;IACrB,MAAM,CAAC,EAAE,WAAW,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAC/C,KAAK,CAAC,EAAE,MAAM,CAAC;IACf;;;;OAIG;IACH,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACzC,GACA,OAAO,CAAC,aAAa,CAAC,CAyBxB;AAED;;;GAGG;AACH,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,YAAY,EACpB,OAAO,EAAE;IACP,OAAO,EAAE,WAAW,CAAC;IACrB,gBAAgB,EAAE,iBAAiB,CAAC;IACpC,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;CACzC,GACA,OAAO,CAAC,aAAa,CAAC,CA6BxB"}
|
package/dist/prove.js
CHANGED
|
@@ -18,6 +18,7 @@ export async function submitProof(config, request) {
|
|
|
18
18
|
if (request.nonce) {
|
|
19
19
|
headers['X-Payment-Nonce'] = request.nonce;
|
|
20
20
|
}
|
|
21
|
+
Object.assign(headers, request.paymentHeaders ?? {});
|
|
21
22
|
const response = await fetch(url, {
|
|
22
23
|
method: 'POST',
|
|
23
24
|
headers,
|
|
@@ -41,6 +42,7 @@ export async function submitEncryptedProof(config, request) {
|
|
|
41
42
|
if (request.nonce) {
|
|
42
43
|
headers['X-Payment-Nonce'] = request.nonce;
|
|
43
44
|
}
|
|
45
|
+
Object.assign(headers, request.paymentHeaders ?? {});
|
|
44
46
|
const response = await fetch(url, {
|
|
45
47
|
method: 'POST',
|
|
46
48
|
headers,
|
package/dist/prove.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"prove.js","sourceRoot":"","sources":["../src/prove.ts"],"names":[],"m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A6E;AAC7E,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,GAAG,IAAI,CAkDjE"}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
const ADDRESS = /^0x[0-9a-fA-F]{40}$/;
|
|
2
|
+
/** The reason the value is not a usable action, or `null` when it is one. */
|
|
3
|
+
export function validateTypedAction(value) {
|
|
4
|
+
if (value === undefined || value === null) {
|
|
5
|
+
return 'action is required for arc_eligibility. The circuit proves that a wallet authorised ONE EIP-712 action; there is nothing to prove without it.';
|
|
6
|
+
}
|
|
7
|
+
if (typeof value !== 'object' || Array.isArray(value)) {
|
|
8
|
+
return 'action must be an object.';
|
|
9
|
+
}
|
|
10
|
+
const a = value;
|
|
11
|
+
const d = a.domain;
|
|
12
|
+
if (!d || typeof d !== 'object') {
|
|
13
|
+
return 'action.domain is required.';
|
|
14
|
+
}
|
|
15
|
+
for (const k of ['name', 'version', 'verifyingContract']) {
|
|
16
|
+
if (typeof d[k] !== 'string' || !d[k]) {
|
|
17
|
+
return `action.domain.${k} must be a non-empty string.`;
|
|
18
|
+
}
|
|
19
|
+
}
|
|
20
|
+
if (typeof d.chainId !== 'number' || !Number.isInteger(d.chainId)) {
|
|
21
|
+
return 'action.domain.chainId must be an integer.';
|
|
22
|
+
}
|
|
23
|
+
if (!ADDRESS.test(d.verifyingContract)) {
|
|
24
|
+
return 'action.domain.verifyingContract must be a 20-byte hex address.';
|
|
25
|
+
}
|
|
26
|
+
if (!a.types || typeof a.types !== 'object' || Array.isArray(a.types)) {
|
|
27
|
+
return 'action.types is required.';
|
|
28
|
+
}
|
|
29
|
+
if (typeof a.primaryType !== 'string' || !a.primaryType) {
|
|
30
|
+
return 'action.primaryType is required.';
|
|
31
|
+
}
|
|
32
|
+
if (!(a.primaryType in a.types)) {
|
|
33
|
+
return `action.primaryType '${a.primaryType}' is not one of the structs in action.types.`;
|
|
34
|
+
}
|
|
35
|
+
if (!a.message || typeof a.message !== 'object' || Array.isArray(a.message)) {
|
|
36
|
+
return 'action.message is required.';
|
|
37
|
+
}
|
|
38
|
+
const fields = a.types[a.primaryType];
|
|
39
|
+
if (!Array.isArray(fields) || fields.length === 0) {
|
|
40
|
+
return `action.types.${a.primaryType} declares no fields.`;
|
|
41
|
+
}
|
|
42
|
+
const missing = fields
|
|
43
|
+
.map(f => f?.name)
|
|
44
|
+
.filter(n => typeof n === 'string' && !(n in a.message));
|
|
45
|
+
if (missing.length) {
|
|
46
|
+
return `action.message is missing: ${missing.join(', ')}`;
|
|
47
|
+
}
|
|
48
|
+
return null;
|
|
49
|
+
}
|
|
50
|
+
//# sourceMappingURL=typedAction.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"typedAction.js","sourceRoot":"","sources":["../src/typedAction.ts"],"names":[],"mappings":"AAoBA,MAAM,OAAO,GAAG,qBAAqB,CAAC;AAEtC,6EAA6E;AAC7E,MAAM,UAAU,mBAAmB,CAAC,KAAc;IAChD,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE,CAAC;QAC1C,OAAO,+IAA+I,CAAC;IACzJ,CAAC;IACD,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACtD,OAAO,2BAA2B,CAAC;IACrC,CAAC;IACD,MAAM,CAAC,GAAG,KAA6B,CAAC;IAExC,MAAM,CAAC,GAAG,CAAC,CAAC,MAAM,CAAC;IACnB,IAAI,CAAC,CAAC,IAAI,OAAO,CAAC,KAAK,QAAQ,EAAE,CAAC;QAChC,OAAO,4BAA4B,CAAC;IACtC,CAAC;IACD,KAAK,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,SAAS,EAAE,mBAAmB,CAAU,EAAE,CAAC;QAClE,IAAI,OAAO,CAAC,CAAC,CAAC,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;YACtC,OAAO,iBAA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O,GAAG,MAAM;SACnB,GAAG,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,IAAI,CAAC;SACjB,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,OAAO,CAAC,KAAK,QAAQ,IAAI,CAAC,CAAC,CAAC,IAAK,CAAC,CAAC,OAAkB,CAAC,CAAC,CAAC;IACvE,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;QACnB,OAAO,8BAA8B,OAAO,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC;IAC5D,CAAC;IAED,OAAO,IAAI,CAAC;AACd,CAAC"}
|
package/dist/types.d.ts
CHANGED
|
@@ -1,7 +1,18 @@
|
|
|
1
|
+
import { PROVABLE_CIRCUIT_IDS } from './circuits.js';
|
|
1
2
|
/** Client-friendly circuit aliases. */
|
|
2
|
-
export type CircuitName = 'coinbase_kyc' | 'coinbase_country' | 'oidc_domain'
|
|
3
|
-
/**
|
|
4
|
-
|
|
3
|
+
export type CircuitName = 'coinbase_kyc' | 'coinbase_country' | 'oidc_domain'
|
|
4
|
+
/** Coinbase KYC, with the signature bound to one EIP-712 action. */
|
|
5
|
+
| 'arc_eligibility';
|
|
6
|
+
/**
|
|
7
|
+
* Canonical circuit IDs this server can prove.
|
|
8
|
+
*
|
|
9
|
+
* Derived from `PROVABLE_CIRCUIT_IDS` in `./circuits.js`, which is itself built
|
|
10
|
+
* from the canonical identifiers owned by `@zkproofport-app/sdk/circuits`. The
|
|
11
|
+
* union is unchanged — the three names are no longer typed out here, so a
|
|
12
|
+
* rename in the customer SDK becomes a compile error instead of a silent
|
|
13
|
+
* divergence.
|
|
14
|
+
*/
|
|
15
|
+
export type CircuitId = (typeof PROVABLE_CIRCUIT_IDS)[number];
|
|
5
16
|
/** Map client-friendly names to canonical circuit IDs. */
|
|
6
17
|
export declare const CIRCUIT_NAME_MAP: Record<CircuitName, CircuitId>;
|
|
7
18
|
/** Map canonical circuit IDs back to client-friendly names. */
|
|
@@ -19,9 +30,25 @@ export interface ChallengeResponse {
|
|
|
19
30
|
keyId: string;
|
|
20
31
|
attestationDocument: string | null;
|
|
21
32
|
} | null;
|
|
33
|
+
/**
|
|
34
|
+
* False when the service is running with payment disabled. The nonce is
|
|
35
|
+
* still real and still single-use in that case -- it is replay protection,
|
|
36
|
+
* not a payment receipt -- so the flow is identical apart from the paying.
|
|
37
|
+
*/
|
|
38
|
+
requiresPayment?: boolean;
|
|
39
|
+
/**
|
|
40
|
+
* The chains this service will take payment on, one entry each, in the
|
|
41
|
+
* order it prefers. Read it to choose; pass a chain to `signPayment` to
|
|
42
|
+
* pay on it.
|
|
43
|
+
*/
|
|
44
|
+
accepts?: Array<Record<string, unknown>>;
|
|
22
45
|
}
|
|
23
46
|
export interface ProveInputs {
|
|
24
47
|
signal_hash: string;
|
|
48
|
+
/** EIP-712 domain hash. Present only when `action` was supplied. */
|
|
49
|
+
domain_separator?: string;
|
|
50
|
+
/** EIP-712 hashStruct of the action. Present only when `action` was supplied. */
|
|
51
|
+
action_hash?: string;
|
|
25
52
|
nullifier: string;
|
|
26
53
|
scope_bytes: string;
|
|
27
54
|
merkle_root: string;
|
|
@@ -98,8 +125,68 @@ export interface AttestationData {
|
|
|
98
125
|
attestation: EASAttestation;
|
|
99
126
|
rawTransaction: string;
|
|
100
127
|
}
|
|
128
|
+
/**
|
|
129
|
+
* An EIP-712 typed structure, exactly as `eth_signTypedData_v4` takes it.
|
|
130
|
+
*
|
|
131
|
+
* The caller owns every field here. This SDK keeps no registry of action
|
|
132
|
+
* shapes and never invents one: it hands the structure to the wallet, which
|
|
133
|
+
* renders the named fields for the person to read, and passes the two
|
|
134
|
+
* resulting 32-byte hashes to the circuit.
|
|
135
|
+
*
|
|
136
|
+
* Do NOT include an `EIP712Domain` entry in `types` -- ethers adds it, and
|
|
137
|
+
* passing it yourself produces a different hash than the wallet computes.
|
|
138
|
+
*
|
|
139
|
+
* A single free-form string is a valid shape:
|
|
140
|
+
*
|
|
141
|
+
* types: { Agreement: [{ name: 'terms', type: 'string' }] },
|
|
142
|
+
* primaryType: 'Agreement',
|
|
143
|
+
* message: { terms: 'Deposit 10 USDC into the KYC-gated vault' }
|
|
144
|
+
*
|
|
145
|
+
* A contract cannot enforce prose, though -- to check an amount on-chain the
|
|
146
|
+
* amount has to be its own field.
|
|
147
|
+
*/
|
|
148
|
+
export interface TypedAction {
|
|
149
|
+
domain: {
|
|
150
|
+
name: string;
|
|
151
|
+
version: string;
|
|
152
|
+
chainId: number;
|
|
153
|
+
/** The contract that will verify this signature. Binds it to one address. */
|
|
154
|
+
verifyingContract: string;
|
|
155
|
+
};
|
|
156
|
+
types: Record<string, Array<{
|
|
157
|
+
name: string;
|
|
158
|
+
type: string;
|
|
159
|
+
}>>;
|
|
160
|
+
primaryType: string;
|
|
161
|
+
message: Record<string, unknown>;
|
|
162
|
+
}
|
|
163
|
+
/** Terms explicitly accepted by a user; nonce is intentionally not pinned. */
|
|
164
|
+
export interface ApprovedPayment {
|
|
165
|
+
network: string;
|
|
166
|
+
scheme: string;
|
|
167
|
+
amount: string;
|
|
168
|
+
asset: string;
|
|
169
|
+
payTo: string;
|
|
170
|
+
extra: {
|
|
171
|
+
name: string;
|
|
172
|
+
version: string;
|
|
173
|
+
verifyingContract: string;
|
|
174
|
+
};
|
|
175
|
+
}
|
|
101
176
|
export interface ProofParams {
|
|
102
177
|
circuit: CircuitName;
|
|
178
|
+
/**
|
|
179
|
+
* Which chain to pay on, when the service charges. Either the CAIP-2 id
|
|
180
|
+
* (`eip155:5042002`) or the plain name (`arc-testnet`).
|
|
181
|
+
*
|
|
182
|
+
* Omitting it takes the first chain the service offers. Naming a chain it
|
|
183
|
+
* does not offer is an error listing what it does -- never a quiet fall
|
|
184
|
+
* back to the first, which would spend money somewhere the caller did not
|
|
185
|
+
* choose and report success.
|
|
186
|
+
*/
|
|
187
|
+
payOn?: string;
|
|
188
|
+
approvedPayment?: ApprovedPayment;
|
|
189
|
+
maxPayment?: string;
|
|
103
190
|
/** Scope string for the proof (defaults to "proofport") */
|
|
104
191
|
scope?: string;
|
|
105
192
|
/** Country codes for the country circuit (e.g. ["US", "KR"]) */
|
|
@@ -110,6 +197,22 @@ export interface ProofParams {
|
|
|
110
197
|
jwt?: string;
|
|
111
198
|
/** OIDC provider: 'google' (default) or 'microsoft' for Microsoft 365 */
|
|
112
199
|
provider?: 'google' | 'microsoft';
|
|
200
|
+
/**
|
|
201
|
+
* Bind this proof to one action.
|
|
202
|
+
*
|
|
203
|
+
* WITHOUT it the wallet signs `signal_hash` through personal_sign, exactly
|
|
204
|
+
* as every existing caller does today: the signature asserts "this wallet is
|
|
205
|
+
* KYC'd for this scope" and commits to no contract, amount, caller or
|
|
206
|
+
* deadline, and the wallet can only show the person 32 opaque bytes.
|
|
207
|
+
*
|
|
208
|
+
* WITH it the wallet signs the typed structure instead, so the person reads
|
|
209
|
+
* named fields before approving, and the verifying contract recomputes the
|
|
210
|
+
* same two hashes from the call it is about to run. A proof produced for one
|
|
211
|
+
* contract no longer verifies at another.
|
|
212
|
+
*
|
|
213
|
+
* Omitting it keeps the old behaviour, so existing callers need no change.
|
|
214
|
+
*/
|
|
215
|
+
action?: TypedAction;
|
|
113
216
|
}
|
|
114
217
|
export interface ProofResult {
|
|
115
218
|
circuit: string;
|
|
@@ -127,4 +230,44 @@ export interface StepResult<T = unknown> {
|
|
|
127
230
|
data: T;
|
|
128
231
|
durationMs: number;
|
|
129
232
|
}
|
|
233
|
+
/**
|
|
234
|
+
* A wallet that can pay for a proof: an address and the ability to sign one
|
|
235
|
+
* EIP-712 message. Deliberately nothing more -- see `wallets.ts` for why
|
|
236
|
+
* paying needs no transaction, no gas and no chain of its own.
|
|
237
|
+
*
|
|
238
|
+
* Structurally `ClientEvmSigner` from `@x402/evm`, so a viem account or
|
|
239
|
+
* Coinbase's `fromCdpEvmAccount` result satisfies it as-is.
|
|
240
|
+
*/
|
|
241
|
+
export interface PaymentWallet {
|
|
242
|
+
address: `0x${string}`;
|
|
243
|
+
signTypedData(message: {
|
|
244
|
+
domain: Record<string, unknown>;
|
|
245
|
+
types: Record<string, unknown>;
|
|
246
|
+
primaryType: string;
|
|
247
|
+
message: Record<string, unknown>;
|
|
248
|
+
}): Promise<`0x${string}`>;
|
|
249
|
+
/** A line naming this wallet for a log or a CLI, without its secrets. */
|
|
250
|
+
describe(): string;
|
|
251
|
+
}
|
|
252
|
+
/** One chain a service will take payment on, from its 402 answer. */
|
|
253
|
+
export interface PaymentOffer {
|
|
254
|
+
/** CAIP-2, e.g. `eip155:5042002`. */
|
|
255
|
+
network: string;
|
|
256
|
+
/** The plain name, e.g. `arc-testnet`. */
|
|
257
|
+
networkName: string;
|
|
258
|
+
/** Price in that chain's USDC, in the token's own units. */
|
|
259
|
+
amount: string;
|
|
260
|
+
/** The USDC contract the payment must be in. */
|
|
261
|
+
asset: string;
|
|
262
|
+
payTo: string;
|
|
263
|
+
/** The requirement as the service sent it, passed to the signer untouched. */
|
|
264
|
+
raw: Record<string, unknown>;
|
|
265
|
+
}
|
|
266
|
+
/** A signed payment, ready to be sent back with the proof request. */
|
|
267
|
+
export interface PaidRequest {
|
|
268
|
+
headers: Record<string, string>;
|
|
269
|
+
paidOn: string;
|
|
270
|
+
amount: string;
|
|
271
|
+
payer: string;
|
|
272
|
+
}
|
|
130
273
|
//# sourceMappingURL=types.d.ts.map
|
package/dist/types.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA,uCAAuC;AACvC,MAAM,MAAM,WAAW,
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAEA,OAAO,EAAe,oBAAoB,EAAE,MAAM,eAAe,CAAC;AAElE,uCAAuC;AACvC,MAAM,MAAM,WAAW,GACnB,cAAc,GACd,kBAAkB,GAClB,aAAa;AACf,oEAAoE;GAClE,iBAAiB,CAAC;AAEtB;;;;;;;;GAQG;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AC,OAAO,EAAE;QACrB,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAChC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;QAC/B,WAAW,EAAE,MAAM,CAAC;QACpB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;KAClC,GAAG,OAAO,CAAC,KAAK,MAAM,EAAE,CAAC,CAAC;IAC3B,yEAAyE;IACzE,QAAQ,IAAI,MAAM,CAAC;CACpB;AAED,qEAAqE;AACrE,MAAM,WAAW,YAAY;IAC3B,qCAAqC;IACrC,OAAO,EAAE,MAAM,CAAC;IAChB,0CAA0C;IAC1C,WAAW,EAAE,MAAM,CAAC;IACpB,4DAA4D;IAC5D,MAAM,EAAE,MAAM,CAAC;IACf,gDAAgD;IAChD,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,EAAE,MAAM,CAAC;IACd,8EAA8E;IAC9E,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAC9B;AAED,sEAAsE;AACtE,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAChC,MAAM,EAAE,MAAM,CAAC;IACf,MAAM,EAAE,MAAM,CAAC;IACf,KAAK,EAAE,MAAM,CAAC;CACf"}
|
package/dist/types.js
CHANGED
|
@@ -1,14 +1,17 @@
|
|
|
1
1
|
// ─── Circuit name mappings ──────────────────────────────────────────────
|
|
2
|
+
import { CIRCUIT_IDS } from './circuits.js';
|
|
2
3
|
/** Map client-friendly names to canonical circuit IDs. */
|
|
3
4
|
export const CIRCUIT_NAME_MAP = {
|
|
4
|
-
coinbase_kyc:
|
|
5
|
-
coinbase_country:
|
|
6
|
-
oidc_domain:
|
|
5
|
+
coinbase_kyc: CIRCUIT_IDS.COINBASE_ATTESTATION,
|
|
6
|
+
coinbase_country: CIRCUIT_IDS.COINBASE_COUNTRY_ATTESTATION,
|
|
7
|
+
oidc_domain: CIRCUIT_IDS.OIDC_DOMAIN_ATTESTATION,
|
|
8
|
+
arc_eligibility: CIRCUIT_IDS.ARC_ELIGIBILITY,
|
|
7
9
|
};
|
|
8
10
|
/** Map canonical circuit IDs back to client-friendly names. */
|
|
9
11
|
export const CIRCUIT_ID_MAP = {
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
12
|
+
[CIRCUIT_IDS.COINBASE_ATTESTATION]: 'coinbase_kyc',
|
|
13
|
+
[CIRCUIT_IDS.COINBASE_COUNTRY_ATTESTATION]: 'coinbase_country',
|
|
14
|
+
[CIRCUIT_IDS.OIDC_DOMAIN_ATTESTATION]: 'oidc_domain',
|
|
15
|
+
[CIRCUIT_IDS.ARC_ELIGIBILITY]: 'arc_eligibility',
|
|
13
16
|
};
|
|
14
17
|
//# sourceMappingURL=types.js.map
|
package/dist/types.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,2EAA2E;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,2EAA2E;AAE3E,OAAO,EAAE,WAAW,EAAwB,MAAM,eAAe,CAAC;AAqBlE,0DAA0D;AAC1D,MAAM,CAAC,MAAM,gBAAgB,GAAmC;IAC9D,YAAY,EAAE,WAAW,CAAC,oBAAoB;IAC9C,gBAAgB,EAAE,WAAW,CAAC,4BAA4B;IAC1D,WAAW,EAAE,WAAW,CAAC,uBAAuB;IAChD,eAAe,EAAE,WAAW,CAAC,eAAe;CAC7C,CAAC;AAEF,+DAA+D;AAC/D,MAAM,CAAC,MAAM,cAAc,GAAmC;IAC5D,CAAC,WAAW,CAAC,oBAAoB,CAAC,EAAE,cAAc;IAClD,CAAC,WAAW,CAAC,4BAA4B,CAAC,EAAE,kBAAkB;IAC9D,CAAC,WAAW,CAAC,uBAAuB,CAAC,EAAE,aAAa;IACpD,CAAC,WAAW,CAAC,eAAe,CAAC,EAAE,iBAAiB;CACjD,CAAC"}
|
package/dist/usdc.d.ts
ADDED
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The USDC contracts this SDK is willing to pay in.
|
|
3
|
+
*
|
|
4
|
+
* ## Why the client keeps its own list
|
|
5
|
+
*
|
|
6
|
+
* A 402 answer names the token it wants paid in. Signing whatever it names
|
|
7
|
+
* means a service can ask for any token at all -- including one it minted --
|
|
8
|
+
* and a wallet paying autonomously would sign it. `@x402/core` guards against
|
|
9
|
+
* exactly that: it refuses to sign for an asset outside its own default list
|
|
10
|
+
* unless told otherwise, and refusing is the correct behaviour.
|
|
11
|
+
*
|
|
12
|
+
* Arc's USDC is not in that default list, so paying on Arc needs this list
|
|
13
|
+
* rather than `spendControls: false`. The difference matters: turning the
|
|
14
|
+
* control off allows every token on every chain, which is how an agent ends up
|
|
15
|
+
* signing away something nobody meant to spend. This allows five specific
|
|
16
|
+
* contracts and nothing else.
|
|
17
|
+
*
|
|
18
|
+
* So yes, this duplicates the server's table in `src/payment/networks.ts` --
|
|
19
|
+
* deliberately. A shared table would mean the client trusting the server's
|
|
20
|
+
* word about which token is USDC, which is the thing being guarded against.
|
|
21
|
+
*
|
|
22
|
+
* ## Keeping it right
|
|
23
|
+
*
|
|
24
|
+
* Each address was read from the chain, not from memory:
|
|
25
|
+
* `decimals()` is 6 and `name()`/`symbol()` say USDC on all five. Arc's is the
|
|
26
|
+
* ERC-20 view of its native balance, checked on 2026-09-09 -- name "USDC",
|
|
27
|
+
* version "2", decimals 6, and a `DOMAIN_SEPARATOR()` that matches the hash a
|
|
28
|
+
* client computes from those values.
|
|
29
|
+
*/
|
|
30
|
+
/**
|
|
31
|
+
* The most this SDK will sign for in one payment, unless the caller says
|
|
32
|
+
* otherwise.
|
|
33
|
+
*
|
|
34
|
+
* A proof costs cents. A cap two orders of magnitude above that leaves room
|
|
35
|
+
* for a price change without leaving room for a mistake -- and it is the
|
|
36
|
+
* difference between a misconfigured service overcharging by a cent and
|
|
37
|
+
* draining a wallet.
|
|
38
|
+
*/
|
|
39
|
+
export declare const DEFAULT_MAX_PAYMENT = "$1";
|
|
40
|
+
/**
|
|
41
|
+
* The spend controls to sign under: these five USDC contracts, capped.
|
|
42
|
+
*
|
|
43
|
+
* Passing an asset the offer names that is NOT in the list produces a refusal
|
|
44
|
+
* from `@x402/core` rather than a signature.
|
|
45
|
+
*/
|
|
46
|
+
export declare function usdcSpendControls(maxPayment?: string): {
|
|
47
|
+
maxAmountPerPayment: string;
|
|
48
|
+
allowedAssets: {
|
|
49
|
+
network: string;
|
|
50
|
+
asset: string;
|
|
51
|
+
}[];
|
|
52
|
+
};
|
|
53
|
+
/**
|
|
54
|
+
* Whether an offer names the USDC this SDK knows for that chain.
|
|
55
|
+
*
|
|
56
|
+
* Checked before signing so the error says which token was asked for, rather
|
|
57
|
+
* than letting `@x402/core` refuse with a message about allowedAssets that
|
|
58
|
+
* does not name the culprit.
|
|
59
|
+
*/
|
|
60
|
+
export declare function isKnownUsdc(network: string, asset: string): boolean;
|
|
61
|
+
/** The USDC this SDK knows for a chain, or undefined. */
|
|
62
|
+
export declare function knownUsdc(network: string): string | undefined;
|
|
63
|
+
//# sourceMappingURL=usdc.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"usdc.d.ts","sourceRoot":"","sources":["../src/usdc.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA4BG;AAWH;;;;;;;;GAQG;AACH,eAAO,MAAM,mBAAmB,OAAO,CAAC;AAExC;;;;;GAKG;AACH,wBAAgB,iBAAiB,CAAC,UAAU,CAAC,EAAE,MAAM;;;;;;EAQpD;AAED;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAGnE;AAED,yDAAyD;AACzD,wBAAgB,SAAS,CAAC,OAAO,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS,CAE7D"}
|