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