@zendfi/sdk 0.5.2 → 0.5.4

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/README.md CHANGED
@@ -20,6 +20,7 @@ Accept **SOL, USDC, and USDT** payments in your app with just a few lines of cod
20
20
  - **Test Mode** — Free devnet testing with no real money
21
21
  - **Multi-Network** — Automatic routing to devnet or mainnet
22
22
  - **Agentic Intent Protocol** — AI agent payment capabilities with scoped API keys
23
+ - **Session Keys** — On-chain funded wallets for autonomous agent payments
23
24
  - **PPP Pricing** — Purchasing Power Parity for global reach (27+ countries)
24
25
  - **Payment Intents** — Two-phase commit pattern for reliable checkout
25
26
 
@@ -146,6 +147,7 @@ import { zendfi } from '@zendfi/sdk';
146
147
  // Agent API - Manage agent keys and sessions
147
148
  zendfi.agent.createKey(...)
148
149
  zendfi.agent.createSession(...)
150
+ zendfi.agent.pay(...) // Make payments via sessions
149
151
 
150
152
  // Payment Intents - Two-phase payment flow
151
153
  zendfi.intents.create(...)
@@ -162,6 +164,13 @@ zendfi.autonomy.getStatus(...)
162
164
  // Smart Payments - AI-powered routing
163
165
  zendfi.smart.execute(...)
164
166
  zendfi.smart.submitSigned(...) // For device-bound flows
167
+
168
+ // Session Keys - On-chain funded wallets with PKP identity
169
+ zendfi.sessionKeys.create(...)
170
+ zendfi.sessionKeys.submitApproval(...)
171
+ zendfi.sessionKeys.getStatus(...)
172
+ zendfi.sessionKeys.topUp(...)
173
+ zendfi.sessionKeys.revoke(...)
165
174
  ```
166
175
 
167
176
  ### Agent API Keys
@@ -213,6 +222,23 @@ const session = await zendfi.agent.createSession({
213
222
  duration_hours: 24,
214
223
  });
215
224
 
225
+ // Make payments within the session (spending limits enforced!)
226
+ const payment = await zendfi.agent.pay({
227
+ session_token: session.session_token,
228
+ amount: 29.99,
229
+ description: 'Premium widget',
230
+ auto_gasless: true,
231
+ });
232
+
233
+ if (payment.requires_signature) {
234
+ // Device-bound: user must sign
235
+ console.log('Sign transaction:', payment.unsigned_transaction);
236
+ console.log('Submit to:', payment.submit_url);
237
+ } else {
238
+ // Auto-signed: payment complete
239
+ console.log('Payment confirmed:', payment.transaction_signature);
240
+ }
241
+
216
242
  // List active sessions
217
243
  const sessions = await zendfi.agent.listSessions();
218
244
 
@@ -313,6 +339,71 @@ const status = await zendfi.autonomy.getStatus(walletAddress);
313
339
  await zendfi.autonomy.revoke(delegateId);
314
340
  ```
315
341
 
342
+ ### Session Keys (On-Chain Funded Wallets)
343
+
344
+ Session keys are pre-funded wallets with spending limits that enable AI agents to make autonomous payments. They use Lit Protocol's PKP (Programmable Key Pairs) for secure on-chain identity.
345
+
346
+ **The Flow:**
347
+ 1. **Create** - Agent requests a session key with spending limit
348
+ 2. **Approve** - User signs a one-time approval transaction
349
+ 3. **Spend** - Agent makes payments autonomously up to the limit
350
+ 4. **Top-up** - Optionally add more funds when needed
351
+
352
+ ```typescript
353
+ // Step 1: Create a session key
354
+ const key = await zendfi.sessionKeys.create({
355
+ agent_id: 'shopping-assistant',
356
+ user_wallet: 'Hx7B...abc',
357
+ max_amount: 100, // $100 spending limit
358
+ expiry_hours: 24, // Valid for 24 hours
359
+ token: 'USDC',
360
+ });
361
+
362
+ // key.session_key_id - Unique identifier
363
+ // key.approval_transaction - Transaction for user to sign
364
+ // key.session_key_address - The funded wallet address
365
+ // key.pkp_public_key - Lit Protocol PKP public key
366
+
367
+ // Step 2: User signs the approval transaction (one-time)
368
+ const signedTx = await wallet.signTransaction(key.approval_transaction);
369
+ await zendfi.sessionKeys.submitApproval(key.session_key_id, {
370
+ signed_transaction: signedTx,
371
+ });
372
+
373
+ // Step 3: Check status and make payments
374
+ const status = await zendfi.sessionKeys.getStatus(key.session_key_id);
375
+ console.log(`Status: ${status.status}`); // "active"
376
+ console.log(`Remaining: $${status.remaining_amount}`);
377
+ console.log(`Spent: $${status.spent_amount}`);
378
+ console.log(`Transactions: ${status.transaction_count}`);
379
+
380
+ // Step 4: Top-up if needed
381
+ const topUp = await zendfi.sessionKeys.topUp(key.session_key_id, {
382
+ amount: 50, // Add $50 more
383
+ });
384
+ // User signs the top-up transaction
385
+ const signedTopUp = await wallet.signTransaction(topUp.approval_transaction);
386
+ await zendfi.sessionKeys.submitTopUp(key.session_key_id, {
387
+ signed_transaction: signedTopUp,
388
+ });
389
+
390
+ // Revoke when done
391
+ await zendfi.sessionKeys.revoke(key.session_key_id);
392
+
393
+ // List all session keys
394
+ const keys = await zendfi.sessionKeys.list();
395
+ keys.session_keys.forEach(k => {
396
+ console.log(`${k.session_key_id}: $${k.remaining_amount} remaining`);
397
+ });
398
+ ```
399
+
400
+ **Session Key Statuses:**
401
+ - `pending_approval` - Waiting for user to sign approval
402
+ - `active` - Ready for payments
403
+ - `exhausted` - Spending limit reached
404
+ - `expired` - Past expiry time
405
+ - `revoked` - Manually revoked
406
+
316
407
  ### Smart Payments
317
408
 
318
409
  AI-powered payments that automatically apply optimizations:
@@ -1,4 +1,4 @@
1
- import { W as WebhookHandlerConfig, a as WebhookHandlers } from './webhook-handler-D8wEoYd7.mjs';
1
+ import { W as WebhookHandlerConfig, a as WebhookHandlers } from './webhook-handler-B-RdABQr.mjs';
2
2
 
3
3
  /**
4
4
  * Express Webhook Handler
package/dist/express.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { W as WebhookHandlerConfig, a as WebhookHandlers } from './webhook-handler-D8wEoYd7.js';
1
+ import { W as WebhookHandlerConfig, a as WebhookHandlers } from './webhook-handler-B-RdABQr.js';
2
2
 
3
3
  /**
4
4
  * Express Webhook Handler
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 AgentAnalytics, e as CreatePaymentIntentRequest, P as PaymentIntent, f as ConfirmPaymentIntentRequest, g as PaymentIntentEvent, h as PPPFactor, i as PricingSuggestionRequest, j as PricingSuggestion, E as EnableAutonomyRequest, k as EnableAutonomyResponse, l as AutonomyStatus, S as SmartPaymentRequest, m as SmartPaymentResponse, Z as ZendFiConfig, n as CreatePaymentRequest, o as Payment, L as ListPaymentsRequest, p as PaginatedResponse, q as CreateSubscriptionPlanRequest, r as SubscriptionPlan, s as CreateSubscriptionRequest, t as Subscription, u as CreatePaymentLinkRequest, v as PaymentLink, w as CreateInstallmentPlanRequest, I as InstallmentPlan, x as CreateEscrowRequest, y as Escrow, z as ApproveEscrowRequest, R as RefundEscrowRequest, D as DisputeEscrowRequest, B as CreateInvoiceRequest, F as Invoice, V as VerifyWebhookRequest, G as WebhookPayload } from './webhook-handler-D8wEoYd7.mjs';
2
- export { Q as AgentKeyId, ac as ApiKeyMode, ar as ApiKeyScope, ax as AutonomousDelegate, M as Brand, au as CaptureMethod, ao as CreateInstallmentPlanResponse, ad as Currency, ab as Environment, Y as EscrowId, ai as EscrowStatus, _ as InstallmentPlanId, ah as InstallmentPlanStatus, an as InstallmentScheduleItem, a0 as IntentId, U as InvoiceId, aq as InvoiceLineItem, aj as InvoiceStatus, T as MerchantId, aw as PPPConfig, N as PaymentId, at as PaymentIntentStatus, $ as PaymentLinkCode, af as PaymentStatus, ae as PaymentToken, ap as ReleaseCondition, ay as RevokeAutonomyRequest, O as SessionId, as as SessionLimits, az as SmartPaymentStatus, am as SplitRecipient, ak as SplitStatus, X as SubscriptionId, ag as SubscriptionStatus, av as UserProfile, al as WebhookEvent, K as WebhookEventHandler, W as WebhookHandlerConfig, a as WebhookHandlers, J as WebhookResult, a3 as asAgentKeyId, a7 as asEscrowId, a8 as asInstallmentPlanId, aa as asIntentId, a5 as asInvoiceId, a4 as asMerchantId, a1 as asPaymentId, a9 as asPaymentLinkCode, a2 as asSessionId, a6 as asSubscriptionId, H as processWebhook } from './webhook-handler-D8wEoYd7.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-B-RdABQr.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, 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, aO as SecurityStatus, a4 as SessionId, aM as SessionKeyInstructions, aN as SessionKeySecurityInfo, aP 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-B-RdABQr.mjs';
3
3
  import { Transaction, Keypair } from '@solana/web3.js';
4
4
 
5
5
  /**
@@ -84,10 +84,10 @@ interface Interceptors {
84
84
  * ```
85
85
  */
86
86
 
87
- type RequestFn$4 = <T>(method: string, endpoint: string, data?: any) => Promise<T>;
87
+ type RequestFn$5 = <T>(method: string, endpoint: string, data?: any) => Promise<T>;
88
88
  declare class AgentAPI {
89
89
  private request;
90
- constructor(request: RequestFn$4);
90
+ constructor(request: RequestFn$5);
91
91
  /**
92
92
  * Create a new agent API key with scoped permissions
93
93
  *
@@ -210,6 +210,53 @@ declare class AgentAPI {
210
210
  * ```
211
211
  */
212
212
  revokeSession(sessionId: string): Promise<void>;
213
+ /**
214
+ * Execute a payment using an agent session
215
+ *
216
+ * This is the primary method for AI agents to make payments. It uses the
217
+ * session token to enforce spending limits and automatically routes the
218
+ * payment through the optimal path.
219
+ *
220
+ * The session token comes from `createSession()` and enforces:
221
+ * - Per-transaction limits
222
+ * - Daily limits
223
+ * - Weekly limits
224
+ * - Monthly limits
225
+ *
226
+ * @param request - Payment request with session token
227
+ * @returns Payment result with status and receipt
228
+ *
229
+ * @example
230
+ * ```typescript
231
+ * // Create a session first
232
+ * const session = await zendfi.agent.createSession({
233
+ * agent_id: 'shopping-bot',
234
+ * user_wallet: 'Hx7B...abc',
235
+ * limits: {
236
+ * max_per_transaction: 50,
237
+ * max_per_day: 200,
238
+ * },
239
+ * duration_hours: 24,
240
+ * });
241
+ *
242
+ * // Make payments within the session limits
243
+ * const payment = await zendfi.agent.pay({
244
+ * session_token: session.session_token,
245
+ * amount: 29.99,
246
+ * description: 'Premium widget',
247
+ * auto_gasless: true,
248
+ * });
249
+ *
250
+ * if (payment.requires_signature) {
251
+ * // Device-bound: user must sign
252
+ * console.log('Sign and submit to:', payment.submit_url);
253
+ * } else {
254
+ * // Auto-signed: payment complete
255
+ * console.log('Payment confirmed:', payment.transaction_signature);
256
+ * }
257
+ * ```
258
+ */
259
+ pay(request: AgentPaymentRequest): Promise<AgentPaymentResponse>;
213
260
  /**
214
261
  * Get analytics for all agent activity
215
262
  *
@@ -253,7 +300,7 @@ declare class AgentAPI {
253
300
  * ```
254
301
  */
255
302
 
256
- type RequestFn$3 = <T>(method: string, endpoint: string, data?: any) => Promise<T>;
303
+ type RequestFn$4 = <T>(method: string, endpoint: string, data?: any) => Promise<T>;
257
304
  interface ListIntentsOptions {
258
305
  /** Filter by status */
259
306
  status?: string;
@@ -264,7 +311,7 @@ interface ListIntentsOptions {
264
311
  }
265
312
  declare class PaymentIntentsAPI {
266
313
  private request;
267
- constructor(request: RequestFn$3);
314
+ constructor(request: RequestFn$4);
268
315
  /**
269
316
  * Create a payment intent
270
317
  *
@@ -400,10 +447,10 @@ declare class PaymentIntentsAPI {
400
447
  * ```
401
448
  */
402
449
 
403
- type RequestFn$2 = <T>(method: string, endpoint: string, data?: any) => Promise<T>;
450
+ type RequestFn$3 = <T>(method: string, endpoint: string, data?: any) => Promise<T>;
404
451
  declare class PricingAPI {
405
452
  private request;
406
- constructor(request: RequestFn$2);
453
+ constructor(request: RequestFn$3);
407
454
  /**
408
455
  * Get PPP factor for a specific country
409
456
  *
@@ -538,10 +585,10 @@ declare class PricingAPI {
538
585
  * ```
539
586
  */
540
587
 
541
- type RequestFn$1 = <T>(method: string, endpoint: string, data?: any) => Promise<T>;
588
+ type RequestFn$2 = <T>(method: string, endpoint: string, data?: any) => Promise<T>;
542
589
  declare class AutonomyAPI {
543
590
  private request;
544
- constructor(request: RequestFn$1);
591
+ constructor(request: RequestFn$2);
545
592
  /**
546
593
  * Enable autonomous signing for a session key
547
594
  *
@@ -695,10 +742,10 @@ declare class AutonomyAPI {
695
742
  * ```
696
743
  */
697
744
 
698
- type RequestFn = <T>(method: string, endpoint: string, data?: any) => Promise<T>;
745
+ type RequestFn$1 = <T>(method: string, endpoint: string, data?: any) => Promise<T>;
699
746
  declare class SmartPaymentsAPI {
700
747
  private request;
701
- constructor(request: RequestFn);
748
+ constructor(request: RequestFn$1);
702
749
  /**
703
750
  * Execute an AI-powered smart payment
704
751
  *
@@ -776,6 +823,241 @@ declare class SmartPaymentsAPI {
776
823
  submitSigned(paymentId: string, signedTransaction: string): Promise<SmartPaymentResponse>;
777
824
  }
778
825
 
826
+ /**
827
+ * Session Keys API - On-chain funded session wallets
828
+ *
829
+ * Session keys are dedicated wallets funded by users for AI agents to use.
830
+ * Two modes are supported:
831
+ *
832
+ * 1. **Custodial Mode**: Backend generates and stores the keypair (simpler)
833
+ * 2. **Device-Bound Mode**: Client generates keypair and encrypts with PIN (more secure)
834
+ *
835
+ * @example
836
+ * ```typescript
837
+ * // Create a custodial session key
838
+ * const result = await zendfi.sessionKeys.create({
839
+ * user_wallet: 'Hx7B...abc',
840
+ * limit_usdc: 100,
841
+ * duration_days: 7,
842
+ * device_fingerprint: await getDeviceFingerprint(),
843
+ * });
844
+ *
845
+ * // User signs the approval transaction in their wallet
846
+ * const signedTx = await wallet.signTransaction(result.approval_transaction);
847
+ *
848
+ * // Submit the signed transaction
849
+ * await zendfi.sessionKeys.submitApproval({
850
+ * session_key_id: result.session_key_id,
851
+ * signed_transaction: signedTx,
852
+ * });
853
+ *
854
+ * // Check status
855
+ * const status = await zendfi.sessionKeys.getStatus(result.session_key_id);
856
+ * console.log(`Remaining: $${status.remaining_usdc}`);
857
+ * ```
858
+ */
859
+
860
+ type RequestFn = <T>(method: string, endpoint: string, data?: any) => Promise<T>;
861
+ declare class SessionKeysAPI {
862
+ private request;
863
+ constructor(request: RequestFn);
864
+ /**
865
+ * Create a custodial session key
866
+ *
867
+ * The backend generates and securely stores the keypair.
868
+ * Returns an approval transaction that the user must sign to fund the session wallet.
869
+ *
870
+ * @param request - Session key configuration
871
+ * @returns Creation response with approval transaction
872
+ *
873
+ * @example
874
+ * ```typescript
875
+ * const result = await zendfi.sessionKeys.create({
876
+ * user_wallet: 'Hx7B...abc',
877
+ * limit_usdc: 100,
878
+ * duration_days: 7,
879
+ * device_fingerprint: deviceFingerprint,
880
+ * });
881
+ *
882
+ * console.log(`Session key: ${result.session_key_id}`);
883
+ * console.log('Please sign the approval transaction');
884
+ * ```
885
+ */
886
+ create(request: CreateSessionKeyRequest): Promise<CreateSessionKeyResponse>;
887
+ /**
888
+ * Create a device-bound session key (non-custodial)
889
+ *
890
+ * The client generates the keypair and encrypts it with a PIN before sending.
891
+ * The backend cannot decrypt the keypair - only the user's device can.
892
+ *
893
+ * @param request - Device-bound session key configuration
894
+ * @returns Creation response with session wallet address
895
+ *
896
+ * @example
897
+ * ```typescript
898
+ * // Generate keypair client-side
899
+ * const keypair = Keypair.generate();
900
+ *
901
+ * // Encrypt with PIN
902
+ * const encrypted = await encryptWithPin(keypair.secretKey, pin);
903
+ *
904
+ * const result = await zendfi.sessionKeys.createDeviceBound({
905
+ * user_wallet: 'Hx7B...abc',
906
+ * limit_usdc: 100,
907
+ * duration_days: 7,
908
+ * encrypted_session_key: encrypted.ciphertext,
909
+ * nonce: encrypted.nonce,
910
+ * session_public_key: keypair.publicKey.toBase58(),
911
+ * device_fingerprint: deviceFingerprint,
912
+ * });
913
+ *
914
+ * console.log(`Session wallet: ${result.session_wallet}`);
915
+ * ```
916
+ */
917
+ createDeviceBound(request: CreateDeviceBoundSessionKeyRequest$1): Promise<CreateDeviceBoundSessionKeyResponse$1>;
918
+ /**
919
+ * Get encrypted session key for device-bound mode
920
+ *
921
+ * Retrieves the encrypted keypair so the client can decrypt it with their PIN.
922
+ * The device fingerprint must match the one used during creation.
923
+ *
924
+ * @param sessionKeyId - UUID of the session key
925
+ * @param deviceFingerprint - Current device fingerprint
926
+ * @returns Encrypted key data
927
+ */
928
+ getEncrypted(sessionKeyId: string, deviceFingerprint: string): Promise<{
929
+ encrypted_session_key: string;
930
+ nonce: string;
931
+ device_fingerprint_valid: boolean;
932
+ }>;
933
+ /**
934
+ * Submit a signed approval transaction
935
+ *
936
+ * After the user signs the approval transaction from `create()`,
937
+ * submit it here to activate the session key.
938
+ *
939
+ * @param request - Signed transaction data
940
+ * @returns Submission result with signature
941
+ *
942
+ * @example
943
+ * ```typescript
944
+ * const result = await zendfi.sessionKeys.submitApproval({
945
+ * session_key_id: sessionKeyId,
946
+ * signed_transaction: signedTxBase64,
947
+ * });
948
+ *
949
+ * console.log(`Approved! Signature: ${result.signature}`);
950
+ * ```
951
+ */
952
+ submitApproval(request: SubmitSignedTransactionRequest & {
953
+ session_key_id: string;
954
+ }): Promise<SubmitTransactionResponse>;
955
+ /**
956
+ * Submit a signed top-up transaction
957
+ *
958
+ * After the user signs the top-up transaction from `topUp()`,
959
+ * submit it here to add funds.
960
+ *
961
+ * @param sessionKeyId - UUID of the session key
962
+ * @param signedTransaction - Base64 encoded signed transaction
963
+ * @returns Submission result with new limit
964
+ */
965
+ submitTopUp(sessionKeyId: string, signedTransaction: string): Promise<SubmitTransactionResponse>;
966
+ /**
967
+ * Get session key status
968
+ *
969
+ * @param sessionKeyId - UUID of the session key
970
+ * @returns Current status with remaining balance
971
+ *
972
+ * @example
973
+ * ```typescript
974
+ * const status = await zendfi.sessionKeys.getStatus(sessionKeyId);
975
+ *
976
+ * console.log(`Active: ${status.is_active}`);
977
+ * console.log(`Limit: $${status.limit_usdc}`);
978
+ * console.log(`Used: $${status.used_amount_usdc}`);
979
+ * console.log(`Remaining: $${status.remaining_usdc}`);
980
+ * console.log(`Expires in ${status.days_until_expiry} days`);
981
+ * ```
982
+ */
983
+ getStatus(sessionKeyId: string): Promise<SessionKeyStatus>;
984
+ /**
985
+ * List all session keys for the merchant
986
+ *
987
+ * @returns List of session keys with stats
988
+ *
989
+ * @example
990
+ * ```typescript
991
+ * const { session_keys, stats } = await zendfi.sessionKeys.list();
992
+ *
993
+ * console.log(`Total keys: ${stats.total_keys}`);
994
+ * console.log(`Active: ${stats.active_keys}`);
995
+ *
996
+ * session_keys.forEach(key => {
997
+ * console.log(`${key.session_key_id}: $${key.remaining_usdc} remaining`);
998
+ * });
999
+ * ```
1000
+ */
1001
+ list(): Promise<SessionKeyListResponse>;
1002
+ /**
1003
+ * Top up a session key with additional funds
1004
+ *
1005
+ * Returns a transaction that the user must sign to add funds.
1006
+ *
1007
+ * @param sessionKeyId - UUID of the session key
1008
+ * @param request - Top-up configuration
1009
+ * @returns Top-up transaction to sign
1010
+ *
1011
+ * @example
1012
+ * ```typescript
1013
+ * const topUp = await zendfi.sessionKeys.topUp(sessionKeyId, {
1014
+ * user_wallet: 'Hx7B...abc',
1015
+ * amount_usdc: 50,
1016
+ * device_fingerprint: deviceFingerprint,
1017
+ * });
1018
+ *
1019
+ * console.log(`Adding $${topUp.added_amount}`);
1020
+ * console.log(`New limit will be: $${topUp.new_limit}`);
1021
+ *
1022
+ * // User signs the transaction
1023
+ * const signedTx = await wallet.signTransaction(topUp.top_up_transaction);
1024
+ *
1025
+ * // Submit it
1026
+ * await zendfi.sessionKeys.submitTopUp(sessionKeyId, signedTx);
1027
+ * ```
1028
+ */
1029
+ topUp(sessionKeyId: string, request: TopUpSessionKeyRequest): Promise<TopUpSessionKeyResponse>;
1030
+ /**
1031
+ * Revoke a session key
1032
+ *
1033
+ * Immediately deactivates the session key. Any remaining funds
1034
+ * are refunded to the user's wallet.
1035
+ *
1036
+ * @param sessionKeyId - UUID of the session key
1037
+ * @returns Revocation result with optional refund details
1038
+ *
1039
+ * @example
1040
+ * ```typescript
1041
+ * const result = await zendfi.sessionKeys.revoke(sessionKeyId);
1042
+ *
1043
+ * console.log('Session key revoked');
1044
+ * if (result.refund?.refunded) {
1045
+ * console.log(`Refunded: ${result.refund.transaction_signature}`);
1046
+ * }
1047
+ * ```
1048
+ */
1049
+ revoke(sessionKeyId: string): Promise<{
1050
+ message: string;
1051
+ session_key_id: string;
1052
+ note: string;
1053
+ refund?: {
1054
+ refunded: boolean;
1055
+ transaction_signature: string;
1056
+ message: string;
1057
+ };
1058
+ }>;
1059
+ }
1060
+
779
1061
  /**
780
1062
  * ZendFi SDK Client.
781
1063
  * AZero-config TypeScript SDK for crypto payments
@@ -880,6 +1162,38 @@ declare class ZendFiClient {
880
1162
  * ```
881
1163
  */
882
1164
  readonly smart: SmartPaymentsAPI;
1165
+ /**
1166
+ * Session Keys API - On-chain funded session keys with PKP identity
1167
+ *
1168
+ * Session keys are pre-funded wallets with spending limits that enable
1169
+ * AI agents to make autonomous payments without user signatures.
1170
+ *
1171
+ * The flow:
1172
+ * 1. Create a session key (user approves spending limit)
1173
+ * 2. User signs the approval transaction (one-time)
1174
+ * 3. Agent can now make payments up to the limit
1175
+ *
1176
+ * @example
1177
+ * ```typescript
1178
+ * // Create session key
1179
+ * const key = await zendfi.sessionKeys.create({
1180
+ * agent_id: 'shopping-bot',
1181
+ * user_wallet: 'Hx7B...abc',
1182
+ * max_amount: 100,
1183
+ * expiry_hours: 24,
1184
+ * });
1185
+ *
1186
+ * // User signs the approval
1187
+ * await zendfi.sessionKeys.submitApproval(key.session_key_id, {
1188
+ * signed_transaction: signedTx,
1189
+ * });
1190
+ *
1191
+ * // Check status
1192
+ * const status = await zendfi.sessionKeys.getStatus(key.session_key_id);
1193
+ * console.log(`Remaining: $${status.remaining_amount}`);
1194
+ * ```
1195
+ */
1196
+ readonly sessionKeys: SessionKeysAPI;
883
1197
  constructor(options?: Partial<ZendFiConfig>);
884
1198
  /**
885
1199
  * Create a new payment
@@ -1944,4 +2258,4 @@ declare function requiresLitSigning(session: {
1944
2258
  declare function encodeTransactionForLit(transaction: Uint8Array | Buffer): string;
1945
2259
  declare function decodeSignatureFromLit(result: SignPaymentResult): Uint8Array | null;
1946
2260
 
1947
- export { AgentAPI, AgentAnalytics, AgentApiKey, AgentSession, ApiError, ApproveEscrowRequest, AuthenticationError, AutonomyAPI, AutonomyStatus, ConfigLoader, ConfirmPaymentIntentRequest, CreateAgentApiKeyRequest, CreateAgentSessionRequest, type CreateDeviceBoundSessionKeyRequest, type CreateDeviceBoundSessionKeyResponse, CreateEscrowRequest, CreateInstallmentPlanRequest, CreateInvoiceRequest, CreatePaymentIntentRequest, CreatePaymentLinkRequest, CreatePaymentRequest, 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, type SessionKeyPaymentRequest, type SignPaymentParams, type SignPaymentResult, SmartPaymentRequest, SmartPaymentResponse, SmartPaymentsAPI, Subscription, SubscriptionPlan, ValidationError, VerifyWebhookRequest, WebhookError, WebhookPayload, ZendFiClient, ZendFiConfig, ZendFiError, type ZendFiErrorData, type ZendFiErrorType, ZendFiSessionKeyManager, createZendFiError, decodeSignatureFromLit, encodeTransactionForLit, generateIdempotencyKey, isZendFiError, requiresLitSigning, sleep, verifyExpressWebhook, verifyNextWebhook, verifyWebhookSignature, zendfi };
2261
+ 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 };