@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/dist/index.d.cts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { T as TokenStore, F as FetchLike } from './http-DeANAoTs.cjs';
|
|
2
2
|
export { d as defaultBrowserStore, i as inMemoryStore } from './http-DeANAoTs.cjs';
|
|
3
3
|
import { AuthResource } from './resources/auth.cjs';
|
|
4
|
-
export { ChangePasswordInput, ExchangeTelegramInput, JwtIssued, LinkTelegramInput, LoginInput, LoginResponse, OtpSentResponse, RegisterInput, Session, TelegramLink, TelegramUnknown, TotpRequired, TotpSetupComplete, TotpSetupRequired, User } from './resources/auth.cjs';
|
|
5
|
-
import { a as DepositsResource, F as FundingOptionsResource } from './deposits-
|
|
6
|
-
export { C as CardLoadStatus, b as CreateDepositRefundInput, c as CreateQuoteInput, D as Deposit, d as DepositMethod, e as DepositStatus, f as DepositTarget, g as FeeKind, h as FunderMode, i as FundingOption, j as FundingQuote, I as InitiateDepositInput, k as IssueCardInput, M as MethodTerms, R as Refund } from './deposits-
|
|
7
|
-
import { b as CardsResource } from './cards-
|
|
8
|
-
export { A as Address, B as BillingAddress, a as Card, c as CardBalance, d as CardDesignRef, e as CardForm, C as CardProduct, f as CardProductPrice, g as CardStatus, h as CardStatusSource, i as CardTopUp, j as CardTopUpStatus, k as CardTransfer, l as CardType, m as Cardholder, n as CloseBlockedReason, o as CreateCardInput, p as CustomerInfo, I as IssuanceBonus, R as RevealCardInput, q as RevealedCard, S as SetPinInput, T as TopUpInput, r as TopUpResult, s as TopUpTerms, t as TransferInput, u as TransferResult, U as UpdateCardInput } from './cards-
|
|
4
|
+
export { ChangePasswordInput, EmailChangeRequested, ExchangeTelegramInput, JwtIssued, LinkTelegramInput, LoginInput, LoginResponse, OtpSentResponse, RegisterInput, Session, TelegramLink, TelegramUnknown, TotpRequired, TotpSetupComplete, TotpSetupRequired, User } from './resources/auth.cjs';
|
|
5
|
+
import { a as DepositsResource, F as FundingOptionsResource } from './deposits-BEkNeE-v.cjs';
|
|
6
|
+
export { C as CardLoadStatus, b as CreateDepositRefundInput, c as CreateQuoteInput, D as Deposit, d as DepositMethod, e as DepositStatus, f as DepositTarget, g as FeeKind, h as FunderMode, i as FundingOption, j as FundingQuote, I as InitiateDepositInput, k as IssueCardInput, M as MethodTerms, R as Refund } from './deposits-BEkNeE-v.cjs';
|
|
7
|
+
import { b as CardsResource } from './cards-DU2DdhYO.cjs';
|
|
8
|
+
export { A as Address, B as BillingAddress, a as Card, c as CardBalance, d as CardDesignRef, e as CardForm, C as CardProduct, f as CardProductPrice, g as CardStatus, h as CardStatusSource, i as CardTopUp, j as CardTopUpStatus, k as CardTransfer, l as CardType, m as Cardholder, n as CloseBlockedReason, o as CreateCardInput, p as CustomerInfo, I as IssuanceBonus, R as RevealCardInput, q as RevealedCard, S as SetPinInput, T as TopUpInput, r as TopUpResult, s as TopUpTerms, t as TransferInput, u as TransferResult, U as UpdateCardInput } from './cards-DU2DdhYO.cjs';
|
|
9
9
|
import { BalanceResource } from './resources/balance.cjs';
|
|
10
10
|
export { Balance } from './resources/balance.cjs';
|
|
11
11
|
import { BonusResource } from './resources/bonus.cjs';
|
|
@@ -39,6 +39,10 @@ import { AttributionResource } from './resources/attribution.cjs';
|
|
|
39
39
|
export { AnonymousKeyOptions, AttributionStatus, SignupAttribution, SurveyAnswer, TouchFields, TouchInput, TouchResult, anonymousKey, currentTouch } from './resources/attribution.cjs';
|
|
40
40
|
import { HistoryResource } from './resources/history.cjs';
|
|
41
41
|
export { HistoryAmount, HistoryCard, HistoryItem, HistoryKind, HistoryPage, HistoryStatus, ListHistoryParams } from './resources/history.cjs';
|
|
42
|
+
import { ConsentsResource } from './resources/consents.cjs';
|
|
43
|
+
export { ConsentChannel, ConsentDocument, ConsentKind, ConsentState, Consents, CookieChoiceInput } from './resources/consents.cjs';
|
|
44
|
+
import { ReceiptsResource } from './resources/receipts.cjs';
|
|
45
|
+
export { ListReceiptsParams, Receipt, ReceiptKind } from './resources/receipts.cjs';
|
|
42
46
|
export { ANALYTICS_EVENTS, AnalyticsEvent, AnalyticsOptions, AnalyticsProperties, AnalyticsZone, METRIKA_GOALS, MetrikaOptions, NO_CAPTURE_CLASS, PostHogLike, PostHogOptions, identify, initAnalytics, page, posthogDistinctId, resetAnalytics, sanitizeProperties, sanitizeUrl, setAnalyticsZone, track } from './analytics.cjs';
|
|
43
47
|
|
|
44
48
|
/**
|
|
@@ -71,7 +75,7 @@ interface BrandConfig {
|
|
|
71
75
|
* Which platform versions this SDK works with, as a semver range:
|
|
72
76
|
* comparators separated by ", ". Keep this the only definition.
|
|
73
77
|
*/
|
|
74
|
-
declare const SUPPORTED_MEISTER = ">=0.6.
|
|
78
|
+
declare const SUPPORTED_MEISTER = ">=0.6.7, <0.7.0";
|
|
75
79
|
/** What `client.ready()` returns. */
|
|
76
80
|
interface ReadyInfo {
|
|
77
81
|
/** `true` when the platform reported a version inside `supportedMeister`. */
|
|
@@ -177,7 +181,7 @@ declare function isNetworkError(e: unknown): e is NetworkError;
|
|
|
177
181
|
* `define`. `src/version.test.ts` checks it matches `package.json`, so a
|
|
178
182
|
* release bump that forgets this file fails the test run.
|
|
179
183
|
*/
|
|
180
|
-
declare const SDK_VERSION = "0.6.
|
|
184
|
+
declare const SDK_VERSION = "0.6.2";
|
|
181
185
|
|
|
182
186
|
/**
|
|
183
187
|
* `@takeal/cusfront-sdk` — typed client for the Takeal end-user API.
|
|
@@ -273,6 +277,10 @@ interface CusfrontClient {
|
|
|
273
277
|
readonly attribution: AttributionResource;
|
|
274
278
|
/** Everything that happened to the user's money in one list, or one card's part of it. */
|
|
275
279
|
readonly history: HistoryResource;
|
|
280
|
+
/** What the user agreed to; give or withdraw the optional consents. */
|
|
281
|
+
readonly consents: ConsentsResource;
|
|
282
|
+
/** A numbered receipt for every payment. */
|
|
283
|
+
readonly receipts: ReceiptsResource;
|
|
276
284
|
/** Direct access to the token store (e.g. for an explicit sign-out
|
|
277
285
|
* on Capacitor's lifecycle "app pausing" event). */
|
|
278
286
|
readonly tokens: TokenStore;
|
|
@@ -303,4 +311,4 @@ interface CusfrontClient {
|
|
|
303
311
|
*/
|
|
304
312
|
declare function createClient(opts: CreateClientOptions): CusfrontClient;
|
|
305
313
|
|
|
306
|
-
export { ApiError, type BrandConfig, ClientDescriptor, type CreateClientOptions, type CusfrontClient, MeResource, NetworkError, type ReadyBody, type ReadyInfo, ResolvedClientDescriptor, SDK_VERSION, SUPPORTED_MEISTER, TokenStore, createClient, isApiError, isNetworkError, resolveAssetUrl, satisfies };
|
|
314
|
+
export { ApiError, type BrandConfig, ClientDescriptor, ConsentsResource, type CreateClientOptions, type CusfrontClient, MeResource, NetworkError, type ReadyBody, type ReadyInfo, ReceiptsResource, ResolvedClientDescriptor, SDK_VERSION, SUPPORTED_MEISTER, TokenStore, createClient, isApiError, isNetworkError, resolveAssetUrl, satisfies };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { T as TokenStore, F as FetchLike } from './http-DeANAoTs.js';
|
|
2
2
|
export { d as defaultBrowserStore, i as inMemoryStore } from './http-DeANAoTs.js';
|
|
3
3
|
import { AuthResource } from './resources/auth.js';
|
|
4
|
-
export { ChangePasswordInput, ExchangeTelegramInput, JwtIssued, LinkTelegramInput, LoginInput, LoginResponse, OtpSentResponse, RegisterInput, Session, TelegramLink, TelegramUnknown, TotpRequired, TotpSetupComplete, TotpSetupRequired, User } from './resources/auth.js';
|
|
5
|
-
import { a as DepositsResource, F as FundingOptionsResource } from './deposits-
|
|
6
|
-
export { C as CardLoadStatus, b as CreateDepositRefundInput, c as CreateQuoteInput, D as Deposit, d as DepositMethod, e as DepositStatus, f as DepositTarget, g as FeeKind, h as FunderMode, i as FundingOption, j as FundingQuote, I as InitiateDepositInput, k as IssueCardInput, M as MethodTerms, R as Refund } from './deposits-
|
|
7
|
-
import { b as CardsResource } from './cards-
|
|
8
|
-
export { A as Address, B as BillingAddress, a as Card, c as CardBalance, d as CardDesignRef, e as CardForm, C as CardProduct, f as CardProductPrice, g as CardStatus, h as CardStatusSource, i as CardTopUp, j as CardTopUpStatus, k as CardTransfer, l as CardType, m as Cardholder, n as CloseBlockedReason, o as CreateCardInput, p as CustomerInfo, I as IssuanceBonus, R as RevealCardInput, q as RevealedCard, S as SetPinInput, T as TopUpInput, r as TopUpResult, s as TopUpTerms, t as TransferInput, u as TransferResult, U as UpdateCardInput } from './cards-
|
|
4
|
+
export { ChangePasswordInput, EmailChangeRequested, ExchangeTelegramInput, JwtIssued, LinkTelegramInput, LoginInput, LoginResponse, OtpSentResponse, RegisterInput, Session, TelegramLink, TelegramUnknown, TotpRequired, TotpSetupComplete, TotpSetupRequired, User } from './resources/auth.js';
|
|
5
|
+
import { a as DepositsResource, F as FundingOptionsResource } from './deposits-Dt6A76MB.js';
|
|
6
|
+
export { C as CardLoadStatus, b as CreateDepositRefundInput, c as CreateQuoteInput, D as Deposit, d as DepositMethod, e as DepositStatus, f as DepositTarget, g as FeeKind, h as FunderMode, i as FundingOption, j as FundingQuote, I as InitiateDepositInput, k as IssueCardInput, M as MethodTerms, R as Refund } from './deposits-Dt6A76MB.js';
|
|
7
|
+
import { b as CardsResource } from './cards-DzhPVA9N.js';
|
|
8
|
+
export { A as Address, B as BillingAddress, a as Card, c as CardBalance, d as CardDesignRef, e as CardForm, C as CardProduct, f as CardProductPrice, g as CardStatus, h as CardStatusSource, i as CardTopUp, j as CardTopUpStatus, k as CardTransfer, l as CardType, m as Cardholder, n as CloseBlockedReason, o as CreateCardInput, p as CustomerInfo, I as IssuanceBonus, R as RevealCardInput, q as RevealedCard, S as SetPinInput, T as TopUpInput, r as TopUpResult, s as TopUpTerms, t as TransferInput, u as TransferResult, U as UpdateCardInput } from './cards-DzhPVA9N.js';
|
|
9
9
|
import { BalanceResource } from './resources/balance.js';
|
|
10
10
|
export { Balance } from './resources/balance.js';
|
|
11
11
|
import { BonusResource } from './resources/bonus.js';
|
|
@@ -39,6 +39,10 @@ import { AttributionResource } from './resources/attribution.js';
|
|
|
39
39
|
export { AnonymousKeyOptions, AttributionStatus, SignupAttribution, SurveyAnswer, TouchFields, TouchInput, TouchResult, anonymousKey, currentTouch } from './resources/attribution.js';
|
|
40
40
|
import { HistoryResource } from './resources/history.js';
|
|
41
41
|
export { HistoryAmount, HistoryCard, HistoryItem, HistoryKind, HistoryPage, HistoryStatus, ListHistoryParams } from './resources/history.js';
|
|
42
|
+
import { ConsentsResource } from './resources/consents.js';
|
|
43
|
+
export { ConsentChannel, ConsentDocument, ConsentKind, ConsentState, Consents, CookieChoiceInput } from './resources/consents.js';
|
|
44
|
+
import { ReceiptsResource } from './resources/receipts.js';
|
|
45
|
+
export { ListReceiptsParams, Receipt, ReceiptKind } from './resources/receipts.js';
|
|
42
46
|
export { ANALYTICS_EVENTS, AnalyticsEvent, AnalyticsOptions, AnalyticsProperties, AnalyticsZone, METRIKA_GOALS, MetrikaOptions, NO_CAPTURE_CLASS, PostHogLike, PostHogOptions, identify, initAnalytics, page, posthogDistinctId, resetAnalytics, sanitizeProperties, sanitizeUrl, setAnalyticsZone, track } from './analytics.js';
|
|
43
47
|
|
|
44
48
|
/**
|
|
@@ -71,7 +75,7 @@ interface BrandConfig {
|
|
|
71
75
|
* Which platform versions this SDK works with, as a semver range:
|
|
72
76
|
* comparators separated by ", ". Keep this the only definition.
|
|
73
77
|
*/
|
|
74
|
-
declare const SUPPORTED_MEISTER = ">=0.6.
|
|
78
|
+
declare const SUPPORTED_MEISTER = ">=0.6.7, <0.7.0";
|
|
75
79
|
/** What `client.ready()` returns. */
|
|
76
80
|
interface ReadyInfo {
|
|
77
81
|
/** `true` when the platform reported a version inside `supportedMeister`. */
|
|
@@ -177,7 +181,7 @@ declare function isNetworkError(e: unknown): e is NetworkError;
|
|
|
177
181
|
* `define`. `src/version.test.ts` checks it matches `package.json`, so a
|
|
178
182
|
* release bump that forgets this file fails the test run.
|
|
179
183
|
*/
|
|
180
|
-
declare const SDK_VERSION = "0.6.
|
|
184
|
+
declare const SDK_VERSION = "0.6.2";
|
|
181
185
|
|
|
182
186
|
/**
|
|
183
187
|
* `@takeal/cusfront-sdk` — typed client for the Takeal end-user API.
|
|
@@ -273,6 +277,10 @@ interface CusfrontClient {
|
|
|
273
277
|
readonly attribution: AttributionResource;
|
|
274
278
|
/** Everything that happened to the user's money in one list, or one card's part of it. */
|
|
275
279
|
readonly history: HistoryResource;
|
|
280
|
+
/** What the user agreed to; give or withdraw the optional consents. */
|
|
281
|
+
readonly consents: ConsentsResource;
|
|
282
|
+
/** A numbered receipt for every payment. */
|
|
283
|
+
readonly receipts: ReceiptsResource;
|
|
276
284
|
/** Direct access to the token store (e.g. for an explicit sign-out
|
|
277
285
|
* on Capacitor's lifecycle "app pausing" event). */
|
|
278
286
|
readonly tokens: TokenStore;
|
|
@@ -303,4 +311,4 @@ interface CusfrontClient {
|
|
|
303
311
|
*/
|
|
304
312
|
declare function createClient(opts: CreateClientOptions): CusfrontClient;
|
|
305
313
|
|
|
306
|
-
export { ApiError, type BrandConfig, ClientDescriptor, type CreateClientOptions, type CusfrontClient, MeResource, NetworkError, type ReadyBody, type ReadyInfo, ResolvedClientDescriptor, SDK_VERSION, SUPPORTED_MEISTER, TokenStore, createClient, isApiError, isNetworkError, resolveAssetUrl, satisfies };
|
|
314
|
+
export { ApiError, type BrandConfig, ClientDescriptor, ConsentsResource, type CreateClientOptions, type CusfrontClient, MeResource, NetworkError, type ReadyBody, type ReadyInfo, ReceiptsResource, ResolvedClientDescriptor, SDK_VERSION, SUPPORTED_MEISTER, TokenStore, createClient, isApiError, isNetworkError, resolveAssetUrl, satisfies };
|
package/dist/index.js
CHANGED
|
@@ -230,7 +230,8 @@ var AuthResource = class {
|
|
|
230
230
|
* `wallet_currency` must be one the deployment offers; omit it to take
|
|
231
231
|
* the deployment default (it can be switched later via `client.wallet`
|
|
232
232
|
* while the wallet is empty).
|
|
233
|
-
* Errors: 400 `validation` / `currency_not_allowed
|
|
233
|
+
* Errors: 400 `validation` / `currency_not_allowed` / `consents_required`
|
|
234
|
+
* / `unknown_consent`, 409 email taken. */
|
|
234
235
|
async register(input) {
|
|
235
236
|
const resp = await this.http.post("/auth/register", {
|
|
236
237
|
body: withRemember(input),
|
|
@@ -275,6 +276,8 @@ var AuthResource = class {
|
|
|
275
276
|
if (input.provision !== void 0) body.provision = input.provision;
|
|
276
277
|
if (input.attribution !== void 0) body.attribution = input.attribution;
|
|
277
278
|
if (input.code !== void 0) body.code = input.code;
|
|
279
|
+
if (input.consents !== void 0) body.consents = input.consents;
|
|
280
|
+
if (input.consentChannel !== void 0) body.consent_channel = input.consentChannel;
|
|
278
281
|
let resp;
|
|
279
282
|
try {
|
|
280
283
|
resp = await this.http.post("/auth/telegram/exchange", {
|
|
@@ -309,12 +312,30 @@ var AuthResource = class {
|
|
|
309
312
|
await Promise.resolve(this.tokens.set(resp.access_token));
|
|
310
313
|
return resp;
|
|
311
314
|
}
|
|
312
|
-
/** Attach
|
|
313
|
-
*
|
|
314
|
-
*
|
|
315
|
+
/** Attach the first real email to a Telegram-made account (and clear
|
|
316
|
+
* `email_pending`). 409 if taken. An account that already has a real
|
|
317
|
+
* address gets 409 `email_change_needs_code`: change it with
|
|
318
|
+
* {@link requestEmailChange} and {@link confirmEmailChange}. */
|
|
315
319
|
async linkEmail(input) {
|
|
316
320
|
return this.http.post("/me/email", { body: { email: input.email } });
|
|
317
321
|
}
|
|
322
|
+
/** Step one of an email change: a six-digit code goes to the new address
|
|
323
|
+
* and works for 5 minutes. Nothing changes yet.
|
|
324
|
+
* Errors: 400 `same_email`, 409 address taken, 429 `too_many_requests`
|
|
325
|
+
* (five codes an hour). */
|
|
326
|
+
async requestEmailChange(input) {
|
|
327
|
+
return this.http.post("/me/email/change", {
|
|
328
|
+
body: { email: input.email }
|
|
329
|
+
});
|
|
330
|
+
}
|
|
331
|
+
/** Step two: the code from the e-mail changes the address; the old one
|
|
332
|
+
* gets a notice. Errors: 401 `invalid_code` (after five wrong codes a new
|
|
333
|
+
* request is needed), 409 the address was taken meanwhile. */
|
|
334
|
+
async confirmEmailChange(input) {
|
|
335
|
+
return this.http.post("/me/email/change/confirm", {
|
|
336
|
+
body: { challenge_id: input.challengeId, code: input.code }
|
|
337
|
+
});
|
|
338
|
+
}
|
|
318
339
|
/** Current user — fails 401 when the stored JWT is expired or
|
|
319
340
|
* missing. Useful as a "do I have a session" probe on app boot. */
|
|
320
341
|
async me() {
|
|
@@ -346,6 +367,7 @@ function cardRequestBody(input) {
|
|
|
346
367
|
useBonus,
|
|
347
368
|
bonusAmount,
|
|
348
369
|
promoCode,
|
|
370
|
+
consentChannel,
|
|
349
371
|
initial_amount: _ignored,
|
|
350
372
|
...rest
|
|
351
373
|
} = input;
|
|
@@ -356,6 +378,7 @@ function cardRequestBody(input) {
|
|
|
356
378
|
if (useBonus !== void 0) body["use_bonus"] = useBonus;
|
|
357
379
|
if (bonusAmount !== void 0) body["bonus_amount"] = bonusAmount;
|
|
358
380
|
if (promoCode !== void 0) body["promo_code"] = promoCode;
|
|
381
|
+
if (consentChannel !== void 0) body["consent_channel"] = consentChannel;
|
|
359
382
|
return body;
|
|
360
383
|
}
|
|
361
384
|
var CardsResource = class {
|
|
@@ -1160,6 +1183,69 @@ var HistoryResource = class {
|
|
|
1160
1183
|
}
|
|
1161
1184
|
};
|
|
1162
1185
|
|
|
1186
|
+
// src/resources/consents.ts
|
|
1187
|
+
var ConsentsResource = class {
|
|
1188
|
+
constructor(http) {
|
|
1189
|
+
this.http = http;
|
|
1190
|
+
}
|
|
1191
|
+
/** Where each consent stands. */
|
|
1192
|
+
async get() {
|
|
1193
|
+
return this.http.get("/me/consents");
|
|
1194
|
+
}
|
|
1195
|
+
/**
|
|
1196
|
+
* Give (`true`) or withdraw (`false`) an optional consent: `marketing` or
|
|
1197
|
+
* `cookies_analytics`. Withdrawing `marketing` turns advertising off in
|
|
1198
|
+
* every channel at once; giving it turns on advertising by e-mail. A call
|
|
1199
|
+
* that changes nothing records nothing.
|
|
1200
|
+
*
|
|
1201
|
+
* Errors: 400 `consent_required` for `terms` or `personal_data`,
|
|
1202
|
+
* 400 `unknown_consent`.
|
|
1203
|
+
*/
|
|
1204
|
+
async set(kind, given, channel) {
|
|
1205
|
+
const body = { kind, given };
|
|
1206
|
+
if (channel !== void 0) body.channel = channel;
|
|
1207
|
+
return this.http.post("/me/consents", { body });
|
|
1208
|
+
}
|
|
1209
|
+
/**
|
|
1210
|
+
* Record what the cookie banner or the cookie settings say about
|
|
1211
|
+
* analytics. Works signed in or not: before sign-in the choice is kept
|
|
1212
|
+
* under the anonymous key and moves to the account at sign-up (send the
|
|
1213
|
+
* same key in `register({ attribution })`). Declining deletes the
|
|
1214
|
+
* visitor's recorded visits and analytics ids and stops their conversions
|
|
1215
|
+
* going to Metrica. Call it on every change, not on every page load; the
|
|
1216
|
+
* same answer twice records nothing (`recorded: false`).
|
|
1217
|
+
*
|
|
1218
|
+
* Errors: 400 `invalid_anonymous_key` when not signed in and no key could
|
|
1219
|
+
* be found.
|
|
1220
|
+
*/
|
|
1221
|
+
async setCookies(input) {
|
|
1222
|
+
const body = {
|
|
1223
|
+
analytics: input.analytics
|
|
1224
|
+
};
|
|
1225
|
+
const key = input.anonymousKey ?? anonymousKey();
|
|
1226
|
+
if (key !== void 0) body.anonymous_key = key;
|
|
1227
|
+
if (input.channel !== void 0) body.channel = input.channel;
|
|
1228
|
+
return this.http.post("/consents/cookies", { body });
|
|
1229
|
+
}
|
|
1230
|
+
};
|
|
1231
|
+
|
|
1232
|
+
// src/resources/receipts.ts
|
|
1233
|
+
var ReceiptsResource = class {
|
|
1234
|
+
constructor(http) {
|
|
1235
|
+
this.http = http;
|
|
1236
|
+
}
|
|
1237
|
+
async list(params = {}) {
|
|
1238
|
+
const q = new URLSearchParams();
|
|
1239
|
+
if (params.refId !== void 0) q.set("ref_id", params.refId);
|
|
1240
|
+
if (params.limit !== void 0) q.set("limit", String(params.limit));
|
|
1241
|
+
const qs = q.toString();
|
|
1242
|
+
return this.http.get(`/me/receipts${qs ? `?${qs}` : ""}`);
|
|
1243
|
+
}
|
|
1244
|
+
async get(id) {
|
|
1245
|
+
return this.http.get(`/me/receipts/${encodeURIComponent(id)}`);
|
|
1246
|
+
}
|
|
1247
|
+
};
|
|
1248
|
+
|
|
1163
1249
|
// src/resources/funding-options.ts
|
|
1164
1250
|
var FundingOptionsResource = class {
|
|
1165
1251
|
constructor(http) {
|
|
@@ -1172,7 +1258,7 @@ var FundingOptionsResource = class {
|
|
|
1172
1258
|
};
|
|
1173
1259
|
|
|
1174
1260
|
// src/version.ts
|
|
1175
|
-
var SDK_VERSION = "0.6.
|
|
1261
|
+
var SDK_VERSION = "0.6.2";
|
|
1176
1262
|
|
|
1177
1263
|
// src/client-platform.ts
|
|
1178
1264
|
var CLIENT_HEADER = "X-Takeal-Client";
|
|
@@ -1247,7 +1333,7 @@ function isAbsolute(url) {
|
|
|
1247
1333
|
}
|
|
1248
1334
|
|
|
1249
1335
|
// src/compat.ts
|
|
1250
|
-
var SUPPORTED_MEISTER = ">=0.6.
|
|
1336
|
+
var SUPPORTED_MEISTER = ">=0.6.7, <0.7.0";
|
|
1251
1337
|
var SEMVER = /^v?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/;
|
|
1252
1338
|
function parse(v) {
|
|
1253
1339
|
const m = SEMVER.exec(v.trim());
|
|
@@ -1774,7 +1860,9 @@ function createClient(opts) {
|
|
|
1774
1860
|
notifications: new NotificationsResource(http),
|
|
1775
1861
|
devices: new DevicesResource(http, client),
|
|
1776
1862
|
attribution: new AttributionResource(http),
|
|
1777
|
-
history: new HistoryResource(http)
|
|
1863
|
+
history: new HistoryResource(http),
|
|
1864
|
+
consents: new ConsentsResource(http),
|
|
1865
|
+
receipts: new ReceiptsResource(http)
|
|
1778
1866
|
};
|
|
1779
1867
|
}
|
|
1780
1868
|
function pickDefaultStore(key) {
|