@zendfi/sdk 0.5.3 → 0.5.6
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 +66 -0
- package/dist/express.d.mts +1 -1
- package/dist/express.d.ts +1 -1
- package/dist/index.d.mts +104 -2
- package/dist/index.d.ts +104 -2
- package/dist/index.js +103 -1
- package/dist/index.mjs +103 -1
- package/dist/nextjs.d.mts +1 -1
- package/dist/nextjs.d.ts +1 -1
- package/dist/{webhook-handler-B-RdABQr.d.mts → webhook-handler-D5CigE9G.d.mts} +34 -1
- package/dist/{webhook-handler-B-RdABQr.d.ts → webhook-handler-D5CigE9G.d.ts} +34 -1
- package/package.json +1 -1
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
|
|
|
@@ -338,6 +339,71 @@ const status = await zendfi.autonomy.getStatus(walletAddress);
|
|
|
338
339
|
await zendfi.autonomy.revoke(delegateId);
|
|
339
340
|
```
|
|
340
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
|
+
|
|
341
407
|
### Smart Payments
|
|
342
408
|
|
|
343
409
|
AI-powered payments that automatically apply optimizations:
|
package/dist/express.d.mts
CHANGED
package/dist/express.d.ts
CHANGED
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-
|
|
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,
|
|
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';
|
|
3
3
|
import { Transaction, Keypair } from '@solana/web3.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -872,6 +872,7 @@ declare class SessionKeysAPI {
|
|
|
872
872
|
*
|
|
873
873
|
* @example
|
|
874
874
|
* ```typescript
|
|
875
|
+
* // Basic creation
|
|
875
876
|
* const result = await zendfi.sessionKeys.create({
|
|
876
877
|
* user_wallet: 'Hx7B...abc',
|
|
877
878
|
* limit_usdc: 100,
|
|
@@ -879,6 +880,15 @@ declare class SessionKeysAPI {
|
|
|
879
880
|
* device_fingerprint: deviceFingerprint,
|
|
880
881
|
* });
|
|
881
882
|
*
|
|
883
|
+
* // Create with linked session for policy enforcement
|
|
884
|
+
* const result = await zendfi.sessionKeys.create({
|
|
885
|
+
* user_wallet: 'Hx7B...abc',
|
|
886
|
+
* limit_usdc: 500,
|
|
887
|
+
* duration_days: 7,
|
|
888
|
+
* device_fingerprint: deviceFingerprint,
|
|
889
|
+
* link_session_id: session.id, // Links to existing session
|
|
890
|
+
* });
|
|
891
|
+
*
|
|
882
892
|
* console.log(`Session key: ${result.session_key_id}`);
|
|
883
893
|
* console.log('Please sign the approval transaction');
|
|
884
894
|
* ```
|
|
@@ -1056,6 +1066,98 @@ declare class SessionKeysAPI {
|
|
|
1056
1066
|
message: string;
|
|
1057
1067
|
};
|
|
1058
1068
|
}>;
|
|
1069
|
+
/**
|
|
1070
|
+
* Link a session key to an AI session for policy enforcement
|
|
1071
|
+
*
|
|
1072
|
+
* When linked, payments through this session key will check both:
|
|
1073
|
+
* 1. Session key balance (hard cap)
|
|
1074
|
+
* 2. AI session limits (per-tx, daily, weekly, monthly)
|
|
1075
|
+
*
|
|
1076
|
+
* This provides defense-in-depth: the session key provides signing
|
|
1077
|
+
* capability while the session enforces granular spending policies.
|
|
1078
|
+
*
|
|
1079
|
+
* @param sessionKeyId - UUID of the session key
|
|
1080
|
+
* @param sessionId - UUID of the AI session to link
|
|
1081
|
+
* @returns Updated session key status
|
|
1082
|
+
*
|
|
1083
|
+
* @example
|
|
1084
|
+
* ```typescript
|
|
1085
|
+
* // Create a session with limits
|
|
1086
|
+
* const session = await zendfi.agent.createSession({
|
|
1087
|
+
* agent_id: 'shopping-bot',
|
|
1088
|
+
* user_wallet: userWallet,
|
|
1089
|
+
* limits: {
|
|
1090
|
+
* max_per_transaction: 25,
|
|
1091
|
+
* max_per_day: 100,
|
|
1092
|
+
* },
|
|
1093
|
+
* duration_hours: 24,
|
|
1094
|
+
* });
|
|
1095
|
+
*
|
|
1096
|
+
* // Create and fund a session key
|
|
1097
|
+
* const key = await zendfi.sessionKeys.create({
|
|
1098
|
+
* user_wallet: userWallet,
|
|
1099
|
+
* limit_usdc: 500, // Fund with $500
|
|
1100
|
+
* duration_days: 7,
|
|
1101
|
+
* device_fingerprint: fp,
|
|
1102
|
+
* });
|
|
1103
|
+
*
|
|
1104
|
+
* // Link them together
|
|
1105
|
+
* await zendfi.sessionKeys.linkSession(key.session_key_id, session.id);
|
|
1106
|
+
*
|
|
1107
|
+
* // Now payments will:
|
|
1108
|
+
* // - Be limited to $25 per transaction (session policy)
|
|
1109
|
+
* // - Be limited to $100 per day (session policy)
|
|
1110
|
+
* // - Never exceed $500 total (session key balance)
|
|
1111
|
+
* ```
|
|
1112
|
+
*/
|
|
1113
|
+
linkSession(sessionKeyId: string, sessionId: string): Promise<{
|
|
1114
|
+
success: boolean;
|
|
1115
|
+
session_key_id: string;
|
|
1116
|
+
linked_session_id: string;
|
|
1117
|
+
message: string;
|
|
1118
|
+
}>;
|
|
1119
|
+
/**
|
|
1120
|
+
* Unlink a session key from its AI session
|
|
1121
|
+
*
|
|
1122
|
+
* After unlinking, the session key will only be limited by its funded balance.
|
|
1123
|
+
*
|
|
1124
|
+
* @param sessionKeyId - UUID of the session key
|
|
1125
|
+
* @returns Result of the unlink operation
|
|
1126
|
+
*/
|
|
1127
|
+
unlinkSession(sessionKeyId: string): Promise<{
|
|
1128
|
+
success: boolean;
|
|
1129
|
+
session_key_id: string;
|
|
1130
|
+
message: string;
|
|
1131
|
+
}>;
|
|
1132
|
+
/**
|
|
1133
|
+
* Check if a payment amount is allowed
|
|
1134
|
+
*
|
|
1135
|
+
* Checks both session key balance and linked session limits (if any).
|
|
1136
|
+
* Useful for pre-validating payments before attempting them.
|
|
1137
|
+
*
|
|
1138
|
+
* @param sessionKeyId - UUID of the session key
|
|
1139
|
+
* @param amount - Amount in USD to check
|
|
1140
|
+
* @returns Whether the payment is allowed and the effective limit
|
|
1141
|
+
*
|
|
1142
|
+
* @example
|
|
1143
|
+
* ```typescript
|
|
1144
|
+
* const check = await zendfi.sessionKeys.canAfford(keyId, 50);
|
|
1145
|
+
*
|
|
1146
|
+
* if (check.allowed) {
|
|
1147
|
+
* await zendfi.smart.execute({ ... });
|
|
1148
|
+
* } else {
|
|
1149
|
+
* console.log(`Cannot afford: ${check.reason}`);
|
|
1150
|
+
* console.log(`Effective limit: $${check.effective_limit}`);
|
|
1151
|
+
* }
|
|
1152
|
+
* ```
|
|
1153
|
+
*/
|
|
1154
|
+
canAfford(sessionKeyId: string, amount: number): Promise<{
|
|
1155
|
+
allowed: boolean;
|
|
1156
|
+
reason?: string;
|
|
1157
|
+
effective_limit: number;
|
|
1158
|
+
session_key_remaining: number;
|
|
1159
|
+
session_remaining_today?: number;
|
|
1160
|
+
}>;
|
|
1059
1161
|
}
|
|
1060
1162
|
|
|
1061
1163
|
/**
|
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 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-
|
|
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,
|
|
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.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, 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.js';
|
|
3
3
|
import { Transaction, Keypair } from '@solana/web3.js';
|
|
4
4
|
|
|
5
5
|
/**
|
|
@@ -872,6 +872,7 @@ declare class SessionKeysAPI {
|
|
|
872
872
|
*
|
|
873
873
|
* @example
|
|
874
874
|
* ```typescript
|
|
875
|
+
* // Basic creation
|
|
875
876
|
* const result = await zendfi.sessionKeys.create({
|
|
876
877
|
* user_wallet: 'Hx7B...abc',
|
|
877
878
|
* limit_usdc: 100,
|
|
@@ -879,6 +880,15 @@ declare class SessionKeysAPI {
|
|
|
879
880
|
* device_fingerprint: deviceFingerprint,
|
|
880
881
|
* });
|
|
881
882
|
*
|
|
883
|
+
* // Create with linked session for policy enforcement
|
|
884
|
+
* const result = await zendfi.sessionKeys.create({
|
|
885
|
+
* user_wallet: 'Hx7B...abc',
|
|
886
|
+
* limit_usdc: 500,
|
|
887
|
+
* duration_days: 7,
|
|
888
|
+
* device_fingerprint: deviceFingerprint,
|
|
889
|
+
* link_session_id: session.id, // Links to existing session
|
|
890
|
+
* });
|
|
891
|
+
*
|
|
882
892
|
* console.log(`Session key: ${result.session_key_id}`);
|
|
883
893
|
* console.log('Please sign the approval transaction');
|
|
884
894
|
* ```
|
|
@@ -1056,6 +1066,98 @@ declare class SessionKeysAPI {
|
|
|
1056
1066
|
message: string;
|
|
1057
1067
|
};
|
|
1058
1068
|
}>;
|
|
1069
|
+
/**
|
|
1070
|
+
* Link a session key to an AI session for policy enforcement
|
|
1071
|
+
*
|
|
1072
|
+
* When linked, payments through this session key will check both:
|
|
1073
|
+
* 1. Session key balance (hard cap)
|
|
1074
|
+
* 2. AI session limits (per-tx, daily, weekly, monthly)
|
|
1075
|
+
*
|
|
1076
|
+
* This provides defense-in-depth: the session key provides signing
|
|
1077
|
+
* capability while the session enforces granular spending policies.
|
|
1078
|
+
*
|
|
1079
|
+
* @param sessionKeyId - UUID of the session key
|
|
1080
|
+
* @param sessionId - UUID of the AI session to link
|
|
1081
|
+
* @returns Updated session key status
|
|
1082
|
+
*
|
|
1083
|
+
* @example
|
|
1084
|
+
* ```typescript
|
|
1085
|
+
* // Create a session with limits
|
|
1086
|
+
* const session = await zendfi.agent.createSession({
|
|
1087
|
+
* agent_id: 'shopping-bot',
|
|
1088
|
+
* user_wallet: userWallet,
|
|
1089
|
+
* limits: {
|
|
1090
|
+
* max_per_transaction: 25,
|
|
1091
|
+
* max_per_day: 100,
|
|
1092
|
+
* },
|
|
1093
|
+
* duration_hours: 24,
|
|
1094
|
+
* });
|
|
1095
|
+
*
|
|
1096
|
+
* // Create and fund a session key
|
|
1097
|
+
* const key = await zendfi.sessionKeys.create({
|
|
1098
|
+
* user_wallet: userWallet,
|
|
1099
|
+
* limit_usdc: 500, // Fund with $500
|
|
1100
|
+
* duration_days: 7,
|
|
1101
|
+
* device_fingerprint: fp,
|
|
1102
|
+
* });
|
|
1103
|
+
*
|
|
1104
|
+
* // Link them together
|
|
1105
|
+
* await zendfi.sessionKeys.linkSession(key.session_key_id, session.id);
|
|
1106
|
+
*
|
|
1107
|
+
* // Now payments will:
|
|
1108
|
+
* // - Be limited to $25 per transaction (session policy)
|
|
1109
|
+
* // - Be limited to $100 per day (session policy)
|
|
1110
|
+
* // - Never exceed $500 total (session key balance)
|
|
1111
|
+
* ```
|
|
1112
|
+
*/
|
|
1113
|
+
linkSession(sessionKeyId: string, sessionId: string): Promise<{
|
|
1114
|
+
success: boolean;
|
|
1115
|
+
session_key_id: string;
|
|
1116
|
+
linked_session_id: string;
|
|
1117
|
+
message: string;
|
|
1118
|
+
}>;
|
|
1119
|
+
/**
|
|
1120
|
+
* Unlink a session key from its AI session
|
|
1121
|
+
*
|
|
1122
|
+
* After unlinking, the session key will only be limited by its funded balance.
|
|
1123
|
+
*
|
|
1124
|
+
* @param sessionKeyId - UUID of the session key
|
|
1125
|
+
* @returns Result of the unlink operation
|
|
1126
|
+
*/
|
|
1127
|
+
unlinkSession(sessionKeyId: string): Promise<{
|
|
1128
|
+
success: boolean;
|
|
1129
|
+
session_key_id: string;
|
|
1130
|
+
message: string;
|
|
1131
|
+
}>;
|
|
1132
|
+
/**
|
|
1133
|
+
* Check if a payment amount is allowed
|
|
1134
|
+
*
|
|
1135
|
+
* Checks both session key balance and linked session limits (if any).
|
|
1136
|
+
* Useful for pre-validating payments before attempting them.
|
|
1137
|
+
*
|
|
1138
|
+
* @param sessionKeyId - UUID of the session key
|
|
1139
|
+
* @param amount - Amount in USD to check
|
|
1140
|
+
* @returns Whether the payment is allowed and the effective limit
|
|
1141
|
+
*
|
|
1142
|
+
* @example
|
|
1143
|
+
* ```typescript
|
|
1144
|
+
* const check = await zendfi.sessionKeys.canAfford(keyId, 50);
|
|
1145
|
+
*
|
|
1146
|
+
* if (check.allowed) {
|
|
1147
|
+
* await zendfi.smart.execute({ ... });
|
|
1148
|
+
* } else {
|
|
1149
|
+
* console.log(`Cannot afford: ${check.reason}`);
|
|
1150
|
+
* console.log(`Effective limit: $${check.effective_limit}`);
|
|
1151
|
+
* }
|
|
1152
|
+
* ```
|
|
1153
|
+
*/
|
|
1154
|
+
canAfford(sessionKeyId: string, amount: number): Promise<{
|
|
1155
|
+
allowed: boolean;
|
|
1156
|
+
reason?: string;
|
|
1157
|
+
effective_limit: number;
|
|
1158
|
+
session_key_remaining: number;
|
|
1159
|
+
session_remaining_today?: number;
|
|
1160
|
+
}>;
|
|
1059
1161
|
}
|
|
1060
1162
|
|
|
1061
1163
|
/**
|
package/dist/index.js
CHANGED
|
@@ -1403,6 +1403,7 @@ var SessionKeysAPI = class {
|
|
|
1403
1403
|
*
|
|
1404
1404
|
* @example
|
|
1405
1405
|
* ```typescript
|
|
1406
|
+
* // Basic creation
|
|
1406
1407
|
* const result = await zendfi.sessionKeys.create({
|
|
1407
1408
|
* user_wallet: 'Hx7B...abc',
|
|
1408
1409
|
* limit_usdc: 100,
|
|
@@ -1410,6 +1411,15 @@ var SessionKeysAPI = class {
|
|
|
1410
1411
|
* device_fingerprint: deviceFingerprint,
|
|
1411
1412
|
* });
|
|
1412
1413
|
*
|
|
1414
|
+
* // Create with linked session for policy enforcement
|
|
1415
|
+
* const result = await zendfi.sessionKeys.create({
|
|
1416
|
+
* user_wallet: 'Hx7B...abc',
|
|
1417
|
+
* limit_usdc: 500,
|
|
1418
|
+
* duration_days: 7,
|
|
1419
|
+
* device_fingerprint: deviceFingerprint,
|
|
1420
|
+
* link_session_id: session.id, // Links to existing session
|
|
1421
|
+
* });
|
|
1422
|
+
*
|
|
1413
1423
|
* console.log(`Session key: ${result.session_key_id}`);
|
|
1414
1424
|
* console.log('Please sign the approval transaction');
|
|
1415
1425
|
* ```
|
|
@@ -1419,7 +1429,9 @@ var SessionKeysAPI = class {
|
|
|
1419
1429
|
user_wallet: request.user_wallet,
|
|
1420
1430
|
limit_usdc: request.limit_usdc,
|
|
1421
1431
|
duration_days: request.duration_days ?? 7,
|
|
1422
|
-
device_fingerprint: request.device_fingerprint
|
|
1432
|
+
device_fingerprint: request.device_fingerprint,
|
|
1433
|
+
link_session_id: request.link_session_id,
|
|
1434
|
+
link_session_token: request.link_session_token
|
|
1423
1435
|
});
|
|
1424
1436
|
}
|
|
1425
1437
|
// ============================================
|
|
@@ -1645,6 +1657,96 @@ var SessionKeysAPI = class {
|
|
|
1645
1657
|
session_key_id: sessionKeyId
|
|
1646
1658
|
});
|
|
1647
1659
|
}
|
|
1660
|
+
// ============================================
|
|
1661
|
+
// Session Linking
|
|
1662
|
+
// ============================================
|
|
1663
|
+
/**
|
|
1664
|
+
* Link a session key to an AI session for policy enforcement
|
|
1665
|
+
*
|
|
1666
|
+
* When linked, payments through this session key will check both:
|
|
1667
|
+
* 1. Session key balance (hard cap)
|
|
1668
|
+
* 2. AI session limits (per-tx, daily, weekly, monthly)
|
|
1669
|
+
*
|
|
1670
|
+
* This provides defense-in-depth: the session key provides signing
|
|
1671
|
+
* capability while the session enforces granular spending policies.
|
|
1672
|
+
*
|
|
1673
|
+
* @param sessionKeyId - UUID of the session key
|
|
1674
|
+
* @param sessionId - UUID of the AI session to link
|
|
1675
|
+
* @returns Updated session key status
|
|
1676
|
+
*
|
|
1677
|
+
* @example
|
|
1678
|
+
* ```typescript
|
|
1679
|
+
* // Create a session with limits
|
|
1680
|
+
* const session = await zendfi.agent.createSession({
|
|
1681
|
+
* agent_id: 'shopping-bot',
|
|
1682
|
+
* user_wallet: userWallet,
|
|
1683
|
+
* limits: {
|
|
1684
|
+
* max_per_transaction: 25,
|
|
1685
|
+
* max_per_day: 100,
|
|
1686
|
+
* },
|
|
1687
|
+
* duration_hours: 24,
|
|
1688
|
+
* });
|
|
1689
|
+
*
|
|
1690
|
+
* // Create and fund a session key
|
|
1691
|
+
* const key = await zendfi.sessionKeys.create({
|
|
1692
|
+
* user_wallet: userWallet,
|
|
1693
|
+
* limit_usdc: 500, // Fund with $500
|
|
1694
|
+
* duration_days: 7,
|
|
1695
|
+
* device_fingerprint: fp,
|
|
1696
|
+
* });
|
|
1697
|
+
*
|
|
1698
|
+
* // Link them together
|
|
1699
|
+
* await zendfi.sessionKeys.linkSession(key.session_key_id, session.id);
|
|
1700
|
+
*
|
|
1701
|
+
* // Now payments will:
|
|
1702
|
+
* // - Be limited to $25 per transaction (session policy)
|
|
1703
|
+
* // - Be limited to $100 per day (session policy)
|
|
1704
|
+
* // - Never exceed $500 total (session key balance)
|
|
1705
|
+
* ```
|
|
1706
|
+
*/
|
|
1707
|
+
async linkSession(sessionKeyId, sessionId) {
|
|
1708
|
+
return this.request("POST", `/api/v1/ai/session-keys/${sessionKeyId}/link-session`, {
|
|
1709
|
+
session_id: sessionId
|
|
1710
|
+
});
|
|
1711
|
+
}
|
|
1712
|
+
/**
|
|
1713
|
+
* Unlink a session key from its AI session
|
|
1714
|
+
*
|
|
1715
|
+
* After unlinking, the session key will only be limited by its funded balance.
|
|
1716
|
+
*
|
|
1717
|
+
* @param sessionKeyId - UUID of the session key
|
|
1718
|
+
* @returns Result of the unlink operation
|
|
1719
|
+
*/
|
|
1720
|
+
async unlinkSession(sessionKeyId) {
|
|
1721
|
+
return this.request("POST", `/api/v1/ai/session-keys/${sessionKeyId}/unlink-session`, {});
|
|
1722
|
+
}
|
|
1723
|
+
/**
|
|
1724
|
+
* Check if a payment amount is allowed
|
|
1725
|
+
*
|
|
1726
|
+
* Checks both session key balance and linked session limits (if any).
|
|
1727
|
+
* Useful for pre-validating payments before attempting them.
|
|
1728
|
+
*
|
|
1729
|
+
* @param sessionKeyId - UUID of the session key
|
|
1730
|
+
* @param amount - Amount in USD to check
|
|
1731
|
+
* @returns Whether the payment is allowed and the effective limit
|
|
1732
|
+
*
|
|
1733
|
+
* @example
|
|
1734
|
+
* ```typescript
|
|
1735
|
+
* const check = await zendfi.sessionKeys.canAfford(keyId, 50);
|
|
1736
|
+
*
|
|
1737
|
+
* if (check.allowed) {
|
|
1738
|
+
* await zendfi.smart.execute({ ... });
|
|
1739
|
+
* } else {
|
|
1740
|
+
* console.log(`Cannot afford: ${check.reason}`);
|
|
1741
|
+
* console.log(`Effective limit: $${check.effective_limit}`);
|
|
1742
|
+
* }
|
|
1743
|
+
* ```
|
|
1744
|
+
*/
|
|
1745
|
+
async canAfford(sessionKeyId, amount) {
|
|
1746
|
+
return this.request("POST", `/api/v1/ai/session-keys/${sessionKeyId}/check-payment`, {
|
|
1747
|
+
amount
|
|
1748
|
+
});
|
|
1749
|
+
}
|
|
1648
1750
|
};
|
|
1649
1751
|
|
|
1650
1752
|
// src/client.ts
|
package/dist/index.mjs
CHANGED
|
@@ -1325,6 +1325,7 @@ var SessionKeysAPI = class {
|
|
|
1325
1325
|
*
|
|
1326
1326
|
* @example
|
|
1327
1327
|
* ```typescript
|
|
1328
|
+
* // Basic creation
|
|
1328
1329
|
* const result = await zendfi.sessionKeys.create({
|
|
1329
1330
|
* user_wallet: 'Hx7B...abc',
|
|
1330
1331
|
* limit_usdc: 100,
|
|
@@ -1332,6 +1333,15 @@ var SessionKeysAPI = class {
|
|
|
1332
1333
|
* device_fingerprint: deviceFingerprint,
|
|
1333
1334
|
* });
|
|
1334
1335
|
*
|
|
1336
|
+
* // Create with linked session for policy enforcement
|
|
1337
|
+
* const result = await zendfi.sessionKeys.create({
|
|
1338
|
+
* user_wallet: 'Hx7B...abc',
|
|
1339
|
+
* limit_usdc: 500,
|
|
1340
|
+
* duration_days: 7,
|
|
1341
|
+
* device_fingerprint: deviceFingerprint,
|
|
1342
|
+
* link_session_id: session.id, // Links to existing session
|
|
1343
|
+
* });
|
|
1344
|
+
*
|
|
1335
1345
|
* console.log(`Session key: ${result.session_key_id}`);
|
|
1336
1346
|
* console.log('Please sign the approval transaction');
|
|
1337
1347
|
* ```
|
|
@@ -1341,7 +1351,9 @@ var SessionKeysAPI = class {
|
|
|
1341
1351
|
user_wallet: request.user_wallet,
|
|
1342
1352
|
limit_usdc: request.limit_usdc,
|
|
1343
1353
|
duration_days: request.duration_days ?? 7,
|
|
1344
|
-
device_fingerprint: request.device_fingerprint
|
|
1354
|
+
device_fingerprint: request.device_fingerprint,
|
|
1355
|
+
link_session_id: request.link_session_id,
|
|
1356
|
+
link_session_token: request.link_session_token
|
|
1345
1357
|
});
|
|
1346
1358
|
}
|
|
1347
1359
|
// ============================================
|
|
@@ -1567,6 +1579,96 @@ var SessionKeysAPI = class {
|
|
|
1567
1579
|
session_key_id: sessionKeyId
|
|
1568
1580
|
});
|
|
1569
1581
|
}
|
|
1582
|
+
// ============================================
|
|
1583
|
+
// Session Linking
|
|
1584
|
+
// ============================================
|
|
1585
|
+
/**
|
|
1586
|
+
* Link a session key to an AI session for policy enforcement
|
|
1587
|
+
*
|
|
1588
|
+
* When linked, payments through this session key will check both:
|
|
1589
|
+
* 1. Session key balance (hard cap)
|
|
1590
|
+
* 2. AI session limits (per-tx, daily, weekly, monthly)
|
|
1591
|
+
*
|
|
1592
|
+
* This provides defense-in-depth: the session key provides signing
|
|
1593
|
+
* capability while the session enforces granular spending policies.
|
|
1594
|
+
*
|
|
1595
|
+
* @param sessionKeyId - UUID of the session key
|
|
1596
|
+
* @param sessionId - UUID of the AI session to link
|
|
1597
|
+
* @returns Updated session key status
|
|
1598
|
+
*
|
|
1599
|
+
* @example
|
|
1600
|
+
* ```typescript
|
|
1601
|
+
* // Create a session with limits
|
|
1602
|
+
* const session = await zendfi.agent.createSession({
|
|
1603
|
+
* agent_id: 'shopping-bot',
|
|
1604
|
+
* user_wallet: userWallet,
|
|
1605
|
+
* limits: {
|
|
1606
|
+
* max_per_transaction: 25,
|
|
1607
|
+
* max_per_day: 100,
|
|
1608
|
+
* },
|
|
1609
|
+
* duration_hours: 24,
|
|
1610
|
+
* });
|
|
1611
|
+
*
|
|
1612
|
+
* // Create and fund a session key
|
|
1613
|
+
* const key = await zendfi.sessionKeys.create({
|
|
1614
|
+
* user_wallet: userWallet,
|
|
1615
|
+
* limit_usdc: 500, // Fund with $500
|
|
1616
|
+
* duration_days: 7,
|
|
1617
|
+
* device_fingerprint: fp,
|
|
1618
|
+
* });
|
|
1619
|
+
*
|
|
1620
|
+
* // Link them together
|
|
1621
|
+
* await zendfi.sessionKeys.linkSession(key.session_key_id, session.id);
|
|
1622
|
+
*
|
|
1623
|
+
* // Now payments will:
|
|
1624
|
+
* // - Be limited to $25 per transaction (session policy)
|
|
1625
|
+
* // - Be limited to $100 per day (session policy)
|
|
1626
|
+
* // - Never exceed $500 total (session key balance)
|
|
1627
|
+
* ```
|
|
1628
|
+
*/
|
|
1629
|
+
async linkSession(sessionKeyId, sessionId) {
|
|
1630
|
+
return this.request("POST", `/api/v1/ai/session-keys/${sessionKeyId}/link-session`, {
|
|
1631
|
+
session_id: sessionId
|
|
1632
|
+
});
|
|
1633
|
+
}
|
|
1634
|
+
/**
|
|
1635
|
+
* Unlink a session key from its AI session
|
|
1636
|
+
*
|
|
1637
|
+
* After unlinking, the session key will only be limited by its funded balance.
|
|
1638
|
+
*
|
|
1639
|
+
* @param sessionKeyId - UUID of the session key
|
|
1640
|
+
* @returns Result of the unlink operation
|
|
1641
|
+
*/
|
|
1642
|
+
async unlinkSession(sessionKeyId) {
|
|
1643
|
+
return this.request("POST", `/api/v1/ai/session-keys/${sessionKeyId}/unlink-session`, {});
|
|
1644
|
+
}
|
|
1645
|
+
/**
|
|
1646
|
+
* Check if a payment amount is allowed
|
|
1647
|
+
*
|
|
1648
|
+
* Checks both session key balance and linked session limits (if any).
|
|
1649
|
+
* Useful for pre-validating payments before attempting them.
|
|
1650
|
+
*
|
|
1651
|
+
* @param sessionKeyId - UUID of the session key
|
|
1652
|
+
* @param amount - Amount in USD to check
|
|
1653
|
+
* @returns Whether the payment is allowed and the effective limit
|
|
1654
|
+
*
|
|
1655
|
+
* @example
|
|
1656
|
+
* ```typescript
|
|
1657
|
+
* const check = await zendfi.sessionKeys.canAfford(keyId, 50);
|
|
1658
|
+
*
|
|
1659
|
+
* if (check.allowed) {
|
|
1660
|
+
* await zendfi.smart.execute({ ... });
|
|
1661
|
+
* } else {
|
|
1662
|
+
* console.log(`Cannot afford: ${check.reason}`);
|
|
1663
|
+
* console.log(`Effective limit: $${check.effective_limit}`);
|
|
1664
|
+
* }
|
|
1665
|
+
* ```
|
|
1666
|
+
*/
|
|
1667
|
+
async canAfford(sessionKeyId, amount) {
|
|
1668
|
+
return this.request("POST", `/api/v1/ai/session-keys/${sessionKeyId}/check-payment`, {
|
|
1669
|
+
amount
|
|
1670
|
+
});
|
|
1671
|
+
}
|
|
1570
1672
|
};
|
|
1571
1673
|
|
|
1572
1674
|
// src/client.ts
|
package/dist/nextjs.d.mts
CHANGED
package/dist/nextjs.d.ts
CHANGED
|
@@ -822,6 +822,16 @@ interface CreateSessionKeyRequest {
|
|
|
822
822
|
duration_days?: number;
|
|
823
823
|
/** Device fingerprint for security */
|
|
824
824
|
device_fingerprint: string;
|
|
825
|
+
/**
|
|
826
|
+
* Optional: Link to an existing AI session for policy enforcement.
|
|
827
|
+
* When linked, payments will check both session key balance AND session limits.
|
|
828
|
+
*/
|
|
829
|
+
link_session_id?: string;
|
|
830
|
+
/**
|
|
831
|
+
* Optional: Link to a session by token instead of ID.
|
|
832
|
+
* Mutually exclusive with link_session_id.
|
|
833
|
+
*/
|
|
834
|
+
link_session_token?: string;
|
|
825
835
|
}
|
|
826
836
|
/**
|
|
827
837
|
* Session key creation response (custodial mode)
|
|
@@ -921,6 +931,29 @@ interface SessionKeyStatus {
|
|
|
921
931
|
days_until_expiry: number;
|
|
922
932
|
/** Security status */
|
|
923
933
|
security_status: SecurityStatus;
|
|
934
|
+
/** Linked AI session info (if linked) */
|
|
935
|
+
linked_session?: LinkedSessionInfo;
|
|
936
|
+
}
|
|
937
|
+
/**
|
|
938
|
+
* Information about a linked AI session (for policy enforcement)
|
|
939
|
+
*/
|
|
940
|
+
interface LinkedSessionInfo {
|
|
941
|
+
/** Session ID */
|
|
942
|
+
session_id: string;
|
|
943
|
+
/** Agent ID */
|
|
944
|
+
agent_id: string;
|
|
945
|
+
/** Whether the linked session is active */
|
|
946
|
+
is_active: boolean;
|
|
947
|
+
/** Per-transaction limit */
|
|
948
|
+
max_per_transaction?: number;
|
|
949
|
+
/** Daily remaining */
|
|
950
|
+
remaining_today: number;
|
|
951
|
+
/** Weekly remaining */
|
|
952
|
+
remaining_this_week: number;
|
|
953
|
+
/** Monthly remaining */
|
|
954
|
+
remaining_this_month: number;
|
|
955
|
+
/** Effective limit (minimum of session key balance and session limits) */
|
|
956
|
+
effective_limit: number;
|
|
924
957
|
}
|
|
925
958
|
interface SecurityStatus {
|
|
926
959
|
device_fingerprint_matched: boolean;
|
|
@@ -1095,4 +1128,4 @@ interface WebhookResult {
|
|
|
1095
1128
|
}
|
|
1096
1129
|
declare function processWebhook(a: any, b?: any, c?: any): Promise<WebhookResult>;
|
|
1097
1130
|
|
|
1098
|
-
export { processWebhook as $, type AgentApiKey as A, type PaginatedResponse as B, type CreateAgentApiKeyRequest as C, type CreateSubscriptionPlanRequest as D, type EnableAutonomyRequest as E, type SubscriptionPlan as F, type CreateSubscriptionRequest as G, type Subscription as H, type CreatePaymentLinkRequest as I, type PaymentLink as J, type CreateInstallmentPlanRequest as K, type ListPaymentsRequest as L, type InstallmentPlan as M, type CreateEscrowRequest as N, type Escrow as O, type PaymentIntent as P, type ApproveEscrowRequest as Q, type RefundEscrowRequest as R, type SmartPaymentRequest as S, type TopUpSessionKeyRequest as T, type DisputeEscrowRequest as U, type CreateInvoiceRequest as V, type WebhookHandlerConfig as W, type Invoice as X, type VerifyWebhookRequest as Y, type ZendFiConfig as Z, type WebhookPayload as _, type WebhookHandlers as a, type WebhookResult as a0, type WebhookEventHandler as a1, type Brand as a2, type PaymentId as a3, type SessionId as a4, type AgentKeyId as a5, type MerchantId as a6, type InvoiceId as a7, type SubscriptionId as a8, type EscrowId as a9, type CreateInstallmentPlanResponse as aA, type ReleaseCondition as aB, type InvoiceLineItem as aC, type ApiKeyScope as aD, type SessionLimits as aE, type PaymentIntentStatus as aF, type CaptureMethod as aG, type UserProfile as aH, type PPPConfig as aI, type AutonomousDelegate as aJ, type RevokeAutonomyRequest as aK, type SmartPaymentStatus as aL, type SessionKeyInstructions as aM, type SessionKeySecurityInfo as aN, type
|
|
1131
|
+
export { processWebhook as $, type AgentApiKey as A, type PaginatedResponse as B, type CreateAgentApiKeyRequest as C, type CreateSubscriptionPlanRequest as D, type EnableAutonomyRequest as E, type SubscriptionPlan as F, type CreateSubscriptionRequest as G, type Subscription as H, type CreatePaymentLinkRequest as I, type PaymentLink as J, type CreateInstallmentPlanRequest as K, type ListPaymentsRequest as L, type InstallmentPlan as M, type CreateEscrowRequest as N, type Escrow as O, type PaymentIntent as P, type ApproveEscrowRequest as Q, type RefundEscrowRequest as R, type SmartPaymentRequest as S, type TopUpSessionKeyRequest as T, type DisputeEscrowRequest as U, type CreateInvoiceRequest as V, type WebhookHandlerConfig as W, type Invoice as X, type VerifyWebhookRequest as Y, type ZendFiConfig as Z, type WebhookPayload as _, type WebhookHandlers as a, type WebhookResult as a0, type WebhookEventHandler as a1, type Brand as a2, type PaymentId as a3, type SessionId as a4, type AgentKeyId as a5, type MerchantId as a6, type InvoiceId as a7, type SubscriptionId as a8, type EscrowId as a9, type CreateInstallmentPlanResponse as aA, type ReleaseCondition as aB, type InvoiceLineItem as aC, type ApiKeyScope as aD, type SessionLimits as aE, type PaymentIntentStatus as aF, type CaptureMethod as aG, type UserProfile as aH, type PPPConfig as aI, type AutonomousDelegate as aJ, type RevokeAutonomyRequest as aK, type SmartPaymentStatus as aL, type SessionKeyInstructions as aM, type SessionKeySecurityInfo as aN, type LinkedSessionInfo as aO, type SecurityStatus as aP, type SessionKeyStats as aQ, type InstallmentPlanId as aa, type PaymentLinkCode as ab, type IntentId as ac, asPaymentId as ad, asSessionId as ae, asAgentKeyId as af, asMerchantId as ag, asInvoiceId as ah, asSubscriptionId as ai, asEscrowId as aj, asInstallmentPlanId as ak, asPaymentLinkCode as al, asIntentId as am, type Environment as an, type ApiKeyMode as ao, type Currency as ap, type PaymentToken as aq, type PaymentStatus as ar, type SubscriptionStatus as as, type InstallmentPlanStatus as at, type EscrowStatus as au, type InvoiceStatus as av, type SplitStatus as aw, type WebhookEvent as ax, type SplitRecipient as ay, type InstallmentScheduleItem as az, type CreateAgentSessionRequest as b, type AgentSession as c, type AgentPaymentRequest as d, type AgentPaymentResponse as e, type AgentAnalytics as f, type CreatePaymentIntentRequest as g, type ConfirmPaymentIntentRequest as h, type PaymentIntentEvent as i, type PPPFactor as j, type PricingSuggestionRequest as k, type PricingSuggestion as l, type EnableAutonomyResponse as m, type AutonomyStatus as n, type SmartPaymentResponse as o, type CreateSessionKeyRequest as p, type CreateSessionKeyResponse as q, type CreateDeviceBoundSessionKeyRequest as r, type CreateDeviceBoundSessionKeyResponse as s, type SubmitSignedTransactionRequest as t, type SubmitTransactionResponse as u, type SessionKeyStatus as v, type SessionKeyListResponse as w, type TopUpSessionKeyResponse as x, type CreatePaymentRequest as y, type Payment as z };
|
|
@@ -822,6 +822,16 @@ interface CreateSessionKeyRequest {
|
|
|
822
822
|
duration_days?: number;
|
|
823
823
|
/** Device fingerprint for security */
|
|
824
824
|
device_fingerprint: string;
|
|
825
|
+
/**
|
|
826
|
+
* Optional: Link to an existing AI session for policy enforcement.
|
|
827
|
+
* When linked, payments will check both session key balance AND session limits.
|
|
828
|
+
*/
|
|
829
|
+
link_session_id?: string;
|
|
830
|
+
/**
|
|
831
|
+
* Optional: Link to a session by token instead of ID.
|
|
832
|
+
* Mutually exclusive with link_session_id.
|
|
833
|
+
*/
|
|
834
|
+
link_session_token?: string;
|
|
825
835
|
}
|
|
826
836
|
/**
|
|
827
837
|
* Session key creation response (custodial mode)
|
|
@@ -921,6 +931,29 @@ interface SessionKeyStatus {
|
|
|
921
931
|
days_until_expiry: number;
|
|
922
932
|
/** Security status */
|
|
923
933
|
security_status: SecurityStatus;
|
|
934
|
+
/** Linked AI session info (if linked) */
|
|
935
|
+
linked_session?: LinkedSessionInfo;
|
|
936
|
+
}
|
|
937
|
+
/**
|
|
938
|
+
* Information about a linked AI session (for policy enforcement)
|
|
939
|
+
*/
|
|
940
|
+
interface LinkedSessionInfo {
|
|
941
|
+
/** Session ID */
|
|
942
|
+
session_id: string;
|
|
943
|
+
/** Agent ID */
|
|
944
|
+
agent_id: string;
|
|
945
|
+
/** Whether the linked session is active */
|
|
946
|
+
is_active: boolean;
|
|
947
|
+
/** Per-transaction limit */
|
|
948
|
+
max_per_transaction?: number;
|
|
949
|
+
/** Daily remaining */
|
|
950
|
+
remaining_today: number;
|
|
951
|
+
/** Weekly remaining */
|
|
952
|
+
remaining_this_week: number;
|
|
953
|
+
/** Monthly remaining */
|
|
954
|
+
remaining_this_month: number;
|
|
955
|
+
/** Effective limit (minimum of session key balance and session limits) */
|
|
956
|
+
effective_limit: number;
|
|
924
957
|
}
|
|
925
958
|
interface SecurityStatus {
|
|
926
959
|
device_fingerprint_matched: boolean;
|
|
@@ -1095,4 +1128,4 @@ interface WebhookResult {
|
|
|
1095
1128
|
}
|
|
1096
1129
|
declare function processWebhook(a: any, b?: any, c?: any): Promise<WebhookResult>;
|
|
1097
1130
|
|
|
1098
|
-
export { processWebhook as $, type AgentApiKey as A, type PaginatedResponse as B, type CreateAgentApiKeyRequest as C, type CreateSubscriptionPlanRequest as D, type EnableAutonomyRequest as E, type SubscriptionPlan as F, type CreateSubscriptionRequest as G, type Subscription as H, type CreatePaymentLinkRequest as I, type PaymentLink as J, type CreateInstallmentPlanRequest as K, type ListPaymentsRequest as L, type InstallmentPlan as M, type CreateEscrowRequest as N, type Escrow as O, type PaymentIntent as P, type ApproveEscrowRequest as Q, type RefundEscrowRequest as R, type SmartPaymentRequest as S, type TopUpSessionKeyRequest as T, type DisputeEscrowRequest as U, type CreateInvoiceRequest as V, type WebhookHandlerConfig as W, type Invoice as X, type VerifyWebhookRequest as Y, type ZendFiConfig as Z, type WebhookPayload as _, type WebhookHandlers as a, type WebhookResult as a0, type WebhookEventHandler as a1, type Brand as a2, type PaymentId as a3, type SessionId as a4, type AgentKeyId as a5, type MerchantId as a6, type InvoiceId as a7, type SubscriptionId as a8, type EscrowId as a9, type CreateInstallmentPlanResponse as aA, type ReleaseCondition as aB, type InvoiceLineItem as aC, type ApiKeyScope as aD, type SessionLimits as aE, type PaymentIntentStatus as aF, type CaptureMethod as aG, type UserProfile as aH, type PPPConfig as aI, type AutonomousDelegate as aJ, type RevokeAutonomyRequest as aK, type SmartPaymentStatus as aL, type SessionKeyInstructions as aM, type SessionKeySecurityInfo as aN, type
|
|
1131
|
+
export { processWebhook as $, type AgentApiKey as A, type PaginatedResponse as B, type CreateAgentApiKeyRequest as C, type CreateSubscriptionPlanRequest as D, type EnableAutonomyRequest as E, type SubscriptionPlan as F, type CreateSubscriptionRequest as G, type Subscription as H, type CreatePaymentLinkRequest as I, type PaymentLink as J, type CreateInstallmentPlanRequest as K, type ListPaymentsRequest as L, type InstallmentPlan as M, type CreateEscrowRequest as N, type Escrow as O, type PaymentIntent as P, type ApproveEscrowRequest as Q, type RefundEscrowRequest as R, type SmartPaymentRequest as S, type TopUpSessionKeyRequest as T, type DisputeEscrowRequest as U, type CreateInvoiceRequest as V, type WebhookHandlerConfig as W, type Invoice as X, type VerifyWebhookRequest as Y, type ZendFiConfig as Z, type WebhookPayload as _, type WebhookHandlers as a, type WebhookResult as a0, type WebhookEventHandler as a1, type Brand as a2, type PaymentId as a3, type SessionId as a4, type AgentKeyId as a5, type MerchantId as a6, type InvoiceId as a7, type SubscriptionId as a8, type EscrowId as a9, type CreateInstallmentPlanResponse as aA, type ReleaseCondition as aB, type InvoiceLineItem as aC, type ApiKeyScope as aD, type SessionLimits as aE, type PaymentIntentStatus as aF, type CaptureMethod as aG, type UserProfile as aH, type PPPConfig as aI, type AutonomousDelegate as aJ, type RevokeAutonomyRequest as aK, type SmartPaymentStatus as aL, type SessionKeyInstructions as aM, type SessionKeySecurityInfo as aN, type LinkedSessionInfo as aO, type SecurityStatus as aP, type SessionKeyStats as aQ, type InstallmentPlanId as aa, type PaymentLinkCode as ab, type IntentId as ac, asPaymentId as ad, asSessionId as ae, asAgentKeyId as af, asMerchantId as ag, asInvoiceId as ah, asSubscriptionId as ai, asEscrowId as aj, asInstallmentPlanId as ak, asPaymentLinkCode as al, asIntentId as am, type Environment as an, type ApiKeyMode as ao, type Currency as ap, type PaymentToken as aq, type PaymentStatus as ar, type SubscriptionStatus as as, type InstallmentPlanStatus as at, type EscrowStatus as au, type InvoiceStatus as av, type SplitStatus as aw, type WebhookEvent as ax, type SplitRecipient as ay, type InstallmentScheduleItem as az, type CreateAgentSessionRequest as b, type AgentSession as c, type AgentPaymentRequest as d, type AgentPaymentResponse as e, type AgentAnalytics as f, type CreatePaymentIntentRequest as g, type ConfirmPaymentIntentRequest as h, type PaymentIntentEvent as i, type PPPFactor as j, type PricingSuggestionRequest as k, type PricingSuggestion as l, type EnableAutonomyResponse as m, type AutonomyStatus as n, type SmartPaymentResponse as o, type CreateSessionKeyRequest as p, type CreateSessionKeyResponse as q, type CreateDeviceBoundSessionKeyRequest as r, type CreateDeviceBoundSessionKeyResponse as s, type SubmitSignedTransactionRequest as t, type SubmitTransactionResponse as u, type SessionKeyStatus as v, type SessionKeyListResponse as w, type TopUpSessionKeyResponse as x, type CreatePaymentRequest as y, type Payment as z };
|