import { type MerchantRegistry } from "./merchants.js"; import { type AcceptSpec } from "./networks.js"; export type X402Environment = "development" | "production"; export interface TollgateConfig { port: number; upstreamUrl: string | undefined; /** * Shared secret for post-payment upstream trust headers * (`UPSTREAM_SHARED_SECRET` or `X402_UPSTREAM_SECRET`). * When set, tollgate injects `X-Tollgate-Secret` / `X-Tollgate-Paid` after settle. * Upstream must require these and reject public direct hits. Not mTLS. */ upstreamSharedSecret: string | undefined; payTo: `0x${string}` | undefined; price: string; /** * Primary CAIP-2 network (first settle / CREATE2 asset default). * Always equal to `networks[0]` after load when NETWORKS drives the list. */ network: string; /** * Networks from `NETWORKS` / `NETWORK` (EVM + optional Solana). * Default: single Base Sepolia (dev) or Base (prod) — Render-safe. */ networks: string[]; /** * Active 402 `accepts[]` specs (network × asset). From `ACCEPTS_JSON` or * `NETWORKS` × `ASSETS` (default USDC only). Never includes TRON/planned. */ accepts: AcceptSpec[]; environment: X402Environment; /** Path prefix that requires payment (e.g. `/v1`). Empty string gates everything except free paths. */ gatedPrefix: string; cdpApiKeyId: string | undefined; cdpApiKeySecret: string | undefined; /** * Public CDP client / project API key for browser Smart Wallet paywall UX. * Safe to expose to the browser; never put `CDP_API_KEY_SECRET` here. */ cdpClientApiKey: string | undefined; /** * WalletConnect Cloud project id for browser paywall (public). * When set, paywall injects WalletConnect alongside Smart Wallet / injected. */ walletConnectProjectId: string | undefined; /** * Enable `@x402/paywall` SVM handler when Solana appears in accepts * (or force with PAYWALL_SVM=true). Off by default. */ paywallSvm: boolean; /** Solana receive address for experimental SVM accepts (base58). */ solanaPayTo: string | undefined; /** True when CDP facilitator credentials + pay-to are present. */ useLiveFacilitator: boolean; /** * Optional CDP / alternate x402 facilitator base URL * (`X402_FACILITATOR_URL` or `CDP_FACILITATOR_URL`). * Applied to MCP `createCdpFacilitatorClient({ baseUrl })`. HTTP live * `createX402Server` still uses the CDP default until the SDK exposes an * override — no multi-facilitator routing engine yet. */ facilitatorUrl: string | undefined; /** * Public https origin for Bazaar resource URLs (no trailing slash). * Without this, demos use http://127.0.0.1:PORT — Bazaar listing is a no-op until set + one CDP settlement. */ publicBaseUrl: string; /** Contact mailto on the landing page (not a SaaS CTA). */ contactEmail: string; /** * Operator fee in basis points (default 10 = 0.1%). * Documented for FeeSplitter deploy; live CDP settle still pays 100% to `payTo`. */ feeBps: number; /** * Fixed operator feeCollector wallet (default OPERATOR_FEE_COLLECTOR). * Each merchant FeeSplitter uses seller=merchant wallet, feeCollector=this address. */ feeCollector: `0x${string}`; /** merchantId → FeeSplitter payTo + seller for display. Loaded at startup. */ merchants: MerchantRegistry; /** Default merchant id when query/header omitted (env DEFAULT_MERCHANT, default `demo`). */ defaultMerchant: string; /** * When true, gated paths require an explicit `?merchant=` / `x-merchant-id` * (no DEFAULT_MERCHANT fallback). Off by default — agents SHOULD send merchant id. */ requireMerchant: boolean; /** Gateway PAYMENT-SIGNATURE dedupe TTL (ms). CDP facilitator remains source of truth for EIP-3009 nonce. */ paymentDedupeTtlMs: number; /** Max fingerprints kept in the in-memory dedupe LRU. */ paymentDedupeMaxEntries: number; /** * Local / facilitator verify budget (ms). Documented separately from settle; * the gateway settle waiter uses `settleTimeoutMs`. */ verifyTimeoutMs: number; /** * Max time to wait for facilitator / on-chain settle before returning * `202 payment_pending` + `retry_with_same_proof` (ms). Default 3 minutes. */ settleTimeoutMs: number; /** * Permissionless seller EOA (env SELLER / X402_SELLER). * When set, gated payTo uses resolvePayTo(amount, seller) unless ?merchant= hits the registry. */ seller: `0x${string}` | undefined; /** * USDC atomic threshold: amount < this → payTo = seller (0 protocol fee). * Default 10_000_000 ($10). Amount ≥ threshold → CREATE2 FeeSplitter. * Env: `FEE_FREE_BELOW_USDC` or `X402_FEE_FREE_BELOW_USDC`. */ feeFreeBelowUsdc: bigint; /** * FeeSplitterFactory for primary `network` (CREATE2 predict ≥ threshold). * Live Base reference: `contracts/deployments/base.json`. */ factoryAddress: `0x${string}` | undefined; /** * Optional per-CAIP-2 factory map (`FACTORY_ADDRESSES` JSON + `FACTORY_ADDRESS`). * Other chains are config-ready stubs until an operator deploys. */ factoryAddresses: Record; /** * Static minimum accept amount in atomic USDC (`X402_MIN_PRICE_USDC`). * 0 = unset (use PRICE only, unless dynamic gas floor bumps). */ minPriceUsdc: bigint; /** * When true, Base gas oracle may raise effective min price / feeFreeBelow * if estimated gas exceeds `gasCostMaxFraction` of the payment. Default OFF. */ dynamicMinEnabled: boolean; /** Max gas-cost / payment ratio before bumping (default 0.5). */ gasCostMaxFraction: number; /** Public Base JSON-RPC for baseFee (cached). */ gasOracleRpcUrl: string; /** Base-fee cache TTL ms (clamped 15–60s). */ gasOracleTtlMs: number; /** Rough L2 gas units for settle estimate. */ gasUsedEstimate: number; /** Conservative ETH/USD floor for gas→USD (no live FX required). */ ethUsd: number; } export declare function loadConfig(env?: NodeJS.ProcessEnv): TollgateConfig; /** * Free HTTP paths that never require x402 payment (MCP has its own payment loop). * `/merchants` and `/v1/merchants` are free registry listing endpoints. * `/x402/discover` (+ `/discover` alias) is the agent-readable yellow pages catalog. */ export declare const FREE_PATHS: Set; export declare function isFreePath(path: string): boolean; export declare function isGatedPath(path: string, gatedPrefix: string): boolean; export declare function gatedRoutePatterns(gatedPrefix: string): string[];