import { W as WalletSet, S as SolanaWallet, R as RelaiNetwork } from './types-DjEveKgt.cjs'; type X402NetworkSelectionMode = 'prefer_then_any' | 'strict_preferred'; /** * MPP (Machine Payment Protocol) handler for automatic Tempo/Stripe payment. * When provided, the client will detect WWW-Authenticate: Payment challenges * on 402 responses and use this handler to create credentials automatically. * * @example * ```typescript * import { Mppx, tempo } from 'mppx/client'; * import { privateKeyToAccount } from 'viem/accounts'; * * const mppx = Mppx.create({ * methods: [tempo.charge({ account: privateKeyToAccount('0x...') })], * polyfill: false, * }); * * const client = createX402Client({ * wallets: { evm: evmWallet }, * mpp: mppx, * }); * ``` */ interface MppHandler { /** Create a credential string from a 402 response containing a WWW-Authenticate challenge. */ createCredential(response: Response): Promise; } interface X402ClientConfig { /** Multi-chain wallets (Solana + EVM) */ wallets?: WalletSet; /** Single Solana wallet (legacy shortcut) */ wallet?: SolanaWallet; /** Custom facilitator URL, default: RelAI facilitator */ facilitatorUrl?: string; /** Optional Relay WebSocket transport for /relay/:apiId endpoints */ relayWs?: X402RelayWsConfig; /** Preferred network when multiple options available */ preferredNetwork?: RelaiNetwork; /** * How to handle 402 accepts when preferredNetwork is set. * - prefer_then_any (default): prefer preferredNetwork, then fall back to any payable option. * - strict_preferred: only accept preferredNetwork, fail otherwise. */ networkSelectionMode?: X402NetworkSelectionMode; /** Custom Solana RPC URL */ solanaRpcUrl?: string; /** Custom EVM RPC URLs per network (e.g. { 'skale-base': 'https://...' }) */ evmRpcUrls?: Record; /** Maximum payment amount in atomic units */ maxAmountAtomic?: string; /** Default Integritas behavior for outgoing requests */ integritas?: boolean | X402IntegritasConfig; /** Enable verbose logging */ verbose?: boolean; /** Default headers added to every request (e.g. X-Service-Key, X-Agent-ID for agent use) */ defaultHeaders?: Record; /** * Optional MPP (Machine Payment Protocol) handler. * When set, the client automatically handles WWW-Authenticate: Payment * challenges (Tempo, Stripe) on 402 responses before falling back to x402. * Pass an mppx client instance (from `Mppx.create()`). */ mpp?: MppHandler; /** * Enable transparent cross-chain bridge. * When set, the client auto-discovers bridge info from the RelAI API and * bridges payments when no wallet matches the server's accepted chains. * The server does NOT need to advertise bridge support — it just verifies * a normal on-chain payment on its target chain. */ bridge?: { enabled?: boolean; /** RelAI API base URL for auto-discovery (default: https://api.relai.fi) */ baseUrl?: string; /** Force bridge even when the client could pay directly on the target chain */ force?: boolean; }; } type X402IntegritasFlow = 'single' | 'dual'; interface X402IntegritasConfig { /** Enable Integritas stamp request headers */ enabled?: boolean; /** Preferred Integritas flow for the request */ flow?: X402IntegritasFlow; } interface X402RequestOptions { /** Per-request Integritas override */ integritas?: boolean | X402IntegritasConfig; } type X402FetchInit = RequestInit & { /** SDK-specific per-request options (not forwarded to fetch as-is) */ x402?: X402RequestOptions; }; interface RelayWebSocketLike { readyState: number; send(data: string): void; close(code?: number, reason?: string): void; addEventListener?: (type: string, listener: (...args: any[]) => void) => void; removeEventListener?: (type: string, listener: (...args: any[]) => void) => void; on?: (type: string, listener: (...args: any[]) => void) => void; off?: (type: string, listener: (...args: any[]) => void) => void; removeListener?: (type: string, listener: (...args: any[]) => void) => void; onopen?: ((event: unknown) => void) | null; onmessage?: ((event: unknown) => void) | null; onerror?: ((event: unknown) => void) | null; onclose?: ((event: unknown) => void) | null; } type RelayWebSocketFactory = (url: string) => RelayWebSocketLike; interface X402RelayWsConfig { /** Enable WebSocket transport for relay URLs (still falls back to HTTP by default). */ enabled?: boolean; /** Explicit WebSocket relay URL (default is derived from relay URL host). */ wsUrl?: string; /** Timeout for WS connect and preflight call in milliseconds. Default: 5000. */ preflightTimeoutMs?: number; /** Timeout for paid WS retry in milliseconds. Default: 10000. */ paymentTimeoutMs?: number; /** Fallback to standard HTTP x402 flow when WS transport fails. Default: true. */ fallbackToHttp?: boolean; /** Custom WebSocket factory, useful in runtimes without global WebSocket. */ webSocketFactory?: RelayWebSocketFactory; } interface X402RelayWsError { code: number; message: string; data?: unknown; paymentRequired?: unknown; } interface X402RelayWsResponse { id?: string | number; result?: unknown; error?: X402RelayWsError; paymentResponse?: unknown; metadata?: Record; } interface X402Client { /** Fetch with automatic x402 payment handling */ fetch(input: string | URL | Request, init?: X402FetchInit): Promise; } declare function createX402Client(config: X402ClientConfig): X402Client; export { type MppHandler, type RelayWebSocketFactory, type RelayWebSocketLike, type X402Client, type X402ClientConfig, type X402FetchInit, type X402IntegritasConfig, type X402IntegritasFlow, type X402NetworkSelectionMode, type X402RelayWsConfig, type X402RelayWsError, type X402RelayWsResponse, type X402RequestOptions, createX402Client, createX402Client as default };