@devlab.group/agent-commerce 2.2.1 → 2.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +20 -16
- package/dist/ap2.d.ts +6 -5
- package/dist/ap2.js +3 -3
- package/dist/{authorization-CMkIuAkO.d.ts → authorization-DjAecwuW.d.ts} +1 -1
- package/dist/{chunk-REBY2IEP.js → chunk-4OEXK3YG.js} +4 -4
- package/dist/{chunk-REBY2IEP.js.map → chunk-4OEXK3YG.js.map} +1 -1
- package/dist/{chunk-2DAJAJI7.js → chunk-6WACRJVT.js} +3 -3
- package/dist/{chunk-2DAJAJI7.js.map → chunk-6WACRJVT.js.map} +1 -1
- package/dist/{chunk-XYHDQ22D.js → chunk-AITMDXKW.js} +3 -3
- package/dist/{chunk-XYHDQ22D.js.map → chunk-AITMDXKW.js.map} +1 -1
- package/dist/{chunk-BNUD4RBN.js → chunk-WUIAUAA7.js} +200 -8
- package/dist/chunk-WUIAUAA7.js.map +1 -0
- package/dist/cli/{ap2-HLBIUSTK.js → ap2-QDHPRSTF.js} +3 -3
- package/dist/cli/{ap2-HLBIUSTK.js.map → ap2-QDHPRSTF.js.map} +1 -1
- package/dist/cli/{chunk-QZ6TOMX6.js → chunk-AZDWFVDW.js} +200 -8
- package/dist/cli/chunk-AZDWFVDW.js.map +1 -0
- package/dist/cli/{chunk-SNM3OVCY.js → chunk-DCMW67JM.js} +19 -5
- package/dist/cli/chunk-DCMW67JM.js.map +1 -0
- package/dist/cli/{chunk-ILUYEQSV.js → chunk-G2JEY7MB.js} +26 -9
- package/dist/cli/chunk-G2JEY7MB.js.map +1 -0
- package/dist/cli/{chunk-2LN5PO5I.js → chunk-PIMFPCNZ.js} +3 -2
- package/dist/cli/chunk-PIMFPCNZ.js.map +1 -0
- package/dist/cli/chunk-UXB65XCS.js +8 -0
- package/dist/cli/{chunk-QY3K6PEQ.js.map → chunk-UXB65XCS.js.map} +1 -1
- package/dist/cli/{chunk-KTV52MCU.js → chunk-WYOGIANL.js} +3 -3
- package/dist/cli/{chunk-KTV52MCU.js.map → chunk-WYOGIANL.js.map} +1 -1
- package/dist/cli/{config-VYAJGZXE.js → config-UI4EDG4L.js} +5 -5
- package/dist/cli/{config-VYAJGZXE.js.map → config-UI4EDG4L.js.map} +1 -1
- package/dist/cli/index.js +98 -12
- package/dist/cli/index.js.map +1 -1
- package/dist/cli/{mcp-HFD7ZNCQ.js → mcp-26LJMN4N.js} +3 -3
- package/dist/cli/{mcp-HFD7ZNCQ.js.map → mcp-26LJMN4N.js.map} +1 -1
- package/dist/cli/{provider-JV5HCQGR.js → provider-Z4OJNAYI.js} +5 -5
- package/dist/cli/{provider-JV5HCQGR.js.map → provider-Z4OJNAYI.js.map} +1 -1
- package/dist/cli/{run-WV44B62Y.js → run-TEPYJUHG.js} +33 -12
- package/dist/cli/run-TEPYJUHG.js.map +1 -0
- package/dist/cli/{x402-NADFV5CD.js → x402-BMVONZKA.js} +6 -6
- package/dist/cli/{x402-NADFV5CD.js.map → x402-BMVONZKA.js.map} +1 -1
- package/dist/{constants-nackLItD.d.ts → constants-BG22tE8S.d.ts} +2 -1
- package/dist/index.d.ts +35 -12
- package/dist/index.js +61 -11
- package/dist/index.js.map +1 -1
- package/dist/mcp.d.ts +5 -4
- package/dist/mcp.js +1 -1
- package/dist/mpp.d.ts +5 -4
- package/dist/mpp.js +3 -3
- package/dist/{networks-DTWRlj-K.d.ts → networks-DDHYJLcg.d.ts} +2 -1
- package/dist/{protocol-adapter-CfxU8Z2T.d.ts → protocol-adapter-C9odYl6l.d.ts} +4 -3
- package/dist/{runtime-7vLNYvmU.d.ts → runtime-Cl_BLVZV.d.ts} +8 -1
- package/dist/{types-CVw6Sf46.d.ts → types-j7MnUXYN.d.ts} +2 -1
- package/dist/x402.d.ts +27 -18
- package/dist/x402.js +4 -4
- package/package.json +6 -6
- package/dist/chunk-BNUD4RBN.js.map +0 -1
- package/dist/cli/chunk-2LN5PO5I.js.map +0 -1
- package/dist/cli/chunk-ILUYEQSV.js.map +0 -1
- package/dist/cli/chunk-QY3K6PEQ.js +0 -8
- package/dist/cli/chunk-QZ6TOMX6.js.map +0 -1
- package/dist/cli/chunk-SNM3OVCY.js.map +0 -1
- package/dist/cli/index.d.ts +0 -1
- package/dist/cli/run-WV44B62Y.js.map +0 -1
package/README.md
CHANGED
|
@@ -279,16 +279,17 @@ See [docs/configuration.md](docs/configuration.md).
|
|
|
279
279
|
|
|
280
280
|
## Protocol support
|
|
281
281
|
|
|
282
|
-
| Protocol
|
|
283
|
-
|
|
|
284
|
-
| **HTTP**
|
|
285
|
-
| **MCP**
|
|
286
|
-
| **x402**
|
|
287
|
-
| **MPP**
|
|
288
|
-
| **A2A**
|
|
289
|
-
| **ACP**
|
|
290
|
-
| **AP2**
|
|
291
|
-
|
|
|
282
|
+
| Protocol | Status | Pinned revision |
|
|
283
|
+
| ------------ | ------------ | ------------------------------------------------------------------------------------------------------------ |
|
|
284
|
+
| **HTTP** | Supported | native routes |
|
|
285
|
+
| **MCP** | Supported | `2026-07-28` and `2025-11-25`, `@modelcontextprotocol/server@2.3.0` |
|
|
286
|
+
| **x402** | Supported | x402 v2 (`@x402/core`, `@x402/evm`, `@x402/svm`, `@x402/near`), scheme `exact`, EVM and Solana; NEAR partial |
|
|
287
|
+
| **MPP** | Experimental | `mppx@0.13.1`, `charge` + `evm` + EIP-3009, USDC on Base Sepolia and Base |
|
|
288
|
+
| **A2A** | Experimental | A2A v1.0.1, binding `JSONRPC`, method `SendMessage`, x402 extension |
|
|
289
|
+
| **ACP** | Experimental | ACP `2026-04-17`, REST checkout + discovery |
|
|
290
|
+
| **AP2** | Experimental | AP2 `v0.2.0`, Direct Checkout Mandate verification |
|
|
291
|
+
| **ERC-8409** | Experimental | draft `SergeevDmitry/ERCs@0ee33230`: signed quotes on x402 EVM offers |
|
|
292
|
+
| UCP | Planned | no implementation |
|
|
292
293
|
|
|
293
294
|
[AP2](docs/protocols/ap2.md) is an authorization method, not a transport. It verifies a
|
|
294
295
|
mandate before a paid resource settles; the gateway does not issue the mandate
|
|
@@ -296,7 +297,8 @@ or its Checkout Receipt.
|
|
|
296
297
|
|
|
297
298
|
The experimental entries above ship off by default with documented subsets:
|
|
298
299
|
[A2A](docs/protocols/a2a.md), [ACP](docs/protocols/acp.md),
|
|
299
|
-
[AP2](docs/protocols/ap2.md#not-implemented)
|
|
300
|
+
[AP2](docs/protocols/ap2.md#not-implemented), [MPP](docs/protocols/mpp.md) and
|
|
301
|
+
[ERC-8409 quotes](docs/protocols/x402.md#erc-8409-signed-quotes). Supported
|
|
300
302
|
[MCP](docs/protocols/mcp.md) and [x402](docs/protocols/x402.md) are also scoped.
|
|
301
303
|
ACP exposes only its five checkout operations; merchant `payment_data` is never
|
|
302
304
|
converted into a gateway payment proof.
|
|
@@ -308,7 +310,8 @@ prints the `unsupported` lists for A2A, ACP and AP2 when they are enabled.
|
|
|
308
310
|
### Versioning
|
|
309
311
|
|
|
310
312
|
Minor releases may break experimental configurations, integrations or types.
|
|
311
|
-
This applies to MPP, A2A, ACP, AP2
|
|
313
|
+
This applies to MPP, A2A, ACP, AP2, ERC-8409 quotes and
|
|
314
|
+
`agent-commerce import openapi`.
|
|
312
315
|
Runtime adapters and providers report `status: experimental` in
|
|
313
316
|
`GET /.well-known/agent-commerce`. Pin an exact version and test upgrades
|
|
314
317
|
before deploying them. Since 2.1, some supported x402 behavior and types
|
|
@@ -318,7 +321,8 @@ differ from 2.0; see [Upgrading from 2.0 to 2.x](docs/migration-2.1.md).
|
|
|
318
321
|
|
|
319
322
|
- **Non-custodial.** Buyer payments go directly to the merchant address in
|
|
320
323
|
`payTo` (`recipient` for MPP). The gateway does not require buyer or merchant
|
|
321
|
-
private keys. Local facilitator mode
|
|
324
|
+
private keys. Local facilitator mode uses a separate key to pay gas.
|
|
325
|
+
Experimental ERC-8409 quotes use a dedicated, unfunded signing key.
|
|
322
326
|
- **Fail closed.** Missing, malformed, expired, replayed, wrong-amount,
|
|
323
327
|
wrong-recipient, wrong-network and wrong-asset payments are rejected.
|
|
324
328
|
- **Replay-safe twice over.** The EIP-3009 or Permit2 nonce stops a double
|
|
@@ -489,9 +493,9 @@ reachable by anyone else, know the split:
|
|
|
489
493
|
- **Agent routes** (`/api/resources/:id/invoke`, `/mcp`, the A2A mount) are
|
|
490
494
|
unauthenticated by design - paid resources are protected by payment, not by a
|
|
491
495
|
password. ACP is the exception: its checkout routes require a bearer token.
|
|
492
|
-
- **Operator routes** (`/api/receipts`, `/api/events`)
|
|
493
|
-
commerce ledger: payer addresses, amounts
|
|
494
|
-
They require `server.adminToken
|
|
496
|
+
- **Operator routes** (`/api/receipts`, `/api/events`, `/api/payment-attempts`)
|
|
497
|
+
expose the merchant's commerce ledger: payer addresses, amounts and settlement
|
|
498
|
+
hashes. They require `server.adminToken` and return **404** if none is configured.
|
|
495
499
|
- **Browsers** are governed by `server.allowedOrigins`, an explicit allowlist
|
|
496
500
|
that defaults to empty.
|
|
497
501
|
- **There is no rate limiting.** A free resource is an unauthenticated proxy to
|
package/dist/ap2.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { E as EnabledAp2Config } from './types-
|
|
2
|
-
export { A as AP2_CHECKOUT_MANDATE_VCT, a as AP2_CHECKOUT_PROFILE, b as AP2_DEFAULT_CLOCK_SKEW_SECONDS, c as AP2_MAX_CLOCK_SKEW_SECONDS, d as AP2_SIGNING_ALGORITHM, e as AP2_SPEC_VERSION, f as Ap2AuthorizationConfig, g as Ap2Mode, h as Ap2TrustedIssuer, i as Ap2TrustedKey } from './types-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import { E as EnabledAp2Config } from './types-j7MnUXYN.js';
|
|
2
|
+
export { A as AP2_CHECKOUT_MANDATE_VCT, a as AP2_CHECKOUT_PROFILE, b as AP2_DEFAULT_CLOCK_SKEW_SECONDS, c as AP2_MAX_CLOCK_SKEW_SECONDS, d as AP2_SIGNING_ALGORITHM, e as AP2_SPEC_VERSION, f as Ap2AuthorizationConfig, g as Ap2Mode, h as Ap2TrustedIssuer, i as Ap2TrustedKey } from './types-j7MnUXYN.js';
|
|
3
|
+
import { AuthorizationProvider } from './index.js';
|
|
4
|
+
import { Clock, Logger } from './index.js';
|
|
5
5
|
|
|
6
6
|
/**
|
|
7
7
|
* A private ES256 key: either a private JWK (the pair of the public one in the
|
|
@@ -158,4 +158,5 @@ interface Ap2AuthorizationProvider extends AuthorizationProvider {
|
|
|
158
158
|
}
|
|
159
159
|
declare function createAp2AuthorizationProvider(options: Ap2AuthorizationProviderOptions): Ap2AuthorizationProvider;
|
|
160
160
|
|
|
161
|
-
export { AP2_CAPABILITIES, AP2_REJECTION_REASONS, AP2_UNSUPPORTED,
|
|
161
|
+
export { AP2_CAPABILITIES, AP2_REJECTION_REASONS, AP2_UNSUPPORTED, EnabledAp2Config, createAp2AuthorizationProvider as ap2, createAp2AuthorizationProvider, createCheckoutJwt };
|
|
162
|
+
export type { Ap2AuthorizationProvider, Ap2AuthorizationProviderOptions, Ap2RejectionReason, Ap2SigningKey, CreateCheckoutJwtOptions };
|
package/dist/ap2.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { AP2_CHECKOUT_MANDATE_VCT, AP2_SIGNING_ALGORITHM, AP2_DIGEST_ALGORITHM, AP2_CHECKOUT_PROFILE, AP2_SPEC_VERSION, AP2_KEY_TYPE, AP2_JWK_CURVE, openSqliteDatabase } from './chunk-
|
|
2
|
-
export { AP2_CHECKOUT_MANDATE_VCT, AP2_CHECKOUT_PROFILE, AP2_DEFAULT_CLOCK_SKEW_SECONDS, AP2_MAX_CLOCK_SKEW_SECONDS, AP2_SIGNING_ALGORITHM, AP2_SPEC_VERSION } from './chunk-
|
|
3
|
-
import { systemClock, NOOP_LOGGER, CommerceError, PACKAGE_VERSION } from './chunk-
|
|
1
|
+
import { AP2_CHECKOUT_MANDATE_VCT, AP2_SIGNING_ALGORITHM, AP2_DIGEST_ALGORITHM, AP2_CHECKOUT_PROFILE, AP2_SPEC_VERSION, AP2_KEY_TYPE, AP2_JWK_CURVE, openSqliteDatabase } from './chunk-6WACRJVT.js';
|
|
2
|
+
export { AP2_CHECKOUT_MANDATE_VCT, AP2_CHECKOUT_PROFILE, AP2_DEFAULT_CLOCK_SKEW_SECONDS, AP2_MAX_CLOCK_SKEW_SECONDS, AP2_SIGNING_ALGORITHM, AP2_SPEC_VERSION } from './chunk-6WACRJVT.js';
|
|
3
|
+
import { systemClock, NOOP_LOGGER, CommerceError, PACKAGE_VERSION } from './chunk-AITMDXKW.js';
|
|
4
4
|
import { isRecord } from './chunk-2CJNA7MS.js';
|
|
5
5
|
import { SignJWT, importPKCS8, importJWK, jwtVerify, decodeProtectedHeader, decodeJwt } from 'jose';
|
|
6
6
|
import canonicalize from 'canonicalize';
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { g as AuthorizationMethodName, A as AdapterDescriptor, n as PaymentRequirement, c as AdapterHealth } from './runtime-
|
|
1
|
+
import { g as AuthorizationMethodName, A as AdapterDescriptor, n as PaymentRequirement, c as AdapterHealth } from './runtime-Cl_BLVZV.js';
|
|
2
2
|
|
|
3
3
|
/**
|
|
4
4
|
* Canonical authorization model. FROZEN CONTRACT.
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CommerceError } from './chunk-
|
|
1
|
+
import { CommerceError } from './chunk-AITMDXKW.js';
|
|
2
2
|
|
|
3
3
|
// src/payments/x402/networks.ts
|
|
4
4
|
var LOCAL_CHAIN_ID = 31337;
|
|
@@ -580,6 +580,6 @@ function resolveX402Option(input, path, custom) {
|
|
|
580
580
|
var X402_PAYMENT_FLOWS = ["authorization", "upfront"];
|
|
581
581
|
var X402_DEFAULT_PAYMENT_FLOW = "authorization";
|
|
582
582
|
|
|
583
|
-
export { LOCAL_CHAIN_ID, REUSE_REJECTED_AUTHORIZATION_METADATA_KEY, SETTLE_AFTER_BACKEND_METADATA_KEY, SUPPORTED_NETWORK_IDS, X402_DEFAULT_PAYMENT_FLOW, X402_PAYMENT_FLOWS, assertDevKeyIsLocalOnly, assertPayToIsNotDevAddress, describeDeploymentMode, describeRpc, findX402Network, isEvmAddress, isEvmZeroAddress, isTransactionReference, normalizeAddress, requireX402Network, resolveDeploymentMode, resolveX402Deployment, resolveX402Option, sameAddress, validateCustomNetworks, x402OfferName };
|
|
584
|
-
//# sourceMappingURL=chunk-
|
|
585
|
-
//# sourceMappingURL=chunk-
|
|
583
|
+
export { LOCAL_CHAIN_ID, REUSE_REJECTED_AUTHORIZATION_METADATA_KEY, SETTLE_AFTER_BACKEND_METADATA_KEY, SUPPORTED_NETWORK_IDS, X402_DEFAULT_PAYMENT_FLOW, X402_PAYMENT_FLOWS, assertDevKeyIsLocalOnly, assertPayToIsNotDevAddress, describeDeploymentMode, describeRpc, findX402Network, isEvmAddress, isEvmZeroAddress, isTransactionReference, isWellKnownDevKey, normalizeAddress, requireX402Network, resolveDeploymentMode, resolveX402Deployment, resolveX402Option, sameAddress, validateCustomNetworks, x402OfferName };
|
|
584
|
+
//# sourceMappingURL=chunk-4OEXK3YG.js.map
|
|
585
|
+
//# sourceMappingURL=chunk-4OEXK3YG.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/payments/x402/networks.ts","../src/core/execution/settlement-order.ts","../src/payments/x402/addresses.ts","../src/payments/x402/local-chain/accounts.ts","../src/payments/x402/dev-key-guard.ts","../src/payments/x402/guardrails.ts","../src/payments/x402/options.ts","../src/payments/x402/payment-flow.ts"],"names":["invalid"],"mappings":";;;AAiBO,IAAM,cAAA,GAAiB;AA0D9B,IAAM,IAAA,GAAO,CAAC,OAAA,EAAiB,IAAA,MAC5B,EAAE,MAAA,EAAQ,MAAA,EAAQ,OAAA,EAAS,IAAA,EAAM,OAAA,EAAS,GAAA,EAAK,QAAA,EAAU,CAAA,EAAE,CAAA;AAE9D,IAAM,QAAA,GAAmC;AAAA,EACvC;AAAA,IACE,MAAA,EAAQ,KAAA;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, EVM chain ID and\n * default stablecoin. Config load rejects unknown IDs; parsing an EVM chain\n * ID cannot establish whether it is mainnet. Merchants must declare custom\n * EVM networks under `payments.x402.networks`; built-ins cannot be redeclared.\n *\n * Profiles copy SDK asset defaults to keep config load and the CLI SDK-free.\n * Tests compare each profile with the pinned SDK tables.\n *\n * The local Anvil chain has a profile of its own, `eip155:31337` (Anvil's\n * default chain id), so the network alone tells a local deployment from a\n * public one. Local health checks still require an Anvil response, because an\n * RPC endpoint can report any chain id.\n */\nimport { CommerceError } from '../../core';\n\n/** Chain id of the local Anvil dev chain, Anvil's default */\nexport const LOCAL_CHAIN_ID = 31337;\n\nexport type X402NetworkFamily = 'evm' | 'svm' | 'near';\n\nexport type NetworkKind = 'testnet' | 'mainnet';\n\n/** An EVM network the x402 provider can settle on */\nexport interface NetworkProfile {\n /** CAIP-2 identifier, e.g. `eip155:84532` */\n readonly id: string;\n /** Signed into the buyer's EIP-712 domain */\n readonly chainId: number;\n readonly displayName: string;\n readonly kind: NetworkKind;\n /** The local Anvil dev chain, where the in-process facilitator runs */\n readonly local?: boolean;\n /**\n * Default USDC deployment and EIP-712 domain. EVM offers may name another\n * token; the local chain has no default and requires explicit token metadata.\n *\n * `name` is the signed EIP-712 domain name, not the symbol, and deployments\n * differ: `\"USDC\"` on Base Sepolia, `\"USD Coin\"` on Base.\n */\n readonly canonicalAsset?: {\n readonly symbol: string;\n readonly address: string;\n readonly name: string;\n readonly version: string;\n readonly decimals: number;\n };\n}\n\ninterface NonEvmNetwork<F extends X402NetworkFamily> {\n readonly family: F;\n readonly id: string;\n readonly displayName: string;\n readonly kind: NetworkKind;\n /** Solana mint or NEAR NEP-141 contract account, with no EIP-712 domain */\n readonly canonicalAsset: {\n readonly symbol: string;\n readonly address: string;\n readonly decimals: number;\n };\n}\n\nexport type X402Network =\n | (NetworkProfile & { readonly family: 'evm' })\n | NonEvmNetwork<'svm'>\n | NonEvmNetwork<'near'>;\n\n/** A merchant-declared EVM network, from `payments.x402.networks` */\nexport interface CustomNetworkDeclaration {\n readonly kind: NetworkKind;\n readonly displayName: string;\n}\n\nexport type CustomNetworks = Readonly<Record<string, CustomNetworkDeclaration>>;\n\nconst usdc = (address: string, name: string) =>\n ({ symbol: 'USDC', address, name, version: '2', decimals: 6 }) as const;\n\nconst PROFILES: readonly X402Network[] = [\n {\n family: 'evm',\n id: `eip155:${LOCAL_CHAIN_ID}`,\n chainId: LOCAL_CHAIN_ID,\n displayName: 'Local Anvil',\n kind: 'testnet',\n local: true,\n },\n {\n family: 'evm',\n id: 'eip155:84532',\n chainId: 84532,\n displayName: 'Base Sepolia',\n kind: 'testnet',\n canonicalAsset: usdc('0x036CbD53842c5426634e7929541eC2318f3dCF7e', 'USDC'),\n },\n {\n family: 'evm',\n id: 'eip155:8453',\n chainId: 8453,\n displayName: 'Base',\n kind: 'mainnet',\n canonicalAsset: usdc('0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913', 'USD Coin'),\n },\n {\n family: 'evm',\n id: 'eip155:1',\n chainId: 1,\n displayName: 'Ethereum',\n kind: 'mainnet',\n canonicalAsset: usdc('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', 'USD Coin'),\n },\n {\n family: 'evm',\n id: 'eip155:137',\n chainId: 137,\n displayName: 'Polygon',\n kind: 'mainnet',\n canonicalAsset: usdc('0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359', 'USD Coin'),\n },\n {\n family: 'evm',\n id: 'eip155:42161',\n chainId: 42161,\n displayName: 'Arbitrum One',\n kind: 'mainnet',\n canonicalAsset: usdc('0xaf88d065e77c8cC2239327C5EDb3A432268e5831', 'USD Coin'),\n },\n {\n family: 'evm',\n id: 'eip155:421614',\n chainId: 421614,\n displayName: 'Arbitrum Sepolia',\n kind: 'testnet',\n canonicalAsset: usdc('0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d', 'USD Coin'),\n },\n {\n family: 'evm',\n id: 'eip155:43114',\n chainId: 43114,\n displayName: 'Avalanche C-Chain',\n kind: 'mainnet',\n canonicalAsset: usdc('0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E', 'USD Coin'),\n },\n {\n family: 'svm',\n id: 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp',\n displayName: 'Solana',\n kind: 'mainnet',\n canonicalAsset: {\n symbol: 'USDC',\n address: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',\n decimals: 6,\n },\n },\n {\n family: 'svm',\n id: 'solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1',\n displayName: 'Solana Devnet',\n kind: 'testnet',\n canonicalAsset: {\n symbol: 'USDC',\n address: '4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU',\n decimals: 6,\n },\n },\n // NEAR's USDC contracts are implicit accounts: 64 lowercase hex characters\n {\n family: 'near',\n id: 'near:mainnet',\n displayName: 'NEAR',\n kind: 'mainnet',\n canonicalAsset: {\n symbol: 'USDC',\n address: '17208628f84f5d6ad33f0da3bbbeb27ffcb398eac501a31bd6ad2011e36133a1',\n decimals: 6,\n },\n },\n {\n family: 'near',\n id: 'near:testnet',\n displayName: 'NEAR Testnet',\n kind: 'testnet',\n canonicalAsset: {\n symbol: 'USDC',\n address: '3e2210e1184b45b64c8a434c0a7e7b23cc04ea7eb7a6c3c32520d03d4afcb8af',\n decimals: 6,\n },\n },\n];\n\nconst BY_ID = new Map(PROFILES.map((profile) => [profile.id, profile]));\n\n/** Built-in networks of every family, for tests and diagnostics */\nexport const BUILT_IN_NETWORKS: readonly X402Network[] = PROFILES;\n\n/** The built-in EVM networks the x402 provider settles on without a declaration */\nexport const SUPPORTED_NETWORK_IDS: readonly string[] = PROFILES.filter(\n (p) => p.family === 'evm',\n).map((p) => p.id);\n\n// A chain id viem and EIP-712 can carry as a JS number\nconst EVM_NETWORK_ID = /^eip155:([1-9]\\d{0,15})$/;\n\nfunction invalid(message: string, path: string): CommerceError {\n return new CommerceError('CONFIG_INVALID', message, { details: { path } });\n}\n\n/** Built-in EVM profile for callers using the original network interface */\nexport function findNetworkProfile(id: string): NetworkProfile | undefined {\n const profile = BY_ID.get(id);\n return profile?.family === 'evm' ? profile : undefined;\n}\n\n/** A built-in network of any family, or a declared custom EVM network */\nexport function findX402Network(id: string, custom?: CustomNetworks): X402Network | undefined {\n const builtIn = BY_ID.get(id);\n if (builtIn) return builtIn;\n const declared = custom?.[id];\n const chainId = Number(EVM_NETWORK_ID.exec(id)?.[1]);\n if (!declared || !Number.isSafeInteger(chainId)) return undefined;\n return {\n family: 'evm',\n id,\n chainId,\n displayName: declared.displayName,\n kind: declared.kind,\n };\n}\n\nexport function requireX402Network(id: string, path: string, custom?: CustomNetworks): X402Network {\n const network = findX402Network(id, custom);\n if (!network) {\n throw new CommerceError(\n 'CONFIG_INVALID',\n `${path}: \"${id}\" is not a known network. Built-in CAIP-2 identifiers: ${PROFILES.map((p) => p.id).join(', ')}. Declare another EVM network under payments.x402.networks with its kind and displayName.`,\n { details: { path, network: id } },\n );\n }\n return network;\n}\n\n/**\n * Allows only new `eip155` networks in `payments.x402.networks`. Redeclaring\n * built-ins could relabel mainnet as testnet; Solana and NEAR IDs are SDK-fixed.\n */\nexport function validateCustomNetworks(custom: CustomNetworks, path: string): void {\n for (const id of Object.keys(custom)) {\n const at = `${path}.${id}`;\n if (BY_ID.has(id)) {\n throw invalid(\n `${at}: \"${id}\" is a built-in network and cannot be redeclared; remove this entry`,\n at,\n );\n }\n if (!findX402Network(id, custom)) {\n throw invalid(\n `${at}: \"${id}\" is not an EVM CAIP-2 identifier (\"eip155:\" followed by a positive chain id below 2^53). Only EVM networks can be declared.`,\n at,\n );\n }\n }\n}\n\n/** What a deployment is: the local dev chain, or a public testnet or mainnet */\nexport type DeploymentMode = 'local' | 'testnet' | 'mainnet';\n\nexport function resolveDeploymentMode(profile: {\n readonly kind: NetworkKind;\n readonly local?: boolean;\n}): DeploymentMode {\n return profile.local ? 'local' : profile.kind;\n}\n\n// The banner an operator must not miss. Printed for mainnet only\nconst LIVE_MAINNET_BANNER = 'LIVE MAINNET MODE - REAL FUNDS';\n\nexport function describeDeploymentMode(mode: DeploymentMode): string {\n return mode === 'mainnet' ? LIVE_MAINNET_BANNER : mode.toUpperCase();\n}\n","/**\n * Set on a payment requirement to run the backend before settlement.\n * The pipeline settles first unless this metadata value is `true`.\n */\nexport const SETTLE_AFTER_BACKEND_METADATA_KEY = 'settleAfterBackend';\n\n/**\n * Set to `true` when the rail permits presenting an authorization again after\n * its attempt was rejected, which settled nothing; the chain still spends each\n * nonce once. The pipeline lets retries reclaim the rejected attempt;\n * otherwise, it refuses them as replays.\n */\nexport const REUSE_REJECTED_AUTHORIZATION_METADATA_KEY = 'reuseRejectedAuthorization';\n","/**\n * SDK-free address checks for config load and the CLI. EVM addresses compare\n * without case; Solana keys and NEAR account IDs compare exactly.\n */\nimport type { X402Network } from './networks';\n\n// `0x` + 40 hex characters. Config load cannot check the EIP-55 checksum,\n// which needs keccak-256; the x402 and MPP providers refuse a mixed-case\n// address whose checksum is wrong when they start.\nconst EVM_ADDRESS = /^0x[0-9a-fA-F]{40}$/;\nconst EVM_ZERO = /^0x0{40}$/i;\n\n/** `0x` followed by 40 hex characters, in any case */\nexport const isEvmAddress = (value: unknown): value is `0x${string}` =>\n typeof value === 'string' && EVM_ADDRESS.test(value);\n\n/** The EVM zero address, in any case */\nexport const isEvmZeroAddress = (value: string): boolean => EVM_ZERO.test(value);\n\nconst BASE58_ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';\n// A 32-byte key is 32 to 44 base58 characters\nconst SOLANA_ADDRESS = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/;\n// The all-zero key, which is the System Program and owns nothing recoverable\nconst SOLANA_ZERO = '11111111111111111111111111111111';\nconst EVM_TRANSACTION_HASH = /^0x[0-9a-fA-F]{64}$/;\n// A 64-byte Ed25519 signature is at most 88 base58 characters\nconst SOLANA_SIGNATURE = /^[1-9A-HJ-NP-Za-km-z]{64,88}$/;\n\n// nearcore's account ID rule: 2 to 64 characters, lowercase alphanumeric runs\n// joined by single \"-\", \"_\" or \".\"; implicit accounts are 64 hex characters\nconst NEAR_ACCOUNT_ID = /^(([a-z\\d]+[-_])*[a-z\\d]+\\.)*([a-z\\d]+[-_])*[a-z\\d]+$/;\n// A transaction hash: 32 bytes in base58\nconst NEAR_TRANSACTION_HASH = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/;\n\n/**\n * Returns the family's wire address or `undefined`. NEAR uses named or\n * implicit account IDs; a `.near` suffix does not identify the network.\n */\nexport function normalizeAddress(network: X402Network, value: string): string | undefined {\n switch (network.family) {\n case 'evm':\n return isEvmAddress(value) ? value : undefined;\n case 'svm':\n return SOLANA_ADDRESS.test(value) && base58ByteLength(value) === 32 ? value : undefined;\n case 'near':\n return value.length >= 2 && value.length <= 64 && NEAR_ACCOUNT_ID.test(value)\n ? value\n : undefined;\n }\n}\n\n/**\n * An address funds cannot be recovered from: the zero address of its family.\n * NEAR has no zero account.\n */\nexport function isBurnAddress(network: X402Network, wireAddress: string): boolean {\n switch (network.family) {\n case 'evm':\n return isEvmZeroAddress(wireAddress);\n case 'svm':\n return wireAddress === SOLANA_ZERO;\n case 'near':\n return false;\n }\n}\n\n/** Compare EVM addresses case-insensitively, Solana keys and NEAR account IDs exactly */\nexport function sameAddress(network: X402Network, a: string, b: string): boolean {\n return network.family === 'evm' ? a.toLowerCase() === b.toLowerCase() : a === b;\n}\n\n/**\n * A settlement reference in its family's form: an EVM transaction hash, a\n * Solana transaction signature or a NEAR transaction hash\n */\nexport function isTransactionReference(network: X402Network, value: string): boolean {\n switch (network.family) {\n case 'evm':\n return EVM_TRANSACTION_HASH.test(value);\n case 'svm':\n return SOLANA_SIGNATURE.test(value) && base58ByteLength(value) === 64;\n case 'near':\n return NEAR_TRANSACTION_HASH.test(value) && base58ByteLength(value) === 32;\n }\n}\n\nfunction base58ByteLength(value: string): number {\n let n = 0n;\n for (const char of value) n = n * 58n + BigInt(BASE58_ALPHABET.indexOf(char));\n // Each leading '1' encodes one leading zero byte\n const leadingZeros = value.length - value.replace(/^1+/, '').length;\n return leadingZeros + (n === 0n ? 0 : Math.ceil(n.toString(16).length / 2));\n}\n","/**\n * Anvil's well-known development accounts.\n *\n * LOCAL DEVELOPMENT ONLY - DO NOT FUND. The keys come from Foundry's public\n * default mnemonic (\"test test ... junk\"), so value sent to these addresses on\n * a real network can be taken by anyone.\n *\n * Index layout on the local demo chain:\n * 0 - deployer and local facilitator signer (pays gas, broadcasts settlement)\n * 1 - merchant settlement destination (`payTo`)\n * 2 - buyer (signs EIP-3009 authorizations; never held by the gateway)\n */\nexport interface AnvilWellKnownAccount {\n readonly address: `0x${string}`;\n readonly privateKey: `0x${string}`;\n}\n\n/** A fixed-length tuple, so indexing by the layout above is typed */\nexport const ANVIL_WELL_KNOWN_ACCOUNTS: readonly [\n AnvilWellKnownAccount,\n AnvilWellKnownAccount,\n AnvilWellKnownAccount,\n] = [\n {\n address: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',\n privateKey: '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80',\n },\n {\n address: '0x70997970C51812dc3A010C7d01b50e0d17dc79C8',\n privateKey: '0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d',\n },\n {\n address: '0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC',\n privateKey: '0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a',\n },\n];\n\nexport const LOCAL_FACILITATOR_ACCOUNT = ANVIL_WELL_KNOWN_ACCOUNTS[0];\nexport const LOCAL_MERCHANT_ACCOUNT = ANVIL_WELL_KNOWN_ACCOUNTS[1];\nexport const LOCAL_BUYER_ACCOUNT = ANVIL_WELL_KNOWN_ACCOUNTS[2];\n\n/** Label printed wherever a dev key appears in output, logs or manifests */\nexport const DEV_KEY_LABEL = 'LOCAL DEVELOPMENT ONLY - DO NOT FUND';\n","/**\n * Rejects well-known Anvil keys and payment destinations when the RPC host\n * does not look local or private. Their private keys are published, so anyone\n * can spend what such an address receives on a public chain.\n *\n * The check uses the RPC hostname because the local chain shares Base\n * Sepolia's chain id. Both guards run at provider construction.\n */\nimport { CommerceError } from '../../core';\nimport { ANVIL_WELL_KNOWN_ACCOUNTS } from './local-chain/accounts';\n\nconst WELL_KNOWN_DEV_KEYS: ReadonlySet<string> = new Set(\n ANVIL_WELL_KNOWN_ACCOUNTS.map((a) => a.privateKey.toLowerCase()),\n);\n\nconst WELL_KNOWN_DEV_ADDRESSES: ReadonlySet<string> = new Set(\n ANVIL_WELL_KNOWN_ACCOUNTS.map((a) => a.address.toLowerCase()),\n);\n\n// `0x` plus 64 hex characters, the only shape `privateKeyToAccount` accepts\nconst PRIVATE_KEY_SHAPE = /^0x[0-9a-fA-F]{64}$/;\n\nexport function isWellKnownDevKey(privateKey: string): boolean {\n return WELL_KNOWN_DEV_KEYS.has(privateKey.toLowerCase());\n}\n\nexport function isWellKnownDevAddress(address: string): boolean {\n return WELL_KNOWN_DEV_ADDRESSES.has(address.toLowerCase());\n}\n\n/**\n * True for loopback addresses, RFC 1918 private ranges, and bare (dot-free)\n * hostnames, such as the compose service name \"anvil\".\n *\n * Bare hostnames are treated as local without resolving them. Operators must\n * point them at a private chain.\n */\nexport function isLikelyLocalOrPrivateHost(hostname: string): boolean {\n const h = hostname.toLowerCase().replace(/^\\[|\\]$/g, '');\n if (h === 'localhost' || h === '::1') return true;\n if (/^127\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$/.test(h)) return true;\n if (/^10\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$/.test(h)) return true;\n if (/^192\\.168\\.\\d{1,3}\\.\\d{1,3}$/.test(h)) return true;\n if (/^172\\.(1[6-9]|2\\d|3[01])\\.\\d{1,3}\\.\\d{1,3}$/.test(h)) return true;\n if (!h.includes('.') && !h.includes(':')) return true; // bare hostname\n return false;\n}\n\nfunction parseHostnameOrThrow(rpcUrl: string): string {\n try {\n return new URL(rpcUrl).hostname;\n } catch (cause) {\n // Never the URL itself: RPC providers commonly put an API key in the path,\n // and this message reaches startup output and CI logs\n throw new CommerceError('CONFIG_INVALID', 'x402 provider: rpcUrl is not a valid URL', {\n cause,\n });\n }\n}\n\n/** Origin only, for diagnostics: RPC URLs often carry an API key in the path or query */\nexport function describeRpc(rpcUrl: string): string {\n try {\n return new URL(rpcUrl).origin;\n } catch {\n return '[unparseable rpcUrl]';\n }\n}\n\n/**\n * Throws CONFIG_INVALID if `signerPrivateKey` is not shaped like a private key,\n * or if it is a well-known dev key and the RPC is not local.\n *\n * The shape check runs first, so a truncated key is reported as malformed\n * instead of passing as \"not a dev key\".\n */\nexport function assertDevKeyIsLocalOnly(rpcUrl: string, signerPrivateKey: string): void {\n if (!PRIVATE_KEY_SHAPE.test(signerPrivateKey)) {\n throw new CommerceError(\n 'CONFIG_INVALID',\n 'x402 provider: facilitator.signerPrivateKey is not a well-formed private key ' +\n '(expected \"0x\" followed by exactly 64 hex characters).',\n );\n }\n\n if (!isWellKnownDevKey(signerPrivateKey)) return; // the operator's own key\n\n const hostname = parseHostnameOrThrow(rpcUrl);\n\n if (!isLikelyLocalOrPrivateHost(hostname)) {\n throw new CommerceError(\n 'CONFIG_INVALID',\n 'x402 provider: facilitator.signerPrivateKey is a well-known Anvil development key, but rpcUrl ' +\n `${describeRpc(rpcUrl)} does not look like a local/private chain. A public dev key must never sign against ` +\n 'a public network: it is instantly drainable and can grief real settlements via nonce exhaustion. ' +\n 'Use a real facilitator key for any non-local RPC, or point rpcUrl at your local/dev chain.',\n );\n }\n}\n\n/**\n * Throws CONFIG_INVALID if `payTo` is a well-known Anvil address and `rpcUrl`\n * does not look local or private.\n *\n * Guards the receiving side, in every facilitator mode. `agent-commerce init`\n * defaults `payTo` to a well-known address for the local demo, and on a real\n * network that default sends every payment where anyone can sweep it.\n */\nexport function assertPayToIsNotDevAddress(rpcUrl: string, payTo: string): void {\n if (!isWellKnownDevAddress(payTo)) return;\n\n const hostname = parseHostnameOrThrow(rpcUrl);\n\n if (!isLikelyLocalOrPrivateHost(hostname)) {\n throw new CommerceError(\n 'CONFIG_INVALID',\n `x402 provider: \"payTo\" (${payTo}) is a well-known Anvil development address, but rpcUrl ` +\n `${describeRpc(rpcUrl)} does not look like a local/private chain. The private key behind that address ` +\n 'is public knowledge, so any revenue settled to it is immediately spendable by anyone. Set ' +\n '\"payTo\" to your own merchant wallet for any non-local RPC, or point rpcUrl at your ' +\n 'local/dev chain.',\n );\n }\n}\n","/**\n * What must hold before this gateway may settle a payment on the configured\n * network. Two callers share these checks: the provider runs them at\n * construction, so a library consumer who skips our config loader still gets\n * them, and the config loader runs them, so `validate` and `doctor` report\n * them too.\n *\n * Both run before any request, because a failure found in `settle()` would\n * come after the pipeline reserved the buyer's replay key.\n *\n * Imports no peer (no viem, no `@x402/*`), so the CLI can load it.\n */\nimport { CommerceError } from '../../core';\nimport { isBurnAddress, sameAddress } from './addresses';\nimport { isLikelyLocalOrPrivateHost, isWellKnownDevAddress } from './dev-key-guard';\nimport {\n type CustomNetworks,\n type DeploymentMode,\n LOCAL_CHAIN_ID,\n requireX402Network,\n resolveDeploymentMode,\n type X402Network,\n} from './networks';\n\n/**\n * How the gateway authenticates to a remote facilitator.\n *\n * - `none`: send no credential; use it when the facilitator accepts\n * anonymous requests.\n * - `bearer`: send a static token; no extra peer package is needed.\n * - `cdp`: Coinbase Developer Platform. The optional peer `@coinbase/x402`,\n * imported only for this type, signs a fresh JWT per request.\n *\n * Any other auth type is refused at config load.\n */\nexport type FacilitatorAuth =\n | { readonly type: 'none' }\n | { readonly type: 'bearer'; readonly token: string }\n | { readonly type: 'cdp'; readonly apiKeyId: string; readonly apiKeySecret: string };\n\nexport type X402FacilitatorConfig =\n | { readonly mode: 'local'; readonly signerPrivateKey: string }\n | { readonly mode: 'remote'; readonly url: string; readonly auth: FacilitatorAuth };\n\nexport interface X402DeploymentInput {\n readonly network: string;\n readonly payTo: string;\n readonly asset: string;\n /** EIP-712 domain of the asset, as the token itself reports it */\n readonly assetName?: string;\n readonly assetVersion?: string;\n readonly facilitator: X402FacilitatorConfig;\n /** Must be `true` before anything settles on a mainnet */\n readonly allowMainnet?: boolean;\n /**\n * Must be `true` on mainnet when facilitator auth is `none`. A separate\n * decision from `allowMainnet`: it accepts settling without an account at\n * the facilitator, under its anonymous-access limits.\n */\n readonly allowUnauthenticatedFacilitator?: boolean;\n /**\n * Allow other tokens on built-in EVM networks with explicit metadata.\n * MPP config leaves this unset; Solana and NEAR still require USDC.\n */\n readonly allowOtherEvmToken?: boolean;\n /** Error-path prefix, `payments.x402` by default */\n readonly configPath?: string;\n /** Settlement-recipient field named in errors, `payTo` by default */\n readonly payToField?: string;\n /** EVM networks declared under `payments.x402.networks` */\n readonly customNetworks?: CustomNetworks;\n}\n\nexport interface X402Deployment {\n readonly profile: X402Network;\n readonly mode: DeploymentMode;\n}\n\nconst BASE_SEPOLIA = 'eip155:84532';\n\nfunction invalid(message: string, path: string): CommerceError {\n return new CommerceError('CONFIG_INVALID', message, { details: { path } });\n}\n\n/**\n * Resolves the deployment and refuses the combinations that could move real\n * money by accident. The network must resolve first; the other checks are\n * independent.\n */\nexport function resolveX402Deployment(input: X402DeploymentInput): X402Deployment {\n const at = input.configPath ?? 'payments.x402';\n const payTo = input.payToField ?? 'payTo';\n const profile = requireX402Network(input.network, `${at}.network`, input.customNetworks);\n const mode = resolveDeploymentMode(profile);\n\n // Local mode keeps a gas-paying key in the gateway process. A compromise\n // could expose that key, so mainnet requires a remote facilitator.\n if (profile.kind === 'mainnet' && input.facilitator.mode === 'local') {\n throw invalid(\n `${at}: network \"${profile.id}\" (${profile.displayName}) is a mainnet and cannot be served by facilitator.mode \"local\". A mainnet deployment must settle through a remote facilitator.`,\n `${at}.facilitator.mode`,\n );\n }\n // The in-process facilitator signs with a client built for the Anvil chain\n // id, so on any other chain every settlement would fail\n if (input.facilitator.mode === 'local' && mode !== 'local') {\n throw invalid(\n profile.id === BASE_SEPOLIA\n ? `${at}: the local Anvil chain is eip155:${LOCAL_CHAIN_ID}, Anvil's default chain id; \"${BASE_SEPOLIA}\" is public Base Sepolia. Set ${at}.network to eip155:${LOCAL_CHAIN_ID}, start Anvil with its default chain id and redeploy the local contracts (npm run chain:start, npm run chain:deploy).`\n : `${at}: facilitator.mode \"local\" serves the local Anvil chain (eip155:${LOCAL_CHAIN_ID}) only, not \"${profile.id}\" (${profile.displayName}). Use a remote facilitator.`,\n `${at}.facilitator.mode`,\n );\n }\n\n if (mode === 'mainnet' && input.allowMainnet !== true) {\n throw invalid(\n `${at}: network \"${profile.id}\" (${profile.displayName}) settles real funds. Set ${at}.allowMainnet: true to acknowledge this explicitly - it is never the default.`,\n `${at}.allowMainnet`,\n );\n }\n\n if (input.facilitator.mode === 'remote') {\n assertFacilitatorUrlIsSafe(input.facilitator.url, mode, at);\n // `@coinbase/x402` signs each request for CDP's own host and route,\n // whatever URL is configured, so no other facilitator can accept the credential\n if (input.facilitator.auth.type === 'cdp' && !isCdpFacilitatorUrl(input.facilitator.url)) {\n throw invalid(\n `${at}: facilitator.auth.type \"cdp\" signs requests for ${CDP_FACILITATOR_URL} only, so facilitator ${describeOrigin(input.facilitator.url)} cannot accept its credential. Set facilitator.url to ${CDP_FACILITATOR_URL}, or use auth.type \"bearer\" or \"none\".`,\n `${at}.facilitator.url`,\n );\n }\n // The authorization fixes recipient, amount and chain, so a facilitator\n // cannot redirect funds. A credential adds an account: rate limits, terms\n // and support. On mainnet, going without one is an explicit choice.\n if (\n mode === 'mainnet' &&\n input.facilitator.auth.type === 'none' &&\n input.allowUnauthenticatedFacilitator !== true\n ) {\n throw invalid(\n `${at}: no credential is configured for facilitator ${describeOrigin(input.facilitator.url)} on mainnet. Set ${at}.allowUnauthenticatedFacilitator: true to accept anonymous access and the facilitator's limits, or configure facilitator.auth.`,\n `${at}.allowUnauthenticatedFacilitator`,\n );\n }\n // A blank credential reaches the facilitator as \"unauthenticated\" and fails\n // every payment after the buyer signed. `${VAR:- }` resolving to whitespace\n // is the usual cause.\n for (const [field, value] of credentialFields(input.facilitator.auth)) {\n if (value.trim() === '') {\n throw invalid(\n `${at}: facilitator.auth.type is \"${input.facilitator.auth.type}\" but ${field} is empty. An empty credential is refused rather than sent.`,\n `${at}.facilitator.auth.${field}`,\n );\n }\n }\n }\n\n // The config loader's address check refuses this too; repeated here for a\n // library consumer who calls `createX402PaymentProvider` without it\n if (isBurnAddress(profile, input.payTo)) {\n throw invalid(\n `${at}: \"${payTo}\" is the zero address. Every payment settled there is destroyed.`,\n `${at}.${payTo}`,\n );\n }\n\n // Anyone can spend from a well-known Anvil address. `dev-key-guard` refuses\n // one behind a public RPC; this refuses one on any non-local deployment,\n // whose RPC host says nothing about where a remote facilitator settles.\n if (mode !== 'local' && isWellKnownDevAddress(input.payTo)) {\n throw invalid(\n `${at}: \"${payTo}\" (${input.payTo}) is a well-known Anvil development address and this is a ${mode} deployment. Anyone can spend what settles there. Set ${payTo} to your own merchant wallet.`,\n `${at}.${payTo}`,\n );\n }\n\n // Public built-ins require USDC unless the caller allows another EVM token.\n // Local and declared networks have no default asset.\n const canonical = profile.canonicalAsset;\n if (canonical) {\n if (!sameAddress(profile, input.asset, canonical.address)) {\n if (input.allowOtherEvmToken !== true || profile.family !== 'evm') {\n const rule =\n input.allowOtherEvmToken === true\n ? `Only an EVM network accepts another token; ${profile.displayName} settles only in its ${canonical.symbol}.`\n : `A built-in network settles only in its ${canonical.symbol}.`;\n throw invalid(\n `${at}: asset ${input.asset} is not ${canonical.symbol} on ${profile.displayName} (expected ${canonical.address}). ${rule}`,\n `${at}.asset`,\n );\n }\n } else {\n // Catch USDC domain mismatches before accepting payments; a wrong name\n // can fail with `invalid_exact_evm_token_name_mismatch`\n const domain = 'name' in canonical ? canonical : undefined;\n if (domain && input.assetName !== undefined && input.assetName !== domain.name) {\n throw invalid(\n `${at}: assetName \"${input.assetName}\" is not the EIP-712 domain name ${canonical.symbol} reports on ${profile.displayName} (expected \"${domain.name}\"). Every payment would be refused after the buyer signed.`,\n `${at}.assetName`,\n );\n }\n if (domain && input.assetVersion !== undefined && input.assetVersion !== domain.version) {\n throw invalid(\n `${at}: assetVersion \"${input.assetVersion}\" is not the EIP-712 domain version ${canonical.symbol} reports on ${profile.displayName} (expected \"${domain.version}\").`,\n `${at}.assetVersion`,\n );\n }\n }\n }\n\n return { profile, mode };\n}\n\n/**\n * A facilitator sees every payment authorization this gateway handles. Plain\n * HTTP puts those on the wire in the clear and lets anyone in the path rewrite\n * a settlement result, so it is allowed only to a local or private host, and\n * never on a mainnet.\n */\nfunction assertFacilitatorUrlIsSafe(url: string, mode: DeploymentMode, at: string): void {\n let parsed: URL;\n try {\n parsed = new URL(url);\n } catch (cause) {\n throw new CommerceError('CONFIG_INVALID', `${at}: facilitator.url is not a valid URL`, {\n cause,\n details: { path: `${at}.facilitator.url` },\n });\n }\n\n if (parsed.protocol === 'https:') return;\n if (parsed.protocol !== 'http:') {\n throw invalid(\n `${at}: facilitator ${describeOrigin(url)} must be reached over https (or http on a local/private host); got \"${parsed.protocol}//\"`,\n `${at}.facilitator.url`,\n );\n }\n if (mode !== 'mainnet' && isLikelyLocalOrPrivateHost(parsed.hostname)) return;\n\n // The origin, never the whole URL: the path can carry a tenant or an API\n // key, and this message reaches `validate`, `doctor`, startup output and CI logs\n throw invalid(\n `${at}: facilitator ${describeOrigin(url)} is reached over plain HTTP. Payment authorizations and settlement results would travel unencrypted. Use https, or point at a local/private host on a non-mainnet deployment.`,\n `${at}.facilitator.url`,\n );\n}\n\n/** The facilitator URL `@coinbase/x402` signs its JWTs for */\nexport const CDP_FACILITATOR_URL = 'https://api.cdp.coinbase.com/platform/v2/x402';\n\n// The SDK client strips trailing slashes before appending its route\nfunction isCdpFacilitatorUrl(url: string): boolean {\n try {\n const parsed = new URL(url);\n const expected = new URL(CDP_FACILITATOR_URL);\n return (\n parsed.origin === expected.origin &&\n parsed.pathname.replace(/\\/+$/, '') === expected.pathname &&\n parsed.search === ''\n );\n } catch {\n return false;\n }\n}\n\n// Origin only: a facilitator URL can carry a tenant path or an API key\nfunction describeOrigin(url: string): string {\n try {\n return new URL(url).origin;\n } catch {\n return '[unparseable facilitator.url]';\n }\n}\n\n// The secret-bearing fields of an auth block, for emptiness checks only. Never logged\nfunction credentialFields(auth: FacilitatorAuth): readonly (readonly [string, string])[] {\n switch (auth.type) {\n case 'bearer':\n return [['token', auth.token]];\n case 'cdp':\n return [\n ['apiKeyId', auth.apiKeyId],\n ['apiKeySecret', auth.apiKeySecret],\n ];\n default:\n return [];\n }\n}\n","/**\n * Resolves an x402 option into offer terms at config load, so `validate`\n * reports invalid options before startup. This module uses no SDK.\n *\n * Omitted assets use `canonicalAsset`. Overrides for the default token must\n * match its metadata; another token needs its own, including the EIP-712 domain\n * on EVM.\n */\nimport { CommerceError } from '../../core';\nimport { isBurnAddress, normalizeAddress, sameAddress } from './addresses';\nimport { type CustomNetworks, requireX402Network, type X402Network } from './networks';\n\nexport interface X402OptionInput {\n readonly scheme?: string;\n readonly network: string;\n readonly payTo: string;\n readonly asset?: string;\n readonly assetName?: string;\n readonly assetVersion?: string;\n readonly assetDecimals?: number;\n /** `eip3009` (the default) or `permit2`; EVM only */\n readonly assetTransferMethod?: string;\n}\n\nexport interface ResolvedX402Option {\n readonly scheme: 'exact';\n readonly network: X402Network;\n readonly payTo: string;\n readonly asset: string;\n /** EIP-712 domain; EVM only */\n readonly assetName?: string;\n readonly assetVersion?: string;\n readonly assetDecimals: number;\n /**\n * Default token symbol when `asset` is omitted; resource prices must use\n * this symbol or USD\n */\n readonly defaultAssetSymbol?: string;\n /** How the buyer authorizes the transfer; always `eip3009` off EVM */\n readonly assetTransferMethod: X402AssetTransferMethod;\n}\n\n/**\n * Names health components by network, asset and payee for discovery matching.\n * Lowercase EVM addresses so case variants identify the same offer.\n */\nexport function x402OfferName(offer: {\n readonly network: string;\n readonly asset: string;\n readonly payTo: string;\n}): string {\n const evm = offer.network.startsWith('eip155:');\n const address = (value: string) => (evm ? value.toLowerCase() : value);\n return `${offer.network} ${address(offer.asset)} ${address(offer.payTo)}`;\n}\n\n/** EIP-3009 `transferWithAuthorization`, or Permit2 with a prior token allowance */\nexport type X402AssetTransferMethod = 'eip3009' | 'permit2';\n\n// Incorrect EIP-712 domain values invalidate the buyer's signature\nconst FIELD_MEANINGS = {\n assetName: 'EIP-712 domain name',\n assetVersion: 'EIP-712 domain version',\n assetDecimals: 'decimals',\n} as const;\n\nconst ADDRESS_SHAPES = {\n evm: '\"0x\" followed by 40 hex characters',\n svm: 'a base58 public key of 32 bytes',\n near: 'a NEAR account ID: 2 to 64 lowercase characters, digits and single \"-\", \"_\" or \".\" separators',\n} as const;\n\nfunction invalid(message: string, path: string): CommerceError {\n return new CommerceError('CONFIG_INVALID', message, { details: { path } });\n}\n\nexport function resolveX402Option(\n input: X402OptionInput,\n path: string,\n custom?: CustomNetworks,\n): ResolvedX402Option {\n if (input.scheme !== undefined && input.scheme !== 'exact') {\n throw invalid(\n `${path}.scheme: \"${input.scheme}\" is not supported; the only x402 scheme is \"exact\"`,\n `${path}.scheme`,\n );\n }\n const network = requireX402Network(input.network, `${path}.network`, custom);\n const address = (field: 'payTo' | 'asset', value: string): string => {\n const wire = normalizeAddress(network, value);\n if (wire === undefined) {\n throw invalid(\n // The value is not echoed: a swapped variable could put a key here\n `${path}.${field} is not a plausible address on ${network.displayName} (expected ${ADDRESS_SHAPES[network.family]})`,\n `${path}.${field}`,\n );\n }\n return wire;\n };\n\n const payTo = address('payTo', input.payTo);\n if (isBurnAddress(network, payTo)) {\n throw invalid(\n `${path}.payTo is the zero address of ${network.displayName}. Every payment settled there is destroyed.`,\n `${path}.payTo`,\n );\n }\n\n const method = input.assetTransferMethod ?? 'eip3009';\n if (method !== 'eip3009' && method !== 'permit2') {\n throw invalid(\n `${path}.assetTransferMethod: \"${method}\" is not supported; use \"eip3009\" or \"permit2\"`,\n `${path}.assetTransferMethod`,\n );\n }\n if (network.family !== 'evm' && input.assetTransferMethod !== undefined) {\n throw invalid(\n `${path}.assetTransferMethod applies to EVM networks only, not to ${network.displayName}`,\n `${path}.assetTransferMethod`,\n );\n }\n\n if (network.family !== 'evm') {\n for (const field of ['assetName', 'assetVersion'] as const) {\n if (input[field] !== undefined) {\n throw invalid(\n `${path}.${field}: an EIP-712 domain applies to EVM tokens only, not to ${network.displayName}`,\n `${path}.${field}`,\n );\n }\n }\n }\n\n const canonical = network.canonicalAsset;\n const domain = canonical && 'name' in canonical ? canonical : undefined;\n\n const asset = input.asset !== undefined ? address('asset', input.asset) : undefined;\n if (asset !== undefined && isBurnAddress(network, asset)) {\n throw invalid(`${path}.asset must not be the zero address`, `${path}.asset`);\n }\n\n // The default asset applies when the option names none or names it exactly\n if (canonical && (asset === undefined || sameAddress(network, asset, canonical.address))) {\n const expected = {\n assetName: domain?.name,\n assetVersion: domain?.version,\n assetDecimals: canonical.decimals,\n };\n for (const field of ['assetName', 'assetVersion', 'assetDecimals'] as const) {\n const given = input[field];\n if (given !== undefined && given !== expected[field]) {\n throw invalid(\n `${path}.${field} does not match ${canonical.symbol} on ${network.displayName}, which reports ${FIELD_MEANINGS[field]} ${JSON.stringify(expected[field])}. Remove ${field}, or set asset to the token it describes.`,\n `${path}.${field}`,\n );\n }\n }\n return {\n scheme: 'exact',\n network,\n payTo,\n asset: asset ?? canonical.address,\n ...(domain ? { assetName: domain.name, assetVersion: domain.version } : {}),\n assetDecimals: canonical.decimals,\n defaultAssetSymbol: canonical.symbol,\n assetTransferMethod: method,\n };\n }\n\n // Another token: nothing about it can be borrowed from the default. The\n // token's EIP-712 domain matters to EIP-3009 only: a Permit2 buyer signs\n // Permit2's own domain.\n const required =\n network.family === 'evm' && method === 'eip3009'\n ? (['asset', 'assetName', 'assetVersion', 'assetDecimals'] as const)\n : (['asset', 'assetDecimals'] as const);\n const missing = required.filter((field) => input[field] === undefined);\n if (asset === undefined || missing.length > 0) {\n throw invalid(\n canonical\n ? `${path}: a token other than ${canonical.symbol} on ${network.displayName} needs ${missing.join(', ')}`\n : `${path}: ${network.displayName} has no default asset, so the option needs ${missing.join(', ')}`,\n `${path}.${missing[0] ?? 'asset'}`,\n );\n }\n return {\n scheme: 'exact',\n network,\n payTo,\n asset,\n ...(input.assetName !== undefined ? { assetName: input.assetName } : {}),\n ...(input.assetVersion !== undefined ? { assetVersion: input.assetVersion } : {}),\n assetDecimals: input.assetDecimals as number,\n assetTransferMethod: method,\n };\n}\n","/**\n * x402 exact-scheme flows, shared by the config loader and CLI.\n * The default `authorization` flow settles after a successful backend call;\n * `upfront` settles first.\n */\nexport const X402_PAYMENT_FLOWS = ['authorization', 'upfront'] as const;\n\nexport type X402PaymentFlow = (typeof X402_PAYMENT_FLOWS)[number];\n\nexport const X402_DEFAULT_PAYMENT_FLOW: X402PaymentFlow = 'authorization';\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/payments/x402/networks.ts","../src/core/execution/settlement-order.ts","../src/payments/x402/addresses.ts","../src/payments/x402/local-chain/accounts.ts","../src/payments/x402/dev-key-guard.ts","../src/payments/x402/guardrails.ts","../src/payments/x402/options.ts","../src/payments/x402/payment-flow.ts"],"names":["invalid"],"mappings":";;;AAiBO,IAAM,cAAA,GAAiB;AA0D9B,IAAM,IAAA,GAAO,CAAC,OAAA,EAAiB,IAAA,MAC5B,EAAE,MAAA,EAAQ,MAAA,EAAQ,OAAA,EAAS,IAAA,EAAM,OAAA,EAAS,GAAA,EAAK,QAAA,EAAU,CAAA,EAAE,CAAA;AAE9D,IAAM,QAAA,GAAmC;AAAA,EACvC;AAAA,IACE,MAAA,EAAQ,KAAA;AAAA,IACR,EAAA,EAAI,UAAU,cAAc,CAAA,CAAA;AAAA,IAC5B,OAAA,EAAS,cAAA;AAAA,IACT,WAAA,EAAa,aAAA;AAAA,IACb,IAAA,EAAM,SAAA;AAAA,IACN,KAAA,EAAO;AAAA,GACT;AAAA,EACA;AAAA,IACE,MAAA,EAAQ,KAA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,KAAA,KAAU,MAAA,IAAa,OAAA,CAAQ,MAAA,GAAS,CAAA,EAAG;AAC7C,IAAA,MAAMA,QAAAA;AAAA,MACJ,SAAA,GACI,CAAA,EAAG,IAAI,CAAA,qBAAA,EAAwB,SAAA,CAAU,MAAM,CAAA,IAAA,EAAO,OAAA,CAAQ,WAAW,CAAA,OAAA,EAAU,OAAA,CAAQ,IAAA,CAAK,IAAI,CAAC,CAAA,CAAA,GACrG,CAAA,EAAG,IAAI,CAAA,EAAA,EAAK,OAAA,CAAQ,WAAW,CAAA,2CAAA,EAA8C,OAAA,CAAQ,IAAA,CAAK,IAAI,CAAC,CAAA,CAAA;AAAA,MACnG,GAAG,IAAI,CAAA,CAAA,EAAI,OAAA,CAAQ,CAAC,KAAK,OAAO,CAAA;AAAA,KAClC;AAAA,EACF;AACA,EAAA,OAAO;AAAA,IACL,MAAA,EAAQ,OAAA;AAAA,IACR,OAAA;AAAA,IACA,KAAA;AAAA,IACA,KAAA;AAAA,IACA,GAAI,MAAM,SAAA,KAAc,MAAA,GAAY,EAAE,SAAA,EAAW,KAAA,CAAM,SAAA,EAAU,GAAI,EAAC;AAAA,IACtE,GAAI,MAAM,YAAA,KAAiB,MAAA,GAAY,EAAE,YAAA,EAAc,KAAA,CAAM,YAAA,EAAa,GAAI,EAAC;AAAA,IAC/E,eAAe,KAAA,CAAM,aAAA;AAAA,IACrB,mBAAA,EAAqB;AAAA,GACvB;AACF;;;AC9LO,IAAM,kBAAA,GAAqB,CAAC,eAAA,EAAiB,SAAS;AAItD,IAAM,yBAAA,GAA6C","file":"chunk-4OEXK3YG.js","sourcesContent":["/**\n * Network profiles: family, display name, environment, EVM chain ID and\n * default stablecoin. Config load rejects unknown IDs; parsing an EVM chain\n * ID cannot establish whether it is mainnet. Merchants must declare custom\n * EVM networks under `payments.x402.networks`; built-ins cannot be redeclared.\n *\n * Profiles copy SDK asset defaults to keep config load and the CLI SDK-free.\n * Tests compare each profile with the pinned SDK tables.\n *\n * The local Anvil chain has a profile of its own, `eip155:31337` (Anvil's\n * default chain id), so the network alone tells a local deployment from a\n * public one. Local health checks still require an Anvil response, because an\n * RPC endpoint can report any chain id.\n */\nimport { CommerceError } from '../../core';\n\n/** Chain id of the local Anvil dev chain, Anvil's default */\nexport const LOCAL_CHAIN_ID = 31337;\n\nexport type X402NetworkFamily = 'evm' | 'svm' | 'near';\n\nexport type NetworkKind = 'testnet' | 'mainnet';\n\n/** An EVM network the x402 provider can settle on */\nexport interface NetworkProfile {\n /** CAIP-2 identifier, e.g. `eip155:84532` */\n readonly id: string;\n /** Signed into the buyer's EIP-712 domain */\n readonly chainId: number;\n readonly displayName: string;\n readonly kind: NetworkKind;\n /** The local Anvil dev chain, where the in-process facilitator runs */\n readonly local?: boolean;\n /**\n * Default USDC deployment and EIP-712 domain. EVM offers may name another\n * token; the local chain has no default and requires explicit token metadata.\n *\n * `name` is the signed EIP-712 domain name, not the symbol, and deployments\n * differ: `\"USDC\"` on Base Sepolia, `\"USD Coin\"` on Base.\n */\n readonly canonicalAsset?: {\n readonly symbol: string;\n readonly address: string;\n readonly name: string;\n readonly version: string;\n readonly decimals: number;\n };\n}\n\ninterface NonEvmNetwork<F extends X402NetworkFamily> {\n readonly family: F;\n readonly id: string;\n readonly displayName: string;\n readonly kind: NetworkKind;\n /** Solana mint or NEAR NEP-141 contract account, with no EIP-712 domain */\n readonly canonicalAsset: {\n readonly symbol: string;\n readonly address: string;\n readonly decimals: number;\n };\n}\n\nexport type X402Network =\n | (NetworkProfile & { readonly family: 'evm' })\n | NonEvmNetwork<'svm'>\n | NonEvmNetwork<'near'>;\n\n/** A merchant-declared EVM network, from `payments.x402.networks` */\nexport interface CustomNetworkDeclaration {\n readonly kind: NetworkKind;\n readonly displayName: string;\n}\n\nexport type CustomNetworks = Readonly<Record<string, CustomNetworkDeclaration>>;\n\nconst usdc = (address: string, name: string) =>\n ({ symbol: 'USDC', address, name, version: '2', decimals: 6 }) as const;\n\nconst PROFILES: readonly X402Network[] = [\n {\n family: 'evm',\n id: `eip155:${LOCAL_CHAIN_ID}`,\n chainId: LOCAL_CHAIN_ID,\n displayName: 'Local Anvil',\n kind: 'testnet',\n local: true,\n },\n {\n family: 'evm',\n id: 'eip155:84532',\n chainId: 84532,\n displayName: 'Base Sepolia',\n kind: 'testnet',\n canonicalAsset: usdc('0x036CbD53842c5426634e7929541eC2318f3dCF7e', 'USDC'),\n },\n {\n family: 'evm',\n id: 'eip155:8453',\n chainId: 8453,\n displayName: 'Base',\n kind: 'mainnet',\n canonicalAsset: usdc('0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913', 'USD Coin'),\n },\n {\n family: 'evm',\n id: 'eip155:1',\n chainId: 1,\n displayName: 'Ethereum',\n kind: 'mainnet',\n canonicalAsset: usdc('0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48', 'USD Coin'),\n },\n {\n family: 'evm',\n id: 'eip155:137',\n chainId: 137,\n displayName: 'Polygon',\n kind: 'mainnet',\n canonicalAsset: usdc('0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359', 'USD Coin'),\n },\n {\n family: 'evm',\n id: 'eip155:42161',\n chainId: 42161,\n displayName: 'Arbitrum One',\n kind: 'mainnet',\n canonicalAsset: usdc('0xaf88d065e77c8cC2239327C5EDb3A432268e5831', 'USD Coin'),\n },\n {\n family: 'evm',\n id: 'eip155:421614',\n chainId: 421614,\n displayName: 'Arbitrum Sepolia',\n kind: 'testnet',\n canonicalAsset: usdc('0x75faf114eafb1BDbe2F0316DF893fd58CE46AA4d', 'USD Coin'),\n },\n {\n family: 'evm',\n id: 'eip155:43114',\n chainId: 43114,\n displayName: 'Avalanche C-Chain',\n kind: 'mainnet',\n canonicalAsset: usdc('0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E', 'USD Coin'),\n },\n {\n family: 'svm',\n id: 'solana:5eykt4UsFv8P8NJdTREpY1vzqKqZKvdp',\n displayName: 'Solana',\n kind: 'mainnet',\n canonicalAsset: {\n symbol: 'USDC',\n address: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',\n decimals: 6,\n },\n },\n {\n family: 'svm',\n id: 'solana:EtWTRABZaYq6iMfeYKouRu166VU2xqa1',\n displayName: 'Solana Devnet',\n kind: 'testnet',\n canonicalAsset: {\n symbol: 'USDC',\n address: '4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU',\n decimals: 6,\n },\n },\n // NEAR's USDC contracts are implicit accounts: 64 lowercase hex characters\n {\n family: 'near',\n id: 'near:mainnet',\n displayName: 'NEAR',\n kind: 'mainnet',\n canonicalAsset: {\n symbol: 'USDC',\n address: '17208628f84f5d6ad33f0da3bbbeb27ffcb398eac501a31bd6ad2011e36133a1',\n decimals: 6,\n },\n },\n {\n family: 'near',\n id: 'near:testnet',\n displayName: 'NEAR Testnet',\n kind: 'testnet',\n canonicalAsset: {\n symbol: 'USDC',\n address: '3e2210e1184b45b64c8a434c0a7e7b23cc04ea7eb7a6c3c32520d03d4afcb8af',\n decimals: 6,\n },\n },\n];\n\nconst BY_ID = new Map(PROFILES.map((profile) => [profile.id, profile]));\n\n/** Built-in networks of every family, for tests and diagnostics */\nexport const BUILT_IN_NETWORKS: readonly X402Network[] = PROFILES;\n\n/** The built-in EVM networks the x402 provider settles on without a declaration */\nexport const SUPPORTED_NETWORK_IDS: readonly string[] = PROFILES.filter(\n (p) => p.family === 'evm',\n).map((p) => p.id);\n\n// A chain id viem and EIP-712 can carry as a JS number\nconst EVM_NETWORK_ID = /^eip155:([1-9]\\d{0,15})$/;\n\nfunction invalid(message: string, path: string): CommerceError {\n return new CommerceError('CONFIG_INVALID', message, { details: { path } });\n}\n\n/** Built-in EVM profile for callers using the original network interface */\nexport function findNetworkProfile(id: string): NetworkProfile | undefined {\n const profile = BY_ID.get(id);\n return profile?.family === 'evm' ? profile : undefined;\n}\n\n/** A built-in network of any family, or a declared custom EVM network */\nexport function findX402Network(id: string, custom?: CustomNetworks): X402Network | undefined {\n const builtIn = BY_ID.get(id);\n if (builtIn) return builtIn;\n const declared = custom?.[id];\n const chainId = Number(EVM_NETWORK_ID.exec(id)?.[1]);\n if (!declared || !Number.isSafeInteger(chainId)) return undefined;\n return {\n family: 'evm',\n id,\n chainId,\n displayName: declared.displayName,\n kind: declared.kind,\n };\n}\n\nexport function requireX402Network(id: string, path: string, custom?: CustomNetworks): X402Network {\n const network = findX402Network(id, custom);\n if (!network) {\n throw new CommerceError(\n 'CONFIG_INVALID',\n `${path}: \"${id}\" is not a known network. Built-in CAIP-2 identifiers: ${PROFILES.map((p) => p.id).join(', ')}. Declare another EVM network under payments.x402.networks with its kind and displayName.`,\n { details: { path, network: id } },\n );\n }\n return network;\n}\n\n/**\n * Allows only new `eip155` networks in `payments.x402.networks`. Redeclaring\n * built-ins could relabel mainnet as testnet; Solana and NEAR IDs are SDK-fixed.\n */\nexport function validateCustomNetworks(custom: CustomNetworks, path: string): void {\n for (const id of Object.keys(custom)) {\n const at = `${path}.${id}`;\n if (BY_ID.has(id)) {\n throw invalid(\n `${at}: \"${id}\" is a built-in network and cannot be redeclared; remove this entry`,\n at,\n );\n }\n if (!findX402Network(id, custom)) {\n throw invalid(\n `${at}: \"${id}\" is not an EVM CAIP-2 identifier (\"eip155:\" followed by a positive chain id below 2^53). Only EVM networks can be declared.`,\n at,\n );\n }\n }\n}\n\n/** What a deployment is: the local dev chain, or a public testnet or mainnet */\nexport type DeploymentMode = 'local' | 'testnet' | 'mainnet';\n\nexport function resolveDeploymentMode(profile: {\n readonly kind: NetworkKind;\n readonly local?: boolean;\n}): DeploymentMode {\n return profile.local ? 'local' : profile.kind;\n}\n\n// The banner an operator must not miss. Printed for mainnet only\nconst LIVE_MAINNET_BANNER = 'LIVE MAINNET MODE - REAL FUNDS';\n\nexport function describeDeploymentMode(mode: DeploymentMode): string {\n return mode === 'mainnet' ? LIVE_MAINNET_BANNER : mode.toUpperCase();\n}\n","/**\n * Set on a payment requirement to run the backend before settlement.\n * The pipeline settles first unless this metadata value is `true`.\n */\nexport const SETTLE_AFTER_BACKEND_METADATA_KEY = 'settleAfterBackend';\n\n/**\n * Set to `true` when the rail permits presenting an authorization again after\n * its attempt was rejected, which settled nothing; the chain still spends each\n * nonce once. The pipeline lets retries reclaim the rejected attempt;\n * otherwise, it refuses them as replays.\n */\nexport const REUSE_REJECTED_AUTHORIZATION_METADATA_KEY = 'reuseRejectedAuthorization';\n","/**\n * SDK-free address checks for config load and the CLI. EVM addresses compare\n * without case; Solana keys and NEAR account IDs compare exactly.\n */\nimport type { X402Network } from './networks';\n\n// `0x` + 40 hex characters. Config load cannot check the EIP-55 checksum,\n// which needs keccak-256; the x402 and MPP providers refuse a mixed-case\n// address whose checksum is wrong when they start.\nconst EVM_ADDRESS = /^0x[0-9a-fA-F]{40}$/;\nconst EVM_ZERO = /^0x0{40}$/i;\n\n/** `0x` followed by 40 hex characters, in any case */\nexport const isEvmAddress = (value: unknown): value is `0x${string}` =>\n typeof value === 'string' && EVM_ADDRESS.test(value);\n\n/** The EVM zero address, in any case */\nexport const isEvmZeroAddress = (value: string): boolean => EVM_ZERO.test(value);\n\nconst BASE58_ALPHABET = '123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz';\n// A 32-byte key is 32 to 44 base58 characters\nconst SOLANA_ADDRESS = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/;\n// The all-zero key, which is the System Program and owns nothing recoverable\nconst SOLANA_ZERO = '11111111111111111111111111111111';\nconst EVM_TRANSACTION_HASH = /^0x[0-9a-fA-F]{64}$/;\n// A 64-byte Ed25519 signature is at most 88 base58 characters\nconst SOLANA_SIGNATURE = /^[1-9A-HJ-NP-Za-km-z]{64,88}$/;\n\n// nearcore's account ID rule: 2 to 64 characters, lowercase alphanumeric runs\n// joined by single \"-\", \"_\" or \".\"; implicit accounts are 64 hex characters\nconst NEAR_ACCOUNT_ID = /^(([a-z\\d]+[-_])*[a-z\\d]+\\.)*([a-z\\d]+[-_])*[a-z\\d]+$/;\n// A transaction hash: 32 bytes in base58\nconst NEAR_TRANSACTION_HASH = /^[1-9A-HJ-NP-Za-km-z]{32,44}$/;\n\n/**\n * Returns the family's wire address or `undefined`. NEAR uses named or\n * implicit account IDs; a `.near` suffix does not identify the network.\n */\nexport function normalizeAddress(network: X402Network, value: string): string | undefined {\n switch (network.family) {\n case 'evm':\n return isEvmAddress(value) ? value : undefined;\n case 'svm':\n return SOLANA_ADDRESS.test(value) && base58ByteLength(value) === 32 ? value : undefined;\n case 'near':\n return value.length >= 2 && value.length <= 64 && NEAR_ACCOUNT_ID.test(value)\n ? value\n : undefined;\n }\n}\n\n/**\n * An address funds cannot be recovered from: the zero address of its family.\n * NEAR has no zero account.\n */\nexport function isBurnAddress(network: X402Network, wireAddress: string): boolean {\n switch (network.family) {\n case 'evm':\n return isEvmZeroAddress(wireAddress);\n case 'svm':\n return wireAddress === SOLANA_ZERO;\n case 'near':\n return false;\n }\n}\n\n/** Compare EVM addresses case-insensitively, Solana keys and NEAR account IDs exactly */\nexport function sameAddress(network: X402Network, a: string, b: string): boolean {\n return network.family === 'evm' ? a.toLowerCase() === b.toLowerCase() : a === b;\n}\n\n/**\n * A settlement reference in its family's form: an EVM transaction hash, a\n * Solana transaction signature or a NEAR transaction hash\n */\nexport function isTransactionReference(network: X402Network, value: string): boolean {\n switch (network.family) {\n case 'evm':\n return EVM_TRANSACTION_HASH.test(value);\n case 'svm':\n return SOLANA_SIGNATURE.test(value) && base58ByteLength(value) === 64;\n case 'near':\n return NEAR_TRANSACTION_HASH.test(value) && base58ByteLength(value) === 32;\n }\n}\n\nfunction base58ByteLength(value: string): number {\n let n = 0n;\n for (const char of value) n = n * 58n + BigInt(BASE58_ALPHABET.indexOf(char));\n // Each leading '1' encodes one leading zero byte\n const leadingZeros = value.length - value.replace(/^1+/, '').length;\n return leadingZeros + (n === 0n ? 0 : Math.ceil(n.toString(16).length / 2));\n}\n","/**\n * Anvil's well-known development accounts.\n *\n * LOCAL DEVELOPMENT ONLY - DO NOT FUND. The keys come from Foundry's public\n * default mnemonic (\"test test ... junk\"), so value sent to these addresses on\n * a real network can be taken by anyone.\n *\n * Index layout on the local demo chain:\n * 0 - deployer and local facilitator signer (pays gas, broadcasts settlement)\n * 1 - merchant settlement destination (`payTo`)\n * 2 - buyer (signs EIP-3009 authorizations; never held by the gateway)\n */\nexport interface AnvilWellKnownAccount {\n readonly address: `0x${string}`;\n readonly privateKey: `0x${string}`;\n}\n\n/** A fixed-length tuple, so indexing by the layout above is typed */\nexport const ANVIL_WELL_KNOWN_ACCOUNTS: readonly [\n AnvilWellKnownAccount,\n AnvilWellKnownAccount,\n AnvilWellKnownAccount,\n] = [\n {\n address: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',\n privateKey: '0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80',\n },\n {\n address: '0x70997970C51812dc3A010C7d01b50e0d17dc79C8',\n privateKey: '0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d',\n },\n {\n address: '0x3C44CdDdB6a900fa2b585dd299e03d12FA4293BC',\n privateKey: '0x5de4111afa1a4b94908f83103eb1f1706367c2e68ca870fc3fb9a804cdab365a',\n },\n];\n\nexport const LOCAL_FACILITATOR_ACCOUNT = ANVIL_WELL_KNOWN_ACCOUNTS[0];\nexport const LOCAL_MERCHANT_ACCOUNT = ANVIL_WELL_KNOWN_ACCOUNTS[1];\nexport const LOCAL_BUYER_ACCOUNT = ANVIL_WELL_KNOWN_ACCOUNTS[2];\n\n/** Label printed wherever a dev key appears in output, logs or manifests */\nexport const DEV_KEY_LABEL = 'LOCAL DEVELOPMENT ONLY - DO NOT FUND';\n","/**\n * Rejects well-known Anvil keys and payment destinations when the RPC host\n * does not look local or private. Their private keys are published, so anyone\n * can spend what such an address receives on a public chain.\n *\n * The check uses the RPC hostname because the local chain shares Base\n * Sepolia's chain id. Both guards run at provider construction.\n */\nimport { CommerceError } from '../../core';\nimport { ANVIL_WELL_KNOWN_ACCOUNTS } from './local-chain/accounts';\n\nconst WELL_KNOWN_DEV_KEYS: ReadonlySet<string> = new Set(\n ANVIL_WELL_KNOWN_ACCOUNTS.map((a) => a.privateKey.toLowerCase()),\n);\n\nconst WELL_KNOWN_DEV_ADDRESSES: ReadonlySet<string> = new Set(\n ANVIL_WELL_KNOWN_ACCOUNTS.map((a) => a.address.toLowerCase()),\n);\n\n// `0x` plus 64 hex characters, the only shape `privateKeyToAccount` accepts\nconst PRIVATE_KEY_SHAPE = /^0x[0-9a-fA-F]{64}$/;\n\nexport function isWellKnownDevKey(privateKey: string): boolean {\n return WELL_KNOWN_DEV_KEYS.has(privateKey.toLowerCase());\n}\n\nexport function isWellKnownDevAddress(address: string): boolean {\n return WELL_KNOWN_DEV_ADDRESSES.has(address.toLowerCase());\n}\n\n/**\n * True for loopback addresses, RFC 1918 private ranges, and bare (dot-free)\n * hostnames, such as the compose service name \"anvil\".\n *\n * Bare hostnames are treated as local without resolving them. Operators must\n * point them at a private chain.\n */\nexport function isLikelyLocalOrPrivateHost(hostname: string): boolean {\n const h = hostname.toLowerCase().replace(/^\\[|\\]$/g, '');\n if (h === 'localhost' || h === '::1') return true;\n if (/^127\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$/.test(h)) return true;\n if (/^10\\.\\d{1,3}\\.\\d{1,3}\\.\\d{1,3}$/.test(h)) return true;\n if (/^192\\.168\\.\\d{1,3}\\.\\d{1,3}$/.test(h)) return true;\n if (/^172\\.(1[6-9]|2\\d|3[01])\\.\\d{1,3}\\.\\d{1,3}$/.test(h)) return true;\n if (!h.includes('.') && !h.includes(':')) return true; // bare hostname\n return false;\n}\n\nfunction parseHostnameOrThrow(rpcUrl: string): string {\n try {\n return new URL(rpcUrl).hostname;\n } catch (cause) {\n // Never the URL itself: RPC providers commonly put an API key in the path,\n // and this message reaches startup output and CI logs\n throw new CommerceError('CONFIG_INVALID', 'x402 provider: rpcUrl is not a valid URL', {\n cause,\n });\n }\n}\n\n/** Origin only, for diagnostics: RPC URLs often carry an API key in the path or query */\nexport function describeRpc(rpcUrl: string): string {\n try {\n return new URL(rpcUrl).origin;\n } catch {\n return '[unparseable rpcUrl]';\n }\n}\n\n/**\n * Throws CONFIG_INVALID if `signerPrivateKey` is not shaped like a private key,\n * or if it is a well-known dev key and the RPC is not local.\n *\n * The shape check runs first, so a truncated key is reported as malformed\n * instead of passing as \"not a dev key\".\n */\nexport function assertDevKeyIsLocalOnly(rpcUrl: string, signerPrivateKey: string): void {\n if (!PRIVATE_KEY_SHAPE.test(signerPrivateKey)) {\n throw new CommerceError(\n 'CONFIG_INVALID',\n 'x402 provider: facilitator.signerPrivateKey is not a well-formed private key ' +\n '(expected \"0x\" followed by exactly 64 hex characters).',\n );\n }\n\n if (!isWellKnownDevKey(signerPrivateKey)) return; // the operator's own key\n\n const hostname = parseHostnameOrThrow(rpcUrl);\n\n if (!isLikelyLocalOrPrivateHost(hostname)) {\n throw new CommerceError(\n 'CONFIG_INVALID',\n 'x402 provider: facilitator.signerPrivateKey is a well-known Anvil development key, but rpcUrl ' +\n `${describeRpc(rpcUrl)} does not look like a local/private chain. A public dev key must never sign against ` +\n 'a public network: it is instantly drainable and can grief real settlements via nonce exhaustion. ' +\n 'Use a real facilitator key for any non-local RPC, or point rpcUrl at your local/dev chain.',\n );\n }\n}\n\n/**\n * Throws CONFIG_INVALID if `payTo` is a well-known Anvil address and `rpcUrl`\n * does not look local or private.\n *\n * Guards the receiving side, in every facilitator mode. `agent-commerce init`\n * defaults `payTo` to a well-known address for the local demo, and on a real\n * network that default sends every payment where anyone can sweep it.\n */\nexport function assertPayToIsNotDevAddress(rpcUrl: string, payTo: string): void {\n if (!isWellKnownDevAddress(payTo)) return;\n\n const hostname = parseHostnameOrThrow(rpcUrl);\n\n if (!isLikelyLocalOrPrivateHost(hostname)) {\n throw new CommerceError(\n 'CONFIG_INVALID',\n `x402 provider: \"payTo\" (${payTo}) is a well-known Anvil development address, but rpcUrl ` +\n `${describeRpc(rpcUrl)} does not look like a local/private chain. The private key behind that address ` +\n 'is public knowledge, so any revenue settled to it is immediately spendable by anyone. Set ' +\n '\"payTo\" to your own merchant wallet for any non-local RPC, or point rpcUrl at your ' +\n 'local/dev chain.',\n );\n }\n}\n","/**\n * What must hold before this gateway may settle a payment on the configured\n * network. Two callers share these checks: the provider runs them at\n * construction, so a library consumer who skips our config loader still gets\n * them, and the config loader runs them, so `validate` and `doctor` report\n * them too.\n *\n * Both run before any request, because a failure found in `settle()` would\n * come after the pipeline reserved the buyer's replay key.\n *\n * Imports no peer (no viem, no `@x402/*`), so the CLI can load it.\n */\nimport { CommerceError } from '../../core';\nimport { isBurnAddress, sameAddress } from './addresses';\nimport { isLikelyLocalOrPrivateHost, isWellKnownDevAddress } from './dev-key-guard';\nimport {\n type CustomNetworks,\n type DeploymentMode,\n LOCAL_CHAIN_ID,\n requireX402Network,\n resolveDeploymentMode,\n type X402Network,\n} from './networks';\n\n/**\n * How the gateway authenticates to a remote facilitator.\n *\n * - `none`: send no credential; use it when the facilitator accepts\n * anonymous requests.\n * - `bearer`: send a static token; no extra peer package is needed.\n * - `cdp`: Coinbase Developer Platform. The optional peer `@coinbase/x402`,\n * imported only for this type, signs a fresh JWT per request.\n *\n * Any other auth type is refused at config load.\n */\nexport type FacilitatorAuth =\n | { readonly type: 'none' }\n | { readonly type: 'bearer'; readonly token: string }\n | { readonly type: 'cdp'; readonly apiKeyId: string; readonly apiKeySecret: string };\n\nexport type X402FacilitatorConfig =\n | { readonly mode: 'local'; readonly signerPrivateKey: string }\n | { readonly mode: 'remote'; readonly url: string; readonly auth: FacilitatorAuth };\n\nexport interface X402DeploymentInput {\n readonly network: string;\n readonly payTo: string;\n readonly asset: string;\n /** EIP-712 domain of the asset, as the token itself reports it */\n readonly assetName?: string;\n readonly assetVersion?: string;\n readonly facilitator: X402FacilitatorConfig;\n /** Must be `true` before anything settles on a mainnet */\n readonly allowMainnet?: boolean;\n /**\n * Must be `true` on mainnet when facilitator auth is `none`. A separate\n * decision from `allowMainnet`: it accepts settling without an account at\n * the facilitator, under its anonymous-access limits.\n */\n readonly allowUnauthenticatedFacilitator?: boolean;\n /**\n * Allow other tokens on built-in EVM networks with explicit metadata.\n * MPP config leaves this unset; Solana and NEAR still require USDC.\n */\n readonly allowOtherEvmToken?: boolean;\n /** Error-path prefix, `payments.x402` by default */\n readonly configPath?: string;\n /** Settlement-recipient field named in errors, `payTo` by default */\n readonly payToField?: string;\n /** EVM networks declared under `payments.x402.networks` */\n readonly customNetworks?: CustomNetworks;\n}\n\nexport interface X402Deployment {\n readonly profile: X402Network;\n readonly mode: DeploymentMode;\n}\n\nconst BASE_SEPOLIA = 'eip155:84532';\n\nfunction invalid(message: string, path: string): CommerceError {\n return new CommerceError('CONFIG_INVALID', message, { details: { path } });\n}\n\n/**\n * Resolves the deployment and refuses the combinations that could move real\n * money by accident. The network must resolve first; the other checks are\n * independent.\n */\nexport function resolveX402Deployment(input: X402DeploymentInput): X402Deployment {\n const at = input.configPath ?? 'payments.x402';\n const payTo = input.payToField ?? 'payTo';\n const profile = requireX402Network(input.network, `${at}.network`, input.customNetworks);\n const mode = resolveDeploymentMode(profile);\n\n // Local mode keeps a gas-paying key in the gateway process. A compromise\n // could expose that key, so mainnet requires a remote facilitator.\n if (profile.kind === 'mainnet' && input.facilitator.mode === 'local') {\n throw invalid(\n `${at}: network \"${profile.id}\" (${profile.displayName}) is a mainnet and cannot be served by facilitator.mode \"local\". A mainnet deployment must settle through a remote facilitator.`,\n `${at}.facilitator.mode`,\n );\n }\n // The in-process facilitator signs with a client built for the Anvil chain\n // id, so on any other chain every settlement would fail\n if (input.facilitator.mode === 'local' && mode !== 'local') {\n throw invalid(\n profile.id === BASE_SEPOLIA\n ? `${at}: the local Anvil chain is eip155:${LOCAL_CHAIN_ID}, Anvil's default chain id; \"${BASE_SEPOLIA}\" is public Base Sepolia. Set ${at}.network to eip155:${LOCAL_CHAIN_ID}, start Anvil with its default chain id and redeploy the local contracts (npm run chain:start, npm run chain:deploy).`\n : `${at}: facilitator.mode \"local\" serves the local Anvil chain (eip155:${LOCAL_CHAIN_ID}) only, not \"${profile.id}\" (${profile.displayName}). Use a remote facilitator.`,\n `${at}.facilitator.mode`,\n );\n }\n\n if (mode === 'mainnet' && input.allowMainnet !== true) {\n throw invalid(\n `${at}: network \"${profile.id}\" (${profile.displayName}) settles real funds. Set ${at}.allowMainnet: true to acknowledge this explicitly - it is never the default.`,\n `${at}.allowMainnet`,\n );\n }\n\n if (input.facilitator.mode === 'remote') {\n assertFacilitatorUrlIsSafe(input.facilitator.url, mode, at);\n // `@coinbase/x402` signs each request for CDP's own host and route,\n // whatever URL is configured, so no other facilitator can accept the credential\n if (input.facilitator.auth.type === 'cdp' && !isCdpFacilitatorUrl(input.facilitator.url)) {\n throw invalid(\n `${at}: facilitator.auth.type \"cdp\" signs requests for ${CDP_FACILITATOR_URL} only, so facilitator ${describeOrigin(input.facilitator.url)} cannot accept its credential. Set facilitator.url to ${CDP_FACILITATOR_URL}, or use auth.type \"bearer\" or \"none\".`,\n `${at}.facilitator.url`,\n );\n }\n // The authorization fixes recipient, amount and chain, so a facilitator\n // cannot redirect funds. A credential adds an account: rate limits, terms\n // and support. On mainnet, going without one is an explicit choice.\n if (\n mode === 'mainnet' &&\n input.facilitator.auth.type === 'none' &&\n input.allowUnauthenticatedFacilitator !== true\n ) {\n throw invalid(\n `${at}: no credential is configured for facilitator ${describeOrigin(input.facilitator.url)} on mainnet. Set ${at}.allowUnauthenticatedFacilitator: true to accept anonymous access and the facilitator's limits, or configure facilitator.auth.`,\n `${at}.allowUnauthenticatedFacilitator`,\n );\n }\n // A blank credential reaches the facilitator as \"unauthenticated\" and fails\n // every payment after the buyer signed. `${VAR:- }` resolving to whitespace\n // is the usual cause.\n for (const [field, value] of credentialFields(input.facilitator.auth)) {\n if (value.trim() === '') {\n throw invalid(\n `${at}: facilitator.auth.type is \"${input.facilitator.auth.type}\" but ${field} is empty. An empty credential is refused rather than sent.`,\n `${at}.facilitator.auth.${field}`,\n );\n }\n }\n }\n\n // The config loader's address check refuses this too; repeated here for a\n // library consumer who calls `createX402PaymentProvider` without it\n if (isBurnAddress(profile, input.payTo)) {\n throw invalid(\n `${at}: \"${payTo}\" is the zero address. Every payment settled there is destroyed.`,\n `${at}.${payTo}`,\n );\n }\n\n // Anyone can spend from a well-known Anvil address. `dev-key-guard` refuses\n // one behind a public RPC; this refuses one on any non-local deployment,\n // whose RPC host says nothing about where a remote facilitator settles.\n if (mode !== 'local' && isWellKnownDevAddress(input.payTo)) {\n throw invalid(\n `${at}: \"${payTo}\" (${input.payTo}) is a well-known Anvil development address and this is a ${mode} deployment. Anyone can spend what settles there. Set ${payTo} to your own merchant wallet.`,\n `${at}.${payTo}`,\n );\n }\n\n // Public built-ins require USDC unless the caller allows another EVM token.\n // Local and declared networks have no default asset.\n const canonical = profile.canonicalAsset;\n if (canonical) {\n if (!sameAddress(profile, input.asset, canonical.address)) {\n if (input.allowOtherEvmToken !== true || profile.family !== 'evm') {\n const rule =\n input.allowOtherEvmToken === true\n ? `Only an EVM network accepts another token; ${profile.displayName} settles only in its ${canonical.symbol}.`\n : `A built-in network settles only in its ${canonical.symbol}.`;\n throw invalid(\n `${at}: asset ${input.asset} is not ${canonical.symbol} on ${profile.displayName} (expected ${canonical.address}). ${rule}`,\n `${at}.asset`,\n );\n }\n } else {\n // Catch USDC domain mismatches before accepting payments; a wrong name\n // can fail with `invalid_exact_evm_token_name_mismatch`\n const domain = 'name' in canonical ? canonical : undefined;\n if (domain && input.assetName !== undefined && input.assetName !== domain.name) {\n throw invalid(\n `${at}: assetName \"${input.assetName}\" is not the EIP-712 domain name ${canonical.symbol} reports on ${profile.displayName} (expected \"${domain.name}\"). Every payment would be refused after the buyer signed.`,\n `${at}.assetName`,\n );\n }\n if (domain && input.assetVersion !== undefined && input.assetVersion !== domain.version) {\n throw invalid(\n `${at}: assetVersion \"${input.assetVersion}\" is not the EIP-712 domain version ${canonical.symbol} reports on ${profile.displayName} (expected \"${domain.version}\").`,\n `${at}.assetVersion`,\n );\n }\n }\n }\n\n return { profile, mode };\n}\n\n/**\n * A facilitator sees every payment authorization this gateway handles. Plain\n * HTTP puts those on the wire in the clear and lets anyone in the path rewrite\n * a settlement result, so it is allowed only to a local or private host, and\n * never on a mainnet.\n */\nfunction assertFacilitatorUrlIsSafe(url: string, mode: DeploymentMode, at: string): void {\n let parsed: URL;\n try {\n parsed = new URL(url);\n } catch (cause) {\n throw new CommerceError('CONFIG_INVALID', `${at}: facilitator.url is not a valid URL`, {\n cause,\n details: { path: `${at}.facilitator.url` },\n });\n }\n\n if (parsed.protocol === 'https:') return;\n if (parsed.protocol !== 'http:') {\n throw invalid(\n `${at}: facilitator ${describeOrigin(url)} must be reached over https (or http on a local/private host); got \"${parsed.protocol}//\"`,\n `${at}.facilitator.url`,\n );\n }\n if (mode !== 'mainnet' && isLikelyLocalOrPrivateHost(parsed.hostname)) return;\n\n // The origin, never the whole URL: the path can carry a tenant or an API\n // key, and this message reaches `validate`, `doctor`, startup output and CI logs\n throw invalid(\n `${at}: facilitator ${describeOrigin(url)} is reached over plain HTTP. Payment authorizations and settlement results would travel unencrypted. Use https, or point at a local/private host on a non-mainnet deployment.`,\n `${at}.facilitator.url`,\n );\n}\n\n/** The facilitator URL `@coinbase/x402` signs its JWTs for */\nexport const CDP_FACILITATOR_URL = 'https://api.cdp.coinbase.com/platform/v2/x402';\n\n// The SDK client strips trailing slashes before appending its route\nfunction isCdpFacilitatorUrl(url: string): boolean {\n try {\n const parsed = new URL(url);\n const expected = new URL(CDP_FACILITATOR_URL);\n return (\n parsed.origin === expected.origin &&\n parsed.pathname.replace(/\\/+$/, '') === expected.pathname &&\n parsed.search === ''\n );\n } catch {\n return false;\n }\n}\n\n// Origin only: a facilitator URL can carry a tenant path or an API key\nfunction describeOrigin(url: string): string {\n try {\n return new URL(url).origin;\n } catch {\n return '[unparseable facilitator.url]';\n }\n}\n\n// The secret-bearing fields of an auth block, for emptiness checks only. Never logged\nfunction credentialFields(auth: FacilitatorAuth): readonly (readonly [string, string])[] {\n switch (auth.type) {\n case 'bearer':\n return [['token', auth.token]];\n case 'cdp':\n return [\n ['apiKeyId', auth.apiKeyId],\n ['apiKeySecret', auth.apiKeySecret],\n ];\n default:\n return [];\n }\n}\n","/**\n * Resolves an x402 option into offer terms at config load, so `validate`\n * reports invalid options before startup. This module uses no SDK.\n *\n * Omitted assets use `canonicalAsset`. Overrides for the default token must\n * match its metadata; another token needs its own, including the EIP-712 domain\n * on EVM.\n */\nimport { CommerceError } from '../../core';\nimport { isBurnAddress, normalizeAddress, sameAddress } from './addresses';\nimport { type CustomNetworks, requireX402Network, type X402Network } from './networks';\n\nexport interface X402OptionInput {\n readonly scheme?: string;\n readonly network: string;\n readonly payTo: string;\n readonly asset?: string;\n readonly assetName?: string;\n readonly assetVersion?: string;\n readonly assetDecimals?: number;\n /** `eip3009` (the default) or `permit2`; EVM only */\n readonly assetTransferMethod?: string;\n}\n\nexport interface ResolvedX402Option {\n readonly scheme: 'exact';\n readonly network: X402Network;\n readonly payTo: string;\n readonly asset: string;\n /** EIP-712 domain; EVM only */\n readonly assetName?: string;\n readonly assetVersion?: string;\n readonly assetDecimals: number;\n /**\n * Default token symbol when `asset` is omitted; resource prices must use\n * this symbol or USD\n */\n readonly defaultAssetSymbol?: string;\n /** How the buyer authorizes the transfer; always `eip3009` off EVM */\n readonly assetTransferMethod: X402AssetTransferMethod;\n}\n\n/**\n * Names health components by network, asset and payee for discovery matching.\n * Lowercase EVM addresses so case variants identify the same offer.\n */\nexport function x402OfferName(offer: {\n readonly network: string;\n readonly asset: string;\n readonly payTo: string;\n}): string {\n const evm = offer.network.startsWith('eip155:');\n const address = (value: string) => (evm ? value.toLowerCase() : value);\n return `${offer.network} ${address(offer.asset)} ${address(offer.payTo)}`;\n}\n\n/** EIP-3009 `transferWithAuthorization`, or Permit2 with a prior token allowance */\nexport type X402AssetTransferMethod = 'eip3009' | 'permit2';\n\n// Incorrect EIP-712 domain values invalidate the buyer's signature\nconst FIELD_MEANINGS = {\n assetName: 'EIP-712 domain name',\n assetVersion: 'EIP-712 domain version',\n assetDecimals: 'decimals',\n} as const;\n\nconst ADDRESS_SHAPES = {\n evm: '\"0x\" followed by 40 hex characters',\n svm: 'a base58 public key of 32 bytes',\n near: 'a NEAR account ID: 2 to 64 lowercase characters, digits and single \"-\", \"_\" or \".\" separators',\n} as const;\n\nfunction invalid(message: string, path: string): CommerceError {\n return new CommerceError('CONFIG_INVALID', message, { details: { path } });\n}\n\nexport function resolveX402Option(\n input: X402OptionInput,\n path: string,\n custom?: CustomNetworks,\n): ResolvedX402Option {\n if (input.scheme !== undefined && input.scheme !== 'exact') {\n throw invalid(\n `${path}.scheme: \"${input.scheme}\" is not supported; the only x402 scheme is \"exact\"`,\n `${path}.scheme`,\n );\n }\n const network = requireX402Network(input.network, `${path}.network`, custom);\n const address = (field: 'payTo' | 'asset', value: string): string => {\n const wire = normalizeAddress(network, value);\n if (wire === undefined) {\n throw invalid(\n // The value is not echoed: a swapped variable could put a key here\n `${path}.${field} is not a plausible address on ${network.displayName} (expected ${ADDRESS_SHAPES[network.family]})`,\n `${path}.${field}`,\n );\n }\n return wire;\n };\n\n const payTo = address('payTo', input.payTo);\n if (isBurnAddress(network, payTo)) {\n throw invalid(\n `${path}.payTo is the zero address of ${network.displayName}. Every payment settled there is destroyed.`,\n `${path}.payTo`,\n );\n }\n\n const method = input.assetTransferMethod ?? 'eip3009';\n if (method !== 'eip3009' && method !== 'permit2') {\n throw invalid(\n `${path}.assetTransferMethod: \"${method}\" is not supported; use \"eip3009\" or \"permit2\"`,\n `${path}.assetTransferMethod`,\n );\n }\n if (network.family !== 'evm' && input.assetTransferMethod !== undefined) {\n throw invalid(\n `${path}.assetTransferMethod applies to EVM networks only, not to ${network.displayName}`,\n `${path}.assetTransferMethod`,\n );\n }\n\n if (network.family !== 'evm') {\n for (const field of ['assetName', 'assetVersion'] as const) {\n if (input[field] !== undefined) {\n throw invalid(\n `${path}.${field}: an EIP-712 domain applies to EVM tokens only, not to ${network.displayName}`,\n `${path}.${field}`,\n );\n }\n }\n }\n\n const canonical = network.canonicalAsset;\n const domain = canonical && 'name' in canonical ? canonical : undefined;\n\n const asset = input.asset !== undefined ? address('asset', input.asset) : undefined;\n if (asset !== undefined && isBurnAddress(network, asset)) {\n throw invalid(`${path}.asset must not be the zero address`, `${path}.asset`);\n }\n\n // The default asset applies when the option names none or names it exactly\n if (canonical && (asset === undefined || sameAddress(network, asset, canonical.address))) {\n const expected = {\n assetName: domain?.name,\n assetVersion: domain?.version,\n assetDecimals: canonical.decimals,\n };\n for (const field of ['assetName', 'assetVersion', 'assetDecimals'] as const) {\n const given = input[field];\n if (given !== undefined && given !== expected[field]) {\n throw invalid(\n `${path}.${field} does not match ${canonical.symbol} on ${network.displayName}, which reports ${FIELD_MEANINGS[field]} ${JSON.stringify(expected[field])}. Remove ${field}, or set asset to the token it describes.`,\n `${path}.${field}`,\n );\n }\n }\n return {\n scheme: 'exact',\n network,\n payTo,\n asset: asset ?? canonical.address,\n ...(domain ? { assetName: domain.name, assetVersion: domain.version } : {}),\n assetDecimals: canonical.decimals,\n defaultAssetSymbol: canonical.symbol,\n assetTransferMethod: method,\n };\n }\n\n // Another token: nothing about it can be borrowed from the default. The\n // token's EIP-712 domain matters to EIP-3009 only: a Permit2 buyer signs\n // Permit2's own domain.\n const required =\n network.family === 'evm' && method === 'eip3009'\n ? (['asset', 'assetName', 'assetVersion', 'assetDecimals'] as const)\n : (['asset', 'assetDecimals'] as const);\n const missing = required.filter((field) => input[field] === undefined);\n if (asset === undefined || missing.length > 0) {\n throw invalid(\n canonical\n ? `${path}: a token other than ${canonical.symbol} on ${network.displayName} needs ${missing.join(', ')}`\n : `${path}: ${network.displayName} has no default asset, so the option needs ${missing.join(', ')}`,\n `${path}.${missing[0] ?? 'asset'}`,\n );\n }\n return {\n scheme: 'exact',\n network,\n payTo,\n asset,\n ...(input.assetName !== undefined ? { assetName: input.assetName } : {}),\n ...(input.assetVersion !== undefined ? { assetVersion: input.assetVersion } : {}),\n assetDecimals: input.assetDecimals as number,\n assetTransferMethod: method,\n };\n}\n","/**\n * x402 exact-scheme flows, shared by the config loader and CLI.\n * The default `authorization` flow settles after a successful backend call;\n * `upfront` settles first.\n */\nexport const X402_PAYMENT_FLOWS = ['authorization', 'upfront'] as const;\n\nexport type X402PaymentFlow = (typeof X402_PAYMENT_FLOWS)[number];\n\nexport const X402_DEFAULT_PAYMENT_FLOW: X402PaymentFlow = 'authorization';\n"]}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { CommerceError } from './chunk-
|
|
1
|
+
import { CommerceError } from './chunk-AITMDXKW.js';
|
|
2
2
|
import { existsSync, accessSync, constants, closeSync, openSync, mkdirSync, chmodSync } from 'fs';
|
|
3
3
|
import { dirname } from 'path';
|
|
4
4
|
import Database from 'better-sqlite3';
|
|
@@ -79,5 +79,5 @@ function restrictDatabasePermissions(path, label, logger) {
|
|
|
79
79
|
}
|
|
80
80
|
|
|
81
81
|
export { AP2_CHECKOUT_MANDATE_VCT, AP2_CHECKOUT_PROFILE, AP2_DEFAULT_CLOCK_SKEW_SECONDS, AP2_DIGEST_ALGORITHM, AP2_JWK_COORDINATE_BYTES, AP2_JWK_CURVE, AP2_JWK_MEMBERS, AP2_KEY_TYPE, AP2_MAX_CLOCK_SKEW_SECONDS, AP2_MODES, AP2_SIGNING_ALGORITHM, AP2_SPEC_VERSION, openSqliteDatabase };
|
|
82
|
-
//# sourceMappingURL=chunk-
|
|
83
|
-
//# sourceMappingURL=chunk-
|
|
82
|
+
//# sourceMappingURL=chunk-6WACRJVT.js.map
|
|
83
|
+
//# sourceMappingURL=chunk-6WACRJVT.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/authorization/ap2/constants.ts","../src/storage/sqlite.ts"],"names":["fsConstants"],"mappings":";;;;;;AAQO,IAAM,gBAAA,GAAmB;AAOzB,IAAM,SAAA,G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A,GAAS,QAAQ,GAAG,CAAA;AAC1B,EAAA,IAAI,MAAA,KAAW,GAAA,EAAK,eAAA,CAAgB,MAAM,CAAA;AAC1C,EAAA,IAAI;AACF,IAAA,SAAA,CAAU,GAAA,EAAK,EAAE,IAAA,EAAM,GAAA,EAAO,CAAA;AAAA,EAChC,SAAS,KAAA,EAAO;AAEd,IAAA,IAAK,KAAA,CAAgC,IAAA,KAAS,QAAA,EAAU,MAAM,KAAA;AAAA,EAChE;AACF;AAWA,SAAS,2BAAA,CAA4B,IAAA,EAAc,KAAA,EAAe,MAAA,EAAsB;AACtF,EAAA,KAAA,MAAW,IAAA,IAAQ,CAAC,IAAA,EAAM,CAAA,EAAG,IAAI,CAAA,IAAA,CAAA,EAAQ,CAAA,EAAG,IAAI,CAAA,IAAA,CAAM,CAAA,EAAG;AACvD,IAAA,IAAI;AACF,MAAA,SAAA,CAAU,MAAM,GAAK,CAAA;AAAA,IACvB,SAAS,KAAA,EAAO;AACd,MAAA,MAAM,OAAQ,KAAA,CAAgC,IAAA;AAC9C,MAAA,IAAI,SAAS,QAAA,EAAU;AACvB,MAAA,MAAA,CAAO,IAAA;AAAA,QACL,EAAE,IAAA,EAAM,KAAA,EAAO,KAAA,EAAO,QAAQ,SAAA,EAAU;AAAA,QACxC;AAAA,OACF;AAAA,IACF;AAAA,EACF;AACF","file":"chunk-6WACRJVT.js","sourcesContent":["/**\n * Pinned AP2 identifiers and key policy.\n *\n * AP2 v0.2.0 (2026-04-28, commit b4587ac) is the tagged release this gateway\n * verifies against; unversioned `main` is never implemented against. Config,\n * the verifier and `doctor` all read these, so a bump lands in one place.\n */\n\nexport const AP2_SPEC_VERSION = '0.2.0';\n\n/**\n * Direct only. Autonomous mode needs open mandates, cnf-bound agent keys and\n * constraint evaluation over `checkout.line_items`, none of which is\n * implemented, so it is refused rather than partly served.\n */\nexport const AP2_MODES = ['direct'] as const;\nexport type Ap2Mode = (typeof AP2_MODES)[number];\n\n/**\n * A single algorithm, so `alg=none` and the HMAC family are excluded by\n * construction rather than by a denylist\n */\nexport const AP2_SIGNING_ALGORITHM = 'ES256';\n\n/** The key type and curve ES256 implies. Any other pair is refused at load */\nexport const AP2_KEY_TYPE = 'EC';\nexport const AP2_JWK_CURVE = 'P-256';\n\n/** Byte length of a P-256 coordinate, before base64url encoding */\nexport const AP2_JWK_COORDINATE_BYTES = 32;\n\n/**\n * JWK members a verification key may carry. An allowlist, so private material\n * (`d`) and URL members (`x5u`, `jku`) are refused without the list naming\n * them. Keys are configured inline and never fetched; see docs/security.md.\n */\nexport const AP2_JWK_MEMBERS = ['kty', 'crv', 'x', 'y', 'kid', 'alg', 'use'] as const;\n\n/**\n * Compared against this literal, never as a prefix. `mandate.checkout.open.1`\n * carries spending constraints nothing here evaluates, so accepting it would\n * tell a buyer their limits were checked when nothing read them.\n */\nexport const AP2_CHECKOUT_MANDATE_VCT = 'mandate.checkout.1';\n\n/**\n * Merchant checkout JWTs declare this gateway-specific profile; AP2 leaves\n * the checkout payload out of scope. The identifier is a namespace that\n * clients do not dereference. Merchants sign it into each checkout JWT, so\n * changing the expected value would reject previously signed JWTs.\n */\nexport const AP2_CHECKOUT_PROFILE = 'agent-commerce/ap2/checkout/v1';\n\n/**\n * The only accepted SD-JWT `_sd_alg` (an absent one means sha-256). Any other\n * value is refused rather than hashed as sha-256, which would check a\n * presentation under an algorithm it never claimed.\n */\nexport const AP2_DIGEST_ALGORITHM = 'sha-256';\n\n/** Seconds of clock skew tolerated on mandate and checkout time claims */\nexport const AP2_DEFAULT_CLOCK_SKEW_SECONDS = 60;\n\n/**\n * Skew as wide as a mandate's validity window would stop `exp` rejecting\n * anything. An operator who needs more than five minutes has a clock to fix.\n */\nexport const AP2_MAX_CLOCK_SKEW_SECONDS = 300;\n","/**\n * Opens a SQLite file with owner-only permissions. Every store that keeps a\n * SQLite file opens it here, so the hardening below exists once: the file is\n * pre-created at 0600, the WAL sidecars are narrowed once WAL creates them, and\n * an existing but unwritable file fails at startup.\n *\n * Callers own their schema; this function migrates nothing.\n */\nimport {\n accessSync,\n chmodSync,\n closeSync,\n existsSync,\n constants as fsConstants,\n mkdirSync,\n openSync,\n} from 'node:fs';\nimport { dirname } from 'node:path';\nimport Database from 'better-sqlite3';\nimport { CommerceError, type Logger } from '../core';\n\nexport interface OpenSqliteOptions {\n /** File path, or ':memory:' for tests. Parent directory is created if missing */\n readonly path: string;\n /** Names the database in operator-facing errors, e.g. \"Receipt database\" */\n readonly label: string;\n readonly logger: Logger;\n}\n\nexport function openSqliteDatabase(options: OpenSqliteOptions): Database.Database {\n const { path, label, logger } = options;\n const isFileBacked = path !== ':memory:';\n\n if (isFileBacked) {\n try {\n createDirectory(dirname(path));\n } catch (cause) {\n throw new CommerceError(\n 'STORAGE_ERROR',\n `${label} directory \"${dirname(path)}\" cannot be created: ${cause instanceof Error ? cause.message : String(cause)}`,\n { details: { path }, cause },\n );\n }\n }\n\n // Check write access at startup. SQLite can open a read-only database and\n // report the problem only when the first write is attempted.\n if (isFileBacked && existsSync(path)) {\n try {\n accessSync(path, fsConstants.W_OK);\n } catch {\n throw new CommerceError(\n 'STORAGE_ERROR',\n `${label} \"${path}\" exists but is not writable by this process (uid ${typeof process.getuid === 'function' ? process.getuid() : 'unknown'}). If this is a container that recently changed user, an existing volume may still be owned by the previous one - recreate it (docker compose down -v) or fix its ownership.`,\n { details: { path } },\n );\n }\n }\n\n // Create the file at 0600 before SQLite creates it at 0644 (less the umask).\n // A chmod afterwards is too late: a local user who opens the file in between\n // keeps a readable descriptor across the chmod. SQLite copies the main file's\n // mode onto the -wal/-shm sidecars, so this covers all three. `mode` applies\n // on creation only; an existing file is left to the chmod below.\n if (isFileBacked) {\n try {\n closeSync(openSync(path, 'a', 0o600));\n } catch {\n // Silent on purpose: `new Database` reports the same cause with a better\n // message, or the failure is harmless and the chmod below covers it\n }\n }\n\n const db = new Database(path);\n db.pragma('journal_mode = WAL');\n db.pragma('foreign_keys = ON');\n if (isFileBacked) restrictDatabasePermissions(path, label, logger);\n return db;\n}\n\n// Create missing directory levels at 0700, preserving existing modes. Explicit\n// recursion avoids the recursive mkdir hang observed on Node 24.8.0 when /proc\n// returns ENOENT for a directory it cannot create.\nfunction createDirectory(dir: string): void {\n if (existsSync(dir)) return;\n const parent = dirname(dir);\n if (parent !== dir) createDirectory(parent);\n try {\n mkdirSync(dir, { mode: 0o700 });\n } catch (error) {\n // Created by someone else in the meantime\n if ((error as NodeJS.ErrnoException).code !== 'EEXIST') throw error;\n }\n}\n\n/**\n * Narrows the database and its WAL sidecars to owner-only. The receipt ledger\n * holds no key material, but it does hold payer and payee addresses, amounts,\n * settlement hashes, replay keys and the commerce event log.\n *\n * Runs after `journal_mode = WAL`, which creates the sidecars, and also\n * tightens a database that already existed with a looser mode. A failure only\n * warns: a filesystem without POSIX modes must not stop the gateway starting.\n */\nfunction restrictDatabasePermissions(path: string, label: string, logger: Logger): void {\n for (const file of [path, `${path}-wal`, `${path}-shm`]) {\n try {\n chmodSync(file, 0o600);\n } catch (error) {\n const code = (error as NodeJS.ErrnoException).code;\n if (code === 'ENOENT') continue;\n logger.warn(\n { file, label, error: code ?? 'unknown' },\n 'could not restrict database permissions to owner-only',\n );\n }\n }\n}\n"]}
|
|
@@ -306,8 +306,8 @@ var systemClock = {
|
|
|
306
306
|
nowIso: () => (/* @__PURE__ */ new Date()).toISOString(),
|
|
307
307
|
monotonicMs: () => performance.now()
|
|
308
308
|
};
|
|
309
|
-
var PACKAGE_VERSION = "2.
|
|
309
|
+
var PACKAGE_VERSION = "2.4.0" ;
|
|
310
310
|
|
|
311
311
|
export { AUTHORIZATION_HEADER, AUTHORIZATION_INPUT_FIELD, COMMERCE_ERROR_CODES, COMMERCE_ERROR_HTTP_STATUS, COMMERCE_EVENT_TYPES, CommerceError, DEFAULT_BACKEND_TIMEOUT_MS, DELIVERY_SUMMARY_META_KEY, MAX_AUTHORIZATION_HEADER_BYTES, NOOP_LOGGER, PACKAGE_VERSION, PAYMENT_HEADER, PAYMENT_INPUT_FIELD, PAYMENT_METHOD_NAMES, PAYMENT_REQUIRED_HEADER, PAYMENT_RESPONSE_HEADER, PROTOCOL_NAMES, RESERVED_INPUT_FIELDS, RETRYABLE_ERROR_CODES, describeError, extractReservedInputFields, isCommerceError, isHttpProtocolAdapter, isPaymentRequiredEnvelope, parseAuthorizationHeader, parseAuthorizationSubmission, redactedErrorText, systemClock, toCommerceError, toDeliverySummary, toErrorEnvelope, toLogInfo, toPaymentRequiredEnvelope };
|
|
312
|
-
//# sourceMappingURL=chunk-
|
|
313
|
-
//# sourceMappingURL=chunk-
|
|
312
|
+
//# sourceMappingURL=chunk-AITMDXKW.js.map
|
|
313
|
+
//# sourceMappingURL=chunk-AITMDXKW.js.map
|