import type { Request, RequestHandler } from "express"; import type { TollgateConfig } from "./config.js"; import { type MerchantEntry } from "./merchants.js"; import { type GasFloorService } from "./gas-floor.js"; /** @deprecated Import from `./networks.js`. */ export { DEFAULT_USDC } from "./networks.js"; export { usdcForNetwork } from "./networks.js"; export interface PaymentLayerOptions { /** Shared gas-floor service (tests / app). Created from config when omitted. */ gasFloor?: GasFloorService; } export type ResolveSellerPayToOptions = { feeFreeBelowUsdc?: bigint; network?: string; asset?: `0x${string}`; }; /** Resolve permissionless seller payTo from amount + config (threshold / CREATE2). */ export declare function resolveSellerPayTo(config: TollgateConfig, amountAtomic: bigint | string, networkOrOptions?: string | ResolveSellerPayToOptions, assetOverride?: `0x${string}`): `0x${string}`; export declare function buildAcceptEntries(config: TollgateConfig, opts: { merchantPayTo?: `0x${string}`; sellerMode?: boolean; fallbackPayTo: string; feeFreeBelowUsdc?: bigint; /** Gas / static floor in 6-decimal USDC atomic units. */ minAmountAtomic?: bigint; }): Array>; export interface PaymentLayer { middleware: RequestHandler; mode: "live" | "demo"; payToEvmAddress?: string; /** Present when created via createPaymentLayer / createDemoPaymentLayer. */ gasFloor?: GasFloorService; } /** Request locals set by merchant gate / rewrite wrappers. */ export type MerchantLocals = { merchantId?: string; merchant?: MerchantEntry; /** Permissionless seller path (no registry entry). */ sellerMode?: boolean; }; /** * Public resource URL for Bazaar / PAYMENT-REQUIRED. * Prefer PUBLIC_BASE_URL so TLS terminators (Render) never advertise http://. * Preserves path + query (fetch-md needs ?url=). */ export declare function buildPublicResourceUrl(config: TollgateConfig, req: Pick): string; /** * On gated paths: resolve merchant (query `merchant` / header `x-merchant-id` / * DEFAULT_MERCHANT) **or** permissionless seller mode when `config.seller` is set. * Unknown merchant → 400 `{error:"unknown_merchant"}`. Free paths pass through. * * When `REQUIRE_MERCHANT=true`, omitting merchant id → 400 `{error:"merchant_required"}` * (hosted multi-tenant harden — still applies if seller is unset). * * Permissionless: with `SELLER` / `x402Tollgate({ seller })` and no `?merchant=`, * registry is not required. */ export declare function withMerchantGate(middleware: RequestHandler, config: TollgateConfig): RequestHandler; /** * Live SDK builds resource.url via ExpressAdapter.getUrl() = * `${req.protocol}://${host}${originalUrl}`. Behind Render, Node sees http * unless trust proxy is on. createX402Server has a single global payTo — rewrite * PAYMENT-REQUIRED resource.url to PUBLIC_BASE_URL and accepts[].payTo to the * resolved merchant FeeSplitter after the SDK sets the header. * * Also enforces the gas-aware minimum accept amount when the floor is active * (rewrites accepts[].amount upward; does not lower). */ export declare function withPublicResourceUrl(middleware: RequestHandler, config: TollgateConfig, gasFloor?: GasFloorService): RequestHandler; /** * Live CDP facilitator path — official seller pattern. * Requires CDP_API_KEY_ID, CDP_API_KEY_SECRET, and X402_PAY_TO (or default merchant payTo). * Bazaar: createX402Server auto-injects bazaar; we override with discoverable + schemas. * Per-request merchant payTo is applied via PAYMENT-REQUIRED header rewrite (SDK payTo is global). */ export declare function createLivePaymentLayer(config: TollgateConfig, options?: PaymentLayerOptions): Promise; /** * Demo / offline payment middleware. * Returns a protocol-shaped 402 + PAYMENT-REQUIRED (with Bazaar extension) when gated and unpaid. * Uses resolved merchant FeeSplitter, or permissionless seller resolvePayTo, as payTo. */ export declare function createDemoPaymentLayer(config: TollgateConfig, options?: PaymentLayerOptions): PaymentLayer; export declare function createPaymentLayer(config: TollgateConfig, options?: PaymentLayerOptions): Promise;