@cosmosapp/pay_sdk 1.2.0 → 2.0.0

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 (40) hide show
  1. package/CHANGELOG.md +18 -0
  2. package/LICENSE +0 -75
  3. package/NOTICE +8 -0
  4. package/README.md +15 -18
  5. package/dist/chunk-AYVWYEOK.js +62 -0
  6. package/dist/chunk-AYVWYEOK.js.map +1 -0
  7. package/dist/{chunk-TZDZBVFS.js → chunk-TM4HAKWE.js} +5 -3
  8. package/dist/chunk-TM4HAKWE.js.map +1 -0
  9. package/dist/cosmosProvider-CFASjnd5.d.cts +100 -0
  10. package/dist/cosmosProvider-CFASjnd5.d.ts +100 -0
  11. package/dist/index.cjs +739 -3
  12. package/dist/index.cjs.map +1 -1
  13. package/dist/index.d.cts +618 -6
  14. package/dist/index.d.ts +618 -6
  15. package/dist/index.js +731 -5
  16. package/dist/index.js.map +1 -1
  17. package/dist/intent-input-BtUp3tFN.d.cts +1697 -0
  18. package/dist/intent-input-BtUp3tFN.d.ts +1697 -0
  19. package/dist/swk/index.cjs +170 -0
  20. package/dist/swk/index.cjs.map +1 -0
  21. package/dist/swk/index.d.cts +207 -0
  22. package/dist/swk/index.d.ts +207 -0
  23. package/dist/swk/index.js +106 -0
  24. package/dist/swk/index.js.map +1 -0
  25. package/dist/web/index.cjs +129 -2
  26. package/dist/web/index.cjs.map +1 -1
  27. package/dist/web/index.d.cts +49 -4
  28. package/dist/web/index.d.ts +49 -4
  29. package/dist/web/index.js +67 -4
  30. package/dist/web/index.js.map +1 -1
  31. package/llms/03-quickstart.md +4 -4
  32. package/llms/05-payment-intents.md +6 -2
  33. package/llms/08-products-customers.md +1 -1
  34. package/llms/13-types-reference.md +1 -1
  35. package/llms/14-recipes.md +14 -8
  36. package/llms/llms-full.txt +26 -16
  37. package/package.json +17 -6
  38. package/dist/chunk-TZDZBVFS.js.map +0 -1
  39. package/dist/intent-input-Ch8ogEg-.d.cts +0 -750
  40. package/dist/intent-input-Ch8ogEg-.d.ts +0 -750
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { version, DEFAULT_VERSION, DEFAULT_BASE_URL, DEFAULT_TIMEOUT, DEFAULT_RETRIES, Events, CosmosPayAPIError, CosmosPayRequestError, resolveIntentBody, SIGNATURE_HEADER } from './chunk-TZDZBVFS.js';
2
- export { AddressBook, Assets, CosmosPayAPIError, CosmosPayRequestError, DEFAULT_BASE_URL, DEFAULT_RETRIES, DEFAULT_TIMEOUT, DEFAULT_VERSION, Events, SIGNATURE_HEADER, TestnetAssets, Wallets, addresses, assertAddress, defineAsset, isAddress, isContractAddress, isMuxedAddress, isNativeAsset, isStellarAddress, resolveAddress, resolveAsset, resolveIntentBody, version } from './chunk-TZDZBVFS.js';
1
+ import { version, DEFAULT_VERSION, DEFAULT_BASE_URL, DEFAULT_TIMEOUT, DEFAULT_RETRIES, Events, CosmosPayAPIError, CosmosPayRequestError, resolveIntentBody, SIGNATURE_HEADER } from './chunk-TM4HAKWE.js';
2
+ export { AddressBook, Assets, CosmosPayAPIError, CosmosPayRequestError, DEFAULT_BASE_URL, DEFAULT_RETRIES, DEFAULT_TIMEOUT, DEFAULT_VERSION, Events, SIGNATURE_HEADER, TestnetAssets, Wallets, addresses, assertAddress, defineAsset, isAddress, isContractAddress, isMuxedAddress, isNativeAsset, isStellarAddress, resolveAddress, resolveAsset, resolveIntentBody, version } from './chunk-TM4HAKWE.js';
3
3
  import { EventEmitter } from 'events';
4
4
  import { createHmac, timingSafeEqual } from 'crypto';
5
5
 
@@ -59,7 +59,6 @@ var Customer = class extends Base {
59
59
  }
60
60
  _patch(data) {
61
61
  super._patch(data);
62
- this.consumerId = data.consumerId;
63
62
  this.name = data.name;
64
63
  this.alias = data.alias;
65
64
  this.note = data.note;
@@ -89,7 +88,6 @@ var Customer = class extends Base {
89
88
  toJSON() {
90
89
  return {
91
90
  id: this.id,
92
- consumerId: this.consumerId,
93
91
  name: this.name,
94
92
  alias: this.alias,
95
93
  note: this.note,
@@ -223,6 +221,728 @@ var SwapStatus = {
223
221
  Failed: "FAILED",
224
222
  Expired: "EXPIRED"
225
223
  };
224
+ var LiquidityOperationKind = {
225
+ Deposit: "DEPOSIT"};
226
+ var LiquidityOperationStatus = {
227
+ Pending: "PENDING",
228
+ Succeeded: "SUCCEEDED"};
229
+
230
+ // src/structures/LiquidityOperation.ts
231
+ var LiquidityOperation = class extends Base {
232
+ constructor(client, data) {
233
+ super(client, data);
234
+ }
235
+ _patch(data) {
236
+ super._patch(data);
237
+ this.kind = data.kind;
238
+ this.status = data.status;
239
+ this.network = data.network;
240
+ this.source = data.source;
241
+ this.poolId = data.poolId;
242
+ this.assetA = data.assetA;
243
+ this.assetAIssuer = data.assetAIssuer ?? null;
244
+ this.assetB = data.assetB;
245
+ this.assetBIssuer = data.assetBIssuer ?? null;
246
+ this.amountA = data.amountA;
247
+ this.amountB = data.amountB;
248
+ this.shares = data.shares ?? null;
249
+ this.minPrice = data.minPrice ?? null;
250
+ this.maxPrice = data.maxPrice ?? null;
251
+ this.slippageBps = data.slippageBps;
252
+ this.idempotencyKey = data.idempotencyKey ?? null;
253
+ this.feeBps = data.feeBps;
254
+ this.feeAmountA = data.feeAmountA;
255
+ this.feeAmountB = data.feeAmountB;
256
+ this.feeWallet = data.feeWallet ?? null;
257
+ this.commissionMemo = data.commissionMemo ?? null;
258
+ this.xdr = data.xdr;
259
+ this.uri = data.uri;
260
+ this.txHash = data.txHash;
261
+ this.qr = data.qr;
262
+ this.expiresAt = data.expiresAt ? new Date(data.expiresAt) : null;
263
+ this.createdAt = new Date(data.createdAt);
264
+ this.updatedAt = new Date(data.updatedAt);
265
+ return this;
266
+ }
267
+ /** True while the envelope still needs a signature. */
268
+ get isPending() {
269
+ return this.status === LiquidityOperationStatus.Pending;
270
+ }
271
+ /** True once the network accepted it. */
272
+ get isSucceeded() {
273
+ return this.status === LiquidityOperationStatus.Succeeded;
274
+ }
275
+ /** True for a deposit, false for a withdrawal. */
276
+ get isDeposit() {
277
+ return this.kind === LiquidityOperationKind.Deposit;
278
+ }
279
+ /** Re-fetch this operation and patch it in place. */
280
+ async fetch() {
281
+ const data = await this.client.liquidity.fetchRaw(this.id);
282
+ return this._patch(data);
283
+ }
284
+ /** Relay the signed envelope to the network and patch this instance with the result. */
285
+ async submit(options) {
286
+ const outcome = await this.client.liquidity.submit(this.id, options);
287
+ this._patch(outcome.operation.toJSON());
288
+ return outcome;
289
+ }
290
+ toJSON() {
291
+ return {
292
+ id: this.id,
293
+ kind: this.kind,
294
+ status: this.status,
295
+ network: this.network,
296
+ source: this.source,
297
+ poolId: this.poolId,
298
+ assetA: this.assetA,
299
+ assetAIssuer: this.assetAIssuer,
300
+ assetB: this.assetB,
301
+ assetBIssuer: this.assetBIssuer,
302
+ amountA: this.amountA,
303
+ amountB: this.amountB,
304
+ shares: this.shares,
305
+ minPrice: this.minPrice,
306
+ maxPrice: this.maxPrice,
307
+ slippageBps: this.slippageBps,
308
+ idempotencyKey: this.idempotencyKey,
309
+ feeBps: this.feeBps,
310
+ feeAmountA: this.feeAmountA,
311
+ feeAmountB: this.feeAmountB,
312
+ feeWallet: this.feeWallet,
313
+ commissionMemo: this.commissionMemo,
314
+ xdr: this.xdr,
315
+ uri: this.uri,
316
+ txHash: this.txHash,
317
+ qr: this.qr,
318
+ expiresAt: this.expiresAt ? this.expiresAt.toISOString() : null,
319
+ createdAt: this.createdAt.toISOString(),
320
+ updatedAt: this.updatedAt.toISOString()
321
+ };
322
+ }
323
+ };
324
+
325
+ // src/managers/LiquidityManager.ts
326
+ var LiquidityManager = class extends BaseManager {
327
+ constructor() {
328
+ super(...arguments);
329
+ this.route = "/liquidity-pools";
330
+ }
331
+ /**
332
+ * Build a deposit into the pool formed by the two assets → unsigned XDR, SEP-7
333
+ * URI and QR.
334
+ *
335
+ * The pool is DERIVED from the two assets rather than named: a constant-product
336
+ * pool id is a hash of its (assetA, assetB, fee) in CAP-38 order, so there is
337
+ * exactly one pool the pair can form and no id for a caller to get wrong.
338
+ */
339
+ async deposit(options) {
340
+ const { idempotencyKey, ...body } = options;
341
+ const data = await this.rest.post(`${this.route}/deposit`, {
342
+ body: { ...body, ...idempotencyKey ? { idempotencyKey } : {} },
343
+ // Sent as a header too: the service accepts either, and the header is what
344
+ // makes a retried POST safe when the body was already consumed upstream.
345
+ ...idempotencyKey ? { headers: { "Idempotency-Key": idempotencyKey } } : {}
346
+ });
347
+ return this._add(new LiquidityOperation(this.client, data));
348
+ }
349
+ /** Build a withdrawal (burn shares) from a pool → unsigned XDR, SEP-7 URI and QR. */
350
+ async withdraw(options) {
351
+ const { idempotencyKey, ...body } = options;
352
+ const data = await this.rest.post(`${this.route}/withdraw`, {
353
+ body: { ...body, ...idempotencyKey ? { idempotencyKey } : {} },
354
+ ...idempotencyKey ? { headers: { "Idempotency-Key": idempotencyKey } } : {}
355
+ });
356
+ return this._add(new LiquidityOperation(this.client, data));
357
+ }
358
+ /** An account's pool share positions, with what each is redeemable for right now. */
359
+ positions(account) {
360
+ return this.rest.get(`${this.route}/positions`, {
361
+ query: { account }
362
+ });
363
+ }
364
+ /** Browse on-chain pools (Horizon proxy). Filter by asset pair or by holder. */
365
+ async browse(options = {}) {
366
+ const data = await this.rest.get(this.route, {
367
+ query: {
368
+ assetACode: options.assetACode,
369
+ assetAIssuer: options.assetAIssuer,
370
+ assetBCode: options.assetBCode,
371
+ assetBIssuer: options.assetBIssuer,
372
+ account: options.account,
373
+ cursor: options.cursor,
374
+ limit: options.limit
375
+ }
376
+ });
377
+ return { items: data.data, cursor: data.cursor ?? null };
378
+ }
379
+ /** One on-chain pool by its hex id (Horizon proxy). */
380
+ pool(poolId) {
381
+ return this.rest.get(`${this.route}/${poolId}`);
382
+ }
383
+ /** List this consumer's pool operations (paginated). */
384
+ async operations(options = {}) {
385
+ const data = await this.rest.get(`${this.route}/operations`, {
386
+ query: {
387
+ kind: options.kind,
388
+ status: options.status,
389
+ take: options.take,
390
+ skip: options.skip
391
+ }
392
+ });
393
+ return {
394
+ items: data.data.map((d) => this._add(new LiquidityOperation(this.client, d))),
395
+ total: data.total,
396
+ take: data.take,
397
+ skip: data.skip
398
+ };
399
+ }
400
+ /** Get one operation by id, materialized. */
401
+ async fetch(id) {
402
+ return this._add(new LiquidityOperation(this.client, await this.fetchRaw(id)));
403
+ }
404
+ /**
405
+ * The raw payload for one operation. Exists so {@link LiquidityOperation.fetch}
406
+ * can patch itself in place instead of materializing a second instance of the
407
+ * thing the caller is already holding.
408
+ */
409
+ fetchRaw(id) {
410
+ return this.rest.get(`${this.route}/operations/${id}`);
411
+ }
412
+ /**
413
+ * Relay a signed operation to the network. The service checks the envelope's
414
+ * hash against the one it built, so a signed envelope that is not the one this
415
+ * operation describes is refused rather than broadcast.
416
+ */
417
+ async submit(id, options) {
418
+ const data = await this.rest.post(
419
+ `${this.route}/operations/${id}/submit`,
420
+ { body: options }
421
+ );
422
+ return {
423
+ submitted: data.submitted,
424
+ status: data.status,
425
+ txHash: data.txHash ?? null,
426
+ reason: data.reason ?? null,
427
+ resultCodes: data.resultCodes ?? null,
428
+ operation: this._add(new LiquidityOperation(this.client, data.operation))
429
+ };
430
+ }
431
+ };
432
+
433
+ // src/managers/OnrampManager.ts
434
+ var OnrampManager = class {
435
+ constructor(client) {
436
+ this.route = "/onramp";
437
+ this.client = client;
438
+ }
439
+ get rest() {
440
+ return this.client.rest;
441
+ }
442
+ /** Price a payin. The quote expires — check `expires_at` before using it. */
443
+ quote(options) {
444
+ return this.rest.post(`${this.route}/quotes`, { body: options });
445
+ }
446
+ /** Create a payin from a quote. The response carries the funding instructions. */
447
+ createPayin(options) {
448
+ return this.rest.post(`${this.route}/payins`, { body: options });
449
+ }
450
+ /** List this consumer's payins (paginated). */
451
+ async payins(options = {}) {
452
+ const data = await this.rest.get(`${this.route}/payins`, {
453
+ query: { take: options.take, skip: options.skip }
454
+ });
455
+ return { items: data.data, total: data.total, take: data.take, skip: data.skip };
456
+ }
457
+ /**
458
+ * One payin. Served from the local mirror, refreshed from the provider when it
459
+ * is stale — so this is the right call to poll, not the provider's own API.
460
+ */
461
+ payin(id) {
462
+ return this.rest.get(`${this.route}/payins/${id}`);
463
+ }
464
+ /**
465
+ * Build the unsigned trustline transaction an address needs before it can hold
466
+ * the stablecoin the ramp pays out in.
467
+ *
468
+ * The envelope comes from the gateway, so a wallet signing it must decode and
469
+ * bound it first — the issuer it names is the one the payout will use, and it is
470
+ * not known to the caller in advance.
471
+ */
472
+ createTrustline(options) {
473
+ return this.rest.post(`${this.route}/trustline`, { body: options });
474
+ }
475
+ /** Open a virtual account (a permanent bank reference) for a verified receiver. */
476
+ createVirtualAccount(receiverId, options) {
477
+ return this.rest.post(
478
+ `${this.route}/receivers/${receiverId}/virtual-accounts`,
479
+ { body: options }
480
+ );
481
+ }
482
+ /** A receiver's virtual accounts. */
483
+ virtualAccounts(receiverId, options = {}) {
484
+ return this.rest.get(
485
+ `${this.route}/receivers/${receiverId}/virtual-accounts`,
486
+ { query: { take: options.take, skip: options.skip } }
487
+ );
488
+ }
489
+ };
490
+
491
+ // src/managers/OfframpManager.ts
492
+ var OfframpManager = class {
493
+ constructor(client) {
494
+ this.route = "/offramp";
495
+ this.client = client;
496
+ }
497
+ get rest() {
498
+ return this.client.rest;
499
+ }
500
+ /** Price a payout. Expires in about five minutes. */
501
+ quote(options) {
502
+ return this.rest.post(`${this.route}/quotes`, { body: options });
503
+ }
504
+ /**
505
+ * Build the unsigned transfer for a Stellar or Solana payout.
506
+ *
507
+ * What comes back is built by the gateway, not by the caller: bound it against
508
+ * the quote the user confirmed before signing, or the amount that leaves is
509
+ * whatever the response says it is.
510
+ */
511
+ authorize(options) {
512
+ return this.rest.post(`${this.route}/payouts/authorize`, {
513
+ body: options
514
+ });
515
+ }
516
+ /** Create the payout from a quote, with the signed transfer attached. */
517
+ createPayout(options) {
518
+ return this.rest.post(`${this.route}/payouts`, { body: options });
519
+ }
520
+ /** List this consumer's payouts (paginated). */
521
+ async payouts(options = {}) {
522
+ const data = await this.rest.get(`${this.route}/payouts`, {
523
+ query: { take: options.take, skip: options.skip }
524
+ });
525
+ return { items: data.data, total: data.total, take: data.take, skip: data.skip };
526
+ }
527
+ /** One payout. Served from the local mirror, refreshed when stale. */
528
+ payout(id) {
529
+ return this.rest.get(`${this.route}/payouts/${id}`);
530
+ }
531
+ /**
532
+ * Attach a compliance document to a payout — an invoice or proof of funds the
533
+ * rail asks for before it will settle.
534
+ */
535
+ attachDocument(id, options) {
536
+ return this.rest.post(`${this.route}/payouts/${id}/documents`, {
537
+ body: options
538
+ });
539
+ }
540
+ };
541
+
542
+ // src/managers/ActivityManager.ts
543
+ var ActivityManager = class {
544
+ constructor(client) {
545
+ this.route = "/activity";
546
+ this.client = client;
547
+ }
548
+ get rest() {
549
+ return this.client.rest;
550
+ }
551
+ /**
552
+ * Report a batch of events.
553
+ *
554
+ * Accepts the array directly or the full body. Give each event an `eventId`: the
555
+ * service de-duplicates on it, which is the difference between a retried batch
556
+ * and a double-counted one.
557
+ */
558
+ report(events) {
559
+ const body = Array.isArray(events) ? { events } : events;
560
+ return this.rest.post(`${this.route}/events`, { body });
561
+ }
562
+ /** Recent events for this consumer, newest first. */
563
+ async events(options = {}) {
564
+ const data = await this.rest.get(`${this.route}/events`, {
565
+ query: {
566
+ take: options.take,
567
+ skip: options.skip,
568
+ source: options.source,
569
+ level: options.level,
570
+ category: options.category,
571
+ type: options.type,
572
+ network: options.network,
573
+ since: options.since,
574
+ until: options.until
575
+ }
576
+ });
577
+ return { items: data.data, total: data.total, take: data.take, skip: data.skip };
578
+ }
579
+ /** Counts, top event types, top errors and a daily series. */
580
+ summary(options = {}) {
581
+ return this.rest.get(`${this.route}/summary`, {
582
+ query: { days: options.days, source: options.source }
583
+ });
584
+ }
585
+ };
586
+
587
+ // src/structures/Receiver.ts
588
+ var Receiver = class extends Base {
589
+ constructor(client, data) {
590
+ super(client, data);
591
+ }
592
+ _patch(data) {
593
+ super._patch(data);
594
+ this.blindpayId = data.blindpayId;
595
+ this.type = data.type;
596
+ this.kycType = data.kycType ?? null;
597
+ this.kycStatus = data.kycStatus ?? null;
598
+ this.email = data.email ?? null;
599
+ this.name = data.name ?? null;
600
+ this.country = data.country ?? null;
601
+ this.externalId = data.externalId ?? null;
602
+ this.disabled = data.disabled;
603
+ this.dossierVersion = data.dossierVersion;
604
+ this.reviewedVersion = data.reviewedVersion ?? null;
605
+ this.createdAt = new Date(data.createdAt);
606
+ this.updatedAt = new Date(data.updatedAt);
607
+ return this;
608
+ }
609
+ /** True once verification has passed and the ramps will act on this receiver. */
610
+ get isApproved() {
611
+ return this.kycStatus === "approved";
612
+ }
613
+ /** Re-read this receiver, refreshing `kycStatus`, and patch it in place. */
614
+ async fetch() {
615
+ return this._patch(await this.client.kyc.fetchReceiverRaw(this.id));
616
+ }
617
+ /** Update and patch in place. */
618
+ async update(options) {
619
+ const updated = await this.client.kyc.updateReceiver(this.id, options);
620
+ return this._patch(updated.toJSON());
621
+ }
622
+ /** Delete this receiver. */
623
+ delete() {
624
+ return this.client.kyc.deleteReceiver(this.id);
625
+ }
626
+ /**
627
+ * Approve it out of review (admin-only).
628
+ *
629
+ * Pinned to the dossier THIS instance holds: `expected_version` defaults to
630
+ * {@link Receiver.dossierVersion}, so approving a receiver that was edited since
631
+ * you read it is a `409 kyc_state_invalid` rather than a silent approval of data
632
+ * you never saw. Call {@link Receiver.fetch} and review again, or pass
633
+ * `expected_version` yourself — including `undefined`, which approves whatever
634
+ * is stored now.
635
+ */
636
+ approve(options = {}) {
637
+ const pinned = "expected_version" in options ? options : { ...options, expected_version: this.dossierVersion };
638
+ return this.client.kyc.approveReceiver(this.id, pinned);
639
+ }
640
+ /** Ask for a terms-of-service link for this receiver. */
641
+ requestTos(options) {
642
+ return this.client.kyc.requestTos(this.id, options);
643
+ }
644
+ /** Enable it with an accepted terms-of-service id, and patch in place. */
645
+ async enable(options) {
646
+ const enabled = await this.client.kyc.enableReceiver(this.id, options);
647
+ return this._patch(enabled.toJSON());
648
+ }
649
+ /** Cut this receiver off from both ramps, or let it back in. */
650
+ async setAccess(disabled) {
651
+ const updated = await this.client.kyc.setReceiverAccess(this.id, { disabled });
652
+ return this._patch(updated.toJSON());
653
+ }
654
+ /** Register a blockchain wallet for this receiver. */
655
+ addWallet(options) {
656
+ return this.client.kyc.addWallet(this.id, options);
657
+ }
658
+ /** This receiver's wallets. */
659
+ wallets(options = {}) {
660
+ return this.client.kyc.wallets(this.id, options);
661
+ }
662
+ /** Add a fiat bank account — where an off-ramp pays out. */
663
+ addBankAccount(options) {
664
+ return this.client.kyc.addBankAccount(this.id, options);
665
+ }
666
+ /** This receiver's bank accounts. */
667
+ bankAccounts(options = {}) {
668
+ return this.client.kyc.bankAccounts(this.id, options);
669
+ }
670
+ toJSON() {
671
+ return {
672
+ id: this.id,
673
+ blindpayId: this.blindpayId,
674
+ type: this.type,
675
+ kycType: this.kycType,
676
+ kycStatus: this.kycStatus,
677
+ email: this.email,
678
+ name: this.name,
679
+ country: this.country,
680
+ externalId: this.externalId,
681
+ disabled: this.disabled,
682
+ dossierVersion: this.dossierVersion,
683
+ reviewedVersion: this.reviewedVersion,
684
+ createdAt: this.createdAt.toISOString(),
685
+ updatedAt: this.updatedAt.toISOString()
686
+ };
687
+ }
688
+ };
689
+
690
+ // src/managers/KycManager.ts
691
+ var KycManager = class extends BaseManager {
692
+ constructor() {
693
+ super(...arguments);
694
+ this.route = "/kyc";
695
+ }
696
+ /* ----------------------------- receivers ------------------------------- */
697
+ /** Create a receiver and start verification. */
698
+ async createReceiver(options) {
699
+ const data = await this.rest.post(`${this.route}/receivers`, { body: options });
700
+ return this._add(new Receiver(this.client, data));
701
+ }
702
+ /** List this consumer's receivers (paginated). */
703
+ async receivers(options = {}) {
704
+ const data = await this.rest.get(`${this.route}/receivers`, {
705
+ query: { take: options.take, skip: options.skip }
706
+ });
707
+ return {
708
+ items: data.data.map((d) => this._add(new Receiver(this.client, d))),
709
+ total: data.total,
710
+ take: data.take,
711
+ skip: data.skip
712
+ };
713
+ }
714
+ /** One receiver, materialized. Reading it refreshes `kycStatus` upstream. */
715
+ async fetchReceiver(id) {
716
+ return this._add(new Receiver(this.client, await this.fetchReceiverRaw(id)));
717
+ }
718
+ /** The raw payload, so a {@link Receiver} can patch itself in place. */
719
+ fetchReceiverRaw(id) {
720
+ return this.rest.get(`${this.route}/receivers/${id}`);
721
+ }
722
+ /**
723
+ * Update a receiver — the same fields as creation, all optional. Once the receiver
724
+ * exists at the provider, identity fields need an elevated key; see
725
+ * {@link UpdateReceiverOptions}.
726
+ */
727
+ async updateReceiver(id, options) {
728
+ const data = await this.rest.patch(`${this.route}/receivers/${id}`, {
729
+ body: options
730
+ });
731
+ return this._add(new Receiver(this.client, data));
732
+ }
733
+ /** Delete a receiver. */
734
+ async deleteReceiver(id) {
735
+ await this.rest.delete(`${this.route}/receivers/${id}`);
736
+ this.cache.delete(id);
737
+ }
738
+ /**
739
+ * Approve a receiver sitting in review. Admin-only: it is the human gate on a
740
+ * verification the provider could not decide by itself.
741
+ */
742
+ approveReceiver(id, options = {}) {
743
+ return this.rest.post(`${this.route}/receivers/${id}/approve`, { body: options });
744
+ }
745
+ /**
746
+ * Ask for a terms-of-service link for an existing receiver. `channel: 'code'`
747
+ * returns the URL to render; `'email'` sends it to the receiver instead.
748
+ */
749
+ requestTos(id, options) {
750
+ return this.rest.post(`${this.route}/receivers/${id}/tos`, {
751
+ body: options
752
+ });
753
+ }
754
+ /** Enable an inactive receiver with an accepted terms-of-service id. */
755
+ async enableReceiver(id, options) {
756
+ const data = await this.rest.post(`${this.route}/receivers/${id}/enable`, {
757
+ body: options
758
+ });
759
+ return this._add(new Receiver(this.client, data));
760
+ }
761
+ /**
762
+ * Cut a receiver off from both ramps, or let it back in. Admin-only, and the
763
+ * fastest lever there is when something is wrong with an account.
764
+ */
765
+ async setReceiverAccess(id, options) {
766
+ const data = await this.rest.patch(`${this.route}/receivers/${id}/access`, {
767
+ body: options
768
+ });
769
+ return this._add(new Receiver(this.client, data));
770
+ }
771
+ /* ------------------------------ wallets -------------------------------- */
772
+ /**
773
+ * The message a receiver must sign to prove it controls an address. Sign it,
774
+ * then pass the resulting transaction hash as `signature_tx_hash` to
775
+ * {@link addWallet}.
776
+ */
777
+ walletSignMessage(receiverId) {
778
+ return this.rest.get(
779
+ `${this.route}/receivers/${receiverId}/wallets/sign-message`
780
+ );
781
+ }
782
+ /** Register a blockchain wallet for a receiver. */
783
+ addWallet(receiverId, options) {
784
+ return this.rest.post(`${this.route}/receivers/${receiverId}/wallets`, {
785
+ body: options
786
+ });
787
+ }
788
+ /** A receiver's wallets (paginated). */
789
+ async wallets(receiverId, options = {}) {
790
+ const data = await this.rest.get(
791
+ `${this.route}/receivers/${receiverId}/wallets`,
792
+ { query: { take: options.take, skip: options.skip } }
793
+ );
794
+ return { items: data.data, total: data.total, take: data.take, skip: data.skip };
795
+ }
796
+ /** Delete one of a receiver's wallets. */
797
+ async deleteWallet(receiverId, id) {
798
+ await this.rest.delete(`${this.route}/receivers/${receiverId}/wallets/${id}`);
799
+ }
800
+ /* ---------------------------- bank accounts ---------------------------- */
801
+ /** Add a fiat bank account for a receiver — where an off-ramp pays out. */
802
+ addBankAccount(receiverId, options) {
803
+ return this.rest.post(
804
+ `${this.route}/receivers/${receiverId}/bank-accounts`,
805
+ { body: options }
806
+ );
807
+ }
808
+ /** A receiver's bank accounts (paginated). */
809
+ async bankAccounts(receiverId, options = {}) {
810
+ const data = await this.rest.get(
811
+ `${this.route}/receivers/${receiverId}/bank-accounts`,
812
+ { query: { take: options.take, skip: options.skip } }
813
+ );
814
+ return { items: data.data, total: data.total, take: data.take, skip: data.skip };
815
+ }
816
+ /** Delete one of a receiver's bank accounts. */
817
+ async deleteBankAccount(receiverId, id) {
818
+ await this.rest.delete(`${this.route}/receivers/${receiverId}/bank-accounts/${id}`);
819
+ }
820
+ /* ------------------------------ the rest ------------------------------- */
821
+ /**
822
+ * Upload a KYC document and get back the `file_url` every `*_file` field
823
+ * expects. Documents are uploaded first and referenced by URL — the receiver
824
+ * payload never carries bytes.
825
+ */
826
+ upload(file) {
827
+ return this.rest.post(`${this.route}/upload`, { body: file });
828
+ }
829
+ /**
830
+ * Start terms-of-service acceptance and get the hosted URL. This is the FIRST
831
+ * step of the flow: the provider will not create a receiver without the `tos_id`
832
+ * it produces.
833
+ */
834
+ termsOfService(options = {}) {
835
+ return this.rest.post(`${this.route}/terms-of-service`, { body: options });
836
+ }
837
+ /** The bank rails available to this consumer. */
838
+ rails() {
839
+ return this.rest.get(`${this.route}/rails`);
840
+ }
841
+ /**
842
+ * The field schema a given rail requires. The authority on which of the ~70
843
+ * rail-specific bank-account fields to send — read it at runtime rather than
844
+ * hard-coding a rail's shape.
845
+ */
846
+ bankDetails(rail) {
847
+ return this.rest.get(`${this.route}/bank-details`, { query: { rail } });
848
+ }
849
+ get rest() {
850
+ return this.client.rest;
851
+ }
852
+ };
853
+
854
+ // src/managers/PollarManager.ts
855
+ var PollarManager = class {
856
+ constructor(client) {
857
+ this.route = "/pollar";
858
+ this.client = client;
859
+ }
860
+ get rest() {
861
+ return this.client.rest;
862
+ }
863
+ /* -------------------------------- login -------------------------------- */
864
+ /** Start a login and get the URL to send the user to. */
865
+ authorize(options) {
866
+ return this.rest.post(`${this.route}/oauth/authorize`, { body: options });
867
+ }
868
+ /**
869
+ * Poll a login. `status: 'authorized'` carries the bridge `code` to redeem;
870
+ * `pending` means keep waiting; anything else is over.
871
+ */
872
+ session(state) {
873
+ return this.rest.get(`${this.route}/oauth/sessions/${state}`);
874
+ }
875
+ /** Redeem the bridge code for a session. Single use — a consumed code is dead. */
876
+ token(options) {
877
+ return this.rest.post(`${this.route}/oauth/token`, { body: options });
878
+ }
879
+ /**
880
+ * Rotate the token pair. The old refresh token stops working, so store what
881
+ * comes back before using it — a rotation you lose is a session you lose.
882
+ */
883
+ refresh(options) {
884
+ return this.rest.post(`${this.route}/oauth/refresh`, { body: options });
885
+ }
886
+ /** Revoke a session — this device, or every one of them. */
887
+ logout(options) {
888
+ return this.rest.post(`${this.route}/oauth/logout`, { body: options });
889
+ }
890
+ /** Validate an end-user access token and learn whose it is. */
891
+ verifyToken(options) {
892
+ return this.rest.post(`${this.route}/tokens/verify`, {
893
+ body: options
894
+ });
895
+ }
896
+ /* ------------------------------- wallets ------------------------------- */
897
+ /**
898
+ * Fund a wallet's XLM base reserve. A Stellar account does not exist until
899
+ * something pays for it, which is why a fresh Pollar wallet can have an address
900
+ * and still not be on the network.
901
+ */
902
+ activateWallet(options) {
903
+ return this.rest.post(`${this.route}/wallets/activate`, {
904
+ body: options
905
+ });
906
+ }
907
+ /** Enable the application's configured assets on a wallet. */
908
+ addDefaultTrustlines(address) {
909
+ return this.rest.post(
910
+ `${this.route}/wallets/${address}/trustlines/default`
911
+ );
912
+ }
913
+ /** Enable specific assets on a wallet. */
914
+ addTrustlines(address, options) {
915
+ return this.rest.post(`${this.route}/wallets/${address}/trustlines`, {
916
+ body: options
917
+ });
918
+ }
919
+ /**
920
+ * Remove a trustline. An asset is `(code, issuer)`, and both are in the path for
921
+ * that reason: a bare code names no asset.
922
+ */
923
+ removeTrustline(address, code, issuer) {
924
+ return this.rest.delete(
925
+ `${this.route}/wallets/${address}/trustlines/${code}/${issuer}`
926
+ );
927
+ }
928
+ /* -------------------------------- users -------------------------------- */
929
+ /**
930
+ * Register a user with Pollar ahead of their first login. Needs an elevated
931
+ * (admin) key: the Pollar user directory is shared by every tenant, so a tenant
932
+ * key gets `403 elevated_key_required`.
933
+ */
934
+ registerUser(options) {
935
+ return this.rest.post(`${this.route}/users`, { body: options });
936
+ }
937
+ /**
938
+ * Register a user AND provision their Stellar wallet in one call — the variant
939
+ * to use when the user should be able to receive before they ever log in. Needs
940
+ * an elevated (admin) key, like {@link registerUser}.
941
+ */
942
+ registerUserWithWallet(options) {
943
+ return this.rest.post(`${this.route}/users/with-wallet`, { body: options });
944
+ }
945
+ };
226
946
 
227
947
  // src/structures/PaymentIntent.ts
228
948
  var PaymentIntent = class extends Base {
@@ -1240,6 +1960,12 @@ var Client = class extends EventEmitter {
1240
1960
  this.webhooks = new WebhookManager(this);
1241
1961
  this.products = new ProductManager(this);
1242
1962
  this.swaps = new SwapManager(this);
1963
+ this.liquidity = new LiquidityManager(this);
1964
+ this.onramp = new OnrampManager(this);
1965
+ this.offramp = new OfframpManager(this);
1966
+ this.activity = new ActivityManager(this);
1967
+ this.kyc = new KycManager(this);
1968
+ this.pollar = new PollarManager(this);
1243
1969
  this.customers = new CustomerManager(this);
1244
1970
  this.analytics = new AnalyticsManager(this);
1245
1971
  this.health = new HealthManager(this);
@@ -1261,6 +1987,6 @@ var Client = class extends EventEmitter {
1261
1987
  }
1262
1988
  };
1263
1989
 
1264
- export { AnalyticsManager, Base, BaseManager, Client, Customer, CustomerManager, HealthManager, PaymentIntent, PaymentIntentKind, PaymentIntentManager, PaymentIntentStatus, Product, ProductKind, ProductManager, REST, Swap, SwapManager, SwapStatus, WebhookDelivery, WebhookDeliveryStatus, WebhookEndpoint, WebhookEventType, WebhookManager, WebhookSignatureError, Webhooks, resolveShared, shared };
1990
+ export { ActivityManager, AnalyticsManager, Base, BaseManager, Client, Customer, CustomerManager, HealthManager, KycManager, LiquidityManager, LiquidityOperation, OfframpManager, OnrampManager, PaymentIntent, PaymentIntentKind, PaymentIntentManager, PaymentIntentStatus, PollarManager, Product, ProductKind, ProductManager, REST, Receiver, Swap, SwapManager, SwapStatus, WebhookDelivery, WebhookDeliveryStatus, WebhookEndpoint, WebhookEventType, WebhookManager, WebhookSignatureError, Webhooks, resolveShared, shared };
1265
1991
  //# sourceMappingURL=index.js.map
1266
1992
  //# sourceMappingURL=index.js.map