@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 +91 -0
- package/dist/express.d.mts +1 -1
- package/dist/express.d.ts +1 -1
- package/dist/index.d.mts +327 -13
- package/dist/index.d.ts +327 -13
- package/dist/index.js +364 -1
- package/dist/index.mjs +363 -1
- package/dist/nextjs.d.mts +1 -1
- package/dist/nextjs.d.ts +1 -1
- package/dist/{webhook-handler-D8wEoYd7.d.mts → webhook-handler-B-RdABQr.d.mts} +230 -1
- package/dist/{webhook-handler-D8wEoYd7.d.ts → webhook-handler-B-RdABQr.d.ts} +230 -1
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { C as CreateAgentApiKeyRequest, A as AgentApiKey, b as CreateAgentSessionRequest, c as AgentSession, d as
|
|
2
|
-
export {
|
|
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.js';
|
|
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.js';
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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$
|
|
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 };
|