@takeal/cusfront-sdk 0.5.0 → 0.6.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 (49) hide show
  1. package/CHANGELOG.md +10 -2
  2. package/README.md +2 -2
  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/index.cjs +58 -43
  8. package/dist/index.cjs.map +1 -1
  9. package/dist/index.d.cts +2 -2
  10. package/dist/index.d.ts +2 -2
  11. package/dist/index.js +58 -43
  12. package/dist/index.js.map +1 -1
  13. package/dist/react/index.cjs +2 -8
  14. package/dist/react/index.cjs.map +1 -1
  15. package/dist/react/index.js +2 -8
  16. package/dist/react/index.js.map +1 -1
  17. package/dist/resources/attribution.cjs.map +1 -1
  18. package/dist/resources/attribution.js.map +1 -1
  19. package/dist/resources/auth.cjs.map +1 -1
  20. package/dist/resources/auth.js.map +1 -1
  21. package/dist/resources/cards.cjs +11 -22
  22. package/dist/resources/cards.cjs.map +1 -1
  23. package/dist/resources/cards.js +11 -22
  24. package/dist/resources/cards.js.map +1 -1
  25. package/dist/resources/deposits.cjs +4 -4
  26. package/dist/resources/deposits.cjs.map +1 -1
  27. package/dist/resources/deposits.js +4 -4
  28. package/dist/resources/deposits.js.map +1 -1
  29. package/dist/resources/devices.cjs +3 -1
  30. package/dist/resources/devices.cjs.map +1 -1
  31. package/dist/resources/devices.js +3 -1
  32. package/dist/resources/devices.js.map +1 -1
  33. package/dist/resources/documents.cjs +3 -1
  34. package/dist/resources/documents.cjs.map +1 -1
  35. package/dist/resources/documents.js +3 -1
  36. package/dist/resources/documents.js.map +1 -1
  37. package/dist/resources/history.cjs +3 -1
  38. package/dist/resources/history.cjs.map +1 -1
  39. package/dist/resources/history.js +3 -1
  40. package/dist/resources/history.js.map +1 -1
  41. package/dist/resources/push.cjs +3 -1
  42. package/dist/resources/push.cjs.map +1 -1
  43. package/dist/resources/push.js +3 -1
  44. package/dist/resources/push.js.map +1 -1
  45. package/dist/telegram.cjs +33 -46
  46. package/dist/telegram.cjs.map +1 -1
  47. package/dist/telegram.js +33 -46
  48. package/dist/telegram.js.map +1 -1
  49. package/package.json +12 -5
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,10 +465,10 @@ 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
474
  * Freeze the caller's own card. Reversible via {@link unfreeze}. The optional
@@ -483,10 +476,7 @@ var CardsResource = class {
483
476
  * 404 if the card isn't the caller's; 501 if the issuer can't freeze.
484
477
  */
485
478
  async freeze(id, reason) {
486
- return this.http.post(
487
- `/me/cards/${encodeURIComponent(id)}/freeze`,
488
- { body: { reason } }
489
- );
479
+ return this.http.post(`/me/cards/${encodeURIComponent(id)}/freeze`, { body: { reason } });
490
480
  }
491
481
  /**
492
482
  * Reveal the FULL PAN + CVV for the caller's own card. The signed-in
@@ -506,10 +496,7 @@ var CardsResource = class {
506
496
  }
507
497
  /** Unfreeze a previously-frozen card. Idempotent on an already-active card. */
508
498
  async unfreeze(id) {
509
- return this.http.post(
510
- `/me/cards/${encodeURIComponent(id)}/unfreeze`,
511
- { body: {} }
512
- );
499
+ return this.http.post(`/me/cards/${encodeURIComponent(id)}/unfreeze`, { body: {} });
513
500
  }
514
501
  /**
515
502
  * Terminate the caller's own card. **One-way** — a terminated card cannot be
@@ -517,10 +504,9 @@ var CardsResource = class {
517
504
  * already-terminated card.
518
505
  */
519
506
  async terminate(id, reason) {
520
- return this.http.post(
521
- `/me/cards/${encodeURIComponent(id)}/terminate`,
522
- { body: { reason } }
523
- );
507
+ return this.http.post(`/me/cards/${encodeURIComponent(id)}/terminate`, {
508
+ body: { reason }
509
+ });
524
510
  }
525
511
  };
526
512
 
@@ -567,10 +553,10 @@ var DepositsResource = class {
567
553
  */
568
554
  async refund(depositId, input) {
569
555
  const { idempotencyKey, ...body } = input;
570
- return this.http.post(
571
- `/me/deposits/${encodeURIComponent(depositId)}/refunds`,
572
- { body, idempotencyKey }
573
- );
556
+ return this.http.post(`/me/deposits/${encodeURIComponent(depositId)}/refunds`, {
557
+ body,
558
+ idempotencyKey
559
+ });
574
560
  }
575
561
  };
576
562
 
@@ -765,7 +751,9 @@ var DocumentsResource = class {
765
751
  }
766
752
  /** Every saved text of a document, newest first, with the date each took effect. */
767
753
  async versions(slug) {
768
- return this.http.get(`/documents/${encodeURIComponent(slug)}/versions`);
754
+ return this.http.get(
755
+ `/documents/${encodeURIComponent(slug)}/versions`
756
+ );
769
757
  }
770
758
  /** The document as it read in one version. */
771
759
  async version(slug, version) {
@@ -849,7 +837,9 @@ var PushResource = class {
849
837
  async enable(registration) {
850
838
  const { vapid_public_key } = await this.status();
851
839
  if (!vapid_public_key) {
852
- throw new Error("@takeal/cusfront-sdk: push notifications are not enabled on this deployment");
840
+ throw new Error(
841
+ "@takeal/cusfront-sdk: push notifications are not enabled on this deployment"
842
+ );
853
843
  }
854
844
  const sub = await registration.pushManager.subscribe({
855
845
  userVisibleOnly: true,
@@ -991,7 +981,9 @@ var DevicesResource = class {
991
981
  async registerWebPush(registration, opts = {}) {
992
982
  const key = opts.vapidPublicKey ?? await this.vapidPublicKey();
993
983
  if (!key) {
994
- throw new Error("@takeal/cusfront-sdk: push notifications are not enabled on this deployment");
984
+ throw new Error(
985
+ "@takeal/cusfront-sdk: push notifications are not enabled on this deployment"
986
+ );
995
987
  }
996
988
  const sub = await registration.pushManager.subscribe({
997
989
  userVisibleOnly: true,
@@ -1068,7 +1060,9 @@ var HistoryResource = class {
1068
1060
  if (params.limit !== void 0) q.set("limit", String(params.limit));
1069
1061
  if (params.lang) q.set("lang", params.lang);
1070
1062
  const qs = q.toString();
1071
- return this.http.get(`/me/history${qs ? `?${qs}` : ""}`, { signal: params.signal });
1063
+ return this.http.get(`/me/history${qs ? `?${qs}` : ""}`, {
1064
+ signal: params.signal
1065
+ });
1072
1066
  }
1073
1067
  /** Every entry, page after page, newest first. */
1074
1068
  async *all(params = {}) {
@@ -1093,7 +1087,7 @@ var FundingOptionsResource = class {
1093
1087
  };
1094
1088
 
1095
1089
  // src/version.ts
1096
- var SDK_VERSION = "0.5.0";
1090
+ var SDK_VERSION = "0.6.0";
1097
1091
 
1098
1092
  // src/client-platform.ts
1099
1093
  var CLIENT_HEADER = "X-Takeal-Client";
@@ -1168,7 +1162,7 @@ function isAbsolute(url) {
1168
1162
  }
1169
1163
 
1170
1164
  // src/compat.ts
1171
- var SUPPORTED_MEISTER = ">=0.5.0, <0.6.0";
1165
+ var SUPPORTED_MEISTER = ">=0.5.0, <0.7.0";
1172
1166
  var SEMVER = /^v?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/;
1173
1167
  function parse(v) {
1174
1168
  const m = SEMVER.exec(v.trim());
@@ -1329,18 +1323,11 @@ function parseInitData(initData) {
1329
1323
  function assertWellFormed(initData, opts = {}) {
1330
1324
  if (!initData) throw new InitDataError("initData is empty", "empty");
1331
1325
  const parsed = parseInitData(initData);
1332
- if (!parsed.hash)
1333
- throw new InitDataError("initData is missing `hash`", "missing_hash");
1326
+ if (!parsed.hash) throw new InitDataError("initData is missing `hash`", "missing_hash");
1334
1327
  if (parsed.auth_date === void 0)
1335
- throw new InitDataError(
1336
- "initData is missing a valid `auth_date`",
1337
- "missing_auth_date"
1338
- );
1328
+ throw new InitDataError("initData is missing a valid `auth_date`", "missing_auth_date");
1339
1329
  if (!parsed.user || typeof parsed.user.id !== "number")
1340
- throw new InitDataError(
1341
- "initData is missing a valid `user`",
1342
- "bad_user"
1343
- );
1330
+ throw new InitDataError("initData is missing a valid `user`", "bad_user");
1344
1331
  const maxAge = opts.maxAgeSeconds ?? 86400;
1345
1332
  if (maxAge > 0) {
1346
1333
  const now = opts.nowUnix ?? Math.floor(Date.now() / 1e3);