@takeal/cusfront-sdk 0.6.8 → 0.6.14
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 +112 -2
- package/README.md +26 -9
- package/dist/analytics.cjs +44 -6
- package/dist/analytics.cjs.map +1 -1
- package/dist/analytics.js +44 -6
- package/dist/analytics.js.map +1 -1
- package/dist/{cards-BgY00UpU.d.ts → cards-DPlgx76p.d.ts} +86 -18
- package/dist/{cards-DGz4Rqu1.d.cts → cards-D_krTWzr.d.cts} +86 -18
- package/dist/index.cjs +225 -93
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +5 -5
- package/dist/index.d.ts +5 -5
- package/dist/index.js +221 -94
- package/dist/index.js.map +1 -1
- package/dist/react/index.d.cts +1 -1
- package/dist/react/index.d.ts +1 -1
- package/dist/resources/attribution.cjs +99 -4
- package/dist/resources/attribution.cjs.map +1 -1
- package/dist/resources/attribution.d.cts +58 -1
- package/dist/resources/attribution.d.ts +58 -1
- package/dist/resources/attribution.js +96 -5
- package/dist/resources/attribution.js.map +1 -1
- package/dist/resources/auth.cjs +64 -3
- package/dist/resources/auth.cjs.map +1 -1
- package/dist/resources/auth.d.cts +1 -1
- package/dist/resources/auth.d.ts +1 -1
- package/dist/resources/auth.js +64 -3
- package/dist/resources/auth.js.map +1 -1
- package/dist/resources/cards.cjs +69 -7
- 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 +69 -8
- package/dist/resources/cards.js.map +1 -1
- package/dist/resources/codes.cjs.map +1 -1
- package/dist/resources/codes.d.cts +21 -1
- package/dist/resources/codes.d.ts +21 -1
- package/dist/resources/codes.js.map +1 -1
- package/dist/resources/consents.cjs +15 -0
- package/dist/resources/consents.cjs.map +1 -1
- package/dist/resources/consents.js +15 -0
- package/dist/resources/consents.js.map +1 -1
- package/dist/resources/deposits.cjs +50 -0
- package/dist/resources/deposits.cjs.map +1 -1
- package/dist/resources/deposits.d.cts +2 -1
- package/dist/resources/deposits.d.ts +2 -1
- package/dist/resources/deposits.js +50 -0
- package/dist/resources/deposits.js.map +1 -1
- package/dist/resources/funding-options.d.cts +2 -1
- package/dist/resources/funding-options.d.ts +2 -1
- package/dist/resources/me.d.cts +1 -1
- package/dist/resources/me.d.ts +1 -1
- package/dist/telegram.cjs +224 -73
- package/dist/telegram.cjs.map +1 -1
- package/dist/telegram.d.cts +34 -3
- package/dist/telegram.d.ts +34 -3
- package/dist/telegram.js +224 -74
- package/dist/telegram.js.map +1 -1
- package/package.json +4 -4
package/dist/index.d.cts
CHANGED
|
@@ -2,8 +2,8 @@ import { T as TokenStore, F as FetchLike } from './http-CL97TjMO.cjs';
|
|
|
2
2
|
export { d as defaultBrowserStore, i as inMemoryStore } from './http-CL97TjMO.cjs';
|
|
3
3
|
import { AuthResource } from './resources/auth.cjs';
|
|
4
4
|
export { ChangePasswordInput, EmailChangeRequested, EmailCodeSent, EmailCodeSession, ExchangeTelegramInput, JwtIssued, LinkTelegramInput, LoginInput, LoginResponse, OtpSentResponse, RegisterInput, RequestEmailCodeInput, Session, TelegramLink, TelegramUnknown, TotpRequired, TotpSetupComplete, TotpSetupRequired, User, VerifyEmailCodeInput } from './resources/auth.cjs';
|
|
5
|
-
import { b as DepositsResource, F as FundingOptionsResource, c as CardsResource } from './cards-
|
|
6
|
-
export { A as Address, B as BillingAddress, a as Card, d as CardBalance, e as CardDesignRef, f as CardForm, g as CardInTransit, h as CardLoadStatus, i as CardOrder, j as CardOrderError, k as CardOrderInput, C as CardProduct, l as CardProductPrice, m as CardStatus, n as CardStatusSource, o as CardTariff, p as CardTopUp, q as CardTopUpStatus, r as CardTransfer, s as CardType, t as Cardholder, u as CloseBlockedReason, v as CreateCardInput, w as CreateDepositRefundInput, x as CreateQuoteInput, y as CustomerInfo, D as Deposit, z as DepositMethod, E as DepositStatus, G as DepositTarget, H as FeeKind, I as FunderMode, J as FundingOption, K as FundingQuote, L as InitiateDepositInput, M as IssuanceBonus, N as IssueCardInput, O as MethodTerms, R as Refund, P as RevealCardInput, Q as
|
|
5
|
+
import { b as DepositsResource, F as FundingOptionsResource, c as CardsResource } from './cards-D_krTWzr.cjs';
|
|
6
|
+
export { A as Address, B as BillingAddress, a as Card, d as CardBalance, e as CardDesignRef, f as CardForm, g as CardInTransit, h as CardLoadStatus, i as CardOrder, j as CardOrderError, k as CardOrderInput, C as CardProduct, l as CardProductPrice, m as CardStatus, n as CardStatusSource, o as CardTariff, p as CardTopUp, q as CardTopUpStatus, r as CardTransfer, s as CardType, t as Cardholder, u as CloseBlockedReason, v as CreateCardInput, w as CreateDepositRefundInput, x as CreateQuoteInput, y as CustomerInfo, D as Deposit, z as DepositMethod, E as DepositStatus, G as DepositTarget, H as FeeKind, I as FunderMode, J as FundingOption, K as FundingQuote, L as InitiateDepositInput, M as IssuanceBonus, N as IssueCardInput, O as MethodTerms, R as Refund, P as RevealCardInput, Q as RevealState, S as RevealedCard, T as SetPinInput, U as TopUpInput, V as TopUpResult, W as TopUpTerms, X as TransferInput, Y as TransferResult, Z as UpdateCardInput, _ as revealState } from './cards-D_krTWzr.cjs';
|
|
7
7
|
import { BalanceResource } from './resources/balance.cjs';
|
|
8
8
|
export { Balance } from './resources/balance.cjs';
|
|
9
9
|
import { BonusResource } from './resources/bonus.cjs';
|
|
@@ -40,7 +40,7 @@ export { CardOtpData, InboxItem, ListNotificationsParams, NotificationCategory,
|
|
|
40
40
|
import { C as ClientDescriptor, R as ResolvedClientDescriptor, D as DevicesResource } from './devices-CiJrlXum.cjs';
|
|
41
41
|
export { a as CLIENT_HEADER, b as ClientPlatform, c as Device, d as DeviceKind, e as DevicePlatform, M as MobilePushCredential, f as RegisterDeviceInput, g as RegisterWebPushOptions, h as RegisteredDevice, U as UnregisterWebPushOptions, W as WebPushCredential, i as detectClientPlatform } from './devices-CiJrlXum.cjs';
|
|
42
42
|
import { AttributionResource } from './resources/attribution.cjs';
|
|
43
|
-
export { AnonymousKeyOptions, AttributionStatus, SignupAttribution, SurveyAnswer, TouchFields, TouchInput, TouchResult, anonymousKey, currentTouch } from './resources/attribution.cjs';
|
|
43
|
+
export { AnalyticsIds, AnonymousKeyOptions, AttributionStatus, HandoffToken, SignupAttribution, SurveyAnswer, TouchFields, TouchInput, TouchResult, analyticsIds, anonymousKey, currentTouch, forgetAnalyticsIds, rememberAnalyticsIds, withAnalyticsIds } from './resources/attribution.cjs';
|
|
44
44
|
import { HistoryResource } from './resources/history.cjs';
|
|
45
45
|
export { HistoryAmount, HistoryCard, HistoryItem, HistoryKind, HistoryPage, HistoryStatus, ListHistoryParams } from './resources/history.cjs';
|
|
46
46
|
import { ConsentsResource } from './resources/consents.cjs';
|
|
@@ -81,7 +81,7 @@ interface BrandConfig {
|
|
|
81
81
|
* Which platform versions this SDK works with, as a semver range:
|
|
82
82
|
* comparators separated by ", ". Keep this the only definition.
|
|
83
83
|
*/
|
|
84
|
-
declare const SUPPORTED_MEISTER = ">=0.6
|
|
84
|
+
declare const SUPPORTED_MEISTER = ">=0.7.6, <1.0.0";
|
|
85
85
|
/** What `client.ready()` returns. */
|
|
86
86
|
interface ReadyInfo {
|
|
87
87
|
/** `true` when the platform reported a version inside `supportedMeister`. */
|
|
@@ -187,7 +187,7 @@ declare function isNetworkError(e: unknown): e is NetworkError;
|
|
|
187
187
|
* `define`. `src/version.test.ts` checks it matches `package.json`, so a
|
|
188
188
|
* release bump that forgets this file fails the test run.
|
|
189
189
|
*/
|
|
190
|
-
declare const SDK_VERSION = "0.6.
|
|
190
|
+
declare const SDK_VERSION = "0.6.14";
|
|
191
191
|
|
|
192
192
|
/**
|
|
193
193
|
* `@takeal/cusfront-sdk` — typed client for the Takeal end-user API.
|
package/dist/index.d.ts
CHANGED
|
@@ -2,8 +2,8 @@ import { T as TokenStore, F as FetchLike } from './http-CL97TjMO.js';
|
|
|
2
2
|
export { d as defaultBrowserStore, i as inMemoryStore } from './http-CL97TjMO.js';
|
|
3
3
|
import { AuthResource } from './resources/auth.js';
|
|
4
4
|
export { ChangePasswordInput, EmailChangeRequested, EmailCodeSent, EmailCodeSession, ExchangeTelegramInput, JwtIssued, LinkTelegramInput, LoginInput, LoginResponse, OtpSentResponse, RegisterInput, RequestEmailCodeInput, Session, TelegramLink, TelegramUnknown, TotpRequired, TotpSetupComplete, TotpSetupRequired, User, VerifyEmailCodeInput } from './resources/auth.js';
|
|
5
|
-
import { b as DepositsResource, F as FundingOptionsResource, c as CardsResource } from './cards-
|
|
6
|
-
export { A as Address, B as BillingAddress, a as Card, d as CardBalance, e as CardDesignRef, f as CardForm, g as CardInTransit, h as CardLoadStatus, i as CardOrder, j as CardOrderError, k as CardOrderInput, C as CardProduct, l as CardProductPrice, m as CardStatus, n as CardStatusSource, o as CardTariff, p as CardTopUp, q as CardTopUpStatus, r as CardTransfer, s as CardType, t as Cardholder, u as CloseBlockedReason, v as CreateCardInput, w as CreateDepositRefundInput, x as CreateQuoteInput, y as CustomerInfo, D as Deposit, z as DepositMethod, E as DepositStatus, G as DepositTarget, H as FeeKind, I as FunderMode, J as FundingOption, K as FundingQuote, L as InitiateDepositInput, M as IssuanceBonus, N as IssueCardInput, O as MethodTerms, R as Refund, P as RevealCardInput, Q as
|
|
5
|
+
import { b as DepositsResource, F as FundingOptionsResource, c as CardsResource } from './cards-DPlgx76p.js';
|
|
6
|
+
export { A as Address, B as BillingAddress, a as Card, d as CardBalance, e as CardDesignRef, f as CardForm, g as CardInTransit, h as CardLoadStatus, i as CardOrder, j as CardOrderError, k as CardOrderInput, C as CardProduct, l as CardProductPrice, m as CardStatus, n as CardStatusSource, o as CardTariff, p as CardTopUp, q as CardTopUpStatus, r as CardTransfer, s as CardType, t as Cardholder, u as CloseBlockedReason, v as CreateCardInput, w as CreateDepositRefundInput, x as CreateQuoteInput, y as CustomerInfo, D as Deposit, z as DepositMethod, E as DepositStatus, G as DepositTarget, H as FeeKind, I as FunderMode, J as FundingOption, K as FundingQuote, L as InitiateDepositInput, M as IssuanceBonus, N as IssueCardInput, O as MethodTerms, R as Refund, P as RevealCardInput, Q as RevealState, S as RevealedCard, T as SetPinInput, U as TopUpInput, V as TopUpResult, W as TopUpTerms, X as TransferInput, Y as TransferResult, Z as UpdateCardInput, _ as revealState } from './cards-DPlgx76p.js';
|
|
7
7
|
import { BalanceResource } from './resources/balance.js';
|
|
8
8
|
export { Balance } from './resources/balance.js';
|
|
9
9
|
import { BonusResource } from './resources/bonus.js';
|
|
@@ -40,7 +40,7 @@ export { CardOtpData, InboxItem, ListNotificationsParams, NotificationCategory,
|
|
|
40
40
|
import { C as ClientDescriptor, R as ResolvedClientDescriptor, D as DevicesResource } from './devices-C88c38hm.js';
|
|
41
41
|
export { a as CLIENT_HEADER, b as ClientPlatform, c as Device, d as DeviceKind, e as DevicePlatform, M as MobilePushCredential, f as RegisterDeviceInput, g as RegisterWebPushOptions, h as RegisteredDevice, U as UnregisterWebPushOptions, W as WebPushCredential, i as detectClientPlatform } from './devices-C88c38hm.js';
|
|
42
42
|
import { AttributionResource } from './resources/attribution.js';
|
|
43
|
-
export { AnonymousKeyOptions, AttributionStatus, SignupAttribution, SurveyAnswer, TouchFields, TouchInput, TouchResult, anonymousKey, currentTouch } from './resources/attribution.js';
|
|
43
|
+
export { AnalyticsIds, AnonymousKeyOptions, AttributionStatus, HandoffToken, SignupAttribution, SurveyAnswer, TouchFields, TouchInput, TouchResult, analyticsIds, anonymousKey, currentTouch, forgetAnalyticsIds, rememberAnalyticsIds, withAnalyticsIds } from './resources/attribution.js';
|
|
44
44
|
import { HistoryResource } from './resources/history.js';
|
|
45
45
|
export { HistoryAmount, HistoryCard, HistoryItem, HistoryKind, HistoryPage, HistoryStatus, ListHistoryParams } from './resources/history.js';
|
|
46
46
|
import { ConsentsResource } from './resources/consents.js';
|
|
@@ -81,7 +81,7 @@ interface BrandConfig {
|
|
|
81
81
|
* Which platform versions this SDK works with, as a semver range:
|
|
82
82
|
* comparators separated by ", ". Keep this the only definition.
|
|
83
83
|
*/
|
|
84
|
-
declare const SUPPORTED_MEISTER = ">=0.6
|
|
84
|
+
declare const SUPPORTED_MEISTER = ">=0.7.6, <1.0.0";
|
|
85
85
|
/** What `client.ready()` returns. */
|
|
86
86
|
interface ReadyInfo {
|
|
87
87
|
/** `true` when the platform reported a version inside `supportedMeister`. */
|
|
@@ -187,7 +187,7 @@ declare function isNetworkError(e: unknown): e is NetworkError;
|
|
|
187
187
|
* `define`. `src/version.test.ts` checks it matches `package.json`, so a
|
|
188
188
|
* release bump that forgets this file fails the test run.
|
|
189
189
|
*/
|
|
190
|
-
declare const SDK_VERSION = "0.6.
|
|
190
|
+
declare const SDK_VERSION = "0.6.14";
|
|
191
191
|
|
|
192
192
|
/**
|
|
193
193
|
* `@takeal/cusfront-sdk` — typed client for the Takeal end-user API.
|
package/dist/index.js
CHANGED
|
@@ -145,6 +145,172 @@ async function parseResponse(resp) {
|
|
|
145
145
|
return body;
|
|
146
146
|
}
|
|
147
147
|
|
|
148
|
+
// src/resources/attribution.ts
|
|
149
|
+
var AttributionResource = class {
|
|
150
|
+
constructor(http) {
|
|
151
|
+
this.http = http;
|
|
152
|
+
}
|
|
153
|
+
/** Record a visit. No session needed; safe to call on every page load. */
|
|
154
|
+
async touch(input) {
|
|
155
|
+
return this.http.post("/attribution/touches", { body: input, skipAuth: true });
|
|
156
|
+
}
|
|
157
|
+
/** A one-day token that carries the visitor's analytics ids into the
|
|
158
|
+
* Telegram Mini App, whose sign-in reads it back. Most callers want
|
|
159
|
+
* {@link AttributionResource.telegramStartParam}. Errors: 400 when none of
|
|
160
|
+
* the ids is valid. */
|
|
161
|
+
async handoff(ids) {
|
|
162
|
+
return this.http.post("/attribution/handoff", { body: ids, skipAuth: true });
|
|
163
|
+
}
|
|
164
|
+
/**
|
|
165
|
+
* The `startapp` value for a link from the site to the Mini App: the code
|
|
166
|
+
* as it is, followed by `__<token>` when the visitor has analytics ids, so
|
|
167
|
+
* a payment made in Telegram is still credited to the visit it came from.
|
|
168
|
+
* Without ids, or when the token can't be had, just the code.
|
|
169
|
+
*
|
|
170
|
+
* ```ts
|
|
171
|
+
* const start = await client.attribution.telegramStartParam("SPRING");
|
|
172
|
+
* location.href = `https://t.me/our_bot/app?startapp=${start}`;
|
|
173
|
+
* ```
|
|
174
|
+
*/
|
|
175
|
+
async telegramStartParam(code = "") {
|
|
176
|
+
const ids = analyticsIds();
|
|
177
|
+
if (!ids) return code;
|
|
178
|
+
try {
|
|
179
|
+
const { token } = await this.handoff(ids);
|
|
180
|
+
return `${code}__${token}`;
|
|
181
|
+
} catch {
|
|
182
|
+
return code;
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
/** Send the visitor's analytics ids for the signed-in account, e.g. right
|
|
186
|
+
* after they agreed to analytics cookies in the cabinet. Without an
|
|
187
|
+
* argument the ids this browser holds are sent; nothing is sent when it
|
|
188
|
+
* holds none. */
|
|
189
|
+
async sendAnalyticsIds(ids = analyticsIds()) {
|
|
190
|
+
if (!ids) return;
|
|
191
|
+
await this.http.post("/me/analytics/ids", { body: ids });
|
|
192
|
+
}
|
|
193
|
+
/** Whether to ask the signed-in user how they heard about us. */
|
|
194
|
+
async status() {
|
|
195
|
+
return this.http.get("/me/attribution");
|
|
196
|
+
}
|
|
197
|
+
/** Answer the question once. Send `"skipped"` when the user closes it.
|
|
198
|
+
* `otherText` is kept only with `"other"`, up to 500 characters.
|
|
199
|
+
* Errors: 400 `validation`, 409 `survey_answered`. */
|
|
200
|
+
async answerSurvey(answer, otherText) {
|
|
201
|
+
const body = { answer };
|
|
202
|
+
if (otherText !== void 0) body.other_text = otherText;
|
|
203
|
+
return this.http.put("/me/attribution/survey", { body });
|
|
204
|
+
}
|
|
205
|
+
};
|
|
206
|
+
function tgWebApp() {
|
|
207
|
+
return globalThis.Telegram?.WebApp?.initDataUnsafe;
|
|
208
|
+
}
|
|
209
|
+
function readCookie(name) {
|
|
210
|
+
const doc = globalThis.document;
|
|
211
|
+
if (!doc?.cookie) return void 0;
|
|
212
|
+
for (const part of doc.cookie.split(";")) {
|
|
213
|
+
const [k, ...v] = part.trim().split("=");
|
|
214
|
+
if (k === name) return decodeURIComponent(v.join("="));
|
|
215
|
+
}
|
|
216
|
+
return void 0;
|
|
217
|
+
}
|
|
218
|
+
var KEY_SHAPE = /^[A-Za-z0-9_-]{8,64}$/;
|
|
219
|
+
function anonymousKey(opts = {}) {
|
|
220
|
+
const tgId = tgWebApp()?.user?.id;
|
|
221
|
+
if (tgId) return `tg:${tgId}`;
|
|
222
|
+
const g = globalThis;
|
|
223
|
+
if (!g.document) return void 0;
|
|
224
|
+
const name = opts.name ?? "takeal_anon";
|
|
225
|
+
let stored2;
|
|
226
|
+
try {
|
|
227
|
+
stored2 = g.localStorage?.getItem(name) ?? void 0;
|
|
228
|
+
} catch {
|
|
229
|
+
stored2 = void 0;
|
|
230
|
+
}
|
|
231
|
+
const fromCookie = readCookie(name);
|
|
232
|
+
let key = [fromCookie, stored2].find((k) => !!k && KEY_SHAPE.test(k));
|
|
233
|
+
if (!key) {
|
|
234
|
+
key = g.crypto?.randomUUID?.() ?? `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 14)}`;
|
|
235
|
+
}
|
|
236
|
+
try {
|
|
237
|
+
g.localStorage?.setItem(name, key);
|
|
238
|
+
} catch {
|
|
239
|
+
}
|
|
240
|
+
const domain = opts.cookieDomain ? `; domain=${opts.cookieDomain}` : "";
|
|
241
|
+
g.document.cookie = `${name}=${encodeURIComponent(key)}; max-age=31536000; path=/; SameSite=Lax${domain}`;
|
|
242
|
+
return key;
|
|
243
|
+
}
|
|
244
|
+
function currentTouch() {
|
|
245
|
+
const g = globalThis;
|
|
246
|
+
const tg = tgWebApp();
|
|
247
|
+
const out = {};
|
|
248
|
+
if (g.location?.href) out.url = g.location.href;
|
|
249
|
+
if (g.document?.referrer) out.referrer = g.document.referrer;
|
|
250
|
+
if (tg?.start_param) out.campaign_code = tg.start_param;
|
|
251
|
+
if (tg?.user?.id) out.platform = "miniapp";
|
|
252
|
+
const ym = readCookie("_ym_uid");
|
|
253
|
+
if (ym) out.metrika_client_id = ym;
|
|
254
|
+
const ga = readCookie("_ga")?.split(".").slice(-2).join(".");
|
|
255
|
+
if (ga) out.ga_client_id = ga;
|
|
256
|
+
return out;
|
|
257
|
+
}
|
|
258
|
+
var IDS_KEY = "takeal_analytics_ids";
|
|
259
|
+
function storage() {
|
|
260
|
+
try {
|
|
261
|
+
return globalThis.localStorage;
|
|
262
|
+
} catch {
|
|
263
|
+
return void 0;
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
function stored() {
|
|
267
|
+
try {
|
|
268
|
+
const raw = storage()?.getItem(IDS_KEY);
|
|
269
|
+
const v = raw ? JSON.parse(raw) : {};
|
|
270
|
+
return typeof v === "object" && v !== null ? v : {};
|
|
271
|
+
} catch {
|
|
272
|
+
return {};
|
|
273
|
+
}
|
|
274
|
+
}
|
|
275
|
+
function clean(ids) {
|
|
276
|
+
const out = {};
|
|
277
|
+
const ym = ids.metrika_client_id?.trim();
|
|
278
|
+
if (ym && /^\d{1,32}$/.test(ym)) out.metrika_client_id = ym;
|
|
279
|
+
const ga = ids.ga_client_id?.trim();
|
|
280
|
+
if (ga && /^\d+\.\d+$/.test(ga) && ga.length <= 64) out.ga_client_id = ga;
|
|
281
|
+
return out.metrika_client_id || out.ga_client_id ? out : void 0;
|
|
282
|
+
}
|
|
283
|
+
function rememberAnalyticsIds(ids) {
|
|
284
|
+
const merged = clean({ ...stored(), ...ids });
|
|
285
|
+
if (!merged) return;
|
|
286
|
+
try {
|
|
287
|
+
storage()?.setItem(IDS_KEY, JSON.stringify(merged));
|
|
288
|
+
} catch {
|
|
289
|
+
}
|
|
290
|
+
}
|
|
291
|
+
function forgetAnalyticsIds() {
|
|
292
|
+
try {
|
|
293
|
+
storage()?.removeItem(IDS_KEY);
|
|
294
|
+
} catch {
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
function analyticsIds() {
|
|
298
|
+
const kept = stored();
|
|
299
|
+
return clean({
|
|
300
|
+
metrika_client_id: kept.metrika_client_id ?? readCookie("_ym_uid"),
|
|
301
|
+
ga_client_id: kept.ga_client_id ?? readCookie("_ga")?.split(".").slice(-2).join(".")
|
|
302
|
+
});
|
|
303
|
+
}
|
|
304
|
+
function withAnalyticsIds(attribution) {
|
|
305
|
+
const ids = analyticsIds();
|
|
306
|
+
if (!ids) return attribution;
|
|
307
|
+
return {
|
|
308
|
+
...attribution,
|
|
309
|
+
metrika_client_id: attribution?.metrika_client_id ?? ids.metrika_client_id,
|
|
310
|
+
ga_client_id: attribution?.ga_client_id ?? ids.ga_client_id
|
|
311
|
+
};
|
|
312
|
+
}
|
|
313
|
+
|
|
148
314
|
// src/resources/cards.ts
|
|
149
315
|
function cardRequestBody(input) {
|
|
150
316
|
const {
|
|
@@ -183,8 +349,15 @@ function cardOrderBody(input) {
|
|
|
183
349
|
if (input.consents !== void 0) body["consents"] = input.consents;
|
|
184
350
|
if (input.consentChannel !== void 0) body["consent_channel"] = input.consentChannel;
|
|
185
351
|
if (input.metadata !== void 0) body["metadata"] = input.metadata;
|
|
352
|
+
const ids = input.analyticsIds ?? analyticsIds();
|
|
353
|
+
if (ids !== void 0) body["analytics_ids"] = ids;
|
|
186
354
|
return body;
|
|
187
355
|
}
|
|
356
|
+
function revealState(r) {
|
|
357
|
+
if (r.details_pending) return "pending";
|
|
358
|
+
if (r.reveal_url) return "page";
|
|
359
|
+
return "numbers";
|
|
360
|
+
}
|
|
188
361
|
var CardsResource = class {
|
|
189
362
|
constructor(http) {
|
|
190
363
|
this.http = http;
|
|
@@ -212,8 +385,10 @@ var CardsResource = class {
|
|
|
212
385
|
* `idempotencyKey` returns the same order.
|
|
213
386
|
* Errors: 400 `unknown_product` / `method_not_available` / a limit of the
|
|
214
387
|
* way of paying, 409 `holder_data_consent_required` (the product has
|
|
215
|
-
* `holder_data_required` and the user has not agreed to it),
|
|
216
|
-
*
|
|
388
|
+
* `holder_data_required` and the user has not agreed to it), 409
|
|
389
|
+
* `payments_on_hold` (a payment on this account was not accepted and new
|
|
390
|
+
* ones wait until support sorts it out: show the message and point the
|
|
391
|
+
* user to support), 503 no funding connector or no exchange rate.
|
|
217
392
|
*/
|
|
218
393
|
async order(input) {
|
|
219
394
|
const { idempotencyKey, ...order } = input;
|
|
@@ -227,7 +402,9 @@ var CardsResource = class {
|
|
|
227
402
|
* (`is_default` marks the one issued when none is chosen). Each item
|
|
228
403
|
* carries its product card (name, tagline, benefits, tile picture),
|
|
229
404
|
* artwork, and the issuance price after the caller's subscription
|
|
230
|
-
* discount, in the
|
|
405
|
+
* discount, in the currency the operator set it in (`price.from_wallet`
|
|
406
|
+
* is the same price from the wallet, when that holds another currency).
|
|
407
|
+
* Pass an item's `id` as
|
|
231
408
|
* `productId` to {@link create}.
|
|
232
409
|
*/
|
|
233
410
|
async listProducts() {
|
|
@@ -340,15 +517,22 @@ var CardsResource = class {
|
|
|
340
517
|
* keep the result in volatile memory only, never write it to
|
|
341
518
|
* localStorage / logs, and clear it within `expires_in_seconds`.
|
|
342
519
|
*
|
|
343
|
-
*
|
|
344
|
-
* when the issuer shows them on a
|
|
345
|
-
* frame right away, it is
|
|
520
|
+
* `state` tells the three answers apart: `numbers`; `page`, with
|
|
521
|
+
* `reveal_url` and empty `pan` and `cvv` when the issuer shows them on a
|
|
522
|
+
* page of its own (open that page in a frame right away, it is
|
|
523
|
+
* short-lived); or `pending` while the card's details are still being
|
|
524
|
+
* prepared, which doesn't count against the limit. A card says the same
|
|
525
|
+
* in {@link Card.details_pending}, so there is no need to call this just
|
|
526
|
+
* to find out.
|
|
346
527
|
*
|
|
347
528
|
* 403 not your card · 409 `card_locked` · 429 rate-limited · 501 connector
|
|
348
529
|
* has no sensitive-data endpoint · 503 `provider_unavailable`.
|
|
349
530
|
*/
|
|
350
531
|
async reveal(id, _input) {
|
|
351
|
-
|
|
532
|
+
const r = await this.http.post(
|
|
533
|
+
`/me/cards/${encodeURIComponent(id)}/reveal`
|
|
534
|
+
);
|
|
535
|
+
return { ...r, state: revealState(r) };
|
|
352
536
|
}
|
|
353
537
|
/**
|
|
354
538
|
* Unfreeze a previously-frozen card. Idempotent on an already-active card.
|
|
@@ -465,8 +649,11 @@ var AuthResource = class {
|
|
|
465
649
|
/** Password-auth entry. May resolve to a JWT, or to a step-up
|
|
466
650
|
* challenge that needs `verifyTotp` / `verifyOtp` next. */
|
|
467
651
|
async login(input) {
|
|
652
|
+
const body = withRemember(input);
|
|
653
|
+
const attribution = withAnalyticsIds(void 0);
|
|
654
|
+
if (attribution !== void 0) body["attribution"] = attribution;
|
|
468
655
|
const resp = await this.http.post("/auth/login", {
|
|
469
|
-
body
|
|
656
|
+
body,
|
|
470
657
|
skipAuth: true
|
|
471
658
|
});
|
|
472
659
|
if (resp.stage === "jwt") {
|
|
@@ -503,6 +690,8 @@ var AuthResource = class {
|
|
|
503
690
|
async register(input) {
|
|
504
691
|
const { cardOrder, ...rest } = input;
|
|
505
692
|
const body = withRemember(rest);
|
|
693
|
+
const attribution = withAnalyticsIds(rest.attribution);
|
|
694
|
+
if (attribution !== void 0) body["attribution"] = attribution;
|
|
506
695
|
if (cardOrder !== void 0) body["card_order"] = cardOrderBody(cardOrder);
|
|
507
696
|
const resp = await this.http.post("/auth/register", {
|
|
508
697
|
body,
|
|
@@ -538,7 +727,8 @@ var AuthResource = class {
|
|
|
538
727
|
};
|
|
539
728
|
if (input.remember) body["remember_me"] = true;
|
|
540
729
|
if (input.walletCurrency !== void 0) body["wallet_currency"] = input.walletCurrency;
|
|
541
|
-
|
|
730
|
+
const attribution = withAnalyticsIds(input.attribution);
|
|
731
|
+
if (attribution !== void 0) body["attribution"] = attribution;
|
|
542
732
|
if (input.promoCode !== void 0) body["promo_code"] = input.promoCode;
|
|
543
733
|
if (input.consents !== void 0) body["consents"] = input.consents;
|
|
544
734
|
if (input.consentChannel !== void 0) body["consent_channel"] = input.consentChannel;
|
|
@@ -584,7 +774,8 @@ var AuthResource = class {
|
|
|
584
774
|
init_data: input.initData
|
|
585
775
|
};
|
|
586
776
|
if (input.provision !== void 0) body.provision = input.provision;
|
|
587
|
-
|
|
777
|
+
const attribution = withAnalyticsIds(input.attribution);
|
|
778
|
+
if (attribution !== void 0) body.attribution = attribution;
|
|
588
779
|
if (input.code !== void 0) body.code = input.code;
|
|
589
780
|
if (input.consents !== void 0) body.consents = input.consents;
|
|
590
781
|
if (input.consentChannel !== void 0) body.consent_channel = input.consentChannel;
|
|
@@ -690,10 +881,17 @@ var DepositsResource = class {
|
|
|
690
881
|
if (connectorSlug !== void 0) body["connector_slug"] = connectorSlug;
|
|
691
882
|
return this.http.post("/me/deposits/quotes", { body });
|
|
692
883
|
}
|
|
884
|
+
/**
|
|
885
|
+
* Start a top-up. 409 `payments_on_hold`: a payment on this account was
|
|
886
|
+
* not accepted and new ones wait until support sorts it out. Show the
|
|
887
|
+
* message as it comes and point the user to support.
|
|
888
|
+
*/
|
|
693
889
|
async initiate(input) {
|
|
694
890
|
const { idempotencyKey, issue_card, ...rest } = input;
|
|
695
891
|
const body = { ...rest };
|
|
696
892
|
if (issue_card !== void 0) body["issue_card"] = cardRequestBody(issue_card);
|
|
893
|
+
const ids = input.analytics_ids ?? analyticsIds();
|
|
894
|
+
if (ids !== void 0) body["analytics_ids"] = ids;
|
|
697
895
|
return this.http.post("/me/deposits", {
|
|
698
896
|
body,
|
|
699
897
|
idempotencyKey
|
|
@@ -1298,81 +1496,6 @@ var DevicesResource = class {
|
|
|
1298
1496
|
}
|
|
1299
1497
|
};
|
|
1300
1498
|
|
|
1301
|
-
// src/resources/attribution.ts
|
|
1302
|
-
var AttributionResource = class {
|
|
1303
|
-
constructor(http) {
|
|
1304
|
-
this.http = http;
|
|
1305
|
-
}
|
|
1306
|
-
/** Record a visit. No session needed; safe to call on every page load. */
|
|
1307
|
-
async touch(input) {
|
|
1308
|
-
return this.http.post("/attribution/touches", { body: input, skipAuth: true });
|
|
1309
|
-
}
|
|
1310
|
-
/** Whether to ask the signed-in user how they heard about us. */
|
|
1311
|
-
async status() {
|
|
1312
|
-
return this.http.get("/me/attribution");
|
|
1313
|
-
}
|
|
1314
|
-
/** Answer the question once. Send `"skipped"` when the user closes it.
|
|
1315
|
-
* `otherText` is kept only with `"other"`, up to 500 characters.
|
|
1316
|
-
* Errors: 400 `validation`, 409 `survey_answered`. */
|
|
1317
|
-
async answerSurvey(answer, otherText) {
|
|
1318
|
-
const body = { answer };
|
|
1319
|
-
if (otherText !== void 0) body.other_text = otherText;
|
|
1320
|
-
return this.http.put("/me/attribution/survey", { body });
|
|
1321
|
-
}
|
|
1322
|
-
};
|
|
1323
|
-
function tgWebApp() {
|
|
1324
|
-
return globalThis.Telegram?.WebApp?.initDataUnsafe;
|
|
1325
|
-
}
|
|
1326
|
-
function readCookie(name) {
|
|
1327
|
-
const doc = globalThis.document;
|
|
1328
|
-
if (!doc?.cookie) return void 0;
|
|
1329
|
-
for (const part of doc.cookie.split(";")) {
|
|
1330
|
-
const [k, ...v] = part.trim().split("=");
|
|
1331
|
-
if (k === name) return decodeURIComponent(v.join("="));
|
|
1332
|
-
}
|
|
1333
|
-
return void 0;
|
|
1334
|
-
}
|
|
1335
|
-
var KEY_SHAPE = /^[A-Za-z0-9_-]{8,64}$/;
|
|
1336
|
-
function anonymousKey(opts = {}) {
|
|
1337
|
-
const tgId = tgWebApp()?.user?.id;
|
|
1338
|
-
if (tgId) return `tg:${tgId}`;
|
|
1339
|
-
const g = globalThis;
|
|
1340
|
-
if (!g.document) return void 0;
|
|
1341
|
-
const name = opts.name ?? "takeal_anon";
|
|
1342
|
-
let stored;
|
|
1343
|
-
try {
|
|
1344
|
-
stored = g.localStorage?.getItem(name) ?? void 0;
|
|
1345
|
-
} catch {
|
|
1346
|
-
stored = void 0;
|
|
1347
|
-
}
|
|
1348
|
-
const fromCookie = readCookie(name);
|
|
1349
|
-
let key = [fromCookie, stored].find((k) => !!k && KEY_SHAPE.test(k));
|
|
1350
|
-
if (!key) {
|
|
1351
|
-
key = g.crypto?.randomUUID?.() ?? `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 14)}`;
|
|
1352
|
-
}
|
|
1353
|
-
try {
|
|
1354
|
-
g.localStorage?.setItem(name, key);
|
|
1355
|
-
} catch {
|
|
1356
|
-
}
|
|
1357
|
-
const domain = opts.cookieDomain ? `; domain=${opts.cookieDomain}` : "";
|
|
1358
|
-
g.document.cookie = `${name}=${encodeURIComponent(key)}; max-age=31536000; path=/; SameSite=Lax${domain}`;
|
|
1359
|
-
return key;
|
|
1360
|
-
}
|
|
1361
|
-
function currentTouch() {
|
|
1362
|
-
const g = globalThis;
|
|
1363
|
-
const tg = tgWebApp();
|
|
1364
|
-
const out = {};
|
|
1365
|
-
if (g.location?.href) out.url = g.location.href;
|
|
1366
|
-
if (g.document?.referrer) out.referrer = g.document.referrer;
|
|
1367
|
-
if (tg?.start_param) out.campaign_code = tg.start_param;
|
|
1368
|
-
if (tg?.user?.id) out.platform = "miniapp";
|
|
1369
|
-
const ym = readCookie("_ym_uid");
|
|
1370
|
-
if (ym) out.metrika_client_id = ym;
|
|
1371
|
-
const ga = readCookie("_ga")?.split(".").slice(-2).join(".");
|
|
1372
|
-
if (ga) out.ga_client_id = ga;
|
|
1373
|
-
return out;
|
|
1374
|
-
}
|
|
1375
|
-
|
|
1376
1499
|
// src/resources/history.ts
|
|
1377
1500
|
var HistoryResource = class {
|
|
1378
1501
|
constructor(http) {
|
|
@@ -1476,6 +1599,7 @@ var ConsentsResource = class {
|
|
|
1476
1599
|
const key = input.anonymousKey ?? anonymousKey();
|
|
1477
1600
|
if (key !== void 0) body.anonymous_key = key;
|
|
1478
1601
|
if (input.channel !== void 0) body.channel = input.channel;
|
|
1602
|
+
if (!input.analytics) forgetAnalyticsIds();
|
|
1479
1603
|
return this.http.post("/consents/cookies", { body });
|
|
1480
1604
|
}
|
|
1481
1605
|
};
|
|
@@ -1573,7 +1697,7 @@ var FundingOptionsResource = class {
|
|
|
1573
1697
|
};
|
|
1574
1698
|
|
|
1575
1699
|
// src/version.ts
|
|
1576
|
-
var SDK_VERSION = "0.6.
|
|
1700
|
+
var SDK_VERSION = "0.6.14";
|
|
1577
1701
|
|
|
1578
1702
|
// src/client-platform.ts
|
|
1579
1703
|
var CLIENT_HEADER = "X-Takeal-Client";
|
|
@@ -1648,7 +1772,7 @@ function isAbsolute(url) {
|
|
|
1648
1772
|
}
|
|
1649
1773
|
|
|
1650
1774
|
// src/compat.ts
|
|
1651
|
-
var SUPPORTED_MEISTER = ">=0.6
|
|
1775
|
+
var SUPPORTED_MEISTER = ">=0.7.6, <1.0.0";
|
|
1652
1776
|
var SEMVER = /^v?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/;
|
|
1653
1777
|
function parse(v) {
|
|
1654
1778
|
const m = SEMVER.exec(v.trim());
|
|
@@ -2047,6 +2171,9 @@ var MetrikaSink = class {
|
|
|
2047
2171
|
trackLinks: false,
|
|
2048
2172
|
accurateTrackBounce: true
|
|
2049
2173
|
});
|
|
2174
|
+
this.ym("getClientID", (id) => {
|
|
2175
|
+
if (id !== void 0 && id !== null) rememberAnalyticsIds({ metrika_client_id: String(id) });
|
|
2176
|
+
});
|
|
2050
2177
|
}
|
|
2051
2178
|
ym(...args) {
|
|
2052
2179
|
if (this.live) win().ym?.(this.id, ...args);
|
|
@@ -2098,19 +2225,19 @@ function setAnalyticsZone(zone) {
|
|
|
2098
2225
|
function track(event, props = {}) {
|
|
2099
2226
|
const s = state();
|
|
2100
2227
|
if (!s || !ANALYTICS_EVENTS.includes(event)) return;
|
|
2101
|
-
const
|
|
2102
|
-
for (const sink of sinks(s)) sink.capture(event,
|
|
2228
|
+
const clean2 = sanitizeProperties(props);
|
|
2229
|
+
for (const sink of sinks(s)) sink.capture(event, clean2);
|
|
2103
2230
|
}
|
|
2104
2231
|
function page(url) {
|
|
2105
2232
|
const s = state();
|
|
2106
2233
|
const w = win();
|
|
2107
2234
|
const raw = url ?? w.location?.href;
|
|
2108
2235
|
if (!s || !raw) return;
|
|
2109
|
-
const
|
|
2110
|
-
if (
|
|
2236
|
+
const clean2 = sanitizeUrl(raw);
|
|
2237
|
+
if (clean2 === s.lastPage) return;
|
|
2111
2238
|
const referrer = s.lastPage ?? (w.document?.referrer ? sanitizeUrl(w.document.referrer) : void 0);
|
|
2112
|
-
s.lastPage =
|
|
2113
|
-
for (const sink of sinks(s)) sink.page(
|
|
2239
|
+
s.lastPage = clean2;
|
|
2240
|
+
for (const sink of sinks(s)) sink.page(clean2, referrer);
|
|
2114
2241
|
}
|
|
2115
2242
|
function identify(userId) {
|
|
2116
2243
|
const s = state();
|
|
@@ -2199,6 +2326,6 @@ function defaultFetch() {
|
|
|
2199
2326
|
);
|
|
2200
2327
|
}
|
|
2201
2328
|
|
|
2202
|
-
export { ANALYTICS_EVENTS, ApiError, CLIENT_HEADER, DISPUTE_DOCUMENTS_CONSENT, HOLDER_DATA_CONSENT, METRIKA_GOALS, NO_CAPTURE_CLASS, NetworkError, SDK_VERSION, SUPPORTED_MEISTER, anonymousKey, createClient, currentTouch, defaultBrowserStore, detectClientPlatform, identify, inMemoryStore, initAnalytics, isApiError, isCardOtp, isNetworkError, page, posthogDistinctId, resetAnalytics, resolveAssetUrl, sanitizeProperties, sanitizeUrl, satisfies, setAnalyticsZone, track };
|
|
2329
|
+
export { ANALYTICS_EVENTS, ApiError, CLIENT_HEADER, DISPUTE_DOCUMENTS_CONSENT, HOLDER_DATA_CONSENT, METRIKA_GOALS, NO_CAPTURE_CLASS, NetworkError, SDK_VERSION, SUPPORTED_MEISTER, analyticsIds, anonymousKey, createClient, currentTouch, defaultBrowserStore, detectClientPlatform, forgetAnalyticsIds, identify, inMemoryStore, initAnalytics, isApiError, isCardOtp, isNetworkError, page, posthogDistinctId, rememberAnalyticsIds, resetAnalytics, resolveAssetUrl, revealState, sanitizeProperties, sanitizeUrl, satisfies, setAnalyticsZone, track, withAnalyticsIds };
|
|
2203
2330
|
//# sourceMappingURL=index.js.map
|
|
2204
2331
|
//# sourceMappingURL=index.js.map
|