@takeal/cusfront-sdk 0.6.2 → 0.6.3
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 +15 -0
- package/README.md +32 -0
- package/dist/{cards-DzhPVA9N.d.ts → cards-BrqeBqLV.d.ts} +432 -1
- package/dist/{cards-DU2DdhYO.d.cts → cards-ofoGRU9v.d.cts} +432 -1
- package/dist/index.cjs +241 -205
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +4 -6
- package/dist/index.d.ts +4 -6
- package/dist/index.js +241 -205
- package/dist/index.js.map +1 -1
- package/dist/react/index.d.cts +1 -2
- package/dist/react/index.d.ts +1 -2
- package/dist/resources/auth.cjs +23 -1
- package/dist/resources/auth.cjs.map +1 -1
- package/dist/resources/auth.d.cts +13 -2
- package/dist/resources/auth.d.ts +13 -2
- package/dist/resources/auth.js +23 -1
- package/dist/resources/auth.js.map +1 -1
- package/dist/resources/cards.cjs +34 -0
- 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 +34 -1
- package/dist/resources/cards.js.map +1 -1
- package/dist/resources/deposits.cjs.map +1 -1
- package/dist/resources/deposits.d.cts +1 -2
- package/dist/resources/deposits.d.ts +1 -2
- package/dist/resources/deposits.js.map +1 -1
- package/dist/resources/funding-options.d.cts +1 -2
- package/dist/resources/funding-options.d.ts +1 -2
- package/dist/resources/me.d.cts +1 -0
- package/dist/resources/me.d.ts +1 -0
- package/dist/telegram.cjs +241 -205
- package/dist/telegram.cjs.map +1 -1
- package/dist/telegram.d.cts +1 -2
- package/dist/telegram.d.ts +1 -2
- package/dist/telegram.js +241 -205
- package/dist/telegram.js.map +1 -1
- package/package.json +1 -1
- package/dist/deposits-BEkNeE-v.d.cts +0 -373
- package/dist/deposits-Dt6A76MB.d.ts +0 -373
package/dist/index.d.cts
CHANGED
|
@@ -2,10 +2,8 @@ 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
4
|
export { ChangePasswordInput, EmailChangeRequested, ExchangeTelegramInput, JwtIssued, LinkTelegramInput, LoginInput, LoginResponse, OtpSentResponse, RegisterInput, Session, TelegramLink, TelegramUnknown, TotpRequired, TotpSetupComplete, TotpSetupRequired, User } from './resources/auth.cjs';
|
|
5
|
-
import {
|
|
6
|
-
export {
|
|
7
|
-
import { b as CardsResource } from './cards-DU2DdhYO.cjs';
|
|
8
|
-
export { A as Address, B as BillingAddress, a as Card, c as CardBalance, d as CardDesignRef, e as CardForm, C as CardProduct, f as CardProductPrice, g as CardStatus, h as CardStatusSource, i as CardTopUp, j as CardTopUpStatus, k as CardTransfer, l as CardType, m as Cardholder, n as CloseBlockedReason, o as CreateCardInput, p as CustomerInfo, I as IssuanceBonus, R as RevealCardInput, q as RevealedCard, S as SetPinInput, T as TopUpInput, r as TopUpResult, s as TopUpTerms, t as TransferInput, u as TransferResult, U as UpdateCardInput } from './cards-DU2DdhYO.cjs';
|
|
5
|
+
import { b as DepositsResource, F as FundingOptionsResource, c as CardsResource } from './cards-ofoGRU9v.cjs';
|
|
6
|
+
export { A as Address, B as BillingAddress, a as Card, d as CardBalance, e as CardDesignRef, f as CardForm, g as CardLoadStatus, h as CardOrder, i as CardOrderError, j as CardOrderInput, C as CardProduct, k as CardProductPrice, l as CardStatus, m as CardStatusSource, n as CardTopUp, o as CardTopUpStatus, p as CardTransfer, q as CardType, r as Cardholder, s as CloseBlockedReason, t as CreateCardInput, u as CreateDepositRefundInput, v as CreateQuoteInput, w as CustomerInfo, D as Deposit, x as DepositMethod, y as DepositStatus, z as DepositTarget, E as FeeKind, G as FunderMode, H as FundingOption, I as FundingQuote, J as InitiateDepositInput, K as IssuanceBonus, L as IssueCardInput, M as MethodTerms, R as Refund, N as RevealCardInput, O as RevealedCard, S as SetPinInput, T as TopUpInput, P as TopUpResult, Q as TopUpTerms, U as TransferInput, V as TransferResult, W as UpdateCardInput } from './cards-ofoGRU9v.cjs';
|
|
9
7
|
import { BalanceResource } from './resources/balance.cjs';
|
|
10
8
|
export { Balance } from './resources/balance.cjs';
|
|
11
9
|
import { BonusResource } from './resources/bonus.cjs';
|
|
@@ -75,7 +73,7 @@ interface BrandConfig {
|
|
|
75
73
|
* Which platform versions this SDK works with, as a semver range:
|
|
76
74
|
* comparators separated by ", ". Keep this the only definition.
|
|
77
75
|
*/
|
|
78
|
-
declare const SUPPORTED_MEISTER = ">=0.6.
|
|
76
|
+
declare const SUPPORTED_MEISTER = ">=0.6.8, <0.7.0";
|
|
79
77
|
/** What `client.ready()` returns. */
|
|
80
78
|
interface ReadyInfo {
|
|
81
79
|
/** `true` when the platform reported a version inside `supportedMeister`. */
|
|
@@ -181,7 +179,7 @@ declare function isNetworkError(e: unknown): e is NetworkError;
|
|
|
181
179
|
* `define`. `src/version.test.ts` checks it matches `package.json`, so a
|
|
182
180
|
* release bump that forgets this file fails the test run.
|
|
183
181
|
*/
|
|
184
|
-
declare const SDK_VERSION = "0.6.
|
|
182
|
+
declare const SDK_VERSION = "0.6.3";
|
|
185
183
|
|
|
186
184
|
/**
|
|
187
185
|
* `@takeal/cusfront-sdk` — typed client for the Takeal end-user API.
|
package/dist/index.d.ts
CHANGED
|
@@ -2,10 +2,8 @@ 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
4
|
export { ChangePasswordInput, EmailChangeRequested, ExchangeTelegramInput, JwtIssued, LinkTelegramInput, LoginInput, LoginResponse, OtpSentResponse, RegisterInput, Session, TelegramLink, TelegramUnknown, TotpRequired, TotpSetupComplete, TotpSetupRequired, User } from './resources/auth.js';
|
|
5
|
-
import {
|
|
6
|
-
export {
|
|
7
|
-
import { b as CardsResource } from './cards-DzhPVA9N.js';
|
|
8
|
-
export { A as Address, B as BillingAddress, a as Card, c as CardBalance, d as CardDesignRef, e as CardForm, C as CardProduct, f as CardProductPrice, g as CardStatus, h as CardStatusSource, i as CardTopUp, j as CardTopUpStatus, k as CardTransfer, l as CardType, m as Cardholder, n as CloseBlockedReason, o as CreateCardInput, p as CustomerInfo, I as IssuanceBonus, R as RevealCardInput, q as RevealedCard, S as SetPinInput, T as TopUpInput, r as TopUpResult, s as TopUpTerms, t as TransferInput, u as TransferResult, U as UpdateCardInput } from './cards-DzhPVA9N.js';
|
|
5
|
+
import { b as DepositsResource, F as FundingOptionsResource, c as CardsResource } from './cards-BrqeBqLV.js';
|
|
6
|
+
export { A as Address, B as BillingAddress, a as Card, d as CardBalance, e as CardDesignRef, f as CardForm, g as CardLoadStatus, h as CardOrder, i as CardOrderError, j as CardOrderInput, C as CardProduct, k as CardProductPrice, l as CardStatus, m as CardStatusSource, n as CardTopUp, o as CardTopUpStatus, p as CardTransfer, q as CardType, r as Cardholder, s as CloseBlockedReason, t as CreateCardInput, u as CreateDepositRefundInput, v as CreateQuoteInput, w as CustomerInfo, D as Deposit, x as DepositMethod, y as DepositStatus, z as DepositTarget, E as FeeKind, G as FunderMode, H as FundingOption, I as FundingQuote, J as InitiateDepositInput, K as IssuanceBonus, L as IssueCardInput, M as MethodTerms, R as Refund, N as RevealCardInput, O as RevealedCard, S as SetPinInput, T as TopUpInput, P as TopUpResult, Q as TopUpTerms, U as TransferInput, V as TransferResult, W as UpdateCardInput } from './cards-BrqeBqLV.js';
|
|
9
7
|
import { BalanceResource } from './resources/balance.js';
|
|
10
8
|
export { Balance } from './resources/balance.js';
|
|
11
9
|
import { BonusResource } from './resources/bonus.js';
|
|
@@ -75,7 +73,7 @@ interface BrandConfig {
|
|
|
75
73
|
* Which platform versions this SDK works with, as a semver range:
|
|
76
74
|
* comparators separated by ", ". Keep this the only definition.
|
|
77
75
|
*/
|
|
78
|
-
declare const SUPPORTED_MEISTER = ">=0.6.
|
|
76
|
+
declare const SUPPORTED_MEISTER = ">=0.6.8, <0.7.0";
|
|
79
77
|
/** What `client.ready()` returns. */
|
|
80
78
|
interface ReadyInfo {
|
|
81
79
|
/** `true` when the platform reported a version inside `supportedMeister`. */
|
|
@@ -181,7 +179,7 @@ declare function isNetworkError(e: unknown): e is NetworkError;
|
|
|
181
179
|
* `define`. `src/version.test.ts` checks it matches `package.json`, so a
|
|
182
180
|
* release bump that forgets this file fails the test run.
|
|
183
181
|
*/
|
|
184
|
-
declare const SDK_VERSION = "0.6.
|
|
182
|
+
declare const SDK_VERSION = "0.6.3";
|
|
185
183
|
|
|
186
184
|
/**
|
|
187
185
|
* `@takeal/cusfront-sdk` — typed client for the Takeal end-user API.
|
package/dist/index.js
CHANGED
|
@@ -135,6 +135,241 @@ async function parseResponse(resp) {
|
|
|
135
135
|
return body;
|
|
136
136
|
}
|
|
137
137
|
|
|
138
|
+
// src/resources/cards.ts
|
|
139
|
+
function cardRequestBody(input) {
|
|
140
|
+
const {
|
|
141
|
+
productId,
|
|
142
|
+
name,
|
|
143
|
+
designId,
|
|
144
|
+
useBonus,
|
|
145
|
+
bonusAmount,
|
|
146
|
+
promoCode,
|
|
147
|
+
consentChannel,
|
|
148
|
+
initial_amount: _ignored,
|
|
149
|
+
...rest
|
|
150
|
+
} = input;
|
|
151
|
+
const body = { ...rest };
|
|
152
|
+
if (productId !== void 0) body["product_id"] = productId;
|
|
153
|
+
if (name !== void 0) body["name"] = name;
|
|
154
|
+
if (designId !== void 0) body["design_id"] = designId;
|
|
155
|
+
if (useBonus !== void 0) body["use_bonus"] = useBonus;
|
|
156
|
+
if (bonusAmount !== void 0) body["bonus_amount"] = bonusAmount;
|
|
157
|
+
if (promoCode !== void 0) body["promo_code"] = promoCode;
|
|
158
|
+
if (consentChannel !== void 0) body["consent_channel"] = consentChannel;
|
|
159
|
+
return body;
|
|
160
|
+
}
|
|
161
|
+
function cardOrderBody(input) {
|
|
162
|
+
const body = {
|
|
163
|
+
product_id: input.productId,
|
|
164
|
+
method: input.method
|
|
165
|
+
};
|
|
166
|
+
if (input.designId !== void 0) body["design_id"] = input.designId;
|
|
167
|
+
if (input.name !== void 0) body["name"] = input.name;
|
|
168
|
+
if (input.funderSlug !== void 0) body["funder_slug"] = input.funderSlug;
|
|
169
|
+
if (input.currency !== void 0) body["currency"] = input.currency;
|
|
170
|
+
if (input.extraLoad !== void 0) body["extra_load"] = input.extraLoad;
|
|
171
|
+
if (input.promoCode !== void 0) body["promo_code"] = input.promoCode;
|
|
172
|
+
if (input.useBonus !== void 0) body["use_bonus"] = input.useBonus;
|
|
173
|
+
if (input.consents !== void 0) body["consents"] = input.consents;
|
|
174
|
+
if (input.consentChannel !== void 0) body["consent_channel"] = input.consentChannel;
|
|
175
|
+
if (input.metadata !== void 0) body["metadata"] = input.metadata;
|
|
176
|
+
return body;
|
|
177
|
+
}
|
|
178
|
+
var CardsResource = class {
|
|
179
|
+
constructor(http) {
|
|
180
|
+
this.http = http;
|
|
181
|
+
}
|
|
182
|
+
/**
|
|
183
|
+
* Issue a card backed by the user's wallet balance. Resolves to the new
|
|
184
|
+
* `Card`. On a ledger failure after provider creation, the Takeal API rolls the row
|
|
185
|
+
* to `failed` (never an orphaned active card); inspect `status` /
|
|
186
|
+
* `failure_reason` on the result.
|
|
187
|
+
*/
|
|
188
|
+
async create(input) {
|
|
189
|
+
const { idempotencyKey, ...card } = input;
|
|
190
|
+
return this.http.post("/me/cards", {
|
|
191
|
+
body: cardRequestBody(card),
|
|
192
|
+
idempotencyKey
|
|
193
|
+
});
|
|
194
|
+
}
|
|
195
|
+
/**
|
|
196
|
+
* Buy a card in one step: the API prices the product in the payment's
|
|
197
|
+
* currency, locks the rate and opens the top-up that issues the card.
|
|
198
|
+
* Send the user to `order.deposit.redirect_url`; the card shows as
|
|
199
|
+
* `pending_payment` until the payment is confirmed. The same
|
|
200
|
+
* `idempotencyKey` returns the same order.
|
|
201
|
+
* Errors: 400 `unknown_product` / `method_not_available` / a limit of the
|
|
202
|
+
* way of paying, 503 no funding connector or no exchange rate.
|
|
203
|
+
*/
|
|
204
|
+
async order(input) {
|
|
205
|
+
const { idempotencyKey, ...order } = input;
|
|
206
|
+
return this.http.post("/me/card-orders", {
|
|
207
|
+
body: cardOrderBody(order),
|
|
208
|
+
idempotencyKey
|
|
209
|
+
});
|
|
210
|
+
}
|
|
211
|
+
/**
|
|
212
|
+
* The cards the caller can order, in the order the storefront shows them
|
|
213
|
+
* (`is_default` marks the one issued when none is chosen). Each item
|
|
214
|
+
* carries its product card (name, tagline, benefits, tile picture),
|
|
215
|
+
* artwork, and the issuance price after the caller's subscription
|
|
216
|
+
* discount, in the caller's wallet currency. Pass an item's `id` as
|
|
217
|
+
* `productId` to {@link create}.
|
|
218
|
+
*/
|
|
219
|
+
async listProducts() {
|
|
220
|
+
return this.http.get("/me/card-products");
|
|
221
|
+
}
|
|
222
|
+
/** One product from the catalog. 404 when unknown, disabled or hidden. */
|
|
223
|
+
async getProduct(id) {
|
|
224
|
+
return this.http.get(`/me/card-products/${encodeURIComponent(id)}`);
|
|
225
|
+
}
|
|
226
|
+
/**
|
|
227
|
+
* The public catalog: the same products, order and default as
|
|
228
|
+
* {@link listProducts}, but readable before sign-in, for a landing page or
|
|
229
|
+
* the cabinet's first screen. Prices are list prices (`discount_bps` is
|
|
230
|
+
* always 0); once the user is signed in, {@link listProducts} shows what
|
|
231
|
+
* they pay. The API lets caches keep this response for a minute.
|
|
232
|
+
*/
|
|
233
|
+
async catalog() {
|
|
234
|
+
return this.http.get("/card-products");
|
|
235
|
+
}
|
|
236
|
+
/**
|
|
237
|
+
* Rename the caller's own card or change its design. Resolves to the
|
|
238
|
+
* updated card. 404 if the card isn't the caller's; 400 `invalid_name` /
|
|
239
|
+
* `design_not_allowed` on a bad value.
|
|
240
|
+
*/
|
|
241
|
+
async update(id, input) {
|
|
242
|
+
const body = {};
|
|
243
|
+
if (input.name !== void 0) body["name"] = input.name;
|
|
244
|
+
if (input.designId !== void 0) body["design_id"] = input.designId;
|
|
245
|
+
return this.http.patch(`/me/cards/${encodeURIComponent(id)}`, {
|
|
246
|
+
body
|
|
247
|
+
});
|
|
248
|
+
}
|
|
249
|
+
/** Fetch one card by id. */
|
|
250
|
+
async get(id) {
|
|
251
|
+
return this.http.get(`/me/cards/${encodeURIComponent(id)}`);
|
|
252
|
+
}
|
|
253
|
+
/** List the caller's cards, most recent first. */
|
|
254
|
+
async list() {
|
|
255
|
+
return this.http.get("/me/cards");
|
|
256
|
+
}
|
|
257
|
+
/**
|
|
258
|
+
* Remaining balance of a prepaid card. `currency` is required by the Takeal API and
|
|
259
|
+
* forwarded as a query param.
|
|
260
|
+
*/
|
|
261
|
+
async balance(id, currency) {
|
|
262
|
+
const q = new URLSearchParams({ currency }).toString();
|
|
263
|
+
return this.http.get(`/me/cards/${encodeURIComponent(id)}/balance?${q}`);
|
|
264
|
+
}
|
|
265
|
+
/**
|
|
266
|
+
* What a top-up of this card can be right now: whether it is possible, the
|
|
267
|
+
* currency, the wallet balance, and the product's floor and cap for one
|
|
268
|
+
* top-up. Read it before drawing the form. 404 if the card isn't the caller's.
|
|
269
|
+
*/
|
|
270
|
+
async topUpTerms(id) {
|
|
271
|
+
return this.http.get(`/me/cards/${encodeURIComponent(id)}/topup`);
|
|
272
|
+
}
|
|
273
|
+
/**
|
|
274
|
+
* Move money from the wallet onto the caller's own card. The wallet is
|
|
275
|
+
* debited first, then the card's provider loads the card; if the provider
|
|
276
|
+
* refuses, the money is back on the wallet and the error says so. Resolves
|
|
277
|
+
* to the card, its new balance and the wallet balance, so no second call
|
|
278
|
+
* is needed. Errors carry a sentence the user can read: 400 outside the
|
|
279
|
+
* floor or cap · 402 not enough in the wallet · 404 not the caller's card ·
|
|
280
|
+
* 409 card frozen, closed or still being issued · 501 provider can't top
|
|
281
|
+
* up · 502/503 provider declined or unreachable (wallet untouched).
|
|
282
|
+
*/
|
|
283
|
+
async topUp(id, input) {
|
|
284
|
+
const { idempotencyKey, amount } = input;
|
|
285
|
+
return this.http.post(`/me/cards/${encodeURIComponent(id)}/topup`, {
|
|
286
|
+
body: { amount },
|
|
287
|
+
idempotencyKey
|
|
288
|
+
});
|
|
289
|
+
}
|
|
290
|
+
/**
|
|
291
|
+
* Move money from one of the caller's cards to another. Both must be
|
|
292
|
+
* theirs, active, in the same currency and of the same kind. The money
|
|
293
|
+
* travels through the wallet one leg at a time: when the second leg does
|
|
294
|
+
* not go through, the call still resolves, `transfer.status` is
|
|
295
|
+
* `on_wallet` and the money is on the wallet — never between two cards.
|
|
296
|
+
* Errors carry a sentence the user can read: 400 the same card twice,
|
|
297
|
+
* different currencies or different kinds · 402 the card holds less than
|
|
298
|
+
* that · 404 one of the cards isn't theirs · 409 a card is frozen, closed
|
|
299
|
+
* or still being issued, or the key was reused with a different body ·
|
|
300
|
+
* 501/502/503 the provider cannot or will not move it.
|
|
301
|
+
*/
|
|
302
|
+
async transfer(fromCardId, input) {
|
|
303
|
+
const { toCardId, amount, idempotencyKey } = input;
|
|
304
|
+
return this.http.post(`/me/cards/${encodeURIComponent(fromCardId)}/transfer`, {
|
|
305
|
+
body: { to_card_id: toCardId, amount },
|
|
306
|
+
idempotencyKey
|
|
307
|
+
});
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Freeze the caller's own card. Reversible via {@link unfreeze} while
|
|
311
|
+
* `status_source` is `holder` or `operator`. The optional `reason` is
|
|
312
|
+
* recorded on the audit trail. Resolves to the updated card. 404 if the
|
|
313
|
+
* card isn't the caller's; 409 `card_locked` when support holds it; 501 if
|
|
314
|
+
* the issuer can't freeze.
|
|
315
|
+
*/
|
|
316
|
+
async freeze(id, reason) {
|
|
317
|
+
return this.http.post(`/me/cards/${encodeURIComponent(id)}/freeze`, { body: { reason } });
|
|
318
|
+
}
|
|
319
|
+
/**
|
|
320
|
+
* Reveal the FULL PAN + CVV for the caller's own card. The signed-in
|
|
321
|
+
* session is all the API asks for; the call is rate-limited and audited
|
|
322
|
+
* server-side. The Takeal API never persists this data and marks the
|
|
323
|
+
* response no-store; the SDK returns it verbatim and holds nothing.
|
|
324
|
+
*
|
|
325
|
+
* **Consumer security duties** (the SDK can't enforce these for you):
|
|
326
|
+
* keep the result in volatile memory only, never write it to
|
|
327
|
+
* localStorage / logs, and clear it within `expires_in_seconds`.
|
|
328
|
+
*
|
|
329
|
+
* The result is the numbers, or `reveal_url` with empty `pan` and `cvv`
|
|
330
|
+
* when the issuer shows them on a page of its own: open that page in a
|
|
331
|
+
* frame right away, it is short-lived.
|
|
332
|
+
*
|
|
333
|
+
* 403 not your card · 409 `card_locked` · 429 rate-limited · 501 connector
|
|
334
|
+
* has no sensitive-data endpoint · 503 `provider_unavailable`.
|
|
335
|
+
*/
|
|
336
|
+
async reveal(id, _input) {
|
|
337
|
+
return this.http.post(`/me/cards/${encodeURIComponent(id)}/reveal`);
|
|
338
|
+
}
|
|
339
|
+
/**
|
|
340
|
+
* Unfreeze a previously-frozen card. Idempotent on an already-active card.
|
|
341
|
+
* A card the issuer froze (`status_source: "provider"`) is not the
|
|
342
|
+
* holder's to unfreeze: the API answers 409 `card_locked`, so hide the
|
|
343
|
+
* button and say the freeze is lifted through the issuer's support.
|
|
344
|
+
*/
|
|
345
|
+
async unfreeze(id) {
|
|
346
|
+
return this.http.post(`/me/cards/${encodeURIComponent(id)}/unfreeze`, { body: {} });
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* Set the PIN of the caller's own physical card. The session is enough; the
|
|
350
|
+
* call is rate-limited like {@link reveal} and the PIN is kept nowhere.
|
|
351
|
+
* Resolves to the card; the user also gets a notification that the PIN
|
|
352
|
+
* was set. 400 not four to six digits or the card is not active · 403 not
|
|
353
|
+
* your card · 409 `card_locked`, or `provider_refused` when the issuer did
|
|
354
|
+
* not take it · 429 too many attempts · 501 a virtual card has no PIN.
|
|
355
|
+
*/
|
|
356
|
+
async setPin(id, input) {
|
|
357
|
+
return this.http.post(`/me/cards/${encodeURIComponent(id)}/pin`, {
|
|
358
|
+
body: { pin: input.pin }
|
|
359
|
+
});
|
|
360
|
+
}
|
|
361
|
+
/**
|
|
362
|
+
* Terminate the caller's own card. **One-way** — a terminated card cannot be
|
|
363
|
+
* reactivated. The optional `reason` is audited. Idempotent on an
|
|
364
|
+
* already-terminated card.
|
|
365
|
+
*/
|
|
366
|
+
async terminate(id, reason) {
|
|
367
|
+
return this.http.post(`/me/cards/${encodeURIComponent(id)}/terminate`, {
|
|
368
|
+
body: { reason }
|
|
369
|
+
});
|
|
370
|
+
}
|
|
371
|
+
};
|
|
372
|
+
|
|
138
373
|
// src/resources/auth.ts
|
|
139
374
|
function withRemember(input) {
|
|
140
375
|
const { remember, ...rest } = input;
|
|
@@ -233,8 +468,11 @@ var AuthResource = class {
|
|
|
233
468
|
* Errors: 400 `validation` / `currency_not_allowed` / `consents_required`
|
|
234
469
|
* / `unknown_consent`, 409 email taken. */
|
|
235
470
|
async register(input) {
|
|
471
|
+
const { cardOrder, ...rest } = input;
|
|
472
|
+
const body = withRemember(rest);
|
|
473
|
+
if (cardOrder !== void 0) body["card_order"] = cardOrderBody(cardOrder);
|
|
236
474
|
const resp = await this.http.post("/auth/register", {
|
|
237
|
-
body
|
|
475
|
+
body,
|
|
238
476
|
skipAuth: true
|
|
239
477
|
});
|
|
240
478
|
await this.keep(resp);
|
|
@@ -358,208 +596,6 @@ var AuthResource = class {
|
|
|
358
596
|
}
|
|
359
597
|
};
|
|
360
598
|
|
|
361
|
-
// src/resources/cards.ts
|
|
362
|
-
function cardRequestBody(input) {
|
|
363
|
-
const {
|
|
364
|
-
productId,
|
|
365
|
-
name,
|
|
366
|
-
designId,
|
|
367
|
-
useBonus,
|
|
368
|
-
bonusAmount,
|
|
369
|
-
promoCode,
|
|
370
|
-
consentChannel,
|
|
371
|
-
initial_amount: _ignored,
|
|
372
|
-
...rest
|
|
373
|
-
} = input;
|
|
374
|
-
const body = { ...rest };
|
|
375
|
-
if (productId !== void 0) body["product_id"] = productId;
|
|
376
|
-
if (name !== void 0) body["name"] = name;
|
|
377
|
-
if (designId !== void 0) body["design_id"] = designId;
|
|
378
|
-
if (useBonus !== void 0) body["use_bonus"] = useBonus;
|
|
379
|
-
if (bonusAmount !== void 0) body["bonus_amount"] = bonusAmount;
|
|
380
|
-
if (promoCode !== void 0) body["promo_code"] = promoCode;
|
|
381
|
-
if (consentChannel !== void 0) body["consent_channel"] = consentChannel;
|
|
382
|
-
return body;
|
|
383
|
-
}
|
|
384
|
-
var CardsResource = class {
|
|
385
|
-
constructor(http) {
|
|
386
|
-
this.http = http;
|
|
387
|
-
}
|
|
388
|
-
/**
|
|
389
|
-
* Issue a card backed by the user's wallet balance. Resolves to the new
|
|
390
|
-
* `Card`. On a ledger failure after provider creation, the Takeal API rolls the row
|
|
391
|
-
* to `failed` (never an orphaned active card); inspect `status` /
|
|
392
|
-
* `failure_reason` on the result.
|
|
393
|
-
*/
|
|
394
|
-
async create(input) {
|
|
395
|
-
const { idempotencyKey, ...card } = input;
|
|
396
|
-
return this.http.post("/me/cards", {
|
|
397
|
-
body: cardRequestBody(card),
|
|
398
|
-
idempotencyKey
|
|
399
|
-
});
|
|
400
|
-
}
|
|
401
|
-
/**
|
|
402
|
-
* The cards the caller can order, in the order the storefront shows them
|
|
403
|
-
* (`is_default` marks the one issued when none is chosen). Each item
|
|
404
|
-
* carries its product card (name, tagline, benefits, tile picture),
|
|
405
|
-
* artwork, and the issuance price after the caller's subscription
|
|
406
|
-
* discount, in the caller's wallet currency. Pass an item's `id` as
|
|
407
|
-
* `productId` to {@link create}.
|
|
408
|
-
*/
|
|
409
|
-
async listProducts() {
|
|
410
|
-
return this.http.get("/me/card-products");
|
|
411
|
-
}
|
|
412
|
-
/** One product from the catalog. 404 when unknown, disabled or hidden. */
|
|
413
|
-
async getProduct(id) {
|
|
414
|
-
return this.http.get(`/me/card-products/${encodeURIComponent(id)}`);
|
|
415
|
-
}
|
|
416
|
-
/**
|
|
417
|
-
* The public catalog: the same products, order and default as
|
|
418
|
-
* {@link listProducts}, but readable before sign-in, for a landing page or
|
|
419
|
-
* the cabinet's first screen. Prices are list prices (`discount_bps` is
|
|
420
|
-
* always 0); once the user is signed in, {@link listProducts} shows what
|
|
421
|
-
* they pay. The API lets caches keep this response for a minute.
|
|
422
|
-
*/
|
|
423
|
-
async catalog() {
|
|
424
|
-
return this.http.get("/card-products");
|
|
425
|
-
}
|
|
426
|
-
/**
|
|
427
|
-
* Rename the caller's own card or change its design. Resolves to the
|
|
428
|
-
* updated card. 404 if the card isn't the caller's; 400 `invalid_name` /
|
|
429
|
-
* `design_not_allowed` on a bad value.
|
|
430
|
-
*/
|
|
431
|
-
async update(id, input) {
|
|
432
|
-
const body = {};
|
|
433
|
-
if (input.name !== void 0) body["name"] = input.name;
|
|
434
|
-
if (input.designId !== void 0) body["design_id"] = input.designId;
|
|
435
|
-
return this.http.patch(`/me/cards/${encodeURIComponent(id)}`, {
|
|
436
|
-
body
|
|
437
|
-
});
|
|
438
|
-
}
|
|
439
|
-
/** Fetch one card by id. */
|
|
440
|
-
async get(id) {
|
|
441
|
-
return this.http.get(`/me/cards/${encodeURIComponent(id)}`);
|
|
442
|
-
}
|
|
443
|
-
/** List the caller's cards, most recent first. */
|
|
444
|
-
async list() {
|
|
445
|
-
return this.http.get("/me/cards");
|
|
446
|
-
}
|
|
447
|
-
/**
|
|
448
|
-
* Remaining balance of a prepaid card. `currency` is required by the Takeal API and
|
|
449
|
-
* forwarded as a query param.
|
|
450
|
-
*/
|
|
451
|
-
async balance(id, currency) {
|
|
452
|
-
const q = new URLSearchParams({ currency }).toString();
|
|
453
|
-
return this.http.get(`/me/cards/${encodeURIComponent(id)}/balance?${q}`);
|
|
454
|
-
}
|
|
455
|
-
/**
|
|
456
|
-
* What a top-up of this card can be right now: whether it is possible, the
|
|
457
|
-
* currency, the wallet balance, and the product's floor and cap for one
|
|
458
|
-
* top-up. Read it before drawing the form. 404 if the card isn't the caller's.
|
|
459
|
-
*/
|
|
460
|
-
async topUpTerms(id) {
|
|
461
|
-
return this.http.get(`/me/cards/${encodeURIComponent(id)}/topup`);
|
|
462
|
-
}
|
|
463
|
-
/**
|
|
464
|
-
* Move money from the wallet onto the caller's own card. The wallet is
|
|
465
|
-
* debited first, then the card's provider loads the card; if the provider
|
|
466
|
-
* refuses, the money is back on the wallet and the error says so. Resolves
|
|
467
|
-
* to the card, its new balance and the wallet balance, so no second call
|
|
468
|
-
* is needed. Errors carry a sentence the user can read: 400 outside the
|
|
469
|
-
* floor or cap · 402 not enough in the wallet · 404 not the caller's card ·
|
|
470
|
-
* 409 card frozen, closed or still being issued · 501 provider can't top
|
|
471
|
-
* up · 502/503 provider declined or unreachable (wallet untouched).
|
|
472
|
-
*/
|
|
473
|
-
async topUp(id, input) {
|
|
474
|
-
const { idempotencyKey, amount } = input;
|
|
475
|
-
return this.http.post(`/me/cards/${encodeURIComponent(id)}/topup`, {
|
|
476
|
-
body: { amount },
|
|
477
|
-
idempotencyKey
|
|
478
|
-
});
|
|
479
|
-
}
|
|
480
|
-
/**
|
|
481
|
-
* Move money from one of the caller's cards to another. Both must be
|
|
482
|
-
* theirs, active, in the same currency and of the same kind. The money
|
|
483
|
-
* travels through the wallet one leg at a time: when the second leg does
|
|
484
|
-
* not go through, the call still resolves, `transfer.status` is
|
|
485
|
-
* `on_wallet` and the money is on the wallet — never between two cards.
|
|
486
|
-
* Errors carry a sentence the user can read: 400 the same card twice,
|
|
487
|
-
* different currencies or different kinds · 402 the card holds less than
|
|
488
|
-
* that · 404 one of the cards isn't theirs · 409 a card is frozen, closed
|
|
489
|
-
* or still being issued, or the key was reused with a different body ·
|
|
490
|
-
* 501/502/503 the provider cannot or will not move it.
|
|
491
|
-
*/
|
|
492
|
-
async transfer(fromCardId, input) {
|
|
493
|
-
const { toCardId, amount, idempotencyKey } = input;
|
|
494
|
-
return this.http.post(`/me/cards/${encodeURIComponent(fromCardId)}/transfer`, {
|
|
495
|
-
body: { to_card_id: toCardId, amount },
|
|
496
|
-
idempotencyKey
|
|
497
|
-
});
|
|
498
|
-
}
|
|
499
|
-
/**
|
|
500
|
-
* Freeze the caller's own card. Reversible via {@link unfreeze} while
|
|
501
|
-
* `status_source` is `holder` or `operator`. The optional `reason` is
|
|
502
|
-
* recorded on the audit trail. Resolves to the updated card. 404 if the
|
|
503
|
-
* card isn't the caller's; 409 `card_locked` when support holds it; 501 if
|
|
504
|
-
* the issuer can't freeze.
|
|
505
|
-
*/
|
|
506
|
-
async freeze(id, reason) {
|
|
507
|
-
return this.http.post(`/me/cards/${encodeURIComponent(id)}/freeze`, { body: { reason } });
|
|
508
|
-
}
|
|
509
|
-
/**
|
|
510
|
-
* Reveal the FULL PAN + CVV for the caller's own card. The signed-in
|
|
511
|
-
* session is all the API asks for; the call is rate-limited and audited
|
|
512
|
-
* server-side. The Takeal API never persists this data and marks the
|
|
513
|
-
* response no-store; the SDK returns it verbatim and holds nothing.
|
|
514
|
-
*
|
|
515
|
-
* **Consumer security duties** (the SDK can't enforce these for you):
|
|
516
|
-
* keep the result in volatile memory only, never write it to
|
|
517
|
-
* localStorage / logs, and clear it within `expires_in_seconds`.
|
|
518
|
-
*
|
|
519
|
-
* The result is the numbers, or `reveal_url` with empty `pan` and `cvv`
|
|
520
|
-
* when the issuer shows them on a page of its own: open that page in a
|
|
521
|
-
* frame right away, it is short-lived.
|
|
522
|
-
*
|
|
523
|
-
* 403 not your card · 409 `card_locked` · 429 rate-limited · 501 connector
|
|
524
|
-
* has no sensitive-data endpoint · 503 `provider_unavailable`.
|
|
525
|
-
*/
|
|
526
|
-
async reveal(id, _input) {
|
|
527
|
-
return this.http.post(`/me/cards/${encodeURIComponent(id)}/reveal`);
|
|
528
|
-
}
|
|
529
|
-
/**
|
|
530
|
-
* Unfreeze a previously-frozen card. Idempotent on an already-active card.
|
|
531
|
-
* A card the issuer froze (`status_source: "provider"`) is not the
|
|
532
|
-
* holder's to unfreeze: the API answers 409 `card_locked`, so hide the
|
|
533
|
-
* button and say the freeze is lifted through the issuer's support.
|
|
534
|
-
*/
|
|
535
|
-
async unfreeze(id) {
|
|
536
|
-
return this.http.post(`/me/cards/${encodeURIComponent(id)}/unfreeze`, { body: {} });
|
|
537
|
-
}
|
|
538
|
-
/**
|
|
539
|
-
* Set the PIN of the caller's own physical card. The session is enough; the
|
|
540
|
-
* call is rate-limited like {@link reveal} and the PIN is kept nowhere.
|
|
541
|
-
* Resolves to the card; the user also gets a notification that the PIN
|
|
542
|
-
* was set. 400 not four to six digits or the card is not active · 403 not
|
|
543
|
-
* your card · 409 `card_locked`, or `provider_refused` when the issuer did
|
|
544
|
-
* not take it · 429 too many attempts · 501 a virtual card has no PIN.
|
|
545
|
-
*/
|
|
546
|
-
async setPin(id, input) {
|
|
547
|
-
return this.http.post(`/me/cards/${encodeURIComponent(id)}/pin`, {
|
|
548
|
-
body: { pin: input.pin }
|
|
549
|
-
});
|
|
550
|
-
}
|
|
551
|
-
/**
|
|
552
|
-
* Terminate the caller's own card. **One-way** — a terminated card cannot be
|
|
553
|
-
* reactivated. The optional `reason` is audited. Idempotent on an
|
|
554
|
-
* already-terminated card.
|
|
555
|
-
*/
|
|
556
|
-
async terminate(id, reason) {
|
|
557
|
-
return this.http.post(`/me/cards/${encodeURIComponent(id)}/terminate`, {
|
|
558
|
-
body: { reason }
|
|
559
|
-
});
|
|
560
|
-
}
|
|
561
|
-
};
|
|
562
|
-
|
|
563
599
|
// src/resources/deposits.ts
|
|
564
600
|
var DepositsResource = class {
|
|
565
601
|
constructor(http) {
|
|
@@ -1258,7 +1294,7 @@ var FundingOptionsResource = class {
|
|
|
1258
1294
|
};
|
|
1259
1295
|
|
|
1260
1296
|
// src/version.ts
|
|
1261
|
-
var SDK_VERSION = "0.6.
|
|
1297
|
+
var SDK_VERSION = "0.6.3";
|
|
1262
1298
|
|
|
1263
1299
|
// src/client-platform.ts
|
|
1264
1300
|
var CLIENT_HEADER = "X-Takeal-Client";
|
|
@@ -1333,7 +1369,7 @@ function isAbsolute(url) {
|
|
|
1333
1369
|
}
|
|
1334
1370
|
|
|
1335
1371
|
// src/compat.ts
|
|
1336
|
-
var SUPPORTED_MEISTER = ">=0.6.
|
|
1372
|
+
var SUPPORTED_MEISTER = ">=0.6.8, <0.7.0";
|
|
1337
1373
|
var SEMVER = /^v?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/;
|
|
1338
1374
|
function parse(v) {
|
|
1339
1375
|
const m = SEMVER.exec(v.trim());
|