@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/flow.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { ethers } from 'ethers';
|
|
2
2
|
import { CIRCUIT_NAME_MAP } from './types.js';
|
|
3
3
|
import { requestChallenge } from './session.js';
|
|
4
|
+
import { signPayment } from './payment.js';
|
|
4
5
|
import { prepareInputs, computeSignalHash } from './inputs.js';
|
|
5
6
|
import { prepareOidcPayload } from './oidc-inputs.js';
|
|
6
7
|
import { submitProof, submitEncryptedProof } from './prove.js';
|
|
7
8
|
import { CIRCUITS } from './constants.js';
|
|
9
|
+
import { CIRCUIT_IDS } from './circuits.js';
|
|
8
10
|
import { encryptForTee } from './tee.js';
|
|
9
11
|
/**
|
|
10
12
|
* Generate a ZK proof end-to-end.
|
|
@@ -34,16 +36,69 @@ export async function generateProof(config, signers, params, callbacks) {
|
|
|
34
36
|
// Steps 1-2: EAS attestation path (skipped for OIDC circuits)
|
|
35
37
|
let easInputs;
|
|
36
38
|
let oidcPayload;
|
|
39
|
+
let domainSeparator;
|
|
40
|
+
let actionHash;
|
|
37
41
|
if (!isOidc) {
|
|
38
|
-
//
|
|
42
|
+
// The circuit decides the signature, and a mismatch is refused here.
|
|
43
|
+
//
|
|
44
|
+
// This used to be "typed data if an action was passed, personal_sign
|
|
45
|
+
// otherwise", with the circuit id carried along beside it. That reads as
|
|
46
|
+
// two paths and is really four, two of which are silently wrong:
|
|
47
|
+
// `arc_eligibility` with no action signed `signal_hash` and produced a
|
|
48
|
+
// proof whose domain and action hashes are absent, and a Coinbase circuit
|
|
49
|
+
// with an action signed typed data the circuit cannot verify. The mobile
|
|
50
|
+
// app had the same defect in its KYC hook and it produced proofs from the
|
|
51
|
+
// wrong circuit for a day.
|
|
52
|
+
if (circuitId === CIRCUIT_IDS.ARC_ELIGIBILITY && !params.action) {
|
|
53
|
+
throw new Error(`${CIRCUIT_IDS.ARC_ELIGIBILITY} proves that a wallet authorised ONE EIP-712 action, and no action was given. ` +
|
|
54
|
+
`Its domain separator and action hash are public inputs, so there is nothing to prove without one. ` +
|
|
55
|
+
`Pass \`action\`, or ask for ${CIRCUIT_IDS.COINBASE_ATTESTATION}.`);
|
|
56
|
+
}
|
|
57
|
+
if (params.action && circuitId !== CIRCUIT_IDS.ARC_ELIGIBILITY) {
|
|
58
|
+
throw new Error(`An action was given but '${circuitId}' was requested, and only ${CIRCUIT_IDS.ARC_ELIGIBILITY} carries one. ` +
|
|
59
|
+
`Signing typed data for '${circuitId}' yields a signature that circuit cannot verify. ` +
|
|
60
|
+
`Ask for ${CIRCUIT_IDS.ARC_ELIGIBILITY}, or drop the action.`);
|
|
61
|
+
}
|
|
62
|
+
// Step 1: Sign.
|
|
63
|
+
//
|
|
64
|
+
// `signal_hash` is computed either way, because the nullifier derives from
|
|
65
|
+
// it and must stay one value per wallet per scope no matter how many
|
|
66
|
+
// actions that wallet authorizes.
|
|
67
|
+
//
|
|
68
|
+
// Without an action the wallet signs `signal_hash` through personal_sign,
|
|
69
|
+
// which shows the person a hex string. With one it signs the typed
|
|
70
|
+
// structure, which the wallet renders as named fields, and the verifying
|
|
71
|
+
// contract can recompute.
|
|
39
72
|
let t = Date.now();
|
|
40
73
|
const attestationAddress = await signers.attestation.getAddress();
|
|
41
74
|
const signalHash = computeSignalHash(attestationAddress, scope, circuitId);
|
|
42
75
|
const signalHashHex = ethers.hexlify(signalHash);
|
|
43
|
-
|
|
44
|
-
|
|
76
|
+
let signature;
|
|
77
|
+
if (params.action) {
|
|
78
|
+
const { domain, types, message } = params.action;
|
|
79
|
+
signature = await signers.attestation.signTypedData(domain, types, message);
|
|
80
|
+
domainSeparator = ethers.TypedDataEncoder.hashDomain(domain);
|
|
81
|
+
actionHash = ethers.TypedDataEncoder.hashStruct(params.action.primaryType, types, message);
|
|
82
|
+
recordStep(1, 'Sign Typed Action', {
|
|
83
|
+
signalHash: signalHashHex,
|
|
84
|
+
domainSeparator,
|
|
85
|
+
actionHash,
|
|
86
|
+
primaryType: params.action.primaryType,
|
|
87
|
+
verifyingContract: domain.verifyingContract,
|
|
88
|
+
signature,
|
|
89
|
+
}, t);
|
|
90
|
+
}
|
|
91
|
+
else {
|
|
92
|
+
signature = await signers.attestation.signMessage(signalHash);
|
|
93
|
+
recordStep(1, 'Sign Signal Hash', { signalHash: signalHashHex, signature }, t);
|
|
94
|
+
}
|
|
45
95
|
// Step 2: Prepare inputs
|
|
46
96
|
t = Date.now();
|
|
97
|
+
// The action hashes go IN, not on afterwards: the public key is recovered
|
|
98
|
+
// inside, and for an action-bound circuit it must be recovered from the
|
|
99
|
+
// EIP-712 digest. Attaching them to the result left the key recovered from
|
|
100
|
+
// `signal_hash`, and the circuit refused the proof with "User pubkey does
|
|
101
|
+
// not match address" — which reads as a wrong wallet, not a wrong message.
|
|
47
102
|
easInputs = await prepareInputs(config, {
|
|
48
103
|
circuitId,
|
|
49
104
|
userAddress: attestationAddress,
|
|
@@ -51,7 +106,12 @@ export async function generateProof(config, signers, params, callbacks) {
|
|
|
51
106
|
scope,
|
|
52
107
|
countryList: params.countryList,
|
|
53
108
|
isIncluded: params.isIncluded,
|
|
109
|
+
domainSeparator,
|
|
110
|
+
actionHash,
|
|
54
111
|
});
|
|
112
|
+
if (domainSeparator && actionHash) {
|
|
113
|
+
easInputs = { ...easInputs, domain_separator: domainSeparator, action_hash: actionHash };
|
|
114
|
+
}
|
|
55
115
|
recordStep(2, 'Prepare Inputs', { inputFields: Object.keys(easInputs).length }, t);
|
|
56
116
|
}
|
|
57
117
|
else {
|
|
@@ -70,6 +130,28 @@ export async function generateProof(config, signers, params, callbacks) {
|
|
|
70
130
|
const challenge = await requestChallenge(config, params.circuit);
|
|
71
131
|
const isE2E = !!challenge.teePublicKey;
|
|
72
132
|
recordStep(3, 'Request Challenge', { nonce: challenge.nonce, e2e: isE2E, keyId: challenge.teePublicKey?.keyId ?? null }, t);
|
|
133
|
+
// Step 3b: Pay, if the service charges.
|
|
134
|
+
//
|
|
135
|
+
// The buyer signs an EIP-3009 authorization and the service settles it, so
|
|
136
|
+
// no gas and no native balance are needed on the paying chain -- which is
|
|
137
|
+
// what makes paying on Arc possible at all, since no public facilitator
|
|
138
|
+
// settles Arc and the buyer cannot rely on one.
|
|
139
|
+
let paymentHeaders;
|
|
140
|
+
if (challenge.requiresPayment) {
|
|
141
|
+
if (!signers.payment) {
|
|
142
|
+
const offered = (challenge.accepts ?? [])
|
|
143
|
+
.map((a) => a.networkName ?? a.network)
|
|
144
|
+
.filter(Boolean)
|
|
145
|
+
.join(', ');
|
|
146
|
+
throw new Error(`${config.baseUrl} charges for proofs and no payment wallet was given. ` +
|
|
147
|
+
`Pass signers.payment (see walletFromPrivateKey / walletFromCdp / walletFromCircle). ` +
|
|
148
|
+
`Chains offered: ${offered || 'none named'}`);
|
|
149
|
+
}
|
|
150
|
+
t = Date.now();
|
|
151
|
+
const paid = await signPayment(challenge, signers.payment, { network: params.payOn, maxPayment: params.maxPayment, approvedPayment: params.approvedPayment });
|
|
152
|
+
paymentHeaders = paid.headers;
|
|
153
|
+
recordStep(3.5, 'Sign Payment', { paidOn: paid.paidOn, amount: paid.amount, payer: paid.payer }, t);
|
|
154
|
+
}
|
|
73
155
|
// Step 4: Submit proof (encrypted or plaintext based on TEE availability)
|
|
74
156
|
t = Date.now();
|
|
75
157
|
let proveResponse;
|
|
@@ -81,6 +163,7 @@ export async function generateProof(config, signers, params, callbacks) {
|
|
|
81
163
|
circuit: params.circuit,
|
|
82
164
|
encryptedPayload,
|
|
83
165
|
nonce: challenge.nonce,
|
|
166
|
+
paymentHeaders,
|
|
84
167
|
});
|
|
85
168
|
recordStep(4, 'Generate Proof (E2E Encrypted)', proveResponse, t);
|
|
86
169
|
}
|
|
@@ -90,6 +173,7 @@ export async function generateProof(config, signers, params, callbacks) {
|
|
|
90
173
|
circuit: params.circuit,
|
|
91
174
|
inputs: oidcPayload,
|
|
92
175
|
nonce: challenge.nonce,
|
|
176
|
+
paymentHeaders,
|
|
93
177
|
});
|
|
94
178
|
recordStep(4, 'Generate Proof (OIDC)', proveResponse, t);
|
|
95
179
|
}
|
|
@@ -99,6 +183,7 @@ export async function generateProof(config, signers, params, callbacks) {
|
|
|
99
183
|
circuit: params.circuit,
|
|
100
184
|
inputs: easInputs,
|
|
101
185
|
nonce: challenge.nonce,
|
|
186
|
+
paymentHeaders,
|
|
102
187
|
});
|
|
103
188
|
recordStep(4, 'Generate Proof', proveResponse, t);
|
|
104
189
|
}
|
package/dist/flow.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"flow.js","sourceRoot":"","sources":["../src/flow.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAQhC,OAAO,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAC9C,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,aAAa,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAE,kBAAkB,EAAE,MAAM,kBAAkB,CAAC;AAEtD,OAAO,EAAE,WAAW,EAAE,oBAAoB,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"flow.js","sourceRoot":"","sources":["../src/fl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EAAE,aAAa,CAAC,OAAO;QAC9B,SAAS,EAAE,aAAa,CAAC,SAAS;QAClC,KAAK,EAAE,aAAa,CAAC,KAAK;QAC1B,YAAY,EAAE,aAAa,CAAC,YAAY;QACxC,eAAe,EAAE,aAAa,CAAC,eAAe;QAC9C,WAAW,EAAE,aAAa,CAAC,WAAW;QACtC,MAAM,EAAE,aAAa,CAAC,MAAM;QAC5B,YAAY,EAAE,aAAa,CAAC,YAAY;KACzC,CAAC;AACJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
export type { ClientConfig, CircuitName, CircuitId, ChallengeResponse, ProveInputs, ProveRequest, ProveResponse, VerifyResult, EASAttestation, AttestationData, ProofParams, ProofResult, StepResult, } from './types.js';
|
|
1
|
+
export type { ClientConfig, CircuitName, CircuitId, ChallengeResponse, ProveInputs, ProveRequest, ProveResponse, VerifyResult, EASAttestation, AttestationData, ProofParams, ApprovedPayment, ProofResult, StepResult, } from './types.js';
|
|
2
2
|
export { CIRCUIT_NAME_MAP, CIRCUIT_ID_MAP } from './types.js';
|
|
3
|
+
export { CIRCUIT_IDS, CIRCUIT_SUPPORT_STATUS, ALL_CIRCUIT_IDS, SUPPORTED_CIRCUIT_IDS, PLANNED_CIRCUIT_IDS, PROVABLE_CIRCUIT_IDS, isCanonicalCircuitId, isProvableCircuitId, getCircuitSupportStatus, } from './circuits.js';
|
|
4
|
+
export type { CanonicalCircuitId, CircuitSupportStatus } from './circuits.js';
|
|
3
5
|
export { CIRCUITS, COINBASE_ATTESTER_CONTRACT, AUTHORIZED_SIGNERS, } from './constants.js';
|
|
4
6
|
export { createConfig } from './config.js';
|
|
5
7
|
export { generateProof } from './flow.js';
|
|
@@ -11,7 +13,16 @@ export { prepareInputs, computeSignalHash, computeScope, computeNullifier, } fro
|
|
|
11
13
|
export { prepareOidcInputs, prepareOidcPayload } from './oidc-inputs.js';
|
|
12
14
|
export type { OidcCircuitInputs, OidcProvePayload, PrepareOidcParams } from './oidc-inputs.js';
|
|
13
15
|
export type { ProofportSigner } from './signer.js';
|
|
16
|
+
export { walletFromPrivateKey, walletFromCdp, walletFromCircle, walletFromEnv, walletFor } from './wallets.js';
|
|
17
|
+
export { signPayment, paymentOffers } from './payment.js';
|
|
18
|
+
export type { PaymentWallet, PaymentOffer, PaidRequest } from './types.js';
|
|
19
|
+
export { CdpWalletSigner } from './cdp.js';
|
|
20
|
+
export type { ExternalWallet } from './cdp.js';
|
|
14
21
|
export { EthersWalletSigner, fromEthersWallet, fromPrivateKey } from './signer.js';
|
|
15
22
|
export { extractDomainFromPublicInputs, extractScopeFromPublicInputs, extractNullifierFromPublicInputs, } from './extract.js';
|
|
16
23
|
export { fetchAttestation, getSignerAddress, } from './attestation.js';
|
|
24
|
+
export { validateTypedAction } from './typedAction.js';
|
|
25
|
+
export { ARC_GATEWAY_CHAIN, gatewayBalance, ensureGatewayBalance, payWithNanopayments, type NanopaymentWallet, type GatewayBalances, } from './nanopayment.js';
|
|
26
|
+
export { buildDelegationAction, delegationActionHash, delegationDomainSeparator, delegationMatchesProof, delegateOf, DELEGATION_PRIMARY_TYPE, DELEGATION_TYPES, type Delegation, } from './delegation.js';
|
|
27
|
+
export { walletFromArcAgent, listArcAgentWallets, createArcAgentWallet, ARC_CLI_CHAINS, type ArcCliChain, } from './arcWallet.js';
|
|
17
28
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AACA,YAAY,EACV,YAAY,EACZ,WAAW,EACX,SAAS,EACT,iBAAiB,EACjB,WAAW,EACX,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,cAAc,EACd,eAAe,EACf,WAAW,EACX,WAAW,EACX,UAAU,GACX,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,YAAY,CA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MAAM,aAAa,CAAC;AAInD,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,gBAAgB,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,cAAc,CAAC;AAC/G,OAAO,EAAE,WAAW,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC;AAC1D,YAAY,EAAE,aAAa,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,YAAY,CAAC;AAC3E,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAC3C,YAAY,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,EAAE,kBAAkB,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAGnF,OAAO,EACL,6BAA6B,EAC7B,4BAA4B,EAC5B,gCAAgC,GACjC,MAAM,cAAc,CAAC;AAGtB,OAAO,EACL,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,kBAAkB,CAAC;AAK1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAKvD,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,oBAAoB,EACpB,mBAAmB,EACnB,KAAK,iBAAiB,EACtB,KAAK,eAAe,GACrB,MAAM,kBAAkB,CAAC;AAI1B,OAAO,EACL,qBAAqB,EACrB,oBAAoB,EACpB,yBAAyB,EACzB,sBAAsB,EACtB,UAAU,EACV,uBAAuB,EACvB,gBAAgB,EAChB,KAAK,UAAU,GAChB,MAAM,iBAAiB,CAAC;AAGzB,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,cAAc,EACd,KAAK,WAAW,GACjB,MAAM,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -1,4 +1,7 @@
|
|
|
1
1
|
export { CIRCUIT_NAME_MAP, CIRCUIT_ID_MAP } from './types.js';
|
|
2
|
+
// Canonical circuit identifiers.
|
|
3
|
+
// Mirrors @zkproofport-app/sdk/circuits — see ./circuits.ts for why a mirror.
|
|
4
|
+
export { CIRCUIT_IDS, CIRCUIT_SUPPORT_STATUS, ALL_CIRCUIT_IDS, SUPPORTED_CIRCUIT_IDS, PLANNED_CIRCUIT_IDS, PROVABLE_CIRCUIT_IDS, isCanonicalCircuitId, isProvableCircuitId, getCircuitSupportStatus, } from './circuits.js';
|
|
2
5
|
// Constants
|
|
3
6
|
export { CIRCUITS, COINBASE_ATTESTER_CONTRACT, AUTHORIZED_SIGNERS, } from './constants.js';
|
|
4
7
|
// Configuration
|
|
@@ -13,9 +16,27 @@ export { verifyProof } from './verify.js';
|
|
|
13
16
|
export { prepareInputs, computeSignalHash, computeScope, computeNullifier, } from './inputs.js';
|
|
14
17
|
// OIDC: SDK fetches JWKS, TEE validates JWT + builds circuit inputs
|
|
15
18
|
export { prepareOidcInputs, prepareOidcPayload } from './oidc-inputs.js';
|
|
19
|
+
// Paying for a proof. The wallet and the chain are chosen separately: any of
|
|
20
|
+
// the three wallets can pay on any chain the service offers.
|
|
21
|
+
export { walletFromPrivateKey, walletFromCdp, walletFromCircle, walletFromEnv, walletFor } from './wallets.js';
|
|
22
|
+
export { signPayment, paymentOffers } from './payment.js';
|
|
23
|
+
export { CdpWalletSigner } from './cdp.js';
|
|
16
24
|
export { EthersWalletSigner, fromEthersWallet, fromPrivateKey } from './signer.js';
|
|
17
25
|
// Extraction helpers (parse publicInputs from proof results)
|
|
18
26
|
export { extractDomainFromPublicInputs, extractScopeFromPublicInputs, extractNullifierFromPublicInputs, } from './extract.js';
|
|
19
27
|
// Attestation (customer-facing helpers)
|
|
20
28
|
export { fetchAttestation, getSignerAddress, } from './attestation.js';
|
|
29
|
+
// Checking the EIP-712 action an arc_eligibility proof binds to. Mirrored from
|
|
30
|
+
// the customer SDK; see the note in typedAction.ts for why, and
|
|
31
|
+
// tests/typedAction.test.ts for the guard that keeps them equal.
|
|
32
|
+
export { validateTypedAction } from './typedAction.js';
|
|
33
|
+
// Arc nanopayments: deposit into Circle Gateway once, then pay per request for
|
|
34
|
+
// almost no gas. See ./nanopayment.ts for why this is separate from the
|
|
35
|
+
// ordinary x402 path.
|
|
36
|
+
export { ARC_GATEWAY_CHAIN, gatewayBalance, ensureGatewayBalance, payWithNanopayments, } from './nanopayment.js';
|
|
37
|
+
// Delegating a credential from the KYC wallet to a second wallet, so the
|
|
38
|
+
// second one can act while the first stays hidden. See ./delegation.ts.
|
|
39
|
+
export { buildDelegationAction, delegationActionHash, delegationDomainSeparator, delegationMatchesProof, delegateOf, DELEGATION_PRIMARY_TYPE, DELEGATION_TYPES, } from './delegation.js';
|
|
40
|
+
// Paying from an Arc agent wallet — Circle holds it and its CLI signs.
|
|
41
|
+
export { walletFromArcAgent, listArcAgentWallets, createArcAgentWallet, ARC_CLI_CHAINS, } from './arcWallet.js';
|
|
21
42
|
//# 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":"
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAkBA,OAAO,EAAE,gBAAgB,EAAE,cAAc,EAAE,MAAM,YAAY,CAAC;AAE9D,iCAAiC;AACjC,8EAA8E;AAC9E,OAAO,EACL,WAAW,EACX,sBAAsB,EACtB,eAAe,EACf,qBAAqB,EACrB,mBAAmB,EACnB,oBAAoB,EACpB,oBAAoB,EACpB,mBAAmB,EACnB,uBAAuB,GACxB,MAAM,eAAe,CAAC;AAGvB,YAAY;AACZ,OAAO,EACL,QAAQ,EACR,0BAA0B,EAC1B,kBAAkB,GACnB,MAAM,gBAAgB,CAAC;AAExB,gBAAgB;AAChB,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,0BAA0B;AAC1B,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAG1C,4CAA4C;AAC5C,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC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EACL,kBAAkB,EAClB,mBAAmB,EACnB,oBAAoB,EACpB,cAAc,GAEf,MAAM,gBAAgB,CAAC"}
|
package/dist/inputs.d.ts
CHANGED
|
@@ -52,5 +52,17 @@ export declare function prepareInputs(config: ClientConfig, params: {
|
|
|
52
52
|
scope: string;
|
|
53
53
|
countryList?: string[];
|
|
54
54
|
isIncluded?: boolean;
|
|
55
|
+
/**
|
|
56
|
+
* The EIP-712 hashes the wallet signed over, for `arc_eligibility`.
|
|
57
|
+
*
|
|
58
|
+
* Required there, because that circuit's wallet signs a typed action rather
|
|
59
|
+
* than `signal_hash` — recovering against `signal_hash` yields a public key
|
|
60
|
+
* that is not the user's, and the circuit then fails on "User pubkey does not
|
|
61
|
+
* match address", which points at the address rather than at the message.
|
|
62
|
+
* Added after exactly that failure on 2026-09-12: the caller was attaching
|
|
63
|
+
* these two AFTER this function had already recovered the key.
|
|
64
|
+
*/
|
|
65
|
+
domainSeparator?: string;
|
|
66
|
+
actionHash?: string;
|
|
55
67
|
}): Promise<ProveInputs>;
|
|
56
68
|
//# sourceMappingURL=inputs.d.ts.map
|
package/dist/inputs.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inputs.d.ts","sourceRoot":"","sources":["../src/inputs.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;
|
|
1
|
+
{"version":3,"file":"inputs.d.ts","sourceRoot":"","sources":["../src/inputs.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AASvE;;GAEG;AACH,wBAAgB,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,EAAE,CAOhD;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,MAAM,EAAE,MAAM,GAAG;IAAE,CAAC,EAAE,MAAM,CAAC;IAAC,CAAC,EAAE,MAAM,CAAA;CAAE,CAKjF;AAID;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,EACnB,WAAW,EAAE,MAAM,GAClB,UAAU,CAMZ;AAED;;;GAGG;AACH,wBAAgB,iBAAiB,CAC/B,UAAU,EAAE,UAAU,EACtB,aAAa,EAAE,MAAM,GACpB,MAAM,CAKR;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,WAAW,EAAE,MAAM,GAAG,UAAU,CAE5D;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAC9B,WAAW,EAAE,MAAM,EACnB,UAAU,EAAE,UAAU,EACtB,UAAU,EAAE,UAAU,GACrB,UAAU,CAQZ;AA4ED;;;;;;;;;;;;;GAaG;AACH,wBAAsB,aAAa,CAAC,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE;IAChE,SAAS,EAAE,SAAS,CAAC;IACrB,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB;;;;;;;;;OASG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB,GAAG,OAAO,CAAC,WAAW,CAAC,CAwFvB"}
|
package/dist/inputs.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ethers } from 'ethers';
|
|
2
|
+
import { CIRCUIT_IDS } from './circuits.js';
|
|
2
3
|
import { CIRCUITS, MERKLE_PROOF_MAX_DEPTH, COUNTRY_LIST_MAX_LENGTH } from './constants.js';
|
|
3
4
|
import { fetchAttestation, recoverAttesterPubkey, getSignerAddress } from './attestation.js';
|
|
4
5
|
import { findSignerIndex, buildSignerMerkleTree } from './merkle.js';
|
|
@@ -158,8 +159,18 @@ export async function prepareInputs(config, params) {
|
|
|
158
159
|
}
|
|
159
160
|
// Step 1: Compute signal hash
|
|
160
161
|
const signalHash = computeSignalHash(userAddress, scope, circuitId);
|
|
161
|
-
// Step 2: Recover user public key
|
|
162
|
-
const
|
|
162
|
+
// Step 2: Recover the user's public key from the digest they actually signed.
|
|
163
|
+
const isAction = circuitId === CIRCUIT_IDS.ARC_ELIGIBILITY;
|
|
164
|
+
if (isAction && !(params.domainSeparator && params.actionHash)) {
|
|
165
|
+
throw new Error(`${CIRCUIT_IDS.ARC_ELIGIBILITY} signs an EIP-712 action, so domainSeparator and actionHash are required here. ` +
|
|
166
|
+
'Without them the public key is recovered from signal_hash and belongs to nobody.');
|
|
167
|
+
}
|
|
168
|
+
if (!isAction && (params.domainSeparator || params.actionHash)) {
|
|
169
|
+
throw new Error(`An EIP-712 action was given but '${circuitId}' does not carry one. Only ${CIRCUIT_IDS.ARC_ELIGIBILITY} does.`);
|
|
170
|
+
}
|
|
171
|
+
const userPubkey = isAction
|
|
172
|
+
? ethers.SigningKey.recoverPublicKey(ethers.keccak256(ethers.concat(['0x1901', params.domainSeparator, params.actionHash])), userSignature)
|
|
173
|
+
: recoverUserPubkey(signalHash, userSignature);
|
|
163
174
|
const { x: userPubkeyX, y: userPubkeyY } = extractPubkeyCoordinates(userPubkey);
|
|
164
175
|
// Step 3: Fetch attestation transaction from Base chain
|
|
165
176
|
const attestationData = await fetchAttestation(config, circuitId, userAddress);
|
package/dist/inputs.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"inputs.js","sourceRoot":"","sources":["../src/inputs.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAGhC,OAAO,EAAE,QAAQ,EAAwB,sBAAsB,EAAE,uBAAuB,EAAE,MAAM,gBAAgB,CAAC;AACjH,OAAO,EAAE,gBAAgB,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAC7F,OAAO,EA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EAAE,eAAe,CAAC,cAAc;QAC/C,SAAS,EAAE,QAAQ;QACnB,0BAA0B,EAAE,eAAe;QAC3C,0BAA0B,EAAE,eAAe;QAC3C,YAAY,EAAE,UAAU,CAAC,KAAK;QAC9B,UAAU,EAAE,UAAU,CAAC,SAAS;QAChC,KAAK,EAAE,UAAU,CAAC,KAAK;KACxB,CAAC;IAEF,8BAA8B;IAC9B,IAAI,SAAS,KAAK,8BAA8B,EAAE,CAAC;QACjD,MAAM,CAAC,YAAY,GAAG,MAAM,CAAC,WAAW,CAAC;QACzC,MAAM,CAAC,WAAW,GAAG,MAAM,CAAC,UAAU,CAAC;IACzC,CAAC;IAED,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Paying with Arc nanopayments: deposit once, then pay many times for free.
|
|
3
|
+
*
|
|
4
|
+
* ## What is different from the ordinary path
|
|
5
|
+
*
|
|
6
|
+
* An ordinary x402 payment puts one authorization on chain per purchase, and
|
|
7
|
+
* on Arc that costs gas in USDC — measured 2026-09-12 at 0.0035 USDC to settle
|
|
8
|
+
* a payment of 0.001, which is four times the price of the thing being bought.
|
|
9
|
+
* That is fine for a one-off and absurd for an agent buying thousands of
|
|
10
|
+
* proofs.
|
|
11
|
+
*
|
|
12
|
+
* Circle Gateway takes the same EIP-3009 authorization, verifies it off chain
|
|
13
|
+
* in under a second, and settles thousands of them in one transaction. The
|
|
14
|
+
* buyer's money moves into Gateway once, by depositing; after that each
|
|
15
|
+
* payment is a signature and nothing more.
|
|
16
|
+
*
|
|
17
|
+
* ## What the buyer has to do
|
|
18
|
+
*
|
|
19
|
+
* Deposit first. A signature drawn against a Gateway balance that is not there
|
|
20
|
+
* is refused, and the refusal names the balance rather than the signature, so
|
|
21
|
+
* `ensureGatewayBalance` checks before paying rather than after failing.
|
|
22
|
+
*/
|
|
23
|
+
/** Arc Testnet, as `@circle-fin/x402-batching` names it. */
|
|
24
|
+
export declare const ARC_GATEWAY_CHAIN: "arcTestnet";
|
|
25
|
+
export interface NanopaymentWallet {
|
|
26
|
+
/** The buyer's key. Gateway signs authorizations with it and never sends a transaction per payment. */
|
|
27
|
+
privateKey: `0x${string}`;
|
|
28
|
+
/** Arc's RPC. Required — the package's default is for Arc mainnet. */
|
|
29
|
+
rpcUrl: string;
|
|
30
|
+
}
|
|
31
|
+
/** What a buyer holds inside Gateway, in USDC's smallest units. */
|
|
32
|
+
export interface GatewayBalances {
|
|
33
|
+
/** Spendable right now. */
|
|
34
|
+
available: bigint;
|
|
35
|
+
/** On the way out, not spendable. */
|
|
36
|
+
withdrawing: bigint;
|
|
37
|
+
}
|
|
38
|
+
/** What the buyer currently has inside Gateway. */
|
|
39
|
+
export declare function gatewayBalance(wallet: NanopaymentWallet): Promise<GatewayBalances>;
|
|
40
|
+
/**
|
|
41
|
+
* Make sure the buyer can pay `atLeast`, depositing `topUp` if not.
|
|
42
|
+
*
|
|
43
|
+
* Deposits are the one on-chain step in this flow and they cost gas, so this
|
|
44
|
+
* is deliberately not called before every payment — an agent deposits once and
|
|
45
|
+
* spends against it.
|
|
46
|
+
*/
|
|
47
|
+
export declare function ensureGatewayBalance(wallet: NanopaymentWallet,
|
|
48
|
+
/** In USDC's smallest units. Undefined requests an unconditional deposit. */
|
|
49
|
+
atLeast: bigint | undefined,
|
|
50
|
+
/** In whole USDC, like everything the deposit call takes. */
|
|
51
|
+
topUp: string): Promise<{
|
|
52
|
+
deposited: boolean;
|
|
53
|
+
balance: GatewayBalances;
|
|
54
|
+
depositTxHash?: string;
|
|
55
|
+
}>;
|
|
56
|
+
/**
|
|
57
|
+
* Buy something priced in x402, paying through Gateway.
|
|
58
|
+
*
|
|
59
|
+
* The 402 answer must carry a batched offer; a service that offers only the
|
|
60
|
+
* ordinary on-chain options is not reachable this way, and saying so is better
|
|
61
|
+
* than silently paying the expensive way.
|
|
62
|
+
*/
|
|
63
|
+
export declare function payWithNanopayments<T = unknown>(wallet: NanopaymentWallet, url: string, options?: {
|
|
64
|
+
method?: string;
|
|
65
|
+
body?: unknown;
|
|
66
|
+
headers?: Record<string, string>;
|
|
67
|
+
}): Promise<{
|
|
68
|
+
data: T;
|
|
69
|
+
amount: string;
|
|
70
|
+
}>;
|
|
71
|
+
//# sourceMappingURL=nanopayment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nanopayment.d.ts","sourceRoot":"","sources":["../src/nanopayment.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAIH,4DAA4D;AAC5D,eAAO,MAAM,iBAAiB,EAAG,YAAqB,CAAC;AAEvD,MAAM,WAAW,iBAAiB;IAChC,uGAAuG;IACvG,UAAU,EAAE,KAAK,MAAM,EAAE,CAAC;IAC1B,sEAAsE;IACtE,MAAM,EAAE,MAAM,CAAC;CAChB;AAED,mEAAmE;AACnE,MAAM,WAAW,eAAe;IAC9B,2BAA2B;IAC3B,SAAS,EAAE,MAAM,CAAC;IAClB,qCAAqC;IACrC,WAAW,EAAE,MAAM,CAAC;CACrB;AAUD,mDAAmD;AACnD,wBAAsB,cAAc,CAAC,MAAM,EAAE,iBAAiB,GAAG,OAAO,CAAC,eAAe,CAAC,CAGxF;AAED;;;;;;GAMG;AACH,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,iBAAiB;AACzB,6EAA6E;AAC7E,OAAO,EAAE,MAAM,GAAG,SAAS;AAC3B,6DAA6D;AAC7D,KAAK,EAAE,MAAM,GACZ,OAAO,CAAC;IAAE,SAAS,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,eAAe,CAAC;IAAC,aAAa,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,CAUnF;AAED;;;;;;GAMG;AACH,wBAAsB,mBAAmB,CAAC,CAAC,GAAG,OAAO,EACnD,MAAM,EAAE,iBAAiB,EACzB,GAAG,EAAE,MAAM,EACX,OAAO,CAAC,EAAE;IAAE,MAAM,CAAC,EAAE,MAAM,CAAC;IAAC,IAAI,CAAC,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;CAAE,GAC9E,OAAO,CAAC;IAAE,IAAI,EAAE,CAAC,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAAC,CAWtC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Paying with Arc nanopayments: deposit once, then pay many times for free.
|
|
3
|
+
*
|
|
4
|
+
* ## What is different from the ordinary path
|
|
5
|
+
*
|
|
6
|
+
* An ordinary x402 payment puts one authorization on chain per purchase, and
|
|
7
|
+
* on Arc that costs gas in USDC — measured 2026-09-12 at 0.0035 USDC to settle
|
|
8
|
+
* a payment of 0.001, which is four times the price of the thing being bought.
|
|
9
|
+
* That is fine for a one-off and absurd for an agent buying thousands of
|
|
10
|
+
* proofs.
|
|
11
|
+
*
|
|
12
|
+
* Circle Gateway takes the same EIP-3009 authorization, verifies it off chain
|
|
13
|
+
* in under a second, and settles thousands of them in one transaction. The
|
|
14
|
+
* buyer's money moves into Gateway once, by depositing; after that each
|
|
15
|
+
* payment is a signature and nothing more.
|
|
16
|
+
*
|
|
17
|
+
* ## What the buyer has to do
|
|
18
|
+
*
|
|
19
|
+
* Deposit first. A signature drawn against a Gateway balance that is not there
|
|
20
|
+
* is refused, and the refusal names the balance rather than the signature, so
|
|
21
|
+
* `ensureGatewayBalance` checks before paying rather than after failing.
|
|
22
|
+
*/
|
|
23
|
+
import { GatewayClient } from '@circle-fin/x402-batching/client';
|
|
24
|
+
/** Arc Testnet, as `@circle-fin/x402-batching` names it. */
|
|
25
|
+
export const ARC_GATEWAY_CHAIN = 'arcTestnet';
|
|
26
|
+
function client(wallet) {
|
|
27
|
+
return new GatewayClient({
|
|
28
|
+
chain: ARC_GATEWAY_CHAIN,
|
|
29
|
+
privateKey: wallet.privateKey,
|
|
30
|
+
rpcUrl: wallet.rpcUrl,
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
/** What the buyer currently has inside Gateway. */
|
|
34
|
+
export async function gatewayBalance(wallet) {
|
|
35
|
+
const balance = await client(wallet).getBalance();
|
|
36
|
+
return { available: balance.available, withdrawing: balance.withdrawing };
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Make sure the buyer can pay `atLeast`, depositing `topUp` if not.
|
|
40
|
+
*
|
|
41
|
+
* Deposits are the one on-chain step in this flow and they cost gas, so this
|
|
42
|
+
* is deliberately not called before every payment — an agent deposits once and
|
|
43
|
+
* spends against it.
|
|
44
|
+
*/
|
|
45
|
+
export async function ensureGatewayBalance(wallet,
|
|
46
|
+
/** In USDC's smallest units. Undefined requests an unconditional deposit. */
|
|
47
|
+
atLeast,
|
|
48
|
+
/** In whole USDC, like everything the deposit call takes. */
|
|
49
|
+
topUp) {
|
|
50
|
+
const before = await gatewayBalance(wallet);
|
|
51
|
+
if (atLeast !== undefined && before.available >= atLeast)
|
|
52
|
+
return { deposited: false, balance: before };
|
|
53
|
+
const result = await client(wallet).deposit(topUp);
|
|
54
|
+
return {
|
|
55
|
+
deposited: true,
|
|
56
|
+
balance: await gatewayBalance(wallet),
|
|
57
|
+
depositTxHash: result.depositTxHash,
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Buy something priced in x402, paying through Gateway.
|
|
62
|
+
*
|
|
63
|
+
* The 402 answer must carry a batched offer; a service that offers only the
|
|
64
|
+
* ordinary on-chain options is not reachable this way, and saying so is better
|
|
65
|
+
* than silently paying the expensive way.
|
|
66
|
+
*/
|
|
67
|
+
export async function payWithNanopayments(wallet, url, options) {
|
|
68
|
+
const gateway = client(wallet);
|
|
69
|
+
const supported = await gateway.supports(url);
|
|
70
|
+
if (!supported.supported) {
|
|
71
|
+
throw new Error(`${url} offers no batched payment option, so it cannot be paid through Circle Gateway. ` +
|
|
72
|
+
`Pay it the ordinary way, or have the service offer arc-testnet-nano.`);
|
|
73
|
+
}
|
|
74
|
+
const paid = await gateway.pay(url, options);
|
|
75
|
+
return { data: paid.data, amount: String(paid.amount ?? '0') };
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=nanopayment.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"nanopayment.js","sourceRoot":"","sources":["../src/nanopayment.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AAEH,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AAEjE,4DAA4D;AAC5D,MAAM,CAAC,MAAM,iBAAiB,GAAG,YAAqB,CAAC;AAiBvD,SAAS,MAAM,CAAC,MAAyB;IACvC,OAAO,IAAI,aAAa,CAAC;QACvB,KAAK,EAAE,iBAAiB;QACxB,UAAU,EAAE,MAAM,CAAC,UAAU;QAC7B,MAAM,EAAE,MAAM,CAAC,MAAM;KACtB,CAAC,CAAC;AACL,CAAC;AAED,mDAAmD;AACnD,MAAM,CAAC,KAAK,UAAU,cAAc,CAAC,MAAyB;IAC5D,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,CAAC,UAAU,EAAE,CAAC;IAClD,OAAO,EAAE,SAAS,EAAE,OAAO,CAAC,SAAS,EAAE,WAAW,EAAE,OAAO,CAAC,WAAW,EAAE,CAAC;AAC5E,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CACxC,MAAyB;AACzB,6EAA6E;AAC7E,OAA2B;AAC3B,6DAA6D;AAC7D,KAAa;IAEb,MAAM,MAAM,GAAG,MAAM,cAAc,CAAC,MAAM,CAAC,CAAC;IAC5C,IAAI,OAAO,KAAK,SAAS,IAAI,MAAM,CAAC,SAAS,IAAI,OAAO;QAAE,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC;IAEvG,MAAM,MAAM,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IACnD,OAAO;QACL,SAAS,EAAE,IAAI;QACf,OAAO,EAAE,MAAM,cAAc,CAAC,MAAM,CAAC;QACrC,aAAa,EAAE,MAAM,CAAC,aAAa;KACpC,CAAC;AACJ,CAAC;AAED;;;;;;GAMG;AACH,MAAM,CAAC,KAAK,UAAU,mBAAmB,CACvC,MAAyB,EACzB,GAAW,EACX,OAA+E;IAE/E,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,CAAC,CAAC;IAC/B,MAAM,SAAS,GAAG,MAAM,OAAO,CAAC,QAAQ,CAAC,GAAG,CAAC,CAAC;IAC9C,IAAI,CAAC,SAAS,CAAC,SAAS,EAAE,CAAC;QACzB,MAAM,IAAI,KAAK,CACb,GAAG,GAAG,kFAAkF;YACxF,sEAAsE,CACvE,CAAC;IACJ,CAAC;IACD,MAAM,IAAI,GAAG,MAAM,OAAO,CAAC,GAAG,CAAI,GAAG,EAAE,OAAgB,CAAC,CAAC;IACzD,OAAO,EAAE,IAAI,EAAE,IAAI,CAAC,IAAS,EAAE,MAAM,EAAE,MAAM,CAAE,IAA6B,CAAC,MAAM,IAAI,GAAG,CAAC,EAAE,CAAC;AAChG,CAAC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
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 type { PaymentWallet, PaymentOffer, PaidRequest, ApprovedPayment } from './types.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 declare function paymentOffers(challenge: {
|
|
47
|
+
accepts?: unknown[];
|
|
48
|
+
payment?: unknown;
|
|
49
|
+
requiresPayment?: boolean;
|
|
50
|
+
}): PaymentOffer[];
|
|
51
|
+
/**
|
|
52
|
+
* Sign payment for one of the offers and return the headers to retry with.
|
|
53
|
+
*
|
|
54
|
+
* `network` names the chain to pay on, as either the CAIP-2 id
|
|
55
|
+
* (`eip155:5042002`) or the plain name (`arc-testnet`). Omitting it takes the
|
|
56
|
+
* first offer, which is the order the service listed its chains in.
|
|
57
|
+
*
|
|
58
|
+
* An unmatched name is an error listing what was offered. It is never a
|
|
59
|
+
* silent fall back to the first chain: paying on a chain the caller did not
|
|
60
|
+
* ask for spends real money in the wrong place, and the caller who typed
|
|
61
|
+
* `--network arc` would be told the payment succeeded.
|
|
62
|
+
*/
|
|
63
|
+
export declare function assertApprovedPayment(offer: PaymentOffer, approved: ApprovedPayment): void;
|
|
64
|
+
export declare function signPayment(challenge: {
|
|
65
|
+
accepts?: unknown[];
|
|
66
|
+
payment?: unknown;
|
|
67
|
+
nonce?: string;
|
|
68
|
+
}, wallet: PaymentWallet, opts?: {
|
|
69
|
+
network?: string;
|
|
70
|
+
maxPayment?: string;
|
|
71
|
+
approvedPayment?: ApprovedPayment;
|
|
72
|
+
}): Promise<PaidRequest>;
|
|
73
|
+
//# sourceMappingURL=payment.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"payment.d.ts","sourceRoot":"","sources":["../src/payment.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AAEH,OAAO,KAAK,EAAE,aAAa,EAAE,YAAY,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAG5F;;;;;GAKG;AACH,wBAAgB,aAAa,CAAC,SAAS,EAAE;IACvC,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC;IACpB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,eAAe,CAAC,EAAE,OAAO,CAAC;CAC3B,GAAG,YAAY,EAAE,CAcjB;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,qBAAqB,CAAC,KAAK,EAAC,YAAY,EAAC,QAAQ,EAAC,eAAe,QAQhF;AAED,wBAAsB,WAAW,CAC/B,SAAS,EAAE;IAAE,OAAO,CAAC,EAAE,OAAO,EAAE,CAAC;IAAC,OAAO,CAAC,EAAE,OAAO,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAA;CAAE,EACrE,MAAM,EAAE,aAAa,EACrB,IAAI,GAAE;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAC;IAAC,eAAe,CAAC,EAAC,eAAe,CAAA;CAAO,GACrF,OAAO,CAAC,WAAW,CAAC,CAgGtB"}
|