@takeal/cusfront-sdk 0.8.4 → 0.9.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 +57 -0
- package/README.md +46 -5
- package/dist/analytics.cjs +74 -22
- package/dist/analytics.cjs.map +1 -1
- package/dist/analytics.d.cts +43 -4
- package/dist/analytics.d.ts +43 -4
- package/dist/analytics.js +71 -23
- package/dist/analytics.js.map +1 -1
- package/dist/{cards-DwxkVJUB.d.cts → cards-C5rk0XkI.d.cts} +47 -5
- package/dist/{cards-VkS_2lPe.d.ts → cards-CS-oxqLS.d.ts} +47 -5
- package/dist/index.cjs +94 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +13 -5
- package/dist/index.d.ts +13 -5
- package/dist/index.js +91 -27
- package/dist/index.js.map +1 -1
- package/dist/react/index.d.cts +1 -1
- package/dist/react/index.d.ts +1 -1
- package/dist/resources/auth.cjs.map +1 -1
- package/dist/resources/auth.d.cts +1 -1
- package/dist/resources/auth.d.ts +1 -1
- package/dist/resources/auth.js.map +1 -1
- package/dist/resources/branding.cjs.map +1 -1
- package/dist/resources/branding.d.cts +6 -0
- package/dist/resources/branding.d.ts +6 -0
- package/dist/resources/branding.js.map +1 -1
- 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.map +1 -1
- package/dist/resources/deposits.cjs.map +1 -1
- package/dist/resources/deposits.d.cts +1 -1
- package/dist/resources/deposits.d.ts +1 -1
- package/dist/resources/deposits.js.map +1 -1
- package/dist/resources/funding-options.d.cts +1 -1
- package/dist/resources/funding-options.d.ts +1 -1
- package/dist/resources/me.d.cts +1 -1
- package/dist/resources/me.d.ts +1 -1
- package/dist/telegram.cjs +20 -4
- package/dist/telegram.cjs.map +1 -1
- package/dist/telegram.d.cts +1 -1
- package/dist/telegram.d.ts +1 -1
- package/dist/telegram.js +20 -4
- package/dist/telegram.js.map +1 -1
- package/package.json +1 -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
3
|
import './http-CL97TjMO.cjs';
|
|
4
|
-
import './cards-
|
|
4
|
+
import './cards-C5rk0XkI.cjs';
|
|
5
5
|
import './resources/claims.cjs';
|
|
6
6
|
import './resources/codes.cjs';
|
|
7
7
|
import './resources/consents.cjs';
|
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
3
|
import './http-CL97TjMO.js';
|
|
4
|
-
import './cards-
|
|
4
|
+
import './cards-CS-oxqLS.js';
|
|
5
5
|
import './resources/claims.js';
|
|
6
6
|
import './resources/codes.js';
|
|
7
7
|
import './resources/consents.js';
|
package/dist/telegram.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
// src/error.ts
|
|
2
2
|
var ApiError = class extends Error {
|
|
3
|
-
constructor(status, code, message, body) {
|
|
3
|
+
constructor(status, code, message, body, retryAfterSeconds) {
|
|
4
4
|
super(message);
|
|
5
5
|
this.status = status;
|
|
6
6
|
this.code = code;
|
|
7
7
|
this.body = body;
|
|
8
|
+
this.retryAfterSeconds = retryAfterSeconds;
|
|
8
9
|
this.isApiError = true;
|
|
9
10
|
this.name = "ApiError";
|
|
10
11
|
}
|
|
@@ -136,11 +137,20 @@ async function parseResponse(resp) {
|
|
|
136
137
|
resp.status,
|
|
137
138
|
errBody.code ?? `http_${resp.status}`,
|
|
138
139
|
errBody.message ?? resp.statusText ?? "request failed",
|
|
139
|
-
body
|
|
140
|
+
body,
|
|
141
|
+
retryAfter(resp.headers?.get("Retry-After"))
|
|
140
142
|
);
|
|
141
143
|
}
|
|
142
144
|
return body;
|
|
143
145
|
}
|
|
146
|
+
function retryAfter(v, now = Date.now()) {
|
|
147
|
+
if (!v) return void 0;
|
|
148
|
+
const t = v.trim();
|
|
149
|
+
if (/^\d+$/.test(t)) return Number(t);
|
|
150
|
+
const at = Date.parse(t);
|
|
151
|
+
if (Number.isNaN(at)) return void 0;
|
|
152
|
+
return Math.max(0, Math.ceil((at - now) / 1e3));
|
|
153
|
+
}
|
|
144
154
|
|
|
145
155
|
// src/resources/attribution.ts
|
|
146
156
|
var AttributionResource = class {
|
|
@@ -1771,7 +1781,7 @@ var FundingOptionsResource = class {
|
|
|
1771
1781
|
};
|
|
1772
1782
|
|
|
1773
1783
|
// src/version.ts
|
|
1774
|
-
var SDK_VERSION = "0.
|
|
1784
|
+
var SDK_VERSION = "0.9.0";
|
|
1775
1785
|
|
|
1776
1786
|
// src/client-platform.ts
|
|
1777
1787
|
var CLIENT_HEADER = "X-Takeal-Client";
|
|
@@ -1908,12 +1918,18 @@ function readyInfo(raw, healthy) {
|
|
|
1908
1918
|
}
|
|
1909
1919
|
return { ...base, compatible: true };
|
|
1910
1920
|
}
|
|
1921
|
+
function isReadyBody(body) {
|
|
1922
|
+
if (typeof body !== "object" || body === null || Array.isArray(body)) return false;
|
|
1923
|
+
const b = body;
|
|
1924
|
+
const block = (v) => typeof v === "object" && v !== null;
|
|
1925
|
+
return b.code !== "service_unavailable" && typeof b.status === "string" && (block(b.checks) || block(b.ops));
|
|
1926
|
+
}
|
|
1911
1927
|
async function fetchReady(http, opts = {}) {
|
|
1912
1928
|
try {
|
|
1913
1929
|
const body = await http.get("/ready", { skipAuth: true, signal: opts.signal });
|
|
1914
1930
|
return readyInfo(body ?? {}, true);
|
|
1915
1931
|
} catch (e) {
|
|
1916
|
-
if (isApiError(e) && e.status === 503 &&
|
|
1932
|
+
if (isApiError(e) && e.status === 503 && isReadyBody(e.body)) {
|
|
1917
1933
|
return readyInfo(e.body, false);
|
|
1918
1934
|
}
|
|
1919
1935
|
throw e;
|