@zendfi/sdk 1.1.4 → 1.1.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.
Files changed (2) hide show
  1. package/README.md +57 -2
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -262,6 +262,8 @@ zendfi.withdrawSubAccountToBank(...)
262
262
  zendfi.createSubAccountAutomationToken(...)
263
263
  zendfi.revokeSubAccountAutomationToken(...)
264
264
  zendfi.createSubAccountSigningGrant(...)
265
+ zendfi.startSubAccountSigningGrantBrowserIntent(...)
266
+ zendfi.pollSubAccountSigningGrantBrowserIntent(...)
265
267
  zendfi.revokeSubAccountSigningGrant(...)
266
268
  zendfi.closeSubAccount(...)
267
269
  ```
@@ -292,8 +294,61 @@ Sensitive sub-account operations such as `drainSubAccount` require `passkey_sign
292
294
  For `withdrawFromSubAccount` and `withdrawSubAccountToBank`, the recommended headless path is:
293
295
 
294
296
  1. Mint policy token via `createSubAccountAutomationToken` (or use delegation token).
295
- 2. Mint signing authorization via `createSubAccountSigningGrant` (one interactive passkey ceremony).
296
- 3. Execute `withdrawFromSubAccount` or `withdrawSubAccountToBank` using `delegation_token` (or `automation_token` for bank) + `signing_grant`.
297
+ 2. Start browser intent via `startSubAccountSigningGrantBrowserIntent`.
298
+ 3. Open `approval_url` in a browser and complete passkey approval.
299
+ 4. Poll with `pollSubAccountSigningGrantBrowserIntent` until approved; consume returned `signing_grant`.
300
+ 5. Execute `withdrawFromSubAccount` or `withdrawSubAccountToBank` using `delegation_token` (or `automation_token` for bank) + `signing_grant`.
301
+
302
+ Legacy direct mint (`createSubAccountSigningGrant` with `passkey_signature`) remains available as fallback.
303
+
304
+ Example browser-intent flow (Node/CLI app):
305
+
306
+ ```typescript
307
+ import open from 'open';
308
+ import { zendfi } from '@zendfi/sdk';
309
+
310
+ const intent = await zendfi.startSubAccountSigningGrantBrowserIntent({
311
+ sub_account_id: 'sa_7b1w9j2k4m8p',
312
+ ttl_seconds: 3600,
313
+ max_uses: 25,
314
+ total_limit_usdc: 500,
315
+ per_tx_limit_usdc: 50,
316
+ mode: 'live',
317
+ });
318
+
319
+ await open(intent.approval_url);
320
+
321
+ let grant: string | undefined;
322
+ for (let i = 0; i < 180; i += 1) {
323
+ const poll = await zendfi.pollSubAccountSigningGrantBrowserIntent({
324
+ intent_id: intent.intent_id,
325
+ intent_token: intent.intent_token,
326
+ });
327
+
328
+ if (poll.completed) {
329
+ if (poll.status !== 'approved' || !poll.grant) {
330
+ throw new Error(poll.error || `intent ended in ${poll.status}`);
331
+ }
332
+ grant = poll.grant.signing_grant;
333
+ break;
334
+ }
335
+
336
+ await new Promise((r) => setTimeout(r, 2000));
337
+ }
338
+
339
+ if (!grant) {
340
+ throw new Error('Timed out waiting for browser approval');
341
+ }
342
+
343
+ await zendfi.withdrawSubAccountToBank('sa_7b1w9j2k4m8p', {
344
+ amount_usdc: 25,
345
+ bank_id: '9PSB7A2A2LJZ3H6Q4G8XJ6A4',
346
+ account_number: '0123456789',
347
+ mode: 'live',
348
+ automation_token: 'saatk_xxxxx',
349
+ signing_grant: grant,
350
+ });
351
+ ```
297
352
 
298
353
  `withdrawSubAccountToBank` executes PAJ offramp with server-side proxy-email OTP automation (same pattern as split bank withdrawals), so your integration does not need to collect OTP manually.
299
354
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zendfi/sdk",
3
- "version": "1.1.4",
3
+ "version": "1.1.6",
4
4
  "description": "Zero-config TypeScript SDK for ZendFi. Global payments powered by stablecoins!",
5
5
  "main": "./dist/index.js",
6
6
  "module": "./dist/index.mjs",