@takeal/cusfront-sdk 0.6.3 → 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 +48 -0
- package/README.md +175 -12
- 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 +160 -11
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -6
- package/dist/index.d.ts +14 -6
- package/dist/index.js +159 -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 +39 -0
- package/dist/resources/auth.cjs.map +1 -1
- package/dist/resources/auth.d.cts +76 -3
- package/dist/resources/auth.d.ts +76 -3
- package/dist/resources/auth.js +39 -0
- 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 +158 -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 +158 -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`, {
|
|
@@ -475,6 +482,45 @@ var AuthResource = class {
|
|
|
475
482
|
await this.keep(resp);
|
|
476
483
|
return resp;
|
|
477
484
|
}
|
|
485
|
+
/** Step one of signing in without a password: a six-digit code goes to
|
|
486
|
+
* the address. It works for an address with an account and for a new one
|
|
487
|
+
* alike, and the answer doesn't say which. The code works for 10 minutes;
|
|
488
|
+
* another can be asked for after `resend_at` and replaces it.
|
|
489
|
+
* Errors: 400 `validation` (not an address), 429 `resend_too_soon` /
|
|
490
|
+
* `too_many_requests` (the message says when to try again), 503
|
|
491
|
+
* `delivery_failed`. */
|
|
492
|
+
async requestEmailCode(input) {
|
|
493
|
+
const body = { email: input.email };
|
|
494
|
+
if (input.locale !== void 0) body["locale"] = input.locale;
|
|
495
|
+
return this.http.post("/auth/email-code", { body, skipAuth: true });
|
|
496
|
+
}
|
|
497
|
+
/** Step two: the code signs in to the account with that address, or
|
|
498
|
+
* creates one (no password) when there is none; `account_created` says
|
|
499
|
+
* which. The JWT is stored. With `cardOrder`, the card is ordered for
|
|
500
|
+
* that account in the same call.
|
|
501
|
+
* Errors: 401 `invalid_code` (wrong, expired or used; after five checks a
|
|
502
|
+
* new code is needed), 400 `consents_required` for a new account, 403
|
|
503
|
+
* `user_disabled` / `second_factor_required` (operator accounts sign in
|
|
504
|
+
* with a password and their authenticator). */
|
|
505
|
+
async verifyEmailCode(input) {
|
|
506
|
+
const body = {
|
|
507
|
+
challenge_id: input.challengeId,
|
|
508
|
+
code: input.code
|
|
509
|
+
};
|
|
510
|
+
if (input.remember) body["remember_me"] = true;
|
|
511
|
+
if (input.walletCurrency !== void 0) body["wallet_currency"] = input.walletCurrency;
|
|
512
|
+
if (input.attribution !== void 0) body["attribution"] = input.attribution;
|
|
513
|
+
if (input.promoCode !== void 0) body["promo_code"] = input.promoCode;
|
|
514
|
+
if (input.consents !== void 0) body["consents"] = input.consents;
|
|
515
|
+
if (input.consentChannel !== void 0) body["consent_channel"] = input.consentChannel;
|
|
516
|
+
if (input.cardOrder !== void 0) body["card_order"] = cardOrderBody(input.cardOrder);
|
|
517
|
+
const resp = await this.http.post("/auth/email-code/verify", {
|
|
518
|
+
body,
|
|
519
|
+
skipAuth: true
|
|
520
|
+
});
|
|
521
|
+
await this.keep(resp);
|
|
522
|
+
return resp;
|
|
523
|
+
}
|
|
478
524
|
/** Finish a `totp_setup_required` login: send the first code from the
|
|
479
525
|
* authenticator app. The JWT is stored. The response carries ten
|
|
480
526
|
* one-time `backup_codes` that are never returned again, so show them to
|
|
@@ -686,6 +732,72 @@ var BonusResource = class {
|
|
|
686
732
|
}
|
|
687
733
|
};
|
|
688
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
|
+
|
|
689
801
|
// src/resources/codes.ts
|
|
690
802
|
var CodesResource = class {
|
|
691
803
|
constructor(http) {
|
|
@@ -1200,6 +1312,8 @@ var HistoryResource = class {
|
|
|
1200
1312
|
};
|
|
1201
1313
|
|
|
1202
1314
|
// src/resources/consents.ts
|
|
1315
|
+
var HOLDER_DATA_CONSENT = "holder_data_transfer";
|
|
1316
|
+
var DISPUTE_DOCUMENTS_CONSENT = "dispute_documents_transfer";
|
|
1203
1317
|
var ConsentsResource = class {
|
|
1204
1318
|
constructor(http) {
|
|
1205
1319
|
this.http = http;
|
|
@@ -1208,20 +1322,51 @@ var ConsentsResource = class {
|
|
|
1208
1322
|
async get() {
|
|
1209
1323
|
return this.http.get("/me/consents");
|
|
1210
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
|
+
}
|
|
1211
1330
|
/**
|
|
1212
|
-
* Give (`true`) or withdraw (`false`) an optional consent: `marketing
|
|
1213
|
-
* `cookies_analytics
|
|
1214
|
-
*
|
|
1215
|
-
*
|
|
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.
|
|
1216
1341
|
*
|
|
1217
1342
|
* Errors: 400 `consent_required` for `terms` or `personal_data`,
|
|
1218
|
-
* 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).
|
|
1219
1345
|
*/
|
|
1220
|
-
async set(kind, given,
|
|
1346
|
+
async set(kind, given, options) {
|
|
1347
|
+
const opts = typeof options === "string" ? { channel: options } : options ?? {};
|
|
1221
1348
|
const body = { kind, given };
|
|
1222
|
-
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;
|
|
1223
1351
|
return this.http.post("/me/consents", { body });
|
|
1224
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
|
+
}
|
|
1225
1370
|
/**
|
|
1226
1371
|
* Record what the cookie banner or the cookie settings say about
|
|
1227
1372
|
* analytics. Works signed in or not: before sign-in the choice is kept
|
|
@@ -1274,7 +1419,7 @@ var FundingOptionsResource = class {
|
|
|
1274
1419
|
};
|
|
1275
1420
|
|
|
1276
1421
|
// src/version.ts
|
|
1277
|
-
var SDK_VERSION = "0.6.
|
|
1422
|
+
var SDK_VERSION = "0.6.5";
|
|
1278
1423
|
|
|
1279
1424
|
// src/client-platform.ts
|
|
1280
1425
|
var CLIENT_HEADER = "X-Takeal-Client";
|
|
@@ -1349,7 +1494,7 @@ function isAbsolute(url) {
|
|
|
1349
1494
|
}
|
|
1350
1495
|
|
|
1351
1496
|
// src/compat.ts
|
|
1352
|
-
var SUPPORTED_MEISTER = ">=0.6.
|
|
1497
|
+
var SUPPORTED_MEISTER = ">=0.6.11, <0.7.0";
|
|
1353
1498
|
var SEMVER = /^v?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/;
|
|
1354
1499
|
function parse(v) {
|
|
1355
1500
|
const m = SEMVER.exec(v.trim());
|
|
@@ -1444,6 +1589,8 @@ function createClient(opts) {
|
|
|
1444
1589
|
cards: new CardsResource(http),
|
|
1445
1590
|
balance: new BalanceResource(http),
|
|
1446
1591
|
bonus: new BonusResource(http),
|
|
1592
|
+
debt: new DebtResource(http),
|
|
1593
|
+
closeRequests: new CloseRequestsResource(http),
|
|
1447
1594
|
codes: new CodesResource(http),
|
|
1448
1595
|
referral: new ReferralResource(http),
|
|
1449
1596
|
subscription: new SubscriptionResource(http),
|