@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.
- package/CHANGELOG.md +49 -2
- package/README.md +168 -3
- 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/{cards-Ba1wZttb.d.ts → cards-CF3-He2x.d.ts} +144 -20
- package/dist/{cards-B_aNY35J.d.cts → cards-qfHz6xZY.d.cts} +144 -20
- package/dist/{deposits-DScyT_D9.d.ts → deposits-B2LBe2k1.d.ts} +71 -8
- package/dist/{deposits-BEc8U80M.d.cts → deposits-ZjT_btgi.d.cts} +71 -8
- package/dist/index.cjs +92 -50
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -6
- package/dist/index.d.ts +6 -6
- package/dist/index.js +92 -50
- 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.d.cts +2 -2
- package/dist/react/index.d.ts +2 -2
- 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 +41 -28
- package/dist/resources/cards.cjs.map +1 -1
- package/dist/resources/cards.d.cts +1 -1
- package/dist/resources/cards.d.ts +1 -1
- package/dist/resources/cards.js +41 -28
- package/dist/resources/cards.js.map +1 -1
- package/dist/resources/deposits.cjs +8 -5
- package/dist/resources/deposits.cjs.map +1 -1
- package/dist/resources/deposits.d.cts +2 -2
- package/dist/resources/deposits.d.ts +2 -2
- package/dist/resources/deposits.js +8 -5
- 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/funding-options.cjs.map +1 -1
- package/dist/resources/funding-options.d.cts +2 -2
- package/dist/resources/funding-options.d.ts +2 -2
- package/dist/resources/funding-options.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 +67 -53
- package/dist/telegram.cjs.map +1 -1
- package/dist/telegram.d.cts +2 -2
- package/dist/telegram.d.ts +2 -2
- package/dist/telegram.js +67 -53
- 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,21 +470,20 @@ 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
|
-
* Freeze the caller's own card. Reversible via {@link unfreeze}
|
|
487
|
-
* `
|
|
488
|
-
*
|
|
479
|
+
* Freeze the caller's own card. Reversible via {@link unfreeze} while
|
|
480
|
+
* `status_source` is `holder` or `operator`. The optional `reason` is
|
|
481
|
+
* recorded on the audit trail. Resolves to the updated card. 404 if the
|
|
482
|
+
* card isn't the caller's; 409 `card_locked` when support holds it; 501 if
|
|
483
|
+
* the issuer can't freeze.
|
|
489
484
|
*/
|
|
490
485
|
async freeze(id, reason) {
|
|
491
|
-
return this.http.post(
|
|
492
|
-
`/me/cards/${encodeURIComponent(id)}/freeze`,
|
|
493
|
-
{ body: { reason } }
|
|
494
|
-
);
|
|
486
|
+
return this.http.post(`/me/cards/${encodeURIComponent(id)}/freeze`, { body: { reason } });
|
|
495
487
|
}
|
|
496
488
|
/**
|
|
497
489
|
* Reveal the FULL PAN + CVV for the caller's own card. The signed-in
|
|
@@ -503,18 +495,37 @@ var CardsResource = class {
|
|
|
503
495
|
* keep the result in volatile memory only, never write it to
|
|
504
496
|
* localStorage / logs, and clear it within `expires_in_seconds`.
|
|
505
497
|
*
|
|
506
|
-
*
|
|
507
|
-
*
|
|
498
|
+
* The result is the numbers, or `reveal_url` with empty `pan` and `cvv`
|
|
499
|
+
* when the issuer shows them on a page of its own: open that page in a
|
|
500
|
+
* frame right away, it is short-lived.
|
|
501
|
+
*
|
|
502
|
+
* 403 not your card · 409 `card_locked` · 429 rate-limited · 501 connector
|
|
503
|
+
* has no sensitive-data endpoint · 503 `provider_unavailable`.
|
|
508
504
|
*/
|
|
509
505
|
async reveal(id, _input) {
|
|
510
506
|
return this.http.post(`/me/cards/${encodeURIComponent(id)}/reveal`);
|
|
511
507
|
}
|
|
512
|
-
/**
|
|
508
|
+
/**
|
|
509
|
+
* Unfreeze a previously-frozen card. Idempotent on an already-active card.
|
|
510
|
+
* A card the issuer froze (`status_source: "provider"`) is not the
|
|
511
|
+
* holder's to unfreeze: the API answers 409 `card_locked`, so hide the
|
|
512
|
+
* button and say the freeze is lifted through the issuer's support.
|
|
513
|
+
*/
|
|
513
514
|
async unfreeze(id) {
|
|
514
|
-
return this.http.post(
|
|
515
|
-
|
|
516
|
-
|
|
517
|
-
|
|
515
|
+
return this.http.post(`/me/cards/${encodeURIComponent(id)}/unfreeze`, { body: {} });
|
|
516
|
+
}
|
|
517
|
+
/**
|
|
518
|
+
* Set the PIN of the caller's own physical card. The session is enough; the
|
|
519
|
+
* call is rate-limited like {@link reveal} and the PIN is kept nowhere.
|
|
520
|
+
* Resolves to the card; the user also gets a notification that the PIN
|
|
521
|
+
* was set. 400 not four to six digits or the card is not active · 403 not
|
|
522
|
+
* your card · 409 `card_locked`, or `provider_refused` when the issuer did
|
|
523
|
+
* not take it · 429 too many attempts · 501 a virtual card has no PIN.
|
|
524
|
+
*/
|
|
525
|
+
async setPin(id, input) {
|
|
526
|
+
return this.http.post(`/me/cards/${encodeURIComponent(id)}/pin`, {
|
|
527
|
+
body: { pin: input.pin }
|
|
528
|
+
});
|
|
518
529
|
}
|
|
519
530
|
/**
|
|
520
531
|
* Terminate the caller's own card. **One-way** — a terminated card cannot be
|
|
@@ -522,10 +533,9 @@ var CardsResource = class {
|
|
|
522
533
|
* already-terminated card.
|
|
523
534
|
*/
|
|
524
535
|
async terminate(id, reason) {
|
|
525
|
-
return this.http.post(
|
|
526
|
-
|
|
527
|
-
|
|
528
|
-
);
|
|
536
|
+
return this.http.post(`/me/cards/${encodeURIComponent(id)}/terminate`, {
|
|
537
|
+
body: { reason }
|
|
538
|
+
});
|
|
529
539
|
}
|
|
530
540
|
};
|
|
531
541
|
|
|
@@ -546,7 +556,10 @@ var DepositsResource = class {
|
|
|
546
556
|
* API answers 400 `no_quote_needed`).
|
|
547
557
|
*/
|
|
548
558
|
async quote(input) {
|
|
549
|
-
|
|
559
|
+
const { connectorSlug, ...rest } = input;
|
|
560
|
+
const body = { ...rest };
|
|
561
|
+
if (connectorSlug !== void 0) body["connector_slug"] = connectorSlug;
|
|
562
|
+
return this.http.post("/me/deposits/quotes", { body });
|
|
550
563
|
}
|
|
551
564
|
async initiate(input) {
|
|
552
565
|
const { idempotencyKey, issue_card, ...rest } = input;
|
|
@@ -572,10 +585,10 @@ var DepositsResource = class {
|
|
|
572
585
|
*/
|
|
573
586
|
async refund(depositId, input) {
|
|
574
587
|
const { idempotencyKey, ...body } = input;
|
|
575
|
-
return this.http.post(
|
|
576
|
-
|
|
577
|
-
|
|
578
|
-
);
|
|
588
|
+
return this.http.post(`/me/deposits/${encodeURIComponent(depositId)}/refunds`, {
|
|
589
|
+
body,
|
|
590
|
+
idempotencyKey
|
|
591
|
+
});
|
|
579
592
|
}
|
|
580
593
|
};
|
|
581
594
|
|
|
@@ -770,7 +783,9 @@ var DocumentsResource = class {
|
|
|
770
783
|
}
|
|
771
784
|
/** Every saved text of a document, newest first, with the date each took effect. */
|
|
772
785
|
async versions(slug) {
|
|
773
|
-
return this.http.get(
|
|
786
|
+
return this.http.get(
|
|
787
|
+
`/documents/${encodeURIComponent(slug)}/versions`
|
|
788
|
+
);
|
|
774
789
|
}
|
|
775
790
|
/** The document as it read in one version. */
|
|
776
791
|
async version(slug, version) {
|
|
@@ -854,7 +869,9 @@ var PushResource = class {
|
|
|
854
869
|
async enable(registration) {
|
|
855
870
|
const { vapid_public_key } = await this.status();
|
|
856
871
|
if (!vapid_public_key) {
|
|
857
|
-
throw new Error(
|
|
872
|
+
throw new Error(
|
|
873
|
+
"@takeal/cusfront-sdk: push notifications are not enabled on this deployment"
|
|
874
|
+
);
|
|
858
875
|
}
|
|
859
876
|
const sub = await registration.pushManager.subscribe({
|
|
860
877
|
userVisibleOnly: true,
|
|
@@ -999,7 +1016,9 @@ var DevicesResource = class {
|
|
|
999
1016
|
async registerWebPush(registration, opts = {}) {
|
|
1000
1017
|
const key = opts.vapidPublicKey ?? await this.vapidPublicKey();
|
|
1001
1018
|
if (!key) {
|
|
1002
|
-
throw new Error(
|
|
1019
|
+
throw new Error(
|
|
1020
|
+
"@takeal/cusfront-sdk: push notifications are not enabled on this deployment"
|
|
1021
|
+
);
|
|
1003
1022
|
}
|
|
1004
1023
|
const sub = await registration.pushManager.subscribe({
|
|
1005
1024
|
userVisibleOnly: true,
|
|
@@ -1128,7 +1147,9 @@ var HistoryResource = class {
|
|
|
1128
1147
|
if (params.limit !== void 0) q.set("limit", String(params.limit));
|
|
1129
1148
|
if (params.lang) q.set("lang", params.lang);
|
|
1130
1149
|
const qs = q.toString();
|
|
1131
|
-
return this.http.get(`/me/history${qs ? `?${qs}` : ""}`, {
|
|
1150
|
+
return this.http.get(`/me/history${qs ? `?${qs}` : ""}`, {
|
|
1151
|
+
signal: params.signal
|
|
1152
|
+
});
|
|
1132
1153
|
}
|
|
1133
1154
|
/** Every entry, page after page, newest first. */
|
|
1134
1155
|
async *all(params = {}) {
|
|
@@ -1153,7 +1174,7 @@ var FundingOptionsResource = class {
|
|
|
1153
1174
|
};
|
|
1154
1175
|
|
|
1155
1176
|
// src/version.ts
|
|
1156
|
-
var SDK_VERSION = "0.
|
|
1177
|
+
var SDK_VERSION = "0.6.1";
|
|
1157
1178
|
|
|
1158
1179
|
// src/client-platform.ts
|
|
1159
1180
|
var CLIENT_HEADER = "X-Takeal-Client";
|
|
@@ -1228,7 +1249,7 @@ function isAbsolute(url) {
|
|
|
1228
1249
|
}
|
|
1229
1250
|
|
|
1230
1251
|
// src/compat.ts
|
|
1231
|
-
var SUPPORTED_MEISTER = ">=0.
|
|
1252
|
+
var SUPPORTED_MEISTER = ">=0.6.4, <0.7.0";
|
|
1232
1253
|
var SEMVER = /^v?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/;
|
|
1233
1254
|
function parse(v) {
|
|
1234
1255
|
const m = SEMVER.exec(v.trim());
|
|
@@ -1393,7 +1414,15 @@ var SECRET_QUERY_WORDS = /* @__PURE__ */ new Set([
|
|
|
1393
1414
|
"cvc",
|
|
1394
1415
|
"iban"
|
|
1395
1416
|
]);
|
|
1396
|
-
var MONEY_KEYS = /* @__PURE__ */ new Set([
|
|
1417
|
+
var MONEY_KEYS = /* @__PURE__ */ new Set([
|
|
1418
|
+
"amount",
|
|
1419
|
+
"amount_minor",
|
|
1420
|
+
"currency",
|
|
1421
|
+
"value",
|
|
1422
|
+
"price",
|
|
1423
|
+
"revenue",
|
|
1424
|
+
"sum"
|
|
1425
|
+
]);
|
|
1397
1426
|
function words(key) {
|
|
1398
1427
|
return key.replace(/^\$+/, "").replace(/([a-z])([A-Z])/g, "$1_$2").toLowerCase().split(/[^a-z0-9]+/).filter(Boolean);
|
|
1399
1428
|
}
|
|
@@ -1403,7 +1432,9 @@ function personalKey(key) {
|
|
|
1403
1432
|
if (joined.includes("email") || joined.includes("phone")) return true;
|
|
1404
1433
|
if (w.some((x) => PERSONAL_WORDS.has(x)) || PERSONAL_WORDS.has(joined)) return true;
|
|
1405
1434
|
if (key.startsWith("$")) return false;
|
|
1406
|
-
return w.some(
|
|
1435
|
+
return w.some(
|
|
1436
|
+
(x, i) => x === "name" && (w.length === 1 || PERSON_NAME_QUALIFIERS.has(w[i - 1] ?? ""))
|
|
1437
|
+
);
|
|
1407
1438
|
}
|
|
1408
1439
|
function urlKey(key) {
|
|
1409
1440
|
const k = key.replace(/^\$+/, "").toLowerCase();
|
|
@@ -1440,7 +1471,9 @@ function sanitizeUrl(raw) {
|
|
|
1440
1471
|
const k = words(key);
|
|
1441
1472
|
if (k.some((w) => SECRET_QUERY_WORDS.has(w)) || personalKey(key)) return;
|
|
1442
1473
|
if (redactText(value) !== value) return;
|
|
1443
|
-
query.push(
|
|
1474
|
+
query.push(
|
|
1475
|
+
`${encodeURIComponent(key)}=${isId(value) ? PLACEHOLDER : encodeURIComponent(value)}`
|
|
1476
|
+
);
|
|
1444
1477
|
});
|
|
1445
1478
|
const search = query.length ? `?${query.join("&")}` : "";
|
|
1446
1479
|
return (absolute ? `${u.protocol}//${u.host}` : "") + path + search;
|
|
@@ -1451,13 +1484,17 @@ function cleanValue(key, v, depth) {
|
|
|
1451
1484
|
if (MONEY_KEYS.has(key.toLowerCase()) || UUID_ONLY.test(v)) return v;
|
|
1452
1485
|
if (urlKey(key) || /^https?:\/\//i.test(v)) return sanitizeUrl(v);
|
|
1453
1486
|
if (key === "$elements_chain") {
|
|
1454
|
-
return redactText(v).replace(
|
|
1487
|
+
return redactText(v).replace(
|
|
1488
|
+
/attr__href="([^"]*)"/g,
|
|
1489
|
+
(_, h) => `attr__href="${sanitizeUrl(h)}"`
|
|
1490
|
+
);
|
|
1455
1491
|
}
|
|
1456
1492
|
const r = redactText(v);
|
|
1457
1493
|
return r.replace(/\[(email|number)\]/g, "").trim() === "" && r !== v ? void 0 : r;
|
|
1458
1494
|
}
|
|
1459
1495
|
if (depth > 5) return void 0;
|
|
1460
|
-
if (Array.isArray(v))
|
|
1496
|
+
if (Array.isArray(v))
|
|
1497
|
+
return v.map((x) => cleanValue(key, x, depth + 1)).filter((x) => x !== void 0);
|
|
1461
1498
|
if (typeof v === "object") return sanitizeProperties(v, depth + 1);
|
|
1462
1499
|
return void 0;
|
|
1463
1500
|
}
|
|
@@ -1537,7 +1574,10 @@ function loadPostHogScript(o, config) {
|
|
|
1537
1574
|
return new Promise((resolve) => {
|
|
1538
1575
|
const w = win();
|
|
1539
1576
|
if (!w.document) return resolve(void 0);
|
|
1540
|
-
const placeholder = Object.assign([], {
|
|
1577
|
+
const placeholder = Object.assign([], {
|
|
1578
|
+
__SV: 1,
|
|
1579
|
+
_i: [[o.key, config, "posthog"]]
|
|
1580
|
+
});
|
|
1541
1581
|
w.posthog = placeholder;
|
|
1542
1582
|
injectScript(
|
|
1543
1583
|
`${assetsHost(o)}/static/array.js`,
|
|
@@ -1640,7 +1680,9 @@ function sinks(s) {
|
|
|
1640
1680
|
function initAnalytics(options) {
|
|
1641
1681
|
if (state() || !win().document) return;
|
|
1642
1682
|
if (options.zone !== "public" && win().ym) {
|
|
1643
|
-
console.warn(
|
|
1683
|
+
console.warn(
|
|
1684
|
+
"[analytics] Yandex Metrica is on a page outside the public zone; it must not be."
|
|
1685
|
+
);
|
|
1644
1686
|
}
|
|
1645
1687
|
const s = { options, zone: options.zone };
|
|
1646
1688
|
holder[KEY] = s;
|