@takeal/cusfront-sdk 0.6.4 → 0.6.5
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 +33 -0
- package/README.md +129 -3
- package/dist/{cards-ofoGRU9v.d.cts → cards-CEFKrVkl.d.cts} +125 -10
- package/dist/{cards-BrqeBqLV.d.ts → cards-ColpW52n.d.ts} +125 -10
- package/dist/index.cjs +121 -11
- 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 +120 -12
- package/dist/index.js.map +1 -1
- package/dist/react/index.d.cts +3 -1
- package/dist/react/index.d.ts +3 -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/cards.cjs +9 -2
- 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 +9 -2
- package/dist/resources/cards.js.map +1 -1
- package/dist/resources/close-requests.cjs +54 -0
- package/dist/resources/close-requests.cjs.map +1 -0
- package/dist/resources/close-requests.d.cts +155 -0
- package/dist/resources/close-requests.d.ts +155 -0
- package/dist/resources/close-requests.js +52 -0
- package/dist/resources/close-requests.js.map +1 -0
- package/dist/resources/consents.cjs +42 -7
- package/dist/resources/consents.cjs.map +1 -1
- package/dist/resources/consents.d.cts +58 -8
- package/dist/resources/consents.d.ts +58 -8
- package/dist/resources/consents.js +41 -8
- package/dist/resources/consents.js.map +1 -1
- package/dist/resources/debt.cjs +22 -0
- package/dist/resources/debt.cjs.map +1 -0
- package/dist/resources/debt.d.cts +76 -0
- package/dist/resources/debt.d.ts +76 -0
- package/dist/resources/debt.js +20 -0
- package/dist/resources/debt.js.map +1 -0
- 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/history.cjs.map +1 -1
- package/dist/resources/history.d.cts +12 -1
- package/dist/resources/history.d.ts +12 -1
- package/dist/resources/history.js.map +1 -1
- package/dist/resources/me.d.cts +1 -1
- package/dist/resources/me.d.ts +1 -1
- package/dist/telegram.cjs +119 -11
- package/dist/telegram.cjs.map +1 -1
- package/dist/telegram.d.cts +3 -1
- package/dist/telegram.d.ts +3 -1
- package/dist/telegram.js +119 -11
- package/dist/telegram.js.map +1 -1
- package/package.json +11 -1
package/dist/telegram.d.cts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { CusfrontClient, CreateClientOptions } from './index.cjs';
|
|
2
2
|
import { JwtIssued, TelegramUnknown } from './resources/auth.cjs';
|
|
3
3
|
import './http-DeANAoTs.cjs';
|
|
4
|
-
import './cards-
|
|
4
|
+
import './cards-CEFKrVkl.cjs';
|
|
5
5
|
import './resources/consents.cjs';
|
|
6
6
|
import './resources/balance.cjs';
|
|
7
7
|
import './resources/bonus.cjs';
|
|
8
|
+
import './resources/debt.cjs';
|
|
9
|
+
import './resources/close-requests.cjs';
|
|
8
10
|
import './resources/codes.cjs';
|
|
9
11
|
import './resources/referral.cjs';
|
|
10
12
|
import './resources/subscription.cjs';
|
package/dist/telegram.d.ts
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
1
|
import { CusfrontClient, CreateClientOptions } from './index.js';
|
|
2
2
|
import { JwtIssued, TelegramUnknown } from './resources/auth.js';
|
|
3
3
|
import './http-DeANAoTs.js';
|
|
4
|
-
import './cards-
|
|
4
|
+
import './cards-ColpW52n.js';
|
|
5
5
|
import './resources/consents.js';
|
|
6
6
|
import './resources/balance.js';
|
|
7
7
|
import './resources/bonus.js';
|
|
8
|
+
import './resources/debt.js';
|
|
9
|
+
import './resources/close-requests.js';
|
|
8
10
|
import './resources/codes.js';
|
|
9
11
|
import './resources/referral.js';
|
|
10
12
|
import './resources/subscription.js';
|
package/dist/telegram.js
CHANGED
|
@@ -181,6 +181,8 @@ var CardsResource = class {
|
|
|
181
181
|
* `Card`. On a ledger failure after provider creation, the Takeal API rolls the row
|
|
182
182
|
* to `failed` (never an orphaned active card); inspect `status` /
|
|
183
183
|
* `failure_reason` on the result.
|
|
184
|
+
* Errors: 409 `holder_data_consent_required` when the product has
|
|
185
|
+
* `holder_data_required` and the user has not agreed to it.
|
|
184
186
|
*/
|
|
185
187
|
async create(input) {
|
|
186
188
|
const { idempotencyKey, ...card } = input;
|
|
@@ -196,7 +198,9 @@ var CardsResource = class {
|
|
|
196
198
|
* `pending_payment` until the payment is confirmed. The same
|
|
197
199
|
* `idempotencyKey` returns the same order.
|
|
198
200
|
* Errors: 400 `unknown_product` / `method_not_available` / a limit of the
|
|
199
|
-
* way of paying,
|
|
201
|
+
* way of paying, 409 `holder_data_consent_required` (the product has
|
|
202
|
+
* `holder_data_required` and the user has not agreed to it), 503 no
|
|
203
|
+
* funding connector or no exchange rate.
|
|
200
204
|
*/
|
|
201
205
|
async order(input) {
|
|
202
206
|
const { idempotencyKey, ...order } = input;
|
|
@@ -358,7 +362,10 @@ var CardsResource = class {
|
|
|
358
362
|
/**
|
|
359
363
|
* Terminate the caller's own card. **One-way** — a terminated card cannot be
|
|
360
364
|
* reactivated. The optional `reason` is audited. Idempotent on an
|
|
361
|
-
* already-terminated card.
|
|
365
|
+
* already-terminated card. A card that still holds money is refused (409
|
|
366
|
+
* `move_balance_first` or `contact_support_to_close`): close it with
|
|
367
|
+
* `client.closeRequests.request(id)` instead, and the money goes back the
|
|
368
|
+
* way it was paid.
|
|
362
369
|
*/
|
|
363
370
|
async terminate(id, reason) {
|
|
364
371
|
return this.http.post(`/me/cards/${encodeURIComponent(id)}/terminate`, {
|
|
@@ -725,6 +732,72 @@ var BonusResource = class {
|
|
|
725
732
|
}
|
|
726
733
|
};
|
|
727
734
|
|
|
735
|
+
// src/resources/debt.ts
|
|
736
|
+
var DebtResource = class {
|
|
737
|
+
constructor(http) {
|
|
738
|
+
this.http = http;
|
|
739
|
+
}
|
|
740
|
+
/** What the user owes in card fees, per currency, and what for. */
|
|
741
|
+
async get(opts = {}) {
|
|
742
|
+
return this.http.get("/me/debt", { signal: opts.signal });
|
|
743
|
+
}
|
|
744
|
+
/** What the user owes in `currency`, decimal string; `"0"` when nothing. */
|
|
745
|
+
async owedIn(currency, opts = {}) {
|
|
746
|
+
const debt = await this.get(opts);
|
|
747
|
+
const want = currency.trim().toUpperCase();
|
|
748
|
+
return debt.total.find((d) => d.currency.toUpperCase() === want)?.amount ?? "0";
|
|
749
|
+
}
|
|
750
|
+
};
|
|
751
|
+
|
|
752
|
+
// src/resources/close-requests.ts
|
|
753
|
+
var CloseRequestsResource = class {
|
|
754
|
+
constructor(http) {
|
|
755
|
+
this.http = http;
|
|
756
|
+
}
|
|
757
|
+
/**
|
|
758
|
+
* Close a card that holds money, the rest going back the way it was paid.
|
|
759
|
+
* Asking again for the same card returns the same request. 404 no such
|
|
760
|
+
* card · 409 {@link CloseRequestError}: `no_balance` means the card holds
|
|
761
|
+
* nothing, close it with `cards.terminate()` · 503 the issuer can't be
|
|
762
|
+
* reached; the card stays as it was.
|
|
763
|
+
*/
|
|
764
|
+
async request(cardId, input = {}) {
|
|
765
|
+
return this.http.post(`/me/cards/${encodeURIComponent(cardId)}/close-request`, {
|
|
766
|
+
body: { reason: input.reason }
|
|
767
|
+
});
|
|
768
|
+
}
|
|
769
|
+
/** Every card close request of the user, newest first. */
|
|
770
|
+
async list(opts = {}) {
|
|
771
|
+
const res = await this.http.get("/me/close-requests", {
|
|
772
|
+
signal: opts.signal
|
|
773
|
+
});
|
|
774
|
+
return res.items;
|
|
775
|
+
}
|
|
776
|
+
/** One close request. 404 when it isn't the user's. */
|
|
777
|
+
async get(id, opts = {}) {
|
|
778
|
+
return this.http.get(`/me/close-requests/${encodeURIComponent(id)}`, {
|
|
779
|
+
signal: opts.signal
|
|
780
|
+
});
|
|
781
|
+
}
|
|
782
|
+
/** The request for this card, if the user made one. */
|
|
783
|
+
async forCard(cardId, opts = {}) {
|
|
784
|
+
const all = await this.list(opts);
|
|
785
|
+
return all.find((r) => r.card_id === cardId) ?? null;
|
|
786
|
+
}
|
|
787
|
+
/**
|
|
788
|
+
* Give a bank account or a card in the user's own name, when the request
|
|
789
|
+
* is `payout_details_required` (or `identity_check`, to correct them). 400
|
|
790
|
+
* `validation`: a name, number or bank code that doesn't look right · 409
|
|
791
|
+
* `details_not_needed`.
|
|
792
|
+
*/
|
|
793
|
+
async submitPayoutDetails(id, details) {
|
|
794
|
+
return this.http.post(
|
|
795
|
+
`/me/close-requests/${encodeURIComponent(id)}/payout-details`,
|
|
796
|
+
{ body: details }
|
|
797
|
+
);
|
|
798
|
+
}
|
|
799
|
+
};
|
|
800
|
+
|
|
728
801
|
// src/resources/codes.ts
|
|
729
802
|
var CodesResource = class {
|
|
730
803
|
constructor(http) {
|
|
@@ -1239,6 +1312,8 @@ var HistoryResource = class {
|
|
|
1239
1312
|
};
|
|
1240
1313
|
|
|
1241
1314
|
// src/resources/consents.ts
|
|
1315
|
+
var HOLDER_DATA_CONSENT = "holder_data_transfer";
|
|
1316
|
+
var DISPUTE_DOCUMENTS_CONSENT = "dispute_documents_transfer";
|
|
1242
1317
|
var ConsentsResource = class {
|
|
1243
1318
|
constructor(http) {
|
|
1244
1319
|
this.http = http;
|
|
@@ -1247,20 +1322,51 @@ var ConsentsResource = class {
|
|
|
1247
1322
|
async get() {
|
|
1248
1323
|
return this.http.get("/me/consents");
|
|
1249
1324
|
}
|
|
1325
|
+
/** Whether `kind` stands now: given and not withdrawn since. */
|
|
1326
|
+
async stands(kind) {
|
|
1327
|
+
const { consents } = await this.get();
|
|
1328
|
+
return consents.some((c) => c.kind === kind && c.given);
|
|
1329
|
+
}
|
|
1250
1330
|
/**
|
|
1251
|
-
* Give (`true`) or withdraw (`false`) an optional consent: `marketing
|
|
1252
|
-
* `cookies_analytics
|
|
1253
|
-
*
|
|
1254
|
-
*
|
|
1331
|
+
* Give (`true`) or withdraw (`false`) an optional consent: `marketing`,
|
|
1332
|
+
* `cookies_analytics`, `holder_data_transfer` or
|
|
1333
|
+
* `dispute_documents_transfer`. Withdrawing `marketing` turns advertising
|
|
1334
|
+
* off in every channel at once; giving it turns on advertising by e-mail.
|
|
1335
|
+
* Withdrawing `holder_data_transfer` leaves the user's cards alone and
|
|
1336
|
+
* stops new cards whose product has `holder_data_required`. A call that
|
|
1337
|
+
* changes nothing records nothing, unless it names a card.
|
|
1338
|
+
*
|
|
1339
|
+
* The third argument is the channel, or {@link ConsentOptions} with the
|
|
1340
|
+
* channel and the card.
|
|
1255
1341
|
*
|
|
1256
1342
|
* Errors: 400 `consent_required` for `terms` or `personal_data`,
|
|
1257
|
-
* 400 `unknown_consent
|
|
1343
|
+
* 400 `unknown_consent`, 400 `card_not_allowed` (a card named with a kind
|
|
1344
|
+
* that takes none), 404 `not_found` (not one of the user's cards).
|
|
1258
1345
|
*/
|
|
1259
|
-
async set(kind, given,
|
|
1346
|
+
async set(kind, given, options) {
|
|
1347
|
+
const opts = typeof options === "string" ? { channel: options } : options ?? {};
|
|
1260
1348
|
const body = { kind, given };
|
|
1261
|
-
if (channel !== void 0) body.channel = channel;
|
|
1349
|
+
if (opts.channel !== void 0) body.channel = opts.channel;
|
|
1350
|
+
if (opts.cardId !== void 0) body.card_id = opts.cardId;
|
|
1262
1351
|
return this.http.post("/me/consents", { body });
|
|
1263
1352
|
}
|
|
1353
|
+
/**
|
|
1354
|
+
* The user agreed on the consent screen that their real personal details
|
|
1355
|
+
* go to the card issuer (`holder_data_transfer`). Needed before ordering a
|
|
1356
|
+
* product with `holder_data_required`, unless the order itself carries the
|
|
1357
|
+
* kind in its `consents`.
|
|
1358
|
+
*/
|
|
1359
|
+
async allowHolderData(options) {
|
|
1360
|
+
return this.set(HOLDER_DATA_CONSENT, true, options);
|
|
1361
|
+
}
|
|
1362
|
+
/**
|
|
1363
|
+
* The user agreed that their documents go to the card issuer for a
|
|
1364
|
+
* dispute (`dispute_documents_transfer`). Name the disputed card with
|
|
1365
|
+
* `cardId`; each call is then recorded on its own.
|
|
1366
|
+
*/
|
|
1367
|
+
async allowDisputeDocuments(options) {
|
|
1368
|
+
return this.set(DISPUTE_DOCUMENTS_CONSENT, true, options);
|
|
1369
|
+
}
|
|
1264
1370
|
/**
|
|
1265
1371
|
* Record what the cookie banner or the cookie settings say about
|
|
1266
1372
|
* analytics. Works signed in or not: before sign-in the choice is kept
|
|
@@ -1313,7 +1419,7 @@ var FundingOptionsResource = class {
|
|
|
1313
1419
|
};
|
|
1314
1420
|
|
|
1315
1421
|
// src/version.ts
|
|
1316
|
-
var SDK_VERSION = "0.6.
|
|
1422
|
+
var SDK_VERSION = "0.6.5";
|
|
1317
1423
|
|
|
1318
1424
|
// src/client-platform.ts
|
|
1319
1425
|
var CLIENT_HEADER = "X-Takeal-Client";
|
|
@@ -1388,7 +1494,7 @@ function isAbsolute(url) {
|
|
|
1388
1494
|
}
|
|
1389
1495
|
|
|
1390
1496
|
// src/compat.ts
|
|
1391
|
-
var SUPPORTED_MEISTER = ">=0.6.
|
|
1497
|
+
var SUPPORTED_MEISTER = ">=0.6.11, <0.7.0";
|
|
1392
1498
|
var SEMVER = /^v?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/;
|
|
1393
1499
|
function parse(v) {
|
|
1394
1500
|
const m = SEMVER.exec(v.trim());
|
|
@@ -1483,6 +1589,8 @@ function createClient(opts) {
|
|
|
1483
1589
|
cards: new CardsResource(http),
|
|
1484
1590
|
balance: new BalanceResource(http),
|
|
1485
1591
|
bonus: new BonusResource(http),
|
|
1592
|
+
debt: new DebtResource(http),
|
|
1593
|
+
closeRequests: new CloseRequestsResource(http),
|
|
1486
1594
|
codes: new CodesResource(http),
|
|
1487
1595
|
referral: new ReferralResource(http),
|
|
1488
1596
|
subscription: new SubscriptionResource(http),
|