@monetize.software/sdk-extension 3.0.0-alpha.5 → 3.0.0-alpha.7
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-BUQInJ5a.js +2 -0
- package/dist/chunks/ar-BUQInJ5a.js.map +1 -0
- package/dist/chunks/ar-nh4l4WDE.js +125 -0
- package/dist/chunks/ar-nh4l4WDE.js.map +1 -0
- package/dist/chunks/{chrome-port-rPi6zrjD.js → chrome-port-CxW3Pwc2.js} +145 -107
- 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-2UYO2rWf.js +121 -0
- package/dist/chunks/cs-2UYO2rWf.js.map +1 -0
- package/dist/chunks/cs-i5K4KTFV.js +2 -0
- package/dist/chunks/cs-i5K4KTFV.js.map +1 -0
- package/dist/chunks/da-BD0O_HfV.js +121 -0
- package/dist/chunks/da-BD0O_HfV.js.map +1 -0
- package/dist/chunks/da-CZbhtVJO.js +2 -0
- package/dist/chunks/da-CZbhtVJO.js.map +1 -0
- package/dist/chunks/de-Bc-GoLgC.js +2 -0
- package/dist/chunks/de-Bc-GoLgC.js.map +1 -0
- package/dist/chunks/de-BkCiXPsn.js +139 -0
- package/dist/chunks/de-BkCiXPsn.js.map +1 -0
- package/dist/chunks/el-CcMEbl_F.js +2 -0
- package/dist/chunks/el-CcMEbl_F.js.map +1 -0
- package/dist/chunks/el-cIcxTp07.js +125 -0
- package/dist/chunks/el-cIcxTp07.js.map +1 -0
- package/dist/chunks/es-BvYmomAz.js +2 -0
- package/dist/chunks/es-BvYmomAz.js.map +1 -0
- package/dist/chunks/es-CJBC_jrV.js +139 -0
- package/dist/chunks/es-CJBC_jrV.js.map +1 -0
- package/dist/chunks/fi-DyV7ynBf.js +121 -0
- package/dist/chunks/fi-DyV7ynBf.js.map +1 -0
- package/dist/chunks/fi-aZR-qmZN.js +2 -0
- package/dist/chunks/fi-aZR-qmZN.js.map +1 -0
- package/dist/chunks/fr-BLQ4AIu7.js +139 -0
- package/dist/chunks/fr-BLQ4AIu7.js.map +1 -0
- package/dist/chunks/fr-BgbFAgHx.js +2 -0
- package/dist/chunks/fr-BgbFAgHx.js.map +1 -0
- package/dist/chunks/he-Bg-Bqi7r.js +125 -0
- package/dist/chunks/he-Bg-Bqi7r.js.map +1 -0
- package/dist/chunks/he-CQ4yCuja.js +2 -0
- package/dist/chunks/he-CQ4yCuja.js.map +1 -0
- package/dist/chunks/hi-DtUsj1c-.js +2 -0
- package/dist/chunks/hi-DtUsj1c-.js.map +1 -0
- package/dist/chunks/hi-wQeE43oY.js +125 -0
- package/dist/chunks/hi-wQeE43oY.js.map +1 -0
- package/dist/chunks/hu-D9qxzu0r.js +121 -0
- package/dist/chunks/hu-D9qxzu0r.js.map +1 -0
- package/dist/chunks/hu-DXtscQ8_.js +2 -0
- package/dist/chunks/hu-DXtscQ8_.js.map +1 -0
- package/dist/chunks/id-BByOYpeo.js +2 -0
- package/dist/chunks/id-BByOYpeo.js.map +1 -0
- package/dist/chunks/id-Rx_wYvqy.js +121 -0
- package/dist/chunks/id-Rx_wYvqy.js.map +1 -0
- package/dist/chunks/it-52Ip42pa.js +2 -0
- package/dist/chunks/it-52Ip42pa.js.map +1 -0
- package/dist/chunks/it-B1SRPZ3e.js +139 -0
- package/dist/chunks/it-B1SRPZ3e.js.map +1 -0
- package/dist/chunks/ja-CMC3Parn.js +2 -0
- package/dist/chunks/ja-CMC3Parn.js.map +1 -0
- package/dist/chunks/ja-DiItm8te.js +143 -0
- package/dist/chunks/ja-DiItm8te.js.map +1 -0
- package/dist/chunks/ko-3qY21q40.js +2 -0
- package/dist/chunks/ko-3qY21q40.js.map +1 -0
- package/dist/chunks/ko-CdGFWAKX.js +143 -0
- package/dist/chunks/ko-CdGFWAKX.js.map +1 -0
- package/dist/chunks/nl-Borc5nw1.js +2 -0
- package/dist/chunks/nl-Borc5nw1.js.map +1 -0
- package/dist/chunks/nl-CmZ3vEvj.js +139 -0
- package/dist/chunks/nl-CmZ3vEvj.js.map +1 -0
- package/dist/chunks/no-BuxByZpq.js +121 -0
- package/dist/chunks/no-BuxByZpq.js.map +1 -0
- package/dist/chunks/no-Do2iGedg.js +2 -0
- package/dist/chunks/no-Do2iGedg.js.map +1 -0
- package/dist/chunks/pl-jZFCnDb8.js +121 -0
- package/dist/chunks/pl-jZFCnDb8.js.map +1 -0
- package/dist/chunks/pl-mRaky_7k.js +2 -0
- package/dist/chunks/pl-mRaky_7k.js.map +1 -0
- package/dist/chunks/pt-Cld7MwIW.js +139 -0
- package/dist/chunks/pt-Cld7MwIW.js.map +1 -0
- package/dist/chunks/pt-DilDTXfs.js +2 -0
- package/dist/chunks/pt-DilDTXfs.js.map +1 -0
- package/dist/chunks/ro-CuKDqj3C.js +121 -0
- package/dist/chunks/ro-CuKDqj3C.js.map +1 -0
- package/dist/chunks/ro-DF2uzPIB.js +2 -0
- package/dist/chunks/ro-DF2uzPIB.js.map +1 -0
- package/dist/chunks/ru-B7cjqJUm.js +135 -0
- package/dist/chunks/ru-B7cjqJUm.js.map +1 -0
- package/dist/chunks/ru-YeaXnTO-.js +2 -0
- package/dist/chunks/ru-YeaXnTO-.js.map +1 -0
- package/dist/chunks/sv-2pHEvuSe.js +2 -0
- package/dist/chunks/sv-2pHEvuSe.js.map +1 -0
- package/dist/chunks/sv-D9y-M1Fo.js +121 -0
- package/dist/chunks/sv-D9y-M1Fo.js.map +1 -0
- package/dist/chunks/th-D9umBjEy.js +125 -0
- package/dist/chunks/th-D9umBjEy.js.map +1 -0
- package/dist/chunks/th-u2QSDF0G.js +2 -0
- package/dist/chunks/th-u2QSDF0G.js.map +1 -0
- package/dist/chunks/tr-BddMywiw.js +121 -0
- package/dist/chunks/tr-BddMywiw.js.map +1 -0
- package/dist/chunks/tr-Bhgm6_ti.js +2 -0
- package/dist/chunks/tr-Bhgm6_ti.js.map +1 -0
- package/dist/chunks/uk-7vwqsaVK.js +2 -0
- package/dist/chunks/uk-7vwqsaVK.js.map +1 -0
- package/dist/chunks/uk-Dbd31hFt.js +135 -0
- package/dist/chunks/uk-Dbd31hFt.js.map +1 -0
- package/dist/chunks/vi-CJefLP_g.js +2 -0
- package/dist/chunks/vi-CJefLP_g.js.map +1 -0
- package/dist/chunks/vi-Do3BMOdh.js +121 -0
- package/dist/chunks/vi-Do3BMOdh.js.map +1 -0
- package/dist/chunks/zh-D5C3BzYL.js +2 -0
- package/dist/chunks/zh-D5C3BzYL.js.map +1 -0
- package/dist/chunks/zh-gQSYLZI3.js +143 -0
- package/dist/chunks/zh-gQSYLZI3.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 +1977 -949
- 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-rPi6zrjD.js.map +0 -1
- package/dist/chunks/chrome-port-vdrVaWql.js +0 -2
- package/dist/chunks/chrome-port-vdrVaWql.js.map +0 -1
|
@@ -22,9 +22,9 @@ class P {
|
|
|
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,12 +32,12 @@ class P {
|
|
|
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, g, { status:
|
|
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
43
|
function x() {
|
|
@@ -115,7 +115,7 @@ const H = {
|
|
|
115
115
|
function R(i) {
|
|
116
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`,
|
|
@@ -159,18 +159,18 @@ function D() {
|
|
|
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
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);
|
|
@@ -178,26 +178,26 @@ function q(i) {
|
|
|
178
178
|
for (let s = 0; s < i; s++) t[s] = Math.floor(Math.random() * 256);
|
|
179
179
|
return t;
|
|
180
180
|
}
|
|
181
|
-
function
|
|
181
|
+
function b(i) {
|
|
182
182
|
let t = "";
|
|
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
186
|
function j() {
|
|
187
|
-
return
|
|
187
|
+
return b(M(64));
|
|
188
188
|
}
|
|
189
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
|
-
return
|
|
194
|
+
return b(new Uint8Array(s));
|
|
195
195
|
}
|
|
196
196
|
function X() {
|
|
197
|
-
return
|
|
197
|
+
return b(M(16));
|
|
198
198
|
}
|
|
199
199
|
const z = 6e4, Q = 600 * 1e3;
|
|
200
|
-
class
|
|
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");
|
|
@@ -297,7 +297,7 @@ class wt {
|
|
|
297
297
|
})
|
|
298
298
|
}
|
|
299
299
|
), n = this.toSession(a, a.user);
|
|
300
|
-
return this.setSession(n, { event: "SIGNED_IN" }), n;
|
|
300
|
+
return this.setSession(n, { event: "SIGNED_IN" }), this.recordLastLogin("email", t.email), n;
|
|
301
301
|
}
|
|
302
302
|
/**
|
|
303
303
|
* Signup. Если в Supabase включён email confirm — сервер возвращает
|
|
@@ -323,9 +323,9 @@ class wt {
|
|
|
323
323
|
}
|
|
324
324
|
);
|
|
325
325
|
if (a.status === "confirmation_required")
|
|
326
|
-
return { kind: "confirmation_required", user: a.user };
|
|
326
|
+
return this.recordLastLogin("email", t.email), { kind: "confirmation_required", user: a.user };
|
|
327
327
|
const n = this.toSession(a, a.user);
|
|
328
|
-
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 };
|
|
329
329
|
}
|
|
330
330
|
/**
|
|
331
331
|
* Повторная отправка confirmation-email после signUp с включённым
|
|
@@ -641,8 +641,9 @@ class wt {
|
|
|
641
641
|
return this.oauthFlows.set(a, {
|
|
642
642
|
verifier: e,
|
|
643
643
|
userMeta: t.userMeta,
|
|
644
|
+
provider: t.provider,
|
|
644
645
|
startedAt: Date.now()
|
|
645
|
-
}), { authorize_url: l, state: a };
|
|
646
|
+
}), this.recordLastLoginMethod(t.provider), { authorize_url: l, state: a };
|
|
646
647
|
}
|
|
647
648
|
/**
|
|
648
649
|
* Шаг 2 OAuth split-API: обменивает code (полученный из popup) на session,
|
|
@@ -677,7 +678,7 @@ class wt {
|
|
|
677
678
|
if (this.destroyed)
|
|
678
679
|
throw new o("aborted", "AuthClient destroyed mid-flow");
|
|
679
680
|
const n = this.toSession(a, a.user);
|
|
680
|
-
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;
|
|
681
682
|
}
|
|
682
683
|
gcOAuthFlows() {
|
|
683
684
|
const t = Date.now() - Q;
|
|
@@ -818,7 +819,7 @@ class wt {
|
|
|
818
819
|
setSession(t, e) {
|
|
819
820
|
if (this.destroyed) return;
|
|
820
821
|
const s = this.session;
|
|
821
|
-
this.session = t, e.skipPersist || this.persist(),
|
|
822
|
+
this.session = t, e.skipPersist || this.persist(), et(s, t) || this.emit(e.event);
|
|
822
823
|
}
|
|
823
824
|
emit(t) {
|
|
824
825
|
for (const e of this.listeners)
|
|
@@ -829,7 +830,7 @@ class wt {
|
|
|
829
830
|
}
|
|
830
831
|
}
|
|
831
832
|
storageKey() {
|
|
832
|
-
return
|
|
833
|
+
return u.authSession(this.paywallId);
|
|
833
834
|
}
|
|
834
835
|
async hydrate() {
|
|
835
836
|
try {
|
|
@@ -883,7 +884,7 @@ class wt {
|
|
|
883
884
|
}
|
|
884
885
|
async readAnonRefreshToken() {
|
|
885
886
|
try {
|
|
886
|
-
const t = await this.storage.getItem(
|
|
887
|
+
const t = await this.storage.getItem(u.anonRefreshToken(this.paywallId));
|
|
887
888
|
return typeof t == "string" && t.length > 0 ? t : null;
|
|
888
889
|
} catch {
|
|
889
890
|
return null;
|
|
@@ -892,7 +893,7 @@ class wt {
|
|
|
892
893
|
async writeAnonRefreshToken(t) {
|
|
893
894
|
try {
|
|
894
895
|
await this.storage.setItem(
|
|
895
|
-
|
|
896
|
+
u.anonRefreshToken(this.paywallId),
|
|
896
897
|
t
|
|
897
898
|
);
|
|
898
899
|
} catch {
|
|
@@ -901,11 +902,41 @@ class wt {
|
|
|
901
902
|
async clearAnonRefreshToken() {
|
|
902
903
|
try {
|
|
903
904
|
await this.storage.removeItem(
|
|
904
|
-
|
|
905
|
+
u.anonRefreshToken(this.paywallId)
|
|
905
906
|
);
|
|
906
907
|
} catch {
|
|
907
908
|
}
|
|
908
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
|
+
}
|
|
909
940
|
/**
|
|
910
941
|
* Читает stable visitor_id из storage если он там уже есть. НЕ генерит:
|
|
911
942
|
* AuthClient может быть инстанцирован раньше BillingClient, а синтетический
|
|
@@ -915,7 +946,7 @@ class wt {
|
|
|
915
946
|
*/
|
|
916
947
|
async readVisitorId() {
|
|
917
948
|
try {
|
|
918
|
-
const t = await this.storage.getItem(
|
|
949
|
+
const t = await this.storage.getItem(u.visitorId);
|
|
919
950
|
return typeof t == "string" && t.length >= 16 ? t : void 0;
|
|
920
951
|
} catch {
|
|
921
952
|
return;
|
|
@@ -927,10 +958,10 @@ function Z(i, t) {
|
|
|
927
958
|
return new Promise((e, s) => {
|
|
928
959
|
let a = !1;
|
|
929
960
|
const n = () => {
|
|
930
|
-
a = !0, window.removeEventListener("message", r), clearInterval(l), clearTimeout(
|
|
931
|
-
}, r = (
|
|
961
|
+
a = !0, window.removeEventListener("message", r), clearInterval(l), clearTimeout(d);
|
|
962
|
+
}, r = (f) => {
|
|
932
963
|
if (a) return;
|
|
933
|
-
const c =
|
|
964
|
+
const c = f.data;
|
|
934
965
|
if (!(!c || c.type !== "pw-oauth") && c.messageId === t) {
|
|
935
966
|
if (c.status === "success" && c.code) {
|
|
936
967
|
n();
|
|
@@ -955,14 +986,14 @@ function Z(i, t) {
|
|
|
955
986
|
}
|
|
956
987
|
}, l = setInterval(() => {
|
|
957
988
|
if (a) return;
|
|
958
|
-
let
|
|
989
|
+
let f;
|
|
959
990
|
try {
|
|
960
|
-
|
|
991
|
+
f = i.closed;
|
|
961
992
|
} catch {
|
|
962
993
|
return;
|
|
963
994
|
}
|
|
964
|
-
|
|
965
|
-
}, Y),
|
|
995
|
+
f && (n(), s(new o("oauth_cancelled", "auth popup was closed")));
|
|
996
|
+
}, Y), d = setTimeout(() => {
|
|
966
997
|
if (!a) {
|
|
967
998
|
n();
|
|
968
999
|
try {
|
|
@@ -975,10 +1006,13 @@ function Z(i, t) {
|
|
|
975
1006
|
window.addEventListener("message", r);
|
|
976
1007
|
});
|
|
977
1008
|
}
|
|
978
|
-
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) {
|
|
979
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;
|
|
980
1014
|
}
|
|
981
|
-
class
|
|
1015
|
+
class st {
|
|
982
1016
|
constructor(t) {
|
|
983
1017
|
if (!t.paywallId)
|
|
984
1018
|
throw new o("invalid_config", "paywallId is required");
|
|
@@ -1001,13 +1035,13 @@ class et {
|
|
|
1001
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(","));
|
|
1002
1036
|
const n = await this.auth?.getAccessToken();
|
|
1003
1037
|
n ? a.set("Authorization", `Bearer ${n}`) : this.userId && a.set("X-User-ID", this.userId);
|
|
1004
|
-
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";
|
|
1005
1039
|
let c;
|
|
1006
|
-
t.body === void 0 || t.body === null ? c = void 0 : r || l ||
|
|
1007
|
-
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;
|
|
1008
1042
|
let h;
|
|
1009
1043
|
try {
|
|
1010
|
-
h = await
|
|
1044
|
+
h = await y(s.toString(), {
|
|
1011
1045
|
method: t.method ?? "POST",
|
|
1012
1046
|
headers: a,
|
|
1013
1047
|
body: c,
|
|
@@ -1019,11 +1053,11 @@ class et {
|
|
|
1019
1053
|
throw new o("network_error", `Network request failed: ${$}`, { cause: p });
|
|
1020
1054
|
}
|
|
1021
1055
|
if (h.status === 402) {
|
|
1022
|
-
const p = await
|
|
1056
|
+
const p = await it(h);
|
|
1023
1057
|
throw this.onQuotaExceeded?.(p), p;
|
|
1024
1058
|
}
|
|
1025
1059
|
if (!h.ok) {
|
|
1026
|
-
const p = await
|
|
1060
|
+
const p = await at(h.clone());
|
|
1027
1061
|
throw new o(
|
|
1028
1062
|
p ?? `http_${h.status}`,
|
|
1029
1063
|
h.statusText || "Gateway request failed",
|
|
@@ -1034,7 +1068,7 @@ class et {
|
|
|
1034
1068
|
return this.onChargeSuccess?.(g), h;
|
|
1035
1069
|
}
|
|
1036
1070
|
}
|
|
1037
|
-
async function
|
|
1071
|
+
async function it(i) {
|
|
1038
1072
|
let t = {};
|
|
1039
1073
|
try {
|
|
1040
1074
|
t = await i.json();
|
|
@@ -1052,7 +1086,7 @@ async function st(i) {
|
|
|
1052
1086
|
currentBalance: t.details?.currentBalance ?? null
|
|
1053
1087
|
});
|
|
1054
1088
|
}
|
|
1055
|
-
async function
|
|
1089
|
+
async function at(i) {
|
|
1056
1090
|
if (!(i.headers.get("content-type") ?? "").includes("application/json")) return null;
|
|
1057
1091
|
try {
|
|
1058
1092
|
const e = await i.json();
|
|
@@ -1061,26 +1095,27 @@ async function it(i) {
|
|
|
1061
1095
|
return null;
|
|
1062
1096
|
}
|
|
1063
1097
|
}
|
|
1064
|
-
const
|
|
1098
|
+
const nt = 5e3, rt = 30 * 6e4, B = 60 * 6e4, ot = 5 * 6e4, k = {
|
|
1065
1099
|
has_active_subscription: !1,
|
|
1066
1100
|
purchases: [],
|
|
1067
|
-
trial: null
|
|
1101
|
+
trial: null,
|
|
1102
|
+
had_previous_trial: !1
|
|
1068
1103
|
};
|
|
1069
1104
|
function A(i) {
|
|
1070
1105
|
return i && (i.email || i.userId || i.anonymousId) || "guest";
|
|
1071
1106
|
}
|
|
1072
|
-
function
|
|
1107
|
+
function ct(i, t) {
|
|
1073
1108
|
return i === t ? !0 : !i || !t ? !1 : JSON.stringify(i) === JSON.stringify(t);
|
|
1074
1109
|
}
|
|
1075
|
-
const
|
|
1076
|
-
function
|
|
1110
|
+
const ht = 5e3, T = 5 * 6e4, lt = 3e4;
|
|
1111
|
+
function ut(i, t) {
|
|
1077
1112
|
if (i === t) return !0;
|
|
1078
1113
|
if (!i || !t || i.length !== t.length) return !1;
|
|
1079
1114
|
for (let e = 0; e < i.length; e++)
|
|
1080
1115
|
if (i[e].type !== t[e].type || i[e].count !== t[e].count) return !1;
|
|
1081
1116
|
return !0;
|
|
1082
1117
|
}
|
|
1083
|
-
class
|
|
1118
|
+
class St {
|
|
1084
1119
|
constructor(t) {
|
|
1085
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)
|
|
1086
1121
|
throw new o("invalid_config", "paywallId is required");
|
|
@@ -1104,7 +1139,7 @@ class mt {
|
|
|
1104
1139
|
getAuthToken: t.auth ? () => t.auth.getAccessToken() : void 0
|
|
1105
1140
|
}), t.auth && (this.authUnsubscribe = t.auth.onAuthChange((s, a) => {
|
|
1106
1141
|
const n = a ? O(a.user) : void 0;
|
|
1107
|
-
|
|
1142
|
+
dt(this.identity, n) || this.setIdentity(n);
|
|
1108
1143
|
})), this.hydrateUserFromStorage(), this.hydrateBootstrapFromStorage(), this.subscribeBootstrapStorage(), this.hydrateBalancesFromStorage(), this.subscribeBalancesStorage(), this.visitorIdPromise = _(this.storage).then((s) => (this.visitorId = s, s));
|
|
1109
1144
|
}
|
|
1110
1145
|
/**
|
|
@@ -1150,7 +1185,7 @@ class mt {
|
|
|
1150
1185
|
);
|
|
1151
1186
|
}
|
|
1152
1187
|
const s = Date.now(), a = this.cachedBootstrap && this.cachedBootstrapAt > 0 && s - this.cachedBootstrapAt < B;
|
|
1153
|
-
return !e.force && a ? (s - this.cachedBootstrapAt >
|
|
1188
|
+
return !e.force && a ? (s - this.cachedBootstrapAt > ot && this.revalidateBootstrap(e.signal).catch(() => {
|
|
1154
1189
|
}), { ...this.cachedBootstrap, user: this.cachedUser ?? void 0 }) : this.inflightBootstrap ? this.inflightBootstrap : (this.inflightBootstrap = this.fetchBootstrap({
|
|
1155
1190
|
ifVersion: e.force ? void 0 : this.cachedBootstrap?.version,
|
|
1156
1191
|
signal: e.signal
|
|
@@ -1221,7 +1256,7 @@ class mt {
|
|
|
1221
1256
|
if ("unchanged" in a && a.unchanged)
|
|
1222
1257
|
return this.cachedBootstrap ? (this.cachedBootstrapAt = Date.now(), a.user && this.applyUser(a.user), this.cachedBootstrap) : this.fetchBootstrap({ signal: t.signal });
|
|
1223
1258
|
const n = a;
|
|
1224
|
-
return
|
|
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;
|
|
1225
1260
|
}
|
|
1226
1261
|
// Фоновый revalidate из stale-while-revalidate ветки. Дедуплицируется через
|
|
1227
1262
|
// `inflightBootstrap`, чтобы параллельные revalidate'ы не пересекались.
|
|
@@ -1251,7 +1286,7 @@ class mt {
|
|
|
1251
1286
|
async hydrateBootstrapFromStorage() {
|
|
1252
1287
|
if (!this.cachedBootstrap)
|
|
1253
1288
|
try {
|
|
1254
|
-
const t = await this.storage.getItem(
|
|
1289
|
+
const t = await this.storage.getItem(u.bootstrap(this.paywallId));
|
|
1255
1290
|
if (!t) return;
|
|
1256
1291
|
const e = JSON.parse(t);
|
|
1257
1292
|
if (!e?.bootstrap || Date.now() - e.at > B || this.cachedBootstrap) return;
|
|
@@ -1270,7 +1305,7 @@ class mt {
|
|
|
1270
1305
|
try {
|
|
1271
1306
|
const { user: e, ...s } = t;
|
|
1272
1307
|
await this.storage.setItem(
|
|
1273
|
-
|
|
1308
|
+
u.bootstrap(this.paywallId),
|
|
1274
1309
|
JSON.stringify({ at: Date.now(), bootstrap: s })
|
|
1275
1310
|
);
|
|
1276
1311
|
} catch {
|
|
@@ -1281,7 +1316,7 @@ class mt {
|
|
|
1281
1316
|
// no-op, всё работает как раньше через сеть.
|
|
1282
1317
|
subscribeBootstrapStorage() {
|
|
1283
1318
|
typeof this.storage.watch == "function" && (this.bootstrapStorageUnwatch = this.storage.watch(
|
|
1284
|
-
|
|
1319
|
+
u.bootstrap(this.paywallId),
|
|
1285
1320
|
(t) => {
|
|
1286
1321
|
if (t)
|
|
1287
1322
|
try {
|
|
@@ -1338,7 +1373,7 @@ class mt {
|
|
|
1338
1373
|
* есть `navigator.language`.
|
|
1339
1374
|
*/
|
|
1340
1375
|
getUserLanguage() {
|
|
1341
|
-
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;
|
|
1342
1377
|
return { tag: s ?? t ?? e, applied: s, browserLanguage: t, countryLanguage: e };
|
|
1343
1378
|
}
|
|
1344
1379
|
/**
|
|
@@ -1350,7 +1385,7 @@ class mt {
|
|
|
1350
1385
|
* - Без identity возвращает empty-state (сервер тоже так делает).
|
|
1351
1386
|
*/
|
|
1352
1387
|
async getUser({ force: t = !1, signal: e } = {}) {
|
|
1353
|
-
return !t && this.cachedUser && Date.now() - this.cachedUserAt <
|
|
1388
|
+
return !t && this.cachedUser && Date.now() - this.cachedUserAt < nt ? this.cachedUser : this.inflightUser ? this.inflightUser : (this.inflightUser = (async () => {
|
|
1354
1389
|
try {
|
|
1355
1390
|
if (!this.identity?.email)
|
|
1356
1391
|
return this.applyUser(k), k;
|
|
@@ -1406,7 +1441,7 @@ class mt {
|
|
|
1406
1441
|
return this.cachedUser;
|
|
1407
1442
|
}
|
|
1408
1443
|
applyUser(t) {
|
|
1409
|
-
const e = !
|
|
1444
|
+
const e = !ct(this.cachedUser, t);
|
|
1410
1445
|
if (this.cachedUser = t, this.cachedUserAt = Date.now(), e) {
|
|
1411
1446
|
this.persistUser(t);
|
|
1412
1447
|
for (const s of this.userListeners)
|
|
@@ -1418,7 +1453,7 @@ class mt {
|
|
|
1418
1453
|
}
|
|
1419
1454
|
}
|
|
1420
1455
|
storageKey() {
|
|
1421
|
-
return
|
|
1456
|
+
return u.userState(this.paywallId, A(this.identity));
|
|
1422
1457
|
}
|
|
1423
1458
|
async hydrateUserFromStorage() {
|
|
1424
1459
|
if (!this.cachedUser)
|
|
@@ -1426,7 +1461,7 @@ class mt {
|
|
|
1426
1461
|
const t = await this.storage.getItem(this.storageKey());
|
|
1427
1462
|
if (!t) return;
|
|
1428
1463
|
const e = JSON.parse(t);
|
|
1429
|
-
if (!e?.user || Date.now() - e.at >
|
|
1464
|
+
if (!e?.user || Date.now() - e.at > rt || this.cachedUser) return;
|
|
1430
1465
|
this.applyUser(e.user);
|
|
1431
1466
|
} catch {
|
|
1432
1467
|
}
|
|
@@ -1455,7 +1490,7 @@ class mt {
|
|
|
1455
1490
|
*/
|
|
1456
1491
|
async getBalances({ force: t = !1, signal: e } = {}) {
|
|
1457
1492
|
const s = Date.now(), a = this.cachedBalances ? s - this.cachedBalancesAt : 1 / 0;
|
|
1458
|
-
return !t && this.cachedBalances && (a <
|
|
1493
|
+
return !t && this.cachedBalances && (a < ht || a < lt) ? this.cachedBalances : !t && this.cachedBalances && a < T ? (this.fetchBalances({ signal: e }).catch(() => {
|
|
1459
1494
|
}), this.cachedBalances) : this.inflightBalances ? this.inflightBalances : this.fetchBalances({ signal: e });
|
|
1460
1495
|
}
|
|
1461
1496
|
// Network primitive — единая точка для force/stale-revalidate/cold-start.
|
|
@@ -1546,7 +1581,7 @@ class mt {
|
|
|
1546
1581
|
*/
|
|
1547
1582
|
createApiGatewayClient(t = {}) {
|
|
1548
1583
|
const e = t.onChargeSuccess, s = t.onQuotaExceeded;
|
|
1549
|
-
return new
|
|
1584
|
+
return new st({
|
|
1550
1585
|
paywallId: this.paywallId,
|
|
1551
1586
|
apiOrigin: this.apiOrigin,
|
|
1552
1587
|
auth: this.auth,
|
|
@@ -1563,7 +1598,7 @@ class mt {
|
|
|
1563
1598
|
});
|
|
1564
1599
|
}
|
|
1565
1600
|
applyBalances(t, { persist: e = !0 } = {}) {
|
|
1566
|
-
const s = !
|
|
1601
|
+
const s = !ut(this.cachedBalances, t);
|
|
1567
1602
|
if (this.cachedBalances = t, this.cachedBalancesAt = Date.now(), e && this.persistBalances(t), s)
|
|
1568
1603
|
for (const a of this.balanceListeners)
|
|
1569
1604
|
try {
|
|
@@ -1573,7 +1608,7 @@ class mt {
|
|
|
1573
1608
|
}
|
|
1574
1609
|
}
|
|
1575
1610
|
balancesStorageKey() {
|
|
1576
|
-
return
|
|
1611
|
+
return u.balances(this.paywallId, A(this.identity));
|
|
1577
1612
|
}
|
|
1578
1613
|
async hydrateBalancesFromStorage() {
|
|
1579
1614
|
if (!this.cachedBalances)
|
|
@@ -1630,7 +1665,7 @@ class mt {
|
|
|
1630
1665
|
"Idempotency-Key": t.idempotencyKey ?? D()
|
|
1631
1666
|
};
|
|
1632
1667
|
this.apiKey && (n["X-Api-Key"] = this.apiKey);
|
|
1633
|
-
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`, {
|
|
1634
1669
|
method: "POST",
|
|
1635
1670
|
headers: n,
|
|
1636
1671
|
signal: t.signal,
|
|
@@ -1639,7 +1674,7 @@ class mt {
|
|
|
1639
1674
|
priceId: Number(t.priceId),
|
|
1640
1675
|
successUrl: l,
|
|
1641
1676
|
errorUrl: t.errorUrl,
|
|
1642
|
-
shopUrl:
|
|
1677
|
+
shopUrl: d,
|
|
1643
1678
|
productName: r?.checkout_product_name ?? void 0,
|
|
1644
1679
|
trial_days: t.trialDays,
|
|
1645
1680
|
ignoreActivePurchase: t.ignoreActivePurchase ? !0 : void 0,
|
|
@@ -1652,10 +1687,10 @@ class mt {
|
|
|
1652
1687
|
{ status: 409, cause: c.cause }
|
|
1653
1688
|
) : c;
|
|
1654
1689
|
});
|
|
1655
|
-
return this.inflightCheckouts.set(e,
|
|
1656
|
-
this.inflightCheckouts.get(e) ===
|
|
1690
|
+
return this.inflightCheckouts.set(e, f), f.finally(() => {
|
|
1691
|
+
this.inflightCheckouts.get(e) === f && this.inflightCheckouts.delete(e);
|
|
1657
1692
|
}).catch(() => {
|
|
1658
|
-
}),
|
|
1693
|
+
}), f;
|
|
1659
1694
|
}
|
|
1660
1695
|
/**
|
|
1661
1696
|
* URL Stripe/Paddle/Chargebee customer portal — место, где залогиненный
|
|
@@ -1774,7 +1809,7 @@ class mt {
|
|
|
1774
1809
|
function O(i) {
|
|
1775
1810
|
return { email: i.email, userId: i.id };
|
|
1776
1811
|
}
|
|
1777
|
-
function
|
|
1812
|
+
function dt(i, t) {
|
|
1778
1813
|
return i === t ? !0 : !i || !t ? !1 : i.email === t.email && i.userId === t.userId && i.anonymousId === t.anonymousId;
|
|
1779
1814
|
}
|
|
1780
1815
|
function U(i) {
|
|
@@ -1787,7 +1822,7 @@ function U(i) {
|
|
|
1787
1822
|
return null;
|
|
1788
1823
|
}
|
|
1789
1824
|
}
|
|
1790
|
-
function
|
|
1825
|
+
function ft(i, t) {
|
|
1791
1826
|
const e = U(i);
|
|
1792
1827
|
if (!(!e || U(t) === e))
|
|
1793
1828
|
throw new o(
|
|
@@ -1799,15 +1834,18 @@ function E(i, t) {
|
|
|
1799
1834
|
return {
|
|
1800
1835
|
type: "modal",
|
|
1801
1836
|
blocks: [
|
|
1837
|
+
// offer_banner НЕ в default layout — PaywallRoot рендерит его как
|
|
1838
|
+
// top-tab над dialog'ом (rounded-top, negative margin), за пределами
|
|
1839
|
+
// scrollable area. Блок остаётся в registry для opt-in inline-вариантa.
|
|
1802
1840
|
{ type: "heading", text: i.name || "Upgrade", level: 1 },
|
|
1803
1841
|
{ type: "price_grid", priceIds: t.map((e) => e.id) },
|
|
1804
|
-
{ type: "cta_button",
|
|
1842
|
+
{ type: "cta_button", action: "checkout" },
|
|
1805
1843
|
{ type: "guarantee_badge" },
|
|
1806
1844
|
{ type: "current_session" }
|
|
1807
1845
|
]
|
|
1808
1846
|
};
|
|
1809
1847
|
}
|
|
1810
|
-
function
|
|
1848
|
+
function q(i) {
|
|
1811
1849
|
const t = i.locales;
|
|
1812
1850
|
if (!t) return null;
|
|
1813
1851
|
const e = [];
|
|
@@ -1823,7 +1861,7 @@ function K(i) {
|
|
|
1823
1861
|
return null;
|
|
1824
1862
|
}
|
|
1825
1863
|
function w(i) {
|
|
1826
|
-
const t =
|
|
1864
|
+
const t = q(i);
|
|
1827
1865
|
if (!t) return;
|
|
1828
1866
|
const e = i.locales?.[t];
|
|
1829
1867
|
e && (e.layout && (i.layout = e.layout), e.prices && (i.prices = i.prices.map((s) => {
|
|
@@ -1833,8 +1871,8 @@ function w(i) {
|
|
|
1833
1871
|
return "label" in a && (n.label = a.label ?? null), "description" in a && (n.description = a.description ?? null), n;
|
|
1834
1872
|
})));
|
|
1835
1873
|
}
|
|
1836
|
-
const
|
|
1837
|
-
class
|
|
1874
|
+
const yt = 1500, pt = 20, L = 200;
|
|
1875
|
+
class It {
|
|
1838
1876
|
constructor(t) {
|
|
1839
1877
|
this.buffer = [], this.flushTimer = null, this.destroyed = !1, this.unloadHandler = null, this.visibilityHandler = null, this.opts = t, this.isEnabled() && this.attachUnloadHandlers();
|
|
1840
1878
|
}
|
|
@@ -1844,16 +1882,16 @@ class St {
|
|
|
1844
1882
|
track(t, e) {
|
|
1845
1883
|
if (this.destroyed || !this.isEnabled() || typeof t != "string" || t.length === 0) return;
|
|
1846
1884
|
this.buffer.push({ type: t, ts: Date.now(), props: e });
|
|
1847
|
-
const s = this.opts.maxBufferSize ??
|
|
1885
|
+
const s = this.opts.maxBufferSize ?? pt;
|
|
1848
1886
|
if (this.buffer.length >= s) {
|
|
1849
1887
|
this.flush();
|
|
1850
1888
|
return;
|
|
1851
1889
|
}
|
|
1852
|
-
this.buffer.length >
|
|
1890
|
+
this.buffer.length > L && (this.buffer = this.buffer.slice(-L)), this.scheduleFlush();
|
|
1853
1891
|
}
|
|
1854
1892
|
scheduleFlush() {
|
|
1855
1893
|
if (this.flushTimer || this.destroyed) return;
|
|
1856
|
-
const t = this.opts.flushIntervalMs ??
|
|
1894
|
+
const t = this.opts.flushIntervalMs ?? yt;
|
|
1857
1895
|
this.flushTimer = setTimeout(() => {
|
|
1858
1896
|
this.flushTimer = null, this.flush();
|
|
1859
1897
|
}, t);
|
|
@@ -1932,14 +1970,14 @@ class St {
|
|
|
1932
1970
|
this.destroyed || (this.destroyed = !0, this.flushTimer && (clearTimeout(this.flushTimer), this.flushTimer = null), this.flush(), this.detachUnloadHandlers());
|
|
1933
1971
|
}
|
|
1934
1972
|
}
|
|
1935
|
-
const
|
|
1936
|
-
function
|
|
1973
|
+
const C = 3600 * 1e3;
|
|
1974
|
+
function I(i) {
|
|
1937
1975
|
return `paywall-${i}-trial-time-first-open`;
|
|
1938
1976
|
}
|
|
1939
|
-
function
|
|
1977
|
+
function v(i) {
|
|
1940
1978
|
return `paywall-${i}-skip-times`;
|
|
1941
1979
|
}
|
|
1942
|
-
class
|
|
1980
|
+
class K {
|
|
1943
1981
|
constructor(t, e, s) {
|
|
1944
1982
|
this.storage = t, this.paywallId = e, this.config = s;
|
|
1945
1983
|
}
|
|
@@ -1950,10 +1988,10 @@ class M {
|
|
|
1950
1988
|
return this.config.mode === "time" ? this.recordTime() : this.recordOpens();
|
|
1951
1989
|
}
|
|
1952
1990
|
async reset() {
|
|
1953
|
-
await this.storage.removeItem(this.config.mode === "time" ?
|
|
1991
|
+
await this.storage.removeItem(this.config.mode === "time" ? I(this.paywallId) : v(this.paywallId));
|
|
1954
1992
|
}
|
|
1955
1993
|
async checkTime() {
|
|
1956
|
-
const t = this.config.payload *
|
|
1994
|
+
const t = this.config.payload * C, e = await this.storage.getItem(I(this.paywallId)), s = e ? Number(e) : null;
|
|
1957
1995
|
if (!s || !Number.isFinite(s))
|
|
1958
1996
|
return {
|
|
1959
1997
|
mode: "time",
|
|
@@ -1974,7 +2012,7 @@ class M {
|
|
|
1974
2012
|
};
|
|
1975
2013
|
}
|
|
1976
2014
|
async checkOpens() {
|
|
1977
|
-
const t = this.config.payload, e = await this.storage.getItem(
|
|
2015
|
+
const t = this.config.payload, e = await this.storage.getItem(v(this.paywallId)), s = e ? Number(e) : 0, a = Number.isFinite(s) ? s : 0, n = a < t, r = Math.max(0, t - a);
|
|
1978
2016
|
return {
|
|
1979
2017
|
mode: "opens",
|
|
1980
2018
|
blocked: n,
|
|
@@ -1983,7 +2021,7 @@ class M {
|
|
|
1983
2021
|
};
|
|
1984
2022
|
}
|
|
1985
2023
|
async recordTime() {
|
|
1986
|
-
const t = this.config.payload *
|
|
2024
|
+
const t = this.config.payload * C, e = I(this.paywallId), s = await this.storage.getItem(e);
|
|
1987
2025
|
let a = s ? Number(s) : null;
|
|
1988
2026
|
(!a || !Number.isFinite(a)) && (a = Date.now(), await this.storage.setItem(e, String(a)));
|
|
1989
2027
|
const n = a + t, r = Math.max(0, n - Date.now());
|
|
@@ -1997,7 +2035,7 @@ class M {
|
|
|
1997
2035
|
};
|
|
1998
2036
|
}
|
|
1999
2037
|
async recordOpens() {
|
|
2000
|
-
const t = this.config.payload, e =
|
|
2038
|
+
const t = this.config.payload, e = v(this.paywallId), s = await this.storage.getItem(e), a = s ? Number(s) : 0, n = Number.isFinite(a) ? a : 0, r = Math.min(t, n + 1);
|
|
2001
2039
|
await this.storage.setItem(e, String(r));
|
|
2002
2040
|
const l = Math.max(0, t - r);
|
|
2003
2041
|
return {
|
|
@@ -2008,12 +2046,12 @@ class M {
|
|
|
2008
2046
|
};
|
|
2009
2047
|
}
|
|
2010
2048
|
}
|
|
2011
|
-
let
|
|
2012
|
-
class
|
|
2049
|
+
let N = !1;
|
|
2050
|
+
class gt {
|
|
2013
2051
|
constructor(t, e, s) {
|
|
2014
|
-
|
|
2052
|
+
N || (N = !0, console.warn(
|
|
2015
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.'
|
|
2016
|
-
)), this.fallback = new
|
|
2054
|
+
)), this.fallback = new K(t, e, s);
|
|
2017
2055
|
}
|
|
2018
2056
|
check() {
|
|
2019
2057
|
return this.fallback.check();
|
|
@@ -2026,10 +2064,10 @@ class pt {
|
|
|
2026
2064
|
}
|
|
2027
2065
|
}
|
|
2028
2066
|
function vt(i, t, e) {
|
|
2029
|
-
return e.storage === "server" ? new
|
|
2067
|
+
return e.storage === "server" ? new gt(i, t, e) : new K(i, t, e);
|
|
2030
2068
|
}
|
|
2031
2069
|
const bt = 1;
|
|
2032
|
-
function
|
|
2070
|
+
function _t(i) {
|
|
2033
2071
|
return i instanceof o ? {
|
|
2034
2072
|
name: "PaywallError",
|
|
2035
2073
|
code: i.code,
|
|
@@ -2047,7 +2085,7 @@ function It(i) {
|
|
|
2047
2085
|
message: typeof i == "string" ? i : "Unknown error"
|
|
2048
2086
|
};
|
|
2049
2087
|
}
|
|
2050
|
-
function
|
|
2088
|
+
function Bt(i) {
|
|
2051
2089
|
if (i.name === "PaywallError") {
|
|
2052
2090
|
const e = new o(i.code, i.message, { status: i.status });
|
|
2053
2091
|
return i.stack && (e.stack = i.stack), e;
|
|
@@ -2055,7 +2093,7 @@ function _t(i) {
|
|
|
2055
2093
|
const t = new Error(i.message);
|
|
2056
2094
|
return t.name = i.name, i.stack && (t.stack = i.stack), t;
|
|
2057
2095
|
}
|
|
2058
|
-
function
|
|
2096
|
+
function wt(i) {
|
|
2059
2097
|
let t = !1;
|
|
2060
2098
|
const e = /* @__PURE__ */ new Set(), s = /* @__PURE__ */ new Set(), a = (r) => {
|
|
2061
2099
|
for (const l of e) l(r);
|
|
@@ -2087,21 +2125,21 @@ function gt(i) {
|
|
|
2087
2125
|
}
|
|
2088
2126
|
};
|
|
2089
2127
|
}
|
|
2090
|
-
function
|
|
2128
|
+
function kt(i) {
|
|
2091
2129
|
const t = chrome.runtime.connect({ name: i });
|
|
2092
|
-
return
|
|
2130
|
+
return wt(t);
|
|
2093
2131
|
}
|
|
2094
2132
|
export {
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2133
|
+
mt as A,
|
|
2134
|
+
St as B,
|
|
2135
|
+
It as E,
|
|
2098
2136
|
o as P,
|
|
2099
2137
|
bt as a,
|
|
2100
|
-
|
|
2138
|
+
kt as b,
|
|
2101
2139
|
vt as c,
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2140
|
+
wt as p,
|
|
2141
|
+
Bt as r,
|
|
2142
|
+
_t as s,
|
|
2105
2143
|
Z as w
|
|
2106
2144
|
};
|
|
2107
|
-
//# sourceMappingURL=chrome-port-
|
|
2145
|
+
//# sourceMappingURL=chrome-port-CxW3Pwc2.js.map
|