@takeal/cusfront-sdk 0.6.6 → 0.6.11

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 (53) hide show
  1. package/CHANGELOG.md +75 -2
  2. package/README.md +60 -7
  3. package/dist/{cards-DwmzjKDC.d.ts → cards-CuUdrQ0H.d.ts} +65 -7
  4. package/dist/{cards-BiXmrz7h.d.cts → cards-nXmDP0ei.d.cts} +65 -7
  5. package/dist/index.cjs +80 -6
  6. package/dist/index.cjs.map +1 -1
  7. package/dist/index.d.cts +10 -6
  8. package/dist/index.d.ts +10 -6
  9. package/dist/index.js +80 -7
  10. package/dist/index.js.map +1 -1
  11. package/dist/react/index.d.cts +2 -1
  12. package/dist/react/index.d.ts +2 -1
  13. package/dist/resources/auth.cjs.map +1 -1
  14. package/dist/resources/auth.d.cts +2 -1
  15. package/dist/resources/auth.d.ts +2 -1
  16. package/dist/resources/auth.js.map +1 -1
  17. package/dist/resources/cards.cjs +33 -4
  18. package/dist/resources/cards.cjs.map +1 -1
  19. package/dist/resources/cards.d.cts +2 -1
  20. package/dist/resources/cards.d.ts +2 -1
  21. package/dist/resources/cards.js +33 -5
  22. package/dist/resources/cards.js.map +1 -1
  23. package/dist/resources/claims.cjs +40 -0
  24. package/dist/resources/claims.cjs.map +1 -0
  25. package/dist/resources/claims.d.cts +114 -0
  26. package/dist/resources/claims.d.ts +114 -0
  27. package/dist/resources/claims.js +38 -0
  28. package/dist/resources/claims.js.map +1 -0
  29. package/dist/resources/deposits.cjs.map +1 -1
  30. package/dist/resources/deposits.d.cts +2 -1
  31. package/dist/resources/deposits.d.ts +2 -1
  32. package/dist/resources/deposits.js.map +1 -1
  33. package/dist/resources/funding-options.d.cts +2 -1
  34. package/dist/resources/funding-options.d.ts +2 -1
  35. package/dist/resources/me.d.cts +2 -1
  36. package/dist/resources/me.d.ts +2 -1
  37. package/dist/resources/subscription.cjs +9 -0
  38. package/dist/resources/subscription.cjs.map +1 -1
  39. package/dist/resources/subscription.d.cts +19 -2
  40. package/dist/resources/subscription.d.ts +19 -2
  41. package/dist/resources/subscription.js +9 -0
  42. package/dist/resources/subscription.js.map +1 -1
  43. package/dist/resources/support.cjs.map +1 -1
  44. package/dist/resources/support.d.cts +8 -3
  45. package/dist/resources/support.d.ts +8 -3
  46. package/dist/resources/support.js.map +1 -1
  47. package/dist/telegram.cjs +79 -6
  48. package/dist/telegram.cjs.map +1 -1
  49. package/dist/telegram.d.cts +2 -1
  50. package/dist/telegram.d.ts +2 -1
  51. package/dist/telegram.js +79 -6
  52. package/dist/telegram.js.map +1 -1
  53. package/package.json +9 -4
@@ -1,7 +1,8 @@
1
1
  import { CusfrontClient, CreateClientOptions } from './index.cjs';
2
2
  import { JwtIssued, TelegramUnknown } from './resources/auth.cjs';
3
3
  import './http-CL97TjMO.cjs';
4
- import './cards-BiXmrz7h.cjs';
4
+ import './cards-nXmDP0ei.cjs';
5
+ import './resources/claims.cjs';
5
6
  import './resources/consents.cjs';
6
7
  import './resources/balance.cjs';
7
8
  import './resources/bonus.cjs';
@@ -1,7 +1,8 @@
1
1
  import { CusfrontClient, CreateClientOptions } from './index.js';
2
2
  import { JwtIssued, TelegramUnknown } from './resources/auth.js';
3
3
  import './http-CL97TjMO.js';
4
- import './cards-DwmzjKDC.js';
4
+ import './cards-CuUdrQ0H.js';
5
+ import './resources/claims.js';
5
6
  import './resources/consents.js';
6
7
  import './resources/balance.js';
7
8
  import './resources/bonus.js';
package/dist/telegram.js CHANGED
@@ -182,6 +182,11 @@ function cardOrderBody(input) {
182
182
  if (input.metadata !== void 0) body["metadata"] = input.metadata;
183
183
  return body;
184
184
  }
185
+ function revealState(r) {
186
+ if (r.details_pending) return "pending";
187
+ if (r.reveal_url) return "page";
188
+ return "numbers";
189
+ }
185
190
  var CardsResource = class {
186
191
  constructor(http) {
187
192
  this.http = http;
@@ -337,15 +342,22 @@ var CardsResource = class {
337
342
  * keep the result in volatile memory only, never write it to
338
343
  * localStorage / logs, and clear it within `expires_in_seconds`.
339
344
  *
340
- * The result is the numbers, or `reveal_url` with empty `pan` and `cvv`
341
- * when the issuer shows them on a page of its own: open that page in a
342
- * frame right away, it is short-lived.
345
+ * `state` tells the three answers apart: `numbers`; `page`, with
346
+ * `reveal_url` and empty `pan` and `cvv` when the issuer shows them on a
347
+ * page of its own (open that page in a frame right away, it is
348
+ * short-lived); or `pending` while the card's details are still being
349
+ * prepared, which doesn't count against the limit. A card says the same
350
+ * in {@link Card.details_pending}, so there is no need to call this just
351
+ * to find out.
343
352
  *
344
353
  * 403 not your card · 409 `card_locked` · 429 rate-limited · 501 connector
345
354
  * has no sensitive-data endpoint · 503 `provider_unavailable`.
346
355
  */
347
356
  async reveal(id, _input) {
348
- return this.http.post(`/me/cards/${encodeURIComponent(id)}/reveal`);
357
+ const r = await this.http.post(
358
+ `/me/cards/${encodeURIComponent(id)}/reveal`
359
+ );
360
+ return { ...r, state: revealState(r) };
349
361
  }
350
362
  /**
351
363
  * Unfreeze a previously-frozen card. Idempotent on an already-active card.
@@ -356,6 +368,22 @@ var CardsResource = class {
356
368
  async unfreeze(id) {
357
369
  return this.http.post(`/me/cards/${encodeURIComponent(id)}/unfreeze`, { body: {} });
358
370
  }
371
+ /**
372
+ * Report the card lost or stolen. Works at any time, on an active or a
373
+ * frozen card. The report is recorded first with the server's time, which
374
+ * decides who pays for operations someone else made; then the card is
375
+ * frozen at its issuer and only support can unfreeze it. Resolves to the
376
+ * claim (`client.claims`): show its `number` and `reported_at`. When the
377
+ * issuer can't be reached, `card_freeze` is `"pending"`: the report still
378
+ * counts and support freezes the card by hand. Reporting again while the
379
+ * report is open returns the same claim. 404 / 403 not the user's card ·
380
+ * 409 `card_not_open`: the card is closed or was never issued.
381
+ */
382
+ async reportLost(id, input) {
383
+ return this.http.post(`/me/cards/${encodeURIComponent(id)}/report-lost`, {
384
+ body: { kind: input.kind, details: input.details }
385
+ });
386
+ }
359
387
  /**
360
388
  * Set the PIN of the caller's own physical card. The session is enough; the
361
389
  * call is rate-limited like {@link reveal} and the PIN is kept nowhere.
@@ -808,6 +836,41 @@ var CloseRequestsResource = class {
808
836
  }
809
837
  };
810
838
 
839
+ // src/resources/claims.ts
840
+ var ClaimsResource = class {
841
+ constructor(http) {
842
+ this.http = http;
843
+ }
844
+ /**
845
+ * Dispute a card operation, or complain. 400 `validation`: a description
846
+ * that is too short or too long, an operation that isn't on the user's
847
+ * cards, or a lost or stolen card (use `cards.reportLost()`) · 404 no
848
+ * such card · 409 `too_many_claims`: 20 claims are waiting for an answer.
849
+ */
850
+ async create(input) {
851
+ return this.http.post("/me/claims", {
852
+ body: {
853
+ kind: input.kind,
854
+ description: input.description,
855
+ card_id: input.cardId,
856
+ transaction_id: input.transactionId
857
+ }
858
+ });
859
+ }
860
+ /** The user's claims, lost and stolen cards included, newest first. */
861
+ async list(opts = {}) {
862
+ const qs = new URLSearchParams();
863
+ if (opts.limit != null) qs.set("limit", String(opts.limit));
864
+ if (opts.offset != null) qs.set("offset", String(opts.offset));
865
+ const q = qs.toString();
866
+ return this.http.get(`/me/claims${q ? `?${q}` : ""}`, { signal: opts.signal });
867
+ }
868
+ /** One claim. 404 when it isn't the user's. */
869
+ async get(id, opts = {}) {
870
+ return this.http.get(`/me/claims/${encodeURIComponent(id)}`, { signal: opts.signal });
871
+ }
872
+ };
873
+
811
874
  // src/resources/codes.ts
812
875
  var CodesResource = class {
813
876
  constructor(http) {
@@ -851,6 +914,15 @@ var SubscriptionResource = class {
851
914
  async setPromoCode(code) {
852
915
  return this.http.put("/me/subscription/promo-code", { body: { code } });
853
916
  }
917
+ /**
918
+ * Cancel the subscription now, in one step. What was paid for the current
919
+ * period comes back to the balance for the days not used. No subscription
920
+ * running → 404; 503 `refund_unavailable` when the refund can't be made
921
+ * right now (the subscription keeps running; try again).
922
+ */
923
+ async cancel() {
924
+ return this.http.post("/me/subscription/cancel", {});
925
+ }
854
926
  };
855
927
 
856
928
  // src/resources/branding.ts
@@ -1493,7 +1565,7 @@ var FundingOptionsResource = class {
1493
1565
  };
1494
1566
 
1495
1567
  // src/version.ts
1496
- var SDK_VERSION = "0.6.6";
1568
+ var SDK_VERSION = "0.6.11";
1497
1569
 
1498
1570
  // src/client-platform.ts
1499
1571
  var CLIENT_HEADER = "X-Takeal-Client";
@@ -1568,7 +1640,7 @@ function isAbsolute(url) {
1568
1640
  }
1569
1641
 
1570
1642
  // src/compat.ts
1571
- var SUPPORTED_MEISTER = ">=0.6.12, <0.7.0";
1643
+ var SUPPORTED_MEISTER = ">=0.7.6, <1.0.0";
1572
1644
  var SEMVER = /^v?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/;
1573
1645
  function parse(v) {
1574
1646
  const m = SEMVER.exec(v.trim());
@@ -1665,6 +1737,7 @@ function createClient(opts) {
1665
1737
  bonus: new BonusResource(http),
1666
1738
  debt: new DebtResource(http),
1667
1739
  closeRequests: new CloseRequestsResource(http),
1740
+ claims: new ClaimsResource(http),
1668
1741
  codes: new CodesResource(http),
1669
1742
  referral: new ReferralResource(http),
1670
1743
  subscription: new SubscriptionResource(http),