@takeal/cusfront-sdk 0.6.5 → 0.6.8
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 -0
- package/README.md +90 -0
- package/dist/{cards-ColpW52n.d.ts → cards-BgY00UpU.d.ts} +18 -1
- package/dist/{cards-CEFKrVkl.d.cts → cards-DGz4Rqu1.d.cts} +18 -1
- package/dist/{devices-B_YveTl9.d.ts → devices-C88c38hm.d.ts} +1 -1
- package/dist/{devices-a5Z45Mx_.d.cts → devices-CiJrlXum.d.cts} +1 -1
- package/dist/{http-DeANAoTs.d.cts → http-CL97TjMO.d.cts} +4 -0
- package/dist/{http-DeANAoTs.d.ts → http-CL97TjMO.d.ts} +4 -0
- package/dist/index.cjs +142 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +19 -11
- package/dist/index.d.ts +19 -11
- package/dist/index.js +142 -6
- package/dist/index.js.map +1 -1
- package/dist/react/index.d.cts +5 -3
- package/dist/react/index.d.ts +5 -3
- package/dist/resources/attribution.d.cts +1 -1
- package/dist/resources/attribution.d.ts +1 -1
- package/dist/resources/auth.cjs.map +1 -1
- package/dist/resources/auth.d.cts +3 -2
- package/dist/resources/auth.d.ts +3 -2
- package/dist/resources/auth.js.map +1 -1
- package/dist/resources/balance.d.cts +1 -1
- package/dist/resources/balance.d.ts +1 -1
- package/dist/resources/blog.d.cts +1 -1
- package/dist/resources/blog.d.ts +1 -1
- package/dist/resources/bonus.d.cts +1 -1
- package/dist/resources/bonus.d.ts +1 -1
- package/dist/resources/branding.d.cts +1 -1
- package/dist/resources/branding.d.ts +1 -1
- package/dist/resources/cards.cjs +16 -0
- package/dist/resources/cards.cjs.map +1 -1
- package/dist/resources/cards.d.cts +3 -2
- package/dist/resources/cards.d.ts +3 -2
- package/dist/resources/cards.js +16 -0
- package/dist/resources/cards.js.map +1 -1
- package/dist/resources/claims.cjs +40 -0
- package/dist/resources/claims.cjs.map +1 -0
- package/dist/resources/claims.d.cts +114 -0
- package/dist/resources/claims.d.ts +114 -0
- package/dist/resources/claims.js +38 -0
- package/dist/resources/claims.js.map +1 -0
- package/dist/resources/close-requests.d.cts +1 -1
- package/dist/resources/close-requests.d.ts +1 -1
- package/dist/resources/codes.d.cts +1 -1
- package/dist/resources/codes.d.ts +1 -1
- package/dist/resources/consents.d.cts +1 -1
- package/dist/resources/consents.d.ts +1 -1
- package/dist/resources/debt.d.cts +1 -1
- package/dist/resources/debt.d.ts +1 -1
- package/dist/resources/deposits.cjs.map +1 -1
- package/dist/resources/deposits.d.cts +3 -2
- package/dist/resources/deposits.d.ts +3 -2
- package/dist/resources/deposits.js.map +1 -1
- package/dist/resources/devices.d.cts +2 -2
- package/dist/resources/devices.d.ts +2 -2
- package/dist/resources/documents.d.cts +1 -1
- package/dist/resources/documents.d.ts +1 -1
- package/dist/resources/funding-options.d.cts +3 -2
- package/dist/resources/funding-options.d.ts +3 -2
- package/dist/resources/history.d.cts +1 -1
- package/dist/resources/history.d.ts +1 -1
- package/dist/resources/me.d.cts +3 -2
- package/dist/resources/me.d.ts +3 -2
- package/dist/resources/notifications.d.cts +1 -1
- package/dist/resources/notifications.d.ts +1 -1
- package/dist/resources/push.d.cts +1 -1
- package/dist/resources/push.d.ts +1 -1
- package/dist/resources/receipts.d.cts +1 -1
- package/dist/resources/receipts.d.ts +1 -1
- package/dist/resources/referral.d.cts +1 -1
- package/dist/resources/referral.d.ts +1 -1
- package/dist/resources/sessions.d.cts +1 -1
- package/dist/resources/sessions.d.ts +1 -1
- package/dist/resources/subscription.cjs +9 -0
- package/dist/resources/subscription.cjs.map +1 -1
- package/dist/resources/subscription.d.cts +20 -3
- package/dist/resources/subscription.d.ts +20 -3
- package/dist/resources/subscription.js +9 -0
- package/dist/resources/subscription.js.map +1 -1
- package/dist/resources/subscriptions.d.cts +1 -1
- package/dist/resources/subscriptions.d.ts +1 -1
- package/dist/resources/support.cjs +69 -0
- package/dist/resources/support.cjs.map +1 -0
- package/dist/resources/support.d.cts +115 -0
- package/dist/resources/support.d.ts +115 -0
- package/dist/resources/support.js +67 -0
- package/dist/resources/support.js.map +1 -0
- package/dist/resources/wallet.d.cts +1 -1
- package/dist/resources/wallet.d.ts +1 -1
- package/dist/telegram.cjs +142 -6
- package/dist/telegram.cjs.map +1 -1
- package/dist/telegram.d.cts +5 -3
- package/dist/telegram.d.ts +5 -3
- package/dist/telegram.js +142 -6
- package/dist/telegram.js.map +1 -1
- package/package.json +11 -1
package/dist/telegram.d.cts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { CusfrontClient, CreateClientOptions } from './index.cjs';
|
|
2
2
|
import { JwtIssued, TelegramUnknown } from './resources/auth.cjs';
|
|
3
|
-
import './http-
|
|
4
|
-
import './cards-
|
|
3
|
+
import './http-CL97TjMO.cjs';
|
|
4
|
+
import './cards-DGz4Rqu1.cjs';
|
|
5
|
+
import './resources/claims.cjs';
|
|
5
6
|
import './resources/consents.cjs';
|
|
6
7
|
import './resources/balance.cjs';
|
|
7
8
|
import './resources/bonus.cjs';
|
|
@@ -19,10 +20,11 @@ import './resources/sessions.cjs';
|
|
|
19
20
|
import './resources/push.cjs';
|
|
20
21
|
import './resources/me.cjs';
|
|
21
22
|
import './resources/notifications.cjs';
|
|
22
|
-
import './devices-
|
|
23
|
+
import './devices-CiJrlXum.cjs';
|
|
23
24
|
import './resources/attribution.cjs';
|
|
24
25
|
import './resources/history.cjs';
|
|
25
26
|
import './resources/receipts.cjs';
|
|
27
|
+
import './resources/support.cjs';
|
|
26
28
|
import './analytics.cjs';
|
|
27
29
|
|
|
28
30
|
/**
|
package/dist/telegram.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
import { CusfrontClient, CreateClientOptions } from './index.js';
|
|
2
2
|
import { JwtIssued, TelegramUnknown } from './resources/auth.js';
|
|
3
|
-
import './http-
|
|
4
|
-
import './cards-
|
|
3
|
+
import './http-CL97TjMO.js';
|
|
4
|
+
import './cards-BgY00UpU.js';
|
|
5
|
+
import './resources/claims.js';
|
|
5
6
|
import './resources/consents.js';
|
|
6
7
|
import './resources/balance.js';
|
|
7
8
|
import './resources/bonus.js';
|
|
@@ -19,10 +20,11 @@ import './resources/sessions.js';
|
|
|
19
20
|
import './resources/push.js';
|
|
20
21
|
import './resources/me.js';
|
|
21
22
|
import './resources/notifications.js';
|
|
22
|
-
import './devices-
|
|
23
|
+
import './devices-C88c38hm.js';
|
|
23
24
|
import './resources/attribution.js';
|
|
24
25
|
import './resources/history.js';
|
|
25
26
|
import './resources/receipts.js';
|
|
27
|
+
import './resources/support.js';
|
|
26
28
|
import './analytics.js';
|
|
27
29
|
|
|
28
30
|
/**
|
package/dist/telegram.js
CHANGED
|
@@ -68,10 +68,20 @@ var HttpClient = class {
|
|
|
68
68
|
async delete(path, opts = {}) {
|
|
69
69
|
return this.request("DELETE", path, opts);
|
|
70
70
|
}
|
|
71
|
+
/** GET a file. Same auth and refresh as the JSON calls; an error status
|
|
72
|
+
* throws `ApiError` the same way. */
|
|
73
|
+
async getBlob(path, opts = {}) {
|
|
74
|
+
const resp = await this.send("GET", path, { ...opts, accept: "*/*" });
|
|
75
|
+
if (!resp.ok) return parseResponse(resp);
|
|
76
|
+
return resp.blob();
|
|
77
|
+
}
|
|
71
78
|
async request(method, path, opts) {
|
|
79
|
+
return parseResponse(await this.send(method, path, opts));
|
|
80
|
+
}
|
|
81
|
+
async send(method, path, opts) {
|
|
72
82
|
const url = this.absolute(path);
|
|
73
83
|
const headers = {
|
|
74
|
-
Accept: "application/json",
|
|
84
|
+
Accept: opts.accept ?? "application/json",
|
|
75
85
|
...this.defaultHeaders
|
|
76
86
|
};
|
|
77
87
|
if (opts.body !== void 0) headers["Content-Type"] = "application/json";
|
|
@@ -97,10 +107,10 @@ var HttpClient = class {
|
|
|
97
107
|
}
|
|
98
108
|
if (resp.status === 401 && !opts.skipAuth && !opts.retried && this.refresher) {
|
|
99
109
|
if (await this.refreshOnce()) {
|
|
100
|
-
return this.
|
|
110
|
+
return this.send(method, path, { ...opts, retried: true });
|
|
101
111
|
}
|
|
102
112
|
}
|
|
103
|
-
return
|
|
113
|
+
return resp;
|
|
104
114
|
}
|
|
105
115
|
absolute(path) {
|
|
106
116
|
if (path.startsWith("http://") || path.startsWith("https://")) return path;
|
|
@@ -346,6 +356,22 @@ var CardsResource = class {
|
|
|
346
356
|
async unfreeze(id) {
|
|
347
357
|
return this.http.post(`/me/cards/${encodeURIComponent(id)}/unfreeze`, { body: {} });
|
|
348
358
|
}
|
|
359
|
+
/**
|
|
360
|
+
* Report the card lost or stolen. Works at any time, on an active or a
|
|
361
|
+
* frozen card. The report is recorded first with the server's time, which
|
|
362
|
+
* decides who pays for operations someone else made; then the card is
|
|
363
|
+
* frozen at its issuer and only support can unfreeze it. Resolves to the
|
|
364
|
+
* claim (`client.claims`): show its `number` and `reported_at`. When the
|
|
365
|
+
* issuer can't be reached, `card_freeze` is `"pending"`: the report still
|
|
366
|
+
* counts and support freezes the card by hand. Reporting again while the
|
|
367
|
+
* report is open returns the same claim. 404 / 403 not the user's card ·
|
|
368
|
+
* 409 `card_not_open`: the card is closed or was never issued.
|
|
369
|
+
*/
|
|
370
|
+
async reportLost(id, input) {
|
|
371
|
+
return this.http.post(`/me/cards/${encodeURIComponent(id)}/report-lost`, {
|
|
372
|
+
body: { kind: input.kind, details: input.details }
|
|
373
|
+
});
|
|
374
|
+
}
|
|
349
375
|
/**
|
|
350
376
|
* Set the PIN of the caller's own physical card. The session is enough; the
|
|
351
377
|
* call is rate-limited like {@link reveal} and the PIN is kept nowhere.
|
|
@@ -798,6 +824,41 @@ var CloseRequestsResource = class {
|
|
|
798
824
|
}
|
|
799
825
|
};
|
|
800
826
|
|
|
827
|
+
// src/resources/claims.ts
|
|
828
|
+
var ClaimsResource = class {
|
|
829
|
+
constructor(http) {
|
|
830
|
+
this.http = http;
|
|
831
|
+
}
|
|
832
|
+
/**
|
|
833
|
+
* Dispute a card operation, or complain. 400 `validation`: a description
|
|
834
|
+
* that is too short or too long, an operation that isn't on the user's
|
|
835
|
+
* cards, or a lost or stolen card (use `cards.reportLost()`) · 404 no
|
|
836
|
+
* such card · 409 `too_many_claims`: 20 claims are waiting for an answer.
|
|
837
|
+
*/
|
|
838
|
+
async create(input) {
|
|
839
|
+
return this.http.post("/me/claims", {
|
|
840
|
+
body: {
|
|
841
|
+
kind: input.kind,
|
|
842
|
+
description: input.description,
|
|
843
|
+
card_id: input.cardId,
|
|
844
|
+
transaction_id: input.transactionId
|
|
845
|
+
}
|
|
846
|
+
});
|
|
847
|
+
}
|
|
848
|
+
/** The user's claims, lost and stolen cards included, newest first. */
|
|
849
|
+
async list(opts = {}) {
|
|
850
|
+
const qs = new URLSearchParams();
|
|
851
|
+
if (opts.limit != null) qs.set("limit", String(opts.limit));
|
|
852
|
+
if (opts.offset != null) qs.set("offset", String(opts.offset));
|
|
853
|
+
const q = qs.toString();
|
|
854
|
+
return this.http.get(`/me/claims${q ? `?${q}` : ""}`, { signal: opts.signal });
|
|
855
|
+
}
|
|
856
|
+
/** One claim. 404 when it isn't the user's. */
|
|
857
|
+
async get(id, opts = {}) {
|
|
858
|
+
return this.http.get(`/me/claims/${encodeURIComponent(id)}`, { signal: opts.signal });
|
|
859
|
+
}
|
|
860
|
+
};
|
|
861
|
+
|
|
801
862
|
// src/resources/codes.ts
|
|
802
863
|
var CodesResource = class {
|
|
803
864
|
constructor(http) {
|
|
@@ -841,6 +902,15 @@ var SubscriptionResource = class {
|
|
|
841
902
|
async setPromoCode(code) {
|
|
842
903
|
return this.http.put("/me/subscription/promo-code", { body: { code } });
|
|
843
904
|
}
|
|
905
|
+
/**
|
|
906
|
+
* Cancel the subscription now, in one step. What was paid for the current
|
|
907
|
+
* period comes back to the balance for the days not used. No subscription
|
|
908
|
+
* running → 404; 503 `refund_unavailable` when the refund can't be made
|
|
909
|
+
* right now (the subscription keeps running; try again).
|
|
910
|
+
*/
|
|
911
|
+
async cancel() {
|
|
912
|
+
return this.http.post("/me/subscription/cancel", {});
|
|
913
|
+
}
|
|
844
914
|
};
|
|
845
915
|
|
|
846
916
|
// src/resources/branding.ts
|
|
@@ -1407,6 +1477,70 @@ var ReceiptsResource = class {
|
|
|
1407
1477
|
}
|
|
1408
1478
|
};
|
|
1409
1479
|
|
|
1480
|
+
// src/resources/support.ts
|
|
1481
|
+
function bytesToBase64(bytes) {
|
|
1482
|
+
let binary = "";
|
|
1483
|
+
const chunk = 32768;
|
|
1484
|
+
for (let i = 0; i < bytes.length; i += chunk) {
|
|
1485
|
+
binary += String.fromCharCode(...bytes.subarray(i, i + chunk));
|
|
1486
|
+
}
|
|
1487
|
+
return btoa(binary);
|
|
1488
|
+
}
|
|
1489
|
+
async function toBase64(data) {
|
|
1490
|
+
if (typeof data === "string") return data;
|
|
1491
|
+
if (data instanceof Uint8Array) return bytesToBase64(data);
|
|
1492
|
+
if (data instanceof ArrayBuffer) return bytesToBase64(new Uint8Array(data));
|
|
1493
|
+
return bytesToBase64(new Uint8Array(await data.arrayBuffer()));
|
|
1494
|
+
}
|
|
1495
|
+
var SupportResource = class {
|
|
1496
|
+
constructor(http) {
|
|
1497
|
+
this.http = http;
|
|
1498
|
+
}
|
|
1499
|
+
/** The latest messages, oldest first, and the conversation's status.
|
|
1500
|
+
* `before` reads further back; `limit` is 1 to 100 (50). */
|
|
1501
|
+
async list(opts = {}) {
|
|
1502
|
+
const q = new URLSearchParams();
|
|
1503
|
+
if (opts.before) q.set("before", opts.before);
|
|
1504
|
+
if (opts.limit !== void 0) q.set("limit", String(opts.limit));
|
|
1505
|
+
const qs = q.toString();
|
|
1506
|
+
return this.http.get(`/me/support/messages${qs ? `?${qs}` : ""}`, {
|
|
1507
|
+
signal: opts.signal
|
|
1508
|
+
});
|
|
1509
|
+
}
|
|
1510
|
+
/** Write to support. Text, files or both; up to 10 files. */
|
|
1511
|
+
async send(message, opts = {}) {
|
|
1512
|
+
const attachments = await Promise.all(
|
|
1513
|
+
(message.files ?? []).map(async (f) => ({
|
|
1514
|
+
file_name: f.fileName,
|
|
1515
|
+
content_type: f.contentType,
|
|
1516
|
+
data_base64: await toBase64(f.data)
|
|
1517
|
+
}))
|
|
1518
|
+
);
|
|
1519
|
+
return this.http.post("/me/support/messages", {
|
|
1520
|
+
body: { text: message.text ?? "", attachments },
|
|
1521
|
+
signal: opts.signal
|
|
1522
|
+
});
|
|
1523
|
+
}
|
|
1524
|
+
/** A file from the conversation: the person's own or one support sent. */
|
|
1525
|
+
async attachment(id, opts = {}) {
|
|
1526
|
+
return this.http.getBlob(`/me/support/attachments/${encodeURIComponent(id)}`, {
|
|
1527
|
+
signal: opts.signal
|
|
1528
|
+
});
|
|
1529
|
+
}
|
|
1530
|
+
/** Answer `rating_request`: 1 (bad) to 5 (great), a comment if the person
|
|
1531
|
+
* wrote one. Each question takes one answer; a second one is a 404. */
|
|
1532
|
+
async rate(id, answer, opts = {}) {
|
|
1533
|
+
await this.http.post(`/me/support/ratings/${encodeURIComponent(id)}`, {
|
|
1534
|
+
body: { rating: answer.rating, ...answer.comment ? { comment: answer.comment } : {} },
|
|
1535
|
+
signal: opts.signal
|
|
1536
|
+
});
|
|
1537
|
+
}
|
|
1538
|
+
/** Just the conversation's status. */
|
|
1539
|
+
async status(opts = {}) {
|
|
1540
|
+
return (await this.list({ limit: 1, signal: opts.signal })).status;
|
|
1541
|
+
}
|
|
1542
|
+
};
|
|
1543
|
+
|
|
1410
1544
|
// src/resources/funding-options.ts
|
|
1411
1545
|
var FundingOptionsResource = class {
|
|
1412
1546
|
constructor(http) {
|
|
@@ -1419,7 +1553,7 @@ var FundingOptionsResource = class {
|
|
|
1419
1553
|
};
|
|
1420
1554
|
|
|
1421
1555
|
// src/version.ts
|
|
1422
|
-
var SDK_VERSION = "0.6.
|
|
1556
|
+
var SDK_VERSION = "0.6.8";
|
|
1423
1557
|
|
|
1424
1558
|
// src/client-platform.ts
|
|
1425
1559
|
var CLIENT_HEADER = "X-Takeal-Client";
|
|
@@ -1494,7 +1628,7 @@ function isAbsolute(url) {
|
|
|
1494
1628
|
}
|
|
1495
1629
|
|
|
1496
1630
|
// src/compat.ts
|
|
1497
|
-
var SUPPORTED_MEISTER = ">=0.6.
|
|
1631
|
+
var SUPPORTED_MEISTER = ">=0.6.13, <1.0.0";
|
|
1498
1632
|
var SEMVER = /^v?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/;
|
|
1499
1633
|
function parse(v) {
|
|
1500
1634
|
const m = SEMVER.exec(v.trim());
|
|
@@ -1591,6 +1725,7 @@ function createClient(opts) {
|
|
|
1591
1725
|
bonus: new BonusResource(http),
|
|
1592
1726
|
debt: new DebtResource(http),
|
|
1593
1727
|
closeRequests: new CloseRequestsResource(http),
|
|
1728
|
+
claims: new ClaimsResource(http),
|
|
1594
1729
|
codes: new CodesResource(http),
|
|
1595
1730
|
referral: new ReferralResource(http),
|
|
1596
1731
|
subscription: new SubscriptionResource(http),
|
|
@@ -1607,7 +1742,8 @@ function createClient(opts) {
|
|
|
1607
1742
|
attribution: new AttributionResource(http),
|
|
1608
1743
|
history: new HistoryResource(http),
|
|
1609
1744
|
consents: new ConsentsResource(http),
|
|
1610
|
-
receipts: new ReceiptsResource(http)
|
|
1745
|
+
receipts: new ReceiptsResource(http),
|
|
1746
|
+
support: new SupportResource(http)
|
|
1611
1747
|
};
|
|
1612
1748
|
}
|
|
1613
1749
|
function pickDefaultStore(key) {
|