import { AxiosInstance } from 'axios'; import { Signer, MultiNetworkSigner, X402Config } from 'x402/types'; export { MultiNetworkSigner, Signer, X402Config, createSigner } from 'x402/types'; import { PaymentRequirementsSelector } from 'x402/client'; export { PaymentRequirementsSelector } from 'x402/client'; export { decodeXPaymentResponse } from 'x402/shared'; export { Hex } from 'viem'; /** * Enables the payment of APIs using the x402 payment protocol. * * When a request receives a 402 response: * 1. Extracts payment requirements from the response * 2. Verifies the payment amount is within the allowed maximum * 3. Creates a payment header using the provided wallet client * 4. Retries the original request with the payment header * 5. Exposes the X-PAYMENT-RESPONSE header in the final response * * @param axiosClient - The Axios instance to add the interceptor to * @param walletClient - A wallet client that can sign transactions and create payment headers * @param maxValue - The maximum allowed payment amount in base units (defaults to 0.1 USDC) * @param paymentRequirementsSelector - A function that selects the payment requirements from the response * @param config - Optional configuration for X402 operations (e.g., custom RPC URLs) * @returns The modified Axios instance with the payment interceptor * * @example * ```typescript * const client = withPaymentInterceptor( * axios.create(), * signer * ); * * // With custom RPC configuration * const client = withPaymentInterceptor( * axios.create(), * signer, * undefined, * undefined, * { svmConfig: { rpcUrl: "http://localhost:8899" } } * ); * * // The client will automatically handle 402 responses * const response = await client.get('https://api.example.com/premium-content'); * ``` * * @throws {Error} If the payment amount exceeds the maximum allowed value */ declare function withPaymentInterceptor(axiosClient: AxiosInstance, walletClient: Signer | MultiNetworkSigner, maxValue?: bigint, // Default to 0.10 USDC paymentRequirementsSelector?: PaymentRequirementsSelector, config?: X402Config): AxiosInstance; export { withPaymentInterceptor };