@monetize.software/sdk-extension 3.0.0-alpha.4 → 3.0.0-alpha.6
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/dist/chunks/ar-BCHXVoE2.js +114 -0
- package/dist/chunks/ar-BCHXVoE2.js.map +1 -0
- package/dist/chunks/ar-CsJNZJSr.js +2 -0
- package/dist/chunks/ar-CsJNZJSr.js.map +1 -0
- package/dist/chunks/{chrome-port-BAMwPMV0.js → chrome-port-CxW3Pwc2.js} +185 -114
- package/dist/chunks/chrome-port-CxW3Pwc2.js.map +1 -0
- package/dist/chunks/chrome-port-PhlW29BV.js +2 -0
- package/dist/chunks/chrome-port-PhlW29BV.js.map +1 -0
- package/dist/chunks/cs-B5NqpTW_.js +110 -0
- package/dist/chunks/cs-B5NqpTW_.js.map +1 -0
- package/dist/chunks/cs-BydWUC0e.js +2 -0
- package/dist/chunks/cs-BydWUC0e.js.map +1 -0
- package/dist/chunks/da-BJrGZ3LD.js +110 -0
- package/dist/chunks/da-BJrGZ3LD.js.map +1 -0
- package/dist/chunks/da-DNhiAQnh.js +2 -0
- package/dist/chunks/da-DNhiAQnh.js.map +1 -0
- package/dist/chunks/de-H8ztFOie.js +2 -0
- package/dist/chunks/de-H8ztFOie.js.map +1 -0
- package/dist/chunks/de-aepBKwsb.js +130 -0
- package/dist/chunks/de-aepBKwsb.js.map +1 -0
- package/dist/chunks/el-DRfoadtI.js +2 -0
- package/dist/chunks/el-DRfoadtI.js.map +1 -0
- package/dist/chunks/el-DTLQoX2D.js +114 -0
- package/dist/chunks/el-DTLQoX2D.js.map +1 -0
- package/dist/chunks/es-CLutF-D_.js +130 -0
- package/dist/chunks/es-CLutF-D_.js.map +1 -0
- package/dist/chunks/es-GlaYesNR.js +2 -0
- package/dist/chunks/es-GlaYesNR.js.map +1 -0
- package/dist/chunks/fi-BIHFyScH.js +2 -0
- package/dist/chunks/fi-BIHFyScH.js.map +1 -0
- package/dist/chunks/fi-DZ4csxqk.js +110 -0
- package/dist/chunks/fi-DZ4csxqk.js.map +1 -0
- package/dist/chunks/fr-BtZILUNZ.js +2 -0
- package/dist/chunks/fr-BtZILUNZ.js.map +1 -0
- package/dist/chunks/fr-jJU1SSpj.js +130 -0
- package/dist/chunks/fr-jJU1SSpj.js.map +1 -0
- package/dist/chunks/he-D9obGPNj.js +114 -0
- package/dist/chunks/he-D9obGPNj.js.map +1 -0
- package/dist/chunks/he-vSDRE4Nn.js +2 -0
- package/dist/chunks/he-vSDRE4Nn.js.map +1 -0
- package/dist/chunks/hi-B90FsnP6.js +2 -0
- package/dist/chunks/hi-B90FsnP6.js.map +1 -0
- package/dist/chunks/hi-pM8SQwZ3.js +114 -0
- package/dist/chunks/hi-pM8SQwZ3.js.map +1 -0
- package/dist/chunks/hu-DWVFODsS.js +2 -0
- package/dist/chunks/hu-DWVFODsS.js.map +1 -0
- package/dist/chunks/hu-E0m9WgbD.js +110 -0
- package/dist/chunks/hu-E0m9WgbD.js.map +1 -0
- package/dist/chunks/id-C6poPvby.js +110 -0
- package/dist/chunks/id-C6poPvby.js.map +1 -0
- package/dist/chunks/id-Ce2gzMVT.js +2 -0
- package/dist/chunks/id-Ce2gzMVT.js.map +1 -0
- package/dist/chunks/it-B2RSFyVd.js +130 -0
- package/dist/chunks/it-B2RSFyVd.js.map +1 -0
- package/dist/chunks/it-u-Gu44bl.js +2 -0
- package/dist/chunks/it-u-Gu44bl.js.map +1 -0
- package/dist/chunks/ja-CM-VgVG6.js +134 -0
- package/dist/chunks/ja-CM-VgVG6.js.map +1 -0
- package/dist/chunks/ja-CQy8RaRa.js +2 -0
- package/dist/chunks/ja-CQy8RaRa.js.map +1 -0
- package/dist/chunks/ko-BRnb7vJ7.js +2 -0
- package/dist/chunks/ko-BRnb7vJ7.js.map +1 -0
- package/dist/chunks/ko-C451fA21.js +134 -0
- package/dist/chunks/ko-C451fA21.js.map +1 -0
- package/dist/chunks/nl-CJelco6J.js +2 -0
- package/dist/chunks/nl-CJelco6J.js.map +1 -0
- package/dist/chunks/nl-DzQfJPo2.js +130 -0
- package/dist/chunks/nl-DzQfJPo2.js.map +1 -0
- package/dist/chunks/no-B51be8KT.js +110 -0
- package/dist/chunks/no-B51be8KT.js.map +1 -0
- package/dist/chunks/no-BwTjSZ4K.js +2 -0
- package/dist/chunks/no-BwTjSZ4K.js.map +1 -0
- package/dist/chunks/pl-5rTEkvfY.js +110 -0
- package/dist/chunks/pl-5rTEkvfY.js.map +1 -0
- package/dist/chunks/pl-kO82vcjb.js +2 -0
- package/dist/chunks/pl-kO82vcjb.js.map +1 -0
- package/dist/chunks/pt-CsJzaSjg.js +2 -0
- package/dist/chunks/pt-CsJzaSjg.js.map +1 -0
- package/dist/chunks/pt-JwqffZ9u.js +130 -0
- package/dist/chunks/pt-JwqffZ9u.js.map +1 -0
- package/dist/chunks/ro-BE_wJ1td.js +110 -0
- package/dist/chunks/ro-BE_wJ1td.js.map +1 -0
- package/dist/chunks/ro-ue15Ina4.js +2 -0
- package/dist/chunks/ro-ue15Ina4.js.map +1 -0
- package/dist/chunks/ru-B1iMOhX0.js +2 -0
- package/dist/chunks/ru-B1iMOhX0.js.map +1 -0
- package/dist/chunks/ru-BviATvLb.js +124 -0
- package/dist/chunks/ru-BviATvLb.js.map +1 -0
- package/dist/chunks/sv-CkNYpUVy.js +2 -0
- package/dist/chunks/sv-CkNYpUVy.js.map +1 -0
- package/dist/chunks/sv-DabGF9WL.js +110 -0
- package/dist/chunks/sv-DabGF9WL.js.map +1 -0
- package/dist/chunks/th-BiF-bNo0.js +114 -0
- package/dist/chunks/th-BiF-bNo0.js.map +1 -0
- package/dist/chunks/th-Cu80HK4y.js +2 -0
- package/dist/chunks/th-Cu80HK4y.js.map +1 -0
- package/dist/chunks/tr-B7c0afXV.js +2 -0
- package/dist/chunks/tr-B7c0afXV.js.map +1 -0
- package/dist/chunks/tr-xZuly8X8.js +110 -0
- package/dist/chunks/tr-xZuly8X8.js.map +1 -0
- package/dist/chunks/uk-BO106B0H.js +2 -0
- package/dist/chunks/uk-BO106B0H.js.map +1 -0
- package/dist/chunks/uk-KlkAaHuy.js +124 -0
- package/dist/chunks/uk-KlkAaHuy.js.map +1 -0
- package/dist/chunks/vi-BVCeumNE.js +110 -0
- package/dist/chunks/vi-BVCeumNE.js.map +1 -0
- package/dist/chunks/vi-CZ6ow40D.js +2 -0
- package/dist/chunks/vi-CZ6ow40D.js.map +1 -0
- package/dist/chunks/zh-BhP80WI1.js +2 -0
- package/dist/chunks/zh-BhP80WI1.js.map +1 -0
- package/dist/chunks/zh-C_ghwmqi.js +134 -0
- package/dist/chunks/zh-C_ghwmqi.js.map +1 -0
- package/dist/content/RemoteAuthClient.d.ts +5 -1
- package/dist/content/RemoteAuthClient.d.ts.map +1 -1
- package/dist/content/RemoteAuthClient.test-d.d.ts +2 -0
- package/dist/content/RemoteAuthClient.test-d.d.ts.map +1 -0
- package/dist/content/RemoteBillingClient.d.ts +29 -0
- package/dist/content/RemoteBillingClient.d.ts.map +1 -1
- package/dist/content/RemoteBillingClient.test-d.d.ts +2 -0
- package/dist/content/RemoteBillingClient.test-d.d.ts.map +1 -0
- package/dist/content.cjs +3 -3
- package/dist/content.cjs.map +1 -1
- package/dist/content.js +2260 -1237
- package/dist/content.js.map +1 -1
- package/dist/offscreen/server.d.ts.map +1 -1
- package/dist/offscreen.cjs +1 -1
- package/dist/offscreen.cjs.map +1 -1
- package/dist/offscreen.js +5 -2
- package/dist/offscreen.js.map +1 -1
- package/dist/shared/messages.d.ts +21 -1
- package/dist/shared/messages.d.ts.map +1 -1
- package/dist/shared/protocol.d.ts +1 -1
- package/dist/shared/protocol.d.ts.map +1 -1
- package/package.json +7 -6
- package/dist/chunks/chrome-port-BAMwPMV0.js.map +0 -1
- package/dist/chunks/chrome-port-CdxuZ1ND.js +0 -2
- package/dist/chunks/chrome-port-CdxuZ1ND.js.map +0 -1
|
@@ -3,7 +3,7 @@ class o extends Error {
|
|
|
3
3
|
super(e), this.name = "PaywallError", this.code = t, this.status = s.status, this.cause = s.cause;
|
|
4
4
|
}
|
|
5
5
|
}
|
|
6
|
-
class
|
|
6
|
+
class F extends o {
|
|
7
7
|
constructor(t) {
|
|
8
8
|
super("not_enough_queries", t.message ?? "Not enough queries", {
|
|
9
9
|
status: 402
|
|
@@ -11,7 +11,7 @@ class q extends o {
|
|
|
11
11
|
}
|
|
12
12
|
}
|
|
13
13
|
const m = "3.0.0-alpha.0";
|
|
14
|
-
class
|
|
14
|
+
class P {
|
|
15
15
|
constructor(t) {
|
|
16
16
|
this.opts = t;
|
|
17
17
|
}
|
|
@@ -22,9 +22,9 @@ class L {
|
|
|
22
22
|
r && n.set("Authorization", `Bearer ${r}`);
|
|
23
23
|
const l = typeof FormData < "u" && e.body instanceof FormData;
|
|
24
24
|
e.body && !n.has("Content-Type") && !l && n.set("Content-Type", "application/json");
|
|
25
|
-
let
|
|
25
|
+
let d;
|
|
26
26
|
try {
|
|
27
|
-
|
|
27
|
+
d = await a(s, {
|
|
28
28
|
...e,
|
|
29
29
|
headers: n,
|
|
30
30
|
credentials: "omit"
|
|
@@ -32,18 +32,18 @@ class L {
|
|
|
32
32
|
} catch (h) {
|
|
33
33
|
throw (h && typeof h == "object" && "name" in h ? h.name : void 0) === "AbortError" ? new o("aborted", "Request aborted", { cause: h }) : new o("network_error", "Network request failed", { cause: h });
|
|
34
34
|
}
|
|
35
|
-
const
|
|
36
|
-
if (!
|
|
37
|
-
const h =
|
|
38
|
-
throw new o(h,
|
|
35
|
+
const y = (d.headers.get("content-type") ?? "").includes("application/json") ? await d.json().catch(() => null) : null;
|
|
36
|
+
if (!d.ok) {
|
|
37
|
+
const h = y && typeof y == "object" && "code" in y && String(y.code) || `http_${d.status}`, g = y && typeof y == "object" && "message" in y && String(y.message) || d.statusText || "Request failed";
|
|
38
|
+
throw new o(h, g, { status: d.status, cause: y });
|
|
39
39
|
}
|
|
40
|
-
return
|
|
40
|
+
return y;
|
|
41
41
|
}
|
|
42
42
|
}
|
|
43
|
-
function
|
|
43
|
+
function x() {
|
|
44
44
|
return typeof chrome < "u" && !!chrome?.storage?.local && !!chrome?.runtime?.id;
|
|
45
45
|
}
|
|
46
|
-
const
|
|
46
|
+
const H = {
|
|
47
47
|
getItem(i) {
|
|
48
48
|
return new Promise((t) => {
|
|
49
49
|
chrome.storage.local.get([i], (e) => {
|
|
@@ -73,7 +73,7 @@ const x = {
|
|
|
73
73
|
};
|
|
74
74
|
return e.addListener(s), () => e.removeListener(s);
|
|
75
75
|
}
|
|
76
|
-
},
|
|
76
|
+
}, J = {
|
|
77
77
|
async getItem(i) {
|
|
78
78
|
try {
|
|
79
79
|
return window.localStorage.getItem(i);
|
|
@@ -101,21 +101,21 @@ const x = {
|
|
|
101
101
|
};
|
|
102
102
|
return window.addEventListener("storage", e), () => window.removeEventListener("storage", e);
|
|
103
103
|
}
|
|
104
|
-
},
|
|
104
|
+
}, S = /* @__PURE__ */ new Map(), V = {
|
|
105
105
|
async getItem(i) {
|
|
106
|
-
return
|
|
106
|
+
return S.get(i) ?? null;
|
|
107
107
|
},
|
|
108
108
|
async setItem(i, t) {
|
|
109
|
-
|
|
109
|
+
S.set(i, t);
|
|
110
110
|
},
|
|
111
111
|
async removeItem(i) {
|
|
112
|
-
|
|
112
|
+
S.delete(i);
|
|
113
113
|
}
|
|
114
114
|
};
|
|
115
115
|
function R(i) {
|
|
116
|
-
return i || (
|
|
116
|
+
return i || (x() ? H : typeof window < "u" && "localStorage" in window ? J : V);
|
|
117
117
|
}
|
|
118
|
-
const
|
|
118
|
+
const u = {
|
|
119
119
|
visitorId: "pw-visitor-id",
|
|
120
120
|
lastLoginMethod: (i) => `pw-${i}-last-login-method`,
|
|
121
121
|
lastLoginEmail: (i) => `pw-${i}-last-login-email`,
|
|
@@ -145,7 +145,7 @@ const y = {
|
|
|
145
145
|
// (оптимистично через `decrementBalanceLocal`).
|
|
146
146
|
balances: (i, t) => `pw-${i}-${t}-balances-v1`
|
|
147
147
|
};
|
|
148
|
-
function
|
|
148
|
+
function D() {
|
|
149
149
|
const i = typeof globalThis < "u" ? globalThis.crypto : void 0;
|
|
150
150
|
if (i && typeof i.randomUUID == "function") return i.randomUUID();
|
|
151
151
|
const t = new Uint8Array(16);
|
|
@@ -159,18 +159,18 @@ function P() {
|
|
|
159
159
|
}
|
|
160
160
|
async function _(i) {
|
|
161
161
|
try {
|
|
162
|
-
const e = await i.getItem(
|
|
162
|
+
const e = await i.getItem(u.visitorId);
|
|
163
163
|
if (e && typeof e == "string" && e.length >= 16) return e;
|
|
164
164
|
} catch {
|
|
165
165
|
}
|
|
166
|
-
const t =
|
|
166
|
+
const t = D();
|
|
167
167
|
try {
|
|
168
|
-
await i.setItem(
|
|
168
|
+
await i.setItem(u.visitorId, t);
|
|
169
169
|
} catch {
|
|
170
170
|
}
|
|
171
171
|
return t;
|
|
172
172
|
}
|
|
173
|
-
function
|
|
173
|
+
function M(i) {
|
|
174
174
|
const t = new Uint8Array(i), e = typeof globalThis < "u" ? globalThis.crypto : void 0;
|
|
175
175
|
if (e && typeof e.getRandomValues == "function")
|
|
176
176
|
e.getRandomValues(t);
|
|
@@ -183,25 +183,30 @@ function b(i) {
|
|
|
183
183
|
for (let e = 0; e < i.length; e++) t += String.fromCharCode(i[e]);
|
|
184
184
|
return btoa(t).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
185
185
|
}
|
|
186
|
-
function
|
|
187
|
-
return b(
|
|
186
|
+
function j() {
|
|
187
|
+
return b(M(64));
|
|
188
188
|
}
|
|
189
|
-
async function
|
|
189
|
+
async function G(i) {
|
|
190
190
|
const t = new TextEncoder().encode(i), e = globalThis.crypto;
|
|
191
191
|
if (!e?.subtle?.digest)
|
|
192
192
|
throw new Error("crypto.subtle is required for PKCE");
|
|
193
193
|
const s = await e.subtle.digest("SHA-256", t);
|
|
194
194
|
return b(new Uint8Array(s));
|
|
195
195
|
}
|
|
196
|
-
function
|
|
197
|
-
return b(
|
|
196
|
+
function X() {
|
|
197
|
+
return b(M(16));
|
|
198
198
|
}
|
|
199
|
-
const
|
|
199
|
+
const z = 6e4, Q = 600 * 1e3;
|
|
200
200
|
class mt {
|
|
201
201
|
constructor(t) {
|
|
202
202
|
if (this.session = null, this.inflightRefresh = null, this.inflightAnonSignin = null, this.listeners = /* @__PURE__ */ new Set(), this.storageUnwatch = null, this.destroyed = !1, this.oauthFlows = /* @__PURE__ */ new Map(), !t.paywallId)
|
|
203
203
|
throw new o("invalid_config", "paywallId is required");
|
|
204
|
-
|
|
204
|
+
if (!t.apiOrigin)
|
|
205
|
+
throw new o(
|
|
206
|
+
"invalid_config",
|
|
207
|
+
"apiOrigin is required. Pass the paywall custom_domain configured in the platform."
|
|
208
|
+
);
|
|
209
|
+
this.paywallId = t.paywallId, this.apiOrigin = t.apiOrigin, this.storage = R(t.storage), this.api = new P({
|
|
205
210
|
apiOrigin: this.apiOrigin,
|
|
206
211
|
paywallId: t.paywallId,
|
|
207
212
|
fetch: t.fetch
|
|
@@ -292,7 +297,7 @@ class mt {
|
|
|
292
297
|
})
|
|
293
298
|
}
|
|
294
299
|
), n = this.toSession(a, a.user);
|
|
295
|
-
return this.setSession(n, { event: "SIGNED_IN" }), n;
|
|
300
|
+
return this.setSession(n, { event: "SIGNED_IN" }), this.recordLastLogin("email", t.email), n;
|
|
296
301
|
}
|
|
297
302
|
/**
|
|
298
303
|
* Signup. Если в Supabase включён email confirm — сервер возвращает
|
|
@@ -318,9 +323,9 @@ class mt {
|
|
|
318
323
|
}
|
|
319
324
|
);
|
|
320
325
|
if (a.status === "confirmation_required")
|
|
321
|
-
return { kind: "confirmation_required", user: a.user };
|
|
326
|
+
return this.recordLastLogin("email", t.email), { kind: "confirmation_required", user: a.user };
|
|
322
327
|
const n = this.toSession(a, a.user);
|
|
323
|
-
return this.setSession(n, { event: "SIGNED_IN" }), { kind: "signed_in", session: n };
|
|
328
|
+
return this.setSession(n, { event: "SIGNED_IN" }), this.recordLastLogin("email", t.email), { kind: "signed_in", session: n };
|
|
324
329
|
}
|
|
325
330
|
/**
|
|
326
331
|
* Повторная отправка confirmation-email после signUp с включённым
|
|
@@ -618,7 +623,7 @@ class mt {
|
|
|
618
623
|
*/
|
|
619
624
|
async startOAuthFlow(t) {
|
|
620
625
|
await this.hydrated, this.gcOAuthFlows();
|
|
621
|
-
const e =
|
|
626
|
+
const e = j(), s = await G(e), a = X(), n = {}, r = await this.getAccessToken().catch(() => null);
|
|
622
627
|
r && (n.Authorization = `Bearer ${r}`);
|
|
623
628
|
const { authorize_url: l } = await this.api.request(
|
|
624
629
|
`/api/v1/paywall/${this.paywallId}/auth/oauth/init`,
|
|
@@ -636,8 +641,9 @@ class mt {
|
|
|
636
641
|
return this.oauthFlows.set(a, {
|
|
637
642
|
verifier: e,
|
|
638
643
|
userMeta: t.userMeta,
|
|
644
|
+
provider: t.provider,
|
|
639
645
|
startedAt: Date.now()
|
|
640
|
-
}), { authorize_url: l, state: a };
|
|
646
|
+
}), this.recordLastLoginMethod(t.provider), { authorize_url: l, state: a };
|
|
641
647
|
}
|
|
642
648
|
/**
|
|
643
649
|
* Шаг 2 OAuth split-API: обменивает code (полученный из popup) на session,
|
|
@@ -672,7 +678,7 @@ class mt {
|
|
|
672
678
|
if (this.destroyed)
|
|
673
679
|
throw new o("aborted", "AuthClient destroyed mid-flow");
|
|
674
680
|
const n = this.toSession(a, a.user);
|
|
675
|
-
return this.setSession(n, { event: "SIGNED_IN" }), n;
|
|
681
|
+
return this.setSession(n, { event: "SIGNED_IN" }), n.user.email && this.recordLastLoginEmail(n.user.email), n;
|
|
676
682
|
}
|
|
677
683
|
gcOAuthFlows() {
|
|
678
684
|
const t = Date.now() - Q;
|
|
@@ -813,7 +819,7 @@ class mt {
|
|
|
813
819
|
setSession(t, e) {
|
|
814
820
|
if (this.destroyed) return;
|
|
815
821
|
const s = this.session;
|
|
816
|
-
this.session = t, e.skipPersist || this.persist(),
|
|
822
|
+
this.session = t, e.skipPersist || this.persist(), et(s, t) || this.emit(e.event);
|
|
817
823
|
}
|
|
818
824
|
emit(t) {
|
|
819
825
|
for (const e of this.listeners)
|
|
@@ -824,7 +830,7 @@ class mt {
|
|
|
824
830
|
}
|
|
825
831
|
}
|
|
826
832
|
storageKey() {
|
|
827
|
-
return
|
|
833
|
+
return u.authSession(this.paywallId);
|
|
828
834
|
}
|
|
829
835
|
async hydrate() {
|
|
830
836
|
try {
|
|
@@ -878,7 +884,7 @@ class mt {
|
|
|
878
884
|
}
|
|
879
885
|
async readAnonRefreshToken() {
|
|
880
886
|
try {
|
|
881
|
-
const t = await this.storage.getItem(
|
|
887
|
+
const t = await this.storage.getItem(u.anonRefreshToken(this.paywallId));
|
|
882
888
|
return typeof t == "string" && t.length > 0 ? t : null;
|
|
883
889
|
} catch {
|
|
884
890
|
return null;
|
|
@@ -887,7 +893,7 @@ class mt {
|
|
|
887
893
|
async writeAnonRefreshToken(t) {
|
|
888
894
|
try {
|
|
889
895
|
await this.storage.setItem(
|
|
890
|
-
|
|
896
|
+
u.anonRefreshToken(this.paywallId),
|
|
891
897
|
t
|
|
892
898
|
);
|
|
893
899
|
} catch {
|
|
@@ -896,11 +902,41 @@ class mt {
|
|
|
896
902
|
async clearAnonRefreshToken() {
|
|
897
903
|
try {
|
|
898
904
|
await this.storage.removeItem(
|
|
899
|
-
|
|
905
|
+
u.anonRefreshToken(this.paywallId)
|
|
900
906
|
);
|
|
901
907
|
} catch {
|
|
902
908
|
}
|
|
903
909
|
}
|
|
910
|
+
/**
|
|
911
|
+
* Last-used auth method + email — для UI бейджа "Last used" и pre-fill'а
|
|
912
|
+
* email-инпута. Storage paywall-scoped, поэтому переключение между
|
|
913
|
+
* пейволами на одном host'е не пересекает данные. Чтение всегда возвращает
|
|
914
|
+
* объект — отсутствующие поля = null. */
|
|
915
|
+
async getLastLogin() {
|
|
916
|
+
try {
|
|
917
|
+
const [t, e] = await Promise.all([
|
|
918
|
+
this.storage.getItem(u.lastLoginMethod(this.paywallId)),
|
|
919
|
+
this.storage.getItem(u.lastLoginEmail(this.paywallId))
|
|
920
|
+
]);
|
|
921
|
+
return !t || !tt(t) ? null : { method: t, email: typeof e == "string" && e ? e : null };
|
|
922
|
+
} catch {
|
|
923
|
+
return null;
|
|
924
|
+
}
|
|
925
|
+
}
|
|
926
|
+
/** Запись method и email атомарно (для email/password flows — оба известны
|
|
927
|
+
* на момент signin/signup'а). OAuth-flows используют раздельные
|
|
928
|
+
* recordLastLoginMethod (до popup) и recordLastLoginEmail (после exchange). */
|
|
929
|
+
recordLastLogin(t, e) {
|
|
930
|
+
this.recordLastLoginMethod(t), e && this.recordLastLoginEmail(e);
|
|
931
|
+
}
|
|
932
|
+
recordLastLoginMethod(t) {
|
|
933
|
+
this.storage.setItem(u.lastLoginMethod(this.paywallId), t).catch(() => {
|
|
934
|
+
});
|
|
935
|
+
}
|
|
936
|
+
recordLastLoginEmail(t) {
|
|
937
|
+
this.storage.setItem(u.lastLoginEmail(this.paywallId), t).catch(() => {
|
|
938
|
+
});
|
|
939
|
+
}
|
|
904
940
|
/**
|
|
905
941
|
* Читает stable visitor_id из storage если он там уже есть. НЕ генерит:
|
|
906
942
|
* AuthClient может быть инстанцирован раньше BillingClient, а синтетический
|
|
@@ -910,7 +946,7 @@ class mt {
|
|
|
910
946
|
*/
|
|
911
947
|
async readVisitorId() {
|
|
912
948
|
try {
|
|
913
|
-
const t = await this.storage.getItem(
|
|
949
|
+
const t = await this.storage.getItem(u.visitorId);
|
|
914
950
|
return typeof t == "string" && t.length >= 16 ? t : void 0;
|
|
915
951
|
} catch {
|
|
916
952
|
return;
|
|
@@ -922,10 +958,10 @@ function Z(i, t) {
|
|
|
922
958
|
return new Promise((e, s) => {
|
|
923
959
|
let a = !1;
|
|
924
960
|
const n = () => {
|
|
925
|
-
a = !0, window.removeEventListener("message", r), clearInterval(l), clearTimeout(
|
|
926
|
-
}, r = (
|
|
961
|
+
a = !0, window.removeEventListener("message", r), clearInterval(l), clearTimeout(d);
|
|
962
|
+
}, r = (f) => {
|
|
927
963
|
if (a) return;
|
|
928
|
-
const c =
|
|
964
|
+
const c = f.data;
|
|
929
965
|
if (!(!c || c.type !== "pw-oauth") && c.messageId === t) {
|
|
930
966
|
if (c.status === "success" && c.code) {
|
|
931
967
|
n();
|
|
@@ -950,14 +986,14 @@ function Z(i, t) {
|
|
|
950
986
|
}
|
|
951
987
|
}, l = setInterval(() => {
|
|
952
988
|
if (a) return;
|
|
953
|
-
let
|
|
989
|
+
let f;
|
|
954
990
|
try {
|
|
955
|
-
|
|
991
|
+
f = i.closed;
|
|
956
992
|
} catch {
|
|
957
993
|
return;
|
|
958
994
|
}
|
|
959
|
-
|
|
960
|
-
}, Y),
|
|
995
|
+
f && (n(), s(new o("oauth_cancelled", "auth popup was closed")));
|
|
996
|
+
}, Y), d = setTimeout(() => {
|
|
961
997
|
if (!a) {
|
|
962
998
|
n();
|
|
963
999
|
try {
|
|
@@ -970,15 +1006,22 @@ function Z(i, t) {
|
|
|
970
1006
|
window.addEventListener("message", r);
|
|
971
1007
|
});
|
|
972
1008
|
}
|
|
973
|
-
function tt(i
|
|
1009
|
+
function tt(i) {
|
|
1010
|
+
return i === "google" || i === "apple" || i === "github" || i === "facebook" || i === "email";
|
|
1011
|
+
}
|
|
1012
|
+
function et(i, t) {
|
|
974
1013
|
return i === t ? !0 : !i || !t ? !1 : i.access_token === t.access_token && i.refresh_token === t.refresh_token && i.expires_at === t.expires_at && i.user.id === t.user.id && i.user.email === t.user.email;
|
|
975
1014
|
}
|
|
976
|
-
const et = "https://appbox.space";
|
|
977
1015
|
class st {
|
|
978
1016
|
constructor(t) {
|
|
979
1017
|
if (!t.paywallId)
|
|
980
1018
|
throw new o("invalid_config", "paywallId is required");
|
|
981
|
-
|
|
1019
|
+
if (!t.apiOrigin)
|
|
1020
|
+
throw new o(
|
|
1021
|
+
"invalid_config",
|
|
1022
|
+
"apiOrigin is required. Pass the paywall custom_domain configured in the platform."
|
|
1023
|
+
);
|
|
1024
|
+
this.paywallId = t.paywallId, this.apiOrigin = t.apiOrigin, this.auth = t.auth, this.userId = t.userId, this.capabilities = t.capabilities, this.customFetch = t.fetch, this.onChargeSuccess = t.onChargeSuccess, this.onQuotaExceeded = t.onQuotaExceeded, t.userId && !t.auth && typeof window < "u" && typeof window.document < "u" && console.warn(
|
|
982
1025
|
"[paywall] WARNING: ApiGatewayClient.userId set without auth in browser. Client can spoof userId. Use AuthClient + Bearer for trusted user.id."
|
|
983
1026
|
);
|
|
984
1027
|
}
|
|
@@ -992,13 +1035,13 @@ class st {
|
|
|
992
1035
|
a.set("X-SDK-Version", m), a.set("X-Paywall-Id", this.paywallId), this.capabilities?.length && a.set("X-SDK-Capabilities", this.capabilities.join(","));
|
|
993
1036
|
const n = await this.auth?.getAccessToken();
|
|
994
1037
|
n ? a.set("Authorization", `Bearer ${n}`) : this.userId && a.set("X-User-ID", this.userId);
|
|
995
|
-
const r = typeof FormData < "u" && t.body instanceof FormData, l = typeof Blob < "u" && t.body instanceof Blob,
|
|
1038
|
+
const r = typeof FormData < "u" && t.body instanceof FormData, l = typeof Blob < "u" && t.body instanceof Blob, d = typeof ReadableStream < "u" && t.body instanceof ReadableStream, f = typeof t.body == "string";
|
|
996
1039
|
let c;
|
|
997
|
-
t.body === void 0 || t.body === null ? c = void 0 : r || l ||
|
|
998
|
-
const
|
|
1040
|
+
t.body === void 0 || t.body === null ? c = void 0 : r || l || d || f ? c = t.body : (c = JSON.stringify(t.body), a.has("Content-Type") || a.set("Content-Type", "application/json"));
|
|
1041
|
+
const y = this.customFetch ?? fetch;
|
|
999
1042
|
let h;
|
|
1000
1043
|
try {
|
|
1001
|
-
h = await
|
|
1044
|
+
h = await y(s.toString(), {
|
|
1002
1045
|
method: t.method ?? "POST",
|
|
1003
1046
|
headers: a,
|
|
1004
1047
|
body: c,
|
|
@@ -1006,8 +1049,8 @@ class st {
|
|
|
1006
1049
|
credentials: "omit"
|
|
1007
1050
|
});
|
|
1008
1051
|
} catch (p) {
|
|
1009
|
-
const
|
|
1010
|
-
throw new o("network_error", `Network request failed: ${
|
|
1052
|
+
const $ = p instanceof Error ? p.message : String(p);
|
|
1053
|
+
throw new o("network_error", `Network request failed: ${$}`, { cause: p });
|
|
1011
1054
|
}
|
|
1012
1055
|
if (h.status === 402) {
|
|
1013
1056
|
const p = await it(h);
|
|
@@ -1021,8 +1064,8 @@ class st {
|
|
|
1021
1064
|
{ status: h.status }
|
|
1022
1065
|
);
|
|
1023
1066
|
}
|
|
1024
|
-
const
|
|
1025
|
-
return this.onChargeSuccess?.(
|
|
1067
|
+
const g = h.headers.get("X-Query-Type") ?? void 0;
|
|
1068
|
+
return this.onChargeSuccess?.(g), h;
|
|
1026
1069
|
}
|
|
1027
1070
|
}
|
|
1028
1071
|
async function it(i) {
|
|
@@ -1037,7 +1080,7 @@ async function it(i) {
|
|
|
1037
1080
|
const a = e[0];
|
|
1038
1081
|
Array.isArray(a) ? s = a : a && Array.isArray(a.balances) && (s = a.balances);
|
|
1039
1082
|
}
|
|
1040
|
-
return new
|
|
1083
|
+
return new F({
|
|
1041
1084
|
balances: s,
|
|
1042
1085
|
queryType: t.details?.queryType ?? "",
|
|
1043
1086
|
currentBalance: t.details?.currentBalance ?? null
|
|
@@ -1052,12 +1095,13 @@ async function at(i) {
|
|
|
1052
1095
|
return null;
|
|
1053
1096
|
}
|
|
1054
1097
|
}
|
|
1055
|
-
const nt = 5e3, rt = 30 * 6e4, B = 60 * 6e4, ot = 5 * 6e4,
|
|
1098
|
+
const nt = 5e3, rt = 30 * 6e4, B = 60 * 6e4, ot = 5 * 6e4, k = {
|
|
1056
1099
|
has_active_subscription: !1,
|
|
1057
1100
|
purchases: [],
|
|
1058
|
-
trial: null
|
|
1101
|
+
trial: null,
|
|
1102
|
+
had_previous_trial: !1
|
|
1059
1103
|
};
|
|
1060
|
-
function
|
|
1104
|
+
function A(i) {
|
|
1061
1105
|
return i && (i.email || i.userId || i.anonymousId) || "guest";
|
|
1062
1106
|
}
|
|
1063
1107
|
function ct(i, t) {
|
|
@@ -1071,16 +1115,20 @@ function ut(i, t) {
|
|
|
1071
1115
|
if (i[e].type !== t[e].type || i[e].count !== t[e].count) return !1;
|
|
1072
1116
|
return !0;
|
|
1073
1117
|
}
|
|
1074
|
-
|
|
1075
|
-
class It {
|
|
1118
|
+
class St {
|
|
1076
1119
|
constructor(t) {
|
|
1077
1120
|
if (this.cachedBootstrap = null, this.cachedBootstrapAt = 0, this.inflightBootstrap = null, this.bootstrapListeners = /* @__PURE__ */ new Set(), this.bootstrapStorageUnwatch = null, this.authUnsubscribe = null, this.cachedUser = null, this.cachedUserAt = 0, this.inflightUser = null, this.userListeners = /* @__PURE__ */ new Set(), this.visitorIdPromise = null, this.visitorId = null, this.inflightCheckouts = /* @__PURE__ */ new Map(), this.cachedBalances = null, this.cachedBalancesAt = 0, this.balancesStorageUnwatch = null, this.inflightBalances = null, this.balanceListeners = /* @__PURE__ */ new Set(), this.previewVersionCounter = 0, !t.paywallId)
|
|
1078
1121
|
throw new o("invalid_config", "paywallId is required");
|
|
1079
|
-
|
|
1122
|
+
if (!t.apiOrigin)
|
|
1123
|
+
throw new o(
|
|
1124
|
+
"invalid_config",
|
|
1125
|
+
'apiOrigin is required. Pass the paywall custom_domain configured in the platform (e.g. "https://pay.your-domain.com"). The legacy "appbox.space" fallback is not used in SDK 3.0.'
|
|
1126
|
+
);
|
|
1127
|
+
this.paywallId = t.paywallId, this.apiOrigin = t.apiOrigin, this.capabilities = t.capabilities, this.auth = t.auth, this.previewMode = t.preview === !0;
|
|
1080
1128
|
const e = t.auth?.getCachedUser();
|
|
1081
|
-
this.identity = t.identity ?? (e ?
|
|
1129
|
+
this.identity = t.identity ?? (e ? O(e) : void 0), this.apiKey = t.apiKey, this.fetchImpl = t.fetch, t.apiKey && typeof window < "u" && typeof window.document < "u" && console.error(
|
|
1082
1130
|
"[paywall] SECURITY: BillingClient.apiKey detected in browser context. This is a server-SDK key and exposes your account. Remove apiKey or move BillingClient to a trusted backend."
|
|
1083
|
-
), this.storage = R(t.storage), this.api = new
|
|
1131
|
+
), this.storage = R(t.storage), this.api = new P({
|
|
1084
1132
|
apiOrigin: this.apiOrigin,
|
|
1085
1133
|
paywallId: t.paywallId,
|
|
1086
1134
|
capabilities: t.capabilities,
|
|
@@ -1090,8 +1138,8 @@ class It {
|
|
|
1090
1138
|
// Authorization-хедер просто не выставится.
|
|
1091
1139
|
getAuthToken: t.auth ? () => t.auth.getAccessToken() : void 0
|
|
1092
1140
|
}), t.auth && (this.authUnsubscribe = t.auth.onAuthChange((s, a) => {
|
|
1093
|
-
const n = a ?
|
|
1094
|
-
|
|
1141
|
+
const n = a ? O(a.user) : void 0;
|
|
1142
|
+
dt(this.identity, n) || this.setIdentity(n);
|
|
1095
1143
|
})), this.hydrateUserFromStorage(), this.hydrateBootstrapFromStorage(), this.subscribeBootstrapStorage(), this.hydrateBalancesFromStorage(), this.subscribeBalancesStorage(), this.visitorIdPromise = _(this.storage).then((s) => (this.visitorId = s, s));
|
|
1096
1144
|
}
|
|
1097
1145
|
/**
|
|
@@ -1186,7 +1234,7 @@ class It {
|
|
|
1186
1234
|
offers: t.offers !== void 0 ? t.offers : e.offers,
|
|
1187
1235
|
version: `preview:${++this.previewVersionCounter}`
|
|
1188
1236
|
};
|
|
1189
|
-
s.layout || (s.layout =
|
|
1237
|
+
s.layout || (s.layout = E(s.settings, s.prices)), w(s), this.cachedBootstrap = s, this.cachedBootstrapAt = Date.now();
|
|
1190
1238
|
for (const a of this.bootstrapListeners)
|
|
1191
1239
|
try {
|
|
1192
1240
|
a(s);
|
|
@@ -1208,7 +1256,7 @@ class It {
|
|
|
1208
1256
|
if ("unchanged" in a && a.unchanged)
|
|
1209
1257
|
return this.cachedBootstrap ? (this.cachedBootstrapAt = Date.now(), a.user && this.applyUser(a.user), this.cachedBootstrap) : this.fetchBootstrap({ signal: t.signal });
|
|
1210
1258
|
const n = a;
|
|
1211
|
-
return n.layout || (n.layout =
|
|
1259
|
+
return ft(n.settings.custom_domain, this.apiOrigin), n.layout || (n.layout = E(n.settings, n.prices)), w(n), this.applyBootstrap(n, { persist: !0 }), n.user && this.applyUser(n.user), n;
|
|
1212
1260
|
}
|
|
1213
1261
|
// Фоновый revalidate из stale-while-revalidate ветки. Дедуплицируется через
|
|
1214
1262
|
// `inflightBootstrap`, чтобы параллельные revalidate'ы не пересекались.
|
|
@@ -1238,11 +1286,11 @@ class It {
|
|
|
1238
1286
|
async hydrateBootstrapFromStorage() {
|
|
1239
1287
|
if (!this.cachedBootstrap)
|
|
1240
1288
|
try {
|
|
1241
|
-
const t = await this.storage.getItem(
|
|
1289
|
+
const t = await this.storage.getItem(u.bootstrap(this.paywallId));
|
|
1242
1290
|
if (!t) return;
|
|
1243
1291
|
const e = JSON.parse(t);
|
|
1244
1292
|
if (!e?.bootstrap || Date.now() - e.at > B || this.cachedBootstrap) return;
|
|
1245
|
-
|
|
1293
|
+
w(e.bootstrap), this.cachedBootstrap = e.bootstrap, this.cachedBootstrapAt = e.at;
|
|
1246
1294
|
for (const s of this.bootstrapListeners)
|
|
1247
1295
|
try {
|
|
1248
1296
|
s(e.bootstrap);
|
|
@@ -1257,7 +1305,7 @@ class It {
|
|
|
1257
1305
|
try {
|
|
1258
1306
|
const { user: e, ...s } = t;
|
|
1259
1307
|
await this.storage.setItem(
|
|
1260
|
-
|
|
1308
|
+
u.bootstrap(this.paywallId),
|
|
1261
1309
|
JSON.stringify({ at: Date.now(), bootstrap: s })
|
|
1262
1310
|
);
|
|
1263
1311
|
} catch {
|
|
@@ -1268,7 +1316,7 @@ class It {
|
|
|
1268
1316
|
// no-op, всё работает как раньше через сеть.
|
|
1269
1317
|
subscribeBootstrapStorage() {
|
|
1270
1318
|
typeof this.storage.watch == "function" && (this.bootstrapStorageUnwatch = this.storage.watch(
|
|
1271
|
-
|
|
1319
|
+
u.bootstrap(this.paywallId),
|
|
1272
1320
|
(t) => {
|
|
1273
1321
|
if (t)
|
|
1274
1322
|
try {
|
|
@@ -1278,7 +1326,7 @@ class It {
|
|
|
1278
1326
|
this.cachedBootstrapAt = e.at;
|
|
1279
1327
|
return;
|
|
1280
1328
|
}
|
|
1281
|
-
|
|
1329
|
+
w(e.bootstrap), this.applyBootstrap(e.bootstrap, { persist: !1 });
|
|
1282
1330
|
} catch {
|
|
1283
1331
|
}
|
|
1284
1332
|
}
|
|
@@ -1325,7 +1373,7 @@ class It {
|
|
|
1325
1373
|
* есть `navigator.language`.
|
|
1326
1374
|
*/
|
|
1327
1375
|
getUserLanguage() {
|
|
1328
|
-
const t = typeof navigator < "u" && navigator.language ? navigator.language : null, e = this.cachedBootstrap?.settings.locale_default ?? null, s = this.cachedBootstrap ?
|
|
1376
|
+
const t = typeof navigator < "u" && navigator.language ? navigator.language : null, e = this.cachedBootstrap?.settings.locale_default ?? null, s = this.cachedBootstrap ? q(this.cachedBootstrap) : null;
|
|
1329
1377
|
return { tag: s ?? t ?? e, applied: s, browserLanguage: t, countryLanguage: e };
|
|
1330
1378
|
}
|
|
1331
1379
|
/**
|
|
@@ -1340,7 +1388,7 @@ class It {
|
|
|
1340
1388
|
return !t && this.cachedUser && Date.now() - this.cachedUserAt < nt ? this.cachedUser : this.inflightUser ? this.inflightUser : (this.inflightUser = (async () => {
|
|
1341
1389
|
try {
|
|
1342
1390
|
if (!this.identity?.email)
|
|
1343
|
-
return this.applyUser(
|
|
1391
|
+
return this.applyUser(k), k;
|
|
1344
1392
|
const s = await this.api.request(
|
|
1345
1393
|
`/api/v1/paywall/${this.paywallId}/user-state`,
|
|
1346
1394
|
{ headers: { "X-User-Email": this.identity.email }, signal: e }
|
|
@@ -1405,7 +1453,7 @@ class It {
|
|
|
1405
1453
|
}
|
|
1406
1454
|
}
|
|
1407
1455
|
storageKey() {
|
|
1408
|
-
return
|
|
1456
|
+
return u.userState(this.paywallId, A(this.identity));
|
|
1409
1457
|
}
|
|
1410
1458
|
async hydrateUserFromStorage() {
|
|
1411
1459
|
if (!this.cachedUser)
|
|
@@ -1560,7 +1608,7 @@ class It {
|
|
|
1560
1608
|
}
|
|
1561
1609
|
}
|
|
1562
1610
|
balancesStorageKey() {
|
|
1563
|
-
return
|
|
1611
|
+
return u.balances(this.paywallId, A(this.identity));
|
|
1564
1612
|
}
|
|
1565
1613
|
async hydrateBalancesFromStorage() {
|
|
1566
1614
|
if (!this.cachedBalances)
|
|
@@ -1614,10 +1662,10 @@ class It {
|
|
|
1614
1662
|
const e = t.idempotencyKey ?? `auto:${t.priceId}`, s = this.inflightCheckouts.get(e);
|
|
1615
1663
|
if (s) return s;
|
|
1616
1664
|
const n = {
|
|
1617
|
-
"Idempotency-Key": t.idempotencyKey ??
|
|
1665
|
+
"Idempotency-Key": t.idempotencyKey ?? D()
|
|
1618
1666
|
};
|
|
1619
1667
|
this.apiKey && (n["X-Api-Key"] = this.apiKey);
|
|
1620
|
-
const r = this.cachedBootstrap?.settings, l = t.successUrl ?? r?.success_redirect_url ?? void 0,
|
|
1668
|
+
const r = this.cachedBootstrap?.settings, l = t.successUrl ?? r?.success_redirect_url ?? void 0, d = t.shopUrl ?? r?.checkout_shop_url ?? void 0, f = this.api.request(`/api/v1/paywall/${this.paywallId}/start-checkout`, {
|
|
1621
1669
|
method: "POST",
|
|
1622
1670
|
headers: n,
|
|
1623
1671
|
signal: t.signal,
|
|
@@ -1626,7 +1674,7 @@ class It {
|
|
|
1626
1674
|
priceId: Number(t.priceId),
|
|
1627
1675
|
successUrl: l,
|
|
1628
1676
|
errorUrl: t.errorUrl,
|
|
1629
|
-
shopUrl:
|
|
1677
|
+
shopUrl: d,
|
|
1630
1678
|
productName: r?.checkout_product_name ?? void 0,
|
|
1631
1679
|
trial_days: t.trialDays,
|
|
1632
1680
|
ignoreActivePurchase: t.ignoreActivePurchase ? !0 : void 0,
|
|
@@ -1639,10 +1687,10 @@ class It {
|
|
|
1639
1687
|
{ status: 409, cause: c.cause }
|
|
1640
1688
|
) : c;
|
|
1641
1689
|
});
|
|
1642
|
-
return this.inflightCheckouts.set(e,
|
|
1643
|
-
this.inflightCheckouts.get(e) ===
|
|
1690
|
+
return this.inflightCheckouts.set(e, f), f.finally(() => {
|
|
1691
|
+
this.inflightCheckouts.get(e) === f && this.inflightCheckouts.delete(e);
|
|
1644
1692
|
}).catch(() => {
|
|
1645
|
-
}),
|
|
1693
|
+
}), f;
|
|
1646
1694
|
}
|
|
1647
1695
|
/**
|
|
1648
1696
|
* URL Stripe/Paddle/Chargebee customer portal — место, где залогиненный
|
|
@@ -1758,23 +1806,46 @@ class It {
|
|
|
1758
1806
|
});
|
|
1759
1807
|
}
|
|
1760
1808
|
}
|
|
1761
|
-
function
|
|
1809
|
+
function O(i) {
|
|
1762
1810
|
return { email: i.email, userId: i.id };
|
|
1763
1811
|
}
|
|
1764
|
-
function
|
|
1812
|
+
function dt(i, t) {
|
|
1765
1813
|
return i === t ? !0 : !i || !t ? !1 : i.email === t.email && i.userId === t.userId && i.anonymousId === t.anonymousId;
|
|
1766
1814
|
}
|
|
1767
|
-
function
|
|
1815
|
+
function U(i) {
|
|
1816
|
+
if (!i) return null;
|
|
1817
|
+
const t = i.trim();
|
|
1818
|
+
if (!t) return null;
|
|
1819
|
+
try {
|
|
1820
|
+
return new URL(t.includes("://") ? t : `https://${t}`).origin;
|
|
1821
|
+
} catch {
|
|
1822
|
+
return null;
|
|
1823
|
+
}
|
|
1824
|
+
}
|
|
1825
|
+
function ft(i, t) {
|
|
1826
|
+
const e = U(i);
|
|
1827
|
+
if (!(!e || U(t) === e))
|
|
1828
|
+
throw new o(
|
|
1829
|
+
"invalid_config",
|
|
1830
|
+
`apiOrigin mismatch: SDK initialized with "${t}" but paywall is configured with custom_domain "${i}". Use the custom_domain from the platform paywall settings.`
|
|
1831
|
+
);
|
|
1832
|
+
}
|
|
1833
|
+
function E(i, t) {
|
|
1768
1834
|
return {
|
|
1769
1835
|
type: "modal",
|
|
1770
1836
|
blocks: [
|
|
1837
|
+
// offer_banner НЕ в default layout — PaywallRoot рендерит его как
|
|
1838
|
+
// top-tab над dialog'ом (rounded-top, negative margin), за пределами
|
|
1839
|
+
// scrollable area. Блок остаётся в registry для opt-in inline-вариантa.
|
|
1771
1840
|
{ type: "heading", text: i.name || "Upgrade", level: 1 },
|
|
1772
1841
|
{ type: "price_grid", priceIds: t.map((e) => e.id) },
|
|
1773
|
-
{ type: "cta_button",
|
|
1842
|
+
{ type: "cta_button", action: "checkout" },
|
|
1843
|
+
{ type: "guarantee_badge" },
|
|
1844
|
+
{ type: "current_session" }
|
|
1774
1845
|
]
|
|
1775
1846
|
};
|
|
1776
1847
|
}
|
|
1777
|
-
function
|
|
1848
|
+
function q(i) {
|
|
1778
1849
|
const t = i.locales;
|
|
1779
1850
|
if (!t) return null;
|
|
1780
1851
|
const e = [];
|
|
@@ -1789,8 +1860,8 @@ function M(i) {
|
|
|
1789
1860
|
if (a && Object.prototype.hasOwnProperty.call(t, a)) return a;
|
|
1790
1861
|
return null;
|
|
1791
1862
|
}
|
|
1792
|
-
function
|
|
1793
|
-
const t =
|
|
1863
|
+
function w(i) {
|
|
1864
|
+
const t = q(i);
|
|
1794
1865
|
if (!t) return;
|
|
1795
1866
|
const e = i.locales?.[t];
|
|
1796
1867
|
e && (e.layout && (i.layout = e.layout), e.prices && (i.prices = i.prices.map((s) => {
|
|
@@ -1800,8 +1871,8 @@ function g(i) {
|
|
|
1800
1871
|
return "label" in a && (n.label = a.label ?? null), "description" in a && (n.description = a.description ?? null), n;
|
|
1801
1872
|
})));
|
|
1802
1873
|
}
|
|
1803
|
-
const yt = 1500, pt = 20,
|
|
1804
|
-
class
|
|
1874
|
+
const yt = 1500, pt = 20, L = 200;
|
|
1875
|
+
class It {
|
|
1805
1876
|
constructor(t) {
|
|
1806
1877
|
this.buffer = [], this.flushTimer = null, this.destroyed = !1, this.unloadHandler = null, this.visibilityHandler = null, this.opts = t, this.isEnabled() && this.attachUnloadHandlers();
|
|
1807
1878
|
}
|
|
@@ -1816,7 +1887,7 @@ class St {
|
|
|
1816
1887
|
this.flush();
|
|
1817
1888
|
return;
|
|
1818
1889
|
}
|
|
1819
|
-
this.buffer.length >
|
|
1890
|
+
this.buffer.length > L && (this.buffer = this.buffer.slice(-L)), this.scheduleFlush();
|
|
1820
1891
|
}
|
|
1821
1892
|
scheduleFlush() {
|
|
1822
1893
|
if (this.flushTimer || this.destroyed) return;
|
|
@@ -1900,13 +1971,13 @@ class St {
|
|
|
1900
1971
|
}
|
|
1901
1972
|
}
|
|
1902
1973
|
const C = 3600 * 1e3;
|
|
1903
|
-
function
|
|
1974
|
+
function I(i) {
|
|
1904
1975
|
return `paywall-${i}-trial-time-first-open`;
|
|
1905
1976
|
}
|
|
1906
1977
|
function v(i) {
|
|
1907
1978
|
return `paywall-${i}-skip-times`;
|
|
1908
1979
|
}
|
|
1909
|
-
class
|
|
1980
|
+
class K {
|
|
1910
1981
|
constructor(t, e, s) {
|
|
1911
1982
|
this.storage = t, this.paywallId = e, this.config = s;
|
|
1912
1983
|
}
|
|
@@ -1917,10 +1988,10 @@ class F {
|
|
|
1917
1988
|
return this.config.mode === "time" ? this.recordTime() : this.recordOpens();
|
|
1918
1989
|
}
|
|
1919
1990
|
async reset() {
|
|
1920
|
-
await this.storage.removeItem(this.config.mode === "time" ?
|
|
1991
|
+
await this.storage.removeItem(this.config.mode === "time" ? I(this.paywallId) : v(this.paywallId));
|
|
1921
1992
|
}
|
|
1922
1993
|
async checkTime() {
|
|
1923
|
-
const t = this.config.payload * C, e = await this.storage.getItem(
|
|
1994
|
+
const t = this.config.payload * C, e = await this.storage.getItem(I(this.paywallId)), s = e ? Number(e) : null;
|
|
1924
1995
|
if (!s || !Number.isFinite(s))
|
|
1925
1996
|
return {
|
|
1926
1997
|
mode: "time",
|
|
@@ -1950,7 +2021,7 @@ class F {
|
|
|
1950
2021
|
};
|
|
1951
2022
|
}
|
|
1952
2023
|
async recordTime() {
|
|
1953
|
-
const t = this.config.payload * C, e =
|
|
2024
|
+
const t = this.config.payload * C, e = I(this.paywallId), s = await this.storage.getItem(e);
|
|
1954
2025
|
let a = s ? Number(s) : null;
|
|
1955
2026
|
(!a || !Number.isFinite(a)) && (a = Date.now(), await this.storage.setItem(e, String(a)));
|
|
1956
2027
|
const n = a + t, r = Math.max(0, n - Date.now());
|
|
@@ -1976,11 +2047,11 @@ class F {
|
|
|
1976
2047
|
}
|
|
1977
2048
|
}
|
|
1978
2049
|
let N = !1;
|
|
1979
|
-
class
|
|
2050
|
+
class gt {
|
|
1980
2051
|
constructor(t, e, s) {
|
|
1981
2052
|
N || (N = !0, console.warn(
|
|
1982
2053
|
'[paywall] trial.storage="server" is not implemented yet — falling back to client storage. State lives in localStorage; users can reset trial by clearing site data.'
|
|
1983
|
-
)), this.fallback = new
|
|
2054
|
+
)), this.fallback = new K(t, e, s);
|
|
1984
2055
|
}
|
|
1985
2056
|
check() {
|
|
1986
2057
|
return this.fallback.check();
|
|
@@ -1993,7 +2064,7 @@ class wt {
|
|
|
1993
2064
|
}
|
|
1994
2065
|
}
|
|
1995
2066
|
function vt(i, t, e) {
|
|
1996
|
-
return e.storage === "server" ? new
|
|
2067
|
+
return e.storage === "server" ? new gt(i, t, e) : new K(i, t, e);
|
|
1997
2068
|
}
|
|
1998
2069
|
const bt = 1;
|
|
1999
2070
|
function _t(i) {
|
|
@@ -2022,7 +2093,7 @@ function Bt(i) {
|
|
|
2022
2093
|
const t = new Error(i.message);
|
|
2023
2094
|
return t.name = i.name, i.stack && (t.stack = i.stack), t;
|
|
2024
2095
|
}
|
|
2025
|
-
function
|
|
2096
|
+
function wt(i) {
|
|
2026
2097
|
let t = !1;
|
|
2027
2098
|
const e = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set(), a = (r) => {
|
|
2028
2099
|
for (const l of e) l(r);
|
|
@@ -2054,21 +2125,21 @@ function gt(i) {
|
|
|
2054
2125
|
}
|
|
2055
2126
|
};
|
|
2056
2127
|
}
|
|
2057
|
-
function
|
|
2128
|
+
function kt(i) {
|
|
2058
2129
|
const t = chrome.runtime.connect({ name: i });
|
|
2059
|
-
return
|
|
2130
|
+
return wt(t);
|
|
2060
2131
|
}
|
|
2061
2132
|
export {
|
|
2062
2133
|
mt as A,
|
|
2063
|
-
|
|
2064
|
-
|
|
2134
|
+
St as B,
|
|
2135
|
+
It as E,
|
|
2065
2136
|
o as P,
|
|
2066
2137
|
bt as a,
|
|
2067
|
-
|
|
2138
|
+
kt as b,
|
|
2068
2139
|
vt as c,
|
|
2069
|
-
|
|
2140
|
+
wt as p,
|
|
2070
2141
|
Bt as r,
|
|
2071
2142
|
_t as s,
|
|
2072
2143
|
Z as w
|
|
2073
2144
|
};
|
|
2074
|
-
//# sourceMappingURL=chrome-port-
|
|
2145
|
+
//# sourceMappingURL=chrome-port-CxW3Pwc2.js.map
|