import { Request, Response, NextFunction } from 'express'; /** * Configuration for XAPIFi SDK */ interface XAPIFiConfig { /** Your xAPI-Fi API key */ apiKey: string; /** Solana network to use (default: 'solana') */ network?: 'solana' | 'solana-devnet'; /** Custom facilitator URL (optional) */ facilitatorUrl?: string; /** API base URL (default: https://api.xapi-fi.com/v1) */ apiBaseUrl?: string; } /** * Options for protecting an endpoint */ interface ProtectOptions { /** Price in USD for calling this endpoint */ price: number; /** Human-readable description of what this endpoint does */ description?: string; /** Maximum timeout in milliseconds for payment verification */ maxTimeout?: number; /** Custom validation rules */ customRules?: (req: any) => Promise; } /** * Payment requirements returned in 402 response */ interface PaymentRequirements { /** Endpoint ID */ endpointId: string; /** Price in USD */ price: number; /** Price in lamports (SOL) */ priceInLamports: number; /** Treasury address to send payment to */ treasuryAddress: string; /** Network to use */ network: string; /** Description of the endpoint */ description?: string; } /** * Verified payment information */ interface VerifiedPayment { /** Whether the payment is valid */ valid: boolean; /** Transaction signature */ signature?: string; /** Amount paid in lamports */ amount?: number; /** Payer address */ payer?: string; /** Error message if invalid */ error?: string; } /** * XAPIFi Server SDK * * Usage: * ```typescript * const xapi = new XAPIFi({ apiKey: 'your-key' }); * app.post('/api/generate', xapi.protect({ price: 0.001 }), handler); * ``` */ declare class XAPIFi { private config; constructor(config: XAPIFiConfig); /** * Express/Next.js middleware to protect an endpoint with x402 payments */ protect(options: ProtectOptions): (req: Request, res: Response, next: NextFunction) => Promise> | undefined>; /** * Get payment requirements for an endpoint */ private getPaymentRequirements; /** * Verify a payment with the x402 facilitator */ private verifyPayment; /** * Track analytics event */ private trackAnalytics; /** * Framework-agnostic handler */ handleRequest(request: any, options: ProtectOptions): Promise; } export { type PaymentRequirements, type ProtectOptions, type VerifiedPayment, XAPIFi, type XAPIFiConfig, XAPIFi as default };