@zendfi/sdk 1.1.5 → 1.1.7
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 +51 -0
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -301,6 +301,57 @@ For `withdrawFromSubAccount` and `withdrawSubAccountToBank`, the recommended hea
|
|
|
301
301
|
|
|
302
302
|
Legacy direct mint (`createSubAccountSigningGrant` with `passkey_signature`) remains available as fallback.
|
|
303
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: 'GTB',
|
|
346
|
+
account_number: '0123456789',
|
|
347
|
+
mode: 'live',
|
|
348
|
+
automation_token: 'saatk_xxxxx',
|
|
349
|
+
signing_grant: grant,
|
|
350
|
+
});
|
|
351
|
+
```
|
|
352
|
+
|
|
353
|
+
`bank_id` accepts PAJ bank id, bank code, or bank name.
|
|
354
|
+
|
|
304
355
|
`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.
|
|
305
356
|
|
|
306
357
|
`passkey_signature` on `withdrawFromSubAccount` and `withdrawSubAccountToBank` is now optional and should be treated as interactive fallback.
|