@takeal/cusfront-sdk 0.8.3 → 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 +88 -1
- package/README.md +70 -12
- 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-BPu8Ill7.d.cts → cards-C5rk0XkI.d.cts} +83 -8
- package/dist/{cards-DP1fJc_c.d.ts → cards-CS-oxqLS.d.ts} +83 -8
- package/dist/index.cjs +122 -27
- 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 +119 -28
- 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 +28 -1
- package/dist/resources/auth.cjs.map +1 -1
- package/dist/resources/auth.d.cts +57 -5
- package/dist/resources/auth.d.ts +57 -5
- package/dist/resources/auth.js +28 -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/resources/subscription.cjs.map +1 -1
- package/dist/resources/subscription.d.cts +4 -0
- package/dist/resources/subscription.d.ts +4 -0
- package/dist/resources/subscription.js.map +1 -1
- package/dist/telegram.cjs +48 -5
- 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 +48 -5
- package/dist/telegram.js.map +1 -1
- package/package.json +1 -1
|
@@ -159,6 +159,16 @@ interface CreateQuoteInput {
|
|
|
159
159
|
connectorSlug?: string;
|
|
160
160
|
/** The way the user pays. Pass the same method to `initiate()`. */
|
|
161
161
|
method?: DepositMethod;
|
|
162
|
+
/**
|
|
163
|
+
* A promo code for the top-up. Where the method's fee is in the rate
|
|
164
|
+
* (`fee_kind: "markup"`), the code's percentage discount lowers that fee,
|
|
165
|
+
* so the rate is priced with it and `promo_code` comes back on the quote.
|
|
166
|
+
* The top-up made from the quote uses the same code: pass it again to
|
|
167
|
+
* `initiate()` or leave it out. Without one, the code the user signed up
|
|
168
|
+
* with is used when it works here. A code that can't be used fails with
|
|
169
|
+
* 400 `promo_code_*` and the reason. Needs platform 0.8.4.
|
|
170
|
+
*/
|
|
171
|
+
promo_code?: string;
|
|
162
172
|
}
|
|
163
173
|
/**
|
|
164
174
|
* How a method's fee reads. `spread`: taken off the credited amount at the
|
|
@@ -197,11 +207,18 @@ interface FundingQuote {
|
|
|
197
207
|
credited_amount: string;
|
|
198
208
|
credited_currency: string;
|
|
199
209
|
/**
|
|
200
|
-
* Provider rate before the fee, credited units per 1 source unit.
|
|
201
|
-
*
|
|
202
|
-
* the fee in it; see the README for the rouble-per-dollar form.
|
|
210
|
+
* Provider rate before the fee, credited units per 1 source unit. Don't
|
|
211
|
+
* show it: the user's rate is `effective_rate`.
|
|
203
212
|
*/
|
|
204
213
|
rate: string;
|
|
214
|
+
/**
|
|
215
|
+
* The rate the user gets, credited units per 1 source unit, with the fee
|
|
216
|
+
* and any discount of the user's plan or promo code in it. Show this one
|
|
217
|
+
* (or its inverse, see the README) rather than working a rate out from
|
|
218
|
+
* the method's `fee_bps`. Older platforms leave it out; there it is
|
|
219
|
+
* `credited_amount / source_amount`.
|
|
220
|
+
*/
|
|
221
|
+
effective_rate?: string;
|
|
205
222
|
/** The fee in basis points; the same figure as `fee_bps`, under its old name. */
|
|
206
223
|
spread_bps: number;
|
|
207
224
|
/** The fee in basis points (2000 = 20 %). */
|
|
@@ -213,6 +230,16 @@ interface FundingQuote {
|
|
|
213
230
|
method?: DepositMethod;
|
|
214
231
|
/** The rate is locked until then; the deposit made with it waits for its payment as long. */
|
|
215
232
|
expires_at: string;
|
|
233
|
+
/**
|
|
234
|
+
* Set when the user's plan or a promo code lowered the fee in the rate:
|
|
235
|
+
* the method's fee before that, in basis points. `fee_bps` is what the
|
|
236
|
+
* user pays.
|
|
237
|
+
*/
|
|
238
|
+
list_fee_bps?: number;
|
|
239
|
+
/** What the lower fee adds to `credited_amount`, decimal string in `credited_currency`. */
|
|
240
|
+
fee_discount?: string;
|
|
241
|
+
/** The promo code the rate was priced with; the top-up made from this quote uses it. */
|
|
242
|
+
promo_code?: string;
|
|
216
243
|
/**
|
|
217
244
|
* What the user owes in card fees, in `credited_currency`, that this
|
|
218
245
|
* top-up pays first: it comes off `credited_amount` and the rest is
|
|
@@ -269,7 +296,8 @@ interface Deposit {
|
|
|
269
296
|
/**
|
|
270
297
|
* For a top-up onto a card: `pending` until the card provider has loaded
|
|
271
298
|
* the card, then `succeeded` or `failed`. Show the top-up as done only
|
|
272
|
-
* once it is `succeeded`, or once `returned_to_wallet_at` is set.
|
|
299
|
+
* once it is `succeeded`, or once `returned_to_wallet_at` is set. Empty
|
|
300
|
+
* for a top-up that was never paid: nothing was there to load.
|
|
273
301
|
*/
|
|
274
302
|
card_load_status?: CardLoadStatus | null;
|
|
275
303
|
/** Why the card could not take it, when `card_load_status` is `failed`. */
|
|
@@ -369,6 +397,12 @@ interface InitiateDepositInput {
|
|
|
369
397
|
* arrive once the top-up is confirmed. A code that can't be used fails the
|
|
370
398
|
* request with 400 `promo_code_*` and the reason. `client.codes.validate`
|
|
371
399
|
* checks it first.
|
|
400
|
+
*
|
|
401
|
+
* Where the method's fee is in the rate, the discount lowers the rate, and
|
|
402
|
+
* only the quote prices the rate: send the code to `quote()`. A top-up
|
|
403
|
+
* from that quote uses the quote's `promo_code` without being told; another
|
|
404
|
+
* code here is refused (400 `validation`), and a code the quote was made
|
|
405
|
+
* without is refused with 400 `promo_code_not_applicable`.
|
|
372
406
|
*/
|
|
373
407
|
promo_code?: string;
|
|
374
408
|
/** The visitor's analytics ids for the payment's server-side conversions.
|
|
@@ -832,7 +866,15 @@ interface CardOrderInput {
|
|
|
832
866
|
currency?: string;
|
|
833
867
|
/** Money to put on the card on top of its price, decimal string in the card's currency. Sent as `extra_load`. */
|
|
834
868
|
extraLoad?: string;
|
|
835
|
-
/**
|
|
869
|
+
/**
|
|
870
|
+
* A promo code for the order. A code for cards lowers the card's price.
|
|
871
|
+
* A code for top-ups lowers the fee on the payment: for a way of paying
|
|
872
|
+
* with its fee in the exchange rate it lowers the rate, and the amount
|
|
873
|
+
* with it (see `rate` of the order and of the quote). A minimum amount of
|
|
874
|
+
* such a code is checked against the money that goes onto the card, not
|
|
875
|
+
* against the card's price; below it the order is refused with
|
|
876
|
+
* `promo_code_below_minimum` and a sentence to show. Sent as `promo_code`.
|
|
877
|
+
*/
|
|
836
878
|
promoCode?: string;
|
|
837
879
|
/** Pay part of the price with bonuses; on by default. Sent as `use_bonus`. */
|
|
838
880
|
useBonus?: boolean;
|
|
@@ -904,8 +946,10 @@ interface PromoCodeQuote {
|
|
|
904
946
|
message: string | null;
|
|
905
947
|
/**
|
|
906
948
|
* The discount and what it comes off: `card_issuance` (the card's price,
|
|
907
|
-
* in `discount` of the quote) or `funding_commission` (the
|
|
908
|
-
*
|
|
949
|
+
* in `discount` of the quote) or `funding_commission` (the fee on the
|
|
950
|
+
* payment). A fee in the exchange rate gets lower and the amount with it,
|
|
951
|
+
* so it is in `discount` of the quote too; a separate commission gets
|
|
952
|
+
* lower while the amount stays the same, and more goes onto the card.
|
|
909
953
|
*/
|
|
910
954
|
discount: CodeDiscount | null;
|
|
911
955
|
/** What else the code gives, once the card is issued. */
|
|
@@ -913,6 +957,26 @@ interface PromoCodeQuote {
|
|
|
913
957
|
/** The code the user signed up with, applied without being typed. */
|
|
914
958
|
from_sign_up: boolean;
|
|
915
959
|
}
|
|
960
|
+
/**
|
|
961
|
+
* The exchange rate a card order was priced at, when the payment is in
|
|
962
|
+
* another currency than the card's.
|
|
963
|
+
*/
|
|
964
|
+
interface CardOrderRate {
|
|
965
|
+
/**
|
|
966
|
+
* The rate the user gets, the fee included: units of `card_currency` per
|
|
967
|
+
* 1 unit of `currency`, decimal string. Show this one; `1 / effective_rate`
|
|
968
|
+
* is the price of one unit of the card's currency.
|
|
969
|
+
*/
|
|
970
|
+
effective_rate: string;
|
|
971
|
+
/** The fee in basis points (1900 = 19 %), as the order was priced. */
|
|
972
|
+
fee_bps: number;
|
|
973
|
+
/** `markup` (the fee is in the rate), `spread` or `commission`. */
|
|
974
|
+
fee_kind: string;
|
|
975
|
+
/** When the user's plan or a promo code lowered the fee in the rate: the fee before that. */
|
|
976
|
+
list_fee_bps?: number | null;
|
|
977
|
+
/** The promo code the rate was priced with. */
|
|
978
|
+
promo_code?: string | null;
|
|
979
|
+
}
|
|
916
980
|
/** What a card order would cost now, from {@link CardsResource.quote} or {@link CardsResource.quotePublic}. */
|
|
917
981
|
interface CardOrderQuote {
|
|
918
982
|
/** What the user pays, decimal string, in `currency`. Pass it to the order as `expectedAmount`. */
|
|
@@ -934,6 +998,12 @@ interface CardOrderQuote {
|
|
|
934
998
|
preliminary: boolean;
|
|
935
999
|
/** Null when no code was typed and none applies by itself. */
|
|
936
1000
|
promo_code: PromoCodeQuote | null;
|
|
1001
|
+
/**
|
|
1002
|
+
* The rate the amount was worked out at, with the promo code's share
|
|
1003
|
+
* taken off the fee. Null when the payment is in the card's currency;
|
|
1004
|
+
* older platforms leave it out.
|
|
1005
|
+
*/
|
|
1006
|
+
rate?: CardOrderRate | null;
|
|
937
1007
|
}
|
|
938
1008
|
/** What {@link CardsResource.order} returns: the top-up to pay and its price. */
|
|
939
1009
|
interface CardOrder {
|
|
@@ -951,6 +1021,11 @@ interface CardOrder {
|
|
|
951
1021
|
* it before the payment. Older platforms leave it out.
|
|
952
1022
|
*/
|
|
953
1023
|
debt_withheld?: string;
|
|
1024
|
+
/**
|
|
1025
|
+
* The rate the order was priced at. Null when the payment is in the
|
|
1026
|
+
* card's currency; older platforms leave it out.
|
|
1027
|
+
*/
|
|
1028
|
+
rate?: CardOrderRate | null;
|
|
954
1029
|
}
|
|
955
1030
|
/** Why a card ordered with the sign-up was not placed. The account exists all the same. */
|
|
956
1031
|
interface CardOrderError {
|
|
@@ -1396,4 +1471,4 @@ declare class CardsResource {
|
|
|
1396
1471
|
terminate(id: string, reason?: string): Promise<Card>;
|
|
1397
1472
|
}
|
|
1398
1473
|
|
|
1399
|
-
export { type
|
|
1474
|
+
export { type TopUpTerms as $, type Address as A, type BillingAddress as B, type CardProduct as C, type Deposit as D, type CreateQuoteInput as E, FundingOptionsResource as F, type CustomerInfo as G, type DepositMethod as H, type DepositStatus as I, type DepositTarget as J, type FeeKind as K, type FunderMode as L, type FundingOption as M, type FundingQuote as N, type InitiateDepositInput as O, type IssuanceBonus as P, type IssueCardInput as Q, type MethodTerms as R, type PromoCodeQuote as S, type PromoCodeStatus as T, type Refund as U, type RevealCardInput as V, type RevealState as W, type RevealedCard as X, type SetPinInput as Y, type TopUpInput as Z, type TopUpResult as _, type Card as a, type TransferInput as a0, type TransferResult as a1, type UpdateCardInput as a2, priceChangedQuote as a3, revealState as a4, cardOrderBody as a5, cardOrderQuoteBody as a6, cardRequestBody as a7, DepositsResource as b, CardsResource as c, type CardBalance as d, type CardDesignRef as e, type CardForm as f, type CardInTransit as g, type CardLoadStatus as h, type CardOrder as i, type CardOrderError as j, type CardOrderInput as k, type CardOrderQuote as l, type CardOrderQuoteInput as m, type CardOrderRate as n, type CardProductPrice as o, type CardStatus as p, type CardStatusSource as q, type CardTariff as r, type CardTopUp as s, type CardTopUpStatus as t, type CardTransfer as u, type CardType as v, type Cardholder as w, type CloseBlockedReason as x, type CreateCardInput as y, type CreateDepositRefundInput as z };
|
|
@@ -159,6 +159,16 @@ interface CreateQuoteInput {
|
|
|
159
159
|
connectorSlug?: string;
|
|
160
160
|
/** The way the user pays. Pass the same method to `initiate()`. */
|
|
161
161
|
method?: DepositMethod;
|
|
162
|
+
/**
|
|
163
|
+
* A promo code for the top-up. Where the method's fee is in the rate
|
|
164
|
+
* (`fee_kind: "markup"`), the code's percentage discount lowers that fee,
|
|
165
|
+
* so the rate is priced with it and `promo_code` comes back on the quote.
|
|
166
|
+
* The top-up made from the quote uses the same code: pass it again to
|
|
167
|
+
* `initiate()` or leave it out. Without one, the code the user signed up
|
|
168
|
+
* with is used when it works here. A code that can't be used fails with
|
|
169
|
+
* 400 `promo_code_*` and the reason. Needs platform 0.8.4.
|
|
170
|
+
*/
|
|
171
|
+
promo_code?: string;
|
|
162
172
|
}
|
|
163
173
|
/**
|
|
164
174
|
* How a method's fee reads. `spread`: taken off the credited amount at the
|
|
@@ -197,11 +207,18 @@ interface FundingQuote {
|
|
|
197
207
|
credited_amount: string;
|
|
198
208
|
credited_currency: string;
|
|
199
209
|
/**
|
|
200
|
-
* Provider rate before the fee, credited units per 1 source unit.
|
|
201
|
-
*
|
|
202
|
-
* the fee in it; see the README for the rouble-per-dollar form.
|
|
210
|
+
* Provider rate before the fee, credited units per 1 source unit. Don't
|
|
211
|
+
* show it: the user's rate is `effective_rate`.
|
|
203
212
|
*/
|
|
204
213
|
rate: string;
|
|
214
|
+
/**
|
|
215
|
+
* The rate the user gets, credited units per 1 source unit, with the fee
|
|
216
|
+
* and any discount of the user's plan or promo code in it. Show this one
|
|
217
|
+
* (or its inverse, see the README) rather than working a rate out from
|
|
218
|
+
* the method's `fee_bps`. Older platforms leave it out; there it is
|
|
219
|
+
* `credited_amount / source_amount`.
|
|
220
|
+
*/
|
|
221
|
+
effective_rate?: string;
|
|
205
222
|
/** The fee in basis points; the same figure as `fee_bps`, under its old name. */
|
|
206
223
|
spread_bps: number;
|
|
207
224
|
/** The fee in basis points (2000 = 20 %). */
|
|
@@ -213,6 +230,16 @@ interface FundingQuote {
|
|
|
213
230
|
method?: DepositMethod;
|
|
214
231
|
/** The rate is locked until then; the deposit made with it waits for its payment as long. */
|
|
215
232
|
expires_at: string;
|
|
233
|
+
/**
|
|
234
|
+
* Set when the user's plan or a promo code lowered the fee in the rate:
|
|
235
|
+
* the method's fee before that, in basis points. `fee_bps` is what the
|
|
236
|
+
* user pays.
|
|
237
|
+
*/
|
|
238
|
+
list_fee_bps?: number;
|
|
239
|
+
/** What the lower fee adds to `credited_amount`, decimal string in `credited_currency`. */
|
|
240
|
+
fee_discount?: string;
|
|
241
|
+
/** The promo code the rate was priced with; the top-up made from this quote uses it. */
|
|
242
|
+
promo_code?: string;
|
|
216
243
|
/**
|
|
217
244
|
* What the user owes in card fees, in `credited_currency`, that this
|
|
218
245
|
* top-up pays first: it comes off `credited_amount` and the rest is
|
|
@@ -269,7 +296,8 @@ interface Deposit {
|
|
|
269
296
|
/**
|
|
270
297
|
* For a top-up onto a card: `pending` until the card provider has loaded
|
|
271
298
|
* the card, then `succeeded` or `failed`. Show the top-up as done only
|
|
272
|
-
* once it is `succeeded`, or once `returned_to_wallet_at` is set.
|
|
299
|
+
* once it is `succeeded`, or once `returned_to_wallet_at` is set. Empty
|
|
300
|
+
* for a top-up that was never paid: nothing was there to load.
|
|
273
301
|
*/
|
|
274
302
|
card_load_status?: CardLoadStatus | null;
|
|
275
303
|
/** Why the card could not take it, when `card_load_status` is `failed`. */
|
|
@@ -369,6 +397,12 @@ interface InitiateDepositInput {
|
|
|
369
397
|
* arrive once the top-up is confirmed. A code that can't be used fails the
|
|
370
398
|
* request with 400 `promo_code_*` and the reason. `client.codes.validate`
|
|
371
399
|
* checks it first.
|
|
400
|
+
*
|
|
401
|
+
* Where the method's fee is in the rate, the discount lowers the rate, and
|
|
402
|
+
* only the quote prices the rate: send the code to `quote()`. A top-up
|
|
403
|
+
* from that quote uses the quote's `promo_code` without being told; another
|
|
404
|
+
* code here is refused (400 `validation`), and a code the quote was made
|
|
405
|
+
* without is refused with 400 `promo_code_not_applicable`.
|
|
372
406
|
*/
|
|
373
407
|
promo_code?: string;
|
|
374
408
|
/** The visitor's analytics ids for the payment's server-side conversions.
|
|
@@ -832,7 +866,15 @@ interface CardOrderInput {
|
|
|
832
866
|
currency?: string;
|
|
833
867
|
/** Money to put on the card on top of its price, decimal string in the card's currency. Sent as `extra_load`. */
|
|
834
868
|
extraLoad?: string;
|
|
835
|
-
/**
|
|
869
|
+
/**
|
|
870
|
+
* A promo code for the order. A code for cards lowers the card's price.
|
|
871
|
+
* A code for top-ups lowers the fee on the payment: for a way of paying
|
|
872
|
+
* with its fee in the exchange rate it lowers the rate, and the amount
|
|
873
|
+
* with it (see `rate` of the order and of the quote). A minimum amount of
|
|
874
|
+
* such a code is checked against the money that goes onto the card, not
|
|
875
|
+
* against the card's price; below it the order is refused with
|
|
876
|
+
* `promo_code_below_minimum` and a sentence to show. Sent as `promo_code`.
|
|
877
|
+
*/
|
|
836
878
|
promoCode?: string;
|
|
837
879
|
/** Pay part of the price with bonuses; on by default. Sent as `use_bonus`. */
|
|
838
880
|
useBonus?: boolean;
|
|
@@ -904,8 +946,10 @@ interface PromoCodeQuote {
|
|
|
904
946
|
message: string | null;
|
|
905
947
|
/**
|
|
906
948
|
* The discount and what it comes off: `card_issuance` (the card's price,
|
|
907
|
-
* in `discount` of the quote) or `funding_commission` (the
|
|
908
|
-
*
|
|
949
|
+
* in `discount` of the quote) or `funding_commission` (the fee on the
|
|
950
|
+
* payment). A fee in the exchange rate gets lower and the amount with it,
|
|
951
|
+
* so it is in `discount` of the quote too; a separate commission gets
|
|
952
|
+
* lower while the amount stays the same, and more goes onto the card.
|
|
909
953
|
*/
|
|
910
954
|
discount: CodeDiscount | null;
|
|
911
955
|
/** What else the code gives, once the card is issued. */
|
|
@@ -913,6 +957,26 @@ interface PromoCodeQuote {
|
|
|
913
957
|
/** The code the user signed up with, applied without being typed. */
|
|
914
958
|
from_sign_up: boolean;
|
|
915
959
|
}
|
|
960
|
+
/**
|
|
961
|
+
* The exchange rate a card order was priced at, when the payment is in
|
|
962
|
+
* another currency than the card's.
|
|
963
|
+
*/
|
|
964
|
+
interface CardOrderRate {
|
|
965
|
+
/**
|
|
966
|
+
* The rate the user gets, the fee included: units of `card_currency` per
|
|
967
|
+
* 1 unit of `currency`, decimal string. Show this one; `1 / effective_rate`
|
|
968
|
+
* is the price of one unit of the card's currency.
|
|
969
|
+
*/
|
|
970
|
+
effective_rate: string;
|
|
971
|
+
/** The fee in basis points (1900 = 19 %), as the order was priced. */
|
|
972
|
+
fee_bps: number;
|
|
973
|
+
/** `markup` (the fee is in the rate), `spread` or `commission`. */
|
|
974
|
+
fee_kind: string;
|
|
975
|
+
/** When the user's plan or a promo code lowered the fee in the rate: the fee before that. */
|
|
976
|
+
list_fee_bps?: number | null;
|
|
977
|
+
/** The promo code the rate was priced with. */
|
|
978
|
+
promo_code?: string | null;
|
|
979
|
+
}
|
|
916
980
|
/** What a card order would cost now, from {@link CardsResource.quote} or {@link CardsResource.quotePublic}. */
|
|
917
981
|
interface CardOrderQuote {
|
|
918
982
|
/** What the user pays, decimal string, in `currency`. Pass it to the order as `expectedAmount`. */
|
|
@@ -934,6 +998,12 @@ interface CardOrderQuote {
|
|
|
934
998
|
preliminary: boolean;
|
|
935
999
|
/** Null when no code was typed and none applies by itself. */
|
|
936
1000
|
promo_code: PromoCodeQuote | null;
|
|
1001
|
+
/**
|
|
1002
|
+
* The rate the amount was worked out at, with the promo code's share
|
|
1003
|
+
* taken off the fee. Null when the payment is in the card's currency;
|
|
1004
|
+
* older platforms leave it out.
|
|
1005
|
+
*/
|
|
1006
|
+
rate?: CardOrderRate | null;
|
|
937
1007
|
}
|
|
938
1008
|
/** What {@link CardsResource.order} returns: the top-up to pay and its price. */
|
|
939
1009
|
interface CardOrder {
|
|
@@ -951,6 +1021,11 @@ interface CardOrder {
|
|
|
951
1021
|
* it before the payment. Older platforms leave it out.
|
|
952
1022
|
*/
|
|
953
1023
|
debt_withheld?: string;
|
|
1024
|
+
/**
|
|
1025
|
+
* The rate the order was priced at. Null when the payment is in the
|
|
1026
|
+
* card's currency; older platforms leave it out.
|
|
1027
|
+
*/
|
|
1028
|
+
rate?: CardOrderRate | null;
|
|
954
1029
|
}
|
|
955
1030
|
/** Why a card ordered with the sign-up was not placed. The account exists all the same. */
|
|
956
1031
|
interface CardOrderError {
|
|
@@ -1396,4 +1471,4 @@ declare class CardsResource {
|
|
|
1396
1471
|
terminate(id: string, reason?: string): Promise<Card>;
|
|
1397
1472
|
}
|
|
1398
1473
|
|
|
1399
|
-
export { type
|
|
1474
|
+
export { type TopUpTerms as $, type Address as A, type BillingAddress as B, type CardProduct as C, type Deposit as D, type CreateQuoteInput as E, FundingOptionsResource as F, type CustomerInfo as G, type DepositMethod as H, type DepositStatus as I, type DepositTarget as J, type FeeKind as K, type FunderMode as L, type FundingOption as M, type FundingQuote as N, type InitiateDepositInput as O, type IssuanceBonus as P, type IssueCardInput as Q, type MethodTerms as R, type PromoCodeQuote as S, type PromoCodeStatus as T, type Refund as U, type RevealCardInput as V, type RevealState as W, type RevealedCard as X, type SetPinInput as Y, type TopUpInput as Z, type TopUpResult as _, type Card as a, type TransferInput as a0, type TransferResult as a1, type UpdateCardInput as a2, priceChangedQuote as a3, revealState as a4, cardOrderBody as a5, cardOrderQuoteBody as a6, cardRequestBody as a7, DepositsResource as b, CardsResource as c, type CardBalance as d, type CardDesignRef as e, type CardForm as f, type CardInTransit as g, type CardLoadStatus as h, type CardOrder as i, type CardOrderError as j, type CardOrderInput as k, type CardOrderQuote as l, type CardOrderQuoteInput as m, type CardOrderRate as n, type CardProductPrice as o, type CardStatus as p, type CardStatusSource as q, type CardTariff as r, type CardTopUp as s, type CardTopUpStatus as t, type CardTransfer as u, type CardType as v, type Cardholder as w, type CloseBlockedReason as x, type CreateCardInput as y, type CreateDepositRefundInput as z };
|
package/dist/index.cjs
CHANGED
|
@@ -2,11 +2,12 @@
|
|
|
2
2
|
|
|
3
3
|
// src/error.ts
|
|
4
4
|
var ApiError = class extends Error {
|
|
5
|
-
constructor(status, code, message, body) {
|
|
5
|
+
constructor(status, code, message, body, retryAfterSeconds) {
|
|
6
6
|
super(message);
|
|
7
7
|
this.status = status;
|
|
8
8
|
this.code = code;
|
|
9
9
|
this.body = body;
|
|
10
|
+
this.retryAfterSeconds = retryAfterSeconds;
|
|
10
11
|
this.isApiError = true;
|
|
11
12
|
this.name = "ApiError";
|
|
12
13
|
}
|
|
@@ -141,11 +142,20 @@ async function parseResponse(resp) {
|
|
|
141
142
|
resp.status,
|
|
142
143
|
errBody.code ?? `http_${resp.status}`,
|
|
143
144
|
errBody.message ?? resp.statusText ?? "request failed",
|
|
144
|
-
body
|
|
145
|
+
body,
|
|
146
|
+
retryAfter(resp.headers?.get("Retry-After"))
|
|
145
147
|
);
|
|
146
148
|
}
|
|
147
149
|
return body;
|
|
148
150
|
}
|
|
151
|
+
function retryAfter(v, now = Date.now()) {
|
|
152
|
+
if (!v) return void 0;
|
|
153
|
+
const t = v.trim();
|
|
154
|
+
if (/^\d+$/.test(t)) return Number(t);
|
|
155
|
+
const at = Date.parse(t);
|
|
156
|
+
if (Number.isNaN(at)) return void 0;
|
|
157
|
+
return Math.max(0, Math.ceil((at - now) / 1e3));
|
|
158
|
+
}
|
|
149
159
|
|
|
150
160
|
// src/resources/attribution.ts
|
|
151
161
|
var AttributionResource = class {
|
|
@@ -716,12 +726,17 @@ var AuthResource = class {
|
|
|
716
726
|
return resp;
|
|
717
727
|
}
|
|
718
728
|
/** Verify a TOTP code (or XXXX-XXXX backup code) against a
|
|
719
|
-
* `totp_required` challenge. On success the JWT is stored.
|
|
729
|
+
* `totp_required` challenge. On success the JWT is stored. A backup code
|
|
730
|
+
* signs nobody in: it is used up and the answer is
|
|
731
|
+
* `totp_setup_email_required`, the start of connecting a new
|
|
732
|
+
* authenticator ({@link confirmTotpSetupEmail}). Nothing is stored then.
|
|
733
|
+
* Errors after a backup code: see {@link TotpSetupEmailErrorCode}. */
|
|
720
734
|
async verifyTotp(input) {
|
|
721
735
|
const resp = await this.http.post("/auth/login/totp", {
|
|
722
736
|
body: withRemember(input),
|
|
723
737
|
skipAuth: true
|
|
724
738
|
});
|
|
739
|
+
if (resp.stage === "totp_setup_email_required") return resp;
|
|
725
740
|
await this.keep(resp);
|
|
726
741
|
return resp;
|
|
727
742
|
}
|
|
@@ -794,6 +809,28 @@ var AuthResource = class {
|
|
|
794
809
|
await this.keep(resp);
|
|
795
810
|
return resp;
|
|
796
811
|
}
|
|
812
|
+
/** Send the code from the e-mail of a `totp_setup_email_required`
|
|
813
|
+
* answer. A right code answers `totp_setup_required`: show its
|
|
814
|
+
* `otpauth_url` as a QR, then finish with {@link completeTotpSetup}.
|
|
815
|
+
* Each code works for 5 minutes and takes five tries; only the newest
|
|
816
|
+
* one works. Nothing is stored. Errors: {@link TotpSetupEmailErrorCode}. */
|
|
817
|
+
async confirmTotpSetupEmail(input) {
|
|
818
|
+
return this.http.post("/auth/login/totp-setup/email", {
|
|
819
|
+
body: { challenge_token: input.challenge_token, code: input.code },
|
|
820
|
+
skipAuth: true
|
|
821
|
+
});
|
|
822
|
+
}
|
|
823
|
+
/** A new e-mail code for the same `totp_setup_email_required` sign-in;
|
|
824
|
+
* the one before it stops working. Use the `challenge_token` of the
|
|
825
|
+
* answer from now on. Five codes an hour at most.
|
|
826
|
+
* Errors: {@link TotpSetupEmailErrorCode}; 401 means the sign-in is over,
|
|
827
|
+
* so start again with {@link login}. */
|
|
828
|
+
async resendTotpSetupEmail(input) {
|
|
829
|
+
return this.http.post("/auth/login/totp-setup/email/resend", {
|
|
830
|
+
body: { challenge_token: input.challenge_token },
|
|
831
|
+
skipAuth: true
|
|
832
|
+
});
|
|
833
|
+
}
|
|
797
834
|
/** Finish a `totp_setup_required` login: send the first code from the
|
|
798
835
|
* authenticator app. The JWT is stored. The response carries ten
|
|
799
836
|
* one-time `backup_codes` that are never returned again, so show them to
|
|
@@ -1781,7 +1818,7 @@ var FundingOptionsResource = class {
|
|
|
1781
1818
|
};
|
|
1782
1819
|
|
|
1783
1820
|
// src/version.ts
|
|
1784
|
-
var SDK_VERSION = "0.
|
|
1821
|
+
var SDK_VERSION = "0.9.0";
|
|
1785
1822
|
|
|
1786
1823
|
// src/client-platform.ts
|
|
1787
1824
|
var CLIENT_HEADER = "X-Takeal-Client";
|
|
@@ -1918,12 +1955,18 @@ function readyInfo(raw, healthy) {
|
|
|
1918
1955
|
}
|
|
1919
1956
|
return { ...base, compatible: true };
|
|
1920
1957
|
}
|
|
1958
|
+
function isReadyBody(body) {
|
|
1959
|
+
if (typeof body !== "object" || body === null || Array.isArray(body)) return false;
|
|
1960
|
+
const b = body;
|
|
1961
|
+
const block = (v) => typeof v === "object" && v !== null;
|
|
1962
|
+
return b.code !== "service_unavailable" && typeof b.status === "string" && (block(b.checks) || block(b.ops));
|
|
1963
|
+
}
|
|
1921
1964
|
async function fetchReady(http, opts = {}) {
|
|
1922
1965
|
try {
|
|
1923
1966
|
const body = await http.get("/ready", { skipAuth: true, signal: opts.signal });
|
|
1924
1967
|
return readyInfo(body ?? {}, true);
|
|
1925
1968
|
} catch (e) {
|
|
1926
|
-
if (isApiError(e) && e.status === 503 &&
|
|
1969
|
+
if (isApiError(e) && e.status === 503 && isReadyBody(e.body)) {
|
|
1927
1970
|
return readyInfo(e.body, false);
|
|
1928
1971
|
}
|
|
1929
1972
|
throw e;
|
|
@@ -1957,6 +2000,8 @@ var ANALYTICS_EVENTS = [
|
|
|
1957
2000
|
];
|
|
1958
2001
|
var METRIKA_GOALS = ["signup_started", "signup_completed"];
|
|
1959
2002
|
var NO_CAPTURE_CLASS = "ph-no-capture";
|
|
2003
|
+
var MASK_TEXT_CLASS = "ph-mask";
|
|
2004
|
+
var ZONE_ATTRIBUTE = "data-analytics-zone";
|
|
1960
2005
|
var UUID = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi;
|
|
1961
2006
|
var EMAIL = /[^\s@"'<>(),;:]+@[^\s@"'<>(),;:]+\.[a-z]{2,}/gi;
|
|
1962
2007
|
var DIGIT_RUN = /\+?\d[\d\s().-]{7,}\d/g;
|
|
@@ -2222,18 +2267,38 @@ function posthogConfig(zone, o) {
|
|
|
2222
2267
|
// Page views go through `page()`, with a cleaned address.
|
|
2223
2268
|
capture_pageview: false,
|
|
2224
2269
|
capture_pageleave: true,
|
|
2225
|
-
before_send: beforeSend
|
|
2270
|
+
before_send: beforeSend,
|
|
2271
|
+
// Set once. A zone change never touches these: posthog-js hands the
|
|
2272
|
+
// recording options to rrweb when the recorder starts, and changing
|
|
2273
|
+
// `disable_session_recording` stops or restarts it.
|
|
2274
|
+
disable_session_recording: !o.sessionRecording,
|
|
2275
|
+
session_recording: recordingOptions()
|
|
2276
|
+
};
|
|
2277
|
+
return { ...base, ...zoneConfig(zone) };
|
|
2278
|
+
}
|
|
2279
|
+
function recordingOptions() {
|
|
2280
|
+
return {
|
|
2281
|
+
maskAllInputs: true,
|
|
2282
|
+
maskTextSelector: "*",
|
|
2283
|
+
maskTextFn: maskRecordedText,
|
|
2284
|
+
blockClass: NO_CAPTURE_CLASS
|
|
2226
2285
|
};
|
|
2227
|
-
return { ...base, ...zoneConfig(zone, o) };
|
|
2228
2286
|
}
|
|
2229
|
-
|
|
2287
|
+
var PRIVATE_BLOCK = `.${MASK_TEXT_CLASS}, [${ZONE_ATTRIBUTE}]:not([${ZONE_ATTRIBUTE}="public"])`;
|
|
2288
|
+
function maskRecordedText(text, element) {
|
|
2289
|
+
try {
|
|
2290
|
+
if (state()?.zone === "public" && !element?.closest(PRIVATE_BLOCK)) return text;
|
|
2291
|
+
} catch {
|
|
2292
|
+
}
|
|
2293
|
+
return text.replace(/\S/g, "*");
|
|
2294
|
+
}
|
|
2295
|
+
function zoneConfig(zone) {
|
|
2230
2296
|
if (zone === "public") {
|
|
2231
2297
|
return {
|
|
2232
2298
|
autocapture: true,
|
|
2233
2299
|
mask_all_text: false,
|
|
2234
2300
|
mask_all_element_attributes: false,
|
|
2235
|
-
enable_heatmaps: true
|
|
2236
|
-
disable_session_recording: true
|
|
2301
|
+
enable_heatmaps: true
|
|
2237
2302
|
};
|
|
2238
2303
|
}
|
|
2239
2304
|
return {
|
|
@@ -2241,13 +2306,7 @@ function zoneConfig(zone, o) {
|
|
|
2241
2306
|
autocapture: { capture_copied_text: false },
|
|
2242
2307
|
mask_all_text: true,
|
|
2243
2308
|
mask_all_element_attributes: true,
|
|
2244
|
-
enable_heatmaps: false
|
|
2245
|
-
disable_session_recording: !o.sessionRecording,
|
|
2246
|
-
session_recording: {
|
|
2247
|
-
maskAllInputs: true,
|
|
2248
|
-
maskTextSelector: "*",
|
|
2249
|
-
blockClass: NO_CAPTURE_CLASS
|
|
2250
|
-
}
|
|
2309
|
+
enable_heatmaps: false
|
|
2251
2310
|
};
|
|
2252
2311
|
}
|
|
2253
2312
|
function assetsHost(o) {
|
|
@@ -2306,16 +2365,26 @@ var PostHogSink = class {
|
|
|
2306
2365
|
}
|
|
2307
2366
|
setZone(zone) {
|
|
2308
2367
|
this.with((ph) => {
|
|
2309
|
-
ph.set_config(zoneConfig(zone
|
|
2368
|
+
ph.set_config(zoneConfig(zone));
|
|
2310
2369
|
ph.register({ zone });
|
|
2311
|
-
|
|
2312
|
-
|
|
2370
|
+
});
|
|
2371
|
+
}
|
|
2372
|
+
setConsent(granted) {
|
|
2373
|
+
this.with((ph) => {
|
|
2374
|
+
if (granted) {
|
|
2375
|
+
ph.opt_in_capturing?.();
|
|
2376
|
+
if (this.o.sessionRecording) ph.startSessionRecording?.();
|
|
2377
|
+
} else {
|
|
2378
|
+
ph.stopSessionRecording?.();
|
|
2379
|
+
ph.opt_out_capturing?.();
|
|
2380
|
+
}
|
|
2313
2381
|
});
|
|
2314
2382
|
}
|
|
2315
2383
|
};
|
|
2316
2384
|
var MetrikaSink = class {
|
|
2317
2385
|
constructor(o) {
|
|
2318
2386
|
this.live = true;
|
|
2387
|
+
this.consented = true;
|
|
2319
2388
|
this.id = Number(o.counterId);
|
|
2320
2389
|
const w = win();
|
|
2321
2390
|
if (!w.ym) {
|
|
@@ -2338,7 +2407,7 @@ var MetrikaSink = class {
|
|
|
2338
2407
|
});
|
|
2339
2408
|
}
|
|
2340
2409
|
ym(...args) {
|
|
2341
|
-
if (this.live) win().ym?.(this.id, ...args);
|
|
2410
|
+
if (this.live && this.consented) win().ym?.(this.id, ...args);
|
|
2342
2411
|
}
|
|
2343
2412
|
capture(event, props) {
|
|
2344
2413
|
if (METRIKA_GOALS.includes(event)) this.ym("reachGoal", event, props);
|
|
@@ -2354,16 +2423,27 @@ var MetrikaSink = class {
|
|
|
2354
2423
|
setZone(zone) {
|
|
2355
2424
|
this.live = zone === "public";
|
|
2356
2425
|
}
|
|
2426
|
+
setConsent(granted) {
|
|
2427
|
+
this.consented = granted;
|
|
2428
|
+
}
|
|
2357
2429
|
};
|
|
2358
2430
|
var KEY = /* @__PURE__ */ Symbol.for("takeal.cusfront-sdk.analytics");
|
|
2359
2431
|
var holder = globalThis;
|
|
2360
2432
|
var state = () => holder[KEY];
|
|
2433
|
+
function loaded(s) {
|
|
2434
|
+
return [s.posthog, s.metrika].filter((x) => !!x);
|
|
2435
|
+
}
|
|
2361
2436
|
function sinks(s) {
|
|
2437
|
+
if (!s.consent) return [];
|
|
2438
|
+
if (s.options.posthog?.key && !s.posthog) {
|
|
2439
|
+
s.posthog = new PostHogSink(s.options.posthog, s.zone);
|
|
2440
|
+
if (s.userId) s.posthog.identify(s.userId);
|
|
2441
|
+
}
|
|
2362
2442
|
if (s.zone === "public" && s.options.metrika && !s.metrika) {
|
|
2363
2443
|
s.metrika = new MetrikaSink(s.options.metrika);
|
|
2364
2444
|
if (s.userId) s.metrika.identify(s.userId);
|
|
2365
2445
|
}
|
|
2366
|
-
return
|
|
2446
|
+
return loaded(s);
|
|
2367
2447
|
}
|
|
2368
2448
|
function initAnalytics(options) {
|
|
2369
2449
|
if (state() || !win().document) return;
|
|
@@ -2372,17 +2452,28 @@ function initAnalytics(options) {
|
|
|
2372
2452
|
"[analytics] Yandex Metrica is on a page outside the public zone; it must not be."
|
|
2373
2453
|
);
|
|
2374
2454
|
}
|
|
2375
|
-
const s = { options, zone: options.zone };
|
|
2455
|
+
const s = { options, zone: options.zone, consent: options.consent !== false };
|
|
2376
2456
|
holder[KEY] = s;
|
|
2377
|
-
if (options.posthog?.key) s.posthog = new PostHogSink(options.posthog, options.zone);
|
|
2378
2457
|
sinks(s);
|
|
2379
2458
|
if (options.initialPageview !== false) page();
|
|
2380
2459
|
}
|
|
2460
|
+
function setAnalyticsConsent(granted) {
|
|
2461
|
+
const s = state();
|
|
2462
|
+
if (!s || s.consent === granted) return;
|
|
2463
|
+
s.consent = granted;
|
|
2464
|
+
const before = loaded(s);
|
|
2465
|
+
for (const sink of before) sink.setConsent(granted);
|
|
2466
|
+
if (granted) {
|
|
2467
|
+
sinks(s);
|
|
2468
|
+
if (s.lastPage === void 0 && s.options.initialPageview !== false) page();
|
|
2469
|
+
}
|
|
2470
|
+
}
|
|
2381
2471
|
function setAnalyticsZone(zone) {
|
|
2382
2472
|
const s = state();
|
|
2383
2473
|
if (!s || s.zone === zone) return;
|
|
2384
2474
|
s.zone = zone;
|
|
2385
|
-
|
|
2475
|
+
sinks(s);
|
|
2476
|
+
for (const sink of loaded(s)) sink.setZone(zone);
|
|
2386
2477
|
}
|
|
2387
2478
|
function track(event, props = {}) {
|
|
2388
2479
|
const s = state();
|
|
@@ -2394,7 +2485,7 @@ function page(url) {
|
|
|
2394
2485
|
const s = state();
|
|
2395
2486
|
const w = win();
|
|
2396
2487
|
const raw = url ?? w.location?.href;
|
|
2397
|
-
if (!s || !raw) return;
|
|
2488
|
+
if (!s || !s.consent || !raw) return;
|
|
2398
2489
|
const clean2 = sanitizeUrl(raw);
|
|
2399
2490
|
if (clean2 === s.lastPage) return;
|
|
2400
2491
|
const referrer = s.lastPage ?? (w.document?.referrer ? sanitizeUrl(w.document.referrer) : void 0);
|
|
@@ -2411,7 +2502,7 @@ function resetAnalytics() {
|
|
|
2411
2502
|
const s = state();
|
|
2412
2503
|
if (!s) return;
|
|
2413
2504
|
s.userId = void 0;
|
|
2414
|
-
for (const sink of
|
|
2505
|
+
for (const sink of loaded(s)) sink.reset();
|
|
2415
2506
|
}
|
|
2416
2507
|
async function posthogDistinctId(timeoutMs = 3e3) {
|
|
2417
2508
|
const ready = state()?.posthog?.ready;
|
|
@@ -2493,11 +2584,13 @@ exports.ApiError = ApiError;
|
|
|
2493
2584
|
exports.CLIENT_HEADER = CLIENT_HEADER;
|
|
2494
2585
|
exports.DISPUTE_DOCUMENTS_CONSENT = DISPUTE_DOCUMENTS_CONSENT;
|
|
2495
2586
|
exports.HOLDER_DATA_CONSENT = HOLDER_DATA_CONSENT;
|
|
2587
|
+
exports.MASK_TEXT_CLASS = MASK_TEXT_CLASS;
|
|
2496
2588
|
exports.METRIKA_GOALS = METRIKA_GOALS;
|
|
2497
2589
|
exports.NO_CAPTURE_CLASS = NO_CAPTURE_CLASS;
|
|
2498
2590
|
exports.NetworkError = NetworkError;
|
|
2499
2591
|
exports.SDK_VERSION = SDK_VERSION;
|
|
2500
2592
|
exports.SUPPORTED_MEISTER = SUPPORTED_MEISTER;
|
|
2593
|
+
exports.ZONE_ATTRIBUTE = ZONE_ATTRIBUTE;
|
|
2501
2594
|
exports.analyticsIds = analyticsIds;
|
|
2502
2595
|
exports.anonymousKey = anonymousKey;
|
|
2503
2596
|
exports.createClient = createClient;
|
|
@@ -2511,6 +2604,7 @@ exports.initAnalytics = initAnalytics;
|
|
|
2511
2604
|
exports.isApiError = isApiError;
|
|
2512
2605
|
exports.isCardOtp = isCardOtp;
|
|
2513
2606
|
exports.isNetworkError = isNetworkError;
|
|
2607
|
+
exports.maskRecordedText = maskRecordedText;
|
|
2514
2608
|
exports.page = page;
|
|
2515
2609
|
exports.posthogDistinctId = posthogDistinctId;
|
|
2516
2610
|
exports.priceChangedQuote = priceChangedQuote;
|
|
@@ -2521,6 +2615,7 @@ exports.revealState = revealState;
|
|
|
2521
2615
|
exports.sanitizeProperties = sanitizeProperties;
|
|
2522
2616
|
exports.sanitizeUrl = sanitizeUrl;
|
|
2523
2617
|
exports.satisfies = satisfies;
|
|
2618
|
+
exports.setAnalyticsConsent = setAnalyticsConsent;
|
|
2524
2619
|
exports.setAnalyticsZone = setAnalyticsZone;
|
|
2525
2620
|
exports.track = track;
|
|
2526
2621
|
exports.withAnalyticsIds = withAnalyticsIds;
|