import { PaymentRequirements, PaymentRequired, VerifyResponse, SettleResponse, SupportedResponse } from '@payai/x402/types'; export { PaymentRequired, PaymentRequirements, SettleResponse, VerifyResponse } from '@payai/x402/types'; import { e as X402ServerConfig, R as RouteConfig } from '../solana-payment-6F7H5TeY.mjs'; export { T as TokenAsset } from '../solana-payment-6F7H5TeY.mjs'; import '@solana/web3.js'; /** * x402 Payment Handler for server-side payment processing (v2) * Framework agnostic - works with any Node.js HTTP framework */ declare class X402PaymentHandler { private facilitatorClient; private config; constructor(config: X402ServerConfig); /** * Extract payment header from request headers (v2) * Pass in headers object from any framework (Next.js, Express, etc.) * * Note: v2 uses PAYMENT-SIGNATURE header (v1 used X-PAYMENT) */ extractPayment(headers: Record | Headers): string | null; /** * Create payment requirements for a protected resource * * @param routeConfig - Route-specific configuration * @param resourceUrl - URL of the protected resource * @returns Payment requirements object */ createPaymentRequirements(routeConfig: RouteConfig, resourceUrl: string): Promise; /** * Create a 402 Payment Required response body (v2) * Use this with your framework's response method * * @param requirements - Payment requirements (from createPaymentRequirements) * @param resourceUrl - URL of the protected resource */ create402Response(requirements: PaymentRequirements, resourceUrl: string): { status: 402; body: PaymentRequired; }; /** * Verify payment with facilitator * @returns VerifyResponse with isValid and optional invalidReason */ verifyPayment(paymentHeader: string, paymentRequirements: PaymentRequirements): Promise; /** * Settle payment with facilitator * @returns SettleResponse with success status and optional errorReason */ settlePayment(paymentHeader: string, paymentRequirements: PaymentRequirements): Promise; /** * Get the network in CAIP-2 format */ getNetwork(): string; /** * Get the treasury address */ getTreasuryAddress(): string; } /** * Configuration for the facilitator client */ interface FacilitatorClientConfig { url: string; /** PayAI API Key ID for JWT auth */ apiKeyId?: string | undefined; /** PayAI API Key Secret for JWT auth */ apiKeySecret?: string | undefined; } /** * Client for communicating with x402 facilitator service (v2). * * When `apiKeyId` and `apiKeySecret` are provided, all requests are * automatically authenticated with a JWT Bearer token (cached and refreshed). */ declare class FacilitatorClient { private readonly facilitatorUrl; private readonly apiKeyId; private readonly apiKeySecret; constructor(config: FacilitatorClientConfig); /** * Build auth headers when API keys are configured. * Returns an empty object when no keys are present. */ private getAuthHeaders; /** * Get supported payment kinds from facilitator */ getSupported(): Promise; /** * Get fee payer address for a Solana network * @param network - Network in any format (simple or CAIP-2) */ getFeePayer(network: string): Promise; /** * Verify payment with facilitator * @returns VerifyResponse with isValid and optional invalidReason */ verifyPayment(paymentHeader: string, paymentRequirements: PaymentRequirements): Promise; /** * Settle payment with facilitator * @returns SettleResponse with success status and optional errorReason */ settlePayment(paymentHeader: string, paymentRequirements: PaymentRequirements): Promise; } export { FacilitatorClient, RouteConfig, X402PaymentHandler, X402ServerConfig };