@takeal/cusfront-sdk 0.8.3 → 0.9.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 +88 -1
- package/README.md +70 -12
- package/dist/analytics.cjs +74 -22
- package/dist/analytics.cjs.map +1 -1
- package/dist/analytics.d.cts +43 -4
- package/dist/analytics.d.ts +43 -4
- package/dist/analytics.js +71 -23
- package/dist/analytics.js.map +1 -1
- package/dist/{cards-BPu8Ill7.d.cts → cards-C5rk0XkI.d.cts} +83 -8
- package/dist/{cards-DP1fJc_c.d.ts → cards-CS-oxqLS.d.ts} +83 -8
- package/dist/index.cjs +122 -27
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +14 -6
- package/dist/index.d.ts +14 -6
- package/dist/index.js +119 -28
- package/dist/index.js.map +1 -1
- package/dist/react/index.d.cts +1 -1
- package/dist/react/index.d.ts +1 -1
- package/dist/resources/auth.cjs +28 -1
- package/dist/resources/auth.cjs.map +1 -1
- package/dist/resources/auth.d.cts +57 -5
- package/dist/resources/auth.d.ts +57 -5
- package/dist/resources/auth.js +28 -1
- package/dist/resources/auth.js.map +1 -1
- package/dist/resources/branding.cjs.map +1 -1
- package/dist/resources/branding.d.cts +6 -0
- package/dist/resources/branding.d.ts +6 -0
- package/dist/resources/branding.js.map +1 -1
- package/dist/resources/cards.cjs.map +1 -1
- package/dist/resources/cards.d.cts +1 -1
- package/dist/resources/cards.d.ts +1 -1
- package/dist/resources/cards.js.map +1 -1
- package/dist/resources/deposits.cjs.map +1 -1
- package/dist/resources/deposits.d.cts +1 -1
- package/dist/resources/deposits.d.ts +1 -1
- package/dist/resources/deposits.js.map +1 -1
- package/dist/resources/funding-options.d.cts +1 -1
- package/dist/resources/funding-options.d.ts +1 -1
- package/dist/resources/me.d.cts +1 -1
- package/dist/resources/me.d.ts +1 -1
- package/dist/resources/subscription.cjs.map +1 -1
- package/dist/resources/subscription.d.cts +4 -0
- package/dist/resources/subscription.d.ts +4 -0
- package/dist/resources/subscription.js.map +1 -1
- package/dist/telegram.cjs +48 -5
- package/dist/telegram.cjs.map +1 -1
- package/dist/telegram.d.cts +1 -1
- package/dist/telegram.d.ts +1 -1
- package/dist/telegram.js +48 -5
- package/dist/telegram.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { T as TokenStore, F as FetchLike } from './http-CL97TjMO.cjs';
|
|
2
2
|
export { d as defaultBrowserStore, i as inMemoryStore } from './http-CL97TjMO.cjs';
|
|
3
3
|
import { AuthResource } from './resources/auth.cjs';
|
|
4
|
-
export { ChangePasswordInput, ConfirmPasswordSetupInput, EmailChangeRequested, EmailCodeSent, EmailCodeSession, ExchangeTelegramInput, JwtIssued, LinkTelegramInput, LoginInput, LoginResponse, OtpSentResponse, PasswordSetupRequested, RegisterInput, RequestEmailCodeInput, Session, TelegramLink, TelegramUnknown, TotpRequired, TotpSetupComplete, TotpSetupRequired, User, VerifyEmailCodeInput } from './resources/auth.cjs';
|
|
5
|
-
import { b as DepositsResource, F as FundingOptionsResource, c as CardsResource } from './cards-
|
|
6
|
-
export { A as Address, B as BillingAddress, a as Card, d as CardBalance, e as CardDesignRef, f as CardForm, g as CardInTransit, h as CardLoadStatus, i as CardOrder, j as CardOrderError, k as CardOrderInput, l as CardOrderQuote, m as CardOrderQuoteInput, C as CardProduct,
|
|
4
|
+
export { ChangePasswordInput, ConfirmPasswordSetupInput, EmailChangeRequested, EmailCodeSent, EmailCodeSession, ExchangeTelegramInput, JwtIssued, LinkTelegramInput, LoginInput, LoginResponse, OtpSentResponse, PasswordSetupRequested, RegisterInput, RequestEmailCodeInput, Session, TelegramLink, TelegramUnknown, TotpRequired, TotpSetupComplete, TotpSetupEmailErrorCode, TotpSetupEmailInput, TotpSetupEmailRequired, TotpSetupRequired, User, VerifyEmailCodeInput } from './resources/auth.cjs';
|
|
5
|
+
import { b as DepositsResource, F as FundingOptionsResource, c as CardsResource } from './cards-C5rk0XkI.cjs';
|
|
6
|
+
export { A as Address, B as BillingAddress, a as Card, d as CardBalance, e as CardDesignRef, f as CardForm, g as CardInTransit, h as CardLoadStatus, i as CardOrder, j as CardOrderError, k as CardOrderInput, l as CardOrderQuote, m as CardOrderQuoteInput, n as CardOrderRate, C as CardProduct, o as CardProductPrice, p as CardStatus, q as CardStatusSource, r as CardTariff, s as CardTopUp, t as CardTopUpStatus, u as CardTransfer, v as CardType, w as Cardholder, x as CloseBlockedReason, y as CreateCardInput, z as CreateDepositRefundInput, E as CreateQuoteInput, G as CustomerInfo, D as Deposit, H as DepositMethod, I as DepositStatus, J as DepositTarget, K as FeeKind, L as FunderMode, M as FundingOption, N as FundingQuote, O as InitiateDepositInput, P as IssuanceBonus, Q as IssueCardInput, R as MethodTerms, S as PromoCodeQuote, T as PromoCodeStatus, U as Refund, V as RevealCardInput, W as RevealState, X as RevealedCard, Y as SetPinInput, Z as TopUpInput, _ as TopUpResult, $ as TopUpTerms, a0 as TransferInput, a1 as TransferResult, a2 as UpdateCardInput, a3 as priceChangedQuote, a4 as revealState } from './cards-C5rk0XkI.cjs';
|
|
7
7
|
import { BalanceResource } from './resources/balance.cjs';
|
|
8
8
|
export { Balance } from './resources/balance.cjs';
|
|
9
9
|
import { BonusResource } from './resources/bonus.cjs';
|
|
@@ -49,7 +49,7 @@ import { ReceiptsResource } from './resources/receipts.cjs';
|
|
|
49
49
|
export { ListReceiptsParams, Receipt, ReceiptKind } from './resources/receipts.cjs';
|
|
50
50
|
import { SupportResource } from './resources/support.cjs';
|
|
51
51
|
export { SupportAttachment, SupportChannel, SupportConversation, SupportConversationStatus, SupportFile, SupportMessage, SupportMessageStatus, SupportRatingRequest } from './resources/support.cjs';
|
|
52
|
-
export { ANALYTICS_EVENTS, AnalyticsEvent, AnalyticsOptions, AnalyticsProperties, AnalyticsZone, METRIKA_GOALS, MetrikaOptions, NO_CAPTURE_CLASS, PostHogLike, PostHogOptions, identify, initAnalytics, page, posthogDistinctId, resetAnalytics, sanitizeProperties, sanitizeUrl, setAnalyticsZone, track } from './analytics.cjs';
|
|
52
|
+
export { ANALYTICS_EVENTS, AnalyticsEvent, AnalyticsOptions, AnalyticsProperties, AnalyticsZone, MASK_TEXT_CLASS, METRIKA_GOALS, MetrikaOptions, NO_CAPTURE_CLASS, PostHogLike, PostHogOptions, ZONE_ATTRIBUTE, identify, initAnalytics, maskRecordedText, page, posthogDistinctId, resetAnalytics, sanitizeProperties, sanitizeUrl, setAnalyticsConsent, setAnalyticsZone, track } from './analytics.cjs';
|
|
53
53
|
|
|
54
54
|
/**
|
|
55
55
|
* Brand config — runtime-passed, not build-time-baked.
|
|
@@ -155,6 +155,10 @@ declare class ApiError extends Error {
|
|
|
155
155
|
/** Full parsed response body when available. Carries field-level
|
|
156
156
|
* validation details for `code = "validation"`. */
|
|
157
157
|
readonly body?: unknown | undefined;
|
|
158
|
+
/** Seconds the server asked to wait before trying again (its
|
|
159
|
+
* `Retry-After` header), when it sent one. The SDK never retries by
|
|
160
|
+
* itself. */
|
|
161
|
+
readonly retryAfterSeconds?: number | undefined;
|
|
158
162
|
readonly isApiError: true;
|
|
159
163
|
constructor(
|
|
160
164
|
/** HTTP status code returned by the Takeal API. */
|
|
@@ -168,7 +172,11 @@ declare class ApiError extends Error {
|
|
|
168
172
|
message: string,
|
|
169
173
|
/** Full parsed response body when available. Carries field-level
|
|
170
174
|
* validation details for `code = "validation"`. */
|
|
171
|
-
body?: unknown | undefined
|
|
175
|
+
body?: unknown | undefined,
|
|
176
|
+
/** Seconds the server asked to wait before trying again (its
|
|
177
|
+
* `Retry-After` header), when it sent one. The SDK never retries by
|
|
178
|
+
* itself. */
|
|
179
|
+
retryAfterSeconds?: number | undefined);
|
|
172
180
|
}
|
|
173
181
|
declare class NetworkError extends Error {
|
|
174
182
|
readonly cause?: unknown | undefined;
|
|
@@ -187,7 +195,7 @@ declare function isNetworkError(e: unknown): e is NetworkError;
|
|
|
187
195
|
* `define`. `src/version.test.ts` checks it matches `package.json`, so a
|
|
188
196
|
* release bump that forgets this file fails the test run.
|
|
189
197
|
*/
|
|
190
|
-
declare const SDK_VERSION = "0.
|
|
198
|
+
declare const SDK_VERSION = "0.9.0";
|
|
191
199
|
|
|
192
200
|
/**
|
|
193
201
|
* `@takeal/cusfront-sdk` — typed client for the Takeal end-user API.
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { T as TokenStore, F as FetchLike } from './http-CL97TjMO.js';
|
|
2
2
|
export { d as defaultBrowserStore, i as inMemoryStore } from './http-CL97TjMO.js';
|
|
3
3
|
import { AuthResource } from './resources/auth.js';
|
|
4
|
-
export { ChangePasswordInput, ConfirmPasswordSetupInput, EmailChangeRequested, EmailCodeSent, EmailCodeSession, ExchangeTelegramInput, JwtIssued, LinkTelegramInput, LoginInput, LoginResponse, OtpSentResponse, PasswordSetupRequested, RegisterInput, RequestEmailCodeInput, Session, TelegramLink, TelegramUnknown, TotpRequired, TotpSetupComplete, TotpSetupRequired, User, VerifyEmailCodeInput } from './resources/auth.js';
|
|
5
|
-
import { b as DepositsResource, F as FundingOptionsResource, c as CardsResource } from './cards-
|
|
6
|
-
export { A as Address, B as BillingAddress, a as Card, d as CardBalance, e as CardDesignRef, f as CardForm, g as CardInTransit, h as CardLoadStatus, i as CardOrder, j as CardOrderError, k as CardOrderInput, l as CardOrderQuote, m as CardOrderQuoteInput, C as CardProduct,
|
|
4
|
+
export { ChangePasswordInput, ConfirmPasswordSetupInput, EmailChangeRequested, EmailCodeSent, EmailCodeSession, ExchangeTelegramInput, JwtIssued, LinkTelegramInput, LoginInput, LoginResponse, OtpSentResponse, PasswordSetupRequested, RegisterInput, RequestEmailCodeInput, Session, TelegramLink, TelegramUnknown, TotpRequired, TotpSetupComplete, TotpSetupEmailErrorCode, TotpSetupEmailInput, TotpSetupEmailRequired, TotpSetupRequired, User, VerifyEmailCodeInput } from './resources/auth.js';
|
|
5
|
+
import { b as DepositsResource, F as FundingOptionsResource, c as CardsResource } from './cards-CS-oxqLS.js';
|
|
6
|
+
export { A as Address, B as BillingAddress, a as Card, d as CardBalance, e as CardDesignRef, f as CardForm, g as CardInTransit, h as CardLoadStatus, i as CardOrder, j as CardOrderError, k as CardOrderInput, l as CardOrderQuote, m as CardOrderQuoteInput, n as CardOrderRate, C as CardProduct, o as CardProductPrice, p as CardStatus, q as CardStatusSource, r as CardTariff, s as CardTopUp, t as CardTopUpStatus, u as CardTransfer, v as CardType, w as Cardholder, x as CloseBlockedReason, y as CreateCardInput, z as CreateDepositRefundInput, E as CreateQuoteInput, G as CustomerInfo, D as Deposit, H as DepositMethod, I as DepositStatus, J as DepositTarget, K as FeeKind, L as FunderMode, M as FundingOption, N as FundingQuote, O as InitiateDepositInput, P as IssuanceBonus, Q as IssueCardInput, R as MethodTerms, S as PromoCodeQuote, T as PromoCodeStatus, U as Refund, V as RevealCardInput, W as RevealState, X as RevealedCard, Y as SetPinInput, Z as TopUpInput, _ as TopUpResult, $ as TopUpTerms, a0 as TransferInput, a1 as TransferResult, a2 as UpdateCardInput, a3 as priceChangedQuote, a4 as revealState } from './cards-CS-oxqLS.js';
|
|
7
7
|
import { BalanceResource } from './resources/balance.js';
|
|
8
8
|
export { Balance } from './resources/balance.js';
|
|
9
9
|
import { BonusResource } from './resources/bonus.js';
|
|
@@ -49,7 +49,7 @@ import { ReceiptsResource } from './resources/receipts.js';
|
|
|
49
49
|
export { ListReceiptsParams, Receipt, ReceiptKind } from './resources/receipts.js';
|
|
50
50
|
import { SupportResource } from './resources/support.js';
|
|
51
51
|
export { SupportAttachment, SupportChannel, SupportConversation, SupportConversationStatus, SupportFile, SupportMessage, SupportMessageStatus, SupportRatingRequest } from './resources/support.js';
|
|
52
|
-
export { ANALYTICS_EVENTS, AnalyticsEvent, AnalyticsOptions, AnalyticsProperties, AnalyticsZone, METRIKA_GOALS, MetrikaOptions, NO_CAPTURE_CLASS, PostHogLike, PostHogOptions, identify, initAnalytics, page, posthogDistinctId, resetAnalytics, sanitizeProperties, sanitizeUrl, setAnalyticsZone, track } from './analytics.js';
|
|
52
|
+
export { ANALYTICS_EVENTS, AnalyticsEvent, AnalyticsOptions, AnalyticsProperties, AnalyticsZone, MASK_TEXT_CLASS, METRIKA_GOALS, MetrikaOptions, NO_CAPTURE_CLASS, PostHogLike, PostHogOptions, ZONE_ATTRIBUTE, identify, initAnalytics, maskRecordedText, page, posthogDistinctId, resetAnalytics, sanitizeProperties, sanitizeUrl, setAnalyticsConsent, setAnalyticsZone, track } from './analytics.js';
|
|
53
53
|
|
|
54
54
|
/**
|
|
55
55
|
* Brand config — runtime-passed, not build-time-baked.
|
|
@@ -155,6 +155,10 @@ declare class ApiError extends Error {
|
|
|
155
155
|
/** Full parsed response body when available. Carries field-level
|
|
156
156
|
* validation details for `code = "validation"`. */
|
|
157
157
|
readonly body?: unknown | undefined;
|
|
158
|
+
/** Seconds the server asked to wait before trying again (its
|
|
159
|
+
* `Retry-After` header), when it sent one. The SDK never retries by
|
|
160
|
+
* itself. */
|
|
161
|
+
readonly retryAfterSeconds?: number | undefined;
|
|
158
162
|
readonly isApiError: true;
|
|
159
163
|
constructor(
|
|
160
164
|
/** HTTP status code returned by the Takeal API. */
|
|
@@ -168,7 +172,11 @@ declare class ApiError extends Error {
|
|
|
168
172
|
message: string,
|
|
169
173
|
/** Full parsed response body when available. Carries field-level
|
|
170
174
|
* validation details for `code = "validation"`. */
|
|
171
|
-
body?: unknown | undefined
|
|
175
|
+
body?: unknown | undefined,
|
|
176
|
+
/** Seconds the server asked to wait before trying again (its
|
|
177
|
+
* `Retry-After` header), when it sent one. The SDK never retries by
|
|
178
|
+
* itself. */
|
|
179
|
+
retryAfterSeconds?: number | undefined);
|
|
172
180
|
}
|
|
173
181
|
declare class NetworkError extends Error {
|
|
174
182
|
readonly cause?: unknown | undefined;
|
|
@@ -187,7 +195,7 @@ declare function isNetworkError(e: unknown): e is NetworkError;
|
|
|
187
195
|
* `define`. `src/version.test.ts` checks it matches `package.json`, so a
|
|
188
196
|
* release bump that forgets this file fails the test run.
|
|
189
197
|
*/
|
|
190
|
-
declare const SDK_VERSION = "0.
|
|
198
|
+
declare const SDK_VERSION = "0.9.0";
|
|
191
199
|
|
|
192
200
|
/**
|
|
193
201
|
* `@takeal/cusfront-sdk` — typed client for the Takeal end-user API.
|
package/dist/index.js
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
// src/error.ts
|
|
2
2
|
var ApiError = class extends Error {
|
|
3
|
-
constructor(status, code, message, body) {
|
|
3
|
+
constructor(status, code, message, body, retryAfterSeconds) {
|
|
4
4
|
super(message);
|
|
5
5
|
this.status = status;
|
|
6
6
|
this.code = code;
|
|
7
7
|
this.body = body;
|
|
8
|
+
this.retryAfterSeconds = retryAfterSeconds;
|
|
8
9
|
this.isApiError = true;
|
|
9
10
|
this.name = "ApiError";
|
|
10
11
|
}
|
|
@@ -139,11 +140,20 @@ async function parseResponse(resp) {
|
|
|
139
140
|
resp.status,
|
|
140
141
|
errBody.code ?? `http_${resp.status}`,
|
|
141
142
|
errBody.message ?? resp.statusText ?? "request failed",
|
|
142
|
-
body
|
|
143
|
+
body,
|
|
144
|
+
retryAfter(resp.headers?.get("Retry-After"))
|
|
143
145
|
);
|
|
144
146
|
}
|
|
145
147
|
return body;
|
|
146
148
|
}
|
|
149
|
+
function retryAfter(v, now = Date.now()) {
|
|
150
|
+
if (!v) return void 0;
|
|
151
|
+
const t = v.trim();
|
|
152
|
+
if (/^\d+$/.test(t)) return Number(t);
|
|
153
|
+
const at = Date.parse(t);
|
|
154
|
+
if (Number.isNaN(at)) return void 0;
|
|
155
|
+
return Math.max(0, Math.ceil((at - now) / 1e3));
|
|
156
|
+
}
|
|
147
157
|
|
|
148
158
|
// src/resources/attribution.ts
|
|
149
159
|
var AttributionResource = class {
|
|
@@ -714,12 +724,17 @@ var AuthResource = class {
|
|
|
714
724
|
return resp;
|
|
715
725
|
}
|
|
716
726
|
/** Verify a TOTP code (or XXXX-XXXX backup code) against a
|
|
717
|
-
* `totp_required` challenge. On success the JWT is stored.
|
|
727
|
+
* `totp_required` challenge. On success the JWT is stored. A backup code
|
|
728
|
+
* signs nobody in: it is used up and the answer is
|
|
729
|
+
* `totp_setup_email_required`, the start of connecting a new
|
|
730
|
+
* authenticator ({@link confirmTotpSetupEmail}). Nothing is stored then.
|
|
731
|
+
* Errors after a backup code: see {@link TotpSetupEmailErrorCode}. */
|
|
718
732
|
async verifyTotp(input) {
|
|
719
733
|
const resp = await this.http.post("/auth/login/totp", {
|
|
720
734
|
body: withRemember(input),
|
|
721
735
|
skipAuth: true
|
|
722
736
|
});
|
|
737
|
+
if (resp.stage === "totp_setup_email_required") return resp;
|
|
723
738
|
await this.keep(resp);
|
|
724
739
|
return resp;
|
|
725
740
|
}
|
|
@@ -792,6 +807,28 @@ var AuthResource = class {
|
|
|
792
807
|
await this.keep(resp);
|
|
793
808
|
return resp;
|
|
794
809
|
}
|
|
810
|
+
/** Send the code from the e-mail of a `totp_setup_email_required`
|
|
811
|
+
* answer. A right code answers `totp_setup_required`: show its
|
|
812
|
+
* `otpauth_url` as a QR, then finish with {@link completeTotpSetup}.
|
|
813
|
+
* Each code works for 5 minutes and takes five tries; only the newest
|
|
814
|
+
* one works. Nothing is stored. Errors: {@link TotpSetupEmailErrorCode}. */
|
|
815
|
+
async confirmTotpSetupEmail(input) {
|
|
816
|
+
return this.http.post("/auth/login/totp-setup/email", {
|
|
817
|
+
body: { challenge_token: input.challenge_token, code: input.code },
|
|
818
|
+
skipAuth: true
|
|
819
|
+
});
|
|
820
|
+
}
|
|
821
|
+
/** A new e-mail code for the same `totp_setup_email_required` sign-in;
|
|
822
|
+
* the one before it stops working. Use the `challenge_token` of the
|
|
823
|
+
* answer from now on. Five codes an hour at most.
|
|
824
|
+
* Errors: {@link TotpSetupEmailErrorCode}; 401 means the sign-in is over,
|
|
825
|
+
* so start again with {@link login}. */
|
|
826
|
+
async resendTotpSetupEmail(input) {
|
|
827
|
+
return this.http.post("/auth/login/totp-setup/email/resend", {
|
|
828
|
+
body: { challenge_token: input.challenge_token },
|
|
829
|
+
skipAuth: true
|
|
830
|
+
});
|
|
831
|
+
}
|
|
795
832
|
/** Finish a `totp_setup_required` login: send the first code from the
|
|
796
833
|
* authenticator app. The JWT is stored. The response carries ten
|
|
797
834
|
* one-time `backup_codes` that are never returned again, so show them to
|
|
@@ -1779,7 +1816,7 @@ var FundingOptionsResource = class {
|
|
|
1779
1816
|
};
|
|
1780
1817
|
|
|
1781
1818
|
// src/version.ts
|
|
1782
|
-
var SDK_VERSION = "0.
|
|
1819
|
+
var SDK_VERSION = "0.9.0";
|
|
1783
1820
|
|
|
1784
1821
|
// src/client-platform.ts
|
|
1785
1822
|
var CLIENT_HEADER = "X-Takeal-Client";
|
|
@@ -1916,12 +1953,18 @@ function readyInfo(raw, healthy) {
|
|
|
1916
1953
|
}
|
|
1917
1954
|
return { ...base, compatible: true };
|
|
1918
1955
|
}
|
|
1956
|
+
function isReadyBody(body) {
|
|
1957
|
+
if (typeof body !== "object" || body === null || Array.isArray(body)) return false;
|
|
1958
|
+
const b = body;
|
|
1959
|
+
const block = (v) => typeof v === "object" && v !== null;
|
|
1960
|
+
return b.code !== "service_unavailable" && typeof b.status === "string" && (block(b.checks) || block(b.ops));
|
|
1961
|
+
}
|
|
1919
1962
|
async function fetchReady(http, opts = {}) {
|
|
1920
1963
|
try {
|
|
1921
1964
|
const body = await http.get("/ready", { skipAuth: true, signal: opts.signal });
|
|
1922
1965
|
return readyInfo(body ?? {}, true);
|
|
1923
1966
|
} catch (e) {
|
|
1924
|
-
if (isApiError(e) && e.status === 503 &&
|
|
1967
|
+
if (isApiError(e) && e.status === 503 && isReadyBody(e.body)) {
|
|
1925
1968
|
return readyInfo(e.body, false);
|
|
1926
1969
|
}
|
|
1927
1970
|
throw e;
|
|
@@ -1955,6 +1998,8 @@ var ANALYTICS_EVENTS = [
|
|
|
1955
1998
|
];
|
|
1956
1999
|
var METRIKA_GOALS = ["signup_started", "signup_completed"];
|
|
1957
2000
|
var NO_CAPTURE_CLASS = "ph-no-capture";
|
|
2001
|
+
var MASK_TEXT_CLASS = "ph-mask";
|
|
2002
|
+
var ZONE_ATTRIBUTE = "data-analytics-zone";
|
|
1958
2003
|
var UUID = /[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}/gi;
|
|
1959
2004
|
var EMAIL = /[^\s@"'<>(),;:]+@[^\s@"'<>(),;:]+\.[a-z]{2,}/gi;
|
|
1960
2005
|
var DIGIT_RUN = /\+?\d[\d\s().-]{7,}\d/g;
|
|
@@ -2220,18 +2265,38 @@ function posthogConfig(zone, o) {
|
|
|
2220
2265
|
// Page views go through `page()`, with a cleaned address.
|
|
2221
2266
|
capture_pageview: false,
|
|
2222
2267
|
capture_pageleave: true,
|
|
2223
|
-
before_send: beforeSend
|
|
2268
|
+
before_send: beforeSend,
|
|
2269
|
+
// Set once. A zone change never touches these: posthog-js hands the
|
|
2270
|
+
// recording options to rrweb when the recorder starts, and changing
|
|
2271
|
+
// `disable_session_recording` stops or restarts it.
|
|
2272
|
+
disable_session_recording: !o.sessionRecording,
|
|
2273
|
+
session_recording: recordingOptions()
|
|
2274
|
+
};
|
|
2275
|
+
return { ...base, ...zoneConfig(zone) };
|
|
2276
|
+
}
|
|
2277
|
+
function recordingOptions() {
|
|
2278
|
+
return {
|
|
2279
|
+
maskAllInputs: true,
|
|
2280
|
+
maskTextSelector: "*",
|
|
2281
|
+
maskTextFn: maskRecordedText,
|
|
2282
|
+
blockClass: NO_CAPTURE_CLASS
|
|
2224
2283
|
};
|
|
2225
|
-
return { ...base, ...zoneConfig(zone, o) };
|
|
2226
2284
|
}
|
|
2227
|
-
|
|
2285
|
+
var PRIVATE_BLOCK = `.${MASK_TEXT_CLASS}, [${ZONE_ATTRIBUTE}]:not([${ZONE_ATTRIBUTE}="public"])`;
|
|
2286
|
+
function maskRecordedText(text, element) {
|
|
2287
|
+
try {
|
|
2288
|
+
if (state()?.zone === "public" && !element?.closest(PRIVATE_BLOCK)) return text;
|
|
2289
|
+
} catch {
|
|
2290
|
+
}
|
|
2291
|
+
return text.replace(/\S/g, "*");
|
|
2292
|
+
}
|
|
2293
|
+
function zoneConfig(zone) {
|
|
2228
2294
|
if (zone === "public") {
|
|
2229
2295
|
return {
|
|
2230
2296
|
autocapture: true,
|
|
2231
2297
|
mask_all_text: false,
|
|
2232
2298
|
mask_all_element_attributes: false,
|
|
2233
|
-
enable_heatmaps: true
|
|
2234
|
-
disable_session_recording: true
|
|
2299
|
+
enable_heatmaps: true
|
|
2235
2300
|
};
|
|
2236
2301
|
}
|
|
2237
2302
|
return {
|
|
@@ -2239,13 +2304,7 @@ function zoneConfig(zone, o) {
|
|
|
2239
2304
|
autocapture: { capture_copied_text: false },
|
|
2240
2305
|
mask_all_text: true,
|
|
2241
2306
|
mask_all_element_attributes: true,
|
|
2242
|
-
enable_heatmaps: false
|
|
2243
|
-
disable_session_recording: !o.sessionRecording,
|
|
2244
|
-
session_recording: {
|
|
2245
|
-
maskAllInputs: true,
|
|
2246
|
-
maskTextSelector: "*",
|
|
2247
|
-
blockClass: NO_CAPTURE_CLASS
|
|
2248
|
-
}
|
|
2307
|
+
enable_heatmaps: false
|
|
2249
2308
|
};
|
|
2250
2309
|
}
|
|
2251
2310
|
function assetsHost(o) {
|
|
@@ -2304,16 +2363,26 @@ var PostHogSink = class {
|
|
|
2304
2363
|
}
|
|
2305
2364
|
setZone(zone) {
|
|
2306
2365
|
this.with((ph) => {
|
|
2307
|
-
ph.set_config(zoneConfig(zone
|
|
2366
|
+
ph.set_config(zoneConfig(zone));
|
|
2308
2367
|
ph.register({ zone });
|
|
2309
|
-
|
|
2310
|
-
|
|
2368
|
+
});
|
|
2369
|
+
}
|
|
2370
|
+
setConsent(granted) {
|
|
2371
|
+
this.with((ph) => {
|
|
2372
|
+
if (granted) {
|
|
2373
|
+
ph.opt_in_capturing?.();
|
|
2374
|
+
if (this.o.sessionRecording) ph.startSessionRecording?.();
|
|
2375
|
+
} else {
|
|
2376
|
+
ph.stopSessionRecording?.();
|
|
2377
|
+
ph.opt_out_capturing?.();
|
|
2378
|
+
}
|
|
2311
2379
|
});
|
|
2312
2380
|
}
|
|
2313
2381
|
};
|
|
2314
2382
|
var MetrikaSink = class {
|
|
2315
2383
|
constructor(o) {
|
|
2316
2384
|
this.live = true;
|
|
2385
|
+
this.consented = true;
|
|
2317
2386
|
this.id = Number(o.counterId);
|
|
2318
2387
|
const w = win();
|
|
2319
2388
|
if (!w.ym) {
|
|
@@ -2336,7 +2405,7 @@ var MetrikaSink = class {
|
|
|
2336
2405
|
});
|
|
2337
2406
|
}
|
|
2338
2407
|
ym(...args) {
|
|
2339
|
-
if (this.live) win().ym?.(this.id, ...args);
|
|
2408
|
+
if (this.live && this.consented) win().ym?.(this.id, ...args);
|
|
2340
2409
|
}
|
|
2341
2410
|
capture(event, props) {
|
|
2342
2411
|
if (METRIKA_GOALS.includes(event)) this.ym("reachGoal", event, props);
|
|
@@ -2352,16 +2421,27 @@ var MetrikaSink = class {
|
|
|
2352
2421
|
setZone(zone) {
|
|
2353
2422
|
this.live = zone === "public";
|
|
2354
2423
|
}
|
|
2424
|
+
setConsent(granted) {
|
|
2425
|
+
this.consented = granted;
|
|
2426
|
+
}
|
|
2355
2427
|
};
|
|
2356
2428
|
var KEY = /* @__PURE__ */ Symbol.for("takeal.cusfront-sdk.analytics");
|
|
2357
2429
|
var holder = globalThis;
|
|
2358
2430
|
var state = () => holder[KEY];
|
|
2431
|
+
function loaded(s) {
|
|
2432
|
+
return [s.posthog, s.metrika].filter((x) => !!x);
|
|
2433
|
+
}
|
|
2359
2434
|
function sinks(s) {
|
|
2435
|
+
if (!s.consent) return [];
|
|
2436
|
+
if (s.options.posthog?.key && !s.posthog) {
|
|
2437
|
+
s.posthog = new PostHogSink(s.options.posthog, s.zone);
|
|
2438
|
+
if (s.userId) s.posthog.identify(s.userId);
|
|
2439
|
+
}
|
|
2360
2440
|
if (s.zone === "public" && s.options.metrika && !s.metrika) {
|
|
2361
2441
|
s.metrika = new MetrikaSink(s.options.metrika);
|
|
2362
2442
|
if (s.userId) s.metrika.identify(s.userId);
|
|
2363
2443
|
}
|
|
2364
|
-
return
|
|
2444
|
+
return loaded(s);
|
|
2365
2445
|
}
|
|
2366
2446
|
function initAnalytics(options) {
|
|
2367
2447
|
if (state() || !win().document) return;
|
|
@@ -2370,17 +2450,28 @@ function initAnalytics(options) {
|
|
|
2370
2450
|
"[analytics] Yandex Metrica is on a page outside the public zone; it must not be."
|
|
2371
2451
|
);
|
|
2372
2452
|
}
|
|
2373
|
-
const s = { options, zone: options.zone };
|
|
2453
|
+
const s = { options, zone: options.zone, consent: options.consent !== false };
|
|
2374
2454
|
holder[KEY] = s;
|
|
2375
|
-
if (options.posthog?.key) s.posthog = new PostHogSink(options.posthog, options.zone);
|
|
2376
2455
|
sinks(s);
|
|
2377
2456
|
if (options.initialPageview !== false) page();
|
|
2378
2457
|
}
|
|
2458
|
+
function setAnalyticsConsent(granted) {
|
|
2459
|
+
const s = state();
|
|
2460
|
+
if (!s || s.consent === granted) return;
|
|
2461
|
+
s.consent = granted;
|
|
2462
|
+
const before = loaded(s);
|
|
2463
|
+
for (const sink of before) sink.setConsent(granted);
|
|
2464
|
+
if (granted) {
|
|
2465
|
+
sinks(s);
|
|
2466
|
+
if (s.lastPage === void 0 && s.options.initialPageview !== false) page();
|
|
2467
|
+
}
|
|
2468
|
+
}
|
|
2379
2469
|
function setAnalyticsZone(zone) {
|
|
2380
2470
|
const s = state();
|
|
2381
2471
|
if (!s || s.zone === zone) return;
|
|
2382
2472
|
s.zone = zone;
|
|
2383
|
-
|
|
2473
|
+
sinks(s);
|
|
2474
|
+
for (const sink of loaded(s)) sink.setZone(zone);
|
|
2384
2475
|
}
|
|
2385
2476
|
function track(event, props = {}) {
|
|
2386
2477
|
const s = state();
|
|
@@ -2392,7 +2483,7 @@ function page(url) {
|
|
|
2392
2483
|
const s = state();
|
|
2393
2484
|
const w = win();
|
|
2394
2485
|
const raw = url ?? w.location?.href;
|
|
2395
|
-
if (!s || !raw) return;
|
|
2486
|
+
if (!s || !s.consent || !raw) return;
|
|
2396
2487
|
const clean2 = sanitizeUrl(raw);
|
|
2397
2488
|
if (clean2 === s.lastPage) return;
|
|
2398
2489
|
const referrer = s.lastPage ?? (w.document?.referrer ? sanitizeUrl(w.document.referrer) : void 0);
|
|
@@ -2409,7 +2500,7 @@ function resetAnalytics() {
|
|
|
2409
2500
|
const s = state();
|
|
2410
2501
|
if (!s) return;
|
|
2411
2502
|
s.userId = void 0;
|
|
2412
|
-
for (const sink of
|
|
2503
|
+
for (const sink of loaded(s)) sink.reset();
|
|
2413
2504
|
}
|
|
2414
2505
|
async function posthogDistinctId(timeoutMs = 3e3) {
|
|
2415
2506
|
const ready = state()?.posthog?.ready;
|
|
@@ -2486,6 +2577,6 @@ function defaultFetch() {
|
|
|
2486
2577
|
);
|
|
2487
2578
|
}
|
|
2488
2579
|
|
|
2489
|
-
export { ANALYTICS_EVENTS, ApiError, CLIENT_HEADER, DISPUTE_DOCUMENTS_CONSENT, HOLDER_DATA_CONSENT, METRIKA_GOALS, NO_CAPTURE_CLASS, NetworkError, SDK_VERSION, SUPPORTED_MEISTER, analyticsIds, anonymousKey, createClient, currentTouch, defaultBrowserStore, detectClientPlatform, forgetAnalyticsIds, identify, inMemoryStore, initAnalytics, isApiError, isCardOtp, isNetworkError, page, posthogDistinctId, priceChangedQuote, rememberAnalyticsIds, resetAnalytics, resolveAssetUrl, revealState, sanitizeProperties, sanitizeUrl, satisfies, setAnalyticsZone, track, withAnalyticsIds };
|
|
2580
|
+
export { ANALYTICS_EVENTS, ApiError, CLIENT_HEADER, DISPUTE_DOCUMENTS_CONSENT, HOLDER_DATA_CONSENT, MASK_TEXT_CLASS, METRIKA_GOALS, NO_CAPTURE_CLASS, NetworkError, SDK_VERSION, SUPPORTED_MEISTER, ZONE_ATTRIBUTE, analyticsIds, anonymousKey, createClient, currentTouch, defaultBrowserStore, detectClientPlatform, forgetAnalyticsIds, identify, inMemoryStore, initAnalytics, isApiError, isCardOtp, isNetworkError, maskRecordedText, page, posthogDistinctId, priceChangedQuote, rememberAnalyticsIds, resetAnalytics, resolveAssetUrl, revealState, sanitizeProperties, sanitizeUrl, satisfies, setAnalyticsConsent, setAnalyticsZone, track, withAnalyticsIds };
|
|
2490
2581
|
//# sourceMappingURL=index.js.map
|
|
2491
2582
|
//# sourceMappingURL=index.js.map
|