@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/index.d.cts CHANGED
@@ -71,7 +71,7 @@ interface BrandConfig {
71
71
  * Which platform versions this SDK works with, as a semver range:
72
72
  * comparators separated by ", ". Keep this the only definition.
73
73
  */
74
- declare const SUPPORTED_MEISTER = ">=0.5.0, <0.6.0";
74
+ declare const SUPPORTED_MEISTER = ">=0.5.0, <0.7.0";
75
75
  /** What `client.ready()` returns. */
76
76
  interface ReadyInfo {
77
77
  /** `true` when the platform reported a version inside `supportedMeister`. */
@@ -177,7 +177,7 @@ declare function isNetworkError(e: unknown): e is NetworkError;
177
177
  * `define`. `src/version.test.ts` checks it matches `package.json`, so a
178
178
  * release bump that forgets this file fails the test run.
179
179
  */
180
- declare const SDK_VERSION = "0.5.0";
180
+ declare const SDK_VERSION = "0.6.0";
181
181
 
182
182
  /**
183
183
  * `@takeal/cusfront-sdk` — typed client for the Takeal end-user API.
package/dist/index.d.ts CHANGED
@@ -71,7 +71,7 @@ interface BrandConfig {
71
71
  * Which platform versions this SDK works with, as a semver range:
72
72
  * comparators separated by ", ". Keep this the only definition.
73
73
  */
74
- declare const SUPPORTED_MEISTER = ">=0.5.0, <0.6.0";
74
+ declare const SUPPORTED_MEISTER = ">=0.5.0, <0.7.0";
75
75
  /** What `client.ready()` returns. */
76
76
  interface ReadyInfo {
77
77
  /** `true` when the platform reported a version inside `supportedMeister`. */
@@ -177,7 +177,7 @@ declare function isNetworkError(e: unknown): e is NetworkError;
177
177
  * `define`. `src/version.test.ts` checks it matches `package.json`, so a
178
178
  * release bump that forgets this file fails the test run.
179
179
  */
180
- declare const SDK_VERSION = "0.5.0";
180
+ declare const SDK_VERSION = "0.6.0";
181
181
 
182
182
  /**
183
183
  * `@takeal/cusfront-sdk` — typed client for the Takeal end-user API.
package/dist/index.js CHANGED
@@ -96,10 +96,7 @@ var HttpClient = class {
96
96
  try {
97
97
  resp = await this.fetchImpl(url, init);
98
98
  } catch (e) {
99
- throw new NetworkError(
100
- e instanceof Error ? e.message : "network error",
101
- e
102
- );
99
+ throw new NetworkError(e instanceof Error ? e.message : "network error", e);
103
100
  }
104
101
  if (resp.status === 401 && !opts.skipAuth && !opts.retried && this.refresher) {
105
102
  if (await this.refreshOnce()) {
@@ -391,9 +388,7 @@ var CardsResource = class {
391
388
  }
392
389
  /** One product from the catalog. 404 when unknown, disabled or hidden. */
393
390
  async getProduct(id) {
394
- return this.http.get(
395
- `/me/card-products/${encodeURIComponent(id)}`
396
- );
391
+ return this.http.get(`/me/card-products/${encodeURIComponent(id)}`);
397
392
  }
398
393
  /**
399
394
  * The public catalog: the same products, order and default as
@@ -432,9 +427,7 @@ var CardsResource = class {
432
427
  */
433
428
  async balance(id, currency) {
434
429
  const q = new URLSearchParams({ currency }).toString();
435
- return this.http.get(
436
- `/me/cards/${encodeURIComponent(id)}/balance?${q}`
437
- );
430
+ return this.http.get(`/me/cards/${encodeURIComponent(id)}/balance?${q}`);
438
431
  }
439
432
  /**
440
433
  * What a top-up of this card can be right now: whether it is possible, the
@@ -475,10 +468,10 @@ var CardsResource = class {
475
468
  */
476
469
  async transfer(fromCardId, input) {
477
470
  const { toCardId, amount, idempotencyKey } = input;
478
- return this.http.post(
479
- `/me/cards/${encodeURIComponent(fromCardId)}/transfer`,
480
- { body: { to_card_id: toCardId, amount }, idempotencyKey }
481
- );
471
+ return this.http.post(`/me/cards/${encodeURIComponent(fromCardId)}/transfer`, {
472
+ body: { to_card_id: toCardId, amount },
473
+ idempotencyKey
474
+ });
482
475
  }
483
476
  /**
484
477
  * Freeze the caller's own card. Reversible via {@link unfreeze}. The optional
@@ -486,10 +479,7 @@ var CardsResource = class {
486
479
  * 404 if the card isn't the caller's; 501 if the issuer can't freeze.
487
480
  */
488
481
  async freeze(id, reason) {
489
- return this.http.post(
490
- `/me/cards/${encodeURIComponent(id)}/freeze`,
491
- { body: { reason } }
492
- );
482
+ return this.http.post(`/me/cards/${encodeURIComponent(id)}/freeze`, { body: { reason } });
493
483
  }
494
484
  /**
495
485
  * Reveal the FULL PAN + CVV for the caller's own card. The signed-in
@@ -509,10 +499,7 @@ var CardsResource = class {
509
499
  }
510
500
  /** Unfreeze a previously-frozen card. Idempotent on an already-active card. */
511
501
  async unfreeze(id) {
512
- return this.http.post(
513
- `/me/cards/${encodeURIComponent(id)}/unfreeze`,
514
- { body: {} }
515
- );
502
+ return this.http.post(`/me/cards/${encodeURIComponent(id)}/unfreeze`, { body: {} });
516
503
  }
517
504
  /**
518
505
  * Terminate the caller's own card. **One-way** — a terminated card cannot be
@@ -520,10 +507,9 @@ var CardsResource = class {
520
507
  * already-terminated card.
521
508
  */
522
509
  async terminate(id, reason) {
523
- return this.http.post(
524
- `/me/cards/${encodeURIComponent(id)}/terminate`,
525
- { body: { reason } }
526
- );
510
+ return this.http.post(`/me/cards/${encodeURIComponent(id)}/terminate`, {
511
+ body: { reason }
512
+ });
527
513
  }
528
514
  };
529
515
 
@@ -570,10 +556,10 @@ var DepositsResource = class {
570
556
  */
571
557
  async refund(depositId, input) {
572
558
  const { idempotencyKey, ...body } = input;
573
- return this.http.post(
574
- `/me/deposits/${encodeURIComponent(depositId)}/refunds`,
575
- { body, idempotencyKey }
576
- );
559
+ return this.http.post(`/me/deposits/${encodeURIComponent(depositId)}/refunds`, {
560
+ body,
561
+ idempotencyKey
562
+ });
577
563
  }
578
564
  };
579
565
 
@@ -768,7 +754,9 @@ var DocumentsResource = class {
768
754
  }
769
755
  /** Every saved text of a document, newest first, with the date each took effect. */
770
756
  async versions(slug) {
771
- return this.http.get(`/documents/${encodeURIComponent(slug)}/versions`);
757
+ return this.http.get(
758
+ `/documents/${encodeURIComponent(slug)}/versions`
759
+ );
772
760
  }
773
761
  /** The document as it read in one version. */
774
762
  async version(slug, version) {
@@ -852,7 +840,9 @@ var PushResource = class {
852
840
  async enable(registration) {
853
841
  const { vapid_public_key } = await this.status();
854
842
  if (!vapid_public_key) {
855
- throw new Error("@takeal/cusfront-sdk: push notifications are not enabled on this deployment");
843
+ throw new Error(
844
+ "@takeal/cusfront-sdk: push notifications are not enabled on this deployment"
845
+ );
856
846
  }
857
847
  const sub = await registration.pushManager.subscribe({
858
848
  userVisibleOnly: true,
@@ -997,7 +987,9 @@ var DevicesResource = class {
997
987
  async registerWebPush(registration, opts = {}) {
998
988
  const key = opts.vapidPublicKey ?? await this.vapidPublicKey();
999
989
  if (!key) {
1000
- throw new Error("@takeal/cusfront-sdk: push notifications are not enabled on this deployment");
990
+ throw new Error(
991
+ "@takeal/cusfront-sdk: push notifications are not enabled on this deployment"
992
+ );
1001
993
  }
1002
994
  const sub = await registration.pushManager.subscribe({
1003
995
  userVisibleOnly: true,
@@ -1126,7 +1118,9 @@ var HistoryResource = class {
1126
1118
  if (params.limit !== void 0) q.set("limit", String(params.limit));
1127
1119
  if (params.lang) q.set("lang", params.lang);
1128
1120
  const qs = q.toString();
1129
- return this.http.get(`/me/history${qs ? `?${qs}` : ""}`, { signal: params.signal });
1121
+ return this.http.get(`/me/history${qs ? `?${qs}` : ""}`, {
1122
+ signal: params.signal
1123
+ });
1130
1124
  }
1131
1125
  /** Every entry, page after page, newest first. */
1132
1126
  async *all(params = {}) {
@@ -1151,7 +1145,7 @@ var FundingOptionsResource = class {
1151
1145
  };
1152
1146
 
1153
1147
  // src/version.ts
1154
- var SDK_VERSION = "0.5.0";
1148
+ var SDK_VERSION = "0.6.0";
1155
1149
 
1156
1150
  // src/client-platform.ts
1157
1151
  var CLIENT_HEADER = "X-Takeal-Client";
@@ -1226,7 +1220,7 @@ function isAbsolute(url) {
1226
1220
  }
1227
1221
 
1228
1222
  // src/compat.ts
1229
- var SUPPORTED_MEISTER = ">=0.5.0, <0.6.0";
1223
+ var SUPPORTED_MEISTER = ">=0.5.0, <0.7.0";
1230
1224
  var SEMVER = /^v?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/;
1231
1225
  function parse(v) {
1232
1226
  const m = SEMVER.exec(v.trim());
@@ -1391,7 +1385,15 @@ var SECRET_QUERY_WORDS = /* @__PURE__ */ new Set([
1391
1385
  "cvc",
1392
1386
  "iban"
1393
1387
  ]);
1394
- var MONEY_KEYS = /* @__PURE__ */ new Set(["amount", "amount_minor", "currency", "value", "price", "revenue", "sum"]);
1388
+ var MONEY_KEYS = /* @__PURE__ */ new Set([
1389
+ "amount",
1390
+ "amount_minor",
1391
+ "currency",
1392
+ "value",
1393
+ "price",
1394
+ "revenue",
1395
+ "sum"
1396
+ ]);
1395
1397
  function words(key) {
1396
1398
  return key.replace(/^\$+/, "").replace(/([a-z])([A-Z])/g, "$1_$2").toLowerCase().split(/[^a-z0-9]+/).filter(Boolean);
1397
1399
  }
@@ -1401,7 +1403,9 @@ function personalKey(key) {
1401
1403
  if (joined.includes("email") || joined.includes("phone")) return true;
1402
1404
  if (w.some((x) => PERSONAL_WORDS.has(x)) || PERSONAL_WORDS.has(joined)) return true;
1403
1405
  if (key.startsWith("$")) return false;
1404
- return w.some((x, i) => x === "name" && (w.length === 1 || PERSON_NAME_QUALIFIERS.has(w[i - 1] ?? "")));
1406
+ return w.some(
1407
+ (x, i) => x === "name" && (w.length === 1 || PERSON_NAME_QUALIFIERS.has(w[i - 1] ?? ""))
1408
+ );
1405
1409
  }
1406
1410
  function urlKey(key) {
1407
1411
  const k = key.replace(/^\$+/, "").toLowerCase();
@@ -1438,7 +1442,9 @@ function sanitizeUrl(raw) {
1438
1442
  const k = words(key);
1439
1443
  if (k.some((w) => SECRET_QUERY_WORDS.has(w)) || personalKey(key)) return;
1440
1444
  if (redactText(value) !== value) return;
1441
- query.push(`${encodeURIComponent(key)}=${isId(value) ? PLACEHOLDER : encodeURIComponent(value)}`);
1445
+ query.push(
1446
+ `${encodeURIComponent(key)}=${isId(value) ? PLACEHOLDER : encodeURIComponent(value)}`
1447
+ );
1442
1448
  });
1443
1449
  const search = query.length ? `?${query.join("&")}` : "";
1444
1450
  return (absolute ? `${u.protocol}//${u.host}` : "") + path + search;
@@ -1449,13 +1455,17 @@ function cleanValue(key, v, depth) {
1449
1455
  if (MONEY_KEYS.has(key.toLowerCase()) || UUID_ONLY.test(v)) return v;
1450
1456
  if (urlKey(key) || /^https?:\/\//i.test(v)) return sanitizeUrl(v);
1451
1457
  if (key === "$elements_chain") {
1452
- return redactText(v).replace(/attr__href="([^"]*)"/g, (_, h) => `attr__href="${sanitizeUrl(h)}"`);
1458
+ return redactText(v).replace(
1459
+ /attr__href="([^"]*)"/g,
1460
+ (_, h) => `attr__href="${sanitizeUrl(h)}"`
1461
+ );
1453
1462
  }
1454
1463
  const r = redactText(v);
1455
1464
  return r.replace(/\[(email|number)\]/g, "").trim() === "" && r !== v ? void 0 : r;
1456
1465
  }
1457
1466
  if (depth > 5) return void 0;
1458
- if (Array.isArray(v)) return v.map((x) => cleanValue(key, x, depth + 1)).filter((x) => x !== void 0);
1467
+ if (Array.isArray(v))
1468
+ return v.map((x) => cleanValue(key, x, depth + 1)).filter((x) => x !== void 0);
1459
1469
  if (typeof v === "object") return sanitizeProperties(v, depth + 1);
1460
1470
  return void 0;
1461
1471
  }
@@ -1535,7 +1545,10 @@ function loadPostHogScript(o, config) {
1535
1545
  return new Promise((resolve) => {
1536
1546
  const w = win();
1537
1547
  if (!w.document) return resolve(void 0);
1538
- const placeholder = Object.assign([], { __SV: 1, _i: [[o.key, config, "posthog"]] });
1548
+ const placeholder = Object.assign([], {
1549
+ __SV: 1,
1550
+ _i: [[o.key, config, "posthog"]]
1551
+ });
1539
1552
  w.posthog = placeholder;
1540
1553
  injectScript(
1541
1554
  `${assetsHost(o)}/static/array.js`,
@@ -1638,7 +1651,9 @@ function sinks(s) {
1638
1651
  function initAnalytics(options) {
1639
1652
  if (state() || !win().document) return;
1640
1653
  if (options.zone !== "public" && win().ym) {
1641
- console.warn("[analytics] Yandex Metrica is on a page outside the public zone; it must not be.");
1654
+ console.warn(
1655
+ "[analytics] Yandex Metrica is on a page outside the public zone; it must not be."
1656
+ );
1642
1657
  }
1643
1658
  const s = { options, zone: options.zone };
1644
1659
  holder[KEY] = s;