@takeal/cusfront-sdk 0.6.5 → 0.6.8
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 +49 -0
- package/README.md +90 -0
- package/dist/{cards-ColpW52n.d.ts → cards-BgY00UpU.d.ts} +18 -1
- package/dist/{cards-CEFKrVkl.d.cts → cards-DGz4Rqu1.d.cts} +18 -1
- package/dist/{devices-B_YveTl9.d.ts → devices-C88c38hm.d.ts} +1 -1
- package/dist/{devices-a5Z45Mx_.d.cts → devices-CiJrlXum.d.cts} +1 -1
- package/dist/{http-DeANAoTs.d.cts → http-CL97TjMO.d.cts} +4 -0
- package/dist/{http-DeANAoTs.d.ts → http-CL97TjMO.d.ts} +4 -0
- package/dist/index.cjs +142 -6
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +19 -11
- package/dist/index.d.ts +19 -11
- package/dist/index.js +142 -6
- package/dist/index.js.map +1 -1
- package/dist/react/index.d.cts +5 -3
- package/dist/react/index.d.ts +5 -3
- package/dist/resources/attribution.d.cts +1 -1
- package/dist/resources/attribution.d.ts +1 -1
- package/dist/resources/auth.cjs.map +1 -1
- package/dist/resources/auth.d.cts +3 -2
- package/dist/resources/auth.d.ts +3 -2
- package/dist/resources/auth.js.map +1 -1
- package/dist/resources/balance.d.cts +1 -1
- package/dist/resources/balance.d.ts +1 -1
- package/dist/resources/blog.d.cts +1 -1
- package/dist/resources/blog.d.ts +1 -1
- package/dist/resources/bonus.d.cts +1 -1
- package/dist/resources/bonus.d.ts +1 -1
- package/dist/resources/branding.d.cts +1 -1
- package/dist/resources/branding.d.ts +1 -1
- package/dist/resources/cards.cjs +16 -0
- package/dist/resources/cards.cjs.map +1 -1
- package/dist/resources/cards.d.cts +3 -2
- package/dist/resources/cards.d.ts +3 -2
- package/dist/resources/cards.js +16 -0
- package/dist/resources/cards.js.map +1 -1
- package/dist/resources/claims.cjs +40 -0
- package/dist/resources/claims.cjs.map +1 -0
- package/dist/resources/claims.d.cts +114 -0
- package/dist/resources/claims.d.ts +114 -0
- package/dist/resources/claims.js +38 -0
- package/dist/resources/claims.js.map +1 -0
- package/dist/resources/close-requests.d.cts +1 -1
- package/dist/resources/close-requests.d.ts +1 -1
- package/dist/resources/codes.d.cts +1 -1
- package/dist/resources/codes.d.ts +1 -1
- package/dist/resources/consents.d.cts +1 -1
- package/dist/resources/consents.d.ts +1 -1
- package/dist/resources/debt.d.cts +1 -1
- package/dist/resources/debt.d.ts +1 -1
- package/dist/resources/deposits.cjs.map +1 -1
- package/dist/resources/deposits.d.cts +3 -2
- package/dist/resources/deposits.d.ts +3 -2
- package/dist/resources/deposits.js.map +1 -1
- package/dist/resources/devices.d.cts +2 -2
- package/dist/resources/devices.d.ts +2 -2
- package/dist/resources/documents.d.cts +1 -1
- package/dist/resources/documents.d.ts +1 -1
- package/dist/resources/funding-options.d.cts +3 -2
- package/dist/resources/funding-options.d.ts +3 -2
- package/dist/resources/history.d.cts +1 -1
- package/dist/resources/history.d.ts +1 -1
- package/dist/resources/me.d.cts +3 -2
- package/dist/resources/me.d.ts +3 -2
- package/dist/resources/notifications.d.cts +1 -1
- package/dist/resources/notifications.d.ts +1 -1
- package/dist/resources/push.d.cts +1 -1
- package/dist/resources/push.d.ts +1 -1
- package/dist/resources/receipts.d.cts +1 -1
- package/dist/resources/receipts.d.ts +1 -1
- package/dist/resources/referral.d.cts +1 -1
- package/dist/resources/referral.d.ts +1 -1
- package/dist/resources/sessions.d.cts +1 -1
- package/dist/resources/sessions.d.ts +1 -1
- package/dist/resources/subscription.cjs +9 -0
- package/dist/resources/subscription.cjs.map +1 -1
- package/dist/resources/subscription.d.cts +20 -3
- package/dist/resources/subscription.d.ts +20 -3
- package/dist/resources/subscription.js +9 -0
- package/dist/resources/subscription.js.map +1 -1
- package/dist/resources/subscriptions.d.cts +1 -1
- package/dist/resources/subscriptions.d.ts +1 -1
- package/dist/resources/support.cjs +69 -0
- package/dist/resources/support.cjs.map +1 -0
- package/dist/resources/support.d.cts +115 -0
- package/dist/resources/support.d.ts +115 -0
- package/dist/resources/support.js +67 -0
- package/dist/resources/support.js.map +1 -0
- package/dist/resources/wallet.d.cts +1 -1
- package/dist/resources/wallet.d.ts +1 -1
- package/dist/telegram.cjs +142 -6
- package/dist/telegram.cjs.map +1 -1
- package/dist/telegram.d.cts +5 -3
- package/dist/telegram.d.ts +5 -3
- package/dist/telegram.js +142 -6
- package/dist/telegram.js.map +1 -1
- package/package.json +11 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,55 @@ All notable changes to `@takeal/cusfront-sdk` are documented here. The format
|
|
|
4
4
|
follows [Keep a Changelog](https://keepachangelog.com/en/1.1.0/) and the project
|
|
5
5
|
adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
6
6
|
|
|
7
|
+
## [0.6.8] — 2026-10-27
|
|
8
|
+
|
|
9
|
+
Works with platform (TKL) 0.6.13 up to, not including, 1.0.0: `SUPPORTED_MEISTER` is
|
|
10
|
+
`>=0.6.13, <1.0.0`, so the SDK keeps working with platform 0.7.0.
|
|
11
|
+
|
|
12
|
+
## [0.6.7] — 2026-10-27
|
|
13
|
+
|
|
14
|
+
Needs platform (TKL) 0.6.13 or newer: `SUPPORTED_MEISTER` is `>=0.6.13, <0.7.0`.
|
|
15
|
+
|
|
16
|
+
### Added
|
|
17
|
+
|
|
18
|
+
- `subscription.cancel()`: the person cancels their subscription in one
|
|
19
|
+
step. What they paid for the current period comes back to the balance
|
|
20
|
+
for the days not used; the answer says how much. Needs the platform's
|
|
21
|
+
next release.
|
|
22
|
+
- `cards.reportLost(id, { kind, details })`: the user reports a card lost
|
|
23
|
+
or stolen, at any time. The report is recorded with the server's time,
|
|
24
|
+
which decides who pays for operations someone else made, and the card is
|
|
25
|
+
frozen at its issuer; only support can unfreeze it. Resolves to a
|
|
26
|
+
`Claim`. When the issuer can't be reached, `card_freeze` is `"pending"`
|
|
27
|
+
and the report counts all the same. Needs the platform's next release.
|
|
28
|
+
- `claims`: dispute a card operation or complain with `create({ kind,
|
|
29
|
+
description, cardId, transactionId })`, and follow every claim, lost and
|
|
30
|
+
stolen cards included, with `list()` and `get(id)`: a `number` such as
|
|
31
|
+
`C-000123`, a `status` (`open`, `in_review`, `resolved`, `rejected`) and
|
|
32
|
+
support's answer in `resolution`. Needs the platform's next release.
|
|
33
|
+
|
|
34
|
+
### Changed
|
|
35
|
+
|
|
36
|
+
- `support`: a message the person wrote in Telegram keeps its formatting.
|
|
37
|
+
Its `html` now carries it (bold, italic, code, links with their
|
|
38
|
+
addresses), and `text` the plain words. An answer sent to the person's
|
|
39
|
+
Telegram is `queued` until all of it got there and `failed` if it could
|
|
40
|
+
not; it used to be `delivered` at once. Needs the platform's next
|
|
41
|
+
release.
|
|
42
|
+
|
|
43
|
+
## [0.6.6] — 2026-10-23
|
|
44
|
+
|
|
45
|
+
### Added
|
|
46
|
+
|
|
47
|
+
- `support`: the chat with support. `list()` reads the conversation (oldest
|
|
48
|
+
first, `before` for older pages) and its status, `send({ text, files })`
|
|
49
|
+
writes with up to 10 files (a `File`, bytes or base64), `attachment(id)`
|
|
50
|
+
downloads a file as a `Blob`. Answers come with ready, cleaned HTML in
|
|
51
|
+
`html`. Needs the platform's support chat (0.6.12).
|
|
52
|
+
- `support.rate(id, { rating, comment })` and `rating_request` on the
|
|
53
|
+
conversation: support asks how it went after closing a conversation it
|
|
54
|
+
answered.
|
|
55
|
+
|
|
7
56
|
## [0.6.5] — 2026-10-21
|
|
8
57
|
|
|
9
58
|
Needs platform (TKL) 0.6.11 or newer: `SUPPORTED_MEISTER` is `>=0.6.11, <0.7.0`.
|
package/README.md
CHANGED
|
@@ -712,6 +712,43 @@ Only the last four digits come back (`payout_details.masked`). 409 codes of
|
|
|
712
712
|
`topup_in_progress`, `card_closing`, `no_balance` (the card holds nothing:
|
|
713
713
|
`cards.terminate()` it), `provider_refused`.
|
|
714
714
|
|
|
715
|
+
## A lost or stolen card, disputes and complaints
|
|
716
|
+
|
|
717
|
+
The user can report a card lost or stolen at any time. The report is
|
|
718
|
+
recorded first, with the server's time: that time decides who pays for
|
|
719
|
+
operations someone else made with the card, so show it. Then the card is
|
|
720
|
+
frozen at its issuer, and from then on only support can unfreeze it
|
|
721
|
+
(`cards.unfreeze()` answers 409 `card_locked`).
|
|
722
|
+
|
|
723
|
+
```ts
|
|
724
|
+
const claim = await client.cards.reportLost(cardId, { kind: "stolen", details: "Taken with my bag" });
|
|
725
|
+
// claim.number: "C-000123", to quote to support
|
|
726
|
+
// claim.reported_at: when the report counts from
|
|
727
|
+
// claim.card_freeze: "frozen", or "pending" when the issuer couldn't be reached;
|
|
728
|
+
// the report counts all the same and support freezes the card by hand
|
|
729
|
+
```
|
|
730
|
+
|
|
731
|
+
Reporting the same card again while its report is open returns that claim.
|
|
732
|
+
409 `card_not_open`: the card is closed or was never issued.
|
|
733
|
+
|
|
734
|
+
A card operation the user doesn't agree with, or anything else, is a claim
|
|
735
|
+
too. Name the operation as `client.history` does (`txn_<id>`); its card is
|
|
736
|
+
found from it.
|
|
737
|
+
|
|
738
|
+
```ts
|
|
739
|
+
await client.claims.create({
|
|
740
|
+
kind: "dispute", // or "complaint"
|
|
741
|
+
transactionId: entry.id,
|
|
742
|
+
description: "I didn't make this payment and don't know the shop.",
|
|
743
|
+
});
|
|
744
|
+
const { items, total } = await client.claims.list(); // newest first, every kind
|
|
745
|
+
const one = await client.claims.get(claimId);
|
|
746
|
+
// status: "open" → "in_review" → "resolved" | "rejected", with support's answer in `resolution`
|
|
747
|
+
```
|
|
748
|
+
|
|
749
|
+
The user is notified when a claim comes in and each time its status
|
|
750
|
+
changes. 409 `too_many_claims`: 20 claims are waiting for an answer already.
|
|
751
|
+
|
|
715
752
|
## Promo and referral codes
|
|
716
753
|
|
|
717
754
|
A code goes with the operation it is for. At sign-up an unknown or expired
|
|
@@ -1040,6 +1077,58 @@ export default {
|
|
|
1040
1077
|
|
|
1041
1078
|
With Workbox, add `/^\/ingest\//` to `navigateFallbackDenylist` and give the path no runtime caching route.
|
|
1042
1079
|
|
|
1080
|
+
## Support chat
|
|
1081
|
+
|
|
1082
|
+
`client.support` is the chat with support: one conversation per person, the
|
|
1083
|
+
same one the Telegram bot feeds. Support agents answer from their own inbox,
|
|
1084
|
+
and the answers come back here.
|
|
1085
|
+
|
|
1086
|
+
```ts
|
|
1087
|
+
// A message with a picture from a file input.
|
|
1088
|
+
const file = input.files![0];
|
|
1089
|
+
const sent = await client.support.send({
|
|
1090
|
+
text: "The card was declined at the shop",
|
|
1091
|
+
files: [{ fileName: file.name, contentType: file.type, data: file }],
|
|
1092
|
+
});
|
|
1093
|
+
// sent.status === "queued" at first; "delivered" once support has it.
|
|
1094
|
+
|
|
1095
|
+
const chat = await client.support.list();
|
|
1096
|
+
// chat.status: "none" | "open" | "resolved"; chat.items oldest first.
|
|
1097
|
+
for (const m of chat.items) {
|
|
1098
|
+
if (m.author === "support") {
|
|
1099
|
+
// Cleaned HTML, ready to show: paragraphs, line breaks, bold, italic,
|
|
1100
|
+
// strikethrough, code, links, lists and quotes. Nothing else gets through.
|
|
1101
|
+
bubble.innerHTML = m.html;
|
|
1102
|
+
caption.textContent = m.operator_name ?? "Support";
|
|
1103
|
+
} else {
|
|
1104
|
+
bubble.textContent = m.text;
|
|
1105
|
+
}
|
|
1106
|
+
for (const a of m.attachments) {
|
|
1107
|
+
const blob = await client.support.attachment(a.id); // the person's own or support's
|
|
1108
|
+
}
|
|
1109
|
+
}
|
|
1110
|
+
|
|
1111
|
+
// Older messages:
|
|
1112
|
+
if (chat.has_more) await client.support.list({ before: chat.items[0].created_at });
|
|
1113
|
+
```
|
|
1114
|
+
|
|
1115
|
+
Show what the person sent right away, with its `status`: `queued` turns into
|
|
1116
|
+
`delivered` within seconds, and `failed` means the message could not be passed
|
|
1117
|
+
on (support sees those too and can send them again). Files are pictures and
|
|
1118
|
+
PDF up to 20 MB by default; the platform sets both, and a file it doesn't take
|
|
1119
|
+
comes back as a 400 with the reason. Up to 10 files per message.
|
|
1120
|
+
|
|
1121
|
+
When support closes the conversation after answering, `chat.rating_request`
|
|
1122
|
+
asks how it went (a `support_rating_requested` notification points there too).
|
|
1123
|
+
Show 1 to 5 and an optional comment, then
|
|
1124
|
+
`client.support.rate(chat.rating_request.id, { rating: 5, comment })`. The
|
|
1125
|
+
question goes away once answered; a person who wrote from Telegram is asked
|
|
1126
|
+
there instead, with buttons.
|
|
1127
|
+
|
|
1128
|
+
A new answer also arrives as a `support_reply` notification (see
|
|
1129
|
+
[Notifications](#notifications-inbox)) with `href: "/support"`. Writing to a
|
|
1130
|
+
conversation support has closed opens it again.
|
|
1131
|
+
|
|
1043
1132
|
## Notifications (inbox)
|
|
1044
1133
|
|
|
1045
1134
|
Everything the API tells a user (a confirmed deposit, a card transaction, a
|
|
@@ -1300,6 +1389,7 @@ Available now:
|
|
|
1300
1389
|
- `@takeal/cusfront-sdk/history` — `HistoryResource` (the user's money history).
|
|
1301
1390
|
- `@takeal/cusfront-sdk/consents` — `ConsentsResource` (what the user agreed to).
|
|
1302
1391
|
- `@takeal/cusfront-sdk/receipts` — `ReceiptsResource` (a numbered receipt for every payment).
|
|
1392
|
+
- `@takeal/cusfront-sdk/support` — `SupportResource` (the chat with support; see [Support chat](#support-chat)).
|
|
1303
1393
|
- `@takeal/cusfront-sdk/attribution` — `AttributionResource`, `anonymousKey`, `currentTouch` (where users come from).
|
|
1304
1394
|
- `@takeal/cusfront-sdk/webhooks` — HMAC-SHA256 signature verifier (no network, isomorphic).
|
|
1305
1395
|
- `@takeal/cusfront-sdk/react` — optional React hooks layer (`ClientProvider` + `useMe` / `useDeposits` / `useCards` / `useCardProducts` / `useBalance` / `useNotifications` / `useUnreadCount`). React is a `peerDependency`, never bundled.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { Claim } from './resources/claims.js';
|
|
1
2
|
import { ConsentKind, ConsentChannel } from './resources/consents.js';
|
|
2
|
-
import { H as HttpClient } from './http-
|
|
3
|
+
import { H as HttpClient } from './http-CL97TjMO.js';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Structured customer billing details — shared by the deposits and cards
|
|
@@ -444,6 +445,7 @@ declare class DepositsResource {
|
|
|
444
445
|
* GET /me/cards/{id}/balance → balance (prepaid remaining)
|
|
445
446
|
* POST /me/cards/{id}/freeze → freeze
|
|
446
447
|
* POST /me/cards/{id}/unfreeze → unfreeze
|
|
448
|
+
* POST /me/cards/{id}/report-lost → reportLost (lost or stolen: frozen at once)
|
|
447
449
|
* POST /me/cards/{id}/transfer → transfer (to another of their cards)
|
|
448
450
|
* POST /me/cards/{id}/terminate → terminate (one-way)
|
|
449
451
|
* POST /me/cards/{id}/reveal → reveal (the numbers, or a provider page)
|
|
@@ -1171,6 +1173,21 @@ declare class CardsResource {
|
|
|
1171
1173
|
* button and say the freeze is lifted through the issuer's support.
|
|
1172
1174
|
*/
|
|
1173
1175
|
unfreeze(id: string): Promise<Card>;
|
|
1176
|
+
/**
|
|
1177
|
+
* Report the card lost or stolen. Works at any time, on an active or a
|
|
1178
|
+
* frozen card. The report is recorded first with the server's time, which
|
|
1179
|
+
* decides who pays for operations someone else made; then the card is
|
|
1180
|
+
* frozen at its issuer and only support can unfreeze it. Resolves to the
|
|
1181
|
+
* claim (`client.claims`): show its `number` and `reported_at`. When the
|
|
1182
|
+
* issuer can't be reached, `card_freeze` is `"pending"`: the report still
|
|
1183
|
+
* counts and support freezes the card by hand. Reporting again while the
|
|
1184
|
+
* report is open returns the same claim. 404 / 403 not the user's card ·
|
|
1185
|
+
* 409 `card_not_open`: the card is closed or was never issued.
|
|
1186
|
+
*/
|
|
1187
|
+
reportLost(id: string, input: {
|
|
1188
|
+
kind: "lost" | "stolen";
|
|
1189
|
+
details?: string;
|
|
1190
|
+
}): Promise<Claim>;
|
|
1174
1191
|
/**
|
|
1175
1192
|
* Set the PIN of the caller's own physical card. The session is enough; the
|
|
1176
1193
|
* call is rate-limited like {@link reveal} and the PIN is kept nowhere.
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
+
import { Claim } from './resources/claims.cjs';
|
|
1
2
|
import { ConsentKind, ConsentChannel } from './resources/consents.cjs';
|
|
2
|
-
import { H as HttpClient } from './http-
|
|
3
|
+
import { H as HttpClient } from './http-CL97TjMO.cjs';
|
|
3
4
|
|
|
4
5
|
/**
|
|
5
6
|
* Structured customer billing details — shared by the deposits and cards
|
|
@@ -444,6 +445,7 @@ declare class DepositsResource {
|
|
|
444
445
|
* GET /me/cards/{id}/balance → balance (prepaid remaining)
|
|
445
446
|
* POST /me/cards/{id}/freeze → freeze
|
|
446
447
|
* POST /me/cards/{id}/unfreeze → unfreeze
|
|
448
|
+
* POST /me/cards/{id}/report-lost → reportLost (lost or stolen: frozen at once)
|
|
447
449
|
* POST /me/cards/{id}/transfer → transfer (to another of their cards)
|
|
448
450
|
* POST /me/cards/{id}/terminate → terminate (one-way)
|
|
449
451
|
* POST /me/cards/{id}/reveal → reveal (the numbers, or a provider page)
|
|
@@ -1171,6 +1173,21 @@ declare class CardsResource {
|
|
|
1171
1173
|
* button and say the freeze is lifted through the issuer's support.
|
|
1172
1174
|
*/
|
|
1173
1175
|
unfreeze(id: string): Promise<Card>;
|
|
1176
|
+
/**
|
|
1177
|
+
* Report the card lost or stolen. Works at any time, on an active or a
|
|
1178
|
+
* frozen card. The report is recorded first with the server's time, which
|
|
1179
|
+
* decides who pays for operations someone else made; then the card is
|
|
1180
|
+
* frozen at its issuer and only support can unfreeze it. Resolves to the
|
|
1181
|
+
* claim (`client.claims`): show its `number` and `reported_at`. When the
|
|
1182
|
+
* issuer can't be reached, `card_freeze` is `"pending"`: the report still
|
|
1183
|
+
* counts and support freezes the card by hand. Reporting again while the
|
|
1184
|
+
* report is open returns the same claim. 404 / 403 not the user's card ·
|
|
1185
|
+
* 409 `card_not_open`: the card is closed or was never issued.
|
|
1186
|
+
*/
|
|
1187
|
+
reportLost(id: string, input: {
|
|
1188
|
+
kind: "lost" | "stolen";
|
|
1189
|
+
details?: string;
|
|
1190
|
+
}): Promise<Claim>;
|
|
1174
1191
|
/**
|
|
1175
1192
|
* Set the PIN of the caller's own physical card. The session is enough; the
|
|
1176
1193
|
* call is rate-limited like {@link reveal} and the PIN is kept nowhere.
|
|
@@ -84,7 +84,11 @@ declare class HttpClient {
|
|
|
84
84
|
put<T>(path: string, opts?: HttpOptions): Promise<T>;
|
|
85
85
|
patch<T>(path: string, opts?: HttpOptions): Promise<T>;
|
|
86
86
|
delete<T>(path: string, opts?: HttpOptions): Promise<T>;
|
|
87
|
+
/** GET a file. Same auth and refresh as the JSON calls; an error status
|
|
88
|
+
* throws `ApiError` the same way. */
|
|
89
|
+
getBlob(path: string, opts?: HttpOptions): Promise<Blob>;
|
|
87
90
|
private request;
|
|
91
|
+
private send;
|
|
88
92
|
private absolute;
|
|
89
93
|
}
|
|
90
94
|
|
|
@@ -84,7 +84,11 @@ declare class HttpClient {
|
|
|
84
84
|
put<T>(path: string, opts?: HttpOptions): Promise<T>;
|
|
85
85
|
patch<T>(path: string, opts?: HttpOptions): Promise<T>;
|
|
86
86
|
delete<T>(path: string, opts?: HttpOptions): Promise<T>;
|
|
87
|
+
/** GET a file. Same auth and refresh as the JSON calls; an error status
|
|
88
|
+
* throws `ApiError` the same way. */
|
|
89
|
+
getBlob(path: string, opts?: HttpOptions): Promise<Blob>;
|
|
87
90
|
private request;
|
|
91
|
+
private send;
|
|
88
92
|
private absolute;
|
|
89
93
|
}
|
|
90
94
|
|
package/dist/index.cjs
CHANGED
|
@@ -73,10 +73,20 @@ var HttpClient = class {
|
|
|
73
73
|
async delete(path, opts = {}) {
|
|
74
74
|
return this.request("DELETE", path, opts);
|
|
75
75
|
}
|
|
76
|
+
/** GET a file. Same auth and refresh as the JSON calls; an error status
|
|
77
|
+
* throws `ApiError` the same way. */
|
|
78
|
+
async getBlob(path, opts = {}) {
|
|
79
|
+
const resp = await this.send("GET", path, { ...opts, accept: "*/*" });
|
|
80
|
+
if (!resp.ok) return parseResponse(resp);
|
|
81
|
+
return resp.blob();
|
|
82
|
+
}
|
|
76
83
|
async request(method, path, opts) {
|
|
84
|
+
return parseResponse(await this.send(method, path, opts));
|
|
85
|
+
}
|
|
86
|
+
async send(method, path, opts) {
|
|
77
87
|
const url = this.absolute(path);
|
|
78
88
|
const headers = {
|
|
79
|
-
Accept: "application/json",
|
|
89
|
+
Accept: opts.accept ?? "application/json",
|
|
80
90
|
...this.defaultHeaders
|
|
81
91
|
};
|
|
82
92
|
if (opts.body !== void 0) headers["Content-Type"] = "application/json";
|
|
@@ -102,10 +112,10 @@ var HttpClient = class {
|
|
|
102
112
|
}
|
|
103
113
|
if (resp.status === 401 && !opts.skipAuth && !opts.retried && this.refresher) {
|
|
104
114
|
if (await this.refreshOnce()) {
|
|
105
|
-
return this.
|
|
115
|
+
return this.send(method, path, { ...opts, retried: true });
|
|
106
116
|
}
|
|
107
117
|
}
|
|
108
|
-
return
|
|
118
|
+
return resp;
|
|
109
119
|
}
|
|
110
120
|
absolute(path) {
|
|
111
121
|
if (path.startsWith("http://") || path.startsWith("https://")) return path;
|
|
@@ -351,6 +361,22 @@ var CardsResource = class {
|
|
|
351
361
|
async unfreeze(id) {
|
|
352
362
|
return this.http.post(`/me/cards/${encodeURIComponent(id)}/unfreeze`, { body: {} });
|
|
353
363
|
}
|
|
364
|
+
/**
|
|
365
|
+
* Report the card lost or stolen. Works at any time, on an active or a
|
|
366
|
+
* frozen card. The report is recorded first with the server's time, which
|
|
367
|
+
* decides who pays for operations someone else made; then the card is
|
|
368
|
+
* frozen at its issuer and only support can unfreeze it. Resolves to the
|
|
369
|
+
* claim (`client.claims`): show its `number` and `reported_at`. When the
|
|
370
|
+
* issuer can't be reached, `card_freeze` is `"pending"`: the report still
|
|
371
|
+
* counts and support freezes the card by hand. Reporting again while the
|
|
372
|
+
* report is open returns the same claim. 404 / 403 not the user's card ·
|
|
373
|
+
* 409 `card_not_open`: the card is closed or was never issued.
|
|
374
|
+
*/
|
|
375
|
+
async reportLost(id, input) {
|
|
376
|
+
return this.http.post(`/me/cards/${encodeURIComponent(id)}/report-lost`, {
|
|
377
|
+
body: { kind: input.kind, details: input.details }
|
|
378
|
+
});
|
|
379
|
+
}
|
|
354
380
|
/**
|
|
355
381
|
* Set the PIN of the caller's own physical card. The session is enough; the
|
|
356
382
|
* call is rate-limited like {@link reveal} and the PIN is kept nowhere.
|
|
@@ -803,6 +829,41 @@ var CloseRequestsResource = class {
|
|
|
803
829
|
}
|
|
804
830
|
};
|
|
805
831
|
|
|
832
|
+
// src/resources/claims.ts
|
|
833
|
+
var ClaimsResource = class {
|
|
834
|
+
constructor(http) {
|
|
835
|
+
this.http = http;
|
|
836
|
+
}
|
|
837
|
+
/**
|
|
838
|
+
* Dispute a card operation, or complain. 400 `validation`: a description
|
|
839
|
+
* that is too short or too long, an operation that isn't on the user's
|
|
840
|
+
* cards, or a lost or stolen card (use `cards.reportLost()`) · 404 no
|
|
841
|
+
* such card · 409 `too_many_claims`: 20 claims are waiting for an answer.
|
|
842
|
+
*/
|
|
843
|
+
async create(input) {
|
|
844
|
+
return this.http.post("/me/claims", {
|
|
845
|
+
body: {
|
|
846
|
+
kind: input.kind,
|
|
847
|
+
description: input.description,
|
|
848
|
+
card_id: input.cardId,
|
|
849
|
+
transaction_id: input.transactionId
|
|
850
|
+
}
|
|
851
|
+
});
|
|
852
|
+
}
|
|
853
|
+
/** The user's claims, lost and stolen cards included, newest first. */
|
|
854
|
+
async list(opts = {}) {
|
|
855
|
+
const qs = new URLSearchParams();
|
|
856
|
+
if (opts.limit != null) qs.set("limit", String(opts.limit));
|
|
857
|
+
if (opts.offset != null) qs.set("offset", String(opts.offset));
|
|
858
|
+
const q = qs.toString();
|
|
859
|
+
return this.http.get(`/me/claims${q ? `?${q}` : ""}`, { signal: opts.signal });
|
|
860
|
+
}
|
|
861
|
+
/** One claim. 404 when it isn't the user's. */
|
|
862
|
+
async get(id, opts = {}) {
|
|
863
|
+
return this.http.get(`/me/claims/${encodeURIComponent(id)}`, { signal: opts.signal });
|
|
864
|
+
}
|
|
865
|
+
};
|
|
866
|
+
|
|
806
867
|
// src/resources/codes.ts
|
|
807
868
|
var CodesResource = class {
|
|
808
869
|
constructor(http) {
|
|
@@ -846,6 +907,15 @@ var SubscriptionResource = class {
|
|
|
846
907
|
async setPromoCode(code) {
|
|
847
908
|
return this.http.put("/me/subscription/promo-code", { body: { code } });
|
|
848
909
|
}
|
|
910
|
+
/**
|
|
911
|
+
* Cancel the subscription now, in one step. What was paid for the current
|
|
912
|
+
* period comes back to the balance for the days not used. No subscription
|
|
913
|
+
* running → 404; 503 `refund_unavailable` when the refund can't be made
|
|
914
|
+
* right now (the subscription keeps running; try again).
|
|
915
|
+
*/
|
|
916
|
+
async cancel() {
|
|
917
|
+
return this.http.post("/me/subscription/cancel", {});
|
|
918
|
+
}
|
|
849
919
|
};
|
|
850
920
|
|
|
851
921
|
// src/resources/branding.ts
|
|
@@ -1429,6 +1499,70 @@ var ReceiptsResource = class {
|
|
|
1429
1499
|
}
|
|
1430
1500
|
};
|
|
1431
1501
|
|
|
1502
|
+
// src/resources/support.ts
|
|
1503
|
+
function bytesToBase64(bytes) {
|
|
1504
|
+
let binary = "";
|
|
1505
|
+
const chunk = 32768;
|
|
1506
|
+
for (let i = 0; i < bytes.length; i += chunk) {
|
|
1507
|
+
binary += String.fromCharCode(...bytes.subarray(i, i + chunk));
|
|
1508
|
+
}
|
|
1509
|
+
return btoa(binary);
|
|
1510
|
+
}
|
|
1511
|
+
async function toBase64(data) {
|
|
1512
|
+
if (typeof data === "string") return data;
|
|
1513
|
+
if (data instanceof Uint8Array) return bytesToBase64(data);
|
|
1514
|
+
if (data instanceof ArrayBuffer) return bytesToBase64(new Uint8Array(data));
|
|
1515
|
+
return bytesToBase64(new Uint8Array(await data.arrayBuffer()));
|
|
1516
|
+
}
|
|
1517
|
+
var SupportResource = class {
|
|
1518
|
+
constructor(http) {
|
|
1519
|
+
this.http = http;
|
|
1520
|
+
}
|
|
1521
|
+
/** The latest messages, oldest first, and the conversation's status.
|
|
1522
|
+
* `before` reads further back; `limit` is 1 to 100 (50). */
|
|
1523
|
+
async list(opts = {}) {
|
|
1524
|
+
const q = new URLSearchParams();
|
|
1525
|
+
if (opts.before) q.set("before", opts.before);
|
|
1526
|
+
if (opts.limit !== void 0) q.set("limit", String(opts.limit));
|
|
1527
|
+
const qs = q.toString();
|
|
1528
|
+
return this.http.get(`/me/support/messages${qs ? `?${qs}` : ""}`, {
|
|
1529
|
+
signal: opts.signal
|
|
1530
|
+
});
|
|
1531
|
+
}
|
|
1532
|
+
/** Write to support. Text, files or both; up to 10 files. */
|
|
1533
|
+
async send(message, opts = {}) {
|
|
1534
|
+
const attachments = await Promise.all(
|
|
1535
|
+
(message.files ?? []).map(async (f) => ({
|
|
1536
|
+
file_name: f.fileName,
|
|
1537
|
+
content_type: f.contentType,
|
|
1538
|
+
data_base64: await toBase64(f.data)
|
|
1539
|
+
}))
|
|
1540
|
+
);
|
|
1541
|
+
return this.http.post("/me/support/messages", {
|
|
1542
|
+
body: { text: message.text ?? "", attachments },
|
|
1543
|
+
signal: opts.signal
|
|
1544
|
+
});
|
|
1545
|
+
}
|
|
1546
|
+
/** A file from the conversation: the person's own or one support sent. */
|
|
1547
|
+
async attachment(id, opts = {}) {
|
|
1548
|
+
return this.http.getBlob(`/me/support/attachments/${encodeURIComponent(id)}`, {
|
|
1549
|
+
signal: opts.signal
|
|
1550
|
+
});
|
|
1551
|
+
}
|
|
1552
|
+
/** Answer `rating_request`: 1 (bad) to 5 (great), a comment if the person
|
|
1553
|
+
* wrote one. Each question takes one answer; a second one is a 404. */
|
|
1554
|
+
async rate(id, answer, opts = {}) {
|
|
1555
|
+
await this.http.post(`/me/support/ratings/${encodeURIComponent(id)}`, {
|
|
1556
|
+
body: { rating: answer.rating, ...answer.comment ? { comment: answer.comment } : {} },
|
|
1557
|
+
signal: opts.signal
|
|
1558
|
+
});
|
|
1559
|
+
}
|
|
1560
|
+
/** Just the conversation's status. */
|
|
1561
|
+
async status(opts = {}) {
|
|
1562
|
+
return (await this.list({ limit: 1, signal: opts.signal })).status;
|
|
1563
|
+
}
|
|
1564
|
+
};
|
|
1565
|
+
|
|
1432
1566
|
// src/resources/funding-options.ts
|
|
1433
1567
|
var FundingOptionsResource = class {
|
|
1434
1568
|
constructor(http) {
|
|
@@ -1441,7 +1575,7 @@ var FundingOptionsResource = class {
|
|
|
1441
1575
|
};
|
|
1442
1576
|
|
|
1443
1577
|
// src/version.ts
|
|
1444
|
-
var SDK_VERSION = "0.6.
|
|
1578
|
+
var SDK_VERSION = "0.6.8";
|
|
1445
1579
|
|
|
1446
1580
|
// src/client-platform.ts
|
|
1447
1581
|
var CLIENT_HEADER = "X-Takeal-Client";
|
|
@@ -1516,7 +1650,7 @@ function isAbsolute(url) {
|
|
|
1516
1650
|
}
|
|
1517
1651
|
|
|
1518
1652
|
// src/compat.ts
|
|
1519
|
-
var SUPPORTED_MEISTER = ">=0.6.
|
|
1653
|
+
var SUPPORTED_MEISTER = ">=0.6.13, <1.0.0";
|
|
1520
1654
|
var SEMVER = /^v?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/;
|
|
1521
1655
|
function parse(v) {
|
|
1522
1656
|
const m = SEMVER.exec(v.trim());
|
|
@@ -2031,6 +2165,7 @@ function createClient(opts) {
|
|
|
2031
2165
|
bonus: new BonusResource(http),
|
|
2032
2166
|
debt: new DebtResource(http),
|
|
2033
2167
|
closeRequests: new CloseRequestsResource(http),
|
|
2168
|
+
claims: new ClaimsResource(http),
|
|
2034
2169
|
codes: new CodesResource(http),
|
|
2035
2170
|
referral: new ReferralResource(http),
|
|
2036
2171
|
subscription: new SubscriptionResource(http),
|
|
@@ -2047,7 +2182,8 @@ function createClient(opts) {
|
|
|
2047
2182
|
attribution: new AttributionResource(http),
|
|
2048
2183
|
history: new HistoryResource(http),
|
|
2049
2184
|
consents: new ConsentsResource(http),
|
|
2050
|
-
receipts: new ReceiptsResource(http)
|
|
2185
|
+
receipts: new ReceiptsResource(http),
|
|
2186
|
+
support: new SupportResource(http)
|
|
2051
2187
|
};
|
|
2052
2188
|
}
|
|
2053
2189
|
function pickDefaultStore(key) {
|