@takeal/cusfront-sdk 0.5.0 → 0.6.1

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 (65) hide show
  1. package/CHANGELOG.md +49 -2
  2. package/README.md +168 -3
  3. package/dist/analytics.cjs +28 -7
  4. package/dist/analytics.cjs.map +1 -1
  5. package/dist/analytics.js +28 -7
  6. package/dist/analytics.js.map +1 -1
  7. package/dist/{cards-Ba1wZttb.d.ts → cards-CF3-He2x.d.ts} +144 -20
  8. package/dist/{cards-B_aNY35J.d.cts → cards-qfHz6xZY.d.cts} +144 -20
  9. package/dist/{deposits-DScyT_D9.d.ts → deposits-B2LBe2k1.d.ts} +71 -8
  10. package/dist/{deposits-BEc8U80M.d.cts → deposits-ZjT_btgi.d.cts} +71 -8
  11. package/dist/index.cjs +92 -50
  12. package/dist/index.cjs.map +1 -1
  13. package/dist/index.d.cts +6 -6
  14. package/dist/index.d.ts +6 -6
  15. package/dist/index.js +92 -50
  16. package/dist/index.js.map +1 -1
  17. package/dist/react/index.cjs +2 -8
  18. package/dist/react/index.cjs.map +1 -1
  19. package/dist/react/index.d.cts +2 -2
  20. package/dist/react/index.d.ts +2 -2
  21. package/dist/react/index.js +2 -8
  22. package/dist/react/index.js.map +1 -1
  23. package/dist/resources/attribution.cjs.map +1 -1
  24. package/dist/resources/attribution.js.map +1 -1
  25. package/dist/resources/auth.cjs.map +1 -1
  26. package/dist/resources/auth.js.map +1 -1
  27. package/dist/resources/cards.cjs +41 -28
  28. package/dist/resources/cards.cjs.map +1 -1
  29. package/dist/resources/cards.d.cts +1 -1
  30. package/dist/resources/cards.d.ts +1 -1
  31. package/dist/resources/cards.js +41 -28
  32. package/dist/resources/cards.js.map +1 -1
  33. package/dist/resources/deposits.cjs +8 -5
  34. package/dist/resources/deposits.cjs.map +1 -1
  35. package/dist/resources/deposits.d.cts +2 -2
  36. package/dist/resources/deposits.d.ts +2 -2
  37. package/dist/resources/deposits.js +8 -5
  38. package/dist/resources/deposits.js.map +1 -1
  39. package/dist/resources/devices.cjs +3 -1
  40. package/dist/resources/devices.cjs.map +1 -1
  41. package/dist/resources/devices.js +3 -1
  42. package/dist/resources/devices.js.map +1 -1
  43. package/dist/resources/documents.cjs +3 -1
  44. package/dist/resources/documents.cjs.map +1 -1
  45. package/dist/resources/documents.js +3 -1
  46. package/dist/resources/documents.js.map +1 -1
  47. package/dist/resources/funding-options.cjs.map +1 -1
  48. package/dist/resources/funding-options.d.cts +2 -2
  49. package/dist/resources/funding-options.d.ts +2 -2
  50. package/dist/resources/funding-options.js.map +1 -1
  51. package/dist/resources/history.cjs +3 -1
  52. package/dist/resources/history.cjs.map +1 -1
  53. package/dist/resources/history.js +3 -1
  54. package/dist/resources/history.js.map +1 -1
  55. package/dist/resources/push.cjs +3 -1
  56. package/dist/resources/push.cjs.map +1 -1
  57. package/dist/resources/push.js +3 -1
  58. package/dist/resources/push.js.map +1 -1
  59. package/dist/telegram.cjs +67 -53
  60. package/dist/telegram.cjs.map +1 -1
  61. package/dist/telegram.d.cts +2 -2
  62. package/dist/telegram.d.ts +2 -2
  63. package/dist/telegram.js +67 -53
  64. package/dist/telegram.js.map +1 -1
  65. package/package.json +12 -5
@@ -1,8 +1,8 @@
1
1
  import { CusfrontClient, CreateClientOptions } from './index.cjs';
2
2
  import { JwtIssued, TelegramUnknown } from './resources/auth.cjs';
3
3
  import './http-DeANAoTs.cjs';
4
- import './deposits-BEc8U80M.cjs';
5
- import './cards-B_aNY35J.cjs';
4
+ import './deposits-ZjT_btgi.cjs';
5
+ import './cards-qfHz6xZY.cjs';
6
6
  import './resources/balance.cjs';
7
7
  import './resources/bonus.cjs';
8
8
  import './resources/codes.cjs';
@@ -1,8 +1,8 @@
1
1
  import { CusfrontClient, CreateClientOptions } from './index.js';
2
2
  import { JwtIssued, TelegramUnknown } from './resources/auth.js';
3
3
  import './http-DeANAoTs.js';
4
- import './deposits-DScyT_D9.js';
5
- import './cards-Ba1wZttb.js';
4
+ import './deposits-B2LBe2k1.js';
5
+ import './cards-CF3-He2x.js';
6
6
  import './resources/balance.js';
7
7
  import './resources/bonus.js';
8
8
  import './resources/codes.js';
package/dist/telegram.js CHANGED
@@ -93,10 +93,7 @@ var HttpClient = class {
93
93
  try {
94
94
  resp = await this.fetchImpl(url, init);
95
95
  } catch (e) {
96
- throw new NetworkError(
97
- e instanceof Error ? e.message : "network error",
98
- e
99
- );
96
+ throw new NetworkError(e instanceof Error ? e.message : "network error", e);
100
97
  }
101
98
  if (resp.status === 401 && !opts.skipAuth && !opts.retried && this.refresher) {
102
99
  if (await this.refreshOnce()) {
@@ -388,9 +385,7 @@ var CardsResource = class {
388
385
  }
389
386
  /** One product from the catalog. 404 when unknown, disabled or hidden. */
390
387
  async getProduct(id) {
391
- return this.http.get(
392
- `/me/card-products/${encodeURIComponent(id)}`
393
- );
388
+ return this.http.get(`/me/card-products/${encodeURIComponent(id)}`);
394
389
  }
395
390
  /**
396
391
  * The public catalog: the same products, order and default as
@@ -429,9 +424,7 @@ var CardsResource = class {
429
424
  */
430
425
  async balance(id, currency) {
431
426
  const q = new URLSearchParams({ currency }).toString();
432
- return this.http.get(
433
- `/me/cards/${encodeURIComponent(id)}/balance?${q}`
434
- );
427
+ return this.http.get(`/me/cards/${encodeURIComponent(id)}/balance?${q}`);
435
428
  }
436
429
  /**
437
430
  * What a top-up of this card can be right now: whether it is possible, the
@@ -472,21 +465,20 @@ var CardsResource = class {
472
465
  */
473
466
  async transfer(fromCardId, input) {
474
467
  const { toCardId, amount, idempotencyKey } = input;
475
- return this.http.post(
476
- `/me/cards/${encodeURIComponent(fromCardId)}/transfer`,
477
- { body: { to_card_id: toCardId, amount }, idempotencyKey }
478
- );
468
+ return this.http.post(`/me/cards/${encodeURIComponent(fromCardId)}/transfer`, {
469
+ body: { to_card_id: toCardId, amount },
470
+ idempotencyKey
471
+ });
479
472
  }
480
473
  /**
481
- * Freeze the caller's own card. Reversible via {@link unfreeze}. The optional
482
- * `reason` is recorded on the audit trail. Resolves to the updated card.
483
- * 404 if the card isn't the caller's; 501 if the issuer can't freeze.
474
+ * Freeze the caller's own card. Reversible via {@link unfreeze} while
475
+ * `status_source` is `holder` or `operator`. The optional `reason` is
476
+ * recorded on the audit trail. Resolves to the updated card. 404 if the
477
+ * card isn't the caller's; 409 `card_locked` when support holds it; 501 if
478
+ * the issuer can't freeze.
484
479
  */
485
480
  async freeze(id, reason) {
486
- return this.http.post(
487
- `/me/cards/${encodeURIComponent(id)}/freeze`,
488
- { body: { reason } }
489
- );
481
+ return this.http.post(`/me/cards/${encodeURIComponent(id)}/freeze`, { body: { reason } });
490
482
  }
491
483
  /**
492
484
  * Reveal the FULL PAN + CVV for the caller's own card. The signed-in
@@ -498,18 +490,37 @@ var CardsResource = class {
498
490
  * keep the result in volatile memory only, never write it to
499
491
  * localStorage / logs, and clear it within `expires_in_seconds`.
500
492
  *
501
- * 401 bad re-auth · 403 not your card · 429 rate-limited · 501 connector
502
- * has no sensitive-data endpoint · 503 provider error.
493
+ * The result is the numbers, or `reveal_url` with empty `pan` and `cvv`
494
+ * when the issuer shows them on a page of its own: open that page in a
495
+ * frame right away, it is short-lived.
496
+ *
497
+ * 403 not your card · 409 `card_locked` · 429 rate-limited · 501 connector
498
+ * has no sensitive-data endpoint · 503 `provider_unavailable`.
503
499
  */
504
500
  async reveal(id, _input) {
505
501
  return this.http.post(`/me/cards/${encodeURIComponent(id)}/reveal`);
506
502
  }
507
- /** Unfreeze a previously-frozen card. Idempotent on an already-active card. */
503
+ /**
504
+ * Unfreeze a previously-frozen card. Idempotent on an already-active card.
505
+ * A card the issuer froze (`status_source: "provider"`) is not the
506
+ * holder's to unfreeze: the API answers 409 `card_locked`, so hide the
507
+ * button and say the freeze is lifted through the issuer's support.
508
+ */
508
509
  async unfreeze(id) {
509
- return this.http.post(
510
- `/me/cards/${encodeURIComponent(id)}/unfreeze`,
511
- { body: {} }
512
- );
510
+ return this.http.post(`/me/cards/${encodeURIComponent(id)}/unfreeze`, { body: {} });
511
+ }
512
+ /**
513
+ * Set the PIN of the caller's own physical card. The session is enough; the
514
+ * call is rate-limited like {@link reveal} and the PIN is kept nowhere.
515
+ * Resolves to the card; the user also gets a notification that the PIN
516
+ * was set. 400 not four to six digits or the card is not active · 403 not
517
+ * your card · 409 `card_locked`, or `provider_refused` when the issuer did
518
+ * not take it · 429 too many attempts · 501 a virtual card has no PIN.
519
+ */
520
+ async setPin(id, input) {
521
+ return this.http.post(`/me/cards/${encodeURIComponent(id)}/pin`, {
522
+ body: { pin: input.pin }
523
+ });
513
524
  }
514
525
  /**
515
526
  * Terminate the caller's own card. **One-way** — a terminated card cannot be
@@ -517,10 +528,9 @@ var CardsResource = class {
517
528
  * already-terminated card.
518
529
  */
519
530
  async terminate(id, reason) {
520
- return this.http.post(
521
- `/me/cards/${encodeURIComponent(id)}/terminate`,
522
- { body: { reason } }
523
- );
531
+ return this.http.post(`/me/cards/${encodeURIComponent(id)}/terminate`, {
532
+ body: { reason }
533
+ });
524
534
  }
525
535
  };
526
536
 
@@ -541,7 +551,10 @@ var DepositsResource = class {
541
551
  * API answers 400 `no_quote_needed`).
542
552
  */
543
553
  async quote(input) {
544
- return this.http.post("/me/deposits/quotes", { body: input });
554
+ const { connectorSlug, ...rest } = input;
555
+ const body = { ...rest };
556
+ if (connectorSlug !== void 0) body["connector_slug"] = connectorSlug;
557
+ return this.http.post("/me/deposits/quotes", { body });
545
558
  }
546
559
  async initiate(input) {
547
560
  const { idempotencyKey, issue_card, ...rest } = input;
@@ -567,10 +580,10 @@ var DepositsResource = class {
567
580
  */
568
581
  async refund(depositId, input) {
569
582
  const { idempotencyKey, ...body } = input;
570
- return this.http.post(
571
- `/me/deposits/${encodeURIComponent(depositId)}/refunds`,
572
- { body, idempotencyKey }
573
- );
583
+ return this.http.post(`/me/deposits/${encodeURIComponent(depositId)}/refunds`, {
584
+ body,
585
+ idempotencyKey
586
+ });
574
587
  }
575
588
  };
576
589
 
@@ -765,7 +778,9 @@ var DocumentsResource = class {
765
778
  }
766
779
  /** Every saved text of a document, newest first, with the date each took effect. */
767
780
  async versions(slug) {
768
- return this.http.get(`/documents/${encodeURIComponent(slug)}/versions`);
781
+ return this.http.get(
782
+ `/documents/${encodeURIComponent(slug)}/versions`
783
+ );
769
784
  }
770
785
  /** The document as it read in one version. */
771
786
  async version(slug, version) {
@@ -849,7 +864,9 @@ var PushResource = class {
849
864
  async enable(registration) {
850
865
  const { vapid_public_key } = await this.status();
851
866
  if (!vapid_public_key) {
852
- throw new Error("@takeal/cusfront-sdk: push notifications are not enabled on this deployment");
867
+ throw new Error(
868
+ "@takeal/cusfront-sdk: push notifications are not enabled on this deployment"
869
+ );
853
870
  }
854
871
  const sub = await registration.pushManager.subscribe({
855
872
  userVisibleOnly: true,
@@ -991,7 +1008,9 @@ var DevicesResource = class {
991
1008
  async registerWebPush(registration, opts = {}) {
992
1009
  const key = opts.vapidPublicKey ?? await this.vapidPublicKey();
993
1010
  if (!key) {
994
- throw new Error("@takeal/cusfront-sdk: push notifications are not enabled on this deployment");
1011
+ throw new Error(
1012
+ "@takeal/cusfront-sdk: push notifications are not enabled on this deployment"
1013
+ );
995
1014
  }
996
1015
  const sub = await registration.pushManager.subscribe({
997
1016
  userVisibleOnly: true,
@@ -1068,7 +1087,9 @@ var HistoryResource = class {
1068
1087
  if (params.limit !== void 0) q.set("limit", String(params.limit));
1069
1088
  if (params.lang) q.set("lang", params.lang);
1070
1089
  const qs = q.toString();
1071
- return this.http.get(`/me/history${qs ? `?${qs}` : ""}`, { signal: params.signal });
1090
+ return this.http.get(`/me/history${qs ? `?${qs}` : ""}`, {
1091
+ signal: params.signal
1092
+ });
1072
1093
  }
1073
1094
  /** Every entry, page after page, newest first. */
1074
1095
  async *all(params = {}) {
@@ -1093,7 +1114,7 @@ var FundingOptionsResource = class {
1093
1114
  };
1094
1115
 
1095
1116
  // src/version.ts
1096
- var SDK_VERSION = "0.5.0";
1117
+ var SDK_VERSION = "0.6.1";
1097
1118
 
1098
1119
  // src/client-platform.ts
1099
1120
  var CLIENT_HEADER = "X-Takeal-Client";
@@ -1168,7 +1189,7 @@ function isAbsolute(url) {
1168
1189
  }
1169
1190
 
1170
1191
  // src/compat.ts
1171
- var SUPPORTED_MEISTER = ">=0.5.0, <0.6.0";
1192
+ var SUPPORTED_MEISTER = ">=0.6.4, <0.7.0";
1172
1193
  var SEMVER = /^v?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/;
1173
1194
  function parse(v) {
1174
1195
  const m = SEMVER.exec(v.trim());
@@ -1329,18 +1350,11 @@ function parseInitData(initData) {
1329
1350
  function assertWellFormed(initData, opts = {}) {
1330
1351
  if (!initData) throw new InitDataError("initData is empty", "empty");
1331
1352
  const parsed = parseInitData(initData);
1332
- if (!parsed.hash)
1333
- throw new InitDataError("initData is missing `hash`", "missing_hash");
1353
+ if (!parsed.hash) throw new InitDataError("initData is missing `hash`", "missing_hash");
1334
1354
  if (parsed.auth_date === void 0)
1335
- throw new InitDataError(
1336
- "initData is missing a valid `auth_date`",
1337
- "missing_auth_date"
1338
- );
1355
+ throw new InitDataError("initData is missing a valid `auth_date`", "missing_auth_date");
1339
1356
  if (!parsed.user || typeof parsed.user.id !== "number")
1340
- throw new InitDataError(
1341
- "initData is missing a valid `user`",
1342
- "bad_user"
1343
- );
1357
+ throw new InitDataError("initData is missing a valid `user`", "bad_user");
1344
1358
  const maxAge = opts.maxAgeSeconds ?? 86400;
1345
1359
  if (maxAge > 0) {
1346
1360
  const now = opts.nowUnix ?? Math.floor(Date.now() / 1e3);