@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.
- package/CHANGELOG.md +10 -2
- package/README.md +2 -2
- package/dist/analytics.cjs +28 -7
- package/dist/analytics.cjs.map +1 -1
- package/dist/analytics.js +28 -7
- package/dist/analytics.js.map +1 -1
- package/dist/index.cjs +58 -43
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +58 -43
- package/dist/index.js.map +1 -1
- package/dist/react/index.cjs +2 -8
- package/dist/react/index.cjs.map +1 -1
- package/dist/react/index.js +2 -8
- package/dist/react/index.js.map +1 -1
- package/dist/resources/attribution.cjs.map +1 -1
- package/dist/resources/attribution.js.map +1 -1
- package/dist/resources/auth.cjs.map +1 -1
- package/dist/resources/auth.js.map +1 -1
- package/dist/resources/cards.cjs +11 -22
- package/dist/resources/cards.cjs.map +1 -1
- package/dist/resources/cards.js +11 -22
- package/dist/resources/cards.js.map +1 -1
- package/dist/resources/deposits.cjs +4 -4
- package/dist/resources/deposits.cjs.map +1 -1
- package/dist/resources/deposits.js +4 -4
- package/dist/resources/deposits.js.map +1 -1
- package/dist/resources/devices.cjs +3 -1
- package/dist/resources/devices.cjs.map +1 -1
- package/dist/resources/devices.js +3 -1
- package/dist/resources/devices.js.map +1 -1
- package/dist/resources/documents.cjs +3 -1
- package/dist/resources/documents.cjs.map +1 -1
- package/dist/resources/documents.js +3 -1
- package/dist/resources/documents.js.map +1 -1
- package/dist/resources/history.cjs +3 -1
- package/dist/resources/history.cjs.map +1 -1
- package/dist/resources/history.js +3 -1
- package/dist/resources/history.js.map +1 -1
- package/dist/resources/push.cjs +3 -1
- package/dist/resources/push.cjs.map +1 -1
- package/dist/resources/push.js +3 -1
- package/dist/resources/push.js.map +1 -1
- package/dist/telegram.cjs +33 -46
- package/dist/telegram.cjs.map +1 -1
- package/dist/telegram.js +33 -46
- package/dist/telegram.js.map +1 -1
- package/package.json +12 -5
package/dist/index.cjs
CHANGED
|
@@ -98,10 +98,7 @@ var HttpClient = class {
|
|
|
98
98
|
try {
|
|
99
99
|
resp = await this.fetchImpl(url, init);
|
|
100
100
|
} catch (e) {
|
|
101
|
-
throw new NetworkError(
|
|
102
|
-
e instanceof Error ? e.message : "network error",
|
|
103
|
-
e
|
|
104
|
-
);
|
|
101
|
+
throw new NetworkError(e instanceof Error ? e.message : "network error", e);
|
|
105
102
|
}
|
|
106
103
|
if (resp.status === 401 && !opts.skipAuth && !opts.retried && this.refresher) {
|
|
107
104
|
if (await this.refreshOnce()) {
|
|
@@ -393,9 +390,7 @@ var CardsResource = class {
|
|
|
393
390
|
}
|
|
394
391
|
/** One product from the catalog. 404 when unknown, disabled or hidden. */
|
|
395
392
|
async getProduct(id) {
|
|
396
|
-
return this.http.get(
|
|
397
|
-
`/me/card-products/${encodeURIComponent(id)}`
|
|
398
|
-
);
|
|
393
|
+
return this.http.get(`/me/card-products/${encodeURIComponent(id)}`);
|
|
399
394
|
}
|
|
400
395
|
/**
|
|
401
396
|
* The public catalog: the same products, order and default as
|
|
@@ -434,9 +429,7 @@ var CardsResource = class {
|
|
|
434
429
|
*/
|
|
435
430
|
async balance(id, currency) {
|
|
436
431
|
const q = new URLSearchParams({ currency }).toString();
|
|
437
|
-
return this.http.get(
|
|
438
|
-
`/me/cards/${encodeURIComponent(id)}/balance?${q}`
|
|
439
|
-
);
|
|
432
|
+
return this.http.get(`/me/cards/${encodeURIComponent(id)}/balance?${q}`);
|
|
440
433
|
}
|
|
441
434
|
/**
|
|
442
435
|
* What a top-up of this card can be right now: whether it is possible, the
|
|
@@ -477,10 +470,10 @@ var CardsResource = class {
|
|
|
477
470
|
*/
|
|
478
471
|
async transfer(fromCardId, input) {
|
|
479
472
|
const { toCardId, amount, idempotencyKey } = input;
|
|
480
|
-
return this.http.post(
|
|
481
|
-
|
|
482
|
-
|
|
483
|
-
);
|
|
473
|
+
return this.http.post(`/me/cards/${encodeURIComponent(fromCardId)}/transfer`, {
|
|
474
|
+
body: { to_card_id: toCardId, amount },
|
|
475
|
+
idempotencyKey
|
|
476
|
+
});
|
|
484
477
|
}
|
|
485
478
|
/**
|
|
486
479
|
* Freeze the caller's own card. Reversible via {@link unfreeze}. The optional
|
|
@@ -488,10 +481,7 @@ var CardsResource = class {
|
|
|
488
481
|
* 404 if the card isn't the caller's; 501 if the issuer can't freeze.
|
|
489
482
|
*/
|
|
490
483
|
async freeze(id, reason) {
|
|
491
|
-
return this.http.post(
|
|
492
|
-
`/me/cards/${encodeURIComponent(id)}/freeze`,
|
|
493
|
-
{ body: { reason } }
|
|
494
|
-
);
|
|
484
|
+
return this.http.post(`/me/cards/${encodeURIComponent(id)}/freeze`, { body: { reason } });
|
|
495
485
|
}
|
|
496
486
|
/**
|
|
497
487
|
* Reveal the FULL PAN + CVV for the caller's own card. The signed-in
|
|
@@ -511,10 +501,7 @@ var CardsResource = class {
|
|
|
511
501
|
}
|
|
512
502
|
/** Unfreeze a previously-frozen card. Idempotent on an already-active card. */
|
|
513
503
|
async unfreeze(id) {
|
|
514
|
-
return this.http.post(
|
|
515
|
-
`/me/cards/${encodeURIComponent(id)}/unfreeze`,
|
|
516
|
-
{ body: {} }
|
|
517
|
-
);
|
|
504
|
+
return this.http.post(`/me/cards/${encodeURIComponent(id)}/unfreeze`, { body: {} });
|
|
518
505
|
}
|
|
519
506
|
/**
|
|
520
507
|
* Terminate the caller's own card. **One-way** — a terminated card cannot be
|
|
@@ -522,10 +509,9 @@ var CardsResource = class {
|
|
|
522
509
|
* already-terminated card.
|
|
523
510
|
*/
|
|
524
511
|
async terminate(id, reason) {
|
|
525
|
-
return this.http.post(
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
);
|
|
512
|
+
return this.http.post(`/me/cards/${encodeURIComponent(id)}/terminate`, {
|
|
513
|
+
body: { reason }
|
|
514
|
+
});
|
|
529
515
|
}
|
|
530
516
|
};
|
|
531
517
|
|
|
@@ -572,10 +558,10 @@ var DepositsResource = class {
|
|
|
572
558
|
*/
|
|
573
559
|
async refund(depositId, input) {
|
|
574
560
|
const { idempotencyKey, ...body } = input;
|
|
575
|
-
return this.http.post(
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
);
|
|
561
|
+
return this.http.post(`/me/deposits/${encodeURIComponent(depositId)}/refunds`, {
|
|
562
|
+
body,
|
|
563
|
+
idempotencyKey
|
|
564
|
+
});
|
|
579
565
|
}
|
|
580
566
|
};
|
|
581
567
|
|
|
@@ -770,7 +756,9 @@ var DocumentsResource = class {
|
|
|
770
756
|
}
|
|
771
757
|
/** Every saved text of a document, newest first, with the date each took effect. */
|
|
772
758
|
async versions(slug) {
|
|
773
|
-
return this.http.get(
|
|
759
|
+
return this.http.get(
|
|
760
|
+
`/documents/${encodeURIComponent(slug)}/versions`
|
|
761
|
+
);
|
|
774
762
|
}
|
|
775
763
|
/** The document as it read in one version. */
|
|
776
764
|
async version(slug, version) {
|
|
@@ -854,7 +842,9 @@ var PushResource = class {
|
|
|
854
842
|
async enable(registration) {
|
|
855
843
|
const { vapid_public_key } = await this.status();
|
|
856
844
|
if (!vapid_public_key) {
|
|
857
|
-
throw new Error(
|
|
845
|
+
throw new Error(
|
|
846
|
+
"@takeal/cusfront-sdk: push notifications are not enabled on this deployment"
|
|
847
|
+
);
|
|
858
848
|
}
|
|
859
849
|
const sub = await registration.pushManager.subscribe({
|
|
860
850
|
userVisibleOnly: true,
|
|
@@ -999,7 +989,9 @@ var DevicesResource = class {
|
|
|
999
989
|
async registerWebPush(registration, opts = {}) {
|
|
1000
990
|
const key = opts.vapidPublicKey ?? await this.vapidPublicKey();
|
|
1001
991
|
if (!key) {
|
|
1002
|
-
throw new Error(
|
|
992
|
+
throw new Error(
|
|
993
|
+
"@takeal/cusfront-sdk: push notifications are not enabled on this deployment"
|
|
994
|
+
);
|
|
1003
995
|
}
|
|
1004
996
|
const sub = await registration.pushManager.subscribe({
|
|
1005
997
|
userVisibleOnly: true,
|
|
@@ -1128,7 +1120,9 @@ var HistoryResource = class {
|
|
|
1128
1120
|
if (params.limit !== void 0) q.set("limit", String(params.limit));
|
|
1129
1121
|
if (params.lang) q.set("lang", params.lang);
|
|
1130
1122
|
const qs = q.toString();
|
|
1131
|
-
return this.http.get(`/me/history${qs ? `?${qs}` : ""}`, {
|
|
1123
|
+
return this.http.get(`/me/history${qs ? `?${qs}` : ""}`, {
|
|
1124
|
+
signal: params.signal
|
|
1125
|
+
});
|
|
1132
1126
|
}
|
|
1133
1127
|
/** Every entry, page after page, newest first. */
|
|
1134
1128
|
async *all(params = {}) {
|
|
@@ -1153,7 +1147,7 @@ var FundingOptionsResource = class {
|
|
|
1153
1147
|
};
|
|
1154
1148
|
|
|
1155
1149
|
// src/version.ts
|
|
1156
|
-
var SDK_VERSION = "0.
|
|
1150
|
+
var SDK_VERSION = "0.6.0";
|
|
1157
1151
|
|
|
1158
1152
|
// src/client-platform.ts
|
|
1159
1153
|
var CLIENT_HEADER = "X-Takeal-Client";
|
|
@@ -1228,7 +1222,7 @@ function isAbsolute(url) {
|
|
|
1228
1222
|
}
|
|
1229
1223
|
|
|
1230
1224
|
// src/compat.ts
|
|
1231
|
-
var SUPPORTED_MEISTER = ">=0.5.0, <0.
|
|
1225
|
+
var SUPPORTED_MEISTER = ">=0.5.0, <0.7.0";
|
|
1232
1226
|
var SEMVER = /^v?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/;
|
|
1233
1227
|
function parse(v) {
|
|
1234
1228
|
const m = SEMVER.exec(v.trim());
|
|
@@ -1393,7 +1387,15 @@ var SECRET_QUERY_WORDS = /* @__PURE__ */ new Set([
|
|
|
1393
1387
|
"cvc",
|
|
1394
1388
|
"iban"
|
|
1395
1389
|
]);
|
|
1396
|
-
var MONEY_KEYS = /* @__PURE__ */ new Set([
|
|
1390
|
+
var MONEY_KEYS = /* @__PURE__ */ new Set([
|
|
1391
|
+
"amount",
|
|
1392
|
+
"amount_minor",
|
|
1393
|
+
"currency",
|
|
1394
|
+
"value",
|
|
1395
|
+
"price",
|
|
1396
|
+
"revenue",
|
|
1397
|
+
"sum"
|
|
1398
|
+
]);
|
|
1397
1399
|
function words(key) {
|
|
1398
1400
|
return key.replace(/^\$+/, "").replace(/([a-z])([A-Z])/g, "$1_$2").toLowerCase().split(/[^a-z0-9]+/).filter(Boolean);
|
|
1399
1401
|
}
|
|
@@ -1403,7 +1405,9 @@ function personalKey(key) {
|
|
|
1403
1405
|
if (joined.includes("email") || joined.includes("phone")) return true;
|
|
1404
1406
|
if (w.some((x) => PERSONAL_WORDS.has(x)) || PERSONAL_WORDS.has(joined)) return true;
|
|
1405
1407
|
if (key.startsWith("$")) return false;
|
|
1406
|
-
return w.some(
|
|
1408
|
+
return w.some(
|
|
1409
|
+
(x, i) => x === "name" && (w.length === 1 || PERSON_NAME_QUALIFIERS.has(w[i - 1] ?? ""))
|
|
1410
|
+
);
|
|
1407
1411
|
}
|
|
1408
1412
|
function urlKey(key) {
|
|
1409
1413
|
const k = key.replace(/^\$+/, "").toLowerCase();
|
|
@@ -1440,7 +1444,9 @@ function sanitizeUrl(raw) {
|
|
|
1440
1444
|
const k = words(key);
|
|
1441
1445
|
if (k.some((w) => SECRET_QUERY_WORDS.has(w)) || personalKey(key)) return;
|
|
1442
1446
|
if (redactText(value) !== value) return;
|
|
1443
|
-
query.push(
|
|
1447
|
+
query.push(
|
|
1448
|
+
`${encodeURIComponent(key)}=${isId(value) ? PLACEHOLDER : encodeURIComponent(value)}`
|
|
1449
|
+
);
|
|
1444
1450
|
});
|
|
1445
1451
|
const search = query.length ? `?${query.join("&")}` : "";
|
|
1446
1452
|
return (absolute ? `${u.protocol}//${u.host}` : "") + path + search;
|
|
@@ -1451,13 +1457,17 @@ function cleanValue(key, v, depth) {
|
|
|
1451
1457
|
if (MONEY_KEYS.has(key.toLowerCase()) || UUID_ONLY.test(v)) return v;
|
|
1452
1458
|
if (urlKey(key) || /^https?:\/\//i.test(v)) return sanitizeUrl(v);
|
|
1453
1459
|
if (key === "$elements_chain") {
|
|
1454
|
-
return redactText(v).replace(
|
|
1460
|
+
return redactText(v).replace(
|
|
1461
|
+
/attr__href="([^"]*)"/g,
|
|
1462
|
+
(_, h) => `attr__href="${sanitizeUrl(h)}"`
|
|
1463
|
+
);
|
|
1455
1464
|
}
|
|
1456
1465
|
const r = redactText(v);
|
|
1457
1466
|
return r.replace(/\[(email|number)\]/g, "").trim() === "" && r !== v ? void 0 : r;
|
|
1458
1467
|
}
|
|
1459
1468
|
if (depth > 5) return void 0;
|
|
1460
|
-
if (Array.isArray(v))
|
|
1469
|
+
if (Array.isArray(v))
|
|
1470
|
+
return v.map((x) => cleanValue(key, x, depth + 1)).filter((x) => x !== void 0);
|
|
1461
1471
|
if (typeof v === "object") return sanitizeProperties(v, depth + 1);
|
|
1462
1472
|
return void 0;
|
|
1463
1473
|
}
|
|
@@ -1537,7 +1547,10 @@ function loadPostHogScript(o, config) {
|
|
|
1537
1547
|
return new Promise((resolve) => {
|
|
1538
1548
|
const w = win();
|
|
1539
1549
|
if (!w.document) return resolve(void 0);
|
|
1540
|
-
const placeholder = Object.assign([], {
|
|
1550
|
+
const placeholder = Object.assign([], {
|
|
1551
|
+
__SV: 1,
|
|
1552
|
+
_i: [[o.key, config, "posthog"]]
|
|
1553
|
+
});
|
|
1541
1554
|
w.posthog = placeholder;
|
|
1542
1555
|
injectScript(
|
|
1543
1556
|
`${assetsHost(o)}/static/array.js`,
|
|
@@ -1640,7 +1653,9 @@ function sinks(s) {
|
|
|
1640
1653
|
function initAnalytics(options) {
|
|
1641
1654
|
if (state() || !win().document) return;
|
|
1642
1655
|
if (options.zone !== "public" && win().ym) {
|
|
1643
|
-
console.warn(
|
|
1656
|
+
console.warn(
|
|
1657
|
+
"[analytics] Yandex Metrica is on a page outside the public zone; it must not be."
|
|
1658
|
+
);
|
|
1644
1659
|
}
|
|
1645
1660
|
const s = { options, zone: options.zone };
|
|
1646
1661
|
holder[KEY] = s;
|