@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/index.d.cts
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import { T as TokenStore, F as FetchLike } from './http-DeANAoTs.cjs';
|
|
2
2
|
export { d as defaultBrowserStore, i as inMemoryStore } from './http-DeANAoTs.cjs';
|
|
3
3
|
import { AuthResource } from './resources/auth.cjs';
|
|
4
|
-
export { ChangePasswordInput, EmailChangeRequested, ExchangeTelegramInput, JwtIssued, LinkTelegramInput, LoginInput, LoginResponse, OtpSentResponse, RegisterInput, Session, TelegramLink, TelegramUnknown, TotpRequired, TotpSetupComplete, TotpSetupRequired, User } from './resources/auth.cjs';
|
|
5
|
-
import { b as DepositsResource, F as FundingOptionsResource, c as CardsResource } from './cards-
|
|
6
|
-
export { A as Address, B as BillingAddress, a as Card, d as CardBalance, e as CardDesignRef, f as CardForm, g as
|
|
4
|
+
export { ChangePasswordInput, EmailChangeRequested, EmailCodeSent, EmailCodeSession, ExchangeTelegramInput, JwtIssued, LinkTelegramInput, LoginInput, LoginResponse, OtpSentResponse, RegisterInput, RequestEmailCodeInput, Session, TelegramLink, TelegramUnknown, TotpRequired, TotpSetupComplete, TotpSetupRequired, User, VerifyEmailCodeInput } from './resources/auth.cjs';
|
|
5
|
+
import { b as DepositsResource, F as FundingOptionsResource, c as CardsResource } from './cards-CEFKrVkl.cjs';
|
|
6
|
+
export { A as Address, B as BillingAddress, a as Card, d as CardBalance, e as CardDesignRef, f as CardForm, g as CardInTransit, h as CardLoadStatus, i as CardOrder, j as CardOrderError, k as CardOrderInput, C as CardProduct, l as CardProductPrice, m as CardStatus, n as CardStatusSource, o as CardTariff, p as CardTopUp, q as CardTopUpStatus, r as CardTransfer, s as CardType, t as Cardholder, u as CloseBlockedReason, v as CreateCardInput, w as CreateDepositRefundInput, x as CreateQuoteInput, y as CustomerInfo, D as Deposit, z as DepositMethod, E as DepositStatus, G as DepositTarget, H as FeeKind, I as FunderMode, J as FundingOption, K as FundingQuote, L as InitiateDepositInput, M as IssuanceBonus, N as IssueCardInput, O as MethodTerms, R as Refund, P as RevealCardInput, Q as RevealedCard, S as SetPinInput, T as TopUpInput, U as TopUpResult, V as TopUpTerms, W as TransferInput, X as TransferResult, Y as UpdateCardInput } from './cards-CEFKrVkl.cjs';
|
|
7
7
|
import { BalanceResource } from './resources/balance.cjs';
|
|
8
8
|
export { Balance } from './resources/balance.cjs';
|
|
9
9
|
import { BonusResource } from './resources/bonus.cjs';
|
|
10
10
|
export { BonusLot, BonusMovement, BonusPreview, BonusPreviewInput, BonusPurpose, BonusTarget, BonusWallet } from './resources/bonus.cjs';
|
|
11
|
+
import { DebtResource } from './resources/debt.cjs';
|
|
12
|
+
export { CardFeeKind, Debt, DebtAmount, DebtLine } from './resources/debt.cjs';
|
|
13
|
+
import { CloseRequestsResource } from './resources/close-requests.cjs';
|
|
14
|
+
export { CloseAmount, CloseRefund, CloseRequest, CloseRequestError, CloseRequestStatus, PayoutDetailsInput, PayoutDetailsShown } from './resources/close-requests.cjs';
|
|
11
15
|
import { CodesResource } from './resources/codes.cjs';
|
|
12
16
|
export { CodeCheck, CodeDiscount, CodeEffect, CodeEffectOutcome, CodeOperation, CodeRejection, CodeResult, ValidateCodeInput } from './resources/codes.cjs';
|
|
13
17
|
import { ReferralResource } from './resources/referral.cjs';
|
|
@@ -38,7 +42,7 @@ export { AnonymousKeyOptions, AttributionStatus, SignupAttribution, SurveyAnswer
|
|
|
38
42
|
import { HistoryResource } from './resources/history.cjs';
|
|
39
43
|
export { HistoryAmount, HistoryCard, HistoryItem, HistoryKind, HistoryPage, HistoryStatus, ListHistoryParams } from './resources/history.cjs';
|
|
40
44
|
import { ConsentsResource } from './resources/consents.cjs';
|
|
41
|
-
export { ConsentChannel, ConsentDocument, ConsentKind, ConsentState, Consents, CookieChoiceInput } from './resources/consents.cjs';
|
|
45
|
+
export { ConsentChannel, ConsentDocument, ConsentKind, ConsentOptions, ConsentState, Consents, CookieChoiceInput, DISPUTE_DOCUMENTS_CONSENT, HOLDER_DATA_CONSENT } from './resources/consents.cjs';
|
|
42
46
|
import { ReceiptsResource } from './resources/receipts.cjs';
|
|
43
47
|
export { ListReceiptsParams, Receipt, ReceiptKind } from './resources/receipts.cjs';
|
|
44
48
|
export { ANALYTICS_EVENTS, AnalyticsEvent, AnalyticsOptions, AnalyticsProperties, AnalyticsZone, METRIKA_GOALS, MetrikaOptions, NO_CAPTURE_CLASS, PostHogLike, PostHogOptions, identify, initAnalytics, page, posthogDistinctId, resetAnalytics, sanitizeProperties, sanitizeUrl, setAnalyticsZone, track } from './analytics.cjs';
|
|
@@ -73,7 +77,7 @@ interface BrandConfig {
|
|
|
73
77
|
* Which platform versions this SDK works with, as a semver range:
|
|
74
78
|
* comparators separated by ", ". Keep this the only definition.
|
|
75
79
|
*/
|
|
76
|
-
declare const SUPPORTED_MEISTER = ">=0.6.
|
|
80
|
+
declare const SUPPORTED_MEISTER = ">=0.6.11, <0.7.0";
|
|
77
81
|
/** What `client.ready()` returns. */
|
|
78
82
|
interface ReadyInfo {
|
|
79
83
|
/** `true` when the platform reported a version inside `supportedMeister`. */
|
|
@@ -179,7 +183,7 @@ declare function isNetworkError(e: unknown): e is NetworkError;
|
|
|
179
183
|
* `define`. `src/version.test.ts` checks it matches `package.json`, so a
|
|
180
184
|
* release bump that forgets this file fails the test run.
|
|
181
185
|
*/
|
|
182
|
-
declare const SDK_VERSION = "0.6.
|
|
186
|
+
declare const SDK_VERSION = "0.6.5";
|
|
183
187
|
|
|
184
188
|
/**
|
|
185
189
|
* `@takeal/cusfront-sdk` — typed client for the Takeal end-user API.
|
|
@@ -242,6 +246,10 @@ interface CusfrontClient {
|
|
|
242
246
|
readonly balance: BalanceResource;
|
|
243
247
|
/** Bonuses: a discount on the platform's services. Balance, credits, history and a price preview. */
|
|
244
248
|
readonly bonus: BonusResource;
|
|
249
|
+
/** Card fees the user's cards could not cover: paid first from the next top-up. */
|
|
250
|
+
readonly debt: DebtResource;
|
|
251
|
+
/** Close a card that still holds money: the rest goes back the way it was paid. */
|
|
252
|
+
readonly closeRequests: CloseRequestsResource;
|
|
245
253
|
/** Promo and referral codes: check what a code would do before using it. */
|
|
246
254
|
readonly codes: CodesResource;
|
|
247
255
|
/** For referrers: the referral code, the link to share, invited friends and rewards. */
|
package/dist/index.d.ts
CHANGED
|
@@ -1,13 +1,17 @@
|
|
|
1
1
|
import { T as TokenStore, F as FetchLike } from './http-DeANAoTs.js';
|
|
2
2
|
export { d as defaultBrowserStore, i as inMemoryStore } from './http-DeANAoTs.js';
|
|
3
3
|
import { AuthResource } from './resources/auth.js';
|
|
4
|
-
export { ChangePasswordInput, EmailChangeRequested, ExchangeTelegramInput, JwtIssued, LinkTelegramInput, LoginInput, LoginResponse, OtpSentResponse, RegisterInput, Session, TelegramLink, TelegramUnknown, TotpRequired, TotpSetupComplete, TotpSetupRequired, User } from './resources/auth.js';
|
|
5
|
-
import { b as DepositsResource, F as FundingOptionsResource, c as CardsResource } from './cards-
|
|
6
|
-
export { A as Address, B as BillingAddress, a as Card, d as CardBalance, e as CardDesignRef, f as CardForm, g as
|
|
4
|
+
export { ChangePasswordInput, EmailChangeRequested, EmailCodeSent, EmailCodeSession, ExchangeTelegramInput, JwtIssued, LinkTelegramInput, LoginInput, LoginResponse, OtpSentResponse, RegisterInput, RequestEmailCodeInput, Session, TelegramLink, TelegramUnknown, TotpRequired, TotpSetupComplete, TotpSetupRequired, User, VerifyEmailCodeInput } from './resources/auth.js';
|
|
5
|
+
import { b as DepositsResource, F as FundingOptionsResource, c as CardsResource } from './cards-ColpW52n.js';
|
|
6
|
+
export { A as Address, B as BillingAddress, a as Card, d as CardBalance, e as CardDesignRef, f as CardForm, g as CardInTransit, h as CardLoadStatus, i as CardOrder, j as CardOrderError, k as CardOrderInput, C as CardProduct, l as CardProductPrice, m as CardStatus, n as CardStatusSource, o as CardTariff, p as CardTopUp, q as CardTopUpStatus, r as CardTransfer, s as CardType, t as Cardholder, u as CloseBlockedReason, v as CreateCardInput, w as CreateDepositRefundInput, x as CreateQuoteInput, y as CustomerInfo, D as Deposit, z as DepositMethod, E as DepositStatus, G as DepositTarget, H as FeeKind, I as FunderMode, J as FundingOption, K as FundingQuote, L as InitiateDepositInput, M as IssuanceBonus, N as IssueCardInput, O as MethodTerms, R as Refund, P as RevealCardInput, Q as RevealedCard, S as SetPinInput, T as TopUpInput, U as TopUpResult, V as TopUpTerms, W as TransferInput, X as TransferResult, Y as UpdateCardInput } from './cards-ColpW52n.js';
|
|
7
7
|
import { BalanceResource } from './resources/balance.js';
|
|
8
8
|
export { Balance } from './resources/balance.js';
|
|
9
9
|
import { BonusResource } from './resources/bonus.js';
|
|
10
10
|
export { BonusLot, BonusMovement, BonusPreview, BonusPreviewInput, BonusPurpose, BonusTarget, BonusWallet } from './resources/bonus.js';
|
|
11
|
+
import { DebtResource } from './resources/debt.js';
|
|
12
|
+
export { CardFeeKind, Debt, DebtAmount, DebtLine } from './resources/debt.js';
|
|
13
|
+
import { CloseRequestsResource } from './resources/close-requests.js';
|
|
14
|
+
export { CloseAmount, CloseRefund, CloseRequest, CloseRequestError, CloseRequestStatus, PayoutDetailsInput, PayoutDetailsShown } from './resources/close-requests.js';
|
|
11
15
|
import { CodesResource } from './resources/codes.js';
|
|
12
16
|
export { CodeCheck, CodeDiscount, CodeEffect, CodeEffectOutcome, CodeOperation, CodeRejection, CodeResult, ValidateCodeInput } from './resources/codes.js';
|
|
13
17
|
import { ReferralResource } from './resources/referral.js';
|
|
@@ -38,7 +42,7 @@ export { AnonymousKeyOptions, AttributionStatus, SignupAttribution, SurveyAnswer
|
|
|
38
42
|
import { HistoryResource } from './resources/history.js';
|
|
39
43
|
export { HistoryAmount, HistoryCard, HistoryItem, HistoryKind, HistoryPage, HistoryStatus, ListHistoryParams } from './resources/history.js';
|
|
40
44
|
import { ConsentsResource } from './resources/consents.js';
|
|
41
|
-
export { ConsentChannel, ConsentDocument, ConsentKind, ConsentState, Consents, CookieChoiceInput } from './resources/consents.js';
|
|
45
|
+
export { ConsentChannel, ConsentDocument, ConsentKind, ConsentOptions, ConsentState, Consents, CookieChoiceInput, DISPUTE_DOCUMENTS_CONSENT, HOLDER_DATA_CONSENT } from './resources/consents.js';
|
|
42
46
|
import { ReceiptsResource } from './resources/receipts.js';
|
|
43
47
|
export { ListReceiptsParams, Receipt, ReceiptKind } from './resources/receipts.js';
|
|
44
48
|
export { ANALYTICS_EVENTS, AnalyticsEvent, AnalyticsOptions, AnalyticsProperties, AnalyticsZone, METRIKA_GOALS, MetrikaOptions, NO_CAPTURE_CLASS, PostHogLike, PostHogOptions, identify, initAnalytics, page, posthogDistinctId, resetAnalytics, sanitizeProperties, sanitizeUrl, setAnalyticsZone, track } from './analytics.js';
|
|
@@ -73,7 +77,7 @@ interface BrandConfig {
|
|
|
73
77
|
* Which platform versions this SDK works with, as a semver range:
|
|
74
78
|
* comparators separated by ", ". Keep this the only definition.
|
|
75
79
|
*/
|
|
76
|
-
declare const SUPPORTED_MEISTER = ">=0.6.
|
|
80
|
+
declare const SUPPORTED_MEISTER = ">=0.6.11, <0.7.0";
|
|
77
81
|
/** What `client.ready()` returns. */
|
|
78
82
|
interface ReadyInfo {
|
|
79
83
|
/** `true` when the platform reported a version inside `supportedMeister`. */
|
|
@@ -179,7 +183,7 @@ declare function isNetworkError(e: unknown): e is NetworkError;
|
|
|
179
183
|
* `define`. `src/version.test.ts` checks it matches `package.json`, so a
|
|
180
184
|
* release bump that forgets this file fails the test run.
|
|
181
185
|
*/
|
|
182
|
-
declare const SDK_VERSION = "0.6.
|
|
186
|
+
declare const SDK_VERSION = "0.6.5";
|
|
183
187
|
|
|
184
188
|
/**
|
|
185
189
|
* `@takeal/cusfront-sdk` — typed client for the Takeal end-user API.
|
|
@@ -242,6 +246,10 @@ interface CusfrontClient {
|
|
|
242
246
|
readonly balance: BalanceResource;
|
|
243
247
|
/** Bonuses: a discount on the platform's services. Balance, credits, history and a price preview. */
|
|
244
248
|
readonly bonus: BonusResource;
|
|
249
|
+
/** Card fees the user's cards could not cover: paid first from the next top-up. */
|
|
250
|
+
readonly debt: DebtResource;
|
|
251
|
+
/** Close a card that still holds money: the rest goes back the way it was paid. */
|
|
252
|
+
readonly closeRequests: CloseRequestsResource;
|
|
245
253
|
/** Promo and referral codes: check what a code would do before using it. */
|
|
246
254
|
readonly codes: CodesResource;
|
|
247
255
|
/** For referrers: the referral code, the link to share, invited friends and rewards. */
|
package/dist/index.js
CHANGED
|
@@ -184,6 +184,8 @@ var CardsResource = class {
|
|
|
184
184
|
* `Card`. On a ledger failure after provider creation, the Takeal API rolls the row
|
|
185
185
|
* to `failed` (never an orphaned active card); inspect `status` /
|
|
186
186
|
* `failure_reason` on the result.
|
|
187
|
+
* Errors: 409 `holder_data_consent_required` when the product has
|
|
188
|
+
* `holder_data_required` and the user has not agreed to it.
|
|
187
189
|
*/
|
|
188
190
|
async create(input) {
|
|
189
191
|
const { idempotencyKey, ...card } = input;
|
|
@@ -199,7 +201,9 @@ var CardsResource = class {
|
|
|
199
201
|
* `pending_payment` until the payment is confirmed. The same
|
|
200
202
|
* `idempotencyKey` returns the same order.
|
|
201
203
|
* Errors: 400 `unknown_product` / `method_not_available` / a limit of the
|
|
202
|
-
* way of paying,
|
|
204
|
+
* way of paying, 409 `holder_data_consent_required` (the product has
|
|
205
|
+
* `holder_data_required` and the user has not agreed to it), 503 no
|
|
206
|
+
* funding connector or no exchange rate.
|
|
203
207
|
*/
|
|
204
208
|
async order(input) {
|
|
205
209
|
const { idempotencyKey, ...order } = input;
|
|
@@ -361,7 +365,10 @@ var CardsResource = class {
|
|
|
361
365
|
/**
|
|
362
366
|
* Terminate the caller's own card. **One-way** — a terminated card cannot be
|
|
363
367
|
* reactivated. The optional `reason` is audited. Idempotent on an
|
|
364
|
-
* already-terminated card.
|
|
368
|
+
* already-terminated card. A card that still holds money is refused (409
|
|
369
|
+
* `move_balance_first` or `contact_support_to_close`): close it with
|
|
370
|
+
* `client.closeRequests.request(id)` instead, and the money goes back the
|
|
371
|
+
* way it was paid.
|
|
365
372
|
*/
|
|
366
373
|
async terminate(id, reason) {
|
|
367
374
|
return this.http.post(`/me/cards/${encodeURIComponent(id)}/terminate`, {
|
|
@@ -478,6 +485,45 @@ var AuthResource = class {
|
|
|
478
485
|
await this.keep(resp);
|
|
479
486
|
return resp;
|
|
480
487
|
}
|
|
488
|
+
/** Step one of signing in without a password: a six-digit code goes to
|
|
489
|
+
* the address. It works for an address with an account and for a new one
|
|
490
|
+
* alike, and the answer doesn't say which. The code works for 10 minutes;
|
|
491
|
+
* another can be asked for after `resend_at` and replaces it.
|
|
492
|
+
* Errors: 400 `validation` (not an address), 429 `resend_too_soon` /
|
|
493
|
+
* `too_many_requests` (the message says when to try again), 503
|
|
494
|
+
* `delivery_failed`. */
|
|
495
|
+
async requestEmailCode(input) {
|
|
496
|
+
const body = { email: input.email };
|
|
497
|
+
if (input.locale !== void 0) body["locale"] = input.locale;
|
|
498
|
+
return this.http.post("/auth/email-code", { body, skipAuth: true });
|
|
499
|
+
}
|
|
500
|
+
/** Step two: the code signs in to the account with that address, or
|
|
501
|
+
* creates one (no password) when there is none; `account_created` says
|
|
502
|
+
* which. The JWT is stored. With `cardOrder`, the card is ordered for
|
|
503
|
+
* that account in the same call.
|
|
504
|
+
* Errors: 401 `invalid_code` (wrong, expired or used; after five checks a
|
|
505
|
+
* new code is needed), 400 `consents_required` for a new account, 403
|
|
506
|
+
* `user_disabled` / `second_factor_required` (operator accounts sign in
|
|
507
|
+
* with a password and their authenticator). */
|
|
508
|
+
async verifyEmailCode(input) {
|
|
509
|
+
const body = {
|
|
510
|
+
challenge_id: input.challengeId,
|
|
511
|
+
code: input.code
|
|
512
|
+
};
|
|
513
|
+
if (input.remember) body["remember_me"] = true;
|
|
514
|
+
if (input.walletCurrency !== void 0) body["wallet_currency"] = input.walletCurrency;
|
|
515
|
+
if (input.attribution !== void 0) body["attribution"] = input.attribution;
|
|
516
|
+
if (input.promoCode !== void 0) body["promo_code"] = input.promoCode;
|
|
517
|
+
if (input.consents !== void 0) body["consents"] = input.consents;
|
|
518
|
+
if (input.consentChannel !== void 0) body["consent_channel"] = input.consentChannel;
|
|
519
|
+
if (input.cardOrder !== void 0) body["card_order"] = cardOrderBody(input.cardOrder);
|
|
520
|
+
const resp = await this.http.post("/auth/email-code/verify", {
|
|
521
|
+
body,
|
|
522
|
+
skipAuth: true
|
|
523
|
+
});
|
|
524
|
+
await this.keep(resp);
|
|
525
|
+
return resp;
|
|
526
|
+
}
|
|
481
527
|
/** Finish a `totp_setup_required` login: send the first code from the
|
|
482
528
|
* authenticator app. The JWT is stored. The response carries ten
|
|
483
529
|
* one-time `backup_codes` that are never returned again, so show them to
|
|
@@ -689,6 +735,72 @@ var BonusResource = class {
|
|
|
689
735
|
}
|
|
690
736
|
};
|
|
691
737
|
|
|
738
|
+
// src/resources/debt.ts
|
|
739
|
+
var DebtResource = class {
|
|
740
|
+
constructor(http) {
|
|
741
|
+
this.http = http;
|
|
742
|
+
}
|
|
743
|
+
/** What the user owes in card fees, per currency, and what for. */
|
|
744
|
+
async get(opts = {}) {
|
|
745
|
+
return this.http.get("/me/debt", { signal: opts.signal });
|
|
746
|
+
}
|
|
747
|
+
/** What the user owes in `currency`, decimal string; `"0"` when nothing. */
|
|
748
|
+
async owedIn(currency, opts = {}) {
|
|
749
|
+
const debt = await this.get(opts);
|
|
750
|
+
const want = currency.trim().toUpperCase();
|
|
751
|
+
return debt.total.find((d) => d.currency.toUpperCase() === want)?.amount ?? "0";
|
|
752
|
+
}
|
|
753
|
+
};
|
|
754
|
+
|
|
755
|
+
// src/resources/close-requests.ts
|
|
756
|
+
var CloseRequestsResource = class {
|
|
757
|
+
constructor(http) {
|
|
758
|
+
this.http = http;
|
|
759
|
+
}
|
|
760
|
+
/**
|
|
761
|
+
* Close a card that holds money, the rest going back the way it was paid.
|
|
762
|
+
* Asking again for the same card returns the same request. 404 no such
|
|
763
|
+
* card · 409 {@link CloseRequestError}: `no_balance` means the card holds
|
|
764
|
+
* nothing, close it with `cards.terminate()` · 503 the issuer can't be
|
|
765
|
+
* reached; the card stays as it was.
|
|
766
|
+
*/
|
|
767
|
+
async request(cardId, input = {}) {
|
|
768
|
+
return this.http.post(`/me/cards/${encodeURIComponent(cardId)}/close-request`, {
|
|
769
|
+
body: { reason: input.reason }
|
|
770
|
+
});
|
|
771
|
+
}
|
|
772
|
+
/** Every card close request of the user, newest first. */
|
|
773
|
+
async list(opts = {}) {
|
|
774
|
+
const res = await this.http.get("/me/close-requests", {
|
|
775
|
+
signal: opts.signal
|
|
776
|
+
});
|
|
777
|
+
return res.items;
|
|
778
|
+
}
|
|
779
|
+
/** One close request. 404 when it isn't the user's. */
|
|
780
|
+
async get(id, opts = {}) {
|
|
781
|
+
return this.http.get(`/me/close-requests/${encodeURIComponent(id)}`, {
|
|
782
|
+
signal: opts.signal
|
|
783
|
+
});
|
|
784
|
+
}
|
|
785
|
+
/** The request for this card, if the user made one. */
|
|
786
|
+
async forCard(cardId, opts = {}) {
|
|
787
|
+
const all = await this.list(opts);
|
|
788
|
+
return all.find((r) => r.card_id === cardId) ?? null;
|
|
789
|
+
}
|
|
790
|
+
/**
|
|
791
|
+
* Give a bank account or a card in the user's own name, when the request
|
|
792
|
+
* is `payout_details_required` (or `identity_check`, to correct them). 400
|
|
793
|
+
* `validation`: a name, number or bank code that doesn't look right · 409
|
|
794
|
+
* `details_not_needed`.
|
|
795
|
+
*/
|
|
796
|
+
async submitPayoutDetails(id, details) {
|
|
797
|
+
return this.http.post(
|
|
798
|
+
`/me/close-requests/${encodeURIComponent(id)}/payout-details`,
|
|
799
|
+
{ body: details }
|
|
800
|
+
);
|
|
801
|
+
}
|
|
802
|
+
};
|
|
803
|
+
|
|
692
804
|
// src/resources/codes.ts
|
|
693
805
|
var CodesResource = class {
|
|
694
806
|
constructor(http) {
|
|
@@ -1220,6 +1332,8 @@ var HistoryResource = class {
|
|
|
1220
1332
|
};
|
|
1221
1333
|
|
|
1222
1334
|
// src/resources/consents.ts
|
|
1335
|
+
var HOLDER_DATA_CONSENT = "holder_data_transfer";
|
|
1336
|
+
var DISPUTE_DOCUMENTS_CONSENT = "dispute_documents_transfer";
|
|
1223
1337
|
var ConsentsResource = class {
|
|
1224
1338
|
constructor(http) {
|
|
1225
1339
|
this.http = http;
|
|
@@ -1228,20 +1342,51 @@ var ConsentsResource = class {
|
|
|
1228
1342
|
async get() {
|
|
1229
1343
|
return this.http.get("/me/consents");
|
|
1230
1344
|
}
|
|
1345
|
+
/** Whether `kind` stands now: given and not withdrawn since. */
|
|
1346
|
+
async stands(kind) {
|
|
1347
|
+
const { consents } = await this.get();
|
|
1348
|
+
return consents.some((c) => c.kind === kind && c.given);
|
|
1349
|
+
}
|
|
1231
1350
|
/**
|
|
1232
|
-
* Give (`true`) or withdraw (`false`) an optional consent: `marketing
|
|
1233
|
-
* `cookies_analytics
|
|
1234
|
-
*
|
|
1235
|
-
*
|
|
1351
|
+
* Give (`true`) or withdraw (`false`) an optional consent: `marketing`,
|
|
1352
|
+
* `cookies_analytics`, `holder_data_transfer` or
|
|
1353
|
+
* `dispute_documents_transfer`. Withdrawing `marketing` turns advertising
|
|
1354
|
+
* off in every channel at once; giving it turns on advertising by e-mail.
|
|
1355
|
+
* Withdrawing `holder_data_transfer` leaves the user's cards alone and
|
|
1356
|
+
* stops new cards whose product has `holder_data_required`. A call that
|
|
1357
|
+
* changes nothing records nothing, unless it names a card.
|
|
1358
|
+
*
|
|
1359
|
+
* The third argument is the channel, or {@link ConsentOptions} with the
|
|
1360
|
+
* channel and the card.
|
|
1236
1361
|
*
|
|
1237
1362
|
* Errors: 400 `consent_required` for `terms` or `personal_data`,
|
|
1238
|
-
* 400 `unknown_consent
|
|
1363
|
+
* 400 `unknown_consent`, 400 `card_not_allowed` (a card named with a kind
|
|
1364
|
+
* that takes none), 404 `not_found` (not one of the user's cards).
|
|
1239
1365
|
*/
|
|
1240
|
-
async set(kind, given,
|
|
1366
|
+
async set(kind, given, options) {
|
|
1367
|
+
const opts = typeof options === "string" ? { channel: options } : options ?? {};
|
|
1241
1368
|
const body = { kind, given };
|
|
1242
|
-
if (channel !== void 0) body.channel = channel;
|
|
1369
|
+
if (opts.channel !== void 0) body.channel = opts.channel;
|
|
1370
|
+
if (opts.cardId !== void 0) body.card_id = opts.cardId;
|
|
1243
1371
|
return this.http.post("/me/consents", { body });
|
|
1244
1372
|
}
|
|
1373
|
+
/**
|
|
1374
|
+
* The user agreed on the consent screen that their real personal details
|
|
1375
|
+
* go to the card issuer (`holder_data_transfer`). Needed before ordering a
|
|
1376
|
+
* product with `holder_data_required`, unless the order itself carries the
|
|
1377
|
+
* kind in its `consents`.
|
|
1378
|
+
*/
|
|
1379
|
+
async allowHolderData(options) {
|
|
1380
|
+
return this.set(HOLDER_DATA_CONSENT, true, options);
|
|
1381
|
+
}
|
|
1382
|
+
/**
|
|
1383
|
+
* The user agreed that their documents go to the card issuer for a
|
|
1384
|
+
* dispute (`dispute_documents_transfer`). Name the disputed card with
|
|
1385
|
+
* `cardId`; each call is then recorded on its own.
|
|
1386
|
+
*/
|
|
1387
|
+
async allowDisputeDocuments(options) {
|
|
1388
|
+
return this.set(DISPUTE_DOCUMENTS_CONSENT, true, options);
|
|
1389
|
+
}
|
|
1245
1390
|
/**
|
|
1246
1391
|
* Record what the cookie banner or the cookie settings say about
|
|
1247
1392
|
* analytics. Works signed in or not: before sign-in the choice is kept
|
|
@@ -1294,7 +1439,7 @@ var FundingOptionsResource = class {
|
|
|
1294
1439
|
};
|
|
1295
1440
|
|
|
1296
1441
|
// src/version.ts
|
|
1297
|
-
var SDK_VERSION = "0.6.
|
|
1442
|
+
var SDK_VERSION = "0.6.5";
|
|
1298
1443
|
|
|
1299
1444
|
// src/client-platform.ts
|
|
1300
1445
|
var CLIENT_HEADER = "X-Takeal-Client";
|
|
@@ -1369,7 +1514,7 @@ function isAbsolute(url) {
|
|
|
1369
1514
|
}
|
|
1370
1515
|
|
|
1371
1516
|
// src/compat.ts
|
|
1372
|
-
var SUPPORTED_MEISTER = ">=0.6.
|
|
1517
|
+
var SUPPORTED_MEISTER = ">=0.6.11, <0.7.0";
|
|
1373
1518
|
var SEMVER = /^v?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/;
|
|
1374
1519
|
function parse(v) {
|
|
1375
1520
|
const m = SEMVER.exec(v.trim());
|
|
@@ -1882,6 +2027,8 @@ function createClient(opts) {
|
|
|
1882
2027
|
cards: new CardsResource(http),
|
|
1883
2028
|
balance: new BalanceResource(http),
|
|
1884
2029
|
bonus: new BonusResource(http),
|
|
2030
|
+
debt: new DebtResource(http),
|
|
2031
|
+
closeRequests: new CloseRequestsResource(http),
|
|
1885
2032
|
codes: new CodesResource(http),
|
|
1886
2033
|
referral: new ReferralResource(http),
|
|
1887
2034
|
subscription: new SubscriptionResource(http),
|
|
@@ -1916,6 +2063,6 @@ function defaultFetch() {
|
|
|
1916
2063
|
);
|
|
1917
2064
|
}
|
|
1918
2065
|
|
|
1919
|
-
export { ANALYTICS_EVENTS, ApiError, CLIENT_HEADER, METRIKA_GOALS, NO_CAPTURE_CLASS, NetworkError, SDK_VERSION, SUPPORTED_MEISTER, anonymousKey, createClient, currentTouch, defaultBrowserStore, detectClientPlatform, identify, inMemoryStore, initAnalytics, isApiError, isCardOtp, isNetworkError, page, posthogDistinctId, resetAnalytics, resolveAssetUrl, sanitizeProperties, sanitizeUrl, satisfies, setAnalyticsZone, track };
|
|
2066
|
+
export { ANALYTICS_EVENTS, ApiError, CLIENT_HEADER, DISPUTE_DOCUMENTS_CONSENT, HOLDER_DATA_CONSENT, METRIKA_GOALS, NO_CAPTURE_CLASS, NetworkError, SDK_VERSION, SUPPORTED_MEISTER, anonymousKey, createClient, currentTouch, defaultBrowserStore, detectClientPlatform, identify, inMemoryStore, initAnalytics, isApiError, isCardOtp, isNetworkError, page, posthogDistinctId, resetAnalytics, resolveAssetUrl, sanitizeProperties, sanitizeUrl, satisfies, setAnalyticsZone, track };
|
|
1920
2067
|
//# sourceMappingURL=index.js.map
|
|
1921
2068
|
//# sourceMappingURL=index.js.map
|