@takeal/cusfront-sdk 0.6.5 → 0.6.6
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 +13 -0
- package/README.md +53 -0
- package/dist/{cards-CEFKrVkl.d.cts → cards-BiXmrz7h.d.cts} +1 -1
- package/dist/{cards-ColpW52n.d.ts → cards-DwmzjKDC.d.ts} +1 -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 +81 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -9
- package/dist/index.d.ts +13 -9
- package/dist/index.js +81 -6
- package/dist/index.js.map +1 -1
- package/dist/react/index.d.cts +4 -3
- package/dist/react/index.d.ts +4 -3
- package/dist/resources/attribution.d.cts +1 -1
- package/dist/resources/attribution.d.ts +1 -1
- package/dist/resources/auth.d.cts +2 -2
- package/dist/resources/auth.d.ts +2 -2
- 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.d.cts +2 -2
- package/dist/resources/cards.d.ts +2 -2
- 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.d.cts +2 -2
- package/dist/resources/deposits.d.ts +2 -2
- 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 +2 -2
- package/dist/resources/funding-options.d.ts +2 -2
- package/dist/resources/history.d.cts +1 -1
- package/dist/resources/history.d.ts +1 -1
- package/dist/resources/me.d.cts +2 -2
- package/dist/resources/me.d.ts +2 -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.d.cts +1 -1
- package/dist/resources/subscription.d.ts +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 +110 -0
- package/dist/resources/support.d.ts +110 -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 +81 -6
- package/dist/telegram.cjs.map +1 -1
- package/dist/telegram.d.cts +4 -3
- package/dist/telegram.d.ts +4 -3
- package/dist/telegram.js +81 -6
- package/dist/telegram.js.map +1 -1
- package/package.json +6 -1
package/dist/telegram.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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-BiXmrz7h.cjs';
|
|
5
5
|
import './resources/consents.cjs';
|
|
6
6
|
import './resources/balance.cjs';
|
|
7
7
|
import './resources/bonus.cjs';
|
|
@@ -19,10 +19,11 @@ import './resources/sessions.cjs';
|
|
|
19
19
|
import './resources/push.cjs';
|
|
20
20
|
import './resources/me.cjs';
|
|
21
21
|
import './resources/notifications.cjs';
|
|
22
|
-
import './devices-
|
|
22
|
+
import './devices-CiJrlXum.cjs';
|
|
23
23
|
import './resources/attribution.cjs';
|
|
24
24
|
import './resources/history.cjs';
|
|
25
25
|
import './resources/receipts.cjs';
|
|
26
|
+
import './resources/support.cjs';
|
|
26
27
|
import './analytics.cjs';
|
|
27
28
|
|
|
28
29
|
/**
|
package/dist/telegram.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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-DwmzjKDC.js';
|
|
5
5
|
import './resources/consents.js';
|
|
6
6
|
import './resources/balance.js';
|
|
7
7
|
import './resources/bonus.js';
|
|
@@ -19,10 +19,11 @@ import './resources/sessions.js';
|
|
|
19
19
|
import './resources/push.js';
|
|
20
20
|
import './resources/me.js';
|
|
21
21
|
import './resources/notifications.js';
|
|
22
|
-
import './devices-
|
|
22
|
+
import './devices-C88c38hm.js';
|
|
23
23
|
import './resources/attribution.js';
|
|
24
24
|
import './resources/history.js';
|
|
25
25
|
import './resources/receipts.js';
|
|
26
|
+
import './resources/support.js';
|
|
26
27
|
import './analytics.js';
|
|
27
28
|
|
|
28
29
|
/**
|
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;
|
|
@@ -1407,6 +1417,70 @@ var ReceiptsResource = class {
|
|
|
1407
1417
|
}
|
|
1408
1418
|
};
|
|
1409
1419
|
|
|
1420
|
+
// src/resources/support.ts
|
|
1421
|
+
function bytesToBase64(bytes) {
|
|
1422
|
+
let binary = "";
|
|
1423
|
+
const chunk = 32768;
|
|
1424
|
+
for (let i = 0; i < bytes.length; i += chunk) {
|
|
1425
|
+
binary += String.fromCharCode(...bytes.subarray(i, i + chunk));
|
|
1426
|
+
}
|
|
1427
|
+
return btoa(binary);
|
|
1428
|
+
}
|
|
1429
|
+
async function toBase64(data) {
|
|
1430
|
+
if (typeof data === "string") return data;
|
|
1431
|
+
if (data instanceof Uint8Array) return bytesToBase64(data);
|
|
1432
|
+
if (data instanceof ArrayBuffer) return bytesToBase64(new Uint8Array(data));
|
|
1433
|
+
return bytesToBase64(new Uint8Array(await data.arrayBuffer()));
|
|
1434
|
+
}
|
|
1435
|
+
var SupportResource = class {
|
|
1436
|
+
constructor(http) {
|
|
1437
|
+
this.http = http;
|
|
1438
|
+
}
|
|
1439
|
+
/** The latest messages, oldest first, and the conversation's status.
|
|
1440
|
+
* `before` reads further back; `limit` is 1 to 100 (50). */
|
|
1441
|
+
async list(opts = {}) {
|
|
1442
|
+
const q = new URLSearchParams();
|
|
1443
|
+
if (opts.before) q.set("before", opts.before);
|
|
1444
|
+
if (opts.limit !== void 0) q.set("limit", String(opts.limit));
|
|
1445
|
+
const qs = q.toString();
|
|
1446
|
+
return this.http.get(`/me/support/messages${qs ? `?${qs}` : ""}`, {
|
|
1447
|
+
signal: opts.signal
|
|
1448
|
+
});
|
|
1449
|
+
}
|
|
1450
|
+
/** Write to support. Text, files or both; up to 10 files. */
|
|
1451
|
+
async send(message, opts = {}) {
|
|
1452
|
+
const attachments = await Promise.all(
|
|
1453
|
+
(message.files ?? []).map(async (f) => ({
|
|
1454
|
+
file_name: f.fileName,
|
|
1455
|
+
content_type: f.contentType,
|
|
1456
|
+
data_base64: await toBase64(f.data)
|
|
1457
|
+
}))
|
|
1458
|
+
);
|
|
1459
|
+
return this.http.post("/me/support/messages", {
|
|
1460
|
+
body: { text: message.text ?? "", attachments },
|
|
1461
|
+
signal: opts.signal
|
|
1462
|
+
});
|
|
1463
|
+
}
|
|
1464
|
+
/** A file from the conversation: the person's own or one support sent. */
|
|
1465
|
+
async attachment(id, opts = {}) {
|
|
1466
|
+
return this.http.getBlob(`/me/support/attachments/${encodeURIComponent(id)}`, {
|
|
1467
|
+
signal: opts.signal
|
|
1468
|
+
});
|
|
1469
|
+
}
|
|
1470
|
+
/** Answer `rating_request`: 1 (bad) to 5 (great), a comment if the person
|
|
1471
|
+
* wrote one. Each question takes one answer; a second one is a 404. */
|
|
1472
|
+
async rate(id, answer, opts = {}) {
|
|
1473
|
+
await this.http.post(`/me/support/ratings/${encodeURIComponent(id)}`, {
|
|
1474
|
+
body: { rating: answer.rating, ...answer.comment ? { comment: answer.comment } : {} },
|
|
1475
|
+
signal: opts.signal
|
|
1476
|
+
});
|
|
1477
|
+
}
|
|
1478
|
+
/** Just the conversation's status. */
|
|
1479
|
+
async status(opts = {}) {
|
|
1480
|
+
return (await this.list({ limit: 1, signal: opts.signal })).status;
|
|
1481
|
+
}
|
|
1482
|
+
};
|
|
1483
|
+
|
|
1410
1484
|
// src/resources/funding-options.ts
|
|
1411
1485
|
var FundingOptionsResource = class {
|
|
1412
1486
|
constructor(http) {
|
|
@@ -1419,7 +1493,7 @@ var FundingOptionsResource = class {
|
|
|
1419
1493
|
};
|
|
1420
1494
|
|
|
1421
1495
|
// src/version.ts
|
|
1422
|
-
var SDK_VERSION = "0.6.
|
|
1496
|
+
var SDK_VERSION = "0.6.6";
|
|
1423
1497
|
|
|
1424
1498
|
// src/client-platform.ts
|
|
1425
1499
|
var CLIENT_HEADER = "X-Takeal-Client";
|
|
@@ -1494,7 +1568,7 @@ function isAbsolute(url) {
|
|
|
1494
1568
|
}
|
|
1495
1569
|
|
|
1496
1570
|
// src/compat.ts
|
|
1497
|
-
var SUPPORTED_MEISTER = ">=0.6.
|
|
1571
|
+
var SUPPORTED_MEISTER = ">=0.6.12, <0.7.0";
|
|
1498
1572
|
var SEMVER = /^v?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/;
|
|
1499
1573
|
function parse(v) {
|
|
1500
1574
|
const m = SEMVER.exec(v.trim());
|
|
@@ -1607,7 +1681,8 @@ function createClient(opts) {
|
|
|
1607
1681
|
attribution: new AttributionResource(http),
|
|
1608
1682
|
history: new HistoryResource(http),
|
|
1609
1683
|
consents: new ConsentsResource(http),
|
|
1610
|
-
receipts: new ReceiptsResource(http)
|
|
1684
|
+
receipts: new ReceiptsResource(http),
|
|
1685
|
+
support: new SupportResource(http)
|
|
1611
1686
|
};
|
|
1612
1687
|
}
|
|
1613
1688
|
function pickDefaultStore(key) {
|