@lunora/x402 1.0.0-alpha.9 → 1.0.0-alpha.90

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 (32) hide show
  1. package/LICENSE.md +18 -0
  2. package/README.md +22 -4
  3. package/dist/charge/index.d.mts +82 -47
  4. package/dist/charge/index.d.ts +82 -47
  5. package/dist/charge/index.mjs +1 -1
  6. package/dist/index.d.mts +2 -5
  7. package/dist/index.d.ts +2 -5
  8. package/dist/index.mjs +1 -1
  9. package/dist/packem_shared/DEFAULT_ALLOWED_ASSETS-CX67Ktyc.mjs +1 -0
  10. package/dist/packem_shared/DEFAULT_FACILITATOR_URL-CPJNUMvi.mjs +1 -0
  11. package/dist/packem_shared/EVM_NETWORKS-CwbBEtp1.mjs +1 -0
  12. package/dist/packem_shared/createChargeMiddleware-DyOEuTCT.mjs +1 -0
  13. package/dist/packem_shared/createProcedureChargeGate-BidGWCmf.mjs +1 -0
  14. package/dist/packem_shared/{config.d-B-NYmHgG.d.ts → index.d-A-g7yKuO.d.mts} +122 -130
  15. package/dist/packem_shared/{config.d-B-NYmHgG.d.mts → index.d-A-g7yKuO.d.ts} +122 -130
  16. package/dist/packem_shared/optional-peer-BBhVxozi.mjs +1 -0
  17. package/dist/packem_shared/toPaymentEventRow-DTXuTDh0.mjs +1 -0
  18. package/dist/packem_shared/withX402-mUrRb9a2.mjs +1 -0
  19. package/dist/pay/index.d.mts +9 -58
  20. package/dist/pay/index.d.ts +9 -58
  21. package/dist/pay/index.mjs +1 -1
  22. package/package.json +21 -9
  23. package/dist/packem_shared/DEFAULT_FACILITATOR_URL-lUtljfJI.mjs +0 -1
  24. package/dist/packem_shared/DEFAULT_STABLECOIN_DECIMALS-gY9zXmGa.mjs +0 -1
  25. package/dist/packem_shared/EVM_NETWORKS-XOms9Rtk.mjs +0 -1
  26. package/dist/packem_shared/createChargeMiddleware-MQhSA6Wt.mjs +0 -1
  27. package/dist/packem_shared/createFacilitatorClient-Dj4Ll9xQ.mjs +0 -1
  28. package/dist/packem_shared/createPayFetch-CDZJaS13.mjs +0 -1
  29. package/dist/packem_shared/createProcedureChargeGate-Cfm5mD2y.mjs +0 -1
  30. package/dist/packem_shared/registerWallet-Cu4qF5tj.mjs +0 -1
  31. package/dist/packem_shared/toPaymentEventRow-D_kRVcb3.mjs +0 -1
  32. package/dist/packem_shared/withX402-D10895ct.mjs +0 -1
@@ -1,14 +1,72 @@
1
- import { ClientEvmSigner } from '@x402/evm';
2
- import { ClientSvmSigner } from '@x402/svm';
3
- import { ProcessSettleSuccessResponse } from '@x402/core/http';
4
- import { BeforePaymentCreationHook, PaymentPolicy, OnPaymentCreationFailureHook } from '@x402/core/client';
5
1
  import { PaymentRequirements } from '@x402/core/types';
2
+ import { TransactionSigner } from '@solana/accounts';
3
+ /**
4
+ * ClientEvmSigner - Used by x402 clients to sign payment authorizations.
5
+ *
6
+ * Typically a viem LocalAccount:
7
+ * ```typescript
8
+ * const account = privateKeyToAccount('0x...');
9
+ * ```
10
+ *
11
+ * Or composed via `toClientEvmSigner(account, publicClient)`.
12
+ */
13
+ type ClientEvmSigner = {
14
+ readonly address: `0x${string}`;
15
+ signTypedData(message: {
16
+ domain: Record<string, unknown>;
17
+ types: Record<string, unknown>;
18
+ primaryType: string;
19
+ message: Record<string, unknown>;
20
+ }): Promise<`0x${string}`>;
21
+ /**
22
+ * Optional on-chain reads.
23
+ * Required only for extension enrichment (EIP-2612 / ERC-20 approval).
24
+ */
25
+ readContract?(args: {
26
+ address: `0x${string}`;
27
+ abi: readonly unknown[];
28
+ functionName: string;
29
+ args?: readonly unknown[];
30
+ }): Promise<unknown>;
31
+ /**
32
+ * Optional: Signs a raw EIP-1559 transaction without broadcasting.
33
+ * Required for ERC-20 approval gas sponsoring when the token lacks EIP-2612.
34
+ */
35
+ signTransaction?(args: {
36
+ to: `0x${string}`;
37
+ data: `0x${string}`;
38
+ nonce: number;
39
+ gas: bigint;
40
+ maxFeePerGas: bigint;
41
+ maxPriorityFeePerGas: bigint;
42
+ chainId: number;
43
+ }): Promise<`0x${string}`>;
44
+ /**
45
+ * Optional: Gets the current transaction count (nonce) for an address.
46
+ * Required for ERC-20 approval gas sponsoring.
47
+ */
48
+ getTransactionCount?(args: {
49
+ address: `0x${string}`;
50
+ }): Promise<number>;
51
+ /**
52
+ * Optional: Estimates current gas fees per gas.
53
+ * Required for ERC-20 approval gas sponsoring.
54
+ */
55
+ estimateFeesPerGas?(): Promise<{
56
+ maxFeePerGas: bigint;
57
+ maxPriorityFeePerGas: bigint;
58
+ }>;
59
+ };
60
+ /**
61
+ * Client-side signer for creating and signing Solana transactions
62
+ * This is a wrapper around TransactionSigner from @solana/kit
63
+ */
64
+ type ClientSvmSigner = TransactionSigner;
6
65
  /**
7
66
  * A normalised record of one settled x402 payment. The settled `amount` is kept
8
67
  * as its exact on-chain atomic-unit string (USDC has 6 decimals) — never coerced
9
68
  * to a fractional-dollar number — so no precision is lost crossing the reporting
10
69
  * seam.
11
- * @experimental
12
70
  */
13
71
  interface X402Receipt {
14
72
  /** Settled amount in the asset's atomic base units (USDC: 6 decimals), as an exact string. */
@@ -34,26 +92,12 @@ interface X402Receipt {
34
92
  * settlement, does not block the paid response on it, and swallows any error it
35
93
  * throws — so a sink must never rely on being awaited or on its failures
36
94
  * surfacing.
37
- * @experimental
38
95
  */
39
96
  type X402ReceiptSink = (receipt: X402Receipt) => Promise<void> | void;
40
- /**
41
- * Normalise a successful facilitator settlement into an {@link X402Receipt}.
42
- * `resource` (the gated URL or procedure id) and `ts` are supplied by the caller —
43
- * the settlement result carries neither. Prefers the actual settled `amount`
44
- * (present for `upto`-scheme partial settlements) and falls back to the route's
45
- * required amount for `exact`.
46
- * @experimental
47
- */
48
- declare const toReceipt: (settlement: ProcessSettleSuccessResponse, context: {
49
- readonly resource: string;
50
- readonly ts: number;
51
- }) => X402Receipt;
52
97
  /**
53
98
  * A row for `@lunora/payment`'s durable `events` table. Deliberately a plain
54
99
  * structural type — building one imports nothing from `@lunora/payment`, so the
55
100
  * rails stay decoupled.
56
- * @experimental
57
101
  */
58
102
  interface PaymentEventRow {
59
103
  /** Epoch milliseconds the settlement was recorded. */
@@ -81,47 +125,25 @@ interface PaymentEventRow {
81
125
  * table (`packages/payment/src/schema.ts`). Amount / from / to / resource are
82
126
  * intentionally not on this row — that card renders none of them; read them off
83
127
  * the {@link X402Receipt} (e.g. into your own revenue table) if you need them.
84
- * @experimental
85
128
  */
86
129
  declare const toPaymentEventRow: (receipt: X402Receipt) => PaymentEventRow;
87
- /**
88
- * Network identity for `@lunora/x402`.
89
- *
90
- * `@x402/core` v2 speaks **CAIP-2** chain ids (`eip155:8453` for Base,
91
- * `solana:5eyk…` for Solana mainnet) — `type Network = ` `${string}:${string}` ``.
92
- * Lunora keeps ergonomic **friendly** names (`"base"`, `"base-sepolia"`) as the
93
- * public surface and maps them to CAIP-2 here, at the single seam where we hand a
94
- * network to the SDK. A raw CAIP-2 string is also accepted as a power-user escape
95
- * hatch (e.g. a chain we don't yet have a friendly alias for).
96
- *
97
- * The friendly set is intentionally scoped to chains `@x402/evm` / `@x402/svm`
98
- * can settle the ergonomic `price:"$0.01"` path on out of the box (i.e. chains in
99
- * their `DEFAULT_STABLECOINS` registry). Notably that excludes Optimism and
100
- * Avalanche today — advertising them would 500 at settlement — so they are not
101
- * friendly aliases; a caller who needs them can still pass a raw CAIP-2 id with an
102
- * explicit asset.
103
- */
104
130
  /**
105
131
  * A CAIP-2 chain identifier, e.g. `"eip155:8453"` (Base) or `"solana:5eyk…"`.
106
- * @experimental
107
132
  */
108
133
  type Caip2 = `${string}:${string}`;
109
134
  /**
110
135
  * Friendly network names Lunora maps to CAIP-2 for `@x402/core`.
111
- * @experimental
112
136
  */
113
137
  type FriendlyNetwork = "arbitrum" | "arbitrum-sepolia" | "base" | "base-sepolia" | "ethereum" | "polygon" | "solana" | "solana-devnet";
114
138
  /**
115
139
  * A network Lunora can settle on: a {@link FriendlyNetwork} alias (mapped to
116
140
  * CAIP-2 internally) or a raw {@link Caip2} id for chains without a friendly name.
117
- * @experimental
118
141
  */
119
142
  type X402Network = Caip2 | FriendlyNetwork;
120
143
  /**
121
144
  * Friendly name → CAIP-2 id. Values verified against `@x402/evm` and `@x402/svm`
122
145
  * `DEFAULT_STABLECOINS` at 2.17.0. `base` / `base-sepolia` are the primary
123
146
  * prod / test pair.
124
- * @experimental
125
147
  */
126
148
  declare const NETWORK_TO_CAIP2: {
127
149
  readonly arbitrum: "eip155:42161";
@@ -135,55 +157,100 @@ declare const NETWORK_TO_CAIP2: {
135
157
  };
136
158
  /**
137
159
  * EVM friendly networks (signed via `@x402/evm` + viem).
138
- * @experimental
139
160
  */
140
161
  declare const EVM_NETWORKS: readonly ["arbitrum", "arbitrum-sepolia", "base", "base-sepolia", "ethereum", "polygon"];
141
162
  /**
142
163
  * Solana friendly networks (signed via `@x402/svm`).
143
- * @experimental
144
164
  */
145
165
  declare const SVM_NETWORKS: readonly ["solana", "solana-devnet"];
146
166
  /**
147
167
  * Resolve a network to its CAIP-2 id. Friendly aliases are looked up; a value
148
168
  * that already looks like CAIP-2 (`namespace:reference`) passes through.
149
- * @experimental
150
169
  */
151
170
  declare const toCaip2: (network: X402Network) => Caip2;
152
171
  /**
153
172
  * True when `network` settles on an EVM chain (viem signer path).
154
- * @experimental
155
173
  */
156
174
  declare const isEvmNetwork: (network: X402Network) => boolean;
157
175
  /**
158
176
  * True when `network` settles on Solana (`@x402/svm` signer path).
159
- * @experimental
160
177
  */
161
178
  declare const isSvmNetwork: (network: X402Network) => boolean;
162
179
  /**
163
- * USDC — and every asset in `@x402/evm` / `@x402/svm`'s `DEFAULT_STABLECOINS` —
164
- * uses 6 decimals, so a USD price converts to atomic base units at `10 ** 6`.
165
- * Override per {@link SpendPolicy.decimals} only for a custom, non-6-decimal asset.
166
- * @experimental
180
+ * USDC uses 6 decimals, so a USD price converts to atomic base units at `10 ** 6`.
181
+ * This is only the *default* for the standalone {@link usdToAtomic} helper —
182
+ * a spend policy never assumes it, and scales each requirement by the decimals of
183
+ * the asset it actually names (see {@link SpendPolicy.allowedAssets}).
167
184
  */
168
185
  declare const DEFAULT_STABLECOIN_DECIMALS = 6;
186
+ /**
187
+ * A stablecoin an agent wallet may pay in, and the decimals its atomic amounts are
188
+ * denominated in.
189
+ *
190
+ * `decimals` is required and explicit: a 402 server names the token contract to
191
+ * transfer, and the same atomic amount means a wildly different sum in a 6-decimal
192
+ * versus an 18-decimal token. Assuming a decimal count is how a tiny USD cap comes
193
+ * to authorise a large transfer, so the caller states it per asset. Note
194
+ * `@x402/evm`'s own `DEFAULT_STABLECOINS` registry is *not* uniformly 6-decimal
195
+ * (MegaUSD and Mezo USD are 18), which is exactly why it can't be trusted as a gate.
196
+ */
197
+ interface AllowedAsset {
198
+ /** Token contract (EVM) or mint (SVM) address. Matched case-insensitively on EVM, exactly on SVM. */
199
+ readonly asset: string;
200
+ /** Atomic base-unit decimals for this asset. Used to scale the USD caps — must match the token on chain. */
201
+ readonly decimals: number;
202
+ /** The network this asset lives on. Friendly names are resolved to CAIP-2. */
203
+ readonly network: X402Network;
204
+ }
205
+ /**
206
+ * The assets a policy allows when it doesn't name its own — the canonical
207
+ * 6-decimal, dollar-pegged USDC on each network Lunora has a friendly alias for.
208
+ *
209
+ * Deliberately a small hand-mirrored table rather than `@x402/evm`'s
210
+ * `DEFAULT_STABLECOINS`: that registry mixes 6- and 18-decimal assets, and importing
211
+ * it would pull viem into every bundle that touches a policy (the scheme modules are
212
+ * dynamically imported for exactly that reason — see `wallet.ts`). Addresses verified
213
+ * against `@x402/evm` `DEFAULT_STABLECOINS` and `@x402/svm` `USDC_*_ADDRESS` at 2.19.0.
214
+ *
215
+ * `ethereum` (`eip155:1`) is absent — the SDK ships no default stablecoin for it, so
216
+ * paying there needs an explicit {@link SpendPolicy.allowedAssets} entry.
217
+ */
218
+ declare const DEFAULT_ALLOWED_ASSETS: ReadonlyArray<AllowedAsset>;
169
219
  /**
170
220
  * Spend limits and approval gates for an agent wallet. At least one bound must be
171
221
  * set — see {@link assertBoundedPolicy} — or the pay rail refuses to build.
172
222
  *
173
223
  * Caps are denominated in USD (the stablecoin's dollar value); addresses and
174
224
  * networks are matched against the requirement the server offers.
175
- * @experimental
176
225
  */
177
226
  interface SpendPolicy {
227
+ /**
228
+ * Asset allowlist, each entry carrying its own `decimals` (defaults to
229
+ * {@link DEFAULT_ALLOWED_ASSETS} — canonical USDC per friendly network).
230
+ *
231
+ * This is a **security gate, not a convenience**: the server picks which token
232
+ * contract gets transferred, so a policy that only caps a USD amount caps nothing
233
+ * until the asset behind that amount is pinned. A requirement naming an asset
234
+ * outside this list is refused, and the USD caps are scaled by the matched entry's
235
+ * `decimals` — never by an assumed decimal count.
236
+ *
237
+ * Every entry must be dollar-pegged: the caps are USD, and the per-run ledger sums
238
+ * atomic units across payments, so a non-$1 asset silently mis-prices both.
239
+ */
240
+ readonly allowedAssets?: ReadonlyArray<AllowedAsset>;
178
241
  /** Network allowlist. When set, only these networks may be paid on. */
179
242
  readonly allowedNetworks?: ReadonlyArray<X402Network>;
180
243
  /** Recipient allowlist. When set, only these `payTo` addresses may be paid. */
181
244
  readonly allowedRecipients?: ReadonlyArray<string>;
182
- /** Stablecoin decimals for USD→atomic conversion (default {@link DEFAULT_STABLECOIN_DECIMALS}). */
183
- readonly decimals?: number;
184
245
  /** Hard ceiling on a single payment, in USD. */
185
246
  readonly maxPerCall?: X402Price;
186
- /** Hard ceiling on cumulative spend across this wallet's lifetime, in USD. */
247
+ /**
248
+ * Hard ceiling on cumulative spend by one pay rail, in USD. The ledger lives
249
+ * in memory on the rail, so the cap covers one `createX402Pay` result, and for
250
+ * `ctx.x402` one function invocation (codegen builds a rail per ctx). It is not
251
+ * a budget across invocations: for that, keep a counter in durable state (a
252
+ * Durable Object, a table) and check it in `onPaymentRequired`.
253
+ */
187
254
  readonly maxPerRun?: X402Price;
188
255
  /**
189
256
  * Approval gate. Called with the selected requirement before signing; return
@@ -192,87 +259,20 @@ interface SpendPolicy {
192
259
  */
193
260
  readonly onPaymentRequired?: (requirement: PaymentRequirements) => Promise<boolean> | boolean;
194
261
  }
195
- /**
196
- * A running spend ledger the per-run cap is measured (and reserved) against.
197
- * @experimental
198
- */
199
- interface SpendState {
200
- /** Reserve a payment (atomic base units) against the running total, before it is signed. */
201
- readonly add: (amount: bigint) => void;
202
- /** Release a previously reserved amount (atomic base units) — e.g. a declined or failed payment. Clamps at 0. */
203
- readonly release: (amount: bigint) => void;
204
- /** Cumulative spend so far, in atomic base units. */
205
- readonly spentAtomic: bigint;
206
- }
207
- /**
208
- * A fresh spend ledger. One per wallet instance; the guard reserves into it and
209
- * releases from it.
210
- * @experimental
211
- */
212
- declare const createSpendState: () => SpendState;
213
262
  /**
214
263
  * Convert a USD amount (`0.01`, `"0.01"`, or the `"$0.01"` shorthand) to atomic
215
264
  * stablecoin base units, exactly — parsed digit-by-digit so no binary-float drift
216
265
  * can round a cap the wrong way. Throws on a malformed amount (including
217
266
  * exponential notation like `"1e-7"`, which a decimal string never needs).
218
- * @experimental
219
267
  */
220
268
  declare const usdToAtomic: (usd: X402Price, decimals?: number) => bigint;
221
- /**
222
- * A `PaymentPolicy` that narrows the server's offered requirements to those a
223
- * bounded wallet may pay: within the per-call cap, to an allowed recipient, on an
224
- * allowed network. An empty result means the client cannot pay — fail-closed.
225
- * @experimental
226
- */
227
- declare const buildSpendPolicy: (policy: SpendPolicy) => PaymentPolicy;
228
- /**
229
- * A `BeforePaymentCreationHook` enforcing the stateful bounds the stateless
230
- * {@link buildSpendPolicy} filter can't: the cumulative per-run cap and the async
231
- * confirmation gate. Aborts (no signature) when either would be violated.
232
- *
233
- * The per-run cap is *reserved* into `state` as soon as the check passes — before
234
- * the `await policy.onPaymentRequired` below, and before `@x402/core` ever attempts
235
- * to sign — not recorded afterwards. This closes a check-then-act race: without an
236
- * atomic reserve, N concurrent payments could each read the same `spentAtomic`,
237
- * all pass the cap check, and all record, overspending the cap by up to
238
- * (N−1)×maxPerCall. A declined confirmation releases the reservation before this
239
- * hook returns; {@link releaseSpendOnFailure} releases it if the signature itself
240
- * later fails. The reservation is intentionally *not* released on success — a
241
- * committed payment stays counted.
242
- * @experimental
243
- */
244
- declare const buildPaymentGuard: (policy: SpendPolicy, state: SpendState) => BeforePaymentCreationHook;
245
- /**
246
- * An `OnPaymentCreationFailureHook` that releases a reservation
247
- * {@link buildPaymentGuard} made when the scheme's signature creation itself
248
- * throws (network error, wallet error, …) after the guard already approved and
249
- * reserved the amount. Without this, a failed signature would permanently
250
- * over-count against the per-run cap for the rest of the run — fail-closed, but
251
- * needlessly so when the client (`wrapFetchWithPayment`) may retry.
252
- * @experimental
253
- */
254
- declare const releaseSpendOnFailure: (state: SpendState) => OnPaymentCreationFailureHook;
255
- /**
256
- * Guard at wallet-build time: refuse a policy with no bound whatsoever. Signing
257
- * money on an agent's behalf with unlimited spend authority is never the intent,
258
- * so this fails loudly rather than defaulting to unbounded.
259
- *
260
- * `allowedNetworks` / `allowedRecipients` narrow *where* a payment can go, but
261
- * neither caps *how much* — a policy with only an allowlist still authorises
262
- * unlimited spend to any recipient it permits. Only `maxPerCall`, `maxPerRun`, or
263
- * a dynamic `onPaymentRequired` gate actually bound spend, so only those count here.
264
- * @experimental
265
- */
266
- declare const assertBoundedPolicy: (policy: SpendPolicy) => void;
267
269
  /**
268
270
  * The public, Coinbase-operated facilitator (verify + settle). It needs no API
269
271
  * key. Override with a self-hosted or CDP facilitator via {@link FacilitatorConfig}.
270
- * @experimental
271
272
  */
272
273
  declare const DEFAULT_FACILITATOR_URL = "https://x402.org/facilitator";
273
274
  /**
274
275
  * How to reach a facilitator's `/verify` + `/settle` endpoints.
275
- * @experimental
276
276
  */
277
277
  interface FacilitatorConfig {
278
278
  /** Extra headers for a private facilitator (e.g. a CDP bearer token). */
@@ -286,17 +286,14 @@ interface FacilitatorConfig {
286
286
  * to the network's stablecoin base units (USDC has 6 decimals) at challenge
287
287
  * time. (Kept `number | string` rather than a `` `$${string}` `` template
288
288
  * member — the template is subsumed by `string`, so it only adds noise.)
289
- * @experimental
290
289
  */
291
290
  type X402Price = number | string;
292
291
  /**
293
292
  * An EVM recipient address (the merchant wallet that receives settlement).
294
- * @experimental
295
293
  */
296
294
  type EvmAddress = `0x${string}`;
297
295
  /**
298
296
  * Recipient wallet the facilitator settles payments to, per network family.
299
- * @experimental
300
297
  */
301
298
  interface X402Recipient {
302
299
  /** EVM payout address (required for EVM networks). */
@@ -307,7 +304,6 @@ interface X402Recipient {
307
304
  /**
308
305
  * Server-side (charge rail) config. The server needs only a **recipient
309
306
  * address** — no private key — because the facilitator performs settlement.
310
- * @experimental
311
307
  */
312
308
  interface X402ChargeConfig {
313
309
  readonly facilitator?: FacilitatorConfig;
@@ -329,7 +325,6 @@ interface X402ChargeConfig {
329
325
  * Client-side (pay rail) config. The signer holds spending authority, so the
330
326
  * pay rail is ActionCtx-only and MUST be paired with a spend `policy` — the pay
331
327
  * rail refuses to build if the policy is unbounded.
332
- * @experimental
333
328
  */
334
329
  interface X402PayConfig {
335
330
  /** Network to transact on. Determines the signer family (EVM vs SVM). */
@@ -349,7 +344,6 @@ interface X402PayConfig {
349
344
  * custody is `@coinbase/cdp-sdk`.) EVM only today; for CDP on Solana, build a
350
345
  * `@solana/kit` signer around your CDP account and pass it via the `"signer"`
351
346
  * escape hatch.
352
- * @experimental
353
347
  */
354
348
  interface X402CdpSignerConfig {
355
349
  /** CDP account name to get-or-create and sign with. */
@@ -381,7 +375,6 @@ interface X402CdpSignerConfig {
381
375
  * Wired today: raw-key (EVM + SVM), the user-supplied signer (both families),
382
376
  * and CDP-managed EVM custody. CDP on Solana is not yet wired — use the escape
383
377
  * hatch.
384
- * @experimental
385
378
  */
386
379
  type X402SignerConfig = X402CdpSignerConfig | {
387
380
  /** Name of the `ctx.secrets` entry holding the private key. */
@@ -398,7 +391,6 @@ type X402SignerConfig = X402CdpSignerConfig | {
398
391
  };
399
392
  /**
400
393
  * Resolve a facilitator's base URL, applying the public default.
401
- * @experimental
402
394
  */
403
395
  declare const resolveFacilitatorUrl: (facilitator?: FacilitatorConfig) => string;
404
- export { Caip2 as C, DEFAULT_FACILITATOR_URL as D, EVM_NETWORKS as E, FacilitatorConfig as F, NETWORK_TO_CAIP2 as N, PaymentEventRow as P, SVM_NETWORKS as S, X402CdpSignerConfig as X, EvmAddress as a, FriendlyNetwork as b, X402ChargeConfig as c, X402Network as d, X402PayConfig as e, X402Price as f, X402Receipt as g, X402ReceiptSink as h, X402Recipient as i, X402SignerConfig as j, isEvmNetwork as k, isSvmNetwork as l, DEFAULT_STABLECOIN_DECIMALS as m, SpendPolicy as n, SpendState as o, assertBoundedPolicy as p, buildPaymentGuard as q, resolveFacilitatorUrl as r, buildSpendPolicy as s, toCaip2 as t, createSpendState as u, releaseSpendOnFailure as v, usdToAtomic as w, toPaymentEventRow as x, toReceipt as y };
396
+ export { AllowedAsset as A, type Caip2 as C, DEFAULT_ALLOWED_ASSETS as D, EvmAddress as E, type FacilitatorConfig as F, NETWORK_TO_CAIP2 as N, PaymentEventRow as P, type SpendPolicy as S, X402PayConfig as X, DEFAULT_FACILITATOR_URL as a, DEFAULT_STABLECOIN_DECIMALS as b, type X402CdpSignerConfig as c, type X402Network as d, type X402Price as e, type X402SignerConfig as f, type isSvmNetwork as g, X402ChargeConfig as h, isEvmNetwork as i, X402Receipt as j, X402ReceiptSink as k, X402Recipient as l, toPaymentEventRow as m, EVM_NETWORKS as n, FriendlyNetwork as o, SVM_NETWORKS as p, resolveFacilitatorUrl as r, toCaip2 as t, usdToAtomic as u };
@@ -0,0 +1 @@
1
+ import{LunoraError as u}from"@lunora/errors";const a=new Set(["ERR_MODULE_NOT_FOUND","MODULE_NOT_FOUND"]),i=/cannot find (?:module|package)|module not found|failed to resolve (?:module|import)/i,s=(t,o=3)=>{if(typeof t!="object"||t===null||o<0)return!1;const{cause:e,code:r,message:n}=t;return typeof r=="string"&&a.has(r)||typeof n=="string"&&i.test(n)?!0:s(e,o-1)},f=async(t,o)=>{try{return await t()}catch(e){throw s(e)?new u("ENV_INVALID",o,{cause:e}):e}};export{f as i};
@@ -0,0 +1 @@
1
+ const e=(r,o)=>({amount:r.amount??r.requirements.amount,asset:r.requirements.asset,from:r.payer,network:r.network,resource:o.resource,to:r.requirements.payTo,ts:o.ts,tx:r.transaction}),s=r=>({processedAt:r.ts,provider:"x402",providerEventId:r.tx,type:"x402.settled"});export{s as toPaymentEventRow,e as toReceipt};
@@ -0,0 +1 @@
1
+ import{createChargeMiddleware as w}from"./createChargeMiddleware-DyOEuTCT.mjs";const h=(o,r)=>{let t;return async(n,a)=>{t??=w(o).catch(i=>{throw t=void 0,i});const d=await t,e=n,c=typeof e.waitUntil=="function"?{waitUntil:i=>{e.waitUntil?.(i)}}:void 0;return d.handle(a,()=>r(n,a),c)}};export{h as withX402};
@@ -1,70 +1,22 @@
1
- import { e as X402PayConfig } from "../packem_shared/config.d-B-NYmHgG.mjs";
2
- export { type C as Caip2, D as DEFAULT_FACILITATOR_URL, m as DEFAULT_STABLECOIN_DECIMALS, type n as SpendPolicy, type o as SpendState, type X as X402CdpSignerConfig, type d as X402Network, type f as X402Price, type j as X402SignerConfig, p as assertBoundedPolicy, q as buildPaymentGuard, s as buildSpendPolicy, u as createSpendState, k as isEvmNetwork, l as isSvmNetwork, v as releaseSpendOnFailure, r as resolveFacilitatorUrl, t as toCaip2, w as usdToAtomic } from "../packem_shared/config.d-B-NYmHgG.mjs";
3
- import { x402Client } from '@x402/core/client';
4
- import { ClientSvmSigner } from '@x402/svm';
5
- import { PrivateKeyAccount } from 'viem/accounts';
6
- import '@x402/evm';
7
- import '@x402/core/http';
1
+ import { X as X402PayConfig } from "../packem_shared/index.d-A-g7yKuO.mjs";
2
+ export { type A as AllowedAsset, type C as Caip2, D as DEFAULT_ALLOWED_ASSETS, a as DEFAULT_FACILITATOR_URL, b as DEFAULT_STABLECOIN_DECIMALS, type S as SpendPolicy, type c as X402CdpSignerConfig, type d as X402Network, type e as X402Price, type f as X402SignerConfig, i as isEvmNetwork, g as isSvmNetwork, r as resolveFacilitatorUrl, t as toCaip2, u as usdToAtomic } from "../packem_shared/index.d-A-g7yKuO.mjs";
8
3
  import '@x402/core/types';
9
- /** Reads a secret by name; resolves `undefined` when unset. */
10
- type GetSecret = (name: string) => Promise<string | undefined> | string | undefined;
11
- /**
12
- * How the wallet reads its key material — wired to `ctx.secrets.get` in an action.
13
- * @experimental
14
- */
15
- interface WalletDeps {
16
- /** Read a secret (e.g. a private key) by name; `undefined` when unset. */
17
- readonly getSecret: GetSecret;
18
- }
19
- /**
20
- * Resolve a viem `LocalAccount` from a raw private key. The key may be given with
21
- * or without the `0x` prefix. The account is a structural `ClientEvmSigner`
22
- * (`address` + `signTypedData`), so `@x402/evm` accepts it directly.
23
- * @experimental
24
- */
25
- declare const resolveEvmAccount: (privateKey: string) => Promise<PrivateKeyAccount>;
26
- /**
27
- * Resolve a `@solana/kit` `KeyPairSigner` from a raw Solana secret key. The secret
28
- * may be given as a JSON byte array (`[12,34,…]`, the `solana-keygen` keyfile
29
- * format) or as a base58 string. A 64-byte value is a full secret key (seed ‖
30
- * public key); a 32-byte value is the seed alone. The returned signer is a
31
- * structural `ClientSvmSigner` (`TransactionSigner`), so `@x402/svm` accepts it.
32
- * @experimental
33
- */
34
- declare const resolveSvmSigner: (secret: string) => Promise<ClientSvmSigner>;
35
- /**
36
- * Register the scheme family the configured network needs on `client`, wired to
37
- * the agent signer. Dispatches on network family (EVM vs SVM) and on custody —
38
- * `"signer"` (a signer the caller already built; registered directly, no secret
39
- * read), `"raw-key"` (a `ctx.secrets` private key → viem account on EVM or a
40
- * `@solana/kit` keypair on SVM), or `"cdp"` (a Coinbase-managed wallet via
41
- * `@coinbase/cdp-sdk`).
42
- * @experimental
43
- */
44
- declare const registerWallet: (client: x402Client, config: X402PayConfig, deps: WalletDeps) => Promise<void>;
4
+ import '@solana/accounts';
45
5
  /**
46
6
  * A payment-enabled `fetch`: same signature as the platform `fetch`.
47
- * @experimental
48
7
  */
49
8
  type PayFetch = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
50
9
  /**
51
10
  * Dependencies for building a pay-rail fetch: secret access, plus an optional base `fetch` to wrap.
52
- * @experimental
53
11
  */
54
- interface X402PayDeps extends WalletDeps {
12
+ interface X402PayDeps {
55
13
  /** The `fetch` to wrap (defaults to `globalThis.fetch`). Inject to test or to chain transports. */
56
14
  readonly fetch?: typeof globalThis.fetch;
15
+ /** Read a secret (e.g. a private key) by name; `undefined` when unset. Wire it to `ctx.secrets.get`. */
16
+ readonly getSecret: (name: string) => Promise<string | undefined> | string | undefined;
57
17
  }
58
- /**
59
- * Build a payment-enabled `fetch` for `config`. Throws (before resolving a
60
- * signer) when `config.policy` is unbounded — an agent wallet is never built
61
- * with unlimited spend authority.
62
- * @experimental
63
- */
64
- declare const createPayFetch: (config: X402PayConfig, deps: X402PayDeps) => Promise<PayFetch>;
65
18
  /**
66
19
  * A configured pay rail: a payment-enabled `fetch` bounded by the spend policy.
67
- * @experimental
68
20
  */
69
21
  interface X402Pay {
70
22
  /** A `fetch` that transparently pays for `402`-gated resources under the policy. */
@@ -74,7 +26,6 @@ interface X402Pay {
74
26
  * Build a pay rail for `config`. The returned `fetch` answers `402` challenges by
75
27
  * signing and retrying, within `config.policy`. Throws (before touching the
76
28
  * signer) when the policy is unbounded.
77
- * @experimental
78
29
  */
79
30
  declare const createX402Pay: (config: X402PayConfig, deps: X402PayDeps) => Promise<X402Pay>;
80
31
  /**
@@ -86,10 +37,10 @@ declare const createX402Pay: (config: X402PayConfig, deps: X402PayDeps) => Promi
86
37
  * memoises it: the viem/`@x402` signer imports + Secrets Store read are paid for
87
38
  * only when an action actually pays, and the single `SpendState` behind the
88
39
  * rail is shared across every payment for the lifetime of this ctx — so the
89
- * per-run cap scopes to the ctx, not to each request. A failed build (e.g. an
40
+ * per-run cap scopes to the ctx (one function invocation), not to each request
41
+ * and not across invocations. A failed build (e.g. an
90
42
  * unbounded policy) is memoised too, keeping the rail deterministically
91
43
  * fail-closed.
92
- * @experimental
93
44
  */
94
45
  declare const lazyX402Pay: (config: X402PayConfig, deps: X402PayDeps) => X402Pay;
95
- export { type PayFetch, type WalletDeps, X402Pay, type X402PayConfig, type X402PayDeps, createPayFetch, createX402Pay, lazyX402Pay, registerWallet, resolveEvmAccount, resolveSvmSigner };
46
+ export { type PayFetch, X402Pay, type X402PayConfig, type X402PayDeps, createX402Pay, lazyX402Pay };
@@ -1,70 +1,22 @@
1
- import { e as X402PayConfig } from "../packem_shared/config.d-B-NYmHgG.js";
2
- export { type C as Caip2, D as DEFAULT_FACILITATOR_URL, m as DEFAULT_STABLECOIN_DECIMALS, type n as SpendPolicy, type o as SpendState, type X as X402CdpSignerConfig, type d as X402Network, type f as X402Price, type j as X402SignerConfig, p as assertBoundedPolicy, q as buildPaymentGuard, s as buildSpendPolicy, u as createSpendState, k as isEvmNetwork, l as isSvmNetwork, v as releaseSpendOnFailure, r as resolveFacilitatorUrl, t as toCaip2, w as usdToAtomic } from "../packem_shared/config.d-B-NYmHgG.js";
3
- import { x402Client } from '@x402/core/client';
4
- import { ClientSvmSigner } from '@x402/svm';
5
- import { PrivateKeyAccount } from 'viem/accounts';
6
- import '@x402/evm';
7
- import '@x402/core/http';
1
+ import { X as X402PayConfig } from "../packem_shared/index.d-A-g7yKuO.js";
2
+ export { type A as AllowedAsset, type C as Caip2, D as DEFAULT_ALLOWED_ASSETS, a as DEFAULT_FACILITATOR_URL, b as DEFAULT_STABLECOIN_DECIMALS, type S as SpendPolicy, type c as X402CdpSignerConfig, type d as X402Network, type e as X402Price, type f as X402SignerConfig, i as isEvmNetwork, g as isSvmNetwork, r as resolveFacilitatorUrl, t as toCaip2, u as usdToAtomic } from "../packem_shared/index.d-A-g7yKuO.js";
8
3
  import '@x402/core/types';
9
- /** Reads a secret by name; resolves `undefined` when unset. */
10
- type GetSecret = (name: string) => Promise<string | undefined> | string | undefined;
11
- /**
12
- * How the wallet reads its key material — wired to `ctx.secrets.get` in an action.
13
- * @experimental
14
- */
15
- interface WalletDeps {
16
- /** Read a secret (e.g. a private key) by name; `undefined` when unset. */
17
- readonly getSecret: GetSecret;
18
- }
19
- /**
20
- * Resolve a viem `LocalAccount` from a raw private key. The key may be given with
21
- * or without the `0x` prefix. The account is a structural `ClientEvmSigner`
22
- * (`address` + `signTypedData`), so `@x402/evm` accepts it directly.
23
- * @experimental
24
- */
25
- declare const resolveEvmAccount: (privateKey: string) => Promise<PrivateKeyAccount>;
26
- /**
27
- * Resolve a `@solana/kit` `KeyPairSigner` from a raw Solana secret key. The secret
28
- * may be given as a JSON byte array (`[12,34,…]`, the `solana-keygen` keyfile
29
- * format) or as a base58 string. A 64-byte value is a full secret key (seed ‖
30
- * public key); a 32-byte value is the seed alone. The returned signer is a
31
- * structural `ClientSvmSigner` (`TransactionSigner`), so `@x402/svm` accepts it.
32
- * @experimental
33
- */
34
- declare const resolveSvmSigner: (secret: string) => Promise<ClientSvmSigner>;
35
- /**
36
- * Register the scheme family the configured network needs on `client`, wired to
37
- * the agent signer. Dispatches on network family (EVM vs SVM) and on custody —
38
- * `"signer"` (a signer the caller already built; registered directly, no secret
39
- * read), `"raw-key"` (a `ctx.secrets` private key → viem account on EVM or a
40
- * `@solana/kit` keypair on SVM), or `"cdp"` (a Coinbase-managed wallet via
41
- * `@coinbase/cdp-sdk`).
42
- * @experimental
43
- */
44
- declare const registerWallet: (client: x402Client, config: X402PayConfig, deps: WalletDeps) => Promise<void>;
4
+ import '@solana/accounts';
45
5
  /**
46
6
  * A payment-enabled `fetch`: same signature as the platform `fetch`.
47
- * @experimental
48
7
  */
49
8
  type PayFetch = (input: RequestInfo | URL, init?: RequestInit) => Promise<Response>;
50
9
  /**
51
10
  * Dependencies for building a pay-rail fetch: secret access, plus an optional base `fetch` to wrap.
52
- * @experimental
53
11
  */
54
- interface X402PayDeps extends WalletDeps {
12
+ interface X402PayDeps {
55
13
  /** The `fetch` to wrap (defaults to `globalThis.fetch`). Inject to test or to chain transports. */
56
14
  readonly fetch?: typeof globalThis.fetch;
15
+ /** Read a secret (e.g. a private key) by name; `undefined` when unset. Wire it to `ctx.secrets.get`. */
16
+ readonly getSecret: (name: string) => Promise<string | undefined> | string | undefined;
57
17
  }
58
- /**
59
- * Build a payment-enabled `fetch` for `config`. Throws (before resolving a
60
- * signer) when `config.policy` is unbounded — an agent wallet is never built
61
- * with unlimited spend authority.
62
- * @experimental
63
- */
64
- declare const createPayFetch: (config: X402PayConfig, deps: X402PayDeps) => Promise<PayFetch>;
65
18
  /**
66
19
  * A configured pay rail: a payment-enabled `fetch` bounded by the spend policy.
67
- * @experimental
68
20
  */
69
21
  interface X402Pay {
70
22
  /** A `fetch` that transparently pays for `402`-gated resources under the policy. */
@@ -74,7 +26,6 @@ interface X402Pay {
74
26
  * Build a pay rail for `config`. The returned `fetch` answers `402` challenges by
75
27
  * signing and retrying, within `config.policy`. Throws (before touching the
76
28
  * signer) when the policy is unbounded.
77
- * @experimental
78
29
  */
79
30
  declare const createX402Pay: (config: X402PayConfig, deps: X402PayDeps) => Promise<X402Pay>;
80
31
  /**
@@ -86,10 +37,10 @@ declare const createX402Pay: (config: X402PayConfig, deps: X402PayDeps) => Promi
86
37
  * memoises it: the viem/`@x402` signer imports + Secrets Store read are paid for
87
38
  * only when an action actually pays, and the single `SpendState` behind the
88
39
  * rail is shared across every payment for the lifetime of this ctx — so the
89
- * per-run cap scopes to the ctx, not to each request. A failed build (e.g. an
40
+ * per-run cap scopes to the ctx (one function invocation), not to each request
41
+ * and not across invocations. A failed build (e.g. an
90
42
  * unbounded policy) is memoised too, keeping the rail deterministically
91
43
  * fail-closed.
92
- * @experimental
93
44
  */
94
45
  declare const lazyX402Pay: (config: X402PayConfig, deps: X402PayDeps) => X402Pay;
95
- export { type PayFetch, type WalletDeps, X402Pay, type X402PayConfig, type X402PayDeps, createPayFetch, createX402Pay, lazyX402Pay, registerWallet, resolveEvmAccount, resolveSvmSigner };
46
+ export { type PayFetch, X402Pay, type X402PayConfig, type X402PayDeps, createX402Pay, lazyX402Pay };
@@ -1 +1 @@
1
- import{createPayFetch as c}from"../packem_shared/createPayFetch-CDZJaS13.mjs";import{DEFAULT_FACILITATOR_URL as p,resolveFacilitatorUrl as d}from"../packem_shared/DEFAULT_FACILITATOR_URL-lUtljfJI.mjs";import{isEvmNetwork as S,isSvmNetwork as f,toCaip2 as u}from"../packem_shared/EVM_NETWORKS-XOms9Rtk.mjs";import{DEFAULT_STABLECOIN_DECIMALS as v,assertBoundedPolicy as E,buildPaymentGuard as F,buildSpendPolicy as L,createSpendState as P,releaseSpendOnFailure as T,usdToAtomic as x}from"../packem_shared/DEFAULT_STABLECOIN_DECIMALS-gY9zXmGa.mjs";import{registerWallet as w,resolveEvmAccount as C,resolveSvmSigner as I}from"../packem_shared/registerWallet-Cu4qF5tj.mjs";const i=async(e,r)=>({fetch:await c(e,r)}),s=(e,r)=>{let t;return{fetch:async(o,a)=>(t??=i(e,r),(await t).fetch(o,a))}};export{p as DEFAULT_FACILITATOR_URL,v as DEFAULT_STABLECOIN_DECIMALS,E as assertBoundedPolicy,F as buildPaymentGuard,L as buildSpendPolicy,c as createPayFetch,P as createSpendState,i as createX402Pay,S as isEvmNetwork,f as isSvmNetwork,s as lazyX402Pay,w as registerWallet,T as releaseSpendOnFailure,C as resolveEvmAccount,d as resolveFacilitatorUrl,I as resolveSvmSigner,u as toCaip2,x as usdToAtomic};
1
+ import{x402Client as h}from"@x402/core/client";import{wrapFetchWithPayment as u}from"@x402/fetch";import{assertBoundedPolicy as E,buildSpendPolicy as S,buildPaymentGuard as k,createSpendState as A,releaseSpendOnFailure as N}from"../packem_shared/DEFAULT_ALLOWED_ASSETS-CX67Ktyc.mjs";import{DEFAULT_ALLOWED_ASSETS as B,DEFAULT_STABLECOIN_DECIMALS as W,usdToAtomic as $}from"../packem_shared/DEFAULT_ALLOWED_ASSETS-CX67Ktyc.mjs";import{LunoraError as c}from"@lunora/errors";import{toCaip2 as f,isEvmNetwork as x}from"../packem_shared/EVM_NETWORKS-CwbBEtp1.mjs";import{isSvmNetwork as Y}from"../packem_shared/EVM_NETWORKS-CwbBEtp1.mjs";import{i as l}from"../packem_shared/optional-peer-BBhVxozi.mjs";import{DEFAULT_FACILITATOR_URL as G,resolveFacilitatorUrl as q}from"../packem_shared/DEFAULT_FACILITATOR_URL-CPJNUMvi.mjs";const P=/^0x[0-9a-fA-F]{64}$/,p=async(e,t)=>{const a=await e(t);if(a===void 0||a.length===0)throw new c("ENV_INVALID",`x402 pay: secret "${t}" is not set — the agent wallet has no key to sign with.`);return a},g=(e,t)=>{const a=e.address.startsWith("0x");if(t&&!a)throw new c("ENV_INVALID",`x402 pay: the supplied signer address "${e.address}" is not an EVM (0x…) address, but the network is EVM.`);if(!t&&a)throw new c("ENV_INVALID",`x402 pay: the supplied signer address "${e.address}" is an EVM (0x…) address, but the network is Solana.`)},I=async(e,t)=>{const{CdpClient:a}=await l(()=>import("@coinbase/cdp-sdk"),'x402 pay: CDP-managed custody needs the optional @coinbase/cdp-sdk peer — install it, or use "raw-key"/"signer" custody instead.'),[i,o,r]=await Promise.all([p(t,e.apiKeyIdSecretName??"CDP_API_KEY_ID"),p(t,e.apiKeySecretName??"CDP_API_KEY_SECRET"),p(t,e.walletSecretName??"CDP_WALLET_SECRET")]);return new a({apiKeyId:i,apiKeySecret:o,walletSecret:r}).evm.getOrCreateAccount({name:e.account})},v=async e=>{const t=e.startsWith("0x")?e:`0x${e}`;if(!P.test(t))throw new c("ENV_INVALID","x402 pay: the EVM wallet key must be a 32-byte hex private key (64 hex chars, optional 0x prefix).");const{privateKeyToAccount:a}=await l(()=>import("viem/accounts"),'x402 pay: raw-key EVM custody needs the optional viem peer — install it, or use "cdp"/"signer" custody instead.');return a(t)},V=async e=>{const t=e.trim(),{createKeyPairSignerFromBytes:a,createKeyPairSignerFromPrivateKeyBytes:i,getBase58Encoder:o}=await l(()=>import("@solana/kit"),'x402 pay: raw-key Solana custody needs the optional @solana/kit peer — install it, or pass a pre-built signer via "signer" custody instead.');let r;if(t.startsWith("[")){let s;try{s=JSON.parse(t)}catch{throw new c("ENV_INVALID","x402 pay: the Solana wallet key looks like a JSON byte array but is not valid JSON.")}if(!Array.isArray(s)||s.some(n=>typeof n!="number"))throw new c("ENV_INVALID","x402 pay: the Solana wallet key JSON must be an array of byte values.");r=Uint8Array.from(s)}else try{r=Uint8Array.from(o().encode(t))}catch{throw new c("ENV_INVALID","x402 pay: the Solana wallet key must be a base58 secret key or a JSON byte array.")}if(r.length===64)return a(r);if(r.length===32)return i(r);throw new c("ENV_INVALID",`x402 pay: the Solana wallet key must decode to 32 or 64 bytes (got ${String(r.length)}). Provide a base58 secret key or a JSON byte array.`)},_=async(e,t,a)=>{const i=f(t.network),{signer:o}=t,r=x(t.network);let s;if(o.type==="signer")g(o.signer,r),s=o.signer;else if(o.type==="cdp"){if(!r)throw new c("NOT_IMPLEMENTED",`x402 pay: CDP-managed Solana custody (account "${o.account}") is not wired — a CDP Solana account is not a @solana/kit signer. Build a @solana/kit signer around it and pass it via the { type: "signer" } escape hatch, or use "raw-key".`);s=await I(o,a.getSecret)}else{const n=await p(a.getSecret,o.secretName);s=r?await v(n):await V(n)}if(r){const{registerExactEvmScheme:n}=await l(()=>import("@x402/evm/exact/client"),"x402 pay: EVM networks need the optional @x402/evm + viem peers — install them, or configure an SVM network.");n(e,{networks:[i],signer:s})}else{const{registerExactSvmScheme:n}=await l(()=>import("@x402/svm/exact/client"),"x402 pay: SVM networks need the optional @x402/svm + @solana/kit peers — install them, or configure an EVM network.");n(e,{networks:[i],signer:s})}},b=async(e,t)=>{E(e.policy);const a=A(),i=S(e.policy),o=k(e.policy,a),r=N(a),s=new h;await _(s,e,t),s.registerPolicy(i),s.onBeforePaymentCreation(o),s.onPaymentCreationFailure(r);const n=t.fetch??globalThis.fetch,w=u(n,s);return async(y,d)=>{const m=new Headers(d?.headers??(y instanceof Request?y.headers:void 0));return m.has("PAYMENT-SIGNATURE")||m.has("X-PAYMENT")?n(y,d):w(y,d)}},D=async(e,t)=>({fetch:await b(e,t)}),K=(e,t)=>{let a;return{fetch:async(o,r)=>(a??=D(e,t),(await a).fetch(o,r))}};export{B as DEFAULT_ALLOWED_ASSETS,G as DEFAULT_FACILITATOR_URL,W as DEFAULT_STABLECOIN_DECIMALS,D as createX402Pay,x as isEvmNetwork,Y as isSvmNetwork,K as lazyX402Pay,q as resolveFacilitatorUrl,f as toCaip2,$ as usdToAtomic};