@takeal/cusfront-sdk 0.6.1 → 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.
- package/CHANGELOG.md +28 -0
- package/README.md +55 -0
- package/dist/{cards-qfHz6xZY.d.cts → cards-DU2DdhYO.d.cts} +10 -0
- package/dist/{cards-CF3-He2x.d.ts → cards-DzhPVA9N.d.ts} +10 -0
- package/dist/{deposits-ZjT_btgi.d.cts → deposits-BEkNeE-v.d.cts} +1 -1
- package/dist/{deposits-B2LBe2k1.d.ts → deposits-Dt6A76MB.d.ts} +1 -1
- package/dist/index.cjs +95 -7
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +16 -8
- package/dist/index.d.ts +16 -8
- package/dist/index.js +95 -7
- package/dist/index.js.map +1 -1
- package/dist/react/index.d.cts +4 -2
- package/dist/react/index.d.ts +4 -2
- package/dist/resources/auth.cjs +25 -4
- package/dist/resources/auth.cjs.map +1 -1
- package/dist/resources/auth.d.cts +40 -5
- package/dist/resources/auth.d.ts +40 -5
- package/dist/resources/auth.js +25 -4
- package/dist/resources/auth.js.map +1 -1
- package/dist/resources/cards.cjs +2 -0
- package/dist/resources/cards.cjs.map +1 -1
- package/dist/resources/cards.d.cts +2 -1
- package/dist/resources/cards.d.ts +2 -1
- package/dist/resources/cards.js +2 -0
- package/dist/resources/cards.js.map +1 -1
- package/dist/resources/consents.cjs +91 -0
- package/dist/resources/consents.cjs.map +1 -0
- package/dist/resources/consents.d.cts +83 -0
- package/dist/resources/consents.d.ts +83 -0
- package/dist/resources/consents.js +89 -0
- package/dist/resources/consents.js.map +1 -0
- package/dist/resources/deposits.cjs +2 -0
- 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 +2 -0
- package/dist/resources/deposits.js.map +1 -1
- package/dist/resources/funding-options.d.cts +3 -2
- package/dist/resources/funding-options.d.ts +3 -2
- package/dist/resources/me.d.cts +1 -0
- package/dist/resources/me.d.ts +1 -0
- package/dist/resources/receipts.cjs +22 -0
- package/dist/resources/receipts.cjs.map +1 -0
- package/dist/resources/receipts.d.cts +51 -0
- package/dist/resources/receipts.d.ts +51 -0
- package/dist/resources/receipts.js +20 -0
- package/dist/resources/receipts.js.map +1 -0
- package/dist/telegram.cjs +133 -7
- package/dist/telegram.cjs.map +1 -1
- package/dist/telegram.d.cts +4 -2
- package/dist/telegram.d.ts +4 -2
- package/dist/telegram.js +133 -7
- package/dist/telegram.js.map +1 -1
- package/package.json +11 -1
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,34 @@ 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.2] — 2026-10-18
|
|
8
|
+
|
|
9
|
+
Needs platform (TKL) 0.6.7 or newer: `SUPPORTED_MEISTER` is `>=0.6.7, <0.7.0`.
|
|
10
|
+
Everything below talks to endpoints that exist from that version on.
|
|
11
|
+
|
|
12
|
+
### Added
|
|
13
|
+
|
|
14
|
+
- Consents: `auth.register` takes `consents` and `consent_channel`,
|
|
15
|
+
`auth.exchangeTelegram` takes `consents` and `consentChannel` for a new
|
|
16
|
+
account, and `cards.create` (with the `issue_card` block of
|
|
17
|
+
`deposits.initiate`) takes `consents` and `consentChannel`. The server
|
|
18
|
+
records each one with the version of its documents in force.
|
|
19
|
+
- `client.consents`: `get()`, `set(kind, given)` for the optional consents,
|
|
20
|
+
and `setCookies({ analytics })` for the cookie banner, signed in or not.
|
|
21
|
+
Also as `@takeal/cusfront-sdk/consents`.
|
|
22
|
+
- `client.receipts`: `list({ refId })` and `get(id)`, a numbered receipt for
|
|
23
|
+
every payment. Also as `@takeal/cusfront-sdk/receipts`.
|
|
24
|
+
- `auth.requestEmailChange` and `auth.confirmEmailChange`: an email change
|
|
25
|
+
confirmed by a code sent to the new address.
|
|
26
|
+
|
|
27
|
+
### Changed
|
|
28
|
+
|
|
29
|
+
- `auth.linkEmail` is for the first address of an account made in the Mini
|
|
30
|
+
App only; an account with a real address gets 409
|
|
31
|
+
`email_change_needs_code` and changes it in two steps instead.
|
|
32
|
+
- `SUPPORTED_MEISTER` narrowed to `>=0.6.7, <0.7.0`; `client.ready()` warns
|
|
33
|
+
on an older deployment.
|
|
34
|
+
|
|
7
35
|
## [0.6.1] — 2026-10-12
|
|
8
36
|
|
|
9
37
|
Needs platform (TKL) 0.6.4 or newer: `SUPPORTED_MEISTER` is `>=0.6.4, <0.7.0`.
|
package/README.md
CHANGED
|
@@ -633,6 +633,59 @@ const v2 = await client.documents.version("offer", 2);
|
|
|
633
633
|
A version dated ahead stays out of `get()` until its day comes, so a new
|
|
634
634
|
redaction can be prepared in advance.
|
|
635
635
|
|
|
636
|
+
### Changing the email
|
|
637
|
+
|
|
638
|
+
A new address proves it is the user's with a code sent there; nothing
|
|
639
|
+
changes before the code comes back, and the old address gets a notice.
|
|
640
|
+
|
|
641
|
+
```ts
|
|
642
|
+
const { challenge_id, destination_hint } = await client.auth.requestEmailChange({ email });
|
|
643
|
+
// "We sent a code to ne***@example.com"
|
|
644
|
+
const user = await client.auth.confirmEmailChange({ challengeId: challenge_id, code });
|
|
645
|
+
```
|
|
646
|
+
|
|
647
|
+
`linkEmail` is only for the first address of an account made in the Mini App.
|
|
648
|
+
|
|
649
|
+
### Receipts
|
|
650
|
+
|
|
651
|
+
Every payment gets a numbered receipt within a minute: a wallet top-up, a
|
|
652
|
+
card top-up and a card's issue price. It is mailed to the user and can be
|
|
653
|
+
shown next to the payment.
|
|
654
|
+
|
|
655
|
+
```ts
|
|
656
|
+
const [receipt] = await client.receipts.list({ refId: deposit.id });
|
|
657
|
+
// receipt.number "R-000123", paid_amount + paid_currency, method,
|
|
658
|
+
// and for a top-up credited_amount + credited_currency and rate
|
|
659
|
+
```
|
|
660
|
+
|
|
661
|
+
### Consents
|
|
662
|
+
|
|
663
|
+
Send the boxes the user ticked with the sign-up and with a card order. The
|
|
664
|
+
server records each one with the version of its documents in force at that
|
|
665
|
+
moment, so the client never sends document versions.
|
|
666
|
+
|
|
667
|
+
```ts
|
|
668
|
+
await client.auth.register({ email, password, consents: ["terms", "personal_data", "marketing"] });
|
|
669
|
+
await client.cards.create({ productId, currency: "USD", consents: ["terms"], idempotencyKey });
|
|
670
|
+
|
|
671
|
+
const { consents } = await client.consents.get(); // where each one stands
|
|
672
|
+
await client.consents.set("marketing", false); // advertising off in every channel
|
|
673
|
+
```
|
|
674
|
+
|
|
675
|
+
The cookie banner reports its choice the same way, signed in or not; before
|
|
676
|
+
sign-in it is kept under the anonymous key and moves to the account at
|
|
677
|
+
sign-up. Declining analytics deletes the visitor's recorded visits and
|
|
678
|
+
analytics ids.
|
|
679
|
+
|
|
680
|
+
```ts
|
|
681
|
+
await client.consents.setCookies({ analytics: false });
|
|
682
|
+
```
|
|
683
|
+
|
|
684
|
+
`terms` covers the offer, the tariffs and the privacy policy. A deployment
|
|
685
|
+
can refuse a sign-up without `terms` and `personal_data`
|
|
686
|
+
(400 `consents_required`). Only `marketing` and `cookies_analytics` can be
|
|
687
|
+
withdrawn later; the required ones go with the account.
|
|
688
|
+
|
|
636
689
|
### From `client.blog`
|
|
637
690
|
|
|
638
691
|
`client.blog` still works for one release and is marked deprecated. Same
|
|
@@ -1051,6 +1104,8 @@ Available now:
|
|
|
1051
1104
|
- `@takeal/cusfront-sdk/devices` — `DevicesResource` (Web Push, mobile push tokens, the Telegram Mini App marker).
|
|
1052
1105
|
- `@takeal/cusfront-sdk/me` — `MeResource` (link or unlink Telegram for the signed-in user).
|
|
1053
1106
|
- `@takeal/cusfront-sdk/history` — `HistoryResource` (the user's money history).
|
|
1107
|
+
- `@takeal/cusfront-sdk/consents` — `ConsentsResource` (what the user agreed to).
|
|
1108
|
+
- `@takeal/cusfront-sdk/receipts` — `ReceiptsResource` (a numbered receipt for every payment).
|
|
1054
1109
|
- `@takeal/cusfront-sdk/attribution` — `AttributionResource`, `anonymousKey`, `currentTouch` (where users come from).
|
|
1055
1110
|
- `@takeal/cusfront-sdk/webhooks` — HMAC-SHA256 signature verifier (no network, isomorphic).
|
|
1056
1111
|
- `@takeal/cusfront-sdk/react` — optional React hooks layer (`ClientProvider` + `useMe` / `useDeposits` / `useCards` / `useCardProducts` / `useBalance` / `useNotifications` / `useUnreadCount`). React is a `peerDependency`, never bundled.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ConsentKind, ConsentChannel } from './resources/consents.cjs';
|
|
1
2
|
import { H as HttpClient } from './http-DeANAoTs.cjs';
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -294,6 +295,15 @@ interface CreateCardInput {
|
|
|
294
295
|
* `promo_code` on the top-up there.
|
|
295
296
|
*/
|
|
296
297
|
promoCode?: string;
|
|
298
|
+
/**
|
|
299
|
+
* Consents the user gave with the order (`terms`, `personal_data`,
|
|
300
|
+
* `marketing`). Recorded with the card, or with the top-up inside
|
|
301
|
+
* `deposits.initiate({ issue_card })`, at the version of their documents
|
|
302
|
+
* in force now.
|
|
303
|
+
*/
|
|
304
|
+
consents?: ConsentKind[];
|
|
305
|
+
/** Where they were given. Sent as `consent_channel`. */
|
|
306
|
+
consentChannel?: ConsentChannel;
|
|
297
307
|
/**
|
|
298
308
|
* Required by the Takeal API on this write endpoint. Same key + body replays the
|
|
299
309
|
* original card; same key + different body returns 409.
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { ConsentKind, ConsentChannel } from './resources/consents.js';
|
|
1
2
|
import { H as HttpClient } from './http-DeANAoTs.js';
|
|
2
3
|
|
|
3
4
|
/**
|
|
@@ -294,6 +295,15 @@ interface CreateCardInput {
|
|
|
294
295
|
* `promo_code` on the top-up there.
|
|
295
296
|
*/
|
|
296
297
|
promoCode?: string;
|
|
298
|
+
/**
|
|
299
|
+
* Consents the user gave with the order (`terms`, `personal_data`,
|
|
300
|
+
* `marketing`). Recorded with the card, or with the top-up inside
|
|
301
|
+
* `deposits.initiate({ issue_card })`, at the version of their documents
|
|
302
|
+
* in force now.
|
|
303
|
+
*/
|
|
304
|
+
consents?: ConsentKind[];
|
|
305
|
+
/** Where they were given. Sent as `consent_channel`. */
|
|
306
|
+
consentChannel?: ConsentChannel;
|
|
297
307
|
/**
|
|
298
308
|
* Required by the Takeal API on this write endpoint. Same key + body replays the
|
|
299
309
|
* original card; same key + different body returns 409.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { H as HttpClient } from './http-DeANAoTs.cjs';
|
|
2
|
-
import { p as CustomerInfo, o as CreateCardInput } from './cards-
|
|
2
|
+
import { p as CustomerInfo, o as CreateCardInput } from './cards-DU2DdhYO.cjs';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Funding options resource — `client.fundingOptions.*`.
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { H as HttpClient } from './http-DeANAoTs.js';
|
|
2
|
-
import { p as CustomerInfo, o as CreateCardInput } from './cards-
|
|
2
|
+
import { p as CustomerInfo, o as CreateCardInput } from './cards-DzhPVA9N.js';
|
|
3
3
|
|
|
4
4
|
/**
|
|
5
5
|
* Funding options resource — `client.fundingOptions.*`.
|
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
|
|
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
|
|
315
|
-
*
|
|
316
|
-
*
|
|
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 {
|
|
@@ -1162,6 +1185,69 @@ var HistoryResource = class {
|
|
|
1162
1185
|
}
|
|
1163
1186
|
};
|
|
1164
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
|
+
|
|
1165
1251
|
// src/resources/funding-options.ts
|
|
1166
1252
|
var FundingOptionsResource = class {
|
|
1167
1253
|
constructor(http) {
|
|
@@ -1174,7 +1260,7 @@ var FundingOptionsResource = class {
|
|
|
1174
1260
|
};
|
|
1175
1261
|
|
|
1176
1262
|
// src/version.ts
|
|
1177
|
-
var SDK_VERSION = "0.6.
|
|
1263
|
+
var SDK_VERSION = "0.6.2";
|
|
1178
1264
|
|
|
1179
1265
|
// src/client-platform.ts
|
|
1180
1266
|
var CLIENT_HEADER = "X-Takeal-Client";
|
|
@@ -1249,7 +1335,7 @@ function isAbsolute(url) {
|
|
|
1249
1335
|
}
|
|
1250
1336
|
|
|
1251
1337
|
// src/compat.ts
|
|
1252
|
-
var SUPPORTED_MEISTER = ">=0.6.
|
|
1338
|
+
var SUPPORTED_MEISTER = ">=0.6.7, <0.7.0";
|
|
1253
1339
|
var SEMVER = /^v?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/;
|
|
1254
1340
|
function parse(v) {
|
|
1255
1341
|
const m = SEMVER.exec(v.trim());
|
|
@@ -1776,7 +1862,9 @@ function createClient(opts) {
|
|
|
1776
1862
|
notifications: new NotificationsResource(http),
|
|
1777
1863
|
devices: new DevicesResource(http, client),
|
|
1778
1864
|
attribution: new AttributionResource(http),
|
|
1779
|
-
history: new HistoryResource(http)
|
|
1865
|
+
history: new HistoryResource(http),
|
|
1866
|
+
consents: new ConsentsResource(http),
|
|
1867
|
+
receipts: new ReceiptsResource(http)
|
|
1780
1868
|
};
|
|
1781
1869
|
}
|
|
1782
1870
|
function pickDefaultStore(key) {
|