@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/telegram.d.cts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { CusfrontClient, CreateClientOptions } from './index.cjs';
|
|
2
2
|
import { JwtIssued, TelegramUnknown } from './resources/auth.cjs';
|
|
3
3
|
import './http-DeANAoTs.cjs';
|
|
4
|
-
import './
|
|
5
|
-
import './cards-DU2DdhYO.cjs';
|
|
4
|
+
import './cards-ofoGRU9v.cjs';
|
|
6
5
|
import './resources/consents.cjs';
|
|
7
6
|
import './resources/balance.cjs';
|
|
8
7
|
import './resources/bonus.cjs';
|
package/dist/telegram.d.ts
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
1
|
import { CusfrontClient, CreateClientOptions } from './index.js';
|
|
2
2
|
import { JwtIssued, TelegramUnknown } from './resources/auth.js';
|
|
3
3
|
import './http-DeANAoTs.js';
|
|
4
|
-
import './
|
|
5
|
-
import './cards-DzhPVA9N.js';
|
|
4
|
+
import './cards-BrqeBqLV.js';
|
|
6
5
|
import './resources/consents.js';
|
|
7
6
|
import './resources/balance.js';
|
|
8
7
|
import './resources/bonus.js';
|
package/dist/telegram.js
CHANGED
|
@@ -132,6 +132,241 @@ async function parseResponse(resp) {
|
|
|
132
132
|
return body;
|
|
133
133
|
}
|
|
134
134
|
|
|
135
|
+
// src/resources/cards.ts
|
|
136
|
+
function cardRequestBody(input) {
|
|
137
|
+
const {
|
|
138
|
+
productId,
|
|
139
|
+
name,
|
|
140
|
+
designId,
|
|
141
|
+
useBonus,
|
|
142
|
+
bonusAmount,
|
|
143
|
+
promoCode,
|
|
144
|
+
consentChannel,
|
|
145
|
+
initial_amount: _ignored,
|
|
146
|
+
...rest
|
|
147
|
+
} = input;
|
|
148
|
+
const body = { ...rest };
|
|
149
|
+
if (productId !== void 0) body["product_id"] = productId;
|
|
150
|
+
if (name !== void 0) body["name"] = name;
|
|
151
|
+
if (designId !== void 0) body["design_id"] = designId;
|
|
152
|
+
if (useBonus !== void 0) body["use_bonus"] = useBonus;
|
|
153
|
+
if (bonusAmount !== void 0) body["bonus_amount"] = bonusAmount;
|
|
154
|
+
if (promoCode !== void 0) body["promo_code"] = promoCode;
|
|
155
|
+
if (consentChannel !== void 0) body["consent_channel"] = consentChannel;
|
|
156
|
+
return body;
|
|
157
|
+
}
|
|
158
|
+
function cardOrderBody(input) {
|
|
159
|
+
const body = {
|
|
160
|
+
product_id: input.productId,
|
|
161
|
+
method: input.method
|
|
162
|
+
};
|
|
163
|
+
if (input.designId !== void 0) body["design_id"] = input.designId;
|
|
164
|
+
if (input.name !== void 0) body["name"] = input.name;
|
|
165
|
+
if (input.funderSlug !== void 0) body["funder_slug"] = input.funderSlug;
|
|
166
|
+
if (input.currency !== void 0) body["currency"] = input.currency;
|
|
167
|
+
if (input.extraLoad !== void 0) body["extra_load"] = input.extraLoad;
|
|
168
|
+
if (input.promoCode !== void 0) body["promo_code"] = input.promoCode;
|
|
169
|
+
if (input.useBonus !== void 0) body["use_bonus"] = input.useBonus;
|
|
170
|
+
if (input.consents !== void 0) body["consents"] = input.consents;
|
|
171
|
+
if (input.consentChannel !== void 0) body["consent_channel"] = input.consentChannel;
|
|
172
|
+
if (input.metadata !== void 0) body["metadata"] = input.metadata;
|
|
173
|
+
return body;
|
|
174
|
+
}
|
|
175
|
+
var CardsResource = class {
|
|
176
|
+
constructor(http) {
|
|
177
|
+
this.http = http;
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Issue a card backed by the user's wallet balance. Resolves to the new
|
|
181
|
+
* `Card`. On a ledger failure after provider creation, the Takeal API rolls the row
|
|
182
|
+
* to `failed` (never an orphaned active card); inspect `status` /
|
|
183
|
+
* `failure_reason` on the result.
|
|
184
|
+
*/
|
|
185
|
+
async create(input) {
|
|
186
|
+
const { idempotencyKey, ...card } = input;
|
|
187
|
+
return this.http.post("/me/cards", {
|
|
188
|
+
body: cardRequestBody(card),
|
|
189
|
+
idempotencyKey
|
|
190
|
+
});
|
|
191
|
+
}
|
|
192
|
+
/**
|
|
193
|
+
* Buy a card in one step: the API prices the product in the payment's
|
|
194
|
+
* currency, locks the rate and opens the top-up that issues the card.
|
|
195
|
+
* Send the user to `order.deposit.redirect_url`; the card shows as
|
|
196
|
+
* `pending_payment` until the payment is confirmed. The same
|
|
197
|
+
* `idempotencyKey` returns the same order.
|
|
198
|
+
* Errors: 400 `unknown_product` / `method_not_available` / a limit of the
|
|
199
|
+
* way of paying, 503 no funding connector or no exchange rate.
|
|
200
|
+
*/
|
|
201
|
+
async order(input) {
|
|
202
|
+
const { idempotencyKey, ...order } = input;
|
|
203
|
+
return this.http.post("/me/card-orders", {
|
|
204
|
+
body: cardOrderBody(order),
|
|
205
|
+
idempotencyKey
|
|
206
|
+
});
|
|
207
|
+
}
|
|
208
|
+
/**
|
|
209
|
+
* The cards the caller can order, in the order the storefront shows them
|
|
210
|
+
* (`is_default` marks the one issued when none is chosen). Each item
|
|
211
|
+
* carries its product card (name, tagline, benefits, tile picture),
|
|
212
|
+
* artwork, and the issuance price after the caller's subscription
|
|
213
|
+
* discount, in the caller's wallet currency. Pass an item's `id` as
|
|
214
|
+
* `productId` to {@link create}.
|
|
215
|
+
*/
|
|
216
|
+
async listProducts() {
|
|
217
|
+
return this.http.get("/me/card-products");
|
|
218
|
+
}
|
|
219
|
+
/** One product from the catalog. 404 when unknown, disabled or hidden. */
|
|
220
|
+
async getProduct(id) {
|
|
221
|
+
return this.http.get(`/me/card-products/${encodeURIComponent(id)}`);
|
|
222
|
+
}
|
|
223
|
+
/**
|
|
224
|
+
* The public catalog: the same products, order and default as
|
|
225
|
+
* {@link listProducts}, but readable before sign-in, for a landing page or
|
|
226
|
+
* the cabinet's first screen. Prices are list prices (`discount_bps` is
|
|
227
|
+
* always 0); once the user is signed in, {@link listProducts} shows what
|
|
228
|
+
* they pay. The API lets caches keep this response for a minute.
|
|
229
|
+
*/
|
|
230
|
+
async catalog() {
|
|
231
|
+
return this.http.get("/card-products");
|
|
232
|
+
}
|
|
233
|
+
/**
|
|
234
|
+
* Rename the caller's own card or change its design. Resolves to the
|
|
235
|
+
* updated card. 404 if the card isn't the caller's; 400 `invalid_name` /
|
|
236
|
+
* `design_not_allowed` on a bad value.
|
|
237
|
+
*/
|
|
238
|
+
async update(id, input) {
|
|
239
|
+
const body = {};
|
|
240
|
+
if (input.name !== void 0) body["name"] = input.name;
|
|
241
|
+
if (input.designId !== void 0) body["design_id"] = input.designId;
|
|
242
|
+
return this.http.patch(`/me/cards/${encodeURIComponent(id)}`, {
|
|
243
|
+
body
|
|
244
|
+
});
|
|
245
|
+
}
|
|
246
|
+
/** Fetch one card by id. */
|
|
247
|
+
async get(id) {
|
|
248
|
+
return this.http.get(`/me/cards/${encodeURIComponent(id)}`);
|
|
249
|
+
}
|
|
250
|
+
/** List the caller's cards, most recent first. */
|
|
251
|
+
async list() {
|
|
252
|
+
return this.http.get("/me/cards");
|
|
253
|
+
}
|
|
254
|
+
/**
|
|
255
|
+
* Remaining balance of a prepaid card. `currency` is required by the Takeal API and
|
|
256
|
+
* forwarded as a query param.
|
|
257
|
+
*/
|
|
258
|
+
async balance(id, currency) {
|
|
259
|
+
const q = new URLSearchParams({ currency }).toString();
|
|
260
|
+
return this.http.get(`/me/cards/${encodeURIComponent(id)}/balance?${q}`);
|
|
261
|
+
}
|
|
262
|
+
/**
|
|
263
|
+
* What a top-up of this card can be right now: whether it is possible, the
|
|
264
|
+
* currency, the wallet balance, and the product's floor and cap for one
|
|
265
|
+
* top-up. Read it before drawing the form. 404 if the card isn't the caller's.
|
|
266
|
+
*/
|
|
267
|
+
async topUpTerms(id) {
|
|
268
|
+
return this.http.get(`/me/cards/${encodeURIComponent(id)}/topup`);
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Move money from the wallet onto the caller's own card. The wallet is
|
|
272
|
+
* debited first, then the card's provider loads the card; if the provider
|
|
273
|
+
* refuses, the money is back on the wallet and the error says so. Resolves
|
|
274
|
+
* to the card, its new balance and the wallet balance, so no second call
|
|
275
|
+
* is needed. Errors carry a sentence the user can read: 400 outside the
|
|
276
|
+
* floor or cap · 402 not enough in the wallet · 404 not the caller's card ·
|
|
277
|
+
* 409 card frozen, closed or still being issued · 501 provider can't top
|
|
278
|
+
* up · 502/503 provider declined or unreachable (wallet untouched).
|
|
279
|
+
*/
|
|
280
|
+
async topUp(id, input) {
|
|
281
|
+
const { idempotencyKey, amount } = input;
|
|
282
|
+
return this.http.post(`/me/cards/${encodeURIComponent(id)}/topup`, {
|
|
283
|
+
body: { amount },
|
|
284
|
+
idempotencyKey
|
|
285
|
+
});
|
|
286
|
+
}
|
|
287
|
+
/**
|
|
288
|
+
* Move money from one of the caller's cards to another. Both must be
|
|
289
|
+
* theirs, active, in the same currency and of the same kind. The money
|
|
290
|
+
* travels through the wallet one leg at a time: when the second leg does
|
|
291
|
+
* not go through, the call still resolves, `transfer.status` is
|
|
292
|
+
* `on_wallet` and the money is on the wallet — never between two cards.
|
|
293
|
+
* Errors carry a sentence the user can read: 400 the same card twice,
|
|
294
|
+
* different currencies or different kinds · 402 the card holds less than
|
|
295
|
+
* that · 404 one of the cards isn't theirs · 409 a card is frozen, closed
|
|
296
|
+
* or still being issued, or the key was reused with a different body ·
|
|
297
|
+
* 501/502/503 the provider cannot or will not move it.
|
|
298
|
+
*/
|
|
299
|
+
async transfer(fromCardId, input) {
|
|
300
|
+
const { toCardId, amount, idempotencyKey } = input;
|
|
301
|
+
return this.http.post(`/me/cards/${encodeURIComponent(fromCardId)}/transfer`, {
|
|
302
|
+
body: { to_card_id: toCardId, amount },
|
|
303
|
+
idempotencyKey
|
|
304
|
+
});
|
|
305
|
+
}
|
|
306
|
+
/**
|
|
307
|
+
* Freeze the caller's own card. Reversible via {@link unfreeze} while
|
|
308
|
+
* `status_source` is `holder` or `operator`. The optional `reason` is
|
|
309
|
+
* recorded on the audit trail. Resolves to the updated card. 404 if the
|
|
310
|
+
* card isn't the caller's; 409 `card_locked` when support holds it; 501 if
|
|
311
|
+
* the issuer can't freeze.
|
|
312
|
+
*/
|
|
313
|
+
async freeze(id, reason) {
|
|
314
|
+
return this.http.post(`/me/cards/${encodeURIComponent(id)}/freeze`, { body: { reason } });
|
|
315
|
+
}
|
|
316
|
+
/**
|
|
317
|
+
* Reveal the FULL PAN + CVV for the caller's own card. The signed-in
|
|
318
|
+
* session is all the API asks for; the call is rate-limited and audited
|
|
319
|
+
* server-side. The Takeal API never persists this data and marks the
|
|
320
|
+
* response no-store; the SDK returns it verbatim and holds nothing.
|
|
321
|
+
*
|
|
322
|
+
* **Consumer security duties** (the SDK can't enforce these for you):
|
|
323
|
+
* keep the result in volatile memory only, never write it to
|
|
324
|
+
* localStorage / logs, and clear it within `expires_in_seconds`.
|
|
325
|
+
*
|
|
326
|
+
* The result is the numbers, or `reveal_url` with empty `pan` and `cvv`
|
|
327
|
+
* when the issuer shows them on a page of its own: open that page in a
|
|
328
|
+
* frame right away, it is short-lived.
|
|
329
|
+
*
|
|
330
|
+
* 403 not your card · 409 `card_locked` · 429 rate-limited · 501 connector
|
|
331
|
+
* has no sensitive-data endpoint · 503 `provider_unavailable`.
|
|
332
|
+
*/
|
|
333
|
+
async reveal(id, _input) {
|
|
334
|
+
return this.http.post(`/me/cards/${encodeURIComponent(id)}/reveal`);
|
|
335
|
+
}
|
|
336
|
+
/**
|
|
337
|
+
* Unfreeze a previously-frozen card. Idempotent on an already-active card.
|
|
338
|
+
* A card the issuer froze (`status_source: "provider"`) is not the
|
|
339
|
+
* holder's to unfreeze: the API answers 409 `card_locked`, so hide the
|
|
340
|
+
* button and say the freeze is lifted through the issuer's support.
|
|
341
|
+
*/
|
|
342
|
+
async unfreeze(id) {
|
|
343
|
+
return this.http.post(`/me/cards/${encodeURIComponent(id)}/unfreeze`, { body: {} });
|
|
344
|
+
}
|
|
345
|
+
/**
|
|
346
|
+
* Set the PIN of the caller's own physical card. The session is enough; the
|
|
347
|
+
* call is rate-limited like {@link reveal} and the PIN is kept nowhere.
|
|
348
|
+
* Resolves to the card; the user also gets a notification that the PIN
|
|
349
|
+
* was set. 400 not four to six digits or the card is not active · 403 not
|
|
350
|
+
* your card · 409 `card_locked`, or `provider_refused` when the issuer did
|
|
351
|
+
* not take it · 429 too many attempts · 501 a virtual card has no PIN.
|
|
352
|
+
*/
|
|
353
|
+
async setPin(id, input) {
|
|
354
|
+
return this.http.post(`/me/cards/${encodeURIComponent(id)}/pin`, {
|
|
355
|
+
body: { pin: input.pin }
|
|
356
|
+
});
|
|
357
|
+
}
|
|
358
|
+
/**
|
|
359
|
+
* Terminate the caller's own card. **One-way** — a terminated card cannot be
|
|
360
|
+
* reactivated. The optional `reason` is audited. Idempotent on an
|
|
361
|
+
* already-terminated card.
|
|
362
|
+
*/
|
|
363
|
+
async terminate(id, reason) {
|
|
364
|
+
return this.http.post(`/me/cards/${encodeURIComponent(id)}/terminate`, {
|
|
365
|
+
body: { reason }
|
|
366
|
+
});
|
|
367
|
+
}
|
|
368
|
+
};
|
|
369
|
+
|
|
135
370
|
// src/resources/auth.ts
|
|
136
371
|
function withRemember(input) {
|
|
137
372
|
const { remember, ...rest } = input;
|
|
@@ -230,8 +465,11 @@ var AuthResource = class {
|
|
|
230
465
|
* Errors: 400 `validation` / `currency_not_allowed` / `consents_required`
|
|
231
466
|
* / `unknown_consent`, 409 email taken. */
|
|
232
467
|
async register(input) {
|
|
468
|
+
const { cardOrder, ...rest } = input;
|
|
469
|
+
const body = withRemember(rest);
|
|
470
|
+
if (cardOrder !== void 0) body["card_order"] = cardOrderBody(cardOrder);
|
|
233
471
|
const resp = await this.http.post("/auth/register", {
|
|
234
|
-
body
|
|
472
|
+
body,
|
|
235
473
|
skipAuth: true
|
|
236
474
|
});
|
|
237
475
|
await this.keep(resp);
|
|
@@ -355,208 +593,6 @@ var AuthResource = class {
|
|
|
355
593
|
}
|
|
356
594
|
};
|
|
357
595
|
|
|
358
|
-
// src/resources/cards.ts
|
|
359
|
-
function cardRequestBody(input) {
|
|
360
|
-
const {
|
|
361
|
-
productId,
|
|
362
|
-
name,
|
|
363
|
-
designId,
|
|
364
|
-
useBonus,
|
|
365
|
-
bonusAmount,
|
|
366
|
-
promoCode,
|
|
367
|
-
consentChannel,
|
|
368
|
-
initial_amount: _ignored,
|
|
369
|
-
...rest
|
|
370
|
-
} = input;
|
|
371
|
-
const body = { ...rest };
|
|
372
|
-
if (productId !== void 0) body["product_id"] = productId;
|
|
373
|
-
if (name !== void 0) body["name"] = name;
|
|
374
|
-
if (designId !== void 0) body["design_id"] = designId;
|
|
375
|
-
if (useBonus !== void 0) body["use_bonus"] = useBonus;
|
|
376
|
-
if (bonusAmount !== void 0) body["bonus_amount"] = bonusAmount;
|
|
377
|
-
if (promoCode !== void 0) body["promo_code"] = promoCode;
|
|
378
|
-
if (consentChannel !== void 0) body["consent_channel"] = consentChannel;
|
|
379
|
-
return body;
|
|
380
|
-
}
|
|
381
|
-
var CardsResource = class {
|
|
382
|
-
constructor(http) {
|
|
383
|
-
this.http = http;
|
|
384
|
-
}
|
|
385
|
-
/**
|
|
386
|
-
* Issue a card backed by the user's wallet balance. Resolves to the new
|
|
387
|
-
* `Card`. On a ledger failure after provider creation, the Takeal API rolls the row
|
|
388
|
-
* to `failed` (never an orphaned active card); inspect `status` /
|
|
389
|
-
* `failure_reason` on the result.
|
|
390
|
-
*/
|
|
391
|
-
async create(input) {
|
|
392
|
-
const { idempotencyKey, ...card } = input;
|
|
393
|
-
return this.http.post("/me/cards", {
|
|
394
|
-
body: cardRequestBody(card),
|
|
395
|
-
idempotencyKey
|
|
396
|
-
});
|
|
397
|
-
}
|
|
398
|
-
/**
|
|
399
|
-
* The cards the caller can order, in the order the storefront shows them
|
|
400
|
-
* (`is_default` marks the one issued when none is chosen). Each item
|
|
401
|
-
* carries its product card (name, tagline, benefits, tile picture),
|
|
402
|
-
* artwork, and the issuance price after the caller's subscription
|
|
403
|
-
* discount, in the caller's wallet currency. Pass an item's `id` as
|
|
404
|
-
* `productId` to {@link create}.
|
|
405
|
-
*/
|
|
406
|
-
async listProducts() {
|
|
407
|
-
return this.http.get("/me/card-products");
|
|
408
|
-
}
|
|
409
|
-
/** One product from the catalog. 404 when unknown, disabled or hidden. */
|
|
410
|
-
async getProduct(id) {
|
|
411
|
-
return this.http.get(`/me/card-products/${encodeURIComponent(id)}`);
|
|
412
|
-
}
|
|
413
|
-
/**
|
|
414
|
-
* The public catalog: the same products, order and default as
|
|
415
|
-
* {@link listProducts}, but readable before sign-in, for a landing page or
|
|
416
|
-
* the cabinet's first screen. Prices are list prices (`discount_bps` is
|
|
417
|
-
* always 0); once the user is signed in, {@link listProducts} shows what
|
|
418
|
-
* they pay. The API lets caches keep this response for a minute.
|
|
419
|
-
*/
|
|
420
|
-
async catalog() {
|
|
421
|
-
return this.http.get("/card-products");
|
|
422
|
-
}
|
|
423
|
-
/**
|
|
424
|
-
* Rename the caller's own card or change its design. Resolves to the
|
|
425
|
-
* updated card. 404 if the card isn't the caller's; 400 `invalid_name` /
|
|
426
|
-
* `design_not_allowed` on a bad value.
|
|
427
|
-
*/
|
|
428
|
-
async update(id, input) {
|
|
429
|
-
const body = {};
|
|
430
|
-
if (input.name !== void 0) body["name"] = input.name;
|
|
431
|
-
if (input.designId !== void 0) body["design_id"] = input.designId;
|
|
432
|
-
return this.http.patch(`/me/cards/${encodeURIComponent(id)}`, {
|
|
433
|
-
body
|
|
434
|
-
});
|
|
435
|
-
}
|
|
436
|
-
/** Fetch one card by id. */
|
|
437
|
-
async get(id) {
|
|
438
|
-
return this.http.get(`/me/cards/${encodeURIComponent(id)}`);
|
|
439
|
-
}
|
|
440
|
-
/** List the caller's cards, most recent first. */
|
|
441
|
-
async list() {
|
|
442
|
-
return this.http.get("/me/cards");
|
|
443
|
-
}
|
|
444
|
-
/**
|
|
445
|
-
* Remaining balance of a prepaid card. `currency` is required by the Takeal API and
|
|
446
|
-
* forwarded as a query param.
|
|
447
|
-
*/
|
|
448
|
-
async balance(id, currency) {
|
|
449
|
-
const q = new URLSearchParams({ currency }).toString();
|
|
450
|
-
return this.http.get(`/me/cards/${encodeURIComponent(id)}/balance?${q}`);
|
|
451
|
-
}
|
|
452
|
-
/**
|
|
453
|
-
* What a top-up of this card can be right now: whether it is possible, the
|
|
454
|
-
* currency, the wallet balance, and the product's floor and cap for one
|
|
455
|
-
* top-up. Read it before drawing the form. 404 if the card isn't the caller's.
|
|
456
|
-
*/
|
|
457
|
-
async topUpTerms(id) {
|
|
458
|
-
return this.http.get(`/me/cards/${encodeURIComponent(id)}/topup`);
|
|
459
|
-
}
|
|
460
|
-
/**
|
|
461
|
-
* Move money from the wallet onto the caller's own card. The wallet is
|
|
462
|
-
* debited first, then the card's provider loads the card; if the provider
|
|
463
|
-
* refuses, the money is back on the wallet and the error says so. Resolves
|
|
464
|
-
* to the card, its new balance and the wallet balance, so no second call
|
|
465
|
-
* is needed. Errors carry a sentence the user can read: 400 outside the
|
|
466
|
-
* floor or cap · 402 not enough in the wallet · 404 not the caller's card ·
|
|
467
|
-
* 409 card frozen, closed or still being issued · 501 provider can't top
|
|
468
|
-
* up · 502/503 provider declined or unreachable (wallet untouched).
|
|
469
|
-
*/
|
|
470
|
-
async topUp(id, input) {
|
|
471
|
-
const { idempotencyKey, amount } = input;
|
|
472
|
-
return this.http.post(`/me/cards/${encodeURIComponent(id)}/topup`, {
|
|
473
|
-
body: { amount },
|
|
474
|
-
idempotencyKey
|
|
475
|
-
});
|
|
476
|
-
}
|
|
477
|
-
/**
|
|
478
|
-
* Move money from one of the caller's cards to another. Both must be
|
|
479
|
-
* theirs, active, in the same currency and of the same kind. The money
|
|
480
|
-
* travels through the wallet one leg at a time: when the second leg does
|
|
481
|
-
* not go through, the call still resolves, `transfer.status` is
|
|
482
|
-
* `on_wallet` and the money is on the wallet — never between two cards.
|
|
483
|
-
* Errors carry a sentence the user can read: 400 the same card twice,
|
|
484
|
-
* different currencies or different kinds · 402 the card holds less than
|
|
485
|
-
* that · 404 one of the cards isn't theirs · 409 a card is frozen, closed
|
|
486
|
-
* or still being issued, or the key was reused with a different body ·
|
|
487
|
-
* 501/502/503 the provider cannot or will not move it.
|
|
488
|
-
*/
|
|
489
|
-
async transfer(fromCardId, input) {
|
|
490
|
-
const { toCardId, amount, idempotencyKey } = input;
|
|
491
|
-
return this.http.post(`/me/cards/${encodeURIComponent(fromCardId)}/transfer`, {
|
|
492
|
-
body: { to_card_id: toCardId, amount },
|
|
493
|
-
idempotencyKey
|
|
494
|
-
});
|
|
495
|
-
}
|
|
496
|
-
/**
|
|
497
|
-
* Freeze the caller's own card. Reversible via {@link unfreeze} while
|
|
498
|
-
* `status_source` is `holder` or `operator`. The optional `reason` is
|
|
499
|
-
* recorded on the audit trail. Resolves to the updated card. 404 if the
|
|
500
|
-
* card isn't the caller's; 409 `card_locked` when support holds it; 501 if
|
|
501
|
-
* the issuer can't freeze.
|
|
502
|
-
*/
|
|
503
|
-
async freeze(id, reason) {
|
|
504
|
-
return this.http.post(`/me/cards/${encodeURIComponent(id)}/freeze`, { body: { reason } });
|
|
505
|
-
}
|
|
506
|
-
/**
|
|
507
|
-
* Reveal the FULL PAN + CVV for the caller's own card. The signed-in
|
|
508
|
-
* session is all the API asks for; the call is rate-limited and audited
|
|
509
|
-
* server-side. The Takeal API never persists this data and marks the
|
|
510
|
-
* response no-store; the SDK returns it verbatim and holds nothing.
|
|
511
|
-
*
|
|
512
|
-
* **Consumer security duties** (the SDK can't enforce these for you):
|
|
513
|
-
* keep the result in volatile memory only, never write it to
|
|
514
|
-
* localStorage / logs, and clear it within `expires_in_seconds`.
|
|
515
|
-
*
|
|
516
|
-
* The result is the numbers, or `reveal_url` with empty `pan` and `cvv`
|
|
517
|
-
* when the issuer shows them on a page of its own: open that page in a
|
|
518
|
-
* frame right away, it is short-lived.
|
|
519
|
-
*
|
|
520
|
-
* 403 not your card · 409 `card_locked` · 429 rate-limited · 501 connector
|
|
521
|
-
* has no sensitive-data endpoint · 503 `provider_unavailable`.
|
|
522
|
-
*/
|
|
523
|
-
async reveal(id, _input) {
|
|
524
|
-
return this.http.post(`/me/cards/${encodeURIComponent(id)}/reveal`);
|
|
525
|
-
}
|
|
526
|
-
/**
|
|
527
|
-
* Unfreeze a previously-frozen card. Idempotent on an already-active card.
|
|
528
|
-
* A card the issuer froze (`status_source: "provider"`) is not the
|
|
529
|
-
* holder's to unfreeze: the API answers 409 `card_locked`, so hide the
|
|
530
|
-
* button and say the freeze is lifted through the issuer's support.
|
|
531
|
-
*/
|
|
532
|
-
async unfreeze(id) {
|
|
533
|
-
return this.http.post(`/me/cards/${encodeURIComponent(id)}/unfreeze`, { body: {} });
|
|
534
|
-
}
|
|
535
|
-
/**
|
|
536
|
-
* Set the PIN of the caller's own physical card. The session is enough; the
|
|
537
|
-
* call is rate-limited like {@link reveal} and the PIN is kept nowhere.
|
|
538
|
-
* Resolves to the card; the user also gets a notification that the PIN
|
|
539
|
-
* was set. 400 not four to six digits or the card is not active · 403 not
|
|
540
|
-
* your card · 409 `card_locked`, or `provider_refused` when the issuer did
|
|
541
|
-
* not take it · 429 too many attempts · 501 a virtual card has no PIN.
|
|
542
|
-
*/
|
|
543
|
-
async setPin(id, input) {
|
|
544
|
-
return this.http.post(`/me/cards/${encodeURIComponent(id)}/pin`, {
|
|
545
|
-
body: { pin: input.pin }
|
|
546
|
-
});
|
|
547
|
-
}
|
|
548
|
-
/**
|
|
549
|
-
* Terminate the caller's own card. **One-way** — a terminated card cannot be
|
|
550
|
-
* reactivated. The optional `reason` is audited. Idempotent on an
|
|
551
|
-
* already-terminated card.
|
|
552
|
-
*/
|
|
553
|
-
async terminate(id, reason) {
|
|
554
|
-
return this.http.post(`/me/cards/${encodeURIComponent(id)}/terminate`, {
|
|
555
|
-
body: { reason }
|
|
556
|
-
});
|
|
557
|
-
}
|
|
558
|
-
};
|
|
559
|
-
|
|
560
596
|
// src/resources/deposits.ts
|
|
561
597
|
var DepositsResource = class {
|
|
562
598
|
constructor(http) {
|
|
@@ -1238,7 +1274,7 @@ var FundingOptionsResource = class {
|
|
|
1238
1274
|
};
|
|
1239
1275
|
|
|
1240
1276
|
// src/version.ts
|
|
1241
|
-
var SDK_VERSION = "0.6.
|
|
1277
|
+
var SDK_VERSION = "0.6.3";
|
|
1242
1278
|
|
|
1243
1279
|
// src/client-platform.ts
|
|
1244
1280
|
var CLIENT_HEADER = "X-Takeal-Client";
|
|
@@ -1313,7 +1349,7 @@ function isAbsolute(url) {
|
|
|
1313
1349
|
}
|
|
1314
1350
|
|
|
1315
1351
|
// src/compat.ts
|
|
1316
|
-
var SUPPORTED_MEISTER = ">=0.6.
|
|
1352
|
+
var SUPPORTED_MEISTER = ">=0.6.8, <0.7.0";
|
|
1317
1353
|
var SEMVER = /^v?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/;
|
|
1318
1354
|
function parse(v) {
|
|
1319
1355
|
const m = SEMVER.exec(v.trim());
|