@takeal/cusfront-sdk 0.3.18 → 0.5.0
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 +139 -0
- package/README.md +430 -9
- package/dist/analytics.cjs +417 -0
- package/dist/analytics.cjs.map +1 -0
- package/dist/analytics.d.cts +129 -0
- package/dist/analytics.d.ts +129 -0
- package/dist/analytics.js +403 -0
- package/dist/analytics.js.map +1 -0
- package/dist/cards-B_aNY35J.d.cts +514 -0
- package/dist/cards-Ba1wZttb.d.ts +514 -0
- package/dist/deposits-BEc8U80M.d.cts +310 -0
- package/dist/deposits-DScyT_D9.d.ts +310 -0
- package/dist/{devices-DP_hxwmW.d.ts → devices-B_YveTl9.d.ts} +1 -1
- package/dist/{devices-C3JHi2Hi.d.cts → devices-a5Z45Mx_.d.cts} +1 -1
- package/dist/{http-B-OQwMYn.d.cts → http-DeANAoTs.d.cts} +11 -3
- package/dist/{http-B-OQwMYn.d.ts → http-DeANAoTs.d.ts} +11 -3
- package/dist/index.cjs +964 -77
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +101 -13
- package/dist/index.d.ts +101 -13
- package/dist/index.js +949 -78
- package/dist/index.js.map +1 -1
- package/dist/react/index.d.cts +12 -5
- package/dist/react/index.d.ts +12 -5
- package/dist/resources/attribution.cjs +82 -0
- package/dist/resources/attribution.cjs.map +1 -0
- package/dist/resources/attribution.d.cts +100 -0
- package/dist/resources/attribution.d.ts +100 -0
- package/dist/resources/attribution.js +78 -0
- package/dist/resources/attribution.js.map +1 -0
- package/dist/resources/auth.cjs +81 -15
- package/dist/resources/auth.cjs.map +1 -1
- package/dist/resources/auth.d.cts +53 -6
- package/dist/resources/auth.d.ts +53 -6
- package/dist/resources/auth.js +81 -15
- 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.cjs.map +1 -1
- package/dist/resources/blog.d.cts +8 -1
- package/dist/resources/blog.d.ts +8 -1
- package/dist/resources/blog.js.map +1 -1
- package/dist/resources/bonus.cjs +28 -0
- package/dist/resources/bonus.cjs.map +1 -0
- package/dist/resources/bonus.d.cts +121 -0
- package/dist/resources/bonus.d.ts +121 -0
- package/dist/resources/bonus.js +26 -0
- package/dist/resources/bonus.js.map +1 -0
- package/dist/resources/branding.d.cts +1 -1
- package/dist/resources/branding.d.ts +1 -1
- package/dist/resources/cards.cjs +73 -10
- package/dist/resources/cards.cjs.map +1 -1
- package/dist/resources/cards.d.cts +2 -281
- package/dist/resources/cards.d.ts +2 -281
- package/dist/resources/cards.js +73 -11
- package/dist/resources/cards.js.map +1 -1
- package/dist/resources/codes.cjs +20 -0
- package/dist/resources/codes.cjs.map +1 -0
- package/dist/resources/codes.d.cts +100 -0
- package/dist/resources/codes.d.ts +100 -0
- package/dist/resources/codes.js +18 -0
- package/dist/resources/codes.js.map +1 -0
- package/dist/resources/deposits.cjs +28 -3
- package/dist/resources/deposits.cjs.map +1 -1
- package/dist/resources/deposits.d.cts +3 -176
- package/dist/resources/deposits.d.ts +3 -176
- package/dist/resources/deposits.js +28 -3
- 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.cjs +64 -0
- package/dist/resources/documents.cjs.map +1 -0
- package/dist/resources/documents.d.cts +212 -0
- package/dist/resources/documents.d.ts +212 -0
- package/dist/resources/documents.js +62 -0
- package/dist/resources/documents.js.map +1 -0
- package/dist/resources/funding-options.cjs +16 -0
- package/dist/resources/funding-options.cjs.map +1 -0
- package/dist/resources/funding-options.d.cts +3 -0
- package/dist/resources/funding-options.d.ts +3 -0
- package/dist/resources/funding-options.js +14 -0
- package/dist/resources/funding-options.js.map +1 -0
- package/dist/resources/history.cjs +31 -0
- package/dist/resources/history.cjs.map +1 -0
- package/dist/resources/history.d.cts +95 -0
- package/dist/resources/history.d.ts +95 -0
- package/dist/resources/history.js +29 -0
- package/dist/resources/history.js.map +1 -0
- package/dist/resources/me.d.cts +3 -1
- package/dist/resources/me.d.ts +3 -1
- 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/referral.cjs +16 -0
- package/dist/resources/referral.cjs.map +1 -0
- package/dist/resources/referral.d.cts +58 -0
- package/dist/resources/referral.d.ts +58 -0
- package/dist/resources/referral.js +14 -0
- package/dist/resources/referral.js.map +1 -0
- package/dist/resources/sessions.d.cts +1 -1
- package/dist/resources/sessions.d.ts +1 -1
- package/dist/resources/subscription.cjs +24 -0
- package/dist/resources/subscription.cjs.map +1 -0
- package/dist/resources/subscription.d.cts +48 -0
- package/dist/resources/subscription.d.ts +48 -0
- package/dist/resources/subscription.js +22 -0
- package/dist/resources/subscription.js.map +1 -0
- package/dist/resources/subscriptions.d.cts +1 -1
- package/dist/resources/subscriptions.d.ts +1 -1
- package/dist/resources/wallet.d.cts +1 -1
- package/dist/resources/wallet.d.ts +1 -1
- package/dist/telegram.cjs +499 -77
- package/dist/telegram.cjs.map +1 -1
- package/dist/telegram.d.cts +12 -5
- package/dist/telegram.d.ts +12 -5
- package/dist/telegram.js +499 -77
- package/dist/telegram.js.map +1 -1
- package/package.json +46 -1
- package/dist/customer-CoxPwe5o.d.cts +0 -32
- package/dist/customer-CoxPwe5o.d.ts +0 -32
package/dist/index.js
CHANGED
|
@@ -42,6 +42,20 @@ var HttpClient = class {
|
|
|
42
42
|
this.defaultHeaders = defaultHeaders;
|
|
43
43
|
if (!baseUrl) throw new Error("HttpClient: baseUrl is required");
|
|
44
44
|
}
|
|
45
|
+
/** Called once on a 401; resolves `true` when a new session was stored. */
|
|
46
|
+
setRefresher(fn) {
|
|
47
|
+
this.refresher = fn;
|
|
48
|
+
}
|
|
49
|
+
/** One refresh at a time, whoever asks. */
|
|
50
|
+
refreshOnce() {
|
|
51
|
+
if (!this.refresher) return Promise.resolve(false);
|
|
52
|
+
if (!this.refreshing) {
|
|
53
|
+
this.refreshing = this.refresher().catch(() => false).finally(() => {
|
|
54
|
+
this.refreshing = void 0;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
return this.refreshing;
|
|
58
|
+
}
|
|
45
59
|
async get(path, opts = {}) {
|
|
46
60
|
return this.request("GET", path, opts);
|
|
47
61
|
}
|
|
@@ -87,6 +101,11 @@ var HttpClient = class {
|
|
|
87
101
|
e
|
|
88
102
|
);
|
|
89
103
|
}
|
|
104
|
+
if (resp.status === 401 && !opts.skipAuth && !opts.retried && this.refresher) {
|
|
105
|
+
if (await this.refreshOnce()) {
|
|
106
|
+
return this.request(method, path, { ...opts, retried: true });
|
|
107
|
+
}
|
|
108
|
+
}
|
|
90
109
|
return parseResponse(resp);
|
|
91
110
|
}
|
|
92
111
|
absolute(path) {
|
|
@@ -120,20 +139,73 @@ async function parseResponse(resp) {
|
|
|
120
139
|
}
|
|
121
140
|
|
|
122
141
|
// src/resources/auth.ts
|
|
142
|
+
function withRemember(input) {
|
|
143
|
+
const { remember, ...rest } = input;
|
|
144
|
+
return remember ? { ...rest, remember_me: true } : rest;
|
|
145
|
+
}
|
|
123
146
|
var AuthResource = class {
|
|
124
|
-
constructor(http, tokens) {
|
|
147
|
+
constructor(http, tokens, remembered) {
|
|
125
148
|
this.http = http;
|
|
126
149
|
this.tokens = tokens;
|
|
150
|
+
this.remembered = remembered;
|
|
151
|
+
if (remembered) http.setRefresher(() => this.renew().then((r) => r.kind !== "gone"));
|
|
152
|
+
}
|
|
153
|
+
/** Store what a finished sign-in returned. */
|
|
154
|
+
async keep(resp) {
|
|
155
|
+
await Promise.resolve(this.tokens.set(resp.access_token));
|
|
156
|
+
if (resp.remember_token && this.remembered) {
|
|
157
|
+
await Promise.resolve(this.remembered.set(resp.remember_token));
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
/** Renew a remembered sign-in: a new session and a new remember token,
|
|
161
|
+
* both stored. Resolves `null` (and forgets the remember token) when there
|
|
162
|
+
* is none or it no longer works; the app then shows the sign-in form.
|
|
163
|
+
* The SDK does this by itself on a 401; call it on app start to resume a
|
|
164
|
+
* session without a request failing first. */
|
|
165
|
+
async refresh() {
|
|
166
|
+
const r = await this.renew();
|
|
167
|
+
if (r.kind === "renewed") return r.resp;
|
|
168
|
+
if (r.kind === "taken_over") {
|
|
169
|
+
const access = await Promise.resolve(this.tokens.get());
|
|
170
|
+
const user = await this.me();
|
|
171
|
+
return { stage: "jwt", access_token: access ?? "", expires_at: "", user };
|
|
172
|
+
}
|
|
173
|
+
return null;
|
|
174
|
+
}
|
|
175
|
+
/** The renewal itself, for the 401 path: it must not call the API again
|
|
176
|
+
* through the client, or a second 401 would wait on this very renewal. */
|
|
177
|
+
async renew() {
|
|
178
|
+
const token = this.remembered ? await Promise.resolve(this.remembered.get()) : null;
|
|
179
|
+
if (!token) return { kind: "gone" };
|
|
180
|
+
try {
|
|
181
|
+
const resp = await this.http.post("/auth/refresh", {
|
|
182
|
+
body: { remember_token: token },
|
|
183
|
+
skipAuth: true
|
|
184
|
+
});
|
|
185
|
+
await this.keep(resp);
|
|
186
|
+
return { kind: "renewed", resp };
|
|
187
|
+
} catch (e) {
|
|
188
|
+
if (isApiError(e) && e.status === 401) {
|
|
189
|
+
const now = await Promise.resolve(this.remembered.get());
|
|
190
|
+
if (now && now !== token && await Promise.resolve(this.tokens.get())) {
|
|
191
|
+
return { kind: "taken_over" };
|
|
192
|
+
}
|
|
193
|
+
await Promise.resolve(this.remembered.clear());
|
|
194
|
+
await Promise.resolve(this.tokens.clear());
|
|
195
|
+
return { kind: "gone" };
|
|
196
|
+
}
|
|
197
|
+
throw e;
|
|
198
|
+
}
|
|
127
199
|
}
|
|
128
200
|
/** Password-auth entry. May resolve to a JWT, or to a step-up
|
|
129
201
|
* challenge that needs `verifyTotp` / `verifyOtp` next. */
|
|
130
202
|
async login(input) {
|
|
131
203
|
const resp = await this.http.post("/auth/login", {
|
|
132
|
-
body: input,
|
|
204
|
+
body: withRemember(input),
|
|
133
205
|
skipAuth: true
|
|
134
206
|
});
|
|
135
207
|
if (resp.stage === "jwt") {
|
|
136
|
-
await
|
|
208
|
+
await this.keep(resp);
|
|
137
209
|
}
|
|
138
210
|
return resp;
|
|
139
211
|
}
|
|
@@ -141,20 +213,20 @@ var AuthResource = class {
|
|
|
141
213
|
* `totp_required` challenge. On success the JWT is stored. */
|
|
142
214
|
async verifyTotp(input) {
|
|
143
215
|
const resp = await this.http.post("/auth/login/totp", {
|
|
144
|
-
body: input,
|
|
216
|
+
body: withRemember(input),
|
|
145
217
|
skipAuth: true
|
|
146
218
|
});
|
|
147
|
-
await
|
|
219
|
+
await this.keep(resp);
|
|
148
220
|
return resp;
|
|
149
221
|
}
|
|
150
222
|
/** Verify a 6-digit OTP code (Telegram / email) against an
|
|
151
223
|
* `otp_sent` challenge. */
|
|
152
224
|
async verifyOtp(input) {
|
|
153
225
|
const resp = await this.http.post("/auth/login/otp/verify", {
|
|
154
|
-
body: input,
|
|
226
|
+
body: withRemember(input),
|
|
155
227
|
skipAuth: true
|
|
156
228
|
});
|
|
157
|
-
await
|
|
229
|
+
await this.keep(resp);
|
|
158
230
|
return resp;
|
|
159
231
|
}
|
|
160
232
|
/** Create an end-user account and sign it in. The JWT is stored.
|
|
@@ -164,10 +236,10 @@ var AuthResource = class {
|
|
|
164
236
|
* Errors: 400 `validation` / `currency_not_allowed`, 409 email taken. */
|
|
165
237
|
async register(input) {
|
|
166
238
|
const resp = await this.http.post("/auth/register", {
|
|
167
|
-
body: input,
|
|
239
|
+
body: withRemember(input),
|
|
168
240
|
skipAuth: true
|
|
169
241
|
});
|
|
170
|
-
await
|
|
242
|
+
await this.keep(resp);
|
|
171
243
|
return resp;
|
|
172
244
|
}
|
|
173
245
|
/** Finish a `totp_setup_required` login: send the first code from the
|
|
@@ -176,10 +248,10 @@ var AuthResource = class {
|
|
|
176
248
|
* the user right away and don't keep them on the device. */
|
|
177
249
|
async completeTotpSetup(input) {
|
|
178
250
|
const resp = await this.http.post("/auth/login/totp-setup", {
|
|
179
|
-
body: input,
|
|
251
|
+
body: withRemember(input),
|
|
180
252
|
skipAuth: true
|
|
181
253
|
});
|
|
182
|
-
await
|
|
254
|
+
await this.keep(resp);
|
|
183
255
|
return resp;
|
|
184
256
|
}
|
|
185
257
|
/** Change the signed-in user's password. Every other session of the
|
|
@@ -200,8 +272,12 @@ var AuthResource = class {
|
|
|
200
272
|
});
|
|
201
273
|
}
|
|
202
274
|
async exchangeTelegram(input) {
|
|
203
|
-
const body = {
|
|
275
|
+
const body = {
|
|
276
|
+
init_data: input.initData
|
|
277
|
+
};
|
|
204
278
|
if (input.provision !== void 0) body.provision = input.provision;
|
|
279
|
+
if (input.attribution !== void 0) body.attribution = input.attribution;
|
|
280
|
+
if (input.code !== void 0) body.code = input.code;
|
|
205
281
|
let resp;
|
|
206
282
|
try {
|
|
207
283
|
resp = await this.http.post("/auth/telegram/exchange", {
|
|
@@ -247,62 +323,44 @@ var AuthResource = class {
|
|
|
247
323
|
async me() {
|
|
248
324
|
return this.http.get("/auth/me");
|
|
249
325
|
}
|
|
250
|
-
/**
|
|
251
|
-
* server
|
|
252
|
-
*
|
|
326
|
+
/** Sign out: ends this session and the remembered sign-in on the
|
|
327
|
+
* server (best effort: a network failure still signs out locally), then
|
|
328
|
+
* forgets both tokens. */
|
|
253
329
|
async signOut() {
|
|
330
|
+
const remember = this.remembered ? await Promise.resolve(this.remembered.get()) : null;
|
|
331
|
+
try {
|
|
332
|
+
await this.http.post("/auth/logout", {
|
|
333
|
+
body: remember ? { remember_token: remember } : {},
|
|
334
|
+
retried: true
|
|
335
|
+
});
|
|
336
|
+
} catch {
|
|
337
|
+
}
|
|
254
338
|
await Promise.resolve(this.tokens.clear());
|
|
255
|
-
|
|
256
|
-
};
|
|
257
|
-
|
|
258
|
-
// src/resources/deposits.ts
|
|
259
|
-
var DepositsResource = class {
|
|
260
|
-
constructor(http) {
|
|
261
|
-
this.http = http;
|
|
262
|
-
}
|
|
263
|
-
/**
|
|
264
|
-
* Initiate a top-up. Resolves to the freshly-created `Deposit`, whose
|
|
265
|
-
* `status` may already be `confirmed` (synchronous rails / mock) or
|
|
266
|
-
* `redirect_required` (3DS / APM — forward the user to `redirect_url`).
|
|
267
|
-
*/
|
|
268
|
-
/**
|
|
269
|
-
* Price a cross-currency deposit BEFORE paying. The rate is locked
|
|
270
|
-
* server-side until `expires_at`; deposits in the local currency need no
|
|
271
|
-
* quote (the API answers 400 `no_quote_needed`).
|
|
272
|
-
*/
|
|
273
|
-
async quote(input) {
|
|
274
|
-
return this.http.post("/me/deposits/quotes", { body: input });
|
|
275
|
-
}
|
|
276
|
-
async initiate(input) {
|
|
277
|
-
const { idempotencyKey, ...body } = input;
|
|
278
|
-
return this.http.post("/me/deposits", {
|
|
279
|
-
body,
|
|
280
|
-
idempotencyKey
|
|
281
|
-
});
|
|
282
|
-
}
|
|
283
|
-
/** Fetch one deposit by id — the poll target while a redirect resolves. */
|
|
284
|
-
async get(id) {
|
|
285
|
-
return this.http.get(`/me/deposits/${encodeURIComponent(id)}`);
|
|
286
|
-
}
|
|
287
|
-
/** List the caller's deposits, most recent first. */
|
|
288
|
-
async list() {
|
|
289
|
-
return this.http.get("/me/deposits");
|
|
290
|
-
}
|
|
291
|
-
/**
|
|
292
|
-
* Refund a previously-confirmed deposit. Synchronous when the
|
|
293
|
-
* connector settles inline; otherwise the row stays `pending` and flips
|
|
294
|
-
* later via the inbound `deposit.refunded` event.
|
|
295
|
-
*/
|
|
296
|
-
async refund(depositId, input) {
|
|
297
|
-
const { idempotencyKey, ...body } = input;
|
|
298
|
-
return this.http.post(
|
|
299
|
-
`/me/deposits/${encodeURIComponent(depositId)}/refunds`,
|
|
300
|
-
{ body, idempotencyKey }
|
|
301
|
-
);
|
|
339
|
+
if (this.remembered) await Promise.resolve(this.remembered.clear());
|
|
302
340
|
}
|
|
303
341
|
};
|
|
304
342
|
|
|
305
343
|
// src/resources/cards.ts
|
|
344
|
+
function cardRequestBody(input) {
|
|
345
|
+
const {
|
|
346
|
+
productId,
|
|
347
|
+
name,
|
|
348
|
+
designId,
|
|
349
|
+
useBonus,
|
|
350
|
+
bonusAmount,
|
|
351
|
+
promoCode,
|
|
352
|
+
initial_amount: _ignored,
|
|
353
|
+
...rest
|
|
354
|
+
} = input;
|
|
355
|
+
const body = { ...rest };
|
|
356
|
+
if (productId !== void 0) body["product_id"] = productId;
|
|
357
|
+
if (name !== void 0) body["name"] = name;
|
|
358
|
+
if (designId !== void 0) body["design_id"] = designId;
|
|
359
|
+
if (useBonus !== void 0) body["use_bonus"] = useBonus;
|
|
360
|
+
if (bonusAmount !== void 0) body["bonus_amount"] = bonusAmount;
|
|
361
|
+
if (promoCode !== void 0) body["promo_code"] = promoCode;
|
|
362
|
+
return body;
|
|
363
|
+
}
|
|
306
364
|
var CardsResource = class {
|
|
307
365
|
constructor(http) {
|
|
308
366
|
this.http = http;
|
|
@@ -314,21 +372,19 @@ var CardsResource = class {
|
|
|
314
372
|
* `failure_reason` on the result.
|
|
315
373
|
*/
|
|
316
374
|
async create(input) {
|
|
317
|
-
const { idempotencyKey,
|
|
318
|
-
const body = { ...rest };
|
|
319
|
-
if (productId !== void 0) body["product_id"] = productId;
|
|
320
|
-
if (name !== void 0) body["name"] = name;
|
|
321
|
-
if (designId !== void 0) body["design_id"] = designId;
|
|
375
|
+
const { idempotencyKey, ...card } = input;
|
|
322
376
|
return this.http.post("/me/cards", {
|
|
323
|
-
body,
|
|
377
|
+
body: cardRequestBody(card),
|
|
324
378
|
idempotencyKey
|
|
325
379
|
});
|
|
326
380
|
}
|
|
327
381
|
/**
|
|
328
|
-
* The cards the caller can order, in the order the
|
|
329
|
-
* (the
|
|
330
|
-
*
|
|
331
|
-
* and the
|
|
382
|
+
* The cards the caller can order, in the order the storefront shows them
|
|
383
|
+
* (`is_default` marks the one issued when none is chosen). Each item
|
|
384
|
+
* carries its product card (name, tagline, benefits, tile picture),
|
|
385
|
+
* artwork, and the issuance price after the caller's subscription
|
|
386
|
+
* discount, in the caller's wallet currency. Pass an item's `id` as
|
|
387
|
+
* `productId` to {@link create}.
|
|
332
388
|
*/
|
|
333
389
|
async listProducts() {
|
|
334
390
|
return this.http.get("/me/card-products");
|
|
@@ -380,6 +436,50 @@ var CardsResource = class {
|
|
|
380
436
|
`/me/cards/${encodeURIComponent(id)}/balance?${q}`
|
|
381
437
|
);
|
|
382
438
|
}
|
|
439
|
+
/**
|
|
440
|
+
* What a top-up of this card can be right now: whether it is possible, the
|
|
441
|
+
* currency, the wallet balance, and the product's floor and cap for one
|
|
442
|
+
* top-up. Read it before drawing the form. 404 if the card isn't the caller's.
|
|
443
|
+
*/
|
|
444
|
+
async topUpTerms(id) {
|
|
445
|
+
return this.http.get(`/me/cards/${encodeURIComponent(id)}/topup`);
|
|
446
|
+
}
|
|
447
|
+
/**
|
|
448
|
+
* Move money from the wallet onto the caller's own card. The wallet is
|
|
449
|
+
* debited first, then the card's provider loads the card; if the provider
|
|
450
|
+
* refuses, the money is back on the wallet and the error says so. Resolves
|
|
451
|
+
* to the card, its new balance and the wallet balance, so no second call
|
|
452
|
+
* is needed. Errors carry a sentence the user can read: 400 outside the
|
|
453
|
+
* floor or cap · 402 not enough in the wallet · 404 not the caller's card ·
|
|
454
|
+
* 409 card frozen, closed or still being issued · 501 provider can't top
|
|
455
|
+
* up · 502/503 provider declined or unreachable (wallet untouched).
|
|
456
|
+
*/
|
|
457
|
+
async topUp(id, input) {
|
|
458
|
+
const { idempotencyKey, amount } = input;
|
|
459
|
+
return this.http.post(`/me/cards/${encodeURIComponent(id)}/topup`, {
|
|
460
|
+
body: { amount },
|
|
461
|
+
idempotencyKey
|
|
462
|
+
});
|
|
463
|
+
}
|
|
464
|
+
/**
|
|
465
|
+
* Move money from one of the caller's cards to another. Both must be
|
|
466
|
+
* theirs, active, in the same currency and of the same kind. The money
|
|
467
|
+
* travels through the wallet one leg at a time: when the second leg does
|
|
468
|
+
* not go through, the call still resolves, `transfer.status` is
|
|
469
|
+
* `on_wallet` and the money is on the wallet — never between two cards.
|
|
470
|
+
* Errors carry a sentence the user can read: 400 the same card twice,
|
|
471
|
+
* different currencies or different kinds · 402 the card holds less than
|
|
472
|
+
* that · 404 one of the cards isn't theirs · 409 a card is frozen, closed
|
|
473
|
+
* or still being issued, or the key was reused with a different body ·
|
|
474
|
+
* 501/502/503 the provider cannot or will not move it.
|
|
475
|
+
*/
|
|
476
|
+
async transfer(fromCardId, input) {
|
|
477
|
+
const { toCardId, amount, idempotencyKey } = input;
|
|
478
|
+
return this.http.post(
|
|
479
|
+
`/me/cards/${encodeURIComponent(fromCardId)}/transfer`,
|
|
480
|
+
{ body: { to_card_id: toCardId, amount }, idempotencyKey }
|
|
481
|
+
);
|
|
482
|
+
}
|
|
383
483
|
/**
|
|
384
484
|
* Freeze the caller's own card. Reversible via {@link unfreeze}. The optional
|
|
385
485
|
* `reason` is recorded on the audit trail. Resolves to the updated card.
|
|
@@ -427,6 +527,56 @@ var CardsResource = class {
|
|
|
427
527
|
}
|
|
428
528
|
};
|
|
429
529
|
|
|
530
|
+
// src/resources/deposits.ts
|
|
531
|
+
var DepositsResource = class {
|
|
532
|
+
constructor(http) {
|
|
533
|
+
this.http = http;
|
|
534
|
+
}
|
|
535
|
+
/**
|
|
536
|
+
* Initiate a top-up. Resolves to the freshly-created `Deposit`, whose
|
|
537
|
+
* `status` may already be `confirmed` (synchronous rails / mock) or
|
|
538
|
+
* `redirect_required` (3DS / APM — forward the user to `redirect_url`).
|
|
539
|
+
*/
|
|
540
|
+
/**
|
|
541
|
+
* Price a cross-currency deposit BEFORE paying. The rate is locked
|
|
542
|
+
* server-side until `expires_at`; deposits already in the currency they
|
|
543
|
+
* credit (the wallet's, or the card's with `card_id`) need no quote (the
|
|
544
|
+
* API answers 400 `no_quote_needed`).
|
|
545
|
+
*/
|
|
546
|
+
async quote(input) {
|
|
547
|
+
return this.http.post("/me/deposits/quotes", { body: input });
|
|
548
|
+
}
|
|
549
|
+
async initiate(input) {
|
|
550
|
+
const { idempotencyKey, issue_card, ...rest } = input;
|
|
551
|
+
const body = { ...rest };
|
|
552
|
+
if (issue_card !== void 0) body["issue_card"] = cardRequestBody(issue_card);
|
|
553
|
+
return this.http.post("/me/deposits", {
|
|
554
|
+
body,
|
|
555
|
+
idempotencyKey
|
|
556
|
+
});
|
|
557
|
+
}
|
|
558
|
+
/** Fetch one deposit by id — the poll target while a redirect resolves. */
|
|
559
|
+
async get(id) {
|
|
560
|
+
return this.http.get(`/me/deposits/${encodeURIComponent(id)}`);
|
|
561
|
+
}
|
|
562
|
+
/** List the caller's deposits, most recent first. */
|
|
563
|
+
async list() {
|
|
564
|
+
return this.http.get("/me/deposits");
|
|
565
|
+
}
|
|
566
|
+
/**
|
|
567
|
+
* Refund a previously-confirmed deposit. Synchronous when the
|
|
568
|
+
* connector settles inline; otherwise the row stays `pending` and flips
|
|
569
|
+
* later via the inbound `deposit.refunded` event.
|
|
570
|
+
*/
|
|
571
|
+
async refund(depositId, input) {
|
|
572
|
+
const { idempotencyKey, ...body } = input;
|
|
573
|
+
return this.http.post(
|
|
574
|
+
`/me/deposits/${encodeURIComponent(depositId)}/refunds`,
|
|
575
|
+
{ body, idempotencyKey }
|
|
576
|
+
);
|
|
577
|
+
}
|
|
578
|
+
};
|
|
579
|
+
|
|
430
580
|
// src/resources/balance.ts
|
|
431
581
|
var BalanceResource = class {
|
|
432
582
|
constructor(http) {
|
|
@@ -444,6 +594,74 @@ var BalanceResource = class {
|
|
|
444
594
|
}
|
|
445
595
|
};
|
|
446
596
|
|
|
597
|
+
// src/resources/bonus.ts
|
|
598
|
+
var BonusResource = class {
|
|
599
|
+
constructor(http) {
|
|
600
|
+
this.http = http;
|
|
601
|
+
}
|
|
602
|
+
/** The user's bonuses: balance, where they can go, credits and history. */
|
|
603
|
+
async get(opts = {}) {
|
|
604
|
+
return this.http.get("/me/bonus", { signal: opts.signal });
|
|
605
|
+
}
|
|
606
|
+
/**
|
|
607
|
+
* Work out how bonuses would change a price, at the rate the payment
|
|
608
|
+
* would use. Nothing is held; the numbers may move by the time the user
|
|
609
|
+
* pays if prices, rates or bonuses change.
|
|
610
|
+
*/
|
|
611
|
+
async preview(input) {
|
|
612
|
+
const { productId, bonusAmount, ...rest } = input;
|
|
613
|
+
const body = { ...rest };
|
|
614
|
+
if (productId !== void 0) body["product_id"] = productId;
|
|
615
|
+
if (bonusAmount !== void 0) body["bonus_amount"] = bonusAmount;
|
|
616
|
+
return this.http.post("/me/bonus/preview", { body });
|
|
617
|
+
}
|
|
618
|
+
};
|
|
619
|
+
|
|
620
|
+
// src/resources/codes.ts
|
|
621
|
+
var CodesResource = class {
|
|
622
|
+
constructor(http) {
|
|
623
|
+
this.http = http;
|
|
624
|
+
}
|
|
625
|
+
/**
|
|
626
|
+
* Whether a code can be used on an operation now and what it would do.
|
|
627
|
+
* Nothing is used up. For sign-up there is nothing to check here: send
|
|
628
|
+
* the code with `auth.register` and read `code_result`.
|
|
629
|
+
*/
|
|
630
|
+
async validate(input) {
|
|
631
|
+
return this.http.post("/me/codes/validate", { body: input });
|
|
632
|
+
}
|
|
633
|
+
};
|
|
634
|
+
|
|
635
|
+
// src/resources/referral.ts
|
|
636
|
+
var ReferralResource = class {
|
|
637
|
+
constructor(http) {
|
|
638
|
+
this.http = http;
|
|
639
|
+
}
|
|
640
|
+
/** The user's referral code, link, invited friends and rewards. */
|
|
641
|
+
async get(opts = {}) {
|
|
642
|
+
return this.http.get("/me/referral", { signal: opts.signal });
|
|
643
|
+
}
|
|
644
|
+
};
|
|
645
|
+
|
|
646
|
+
// src/resources/subscription.ts
|
|
647
|
+
var SubscriptionResource = class {
|
|
648
|
+
constructor(http) {
|
|
649
|
+
this.http = http;
|
|
650
|
+
}
|
|
651
|
+
/** The user's subscription, or `null` when there is none. */
|
|
652
|
+
async get(opts = {}) {
|
|
653
|
+
return this.http.get("/me/subscription", { signal: opts.signal });
|
|
654
|
+
}
|
|
655
|
+
/**
|
|
656
|
+
* Charge the monthly fee with a promo code, as long as the code allows.
|
|
657
|
+
* `null` removes it. A code that can't be used on the fee fails with 400
|
|
658
|
+
* `promo_code_*`; no paid subscription running → 404.
|
|
659
|
+
*/
|
|
660
|
+
async setPromoCode(code) {
|
|
661
|
+
return this.http.put("/me/subscription/promo-code", { body: { code } });
|
|
662
|
+
}
|
|
663
|
+
};
|
|
664
|
+
|
|
447
665
|
// src/resources/branding.ts
|
|
448
666
|
var BrandingResource = class {
|
|
449
667
|
constructor(http) {
|
|
@@ -508,6 +726,65 @@ var BlogResource = class {
|
|
|
508
726
|
}
|
|
509
727
|
};
|
|
510
728
|
|
|
729
|
+
// src/resources/documents.ts
|
|
730
|
+
var DocumentsResource = class {
|
|
731
|
+
constructor(http) {
|
|
732
|
+
this.http = http;
|
|
733
|
+
}
|
|
734
|
+
/**
|
|
735
|
+
* Published documents you may read, paged. The blog comes newest first,
|
|
736
|
+
* other categories in the order set by the editors.
|
|
737
|
+
*/
|
|
738
|
+
async list(input = {}) {
|
|
739
|
+
const q = new URLSearchParams();
|
|
740
|
+
if (input.category) q.set("category", input.category);
|
|
741
|
+
if (input.folderId) q.set("folder_id", input.folderId);
|
|
742
|
+
if (input.tag) q.set("tag", input.tag);
|
|
743
|
+
if (input.locale) q.set("locale", input.locale);
|
|
744
|
+
if (input.q) q.set("q", input.q);
|
|
745
|
+
if (input.page) q.set("page", String(input.page));
|
|
746
|
+
if (input.perPage) q.set("per_page", String(input.perPage));
|
|
747
|
+
const qs = q.toString();
|
|
748
|
+
return this.http.get(`/documents${qs ? `?${qs}` : ""}`);
|
|
749
|
+
}
|
|
750
|
+
/** Folders and documents for a sidebar or a table of contents. */
|
|
751
|
+
async tree(input = {}) {
|
|
752
|
+
const qs = input.category ? `?category=${encodeURIComponent(input.category)}` : "";
|
|
753
|
+
return this.http.get(`/documents/tree${qs}`);
|
|
754
|
+
}
|
|
755
|
+
/** Every tag on a document you may read, most used first. */
|
|
756
|
+
async tags() {
|
|
757
|
+
return this.http.get("/documents/tags");
|
|
758
|
+
}
|
|
759
|
+
/**
|
|
760
|
+
* One document by its address. Without `at`, the text in force now; with
|
|
761
|
+
* `at` (an ISO 8601 moment), the text that was in force then. Unknown
|
|
762
|
+
* addresses and documents above your level are a 404.
|
|
763
|
+
*/
|
|
764
|
+
async get(slug, opts = {}) {
|
|
765
|
+
const at = opts.at instanceof Date ? opts.at.toISOString() : opts.at;
|
|
766
|
+
const qs = at ? `?at=${encodeURIComponent(at)}` : "";
|
|
767
|
+
return this.http.get(`/documents/${encodeURIComponent(slug)}${qs}`);
|
|
768
|
+
}
|
|
769
|
+
/** Every saved text of a document, newest first, with the date each took effect. */
|
|
770
|
+
async versions(slug) {
|
|
771
|
+
return this.http.get(`/documents/${encodeURIComponent(slug)}/versions`);
|
|
772
|
+
}
|
|
773
|
+
/** The document as it read in one version. */
|
|
774
|
+
async version(slug, version) {
|
|
775
|
+
return this.http.get(`/documents/${encodeURIComponent(slug)}/versions/${version}`);
|
|
776
|
+
}
|
|
777
|
+
/**
|
|
778
|
+
* Absolute URL for an image path returned inside a document (`cover_url`,
|
|
779
|
+
* or an image block's `url`). Handy when the app renders on a different
|
|
780
|
+
* origin than the API.
|
|
781
|
+
*/
|
|
782
|
+
imageUrl(baseUrl, path) {
|
|
783
|
+
if (/^https?:\/\//i.test(path)) return path;
|
|
784
|
+
return `${baseUrl.replace(/\/$/, "")}${path.startsWith("/") ? "" : "/"}${path}`;
|
|
785
|
+
}
|
|
786
|
+
};
|
|
787
|
+
|
|
511
788
|
// src/resources/subscriptions.ts
|
|
512
789
|
var SubscriptionsResource = class {
|
|
513
790
|
constructor(http) {
|
|
@@ -761,8 +1038,120 @@ var DevicesResource = class {
|
|
|
761
1038
|
}
|
|
762
1039
|
};
|
|
763
1040
|
|
|
1041
|
+
// src/resources/attribution.ts
|
|
1042
|
+
var AttributionResource = class {
|
|
1043
|
+
constructor(http) {
|
|
1044
|
+
this.http = http;
|
|
1045
|
+
}
|
|
1046
|
+
/** Record a visit. No session needed; safe to call on every page load. */
|
|
1047
|
+
async touch(input) {
|
|
1048
|
+
return this.http.post("/attribution/touches", { body: input, skipAuth: true });
|
|
1049
|
+
}
|
|
1050
|
+
/** Whether to ask the signed-in user how they heard about us. */
|
|
1051
|
+
async status() {
|
|
1052
|
+
return this.http.get("/me/attribution");
|
|
1053
|
+
}
|
|
1054
|
+
/** Answer the question once. Send `"skipped"` when the user closes it.
|
|
1055
|
+
* `otherText` is kept only with `"other"`, up to 500 characters.
|
|
1056
|
+
* Errors: 400 `validation`, 409 `survey_answered`. */
|
|
1057
|
+
async answerSurvey(answer, otherText) {
|
|
1058
|
+
const body = { answer };
|
|
1059
|
+
if (otherText !== void 0) body.other_text = otherText;
|
|
1060
|
+
return this.http.put("/me/attribution/survey", { body });
|
|
1061
|
+
}
|
|
1062
|
+
};
|
|
1063
|
+
function tgWebApp() {
|
|
1064
|
+
return globalThis.Telegram?.WebApp?.initDataUnsafe;
|
|
1065
|
+
}
|
|
1066
|
+
function readCookie(name) {
|
|
1067
|
+
const doc = globalThis.document;
|
|
1068
|
+
if (!doc?.cookie) return void 0;
|
|
1069
|
+
for (const part of doc.cookie.split(";")) {
|
|
1070
|
+
const [k, ...v] = part.trim().split("=");
|
|
1071
|
+
if (k === name) return decodeURIComponent(v.join("="));
|
|
1072
|
+
}
|
|
1073
|
+
return void 0;
|
|
1074
|
+
}
|
|
1075
|
+
var KEY_SHAPE = /^[A-Za-z0-9_-]{8,64}$/;
|
|
1076
|
+
function anonymousKey(opts = {}) {
|
|
1077
|
+
const tgId = tgWebApp()?.user?.id;
|
|
1078
|
+
if (tgId) return `tg:${tgId}`;
|
|
1079
|
+
const g = globalThis;
|
|
1080
|
+
if (!g.document) return void 0;
|
|
1081
|
+
const name = opts.name ?? "takeal_anon";
|
|
1082
|
+
let stored;
|
|
1083
|
+
try {
|
|
1084
|
+
stored = g.localStorage?.getItem(name) ?? void 0;
|
|
1085
|
+
} catch {
|
|
1086
|
+
stored = void 0;
|
|
1087
|
+
}
|
|
1088
|
+
const fromCookie = readCookie(name);
|
|
1089
|
+
let key = [fromCookie, stored].find((k) => !!k && KEY_SHAPE.test(k));
|
|
1090
|
+
if (!key) {
|
|
1091
|
+
key = g.crypto?.randomUUID?.() ?? `${Date.now().toString(36)}-${Math.random().toString(36).slice(2, 14)}`;
|
|
1092
|
+
}
|
|
1093
|
+
try {
|
|
1094
|
+
g.localStorage?.setItem(name, key);
|
|
1095
|
+
} catch {
|
|
1096
|
+
}
|
|
1097
|
+
const domain = opts.cookieDomain ? `; domain=${opts.cookieDomain}` : "";
|
|
1098
|
+
g.document.cookie = `${name}=${encodeURIComponent(key)}; max-age=31536000; path=/; SameSite=Lax${domain}`;
|
|
1099
|
+
return key;
|
|
1100
|
+
}
|
|
1101
|
+
function currentTouch() {
|
|
1102
|
+
const g = globalThis;
|
|
1103
|
+
const tg = tgWebApp();
|
|
1104
|
+
const out = {};
|
|
1105
|
+
if (g.location?.href) out.url = g.location.href;
|
|
1106
|
+
if (g.document?.referrer) out.referrer = g.document.referrer;
|
|
1107
|
+
if (tg?.start_param) out.campaign_code = tg.start_param;
|
|
1108
|
+
if (tg?.user?.id) out.platform = "miniapp";
|
|
1109
|
+
const ym = readCookie("_ym_uid");
|
|
1110
|
+
if (ym) out.metrika_client_id = ym;
|
|
1111
|
+
const ga = readCookie("_ga")?.split(".").slice(-2).join(".");
|
|
1112
|
+
if (ga) out.ga_client_id = ga;
|
|
1113
|
+
return out;
|
|
1114
|
+
}
|
|
1115
|
+
|
|
1116
|
+
// src/resources/history.ts
|
|
1117
|
+
var HistoryResource = class {
|
|
1118
|
+
constructor(http) {
|
|
1119
|
+
this.http = http;
|
|
1120
|
+
}
|
|
1121
|
+
/** One page of the history. Errors: 400 bad cursor or limit, 404 `cardId` is not the user's card. */
|
|
1122
|
+
async list(params = {}) {
|
|
1123
|
+
const q = new URLSearchParams();
|
|
1124
|
+
if (params.cardId) q.set("card_id", params.cardId);
|
|
1125
|
+
if (params.cursor) q.set("cursor", params.cursor);
|
|
1126
|
+
if (params.limit !== void 0) q.set("limit", String(params.limit));
|
|
1127
|
+
if (params.lang) q.set("lang", params.lang);
|
|
1128
|
+
const qs = q.toString();
|
|
1129
|
+
return this.http.get(`/me/history${qs ? `?${qs}` : ""}`, { signal: params.signal });
|
|
1130
|
+
}
|
|
1131
|
+
/** Every entry, page after page, newest first. */
|
|
1132
|
+
async *all(params = {}) {
|
|
1133
|
+
let cursor;
|
|
1134
|
+
do {
|
|
1135
|
+
const page2 = await this.list({ ...params, cursor });
|
|
1136
|
+
yield* page2.items;
|
|
1137
|
+
cursor = page2.next_cursor ?? void 0;
|
|
1138
|
+
} while (cursor);
|
|
1139
|
+
}
|
|
1140
|
+
};
|
|
1141
|
+
|
|
1142
|
+
// src/resources/funding-options.ts
|
|
1143
|
+
var FundingOptionsResource = class {
|
|
1144
|
+
constructor(http) {
|
|
1145
|
+
this.http = http;
|
|
1146
|
+
}
|
|
1147
|
+
/** The ways to top up, preferred first. Empty when none is configured. */
|
|
1148
|
+
async list() {
|
|
1149
|
+
return this.http.get("/me/funding-options");
|
|
1150
|
+
}
|
|
1151
|
+
};
|
|
1152
|
+
|
|
764
1153
|
// src/version.ts
|
|
765
|
-
var SDK_VERSION = "0.
|
|
1154
|
+
var SDK_VERSION = "0.5.0";
|
|
766
1155
|
|
|
767
1156
|
// src/client-platform.ts
|
|
768
1157
|
var CLIENT_HEADER = "X-Takeal-Client";
|
|
@@ -836,9 +1225,482 @@ function isAbsolute(url) {
|
|
|
836
1225
|
return /^(?:[a-z][a-z0-9+.-]*:|\/\/)/i.test(url);
|
|
837
1226
|
}
|
|
838
1227
|
|
|
1228
|
+
// src/compat.ts
|
|
1229
|
+
var SUPPORTED_MEISTER = ">=0.5.0, <0.6.0";
|
|
1230
|
+
var SEMVER = /^v?(0|[1-9]\d*)\.(0|[1-9]\d*)\.(0|[1-9]\d*)(?:-([0-9A-Za-z.-]+))?(?:\+[0-9A-Za-z.-]+)?$/;
|
|
1231
|
+
function parse(v) {
|
|
1232
|
+
const m = SEMVER.exec(v.trim());
|
|
1233
|
+
if (!m) return null;
|
|
1234
|
+
return { core: [Number(m[1]), Number(m[2]), Number(m[3])], pre: m[4] ?? null };
|
|
1235
|
+
}
|
|
1236
|
+
function cmpCore(a, b) {
|
|
1237
|
+
for (let i = 0; i < 3; i++) {
|
|
1238
|
+
if (a.core[i] !== b.core[i]) return a.core[i] < b.core[i] ? -1 : 1;
|
|
1239
|
+
}
|
|
1240
|
+
return 0;
|
|
1241
|
+
}
|
|
1242
|
+
function satisfies(version, range) {
|
|
1243
|
+
const v = parse(version);
|
|
1244
|
+
if (!v) return false;
|
|
1245
|
+
const parts = range.split(",").map((p) => p.trim()).filter(Boolean);
|
|
1246
|
+
if (parts.length === 0) return false;
|
|
1247
|
+
let exactPre = false;
|
|
1248
|
+
for (const part of parts) {
|
|
1249
|
+
const m = /^(>=|<=|>|<|=)?\s*(.+)$/.exec(part);
|
|
1250
|
+
if (!m) return false;
|
|
1251
|
+
const op = m[1] ?? "=";
|
|
1252
|
+
const target = parse(m[2]);
|
|
1253
|
+
if (!target) return false;
|
|
1254
|
+
const c = cmpCore(v, target);
|
|
1255
|
+
if (op === "=") {
|
|
1256
|
+
if (c !== 0 || v.pre !== target.pre) return false;
|
|
1257
|
+
if (v.pre !== null) exactPre = true;
|
|
1258
|
+
continue;
|
|
1259
|
+
}
|
|
1260
|
+
const ok = op === ">=" ? c >= 0 : op === ">" ? c > 0 : op === "<=" ? c <= 0 : c < 0;
|
|
1261
|
+
if (!ok) return false;
|
|
1262
|
+
}
|
|
1263
|
+
return v.pre === null || exactPre;
|
|
1264
|
+
}
|
|
1265
|
+
function readyInfo(raw, healthy) {
|
|
1266
|
+
const reported = raw?.ops?.platform_version;
|
|
1267
|
+
const platformVersion = typeof reported === "string" && reported ? reported : null;
|
|
1268
|
+
const base = {
|
|
1269
|
+
platformVersion,
|
|
1270
|
+
supportedMeister: SUPPORTED_MEISTER,
|
|
1271
|
+
healthy,
|
|
1272
|
+
status: typeof raw?.status === "string" ? raw.status : healthy ? "ready" : "degraded",
|
|
1273
|
+
raw
|
|
1274
|
+
};
|
|
1275
|
+
if (platformVersion === null) {
|
|
1276
|
+
return {
|
|
1277
|
+
...base,
|
|
1278
|
+
compatible: false,
|
|
1279
|
+
warning: `The platform didn't report its version; this SDK supports ${SUPPORTED_MEISTER}.`
|
|
1280
|
+
};
|
|
1281
|
+
}
|
|
1282
|
+
if (!satisfies(platformVersion, SUPPORTED_MEISTER)) {
|
|
1283
|
+
return {
|
|
1284
|
+
...base,
|
|
1285
|
+
compatible: false,
|
|
1286
|
+
warning: `This SDK supports platform ${SUPPORTED_MEISTER}, the platform runs ${platformVersion}. Some calls may fail until the SDK is updated.`
|
|
1287
|
+
};
|
|
1288
|
+
}
|
|
1289
|
+
return { ...base, compatible: true };
|
|
1290
|
+
}
|
|
1291
|
+
async function fetchReady(http, opts = {}) {
|
|
1292
|
+
try {
|
|
1293
|
+
const body = await http.get("/ready", { skipAuth: true, signal: opts.signal });
|
|
1294
|
+
return readyInfo(body ?? {}, true);
|
|
1295
|
+
} catch (e) {
|
|
1296
|
+
if (isApiError(e) && e.status === 503 && typeof e.body === "object" && e.body !== null) {
|
|
1297
|
+
return readyInfo(e.body, false);
|
|
1298
|
+
}
|
|
1299
|
+
throw e;
|
|
1300
|
+
}
|
|
1301
|
+
}
|
|
1302
|
+
|
|
1303
|
+
// src/analytics.ts
|
|
1304
|
+
var ANALYTICS_EVENTS = [
|
|
1305
|
+
"signup_started",
|
|
1306
|
+
"signup_completed",
|
|
1307
|
+
"signup",
|
|
1308
|
+
"login",
|
|
1309
|
+
"deposit_started",
|
|
1310
|
+
"deposit_confirmed",
|
|
1311
|
+
"deposit_failed",
|
|
1312
|
+
"card_issued",
|
|
1313
|
+
"card_issue_failed",
|
|
1314
|
+
"card_activated",
|
|
1315
|
+
"card_topped_up",
|
|
1316
|
+
"card_transferred",
|
|
1317
|
+
"card_frozen",
|
|
1318
|
+
"card_unfrozen",
|
|
1319
|
+
"card_terminated",
|
|
1320
|
+
"txn_cleared",
|
|
1321
|
+
"txn_declined",
|
|
1322
|
+
"subscription_started",
|
|
1323
|
+
"subscription_renewed",
|
|
1324
|
+
"subscription_cancelled",
|
|
1325
|
+
"fee_charged",
|
|
1326
|
+
"refund_issued"
|
|
1327
|
+
];
|
|
1328
|
+
var METRIKA_GOALS = ["signup_started", "signup_completed"];
|
|
1329
|
+
var NO_CAPTURE_CLASS = "ph-no-capture";
|
|
1330
|
+
var UUID = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi;
|
|
1331
|
+
var EMAIL = /[^\s@"'<>(),;:]+@[^\s@"'<>(),;:]+\.[a-z]{2,}/gi;
|
|
1332
|
+
var DIGIT_RUN = /\+?\d[\d\s().-]{7,}\d/g;
|
|
1333
|
+
var UUID_ONLY = /^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i;
|
|
1334
|
+
function isId(v) {
|
|
1335
|
+
return /^\d+$/.test(v) || UUID_ONLY.test(v) || /^[0-9a-f]{16,}$/i.test(v) || /^[A-Za-z0-9_]{20,}$/.test(v) && /\d.*\d/.test(v) && /[A-Za-z].*[A-Za-z]/.test(v);
|
|
1336
|
+
}
|
|
1337
|
+
var PLACEHOLDER = ":id";
|
|
1338
|
+
var PERSONAL_WORDS = /* @__PURE__ */ new Set([
|
|
1339
|
+
"email",
|
|
1340
|
+
"mail",
|
|
1341
|
+
"phone",
|
|
1342
|
+
"tel",
|
|
1343
|
+
"telephone",
|
|
1344
|
+
"mobile",
|
|
1345
|
+
"msisdn",
|
|
1346
|
+
"surname",
|
|
1347
|
+
"patronymic",
|
|
1348
|
+
"firstname",
|
|
1349
|
+
"lastname",
|
|
1350
|
+
"fullname",
|
|
1351
|
+
"username",
|
|
1352
|
+
"nickname"
|
|
1353
|
+
]);
|
|
1354
|
+
var PERSON_NAME_QUALIFIERS = /* @__PURE__ */ new Set([
|
|
1355
|
+
"first",
|
|
1356
|
+
"last",
|
|
1357
|
+
"full",
|
|
1358
|
+
"user",
|
|
1359
|
+
"display",
|
|
1360
|
+
"given",
|
|
1361
|
+
"family",
|
|
1362
|
+
"middle",
|
|
1363
|
+
"nick",
|
|
1364
|
+
"real",
|
|
1365
|
+
"holder",
|
|
1366
|
+
"cardholder",
|
|
1367
|
+
"customer",
|
|
1368
|
+
"contact",
|
|
1369
|
+
"person",
|
|
1370
|
+
"owner",
|
|
1371
|
+
"account",
|
|
1372
|
+
"legal"
|
|
1373
|
+
]);
|
|
1374
|
+
var SECRET_QUERY_WORDS = /* @__PURE__ */ new Set([
|
|
1375
|
+
"token",
|
|
1376
|
+
"code",
|
|
1377
|
+
"key",
|
|
1378
|
+
"secret",
|
|
1379
|
+
"password",
|
|
1380
|
+
"pass",
|
|
1381
|
+
"pwd",
|
|
1382
|
+
"otp",
|
|
1383
|
+
"sig",
|
|
1384
|
+
"signature",
|
|
1385
|
+
"session",
|
|
1386
|
+
"sid",
|
|
1387
|
+
"auth",
|
|
1388
|
+
"jwt",
|
|
1389
|
+
"pan",
|
|
1390
|
+
"cvv",
|
|
1391
|
+
"cvc",
|
|
1392
|
+
"iban"
|
|
1393
|
+
]);
|
|
1394
|
+
var MONEY_KEYS = /* @__PURE__ */ new Set(["amount", "amount_minor", "currency", "value", "price", "revenue", "sum"]);
|
|
1395
|
+
function words(key) {
|
|
1396
|
+
return key.replace(/^\$+/, "").replace(/([a-z])([A-Z])/g, "$1_$2").toLowerCase().split(/[^a-z0-9]+/).filter(Boolean);
|
|
1397
|
+
}
|
|
1398
|
+
function personalKey(key) {
|
|
1399
|
+
const w = words(key);
|
|
1400
|
+
const joined = w.join("");
|
|
1401
|
+
if (joined.includes("email") || joined.includes("phone")) return true;
|
|
1402
|
+
if (w.some((x) => PERSONAL_WORDS.has(x)) || PERSONAL_WORDS.has(joined)) return true;
|
|
1403
|
+
if (key.startsWith("$")) return false;
|
|
1404
|
+
return w.some((x, i) => x === "name" && (w.length === 1 || PERSON_NAME_QUALIFIERS.has(w[i - 1] ?? "")));
|
|
1405
|
+
}
|
|
1406
|
+
function urlKey(key) {
|
|
1407
|
+
const k = key.replace(/^\$+/, "").toLowerCase();
|
|
1408
|
+
return /(^|_)(url|href|pathname|path|referrer|referer)$/.test(k) || k === "page" || k.startsWith("attr__href");
|
|
1409
|
+
}
|
|
1410
|
+
function digitCount(s) {
|
|
1411
|
+
return s.replace(/\D/g, "").length;
|
|
1412
|
+
}
|
|
1413
|
+
function redactText(v) {
|
|
1414
|
+
return v.replace(EMAIL, "[email]").replace(DIGIT_RUN, (m) => digitCount(m) >= 9 && digitCount(m) <= 19 ? "[number]" : m);
|
|
1415
|
+
}
|
|
1416
|
+
function idSegment(seg) {
|
|
1417
|
+
let s = seg;
|
|
1418
|
+
try {
|
|
1419
|
+
s = decodeURIComponent(seg);
|
|
1420
|
+
} catch {
|
|
1421
|
+
}
|
|
1422
|
+
if (isId(s)) return PLACEHOLDER;
|
|
1423
|
+
const replaced = s.replace(UUID, PLACEHOLDER);
|
|
1424
|
+
if (replaced !== s) return replaced;
|
|
1425
|
+
return redactText(s) === s ? seg : PLACEHOLDER;
|
|
1426
|
+
}
|
|
1427
|
+
function sanitizeUrl(raw) {
|
|
1428
|
+
const absolute = /^[a-z][a-z0-9+.-]*:\/\//i.test(raw);
|
|
1429
|
+
let u;
|
|
1430
|
+
try {
|
|
1431
|
+
u = new URL(raw, "http://relative.invalid");
|
|
1432
|
+
} catch {
|
|
1433
|
+
return redactText(raw.split(/[?#]/)[0] ?? "").replace(UUID, PLACEHOLDER);
|
|
1434
|
+
}
|
|
1435
|
+
const path = u.pathname.split("/").map((seg) => seg ? idSegment(seg) : seg).join("/");
|
|
1436
|
+
const query = [];
|
|
1437
|
+
u.searchParams.forEach((value, key) => {
|
|
1438
|
+
const k = words(key);
|
|
1439
|
+
if (k.some((w) => SECRET_QUERY_WORDS.has(w)) || personalKey(key)) return;
|
|
1440
|
+
if (redactText(value) !== value) return;
|
|
1441
|
+
query.push(`${encodeURIComponent(key)}=${isId(value) ? PLACEHOLDER : encodeURIComponent(value)}`);
|
|
1442
|
+
});
|
|
1443
|
+
const search = query.length ? `?${query.join("&")}` : "";
|
|
1444
|
+
return (absolute ? `${u.protocol}//${u.host}` : "") + path + search;
|
|
1445
|
+
}
|
|
1446
|
+
function cleanValue(key, v, depth) {
|
|
1447
|
+
if (v === null || v === void 0 || typeof v === "number" || typeof v === "boolean") return v;
|
|
1448
|
+
if (typeof v === "string") {
|
|
1449
|
+
if (MONEY_KEYS.has(key.toLowerCase()) || UUID_ONLY.test(v)) return v;
|
|
1450
|
+
if (urlKey(key) || /^https?:\/\//i.test(v)) return sanitizeUrl(v);
|
|
1451
|
+
if (key === "$elements_chain") {
|
|
1452
|
+
return redactText(v).replace(/attr__href="([^"]*)"/g, (_, h) => `attr__href="${sanitizeUrl(h)}"`);
|
|
1453
|
+
}
|
|
1454
|
+
const r = redactText(v);
|
|
1455
|
+
return r.replace(/\[(email|number)\]/g, "").trim() === "" && r !== v ? void 0 : r;
|
|
1456
|
+
}
|
|
1457
|
+
if (depth > 5) return void 0;
|
|
1458
|
+
if (Array.isArray(v)) return v.map((x) => cleanValue(key, x, depth + 1)).filter((x) => x !== void 0);
|
|
1459
|
+
if (typeof v === "object") return sanitizeProperties(v, depth + 1);
|
|
1460
|
+
return void 0;
|
|
1461
|
+
}
|
|
1462
|
+
function sanitizeProperties(props, depth = 0) {
|
|
1463
|
+
const out = {};
|
|
1464
|
+
for (const [k, v] of Object.entries(props)) {
|
|
1465
|
+
if (personalKey(k)) continue;
|
|
1466
|
+
const c = cleanValue(k, v, depth);
|
|
1467
|
+
if (c !== void 0) out[k] = c;
|
|
1468
|
+
}
|
|
1469
|
+
return out;
|
|
1470
|
+
}
|
|
1471
|
+
function beforeSend(event) {
|
|
1472
|
+
if (!event) return event;
|
|
1473
|
+
const out = { ...event };
|
|
1474
|
+
if (event.properties) out.properties = sanitizeProperties(event.properties);
|
|
1475
|
+
if (event.$set) out.$set = sanitizeProperties(event.$set);
|
|
1476
|
+
if (event.$set_once) out.$set_once = sanitizeProperties(event.$set_once);
|
|
1477
|
+
return out;
|
|
1478
|
+
}
|
|
1479
|
+
var win = () => globalThis;
|
|
1480
|
+
function injectScript(src, onLoad, onError) {
|
|
1481
|
+
const doc = win().document;
|
|
1482
|
+
if (!doc) return;
|
|
1483
|
+
const s = doc.createElement("script");
|
|
1484
|
+
s.async = true;
|
|
1485
|
+
s.src = src;
|
|
1486
|
+
s.crossOrigin = "anonymous";
|
|
1487
|
+
if (onLoad) s.addEventListener("load", onLoad);
|
|
1488
|
+
if (onError) s.addEventListener("error", onError);
|
|
1489
|
+
(doc.head ?? doc.documentElement).appendChild(s);
|
|
1490
|
+
}
|
|
1491
|
+
function posthogConfig(zone, o) {
|
|
1492
|
+
const host = (o.host ?? "https://eu.i.posthog.com").replace(/\/+$/, "");
|
|
1493
|
+
const base = {
|
|
1494
|
+
api_host: host,
|
|
1495
|
+
ui_host: o.uiHost ?? "https://eu.posthog.com",
|
|
1496
|
+
// Profiles for signed-in users only.
|
|
1497
|
+
person_profiles: "identified_only",
|
|
1498
|
+
// Page views go through `page()`, with a cleaned address.
|
|
1499
|
+
capture_pageview: false,
|
|
1500
|
+
capture_pageleave: true,
|
|
1501
|
+
before_send: beforeSend
|
|
1502
|
+
};
|
|
1503
|
+
return { ...base, ...zoneConfig(zone, o) };
|
|
1504
|
+
}
|
|
1505
|
+
function zoneConfig(zone, o) {
|
|
1506
|
+
if (zone === "public") {
|
|
1507
|
+
return {
|
|
1508
|
+
autocapture: true,
|
|
1509
|
+
mask_all_text: false,
|
|
1510
|
+
mask_all_element_attributes: false,
|
|
1511
|
+
enable_heatmaps: true,
|
|
1512
|
+
disable_session_recording: true
|
|
1513
|
+
};
|
|
1514
|
+
}
|
|
1515
|
+
return {
|
|
1516
|
+
// A click is "the third button in the cards block", never its label.
|
|
1517
|
+
autocapture: { capture_copied_text: false },
|
|
1518
|
+
mask_all_text: true,
|
|
1519
|
+
mask_all_element_attributes: true,
|
|
1520
|
+
enable_heatmaps: false,
|
|
1521
|
+
disable_session_recording: !o.sessionRecording,
|
|
1522
|
+
session_recording: {
|
|
1523
|
+
maskAllInputs: true,
|
|
1524
|
+
maskTextSelector: "*",
|
|
1525
|
+
blockClass: NO_CAPTURE_CLASS
|
|
1526
|
+
}
|
|
1527
|
+
};
|
|
1528
|
+
}
|
|
1529
|
+
function assetsHost(o) {
|
|
1530
|
+
if (o.assetsHost) return o.assetsHost.replace(/\/+$/, "");
|
|
1531
|
+
const host = (o.host ?? "https://eu.i.posthog.com").replace(/\/+$/, "");
|
|
1532
|
+
return host.replace(".i.posthog.com", "-assets.i.posthog.com");
|
|
1533
|
+
}
|
|
1534
|
+
function loadPostHogScript(o, config) {
|
|
1535
|
+
return new Promise((resolve) => {
|
|
1536
|
+
const w = win();
|
|
1537
|
+
if (!w.document) return resolve(void 0);
|
|
1538
|
+
const placeholder = Object.assign([], { __SV: 1, _i: [[o.key, config, "posthog"]] });
|
|
1539
|
+
w.posthog = placeholder;
|
|
1540
|
+
injectScript(
|
|
1541
|
+
`${assetsHost(o)}/static/array.js`,
|
|
1542
|
+
() => {
|
|
1543
|
+
const ph = w.posthog;
|
|
1544
|
+
const live = ph !== placeholder && typeof ph?.capture === "function";
|
|
1545
|
+
resolve(live ? ph : void 0);
|
|
1546
|
+
},
|
|
1547
|
+
() => resolve(void 0)
|
|
1548
|
+
);
|
|
1549
|
+
});
|
|
1550
|
+
}
|
|
1551
|
+
var PostHogSink = class {
|
|
1552
|
+
constructor(o, zone) {
|
|
1553
|
+
this.o = o;
|
|
1554
|
+
const config = posthogConfig(zone, o);
|
|
1555
|
+
this.ready = (o.load ? o.load().then((ph) => {
|
|
1556
|
+
ph.init(o.key, config);
|
|
1557
|
+
return ph;
|
|
1558
|
+
}) : loadPostHogScript(o, config)).then((ph) => {
|
|
1559
|
+
ph?.register({ zone });
|
|
1560
|
+
return ph;
|
|
1561
|
+
}).catch(() => void 0);
|
|
1562
|
+
}
|
|
1563
|
+
with(fn) {
|
|
1564
|
+
void this.ready.then((ph) => ph && fn(ph));
|
|
1565
|
+
}
|
|
1566
|
+
capture(event, props) {
|
|
1567
|
+
this.with((ph) => ph.capture(event, props));
|
|
1568
|
+
}
|
|
1569
|
+
page(url, referrer) {
|
|
1570
|
+
const props = { $current_url: url };
|
|
1571
|
+
if (referrer) props.$referrer = referrer;
|
|
1572
|
+
this.with((ph) => ph.capture("$pageview", props));
|
|
1573
|
+
}
|
|
1574
|
+
identify(userId) {
|
|
1575
|
+
this.with((ph) => ph.identify(userId));
|
|
1576
|
+
}
|
|
1577
|
+
reset() {
|
|
1578
|
+
this.with((ph) => ph.reset());
|
|
1579
|
+
}
|
|
1580
|
+
setZone(zone) {
|
|
1581
|
+
this.with((ph) => {
|
|
1582
|
+
ph.set_config(zoneConfig(zone, this.o));
|
|
1583
|
+
ph.register({ zone });
|
|
1584
|
+
if (zone === "public" || !this.o.sessionRecording) ph.stopSessionRecording?.();
|
|
1585
|
+
else ph.startSessionRecording?.();
|
|
1586
|
+
});
|
|
1587
|
+
}
|
|
1588
|
+
};
|
|
1589
|
+
var MetrikaSink = class {
|
|
1590
|
+
constructor(o) {
|
|
1591
|
+
this.live = true;
|
|
1592
|
+
this.id = Number(o.counterId);
|
|
1593
|
+
const w = win();
|
|
1594
|
+
if (!w.ym) {
|
|
1595
|
+
const ym = ((...args) => {
|
|
1596
|
+
(ym.a = ym.a ?? []).push(args);
|
|
1597
|
+
});
|
|
1598
|
+
ym.l = Date.now();
|
|
1599
|
+
w.ym = ym;
|
|
1600
|
+
injectScript(o.scriptUrl ?? "https://mc.yandex.ru/metrika/tag.js");
|
|
1601
|
+
}
|
|
1602
|
+
this.ym("init", {
|
|
1603
|
+
defer: true,
|
|
1604
|
+
webvisor: false,
|
|
1605
|
+
clickmap: false,
|
|
1606
|
+
trackLinks: false,
|
|
1607
|
+
accurateTrackBounce: true
|
|
1608
|
+
});
|
|
1609
|
+
}
|
|
1610
|
+
ym(...args) {
|
|
1611
|
+
if (this.live) win().ym?.(this.id, ...args);
|
|
1612
|
+
}
|
|
1613
|
+
capture(event, props) {
|
|
1614
|
+
if (METRIKA_GOALS.includes(event)) this.ym("reachGoal", event, props);
|
|
1615
|
+
}
|
|
1616
|
+
page(url, referrer) {
|
|
1617
|
+
this.ym("hit", url, referrer ? { referer: referrer } : {});
|
|
1618
|
+
}
|
|
1619
|
+
identify(userId) {
|
|
1620
|
+
this.ym("setUserID", userId);
|
|
1621
|
+
}
|
|
1622
|
+
reset() {
|
|
1623
|
+
}
|
|
1624
|
+
setZone(zone) {
|
|
1625
|
+
this.live = zone === "public";
|
|
1626
|
+
}
|
|
1627
|
+
};
|
|
1628
|
+
var KEY = /* @__PURE__ */ Symbol.for("takeal.cusfront-sdk.analytics");
|
|
1629
|
+
var holder = globalThis;
|
|
1630
|
+
var state = () => holder[KEY];
|
|
1631
|
+
function sinks(s) {
|
|
1632
|
+
if (s.zone === "public" && s.options.metrika && !s.metrika) {
|
|
1633
|
+
s.metrika = new MetrikaSink(s.options.metrika);
|
|
1634
|
+
if (s.userId) s.metrika.identify(s.userId);
|
|
1635
|
+
}
|
|
1636
|
+
return [s.posthog, s.metrika].filter((x) => !!x);
|
|
1637
|
+
}
|
|
1638
|
+
function initAnalytics(options) {
|
|
1639
|
+
if (state() || !win().document) return;
|
|
1640
|
+
if (options.zone !== "public" && win().ym) {
|
|
1641
|
+
console.warn("[analytics] Yandex Metrica is on a page outside the public zone; it must not be.");
|
|
1642
|
+
}
|
|
1643
|
+
const s = { options, zone: options.zone };
|
|
1644
|
+
holder[KEY] = s;
|
|
1645
|
+
if (options.posthog?.key) s.posthog = new PostHogSink(options.posthog, options.zone);
|
|
1646
|
+
sinks(s);
|
|
1647
|
+
if (options.initialPageview !== false) page();
|
|
1648
|
+
}
|
|
1649
|
+
function setAnalyticsZone(zone) {
|
|
1650
|
+
const s = state();
|
|
1651
|
+
if (!s || s.zone === zone) return;
|
|
1652
|
+
s.zone = zone;
|
|
1653
|
+
for (const sink of sinks(s)) sink.setZone(zone);
|
|
1654
|
+
}
|
|
1655
|
+
function track(event, props = {}) {
|
|
1656
|
+
const s = state();
|
|
1657
|
+
if (!s || !ANALYTICS_EVENTS.includes(event)) return;
|
|
1658
|
+
const clean = sanitizeProperties(props);
|
|
1659
|
+
for (const sink of sinks(s)) sink.capture(event, clean);
|
|
1660
|
+
}
|
|
1661
|
+
function page(url) {
|
|
1662
|
+
const s = state();
|
|
1663
|
+
const w = win();
|
|
1664
|
+
const raw = url ?? w.location?.href;
|
|
1665
|
+
if (!s || !raw) return;
|
|
1666
|
+
const clean = sanitizeUrl(raw);
|
|
1667
|
+
if (clean === s.lastPage) return;
|
|
1668
|
+
const referrer = s.lastPage ?? (w.document?.referrer ? sanitizeUrl(w.document.referrer) : void 0);
|
|
1669
|
+
s.lastPage = clean;
|
|
1670
|
+
for (const sink of sinks(s)) sink.page(clean, referrer);
|
|
1671
|
+
}
|
|
1672
|
+
function identify(userId) {
|
|
1673
|
+
const s = state();
|
|
1674
|
+
if (!s || !userId) return;
|
|
1675
|
+
s.userId = userId;
|
|
1676
|
+
for (const sink of sinks(s)) sink.identify(userId);
|
|
1677
|
+
}
|
|
1678
|
+
function resetAnalytics() {
|
|
1679
|
+
const s = state();
|
|
1680
|
+
if (!s) return;
|
|
1681
|
+
s.userId = void 0;
|
|
1682
|
+
for (const sink of sinks(s)) sink.reset();
|
|
1683
|
+
}
|
|
1684
|
+
async function posthogDistinctId(timeoutMs = 3e3) {
|
|
1685
|
+
const ready = state()?.posthog?.ready;
|
|
1686
|
+
if (!ready) return void 0;
|
|
1687
|
+
let timer;
|
|
1688
|
+
const timeout = new Promise((r) => {
|
|
1689
|
+
timer = setTimeout(r, timeoutMs);
|
|
1690
|
+
});
|
|
1691
|
+
const ph = await Promise.race([ready, timeout]);
|
|
1692
|
+
clearTimeout(timer);
|
|
1693
|
+
try {
|
|
1694
|
+
return ph?.get_distinct_id() || void 0;
|
|
1695
|
+
} catch {
|
|
1696
|
+
return void 0;
|
|
1697
|
+
}
|
|
1698
|
+
}
|
|
1699
|
+
|
|
839
1700
|
// src/index.ts
|
|
840
1701
|
function createClient(opts) {
|
|
841
1702
|
const tokens = opts.tokenStore ?? pickDefaultStore();
|
|
1703
|
+
const remembered = opts.rememberStore ?? pickDefaultStore("takeal_remember");
|
|
842
1704
|
const fetchImpl = opts.fetch ?? defaultFetch();
|
|
843
1705
|
const client = resolveClientDescriptor(opts.client);
|
|
844
1706
|
const http = new HttpClient(opts.baseUrl, tokens, fetchImpl, {
|
|
@@ -849,24 +1711,33 @@ function createClient(opts) {
|
|
|
849
1711
|
client,
|
|
850
1712
|
tokens,
|
|
851
1713
|
assetUrl: (url) => resolveAssetUrl(opts.baseUrl, url),
|
|
852
|
-
|
|
1714
|
+
ready: (o) => fetchReady(http, o),
|
|
1715
|
+
auth: new AuthResource(http, tokens, remembered),
|
|
853
1716
|
deposits: new DepositsResource(http),
|
|
1717
|
+
fundingOptions: new FundingOptionsResource(http),
|
|
854
1718
|
cards: new CardsResource(http),
|
|
855
1719
|
balance: new BalanceResource(http),
|
|
1720
|
+
bonus: new BonusResource(http),
|
|
1721
|
+
codes: new CodesResource(http),
|
|
1722
|
+
referral: new ReferralResource(http),
|
|
1723
|
+
subscription: new SubscriptionResource(http),
|
|
856
1724
|
wallet: new WalletResource(http),
|
|
857
1725
|
branding: new BrandingResource(http),
|
|
1726
|
+
documents: new DocumentsResource(http),
|
|
858
1727
|
blog: new BlogResource(http),
|
|
859
1728
|
subscriptions: new SubscriptionsResource(http),
|
|
860
1729
|
sessions: new SessionsResource(http),
|
|
861
1730
|
push: new PushResource(http),
|
|
862
1731
|
me: new MeResource(http),
|
|
863
1732
|
notifications: new NotificationsResource(http),
|
|
864
|
-
devices: new DevicesResource(http, client)
|
|
1733
|
+
devices: new DevicesResource(http, client),
|
|
1734
|
+
attribution: new AttributionResource(http),
|
|
1735
|
+
history: new HistoryResource(http)
|
|
865
1736
|
};
|
|
866
1737
|
}
|
|
867
|
-
function pickDefaultStore() {
|
|
1738
|
+
function pickDefaultStore(key) {
|
|
868
1739
|
if (typeof globalThis !== "undefined" && "localStorage" in globalThis) {
|
|
869
|
-
return defaultBrowserStore();
|
|
1740
|
+
return defaultBrowserStore(key);
|
|
870
1741
|
}
|
|
871
1742
|
return inMemoryStore();
|
|
872
1743
|
}
|
|
@@ -879,6 +1750,6 @@ function defaultFetch() {
|
|
|
879
1750
|
);
|
|
880
1751
|
}
|
|
881
1752
|
|
|
882
|
-
export { ApiError, CLIENT_HEADER, NetworkError, SDK_VERSION, createClient, defaultBrowserStore, detectClientPlatform, inMemoryStore, isApiError, isCardOtp, isNetworkError, resolveAssetUrl };
|
|
1753
|
+
export { ANALYTICS_EVENTS, ApiError, CLIENT_HEADER, 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 };
|
|
883
1754
|
//# sourceMappingURL=index.js.map
|
|
884
1755
|
//# sourceMappingURL=index.js.map
|