@zendfi/sdk 0.5.7 → 0.6.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.d.mts CHANGED
@@ -1,5 +1,5 @@
1
- import { C as CreateAgentApiKeyRequest, A as AgentApiKey, b as CreateAgentSessionRequest, c as AgentSession, d as AgentPaymentRequest, e as AgentPaymentResponse, f as AgentAnalytics, g as CreatePaymentIntentRequest, P as PaymentIntent, h as ConfirmPaymentIntentRequest, i as PaymentIntentEvent, j as PPPFactor, k as PricingSuggestionRequest, l as PricingSuggestion, E as EnableAutonomyRequest, m as EnableAutonomyResponse, n as AutonomyStatus, S as SmartPaymentRequest, o as SmartPaymentResponse, p as CreateSessionKeyRequest, q as CreateSessionKeyResponse, r as CreateDeviceBoundSessionKeyRequest$1, s as CreateDeviceBoundSessionKeyResponse$1, t as SubmitSignedTransactionRequest, u as SubmitTransactionResponse, v as SessionKeyStatus, w as SessionKeyListResponse, T as TopUpSessionKeyRequest, x as TopUpSessionKeyResponse, Z as ZendFiConfig, y as CreatePaymentRequest, z as Payment, L as ListPaymentsRequest, B as PaginatedResponse, D as CreateSubscriptionPlanRequest, F as SubscriptionPlan, G as CreateSubscriptionRequest, H as Subscription, I as CreatePaymentLinkRequest, J as PaymentLink, K as CreateInstallmentPlanRequest, M as InstallmentPlan, N as CreateEscrowRequest, O as Escrow, Q as ApproveEscrowRequest, R as RefundEscrowRequest, U as DisputeEscrowRequest, V as CreateInvoiceRequest, X as Invoice, Y as VerifyWebhookRequest, _ as WebhookPayload } from './webhook-handler-D5CigE9G.mjs';
2
- export { a5 as AgentKeyId, ao as ApiKeyMode, aD as ApiKeyScope, aJ as AutonomousDelegate, a2 as Brand, aG as CaptureMethod, aA as CreateInstallmentPlanResponse, ap as Currency, an as Environment, a9 as EscrowId, au as EscrowStatus, aa as InstallmentPlanId, at as InstallmentPlanStatus, az as InstallmentScheduleItem, ac as IntentId, a7 as InvoiceId, aC as InvoiceLineItem, av as InvoiceStatus, aO as LinkedSessionInfo, a6 as MerchantId, aI as PPPConfig, a3 as PaymentId, aF as PaymentIntentStatus, ab as PaymentLinkCode, ar as PaymentStatus, aq as PaymentToken, aB as ReleaseCondition, aK as RevokeAutonomyRequest, aP as SecurityStatus, a4 as SessionId, aM as SessionKeyInstructions, aN as SessionKeySecurityInfo, aQ as SessionKeyStats, aE as SessionLimits, aL as SmartPaymentStatus, ay as SplitRecipient, aw as SplitStatus, a8 as SubscriptionId, as as SubscriptionStatus, aH as UserProfile, ax as WebhookEvent, a1 as WebhookEventHandler, W as WebhookHandlerConfig, a as WebhookHandlers, a0 as WebhookResult, af as asAgentKeyId, aj as asEscrowId, ak as asInstallmentPlanId, am as asIntentId, ah as asInvoiceId, ag as asMerchantId, ad as asPaymentId, al as asPaymentLinkCode, ae as asSessionId, ai as asSubscriptionId, $ as processWebhook } from './webhook-handler-D5CigE9G.mjs';
1
+ import { C as CreateAgentApiKeyRequest, A as AgentApiKey, b as CreateAgentSessionRequest, c as AgentSession, d as AgentPaymentRequest, e as AgentPaymentResponse, f as AgentAnalytics, g as CreatePaymentIntentRequest, P as PaymentIntent, h as ConfirmPaymentIntentRequest, i as PaymentIntentEvent, j as PPPFactor, k as PricingSuggestionRequest, l as PricingSuggestion, E as EnableAutonomyRequest, m as EnableAutonomyResponse, n as AutonomyStatus, S as SmartPaymentRequest, o as SmartPaymentResponse, p as CreateSessionKeyRequest, q as CreateSessionKeyResponse, r as CreateDeviceBoundSessionKeyRequest$1, s as CreateDeviceBoundSessionKeyResponse$1, t as SubmitSignedTransactionRequest, u as SubmitTransactionResponse, v as SessionKeyStatus, w as SessionKeyListResponse, T as TopUpSessionKeyRequest, x as TopUpSessionKeyResponse, Z as ZendFiConfig, y as CreatePaymentRequest, z as Payment, L as ListPaymentsRequest, B as PaginatedResponse, D as CreateSubscriptionPlanRequest, F as SubscriptionPlan, G as CreateSubscriptionRequest, H as Subscription, I as CreatePaymentLinkRequest, J as PaymentLink, K as CreateInstallmentPlanRequest, M as InstallmentPlan, N as CreateEscrowRequest, O as Escrow, Q as ApproveEscrowRequest, R as RefundEscrowRequest, U as DisputeEscrowRequest, V as CreateInvoiceRequest, X as Invoice, Y as VerifyWebhookRequest, _ as WebhookPayload } from './webhook-handler-DGBeCWT-.mjs';
2
+ export { a5 as AgentKeyId, ao as ApiKeyMode, aD as ApiKeyScope, aJ as AutonomousDelegate, a2 as Brand, aG as CaptureMethod, aA as CreateInstallmentPlanResponse, ap as Currency, an as Environment, a9 as EscrowId, au as EscrowStatus, aa as InstallmentPlanId, at as InstallmentPlanStatus, az as InstallmentScheduleItem, ac as IntentId, a7 as InvoiceId, aC as InvoiceLineItem, av as InvoiceStatus, aO as LinkedSessionInfo, a6 as MerchantId, aI as PPPConfig, a3 as PaymentId, aF as PaymentIntentStatus, ab as PaymentLinkCode, ar as PaymentStatus, aq as PaymentToken, aB as ReleaseCondition, aK as RevokeAutonomyRequest, aP as SecurityStatus, a4 as SessionId, aM as SessionKeyInstructions, aN as SessionKeySecurityInfo, aQ as SessionKeyStats, aE as SessionLimits, aL as SmartPaymentStatus, ay as SplitRecipient, aw as SplitStatus, a8 as SubscriptionId, as as SubscriptionStatus, aH as UserProfile, ax as WebhookEvent, a1 as WebhookEventHandler, W as WebhookHandlerConfig, a as WebhookHandlers, a0 as WebhookResult, af as asAgentKeyId, aj as asEscrowId, ak as asInstallmentPlanId, am as asIntentId, ah as asInvoiceId, ag as asMerchantId, ad as asPaymentId, al as asPaymentLinkCode, ae as asSessionId, ai as asSubscriptionId, $ as processWebhook } from './webhook-handler-DGBeCWT-.mjs';
3
3
  import { Transaction, Keypair } from '@solana/web3.js';
4
4
 
5
5
  /**
@@ -715,6 +715,68 @@ declare class AutonomyAPI {
715
715
  * ```
716
716
  */
717
717
  validateRequest(request: EnableAutonomyRequest): void;
718
+ /**
719
+ * Get spending attestations for a delegate (audit trail)
720
+ *
721
+ * Returns all cryptographically signed attestations ZendFi created for
722
+ * this delegate. Each attestation contains:
723
+ * - The spending state at the time of payment
724
+ * - ZendFi's Ed25519 signature
725
+ * - Timestamp and nonce (for replay protection)
726
+ *
727
+ * These attestations can be independently verified using ZendFi's public key
728
+ * to confirm spending limit enforcement was applied correctly.
729
+ *
730
+ * @param delegateId - UUID of the autonomous delegate
731
+ * @returns Attestation audit response with all signed attestations
732
+ *
733
+ * @example
734
+ * ```typescript
735
+ * const audit = await zendfi.autonomy.getAttestations('delegate_123...');
736
+ *
737
+ * console.log(`Found ${audit.attestation_count} attestations`);
738
+ * console.log(`ZendFi public key: ${audit.zendfi_attestation_public_key}`);
739
+ *
740
+ * // Verify each attestation independently
741
+ * for (const signed of audit.attestations) {
742
+ * console.log(`Payment ${signed.attestation.payment_id}:`);
743
+ * console.log(` Requested: $${signed.attestation.requested_usd}`);
744
+ * console.log(` Remaining after: $${signed.attestation.remaining_after_usd}`);
745
+ * // Verify signature with nacl.sign.detached.verify()
746
+ * }
747
+ * ```
748
+ */
749
+ getAttestations(delegateId: string): Promise<AttestationAuditResponse>;
750
+ }
751
+ /** Spending attestation - ZendFi's signed commitment to spending state */
752
+ interface SpendingAttestation {
753
+ delegate_id: string;
754
+ session_key_id: string;
755
+ merchant_id: string;
756
+ spent_usd: number;
757
+ limit_usd: number;
758
+ requested_usd: number;
759
+ remaining_after_usd: number;
760
+ timestamp_ms: number;
761
+ nonce: string;
762
+ payment_id: string;
763
+ version: number;
764
+ }
765
+ /** Signed attestation with ZendFi's cryptographic signature */
766
+ interface SignedSpendingAttestation {
767
+ attestation: SpendingAttestation;
768
+ /** Base64-encoded Ed25519 signature */
769
+ signature: string;
770
+ /** Base58-encoded ZendFi public key */
771
+ signer_public_key: string;
772
+ }
773
+ /** Response from the attestation audit endpoint */
774
+ interface AttestationAuditResponse {
775
+ delegate_id: string;
776
+ attestation_count: number;
777
+ attestations: SignedSpendingAttestation[];
778
+ /** ZendFi's attestation public key for independent verification */
779
+ zendfi_attestation_public_key: string | null;
718
780
  }
719
781
 
720
782
  /**
@@ -2058,6 +2120,8 @@ declare class DeviceBoundSessionKey {
2058
2120
 
2059
2121
  interface CreateDeviceBoundSessionKeyRequest {
2060
2122
  userWallet: string;
2123
+ agentId: string;
2124
+ agentName?: string;
2061
2125
  limitUsdc: number;
2062
2126
  durationDays: number;
2063
2127
  encryptedSessionKey: string;
@@ -2071,10 +2135,13 @@ interface CreateDeviceBoundSessionKeyResponse {
2071
2135
  mode: 'device_bound';
2072
2136
  isCustodial: false;
2073
2137
  userWallet: string;
2138
+ agentId: string;
2139
+ agentName?: string;
2074
2140
  sessionWallet: string;
2075
2141
  limitUsdc: number;
2076
2142
  expiresAt: string;
2077
2143
  requiresClientSigning: true;
2144
+ crossAppCompatible: boolean;
2078
2145
  securityInfo: {
2079
2146
  encryptionType: string;
2080
2147
  deviceBound: boolean;
@@ -2105,6 +2172,8 @@ declare class ZendFiSessionKeyManager {
2105
2172
  *
2106
2173
  * const sessionKey = await manager.createSessionKey({
2107
2174
  * userWallet: '7xKNH....',
2175
+ * agentId: 'shopping-assistant-v1',
2176
+ * agentName: 'AI Shopping Assistant',
2108
2177
  * limitUSDC: 100,
2109
2178
  * durationDays: 7,
2110
2179
  * pin: '123456',
@@ -2112,21 +2181,27 @@ declare class ZendFiSessionKeyManager {
2112
2181
  * });
2113
2182
  *
2114
2183
  * console.log('Session key created:', sessionKey.sessionKeyId);
2184
+ * console.log('Works across all apps with agent:', sessionKey.agentId);
2115
2185
  * console.log('Recovery QR:', sessionKey.recoveryQR);
2116
2186
  * ```
2117
2187
  */
2118
2188
  createSessionKey(options: {
2119
2189
  userWallet: string;
2190
+ agentId: string;
2191
+ agentName?: string;
2120
2192
  limitUSDC: number;
2121
2193
  durationDays: number;
2122
2194
  pin: string;
2123
2195
  generateRecoveryQR?: boolean;
2124
2196
  }): Promise<{
2125
2197
  sessionKeyId: string;
2198
+ agentId: string;
2199
+ agentName?: string;
2126
2200
  sessionWallet: string;
2127
2201
  expiresAt: string;
2128
2202
  recoveryQR?: string;
2129
2203
  limitUsdc: number;
2204
+ crossAppCompatible: boolean;
2130
2205
  }>;
2131
2206
  /**
2132
2207
  * Load an existing session key from backend
@@ -2360,4 +2435,988 @@ declare function requiresLitSigning(session: {
2360
2435
  declare function encodeTransactionForLit(transaction: Uint8Array | Buffer): string;
2361
2436
  declare function decodeSignatureFromLit(result: SignPaymentResult): Uint8Array | null;
2362
2437
 
2363
- export { AgentAPI, AgentAnalytics, AgentApiKey, AgentPaymentRequest, AgentPaymentResponse, AgentSession, ApiError, ApproveEscrowRequest, AuthenticationError, AutonomyAPI, AutonomyStatus, ConfigLoader, ConfirmPaymentIntentRequest, CreateAgentApiKeyRequest, CreateAgentSessionRequest, type CreateDeviceBoundSessionKeyRequest, type CreateDeviceBoundSessionKeyResponse, CreateEscrowRequest, CreateInstallmentPlanRequest, CreateInvoiceRequest, CreatePaymentIntentRequest, CreatePaymentLinkRequest, CreatePaymentRequest, CreateSessionKeyRequest, CreateSessionKeyResponse, CreateSubscriptionPlanRequest, CreateSubscriptionRequest, DeviceBoundSessionKey, type DeviceBoundSessionKeyOptions, DeviceFingerprintGenerator, DisputeEscrowRequest, ERROR_CODES, EnableAutonomyRequest, EnableAutonomyResponse, type EncryptedSessionKey, type ErrorInterceptor, Escrow, InstallmentPlan, InterceptorManager, type Interceptors, Invoice, ListPaymentsRequest, LitCryptoSigner, type LitCryptoSignerConfig, type LitNetwork, NetworkError, PPPFactor, PaginatedResponse, Payment, PaymentError, PaymentIntent, PaymentIntentEvent, PaymentIntentsAPI, PaymentLink, PricingAPI, PricingSuggestion, PricingSuggestionRequest, RateLimitError, RateLimiter, type RecoveryQR, RecoveryQRGenerator, RefundEscrowRequest, type RequestConfig, type RequestInterceptor, type ResponseData, type ResponseInterceptor, SPENDING_LIMIT_ACTION_CID, SessionKeyCrypto, SessionKeyListResponse, type SessionKeyPaymentRequest, SessionKeyStatus, SessionKeysAPI, type SignPaymentParams, type SignPaymentResult, SmartPaymentRequest, SmartPaymentResponse, SmartPaymentsAPI, SubmitSignedTransactionRequest, SubmitTransactionResponse, Subscription, SubscriptionPlan, TopUpSessionKeyRequest, TopUpSessionKeyResponse, ValidationError, VerifyWebhookRequest, WebhookError, WebhookPayload, ZendFiClient, ZendFiConfig, ZendFiError, type ZendFiErrorData, type ZendFiErrorType, ZendFiSessionKeyManager, createZendFiError, decodeSignatureFromLit, encodeTransactionForLit, generateIdempotencyKey, isZendFiError, requiresLitSigning, sleep, verifyExpressWebhook, verifyNextWebhook, verifyWebhookSignature, zendfi };
2438
+ /**
2439
+ * Session Key Cache Manager
2440
+ * Optional caching utility for session key keypairs
2441
+ *
2442
+ * @example
2443
+ * ```typescript
2444
+ * import { SessionKeyCache } from '@zendfi/sdk/helpers';
2445
+ *
2446
+ * const cache = new SessionKeyCache({
2447
+ * storage: 'localStorage',
2448
+ * ttl: 3600000, // 1 hour
2449
+ * autoRefresh: true,
2450
+ * });
2451
+ *
2452
+ * // Get cached or decrypt
2453
+ * const keypair = await cache.getCached(sessionKeyId, async () => {
2454
+ * return await SessionKeyCrypto.decrypt(encrypted, pin, fingerprint);
2455
+ * });
2456
+ *
2457
+ * // Invalidate on logout
2458
+ * await cache.clear();
2459
+ * ```
2460
+ */
2461
+ interface CachedKeypair {
2462
+ keypair: any;
2463
+ expiry: number;
2464
+ sessionKeyId: string;
2465
+ deviceFingerprint?: string;
2466
+ }
2467
+ interface SessionKeyCacheConfig {
2468
+ /** Storage backend */
2469
+ storage?: 'memory' | 'localStorage' | 'indexedDB' | CustomStorageAdapter;
2470
+ /** Time-to-live in milliseconds (default: 30 minutes) */
2471
+ ttl?: number;
2472
+ /** Auto-refresh before expiry (default: false) */
2473
+ autoRefresh?: boolean;
2474
+ /** Namespace for storage keys (default: 'zendfi_cache') */
2475
+ namespace?: string;
2476
+ /** Enable debug logging (default: false) */
2477
+ debug?: boolean;
2478
+ }
2479
+ interface CustomStorageAdapter {
2480
+ get(key: string): Promise<string | null>;
2481
+ set(key: string, value: string): Promise<void>;
2482
+ remove(key: string): Promise<void>;
2483
+ clear(): Promise<void>;
2484
+ }
2485
+ /**
2486
+ * Session Key Cache Manager
2487
+ * Provides flexible caching with multiple storage backends
2488
+ */
2489
+ declare class SessionKeyCache {
2490
+ private memoryCache;
2491
+ private config;
2492
+ private refreshTimers;
2493
+ constructor(config?: SessionKeyCacheConfig);
2494
+ /**
2495
+ * Get cached keypair or decrypt and cache
2496
+ */
2497
+ getCached(sessionKeyId: string, decryptFn: () => Promise<any>, options?: {
2498
+ deviceFingerprint?: string;
2499
+ }): Promise<any>;
2500
+ /**
2501
+ * Decrypt keypair and cache it
2502
+ */
2503
+ private decryptAndCache;
2504
+ /**
2505
+ * Invalidate cached keypair
2506
+ */
2507
+ invalidate(sessionKeyId: string): Promise<void>;
2508
+ /**
2509
+ * Clear all cached keypairs
2510
+ */
2511
+ clear(): Promise<void>;
2512
+ /**
2513
+ * Get cache statistics
2514
+ */
2515
+ getStats(): {
2516
+ size: number;
2517
+ entries: Array<{
2518
+ sessionKeyId: string;
2519
+ expiresIn: number;
2520
+ }>;
2521
+ };
2522
+ /**
2523
+ * Check if a session key is cached and valid
2524
+ */
2525
+ isCached(sessionKeyId: string): boolean;
2526
+ /**
2527
+ * Update TTL for a cached session key
2528
+ */
2529
+ extendTTL(sessionKeyId: string, additionalMs: number): Promise<boolean>;
2530
+ private getFromStorage;
2531
+ private setInStorage;
2532
+ private removeFromStorage;
2533
+ private clearStorage;
2534
+ private getFromIndexedDB;
2535
+ private setInIndexedDB;
2536
+ private removeFromIndexedDB;
2537
+ private clearIndexedDB;
2538
+ private serializeKeypair;
2539
+ private deserializeKeypair;
2540
+ private setupAutoRefresh;
2541
+ private getStorageKey;
2542
+ private log;
2543
+ }
2544
+ /**
2545
+ * Pre-configured cache instances for common use cases
2546
+ */
2547
+ declare const QuickCaches: {
2548
+ /** Memory-only cache (30 minutes) */
2549
+ memory: () => SessionKeyCache;
2550
+ /** Persistent cache (1 hour, survives reload) */
2551
+ persistent: () => SessionKeyCache;
2552
+ /** Long-term cache (24 hours, IndexedDB) */
2553
+ longTerm: () => SessionKeyCache;
2554
+ /** Secure cache (5 minutes, memory-only) */
2555
+ secure: () => SessionKeyCache;
2556
+ };
2557
+
2558
+ /**
2559
+ * AI Intent Parser & Adapters
2560
+ * Parse natural language into payment intents
2561
+ *
2562
+ * @example
2563
+ * ```typescript
2564
+ * import { PaymentIntentParser, GeminiAdapter } from '@zendfi/sdk/helpers';
2565
+ *
2566
+ * // Parse AI response
2567
+ * const intent = PaymentIntentParser.parse(aiResponse);
2568
+ * if (intent?.action === 'payment') {
2569
+ * await zendfi.smartPayments.execute({
2570
+ * amount_usd: intent.amount,
2571
+ * description: intent.description,
2572
+ * });
2573
+ * }
2574
+ *
2575
+ * // Or use adapters
2576
+ * const gemini = new GeminiAdapter(apiKey);
2577
+ * const { text, intent } = await gemini.chat('Buy coffee for $5');
2578
+ * ```
2579
+ */
2580
+ interface ParsedIntent {
2581
+ action: 'payment' | 'create_session' | 'check_balance' | 'check_status' | 'topup' | 'revoke' | 'enable_autonomy' | 'chat_only';
2582
+ amount?: number;
2583
+ description?: string;
2584
+ confidence: number;
2585
+ rawText: string;
2586
+ metadata?: Record<string, any>;
2587
+ }
2588
+ interface AICapabilities {
2589
+ createPayment?: boolean;
2590
+ createSessionKey?: boolean;
2591
+ checkBalance?: boolean;
2592
+ checkStatus?: boolean;
2593
+ topUpSession?: boolean;
2594
+ revokeSession?: boolean;
2595
+ enableAutonomy?: boolean;
2596
+ }
2597
+ /**
2598
+ * Payment Intent Parser
2599
+ * Extract payment information from natural language
2600
+ */
2601
+ declare class PaymentIntentParser {
2602
+ /**
2603
+ * Parse natural language into structured intent
2604
+ */
2605
+ static parse(text: string): ParsedIntent | null;
2606
+ /**
2607
+ * Generate system prompt for AI models
2608
+ */
2609
+ static generateSystemPrompt(capabilities?: AICapabilities): string;
2610
+ private static containsPaymentKeywords;
2611
+ private static containsSessionKeywords;
2612
+ private static containsStatusKeywords;
2613
+ private static containsTopUpKeywords;
2614
+ private static containsRevokeKeywords;
2615
+ private static containsAutonomyKeywords;
2616
+ private static extractAmount;
2617
+ private static extractDescription;
2618
+ }
2619
+ interface AIResponse {
2620
+ text: string;
2621
+ intent: ParsedIntent | null;
2622
+ raw?: any;
2623
+ }
2624
+ /**
2625
+ * OpenAI GPT Adapter
2626
+ */
2627
+ declare class OpenAIAdapter {
2628
+ private apiKey;
2629
+ private model;
2630
+ private capabilities?;
2631
+ constructor(apiKey: string, model?: string, capabilities?: AICapabilities | undefined);
2632
+ chat(message: string, conversationHistory?: Array<{
2633
+ role: string;
2634
+ content: string;
2635
+ }>): Promise<AIResponse>;
2636
+ }
2637
+ /**
2638
+ * Anthropic Claude Adapter
2639
+ */
2640
+ declare class AnthropicAdapter {
2641
+ private apiKey;
2642
+ private model;
2643
+ private capabilities?;
2644
+ constructor(apiKey: string, model?: string, capabilities?: AICapabilities | undefined);
2645
+ chat(message: string, conversationHistory?: Array<{
2646
+ role: string;
2647
+ content: string;
2648
+ }>): Promise<AIResponse>;
2649
+ }
2650
+ /**
2651
+ * Google Gemini Adapter
2652
+ */
2653
+ declare class GeminiAdapter {
2654
+ private apiKey;
2655
+ private model;
2656
+ private capabilities?;
2657
+ constructor(apiKey: string, model?: string, capabilities?: AICapabilities | undefined);
2658
+ chat(message: string): Promise<AIResponse>;
2659
+ }
2660
+
2661
+ /**
2662
+ * Wallet Connector
2663
+ * Simplifies integration with Solana wallets (Phantom, Solflare, Backpack, etc.)
2664
+ *
2665
+ * @example
2666
+ * ```typescript
2667
+ * import { WalletConnector } from '@zendfi/sdk/helpers';
2668
+ *
2669
+ * // Auto-detect and connect
2670
+ * const wallet = await WalletConnector.detectAndConnect();
2671
+ * console.log(`Connected: ${wallet.address}`);
2672
+ * console.log(`Provider: ${wallet.provider}`);
2673
+ *
2674
+ * // Sign transaction
2675
+ * const result = await wallet.signTransaction(transaction);
2676
+ *
2677
+ * // Disconnect
2678
+ * await wallet.disconnect();
2679
+ * ```
2680
+ */
2681
+ interface ConnectedWallet {
2682
+ address: string;
2683
+ provider: 'phantom' | 'solflare' | 'backpack' | 'coinbase' | 'trust' | 'unknown';
2684
+ publicKey: any;
2685
+ signTransaction: (tx: any) => Promise<any>;
2686
+ signAllTransactions: (txs: any[]) => Promise<any[]>;
2687
+ signMessage: (message: Uint8Array) => Promise<{
2688
+ signature: Uint8Array;
2689
+ }>;
2690
+ disconnect: () => Promise<void>;
2691
+ isConnected: () => boolean;
2692
+ raw: any;
2693
+ }
2694
+ interface WalletConnectorConfig {
2695
+ /** Preferred wallet provider (if multiple detected) */
2696
+ preferredProvider?: 'phantom' | 'solflare' | 'backpack' | 'coinbase' | 'trust';
2697
+ /** Auto-connect on page load if previously connected */
2698
+ autoConnect?: boolean;
2699
+ /** Show connection UI if no wallet detected */
2700
+ showInstallPrompt?: boolean;
2701
+ /** Network (mainnet-beta, devnet, testnet) */
2702
+ network?: string;
2703
+ }
2704
+ /**
2705
+ * Wallet Connector
2706
+ * Detects and connects to Solana wallets
2707
+ */
2708
+ declare class WalletConnector {
2709
+ private static connectedWallet;
2710
+ /**
2711
+ * Detect and connect to a Solana wallet
2712
+ */
2713
+ static detectAndConnect(config?: WalletConnectorConfig): Promise<ConnectedWallet>;
2714
+ /**
2715
+ * Detect available Solana wallets
2716
+ */
2717
+ static detectWallets(): Array<'phantom' | 'solflare' | 'backpack' | 'coinbase' | 'trust'>;
2718
+ /**
2719
+ * Connect to a specific wallet provider
2720
+ */
2721
+ static connectToProvider(provider: 'phantom' | 'solflare' | 'backpack' | 'coinbase' | 'trust'): Promise<ConnectedWallet>;
2722
+ /**
2723
+ * Sign and submit a transaction
2724
+ */
2725
+ static signAndSubmit(transaction: any, wallet: ConnectedWallet, connection: any): Promise<{
2726
+ signature: string;
2727
+ }>;
2728
+ /**
2729
+ * Get current connected wallet
2730
+ */
2731
+ static getConnectedWallet(): ConnectedWallet | null;
2732
+ /**
2733
+ * Disconnect current wallet
2734
+ */
2735
+ static disconnect(): Promise<void>;
2736
+ /**
2737
+ * Listen for wallet connection changes
2738
+ */
2739
+ static onAccountChange(callback: (publicKey: any) => void): () => void;
2740
+ /**
2741
+ * Listen for wallet disconnection
2742
+ */
2743
+ static onDisconnect(callback: () => void): () => void;
2744
+ /**
2745
+ * Show install prompt UI
2746
+ */
2747
+ private static showInstallPrompt;
2748
+ /**
2749
+ * Check if wallet is installed
2750
+ */
2751
+ static isWalletInstalled(provider: 'phantom' | 'solflare' | 'backpack' | 'coinbase' | 'trust'): boolean;
2752
+ /**
2753
+ * Get wallet download URL
2754
+ */
2755
+ static getWalletUrl(provider: 'phantom' | 'solflare' | 'backpack' | 'coinbase' | 'trust'): string;
2756
+ }
2757
+ /**
2758
+ * React Hook for Wallet Connection (optional)
2759
+ * Export as separate module to avoid forcing React dependency
2760
+ */
2761
+ declare function createWalletHook(): () => {
2762
+ wallet: any;
2763
+ connecting: any;
2764
+ error: any;
2765
+ connect: (config?: WalletConnectorConfig) => Promise<void>;
2766
+ disconnect: () => Promise<void>;
2767
+ isConnected: boolean;
2768
+ };
2769
+
2770
+ /**
2771
+ * Security Utilities
2772
+ * PIN validation, rate limiting, and security best practices
2773
+ *
2774
+ * @example
2775
+ * ```typescript
2776
+ * import { PINValidator, PINRateLimiter } from '@zendfi/sdk/helpers';
2777
+ *
2778
+ * // Validate PIN
2779
+ * const validation = PINValidator.validate(pin);
2780
+ * if (!validation.valid) {
2781
+ * console.error(validation.errors);
2782
+ * }
2783
+ *
2784
+ * // Rate limit PIN attempts
2785
+ * const limiter = new PINRateLimiter();
2786
+ * const attempt = await limiter.checkAttempt(sessionKeyId);
2787
+ * if (!attempt.allowed) {
2788
+ * console.log(`Locked out for ${attempt.lockoutSeconds}s`);
2789
+ * }
2790
+ * ```
2791
+ */
2792
+ interface PINValidationResult {
2793
+ valid: boolean;
2794
+ strength: 'weak' | 'medium' | 'strong';
2795
+ errors: string[];
2796
+ suggestions: string[];
2797
+ }
2798
+ /**
2799
+ * PIN Validator
2800
+ * Validates PIN security and strength
2801
+ */
2802
+ declare class PINValidator {
2803
+ /**
2804
+ * Validate PIN strength and format
2805
+ */
2806
+ static validate(pin: string): PINValidationResult;
2807
+ /**
2808
+ * Check PIN strength (0-100 score)
2809
+ */
2810
+ static strengthScore(pin: string): number;
2811
+ /**
2812
+ * Generate a secure random PIN
2813
+ */
2814
+ static generateSecureRandom(length?: number): string;
2815
+ /**
2816
+ * Check for weak patterns
2817
+ */
2818
+ private static isWeakPattern;
2819
+ /**
2820
+ * Check if PIN is sequential
2821
+ */
2822
+ private static isSequential;
2823
+ /**
2824
+ * Check if PIN has repeated digits
2825
+ */
2826
+ private static hasRepeatedDigits;
2827
+ /**
2828
+ * Hash PIN for storage (if needed)
2829
+ * Note: For device-bound keys, the PIN is used for key derivation, not storage
2830
+ */
2831
+ static hashPIN(pin: string, salt?: string): Promise<string>;
2832
+ }
2833
+ /**
2834
+ * PIN Rate Limiter
2835
+ * Prevents brute-force attacks on PIN entry
2836
+ */
2837
+ declare class PINRateLimiter {
2838
+ private attempts;
2839
+ private locked;
2840
+ private maxAttempts;
2841
+ private windowMs;
2842
+ private lockoutMs;
2843
+ constructor(config?: {
2844
+ maxAttempts?: number;
2845
+ windowMs?: number;
2846
+ lockoutMs?: number;
2847
+ });
2848
+ /**
2849
+ * Check if attempt is allowed
2850
+ */
2851
+ checkAttempt(sessionKeyId: string): Promise<{
2852
+ allowed: boolean;
2853
+ remainingAttempts: number;
2854
+ lockoutSeconds?: number;
2855
+ }>;
2856
+ /**
2857
+ * Record a failed attempt
2858
+ */
2859
+ recordFailedAttempt(sessionKeyId: string): void;
2860
+ /**
2861
+ * Record a successful attempt (clears history)
2862
+ */
2863
+ recordSuccessfulAttempt(sessionKeyId: string): void;
2864
+ /**
2865
+ * Get recent attempts within window
2866
+ */
2867
+ private getRecentAttempts;
2868
+ /**
2869
+ * Clear all rate limit data
2870
+ */
2871
+ clear(): void;
2872
+ /**
2873
+ * Check lockout status
2874
+ */
2875
+ isLockedOut(sessionKeyId: string): boolean;
2876
+ /**
2877
+ * Get remaining lockout time
2878
+ */
2879
+ getRemainingLockoutTime(sessionKeyId: string): number;
2880
+ }
2881
+ /**
2882
+ * Secure Storage Helper
2883
+ * Utilities for secure data storage
2884
+ */
2885
+ declare class SecureStorage {
2886
+ /**
2887
+ * Store data with encryption (basic)
2888
+ * For production, consider using Web Crypto API with user-derived keys
2889
+ */
2890
+ static setEncrypted(key: string, value: string, secret: string): Promise<void>;
2891
+ /**
2892
+ * Retrieve encrypted data
2893
+ */
2894
+ static getEncrypted(key: string, secret: string): Promise<string | null>;
2895
+ /**
2896
+ * Encrypt string with AES-GCM
2897
+ */
2898
+ private static encrypt;
2899
+ /**
2900
+ * Decrypt AES-GCM ciphertext
2901
+ */
2902
+ private static decrypt;
2903
+ /**
2904
+ * Derive encryption key from secret
2905
+ */
2906
+ private static deriveKey;
2907
+ /**
2908
+ * Clear all secure storage
2909
+ */
2910
+ static clearAll(namespace?: string): void;
2911
+ }
2912
+
2913
+ /**
2914
+ * Transaction Polling Utilities
2915
+ * Poll Solana transactions with exponential backoff
2916
+ *
2917
+ * @example
2918
+ * ```typescript
2919
+ * import { TransactionPoller } from '@zendfi/sdk/helpers';
2920
+ *
2921
+ * // Wait for confirmation
2922
+ * const status = await TransactionPoller.waitForConfirmation(
2923
+ * signature,
2924
+ * { timeout: 60000, interval: 2000 }
2925
+ * );
2926
+ *
2927
+ * if (status.confirmed) {
2928
+ * console.log(`Confirmed in slot ${status.slot}`);
2929
+ * }
2930
+ * ```
2931
+ */
2932
+ interface TransactionStatus {
2933
+ confirmed: boolean;
2934
+ signature: string;
2935
+ slot?: number;
2936
+ blockTime?: number;
2937
+ confirmations?: number;
2938
+ error?: string;
2939
+ }
2940
+ interface PollingOptions {
2941
+ /** Maximum time to wait in ms (default: 60000 = 1 minute) */
2942
+ timeout?: number;
2943
+ /** Initial polling interval in ms (default: 2000 = 2 seconds) */
2944
+ interval?: number;
2945
+ /** Maximum polling interval in ms (default: 10000 = 10 seconds) */
2946
+ maxInterval?: number;
2947
+ /** Maximum number of attempts (default: 30) */
2948
+ maxAttempts?: number;
2949
+ /** Commitment level (default: 'confirmed') */
2950
+ commitment?: 'processed' | 'confirmed' | 'finalized';
2951
+ /** RPC endpoint (optional, uses default if not provided) */
2952
+ rpcUrl?: string;
2953
+ }
2954
+ /**
2955
+ * Transaction Poller
2956
+ * Poll transaction status with smart backoff
2957
+ */
2958
+ declare class TransactionPoller {
2959
+ /**
2960
+ * Wait for transaction confirmation
2961
+ */
2962
+ static waitForConfirmation(signature: string, options?: PollingOptions): Promise<TransactionStatus>;
2963
+ /**
2964
+ * Check transaction status via RPC
2965
+ */
2966
+ private static checkTransactionStatus;
2967
+ /**
2968
+ * Check if commitment level is reached
2969
+ */
2970
+ private static isCommitmentReached;
2971
+ /**
2972
+ * Get default RPC URL based on environment
2973
+ */
2974
+ private static getDefaultRpcUrl;
2975
+ /**
2976
+ * Poll multiple transactions in parallel
2977
+ */
2978
+ static waitForMultiple(signatures: string[], options?: PollingOptions): Promise<TransactionStatus[]>;
2979
+ /**
2980
+ * Get transaction details after confirmation
2981
+ */
2982
+ static getTransactionDetails(signature: string, rpcUrl?: string): Promise<any>;
2983
+ /**
2984
+ * Check if transaction exists on chain
2985
+ */
2986
+ static exists(signature: string, rpcUrl?: string): Promise<boolean>;
2987
+ /**
2988
+ * Get recent blockhash (useful for transaction building)
2989
+ */
2990
+ static getRecentBlockhash(rpcUrl?: string): Promise<{
2991
+ blockhash: string;
2992
+ lastValidBlockHeight: number;
2993
+ }>;
2994
+ /**
2995
+ * Sleep utility
2996
+ */
2997
+ private static sleep;
2998
+ }
2999
+ /**
3000
+ * Transaction Monitor
3001
+ * Monitor transaction status with callbacks
3002
+ */
3003
+ declare class TransactionMonitor {
3004
+ private monitors;
3005
+ /**
3006
+ * Start monitoring a transaction
3007
+ */
3008
+ monitor(signature: string, callbacks: {
3009
+ onConfirmed?: (status: TransactionStatus) => void;
3010
+ onFailed?: (status: TransactionStatus) => void;
3011
+ onTimeout?: () => void;
3012
+ }, options?: PollingOptions): void;
3013
+ /**
3014
+ * Stop monitoring a transaction
3015
+ */
3016
+ stopMonitoring(signature: string): void;
3017
+ /**
3018
+ * Stop all monitors
3019
+ */
3020
+ stopAll(): void;
3021
+ /**
3022
+ * Get active monitors
3023
+ */
3024
+ getActiveMonitors(): string[];
3025
+ }
3026
+
3027
+ /**
3028
+ * Retry Strategy & Error Recovery
3029
+ * Smart retry logic with exponential backoff
3030
+ *
3031
+ * @example
3032
+ * ```typescript
3033
+ * import { RetryStrategy, ErrorRecovery } from '@zendfi/sdk/helpers';
3034
+ *
3035
+ * // Retry with exponential backoff
3036
+ * const result = await RetryStrategy.withRetry(
3037
+ * () => zendfi.smartPayments.execute({ amount_usd: 50 }),
3038
+ * { maxAttempts: 3, backoffMs: 1000 }
3039
+ * );
3040
+ *
3041
+ * // Auto-recover from common errors
3042
+ * const payment = await ErrorRecovery.recoverFromNetworkError(
3043
+ * () => createPayment()
3044
+ * );
3045
+ * ```
3046
+ */
3047
+ interface RetryOptions {
3048
+ /** Maximum number of retry attempts (default: 3) */
3049
+ maxAttempts?: number;
3050
+ /** Initial backoff delay in ms (default: 1000) */
3051
+ backoffMs?: number;
3052
+ /** Backoff multiplier (default: 2 for exponential) */
3053
+ backoffMultiplier?: number;
3054
+ /** Maximum backoff delay in ms (default: 30000) */
3055
+ maxBackoffMs?: number;
3056
+ /** Function to determine if error is retryable (default: all errors) */
3057
+ shouldRetry?: (error: Error, attempt: number) => boolean;
3058
+ /** Callback on each retry */
3059
+ onRetry?: (error: Error, attempt: number, nextDelayMs: number) => void;
3060
+ }
3061
+ /**
3062
+ * Retry Strategy
3063
+ * Implements smart retry logic with exponential backoff
3064
+ */
3065
+ declare class RetryStrategy {
3066
+ /**
3067
+ * Execute function with retry logic
3068
+ */
3069
+ static withRetry<T>(fn: () => Promise<T>, options?: RetryOptions): Promise<T>;
3070
+ /**
3071
+ * Retry with linear backoff
3072
+ */
3073
+ static withLinearRetry<T>(fn: () => Promise<T>, maxAttempts?: number, delayMs?: number): Promise<T>;
3074
+ /**
3075
+ * Retry with custom backoff function
3076
+ */
3077
+ static withCustomBackoff<T>(fn: () => Promise<T>, backoffFn: (attempt: number) => number, maxAttempts?: number): Promise<T>;
3078
+ /**
3079
+ * Check if error is retryable
3080
+ */
3081
+ static isRetryableError(error: any): boolean;
3082
+ private static sleep;
3083
+ }
3084
+ /**
3085
+ * Error Recovery
3086
+ * Auto-recovery strategies for common failure scenarios
3087
+ */
3088
+ declare class ErrorRecovery {
3089
+ /**
3090
+ * Recover from network errors with retry
3091
+ */
3092
+ static recoverFromNetworkError<T>(fn: () => Promise<T>, maxAttempts?: number): Promise<T>;
3093
+ /**
3094
+ * Recover from rate limit errors with exponential backoff
3095
+ */
3096
+ static recoverFromRateLimit<T>(fn: () => Promise<T>, maxAttempts?: number): Promise<T>;
3097
+ /**
3098
+ * Recover from Solana RPC errors (blockhash, etc.)
3099
+ */
3100
+ static recoverFromRPCError<T>(fn: () => Promise<T>, maxAttempts?: number): Promise<T>;
3101
+ /**
3102
+ * Recover from timeout errors
3103
+ */
3104
+ static recoverFromTimeout<T>(fn: () => Promise<T>, timeoutMs?: number, maxAttempts?: number): Promise<T>;
3105
+ /**
3106
+ * Add timeout to async function
3107
+ */
3108
+ private static withTimeout;
3109
+ /**
3110
+ * Circuit breaker pattern for repeated failures
3111
+ */
3112
+ static createCircuitBreaker<T>(fn: () => Promise<T>, options?: {
3113
+ failureThreshold?: number;
3114
+ resetTimeoutMs?: number;
3115
+ onStateChange?: (state: 'closed' | 'open' | 'half-open') => void;
3116
+ }): () => Promise<T>;
3117
+ /**
3118
+ * Fallback to alternative function on error
3119
+ */
3120
+ static withFallback<T>(primaryFn: () => Promise<T>, fallbackFn: () => Promise<T>, shouldFallback?: (error: Error) => boolean): Promise<T>;
3121
+ /**
3122
+ * Graceful degradation - return partial result on error
3123
+ */
3124
+ static withGracefulDegradation<T>(fn: () => Promise<T>, defaultValue: T, onError?: (error: Error) => void): Promise<T>;
3125
+ }
3126
+
3127
+ /**
3128
+ * Session Key Lifecycle Manager
3129
+ * High-level wrapper for device-bound session keys
3130
+ * Handles common patterns: create → cache → use → revoke
3131
+ *
3132
+ * @example
3133
+ * ```typescript
3134
+ * import { SessionKeyLifecycle } from '@zendfi/sdk/helpers';
3135
+ *
3136
+ * const lifecycle = new SessionKeyLifecycle(zendfi, {
3137
+ * cache: QuickCaches.persistent(),
3138
+ * pinProvider: () => promptUserForPIN(),
3139
+ * });
3140
+ *
3141
+ * // Create and fund in one call
3142
+ * await lifecycle.createAndFund({
3143
+ * userWallet: address,
3144
+ * agentId: 'my-agent',
3145
+ * limitUsdc: 100,
3146
+ * });
3147
+ *
3148
+ * // Make payments (auto-handles caching/PIN)
3149
+ * await lifecycle.pay(5, 'Coffee');
3150
+ *
3151
+ * // Cleanup on app close
3152
+ * await lifecycle.cleanup();
3153
+ * ```
3154
+ */
3155
+
3156
+ interface LifecycleConfig {
3157
+ /** Optional cache instance */
3158
+ cache?: SessionKeyCache;
3159
+ /** PIN provider function (called when cache expires) */
3160
+ pinProvider?: () => Promise<string>;
3161
+ /** Device fingerprint generator */
3162
+ deviceFingerprintProvider?: () => Promise<string>;
3163
+ /** Auto-cleanup on window/tab close */
3164
+ autoCleanup?: boolean;
3165
+ }
3166
+ interface CreateAndFundConfig {
3167
+ userWallet: string;
3168
+ agentId: string;
3169
+ agentName?: string;
3170
+ limitUsdc: number;
3171
+ durationDays?: number;
3172
+ onApprovalNeeded?: (transaction: string) => Promise<string>;
3173
+ }
3174
+ interface PaymentResult {
3175
+ paymentId: string;
3176
+ status: string;
3177
+ signature?: string;
3178
+ confirmedInMs?: number;
3179
+ }
3180
+ /**
3181
+ * Session Key Lifecycle Manager
3182
+ * Simplifies device-bound session key management
3183
+ */
3184
+ declare class SessionKeyLifecycle {
3185
+ private client;
3186
+ private config;
3187
+ private sessionKeyId;
3188
+ private sessionWallet;
3189
+ private encryptedKey;
3190
+ private deviceFingerprint;
3191
+ constructor(client: ZendFiClient, config?: LifecycleConfig);
3192
+ /**
3193
+ * Create and fund session key in one call
3194
+ * Handles: keypair generation → encryption → backend registration → funding
3195
+ */
3196
+ createAndFund(config: CreateAndFundConfig): Promise<{
3197
+ sessionKeyId: string;
3198
+ sessionWallet: string;
3199
+ }>;
3200
+ /**
3201
+ * Make a payment using the session key
3202
+ * Auto-handles caching, PIN prompts, and signing
3203
+ */
3204
+ pay(amount: number, description: string): Promise<PaymentResult>;
3205
+ /**
3206
+ * Check session key status
3207
+ */
3208
+ getStatus(): Promise<SessionKeyStatus>;
3209
+ /**
3210
+ * Top up session key
3211
+ */
3212
+ topUp(amount: number, userWallet: string, onApprovalNeeded?: (tx: string) => Promise<void>): Promise<void>;
3213
+ /**
3214
+ * Revoke session key
3215
+ */
3216
+ revoke(): Promise<void>;
3217
+ /**
3218
+ * Cleanup (clear cache, reset state)
3219
+ */
3220
+ cleanup(): Promise<void>;
3221
+ /**
3222
+ * Get current session key ID
3223
+ */
3224
+ getSessionKeyId(): string | null;
3225
+ /**
3226
+ * Check if session is active
3227
+ */
3228
+ isActive(): boolean;
3229
+ private decryptKeypair;
3230
+ private generateDeviceFingerprint;
3231
+ private promptForPIN;
3232
+ private getSolanaWeb3;
3233
+ }
3234
+ /**
3235
+ * Quick setup function for common use case
3236
+ */
3237
+ declare function setupQuickSessionKey(client: ZendFiClient, config: {
3238
+ userWallet: string;
3239
+ agentId: string;
3240
+ budgetUsdc: number;
3241
+ onApproval: (tx: string) => Promise<string>;
3242
+ }): Promise<SessionKeyLifecycle>;
3243
+
3244
+ /**
3245
+ * Development Tools & Utilities
3246
+ * Debugging helpers for development and testing
3247
+ *
3248
+ * @example
3249
+ * ```typescript
3250
+ * import { DevTools } from '@zendfi/sdk/helpers';
3251
+ *
3252
+ * // Enable debug mode
3253
+ * DevTools.enableDebugMode();
3254
+ *
3255
+ * // Create test session key
3256
+ * const testKey = await DevTools.createTestSessionKey();
3257
+ *
3258
+ * // Mock wallet for testing
3259
+ * const mockWallet = DevTools.mockWallet();
3260
+ *
3261
+ * // Log transaction flow
3262
+ * DevTools.logTransactionFlow(paymentId);
3263
+ * ```
3264
+ */
3265
+ interface MockWallet {
3266
+ address: string;
3267
+ publicKey: any;
3268
+ signTransaction: (tx: any) => Promise<any>;
3269
+ signMessage: (msg: Uint8Array) => Promise<{
3270
+ signature: Uint8Array;
3271
+ }>;
3272
+ isConnected: () => boolean;
3273
+ disconnect: () => Promise<void>;
3274
+ }
3275
+ interface TestSessionKey {
3276
+ sessionKeyId: string;
3277
+ sessionWallet: string;
3278
+ privateKey: Uint8Array;
3279
+ budget: number;
3280
+ }
3281
+ /**
3282
+ * Development Tools
3283
+ * Utilities for debugging and testing
3284
+ */
3285
+ declare class DevTools {
3286
+ private static debugEnabled;
3287
+ private static requestLog;
3288
+ /**
3289
+ * Enable debug mode (logs all API requests/responses)
3290
+ */
3291
+ static enableDebugMode(): void;
3292
+ /**
3293
+ * Disable debug mode
3294
+ */
3295
+ static disableDebugMode(): void;
3296
+ /**
3297
+ * Check if debug mode is enabled
3298
+ */
3299
+ static isDebugEnabled(): boolean;
3300
+ /**
3301
+ * Log API request
3302
+ */
3303
+ static logRequest(method: string, url: string, body?: any): void;
3304
+ /**
3305
+ * Log API response
3306
+ */
3307
+ static logResponse(method: string, url: string, status: number, data: any, duration?: number): void;
3308
+ /**
3309
+ * Get request log
3310
+ */
3311
+ static getRequestLog(): Array<{
3312
+ timestamp: Date;
3313
+ method: string;
3314
+ url: string;
3315
+ status?: number;
3316
+ duration?: number;
3317
+ }>;
3318
+ /**
3319
+ * Clear request log
3320
+ */
3321
+ static clearRequestLog(): void;
3322
+ /**
3323
+ * Create a test session key (devnet only)
3324
+ */
3325
+ static createTestSessionKey(): Promise<TestSessionKey>;
3326
+ /**
3327
+ * Create a mock wallet for testing
3328
+ */
3329
+ static mockWallet(address?: string): MockWallet;
3330
+ /**
3331
+ * Log transaction flow (visual diagram in console)
3332
+ */
3333
+ static logTransactionFlow(paymentId: string): void;
3334
+ /**
3335
+ * Log session key lifecycle
3336
+ */
3337
+ static logSessionKeyLifecycle(sessionKeyId: string): void;
3338
+ /**
3339
+ * Benchmark API request
3340
+ */
3341
+ static benchmarkRequest<T>(name: string, fn: () => Promise<T>): Promise<{
3342
+ result: T;
3343
+ durationMs: number;
3344
+ }>;
3345
+ /**
3346
+ * Stress test (send multiple concurrent requests)
3347
+ */
3348
+ static stressTest<T>(name: string, fn: () => Promise<T>, concurrency?: number, iterations?: number): Promise<{
3349
+ totalRequests: number;
3350
+ successful: number;
3351
+ failed: number;
3352
+ avgDurationMs: number;
3353
+ minDurationMs: number;
3354
+ maxDurationMs: number;
3355
+ }>;
3356
+ /**
3357
+ * Inspect ZendFi SDK configuration
3358
+ */
3359
+ static inspectConfig(client: any): void;
3360
+ /**
3361
+ * Generate test data
3362
+ */
3363
+ static generateTestData(): {
3364
+ userWallet: string;
3365
+ agentId: string;
3366
+ sessionKeyId: string;
3367
+ paymentId: string;
3368
+ };
3369
+ /**
3370
+ * Check if running in development environment
3371
+ */
3372
+ private static isDevelopment;
3373
+ /**
3374
+ * Generate test Solana address
3375
+ */
3376
+ private static generateTestAddress;
3377
+ /**
3378
+ * Generate test ID with prefix
3379
+ */
3380
+ private static generateTestId;
3381
+ /**
3382
+ * Get Solana Web3.js
3383
+ */
3384
+ private static getSolanaWeb3;
3385
+ }
3386
+ /**
3387
+ * Performance Monitor
3388
+ * Track SDK performance metrics
3389
+ */
3390
+ declare class PerformanceMonitor {
3391
+ private metrics;
3392
+ /**
3393
+ * Record a metric
3394
+ */
3395
+ record(name: string, value: number): void;
3396
+ /**
3397
+ * Get statistics for a metric
3398
+ */
3399
+ getStats(name: string): {
3400
+ count: number;
3401
+ avg: number;
3402
+ min: number;
3403
+ max: number;
3404
+ p50: number;
3405
+ p95: number;
3406
+ p99: number;
3407
+ } | null;
3408
+ /**
3409
+ * Get all metrics
3410
+ */
3411
+ getAllStats(): Record<string, ReturnType<typeof this.getStats>>;
3412
+ /**
3413
+ * Print report
3414
+ */
3415
+ printReport(): void;
3416
+ /**
3417
+ * Clear all metrics
3418
+ */
3419
+ clear(): void;
3420
+ }
3421
+
3422
+ export { AgentAPI, AgentAnalytics, AgentApiKey, AgentPaymentRequest, AgentPaymentResponse, AgentSession, AnthropicAdapter, ApiError, ApproveEscrowRequest, AuthenticationError, AutonomyAPI, AutonomyStatus, type CachedKeypair, ConfigLoader, ConfirmPaymentIntentRequest, type ConnectedWallet, CreateAgentApiKeyRequest, CreateAgentSessionRequest, type CreateAndFundConfig, type CreateDeviceBoundSessionKeyRequest, type CreateDeviceBoundSessionKeyResponse, CreateEscrowRequest, CreateInstallmentPlanRequest, CreateInvoiceRequest, CreatePaymentIntentRequest, CreatePaymentLinkRequest, CreatePaymentRequest, CreateSessionKeyRequest, CreateSessionKeyResponse, CreateSubscriptionPlanRequest, CreateSubscriptionRequest, type CustomStorageAdapter, DevTools, DeviceBoundSessionKey, type DeviceBoundSessionKeyOptions, DeviceFingerprintGenerator, DisputeEscrowRequest, ERROR_CODES, EnableAutonomyRequest, EnableAutonomyResponse, type EncryptedSessionKey, type ErrorInterceptor, ErrorRecovery, Escrow, GeminiAdapter, InstallmentPlan, InterceptorManager, type Interceptors, Invoice, type LifecycleConfig, ListPaymentsRequest, LitCryptoSigner, type LitCryptoSignerConfig, type LitNetwork, type MockWallet, NetworkError, OpenAIAdapter, PINRateLimiter, type PINValidationResult, PINValidator, PPPFactor, PaginatedResponse, type ParsedIntent, Payment, PaymentError, PaymentIntent, PaymentIntentEvent, PaymentIntentParser, PaymentIntentsAPI, PaymentLink, type PaymentResult, PerformanceMonitor, type PollingOptions, PricingAPI, PricingSuggestion, PricingSuggestionRequest, QuickCaches, RateLimitError, RateLimiter, type RecoveryQR, RecoveryQRGenerator, RefundEscrowRequest, type RequestConfig, type RequestInterceptor, type ResponseData, type ResponseInterceptor, type RetryOptions, RetryStrategy, SPENDING_LIMIT_ACTION_CID, SecureStorage, SessionKeyCache, type SessionKeyCacheConfig, SessionKeyCrypto, SessionKeyLifecycle, SessionKeyListResponse, type SessionKeyPaymentRequest, SessionKeyStatus, SessionKeysAPI, type SignPaymentParams, type SignPaymentResult, SmartPaymentRequest, SmartPaymentResponse, SmartPaymentsAPI, SubmitSignedTransactionRequest, SubmitTransactionResponse, Subscription, SubscriptionPlan, type TestSessionKey, TopUpSessionKeyRequest, TopUpSessionKeyResponse, TransactionMonitor, TransactionPoller, type TransactionStatus, ValidationError, VerifyWebhookRequest, WalletConnector, WebhookError, WebhookPayload, ZendFiClient, ZendFiConfig, ZendFiError, type ZendFiErrorData, type ZendFiErrorType, ZendFiSessionKeyManager, createWalletHook, createZendFiError, decodeSignatureFromLit, encodeTransactionForLit, generateIdempotencyKey, isZendFiError, requiresLitSigning, setupQuickSessionKey, sleep, verifyExpressWebhook, verifyNextWebhook, verifyWebhookSignature, zendfi };