@takeal/cusfront-sdk 0.6.0 → 0.6.2

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.
Files changed (57) hide show
  1. package/CHANGELOG.md +67 -0
  2. package/README.md +221 -1
  3. package/dist/{cards-B_aNY35J.d.cts → cards-DU2DdhYO.d.cts} +154 -20
  4. package/dist/{cards-Ba1wZttb.d.ts → cards-DzhPVA9N.d.ts} +154 -20
  5. package/dist/{deposits-BEc8U80M.d.cts → deposits-BEkNeE-v.d.cts} +71 -8
  6. package/dist/{deposits-DScyT_D9.d.ts → deposits-Dt6A76MB.d.ts} +71 -8
  7. package/dist/index.cjs +129 -14
  8. package/dist/index.cjs.map +1 -1
  9. package/dist/index.d.cts +16 -8
  10. package/dist/index.d.ts +16 -8
  11. package/dist/index.js +129 -14
  12. package/dist/index.js.map +1 -1
  13. package/dist/react/index.d.cts +4 -2
  14. package/dist/react/index.d.ts +4 -2
  15. package/dist/resources/auth.cjs +25 -4
  16. package/dist/resources/auth.cjs.map +1 -1
  17. package/dist/resources/auth.d.cts +40 -5
  18. package/dist/resources/auth.d.ts +40 -5
  19. package/dist/resources/auth.js +25 -4
  20. package/dist/resources/auth.js.map +1 -1
  21. package/dist/resources/cards.cjs +32 -6
  22. package/dist/resources/cards.cjs.map +1 -1
  23. package/dist/resources/cards.d.cts +2 -1
  24. package/dist/resources/cards.d.ts +2 -1
  25. package/dist/resources/cards.js +32 -6
  26. package/dist/resources/cards.js.map +1 -1
  27. package/dist/resources/consents.cjs +91 -0
  28. package/dist/resources/consents.cjs.map +1 -0
  29. package/dist/resources/consents.d.cts +83 -0
  30. package/dist/resources/consents.d.ts +83 -0
  31. package/dist/resources/consents.js +89 -0
  32. package/dist/resources/consents.js.map +1 -0
  33. package/dist/resources/deposits.cjs +6 -1
  34. package/dist/resources/deposits.cjs.map +1 -1
  35. package/dist/resources/deposits.d.cts +3 -2
  36. package/dist/resources/deposits.d.ts +3 -2
  37. package/dist/resources/deposits.js +6 -1
  38. package/dist/resources/deposits.js.map +1 -1
  39. package/dist/resources/funding-options.cjs.map +1 -1
  40. package/dist/resources/funding-options.d.cts +3 -2
  41. package/dist/resources/funding-options.d.ts +3 -2
  42. package/dist/resources/funding-options.js.map +1 -1
  43. package/dist/resources/me.d.cts +1 -0
  44. package/dist/resources/me.d.ts +1 -0
  45. package/dist/resources/receipts.cjs +22 -0
  46. package/dist/resources/receipts.cjs.map +1 -0
  47. package/dist/resources/receipts.d.cts +51 -0
  48. package/dist/resources/receipts.d.ts +51 -0
  49. package/dist/resources/receipts.js +20 -0
  50. package/dist/resources/receipts.js.map +1 -0
  51. package/dist/telegram.cjs +167 -14
  52. package/dist/telegram.cjs.map +1 -1
  53. package/dist/telegram.d.cts +4 -2
  54. package/dist/telegram.d.ts +4 -2
  55. package/dist/telegram.js +167 -14
  56. package/dist/telegram.js.map +1 -1
  57. package/package.json +11 -1
package/dist/index.cjs CHANGED
@@ -232,7 +232,8 @@ var AuthResource = class {
232
232
  * `wallet_currency` must be one the deployment offers; omit it to take
233
233
  * the deployment default (it can be switched later via `client.wallet`
234
234
  * while the wallet is empty).
235
- * Errors: 400 `validation` / `currency_not_allowed`, 409 email taken. */
235
+ * Errors: 400 `validation` / `currency_not_allowed` / `consents_required`
236
+ * / `unknown_consent`, 409 email taken. */
236
237
  async register(input) {
237
238
  const resp = await this.http.post("/auth/register", {
238
239
  body: withRemember(input),
@@ -277,6 +278,8 @@ var AuthResource = class {
277
278
  if (input.provision !== void 0) body.provision = input.provision;
278
279
  if (input.attribution !== void 0) body.attribution = input.attribution;
279
280
  if (input.code !== void 0) body.code = input.code;
281
+ if (input.consents !== void 0) body.consents = input.consents;
282
+ if (input.consentChannel !== void 0) body.consent_channel = input.consentChannel;
280
283
  let resp;
281
284
  try {
282
285
  resp = await this.http.post("/auth/telegram/exchange", {
@@ -311,12 +314,30 @@ var AuthResource = class {
311
314
  await Promise.resolve(this.tokens.set(resp.access_token));
312
315
  return resp;
313
316
  }
314
- /** Attach a real email to the current user (and clear `email_pending`).
315
- * Used after a Telegram exchange to satisfy the email requirement; also
316
- * works for a password user changing their address. 409 if taken. */
317
+ /** Attach the first real email to a Telegram-made account (and clear
318
+ * `email_pending`). 409 if taken. An account that already has a real
319
+ * address gets 409 `email_change_needs_code`: change it with
320
+ * {@link requestEmailChange} and {@link confirmEmailChange}. */
317
321
  async linkEmail(input) {
318
322
  return this.http.post("/me/email", { body: { email: input.email } });
319
323
  }
324
+ /** Step one of an email change: a six-digit code goes to the new address
325
+ * and works for 5 minutes. Nothing changes yet.
326
+ * Errors: 400 `same_email`, 409 address taken, 429 `too_many_requests`
327
+ * (five codes an hour). */
328
+ async requestEmailChange(input) {
329
+ return this.http.post("/me/email/change", {
330
+ body: { email: input.email }
331
+ });
332
+ }
333
+ /** Step two: the code from the e-mail changes the address; the old one
334
+ * gets a notice. Errors: 401 `invalid_code` (after five wrong codes a new
335
+ * request is needed), 409 the address was taken meanwhile. */
336
+ async confirmEmailChange(input) {
337
+ return this.http.post("/me/email/change/confirm", {
338
+ body: { challenge_id: input.challengeId, code: input.code }
339
+ });
340
+ }
320
341
  /** Current user — fails 401 when the stored JWT is expired or
321
342
  * missing. Useful as a "do I have a session" probe on app boot. */
322
343
  async me() {
@@ -348,6 +369,7 @@ function cardRequestBody(input) {
348
369
  useBonus,
349
370
  bonusAmount,
350
371
  promoCode,
372
+ consentChannel,
351
373
  initial_amount: _ignored,
352
374
  ...rest
353
375
  } = input;
@@ -358,6 +380,7 @@ function cardRequestBody(input) {
358
380
  if (useBonus !== void 0) body["use_bonus"] = useBonus;
359
381
  if (bonusAmount !== void 0) body["bonus_amount"] = bonusAmount;
360
382
  if (promoCode !== void 0) body["promo_code"] = promoCode;
383
+ if (consentChannel !== void 0) body["consent_channel"] = consentChannel;
361
384
  return body;
362
385
  }
363
386
  var CardsResource = class {
@@ -476,9 +499,11 @@ var CardsResource = class {
476
499
  });
477
500
  }
478
501
  /**
479
- * Freeze the caller's own card. Reversible via {@link unfreeze}. The optional
480
- * `reason` is recorded on the audit trail. Resolves to the updated card.
481
- * 404 if the card isn't the caller's; 501 if the issuer can't freeze.
502
+ * Freeze the caller's own card. Reversible via {@link unfreeze} while
503
+ * `status_source` is `holder` or `operator`. The optional `reason` is
504
+ * recorded on the audit trail. Resolves to the updated card. 404 if the
505
+ * card isn't the caller's; 409 `card_locked` when support holds it; 501 if
506
+ * the issuer can't freeze.
482
507
  */
483
508
  async freeze(id, reason) {
484
509
  return this.http.post(`/me/cards/${encodeURIComponent(id)}/freeze`, { body: { reason } });
@@ -493,16 +518,38 @@ var CardsResource = class {
493
518
  * keep the result in volatile memory only, never write it to
494
519
  * localStorage / logs, and clear it within `expires_in_seconds`.
495
520
  *
496
- * 401 bad re-auth · 403 not your card · 429 rate-limited · 501 connector
497
- * has no sensitive-data endpoint · 503 provider error.
521
+ * The result is the numbers, or `reveal_url` with empty `pan` and `cvv`
522
+ * when the issuer shows them on a page of its own: open that page in a
523
+ * frame right away, it is short-lived.
524
+ *
525
+ * 403 not your card · 409 `card_locked` · 429 rate-limited · 501 connector
526
+ * has no sensitive-data endpoint · 503 `provider_unavailable`.
498
527
  */
499
528
  async reveal(id, _input) {
500
529
  return this.http.post(`/me/cards/${encodeURIComponent(id)}/reveal`);
501
530
  }
502
- /** Unfreeze a previously-frozen card. Idempotent on an already-active card. */
531
+ /**
532
+ * Unfreeze a previously-frozen card. Idempotent on an already-active card.
533
+ * A card the issuer froze (`status_source: "provider"`) is not the
534
+ * holder's to unfreeze: the API answers 409 `card_locked`, so hide the
535
+ * button and say the freeze is lifted through the issuer's support.
536
+ */
503
537
  async unfreeze(id) {
504
538
  return this.http.post(`/me/cards/${encodeURIComponent(id)}/unfreeze`, { body: {} });
505
539
  }
540
+ /**
541
+ * Set the PIN of the caller's own physical card. The session is enough; the
542
+ * call is rate-limited like {@link reveal} and the PIN is kept nowhere.
543
+ * Resolves to the card; the user also gets a notification that the PIN
544
+ * was set. 400 not four to six digits or the card is not active · 403 not
545
+ * your card · 409 `card_locked`, or `provider_refused` when the issuer did
546
+ * not take it · 429 too many attempts · 501 a virtual card has no PIN.
547
+ */
548
+ async setPin(id, input) {
549
+ return this.http.post(`/me/cards/${encodeURIComponent(id)}/pin`, {
550
+ body: { pin: input.pin }
551
+ });
552
+ }
506
553
  /**
507
554
  * Terminate the caller's own card. **One-way** — a terminated card cannot be
508
555
  * reactivated. The optional `reason` is audited. Idempotent on an
@@ -532,7 +579,10 @@ var DepositsResource = class {
532
579
  * API answers 400 `no_quote_needed`).
533
580
  */
534
581
  async quote(input) {
535
- return this.http.post("/me/deposits/quotes", { body: input });
582
+ const { connectorSlug, ...rest } = input;
583
+ const body = { ...rest };
584
+ if (connectorSlug !== void 0) body["connector_slug"] = connectorSlug;
585
+ return this.http.post("/me/deposits/quotes", { body });
536
586
  }
537
587
  async initiate(input) {
538
588
  const { idempotencyKey, issue_card, ...rest } = input;
@@ -1135,6 +1185,69 @@ var HistoryResource = class {
1135
1185
  }
1136
1186
  };
1137
1187
 
1188
+ // src/resources/consents.ts
1189
+ var ConsentsResource = class {
1190
+ constructor(http) {
1191
+ this.http = http;
1192
+ }
1193
+ /** Where each consent stands. */
1194
+ async get() {
1195
+ return this.http.get("/me/consents");
1196
+ }
1197
+ /**
1198
+ * Give (`true`) or withdraw (`false`) an optional consent: `marketing` or
1199
+ * `cookies_analytics`. Withdrawing `marketing` turns advertising off in
1200
+ * every channel at once; giving it turns on advertising by e-mail. A call
1201
+ * that changes nothing records nothing.
1202
+ *
1203
+ * Errors: 400 `consent_required` for `terms` or `personal_data`,
1204
+ * 400 `unknown_consent`.
1205
+ */
1206
+ async set(kind, given, channel) {
1207
+ const body = { kind, given };
1208
+ if (channel !== void 0) body.channel = channel;
1209
+ return this.http.post("/me/consents", { body });
1210
+ }
1211
+ /**
1212
+ * Record what the cookie banner or the cookie settings say about
1213
+ * analytics. Works signed in or not: before sign-in the choice is kept
1214
+ * under the anonymous key and moves to the account at sign-up (send the
1215
+ * same key in `register({ attribution })`). Declining deletes the
1216
+ * visitor's recorded visits and analytics ids and stops their conversions
1217
+ * going to Metrica. Call it on every change, not on every page load; the
1218
+ * same answer twice records nothing (`recorded: false`).
1219
+ *
1220
+ * Errors: 400 `invalid_anonymous_key` when not signed in and no key could
1221
+ * be found.
1222
+ */
1223
+ async setCookies(input) {
1224
+ const body = {
1225
+ analytics: input.analytics
1226
+ };
1227
+ const key = input.anonymousKey ?? anonymousKey();
1228
+ if (key !== void 0) body.anonymous_key = key;
1229
+ if (input.channel !== void 0) body.channel = input.channel;
1230
+ return this.http.post("/consents/cookies", { body });
1231
+ }
1232
+ };
1233
+
1234
+ // src/resources/receipts.ts
1235
+ var ReceiptsResource = class {
1236
+ constructor(http) {
1237
+ this.http = http;
1238
+ }
1239
+ async list(params = {}) {
1240
+ const q = new URLSearchParams();
1241
+ if (params.refId !== void 0) q.set("ref_id", params.refId);
1242
+ if (params.limit !== void 0) q.set("limit", String(params.limit));
1243
+ const qs = q.toString();
1244
+ return this.http.get(`/me/receipts${qs ? `?${qs}` : ""}`);
1245
+ }
1246
+ async get(id) {
1247
+ return this.http.get(`/me/receipts/${encodeURIComponent(id)}`);
1248
+ }
1249
+ };
1250
+
1138
1251
  // src/resources/funding-options.ts
1139
1252
  var FundingOptionsResource = class {
1140
1253
  constructor(http) {
@@ -1147,7 +1260,7 @@ var FundingOptionsResource = class {
1147
1260
  };
1148
1261
 
1149
1262
  // src/version.ts
1150
- var SDK_VERSION = "0.6.0";
1263
+ var SDK_VERSION = "0.6.2";
1151
1264
 
1152
1265
  // src/client-platform.ts
1153
1266
  var CLIENT_HEADER = "X-Takeal-Client";
@@ -1222,7 +1335,7 @@ function isAbsolute(url) {
1222
1335
  }
1223
1336
 
1224
1337
  // src/compat.ts
1225
- var SUPPORTED_MEISTER = ">=0.5.0, <0.7.0";
1338
+ var SUPPORTED_MEISTER = ">=0.6.7, <0.7.0";
1226
1339
  var SEMVER = /^v?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/;
1227
1340
  function parse(v) {
1228
1341
  const m = SEMVER.exec(v.trim());
@@ -1749,7 +1862,9 @@ function createClient(opts) {
1749
1862
  notifications: new NotificationsResource(http),
1750
1863
  devices: new DevicesResource(http, client),
1751
1864
  attribution: new AttributionResource(http),
1752
- history: new HistoryResource(http)
1865
+ history: new HistoryResource(http),
1866
+ consents: new ConsentsResource(http),
1867
+ receipts: new ReceiptsResource(http)
1753
1868
  };
1754
1869
  }
1755
1870
  function pickDefaultStore(key) {