@zendfi/sdk 0.5.2 → 0.5.3
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 +25 -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.mjs
CHANGED
|
@@ -642,6 +642,70 @@ var AgentAPI = class {
|
|
|
642
642
|
await this.request("POST", `/api/v1/ai/sessions/${sessionId}/revoke`);
|
|
643
643
|
}
|
|
644
644
|
// ============================================
|
|
645
|
+
// Agent Payments
|
|
646
|
+
// ============================================
|
|
647
|
+
/**
|
|
648
|
+
* Execute a payment using an agent session
|
|
649
|
+
*
|
|
650
|
+
* This is the primary method for AI agents to make payments. It uses the
|
|
651
|
+
* session token to enforce spending limits and automatically routes the
|
|
652
|
+
* payment through the optimal path.
|
|
653
|
+
*
|
|
654
|
+
* The session token comes from `createSession()` and enforces:
|
|
655
|
+
* - Per-transaction limits
|
|
656
|
+
* - Daily limits
|
|
657
|
+
* - Weekly limits
|
|
658
|
+
* - Monthly limits
|
|
659
|
+
*
|
|
660
|
+
* @param request - Payment request with session token
|
|
661
|
+
* @returns Payment result with status and receipt
|
|
662
|
+
*
|
|
663
|
+
* @example
|
|
664
|
+
* ```typescript
|
|
665
|
+
* // Create a session first
|
|
666
|
+
* const session = await zendfi.agent.createSession({
|
|
667
|
+
* agent_id: 'shopping-bot',
|
|
668
|
+
* user_wallet: 'Hx7B...abc',
|
|
669
|
+
* limits: {
|
|
670
|
+
* max_per_transaction: 50,
|
|
671
|
+
* max_per_day: 200,
|
|
672
|
+
* },
|
|
673
|
+
* duration_hours: 24,
|
|
674
|
+
* });
|
|
675
|
+
*
|
|
676
|
+
* // Make payments within the session limits
|
|
677
|
+
* const payment = await zendfi.agent.pay({
|
|
678
|
+
* session_token: session.session_token,
|
|
679
|
+
* amount: 29.99,
|
|
680
|
+
* description: 'Premium widget',
|
|
681
|
+
* auto_gasless: true,
|
|
682
|
+
* });
|
|
683
|
+
*
|
|
684
|
+
* if (payment.requires_signature) {
|
|
685
|
+
* // Device-bound: user must sign
|
|
686
|
+
* console.log('Sign and submit to:', payment.submit_url);
|
|
687
|
+
* } else {
|
|
688
|
+
* // Auto-signed: payment complete
|
|
689
|
+
* console.log('Payment confirmed:', payment.transaction_signature);
|
|
690
|
+
* }
|
|
691
|
+
* ```
|
|
692
|
+
*/
|
|
693
|
+
async pay(request) {
|
|
694
|
+
return this.request("POST", "/api/v1/ai/smart-payment", {
|
|
695
|
+
session_token: request.session_token,
|
|
696
|
+
agent_id: "session",
|
|
697
|
+
// Session already has agent_id bound
|
|
698
|
+
user_wallet: "",
|
|
699
|
+
// Will be extracted from session
|
|
700
|
+
amount_usd: request.amount,
|
|
701
|
+
merchant_id: request.recipient_merchant_id,
|
|
702
|
+
token: request.token || "USDC",
|
|
703
|
+
auto_detect_gasless: request.auto_gasless,
|
|
704
|
+
description: request.description,
|
|
705
|
+
metadata: request.metadata
|
|
706
|
+
});
|
|
707
|
+
}
|
|
708
|
+
// ============================================
|
|
645
709
|
// Agent Analytics
|
|
646
710
|
// ============================================
|
|
647
711
|
/**
|
|
@@ -777,7 +841,8 @@ var PaymentIntentsAPI = class {
|
|
|
777
841
|
customer_wallet: request.customer_wallet,
|
|
778
842
|
payment_type: request.payment_type,
|
|
779
843
|
auto_gasless: request.auto_gasless,
|
|
780
|
-
metadata: request.metadata
|
|
844
|
+
metadata: request.metadata,
|
|
845
|
+
session_token: request.session_token
|
|
781
846
|
});
|
|
782
847
|
}
|
|
783
848
|
/**
|
|
@@ -1241,6 +1306,269 @@ var SmartPaymentsAPI = class {
|
|
|
1241
1306
|
}
|
|
1242
1307
|
};
|
|
1243
1308
|
|
|
1309
|
+
// src/api/session-keys.ts
|
|
1310
|
+
var SessionKeysAPI = class {
|
|
1311
|
+
constructor(request) {
|
|
1312
|
+
this.request = request;
|
|
1313
|
+
}
|
|
1314
|
+
// ============================================
|
|
1315
|
+
// Custodial Session Keys
|
|
1316
|
+
// ============================================
|
|
1317
|
+
/**
|
|
1318
|
+
* Create a custodial session key
|
|
1319
|
+
*
|
|
1320
|
+
* The backend generates and securely stores the keypair.
|
|
1321
|
+
* Returns an approval transaction that the user must sign to fund the session wallet.
|
|
1322
|
+
*
|
|
1323
|
+
* @param request - Session key configuration
|
|
1324
|
+
* @returns Creation response with approval transaction
|
|
1325
|
+
*
|
|
1326
|
+
* @example
|
|
1327
|
+
* ```typescript
|
|
1328
|
+
* const result = await zendfi.sessionKeys.create({
|
|
1329
|
+
* user_wallet: 'Hx7B...abc',
|
|
1330
|
+
* limit_usdc: 100,
|
|
1331
|
+
* duration_days: 7,
|
|
1332
|
+
* device_fingerprint: deviceFingerprint,
|
|
1333
|
+
* });
|
|
1334
|
+
*
|
|
1335
|
+
* console.log(`Session key: ${result.session_key_id}`);
|
|
1336
|
+
* console.log('Please sign the approval transaction');
|
|
1337
|
+
* ```
|
|
1338
|
+
*/
|
|
1339
|
+
async create(request) {
|
|
1340
|
+
return this.request("POST", "/api/v1/ai/session-keys/create", {
|
|
1341
|
+
user_wallet: request.user_wallet,
|
|
1342
|
+
limit_usdc: request.limit_usdc,
|
|
1343
|
+
duration_days: request.duration_days ?? 7,
|
|
1344
|
+
device_fingerprint: request.device_fingerprint
|
|
1345
|
+
});
|
|
1346
|
+
}
|
|
1347
|
+
// ============================================
|
|
1348
|
+
// Device-Bound Session Keys (Non-Custodial)
|
|
1349
|
+
// ============================================
|
|
1350
|
+
/**
|
|
1351
|
+
* Create a device-bound session key (non-custodial)
|
|
1352
|
+
*
|
|
1353
|
+
* The client generates the keypair and encrypts it with a PIN before sending.
|
|
1354
|
+
* The backend cannot decrypt the keypair - only the user's device can.
|
|
1355
|
+
*
|
|
1356
|
+
* @param request - Device-bound session key configuration
|
|
1357
|
+
* @returns Creation response with session wallet address
|
|
1358
|
+
*
|
|
1359
|
+
* @example
|
|
1360
|
+
* ```typescript
|
|
1361
|
+
* // Generate keypair client-side
|
|
1362
|
+
* const keypair = Keypair.generate();
|
|
1363
|
+
*
|
|
1364
|
+
* // Encrypt with PIN
|
|
1365
|
+
* const encrypted = await encryptWithPin(keypair.secretKey, pin);
|
|
1366
|
+
*
|
|
1367
|
+
* const result = await zendfi.sessionKeys.createDeviceBound({
|
|
1368
|
+
* user_wallet: 'Hx7B...abc',
|
|
1369
|
+
* limit_usdc: 100,
|
|
1370
|
+
* duration_days: 7,
|
|
1371
|
+
* encrypted_session_key: encrypted.ciphertext,
|
|
1372
|
+
* nonce: encrypted.nonce,
|
|
1373
|
+
* session_public_key: keypair.publicKey.toBase58(),
|
|
1374
|
+
* device_fingerprint: deviceFingerprint,
|
|
1375
|
+
* });
|
|
1376
|
+
*
|
|
1377
|
+
* console.log(`Session wallet: ${result.session_wallet}`);
|
|
1378
|
+
* ```
|
|
1379
|
+
*/
|
|
1380
|
+
async createDeviceBound(request) {
|
|
1381
|
+
return this.request(
|
|
1382
|
+
"POST",
|
|
1383
|
+
"/api/v1/ai/session-keys/device-bound/create",
|
|
1384
|
+
{
|
|
1385
|
+
user_wallet: request.user_wallet,
|
|
1386
|
+
limit_usdc: request.limit_usdc,
|
|
1387
|
+
duration_days: request.duration_days,
|
|
1388
|
+
encrypted_session_key: request.encrypted_session_key,
|
|
1389
|
+
nonce: request.nonce,
|
|
1390
|
+
session_public_key: request.session_public_key,
|
|
1391
|
+
device_fingerprint: request.device_fingerprint,
|
|
1392
|
+
recovery_qr_data: request.recovery_qr_data
|
|
1393
|
+
}
|
|
1394
|
+
);
|
|
1395
|
+
}
|
|
1396
|
+
/**
|
|
1397
|
+
* Get encrypted session key for device-bound mode
|
|
1398
|
+
*
|
|
1399
|
+
* Retrieves the encrypted keypair so the client can decrypt it with their PIN.
|
|
1400
|
+
* The device fingerprint must match the one used during creation.
|
|
1401
|
+
*
|
|
1402
|
+
* @param sessionKeyId - UUID of the session key
|
|
1403
|
+
* @param deviceFingerprint - Current device fingerprint
|
|
1404
|
+
* @returns Encrypted key data
|
|
1405
|
+
*/
|
|
1406
|
+
async getEncrypted(sessionKeyId, deviceFingerprint) {
|
|
1407
|
+
return this.request("POST", "/api/v1/ai/session-keys/device-bound/get-encrypted", {
|
|
1408
|
+
session_key_id: sessionKeyId,
|
|
1409
|
+
device_fingerprint: deviceFingerprint
|
|
1410
|
+
});
|
|
1411
|
+
}
|
|
1412
|
+
// ============================================
|
|
1413
|
+
// Transaction Submission
|
|
1414
|
+
// ============================================
|
|
1415
|
+
/**
|
|
1416
|
+
* Submit a signed approval transaction
|
|
1417
|
+
*
|
|
1418
|
+
* After the user signs the approval transaction from `create()`,
|
|
1419
|
+
* submit it here to activate the session key.
|
|
1420
|
+
*
|
|
1421
|
+
* @param request - Signed transaction data
|
|
1422
|
+
* @returns Submission result with signature
|
|
1423
|
+
*
|
|
1424
|
+
* @example
|
|
1425
|
+
* ```typescript
|
|
1426
|
+
* const result = await zendfi.sessionKeys.submitApproval({
|
|
1427
|
+
* session_key_id: sessionKeyId,
|
|
1428
|
+
* signed_transaction: signedTxBase64,
|
|
1429
|
+
* });
|
|
1430
|
+
*
|
|
1431
|
+
* console.log(`Approved! Signature: ${result.signature}`);
|
|
1432
|
+
* ```
|
|
1433
|
+
*/
|
|
1434
|
+
async submitApproval(request) {
|
|
1435
|
+
return this.request(
|
|
1436
|
+
"POST",
|
|
1437
|
+
"/api/v1/ai/session-keys/submit-approval",
|
|
1438
|
+
{
|
|
1439
|
+
session_key_id: request.session_key_id,
|
|
1440
|
+
signed_transaction: request.signed_transaction
|
|
1441
|
+
}
|
|
1442
|
+
);
|
|
1443
|
+
}
|
|
1444
|
+
/**
|
|
1445
|
+
* Submit a signed top-up transaction
|
|
1446
|
+
*
|
|
1447
|
+
* After the user signs the top-up transaction from `topUp()`,
|
|
1448
|
+
* submit it here to add funds.
|
|
1449
|
+
*
|
|
1450
|
+
* @param sessionKeyId - UUID of the session key
|
|
1451
|
+
* @param signedTransaction - Base64 encoded signed transaction
|
|
1452
|
+
* @returns Submission result with new limit
|
|
1453
|
+
*/
|
|
1454
|
+
async submitTopUp(sessionKeyId, signedTransaction) {
|
|
1455
|
+
return this.request(
|
|
1456
|
+
"POST",
|
|
1457
|
+
`/api/v1/ai/session-keys/${sessionKeyId}/submit-top-up`,
|
|
1458
|
+
{
|
|
1459
|
+
signed_transaction: signedTransaction
|
|
1460
|
+
}
|
|
1461
|
+
);
|
|
1462
|
+
}
|
|
1463
|
+
// ============================================
|
|
1464
|
+
// Status & Management
|
|
1465
|
+
// ============================================
|
|
1466
|
+
/**
|
|
1467
|
+
* Get session key status
|
|
1468
|
+
*
|
|
1469
|
+
* @param sessionKeyId - UUID of the session key
|
|
1470
|
+
* @returns Current status with remaining balance
|
|
1471
|
+
*
|
|
1472
|
+
* @example
|
|
1473
|
+
* ```typescript
|
|
1474
|
+
* const status = await zendfi.sessionKeys.getStatus(sessionKeyId);
|
|
1475
|
+
*
|
|
1476
|
+
* console.log(`Active: ${status.is_active}`);
|
|
1477
|
+
* console.log(`Limit: $${status.limit_usdc}`);
|
|
1478
|
+
* console.log(`Used: $${status.used_amount_usdc}`);
|
|
1479
|
+
* console.log(`Remaining: $${status.remaining_usdc}`);
|
|
1480
|
+
* console.log(`Expires in ${status.days_until_expiry} days`);
|
|
1481
|
+
* ```
|
|
1482
|
+
*/
|
|
1483
|
+
async getStatus(sessionKeyId) {
|
|
1484
|
+
return this.request("POST", "/api/v1/ai/session-keys/status", {
|
|
1485
|
+
session_key_id: sessionKeyId
|
|
1486
|
+
});
|
|
1487
|
+
}
|
|
1488
|
+
/**
|
|
1489
|
+
* List all session keys for the merchant
|
|
1490
|
+
*
|
|
1491
|
+
* @returns List of session keys with stats
|
|
1492
|
+
*
|
|
1493
|
+
* @example
|
|
1494
|
+
* ```typescript
|
|
1495
|
+
* const { session_keys, stats } = await zendfi.sessionKeys.list();
|
|
1496
|
+
*
|
|
1497
|
+
* console.log(`Total keys: ${stats.total_keys}`);
|
|
1498
|
+
* console.log(`Active: ${stats.active_keys}`);
|
|
1499
|
+
*
|
|
1500
|
+
* session_keys.forEach(key => {
|
|
1501
|
+
* console.log(`${key.session_key_id}: $${key.remaining_usdc} remaining`);
|
|
1502
|
+
* });
|
|
1503
|
+
* ```
|
|
1504
|
+
*/
|
|
1505
|
+
async list() {
|
|
1506
|
+
return this.request("GET", "/api/v1/ai/session-keys/list");
|
|
1507
|
+
}
|
|
1508
|
+
/**
|
|
1509
|
+
* Top up a session key with additional funds
|
|
1510
|
+
*
|
|
1511
|
+
* Returns a transaction that the user must sign to add funds.
|
|
1512
|
+
*
|
|
1513
|
+
* @param sessionKeyId - UUID of the session key
|
|
1514
|
+
* @param request - Top-up configuration
|
|
1515
|
+
* @returns Top-up transaction to sign
|
|
1516
|
+
*
|
|
1517
|
+
* @example
|
|
1518
|
+
* ```typescript
|
|
1519
|
+
* const topUp = await zendfi.sessionKeys.topUp(sessionKeyId, {
|
|
1520
|
+
* user_wallet: 'Hx7B...abc',
|
|
1521
|
+
* amount_usdc: 50,
|
|
1522
|
+
* device_fingerprint: deviceFingerprint,
|
|
1523
|
+
* });
|
|
1524
|
+
*
|
|
1525
|
+
* console.log(`Adding $${topUp.added_amount}`);
|
|
1526
|
+
* console.log(`New limit will be: $${topUp.new_limit}`);
|
|
1527
|
+
*
|
|
1528
|
+
* // User signs the transaction
|
|
1529
|
+
* const signedTx = await wallet.signTransaction(topUp.top_up_transaction);
|
|
1530
|
+
*
|
|
1531
|
+
* // Submit it
|
|
1532
|
+
* await zendfi.sessionKeys.submitTopUp(sessionKeyId, signedTx);
|
|
1533
|
+
* ```
|
|
1534
|
+
*/
|
|
1535
|
+
async topUp(sessionKeyId, request) {
|
|
1536
|
+
return this.request(
|
|
1537
|
+
"POST",
|
|
1538
|
+
`/api/v1/ai/session-keys/${sessionKeyId}/top-up`,
|
|
1539
|
+
{
|
|
1540
|
+
user_wallet: request.user_wallet,
|
|
1541
|
+
amount_usdc: request.amount_usdc,
|
|
1542
|
+
device_fingerprint: request.device_fingerprint
|
|
1543
|
+
}
|
|
1544
|
+
);
|
|
1545
|
+
}
|
|
1546
|
+
/**
|
|
1547
|
+
* Revoke a session key
|
|
1548
|
+
*
|
|
1549
|
+
* Immediately deactivates the session key. Any remaining funds
|
|
1550
|
+
* are refunded to the user's wallet.
|
|
1551
|
+
*
|
|
1552
|
+
* @param sessionKeyId - UUID of the session key
|
|
1553
|
+
* @returns Revocation result with optional refund details
|
|
1554
|
+
*
|
|
1555
|
+
* @example
|
|
1556
|
+
* ```typescript
|
|
1557
|
+
* const result = await zendfi.sessionKeys.revoke(sessionKeyId);
|
|
1558
|
+
*
|
|
1559
|
+
* console.log('Session key revoked');
|
|
1560
|
+
* if (result.refund?.refunded) {
|
|
1561
|
+
* console.log(`Refunded: ${result.refund.transaction_signature}`);
|
|
1562
|
+
* }
|
|
1563
|
+
* ```
|
|
1564
|
+
*/
|
|
1565
|
+
async revoke(sessionKeyId) {
|
|
1566
|
+
return this.request("POST", "/api/v1/ai/session-keys/revoke", {
|
|
1567
|
+
session_key_id: sessionKeyId
|
|
1568
|
+
});
|
|
1569
|
+
}
|
|
1570
|
+
};
|
|
1571
|
+
|
|
1244
1572
|
// src/client.ts
|
|
1245
1573
|
var ZendFiClient = class {
|
|
1246
1574
|
config;
|
|
@@ -1345,6 +1673,38 @@ var ZendFiClient = class {
|
|
|
1345
1673
|
* ```
|
|
1346
1674
|
*/
|
|
1347
1675
|
smart;
|
|
1676
|
+
/**
|
|
1677
|
+
* Session Keys API - On-chain funded session keys with PKP identity
|
|
1678
|
+
*
|
|
1679
|
+
* Session keys are pre-funded wallets with spending limits that enable
|
|
1680
|
+
* AI agents to make autonomous payments without user signatures.
|
|
1681
|
+
*
|
|
1682
|
+
* The flow:
|
|
1683
|
+
* 1. Create a session key (user approves spending limit)
|
|
1684
|
+
* 2. User signs the approval transaction (one-time)
|
|
1685
|
+
* 3. Agent can now make payments up to the limit
|
|
1686
|
+
*
|
|
1687
|
+
* @example
|
|
1688
|
+
* ```typescript
|
|
1689
|
+
* // Create session key
|
|
1690
|
+
* const key = await zendfi.sessionKeys.create({
|
|
1691
|
+
* agent_id: 'shopping-bot',
|
|
1692
|
+
* user_wallet: 'Hx7B...abc',
|
|
1693
|
+
* max_amount: 100,
|
|
1694
|
+
* expiry_hours: 24,
|
|
1695
|
+
* });
|
|
1696
|
+
*
|
|
1697
|
+
* // User signs the approval
|
|
1698
|
+
* await zendfi.sessionKeys.submitApproval(key.session_key_id, {
|
|
1699
|
+
* signed_transaction: signedTx,
|
|
1700
|
+
* });
|
|
1701
|
+
*
|
|
1702
|
+
* // Check status
|
|
1703
|
+
* const status = await zendfi.sessionKeys.getStatus(key.session_key_id);
|
|
1704
|
+
* console.log(`Remaining: $${status.remaining_amount}`);
|
|
1705
|
+
* ```
|
|
1706
|
+
*/
|
|
1707
|
+
sessionKeys;
|
|
1348
1708
|
constructor(options) {
|
|
1349
1709
|
this.config = ConfigLoader.load(options);
|
|
1350
1710
|
ConfigLoader.validateApiKey(this.config.apiKey);
|
|
@@ -1355,6 +1715,7 @@ var ZendFiClient = class {
|
|
|
1355
1715
|
this.pricing = new PricingAPI(boundRequest);
|
|
1356
1716
|
this.autonomy = new AutonomyAPI(boundRequest);
|
|
1357
1717
|
this.smart = new SmartPaymentsAPI(boundRequest);
|
|
1718
|
+
this.sessionKeys = new SessionKeysAPI(boundRequest);
|
|
1358
1719
|
if (this.config.environment === "development" || this.config.debug) {
|
|
1359
1720
|
console.log(
|
|
1360
1721
|
`\u2713 ZendFi SDK initialized in ${this.config.mode} mode (${this.config.mode === "test" ? "devnet" : "mainnet"})`
|
|
@@ -3005,6 +3366,7 @@ export {
|
|
|
3005
3366
|
RecoveryQRGenerator,
|
|
3006
3367
|
SPENDING_LIMIT_ACTION_CID,
|
|
3007
3368
|
SessionKeyCrypto,
|
|
3369
|
+
SessionKeysAPI,
|
|
3008
3370
|
SmartPaymentsAPI,
|
|
3009
3371
|
ValidationError2 as ValidationError,
|
|
3010
3372
|
WebhookError,
|
package/dist/nextjs.d.mts
CHANGED
package/dist/nextjs.d.ts
CHANGED
|
@@ -532,6 +532,8 @@ interface ConfirmPaymentIntentRequest {
|
|
|
532
532
|
auto_gasless?: boolean;
|
|
533
533
|
/** Additional metadata */
|
|
534
534
|
metadata?: Record<string, unknown>;
|
|
535
|
+
/** Session token for spending limit enforcement (optional) */
|
|
536
|
+
session_token?: string;
|
|
535
537
|
}
|
|
536
538
|
/**
|
|
537
539
|
* Payment Intent Event
|
|
@@ -807,6 +809,233 @@ interface AgentAnalytics {
|
|
|
807
809
|
volume_usd: number;
|
|
808
810
|
}>;
|
|
809
811
|
}
|
|
812
|
+
/**
|
|
813
|
+
* Session key creation request (custodial mode)
|
|
814
|
+
* Backend generates and stores the keypair
|
|
815
|
+
*/
|
|
816
|
+
interface CreateSessionKeyRequest {
|
|
817
|
+
/** User's main wallet address */
|
|
818
|
+
user_wallet: string;
|
|
819
|
+
/** Spending limit in USDC */
|
|
820
|
+
limit_usdc: number;
|
|
821
|
+
/** Duration in days (1-30) */
|
|
822
|
+
duration_days?: number;
|
|
823
|
+
/** Device fingerprint for security */
|
|
824
|
+
device_fingerprint: string;
|
|
825
|
+
}
|
|
826
|
+
/**
|
|
827
|
+
* Session key creation response (custodial mode)
|
|
828
|
+
*/
|
|
829
|
+
interface CreateSessionKeyResponse {
|
|
830
|
+
/** UUID of the created session key */
|
|
831
|
+
session_key_id: string;
|
|
832
|
+
/** User's main wallet address */
|
|
833
|
+
user_wallet: string;
|
|
834
|
+
/** Spending limit in USDC */
|
|
835
|
+
limit_usdc: number;
|
|
836
|
+
/** Expiration timestamp */
|
|
837
|
+
expires_at: string;
|
|
838
|
+
/** Whether user needs to sign approval transaction */
|
|
839
|
+
requires_approval: boolean;
|
|
840
|
+
/** Base64 encoded approval transaction (user must sign) */
|
|
841
|
+
approval_transaction: string;
|
|
842
|
+
/** Setup instructions */
|
|
843
|
+
instructions: SessionKeyInstructions;
|
|
844
|
+
}
|
|
845
|
+
interface SessionKeyInstructions {
|
|
846
|
+
step_1: string;
|
|
847
|
+
step_2: string;
|
|
848
|
+
step_3: string;
|
|
849
|
+
wallet_support: string[];
|
|
850
|
+
}
|
|
851
|
+
/**
|
|
852
|
+
* Device-bound session key creation request (non-custodial mode)
|
|
853
|
+
* Client generates keypair and encrypts it before sending
|
|
854
|
+
*/
|
|
855
|
+
interface CreateDeviceBoundSessionKeyRequest {
|
|
856
|
+
/** User's main wallet address */
|
|
857
|
+
user_wallet: string;
|
|
858
|
+
/** Spending limit in USDC */
|
|
859
|
+
limit_usdc: number;
|
|
860
|
+
/** Duration in days (1-30) */
|
|
861
|
+
duration_days: number;
|
|
862
|
+
/** Client-encrypted session keypair (base64) */
|
|
863
|
+
encrypted_session_key: string;
|
|
864
|
+
/** Encryption nonce (base64, 12 bytes) */
|
|
865
|
+
nonce: string;
|
|
866
|
+
/** Public key of the session keypair */
|
|
867
|
+
session_public_key: string;
|
|
868
|
+
/** Device fingerprint (SHA-256 hex, 64 chars) */
|
|
869
|
+
device_fingerprint: string;
|
|
870
|
+
/** Optional recovery QR data */
|
|
871
|
+
recovery_qr_data?: string;
|
|
872
|
+
}
|
|
873
|
+
/**
|
|
874
|
+
* Device-bound session key creation response
|
|
875
|
+
*/
|
|
876
|
+
interface CreateDeviceBoundSessionKeyResponse {
|
|
877
|
+
/** UUID of the created session key */
|
|
878
|
+
session_key_id: string;
|
|
879
|
+
/** Always "device_bound" */
|
|
880
|
+
mode: string;
|
|
881
|
+
/** Always false for device-bound */
|
|
882
|
+
is_custodial: boolean;
|
|
883
|
+
/** User's main wallet address */
|
|
884
|
+
user_wallet: string;
|
|
885
|
+
/** Session wallet public key */
|
|
886
|
+
session_wallet: string;
|
|
887
|
+
/** Spending limit in USDC */
|
|
888
|
+
limit_usdc: number;
|
|
889
|
+
/** Expiration timestamp */
|
|
890
|
+
expires_at: string;
|
|
891
|
+
/** Always true for device-bound */
|
|
892
|
+
requires_client_signing: boolean;
|
|
893
|
+
/** Security details */
|
|
894
|
+
security_info: SessionKeySecurityInfo;
|
|
895
|
+
}
|
|
896
|
+
interface SessionKeySecurityInfo {
|
|
897
|
+
encryption_type: string;
|
|
898
|
+
device_bound: boolean;
|
|
899
|
+
backend_can_decrypt: boolean;
|
|
900
|
+
recovery_qr_saved: boolean;
|
|
901
|
+
}
|
|
902
|
+
/**
|
|
903
|
+
* Session key status response
|
|
904
|
+
*/
|
|
905
|
+
interface SessionKeyStatus {
|
|
906
|
+
/** UUID of the session key */
|
|
907
|
+
session_key_id: string;
|
|
908
|
+
/** Whether the key is currently active */
|
|
909
|
+
is_active: boolean;
|
|
910
|
+
/** Whether the approval transaction was confirmed */
|
|
911
|
+
is_approved: boolean;
|
|
912
|
+
/** Total spending limit in USDC */
|
|
913
|
+
limit_usdc: number;
|
|
914
|
+
/** Amount already spent in USDC */
|
|
915
|
+
used_amount_usdc: number;
|
|
916
|
+
/** Remaining balance in USDC */
|
|
917
|
+
remaining_usdc: number;
|
|
918
|
+
/** Expiration timestamp */
|
|
919
|
+
expires_at: string;
|
|
920
|
+
/** Days until expiry */
|
|
921
|
+
days_until_expiry: number;
|
|
922
|
+
/** Security status */
|
|
923
|
+
security_status: SecurityStatus;
|
|
924
|
+
}
|
|
925
|
+
interface SecurityStatus {
|
|
926
|
+
device_fingerprint_matched: boolean;
|
|
927
|
+
recent_security_events: number;
|
|
928
|
+
last_used_at: string | null;
|
|
929
|
+
}
|
|
930
|
+
/**
|
|
931
|
+
* Top-up request for adding funds to a session key
|
|
932
|
+
*/
|
|
933
|
+
interface TopUpSessionKeyRequest {
|
|
934
|
+
/** User's main wallet address */
|
|
935
|
+
user_wallet: string;
|
|
936
|
+
/** Amount to add in USDC */
|
|
937
|
+
amount_usdc: number;
|
|
938
|
+
/** Device fingerprint for security */
|
|
939
|
+
device_fingerprint: string;
|
|
940
|
+
}
|
|
941
|
+
/**
|
|
942
|
+
* Top-up response with unsigned transaction
|
|
943
|
+
*/
|
|
944
|
+
interface TopUpSessionKeyResponse {
|
|
945
|
+
/** UUID of the session key */
|
|
946
|
+
session_key_id: string;
|
|
947
|
+
/** Previous limit before top-up */
|
|
948
|
+
previous_limit: number;
|
|
949
|
+
/** New limit after top-up */
|
|
950
|
+
new_limit: number;
|
|
951
|
+
/** Amount being added */
|
|
952
|
+
added_amount: number;
|
|
953
|
+
/** Base64 encoded top-up transaction (user must sign) */
|
|
954
|
+
top_up_transaction: string;
|
|
955
|
+
/** Block height for transaction validity */
|
|
956
|
+
last_valid_block_height: number;
|
|
957
|
+
/** Instructions for the user */
|
|
958
|
+
instructions: string;
|
|
959
|
+
}
|
|
960
|
+
/**
|
|
961
|
+
* Submit signed transaction request
|
|
962
|
+
*/
|
|
963
|
+
interface SubmitSignedTransactionRequest {
|
|
964
|
+
/** Base64 encoded signed transaction */
|
|
965
|
+
signed_transaction: string;
|
|
966
|
+
/** Optional session key ID (for some endpoints) */
|
|
967
|
+
session_key_id?: string;
|
|
968
|
+
}
|
|
969
|
+
/**
|
|
970
|
+
* Submit transaction response
|
|
971
|
+
*/
|
|
972
|
+
interface SubmitTransactionResponse {
|
|
973
|
+
success: boolean;
|
|
974
|
+
signature: string;
|
|
975
|
+
message: string;
|
|
976
|
+
/** For top-up submissions */
|
|
977
|
+
new_limit?: number;
|
|
978
|
+
}
|
|
979
|
+
/**
|
|
980
|
+
* Session key list response
|
|
981
|
+
*/
|
|
982
|
+
interface SessionKeyListResponse {
|
|
983
|
+
session_keys: SessionKeyStatus[];
|
|
984
|
+
stats: SessionKeyStats;
|
|
985
|
+
merchant_id: string;
|
|
986
|
+
}
|
|
987
|
+
interface SessionKeyStats {
|
|
988
|
+
total_keys: number;
|
|
989
|
+
active_keys: number;
|
|
990
|
+
total_limit_usdc: number;
|
|
991
|
+
total_used_usdc: number;
|
|
992
|
+
}
|
|
993
|
+
/**
|
|
994
|
+
* Agent payment request - simplified payment via session
|
|
995
|
+
*/
|
|
996
|
+
interface AgentPaymentRequest {
|
|
997
|
+
/** Session token for spending limit enforcement */
|
|
998
|
+
session_token: string;
|
|
999
|
+
/** Amount in USD */
|
|
1000
|
+
amount: number;
|
|
1001
|
+
/** Payment description */
|
|
1002
|
+
description?: string;
|
|
1003
|
+
/** Recipient merchant ID (optional if paying to session owner) */
|
|
1004
|
+
recipient_merchant_id?: string;
|
|
1005
|
+
/** Token to use (default: USDC) */
|
|
1006
|
+
token?: PaymentToken;
|
|
1007
|
+
/** Auto-detect if gasless is needed */
|
|
1008
|
+
auto_gasless?: boolean;
|
|
1009
|
+
/** Additional metadata */
|
|
1010
|
+
metadata?: Record<string, any>;
|
|
1011
|
+
}
|
|
1012
|
+
/**
|
|
1013
|
+
* Agent payment response
|
|
1014
|
+
*/
|
|
1015
|
+
interface AgentPaymentResponse {
|
|
1016
|
+
/** UUID of the created payment */
|
|
1017
|
+
payment_id: string;
|
|
1018
|
+
/** Payment status */
|
|
1019
|
+
status: 'pending' | 'processing' | 'confirmed' | 'failed' | 'awaiting_signature';
|
|
1020
|
+
/** Amount in USD */
|
|
1021
|
+
amount_usd: number;
|
|
1022
|
+
/** Whether gasless mode was used */
|
|
1023
|
+
gasless_used: boolean;
|
|
1024
|
+
/** Transaction signature (if confirmed) */
|
|
1025
|
+
transaction_signature?: string;
|
|
1026
|
+
/** Confirmation time in milliseconds */
|
|
1027
|
+
confirmed_in_ms?: number;
|
|
1028
|
+
/** Receipt URL */
|
|
1029
|
+
receipt_url?: string;
|
|
1030
|
+
/** If true, client must sign the transaction */
|
|
1031
|
+
requires_signature: boolean;
|
|
1032
|
+
/** Base64 encoded unsigned transaction (if requires_signature) */
|
|
1033
|
+
unsigned_transaction?: string;
|
|
1034
|
+
/** URL to submit signed transaction */
|
|
1035
|
+
submit_url?: string;
|
|
1036
|
+
/** Next steps for the client */
|
|
1037
|
+
next_steps: string;
|
|
1038
|
+
}
|
|
810
1039
|
|
|
811
1040
|
/**
|
|
812
1041
|
* ZendFi Webhook Handlers
|
|
@@ -866,4 +1095,4 @@ interface WebhookResult {
|
|
|
866
1095
|
}
|
|
867
1096
|
declare function processWebhook(a: any, b?: any, c?: any): Promise<WebhookResult>;
|
|
868
1097
|
|
|
869
|
-
export {
|
|
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 SecurityStatus as aO, type SessionKeyStats as aP, 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 };
|