@fkn/lib 0.9.56 → 0.9.58
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/{account-generation-D3jlXBbM.js → account-generation-2ZvMy2tZ.js} +1 -1
- package/{account-generation-DkrSMafa.cjs → account-generation-DIsOqkSQ.cjs} +1 -1
- package/{account-storage-C1VL6fpb.cjs → account-storage-CPTct4Vz.cjs} +1 -1
- package/{account-storage-BBL440_m.js → account-storage-Cmzz-67T.js} +2 -2
- package/account.cjs +1 -1
- package/account.d.ts +1 -1
- package/account.js +2 -2
- package/{api-BSpQkgnM.d.ts → api-BD_XUANc.d.ts} +28 -1
- package/{api-DEfkbHGB.js → api-C-N5AVos.js} +77 -74
- package/api-ibGqkmtA.cjs +3 -0
- package/api.cjs +1 -1
- package/api.d.ts +2 -2
- package/api.js +1 -1
- package/cloud/dns.d.ts +1 -1
- package/cloud/fetch.cjs +1 -1
- package/cloud/fetch.d.ts +1 -1
- package/cloud/fetch.js +1 -1
- package/cloud/fs.cjs +1 -1
- package/cloud/fs.js +1 -1
- package/cloud/net.d.ts +1 -1
- package/{cloud-DTpFBbBH.js → cloud-B6B2XcRU.js} +205 -184
- package/{cloud-BslRIoKs.d.ts → cloud-BEoUa04G.d.ts} +3 -3
- package/cloud-C0hcBrFd.cjs +1 -0
- package/cloud.cjs +1 -1
- package/cloud.d.ts +3 -3
- package/cloud.js +2 -2
- package/{contract-DFycgFJK.d.ts → contract-B8Rqx5BD.d.ts} +47 -4
- package/contract.cjs +1 -1
- package/contract.d.ts +3 -3
- package/contract.js +2 -2
- package/dgram.cjs +1 -1
- package/dgram.d.ts +10 -5
- package/dgram.js +64 -60
- package/dns.cjs +1 -1
- package/dns.d.ts +1 -1
- package/dns.js +1 -1
- package/extension-AidgSVhb.js +101 -0
- package/{extension-kE9yzbkW.d.ts → extension-C_eOfEjv.d.ts} +3 -2
- package/extension-M8bUhlML.cjs +1 -0
- package/extension.cjs +1 -1
- package/extension.d.ts +3 -3
- package/extension.js +1 -1
- package/fs/promises.cjs +1 -1
- package/fs/promises.js +1 -1
- package/{fs-C7ByWYF9.cjs → fs-BlRxCJQW.cjs} +1 -1
- package/{fs-gryDP9qw.js → fs-C_RmxWk9.js} +2 -2
- package/fs.cjs +1 -1
- package/fs.js +2 -2
- package/http.cjs +1 -1
- package/http.d.ts +4 -1
- package/http.js +2 -1
- package/{index-BQ5OZQhf.d.ts → index-C5DdoMGo.d.ts} +38 -1
- package/index.cjs +1 -1
- package/index.d.ts +7 -5
- package/index.js +53 -51
- package/{net-eEjhJ0AE.d.ts → net-CvJwokcz.d.ts} +14 -7
- package/net.cjs +1 -1
- package/net.d.ts +1 -1
- package/net.js +52 -46
- package/package.json +1 -1
- package/packages.cjs +1 -1
- package/packages.d.ts +1 -1
- package/packages.js +1 -1
- package/proxy-C1RlnrDC.js +61 -0
- package/proxy-CII2NFYV.cjs +1 -0
- package/{proxy-8hIHeEHD.d.ts → proxy-z0Y8IgW7.d.ts} +2 -2
- package/relay-choice-BGwXRC5d.js +14 -0
- package/relay-choice-BmXlqfD2.d.ts +28 -0
- package/relay-choice-JC_JJY_M.cjs +1 -0
- package/rooms.cjs +1 -1
- package/rooms.d.ts +1 -1
- package/rooms.js +1 -1
- package/storage.cjs +1 -1
- package/storage.d.ts +1 -1
- package/storage.js +3 -3
- package/api-BmaUJUUp.cjs +0 -3
- package/cloud-C_EPPfe_.cjs +0 -1
- package/extension-C13d41tq.js +0 -95
- package/extension-DA_Fx3Lx.cjs +0 -1
- package/proxy-Blzm-Dc1.cjs +0 -1
- package/proxy-C2HY5Ybc.js +0 -60
|
@@ -1,17 +1,18 @@
|
|
|
1
1
|
import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
|
|
2
2
|
import { D as t, E as n, N as r, O as i, T as a, _ as o, c as s, f as c, ft as l, g as u, h as d, j as f, k as p, l as m, m as h, o as g, p as _, s as v, u as y, x as b, y as x } from "./lib-BGAmzIcU.js";
|
|
3
3
|
import { c as S, m as C, t as w } from "./hosts-t7CKGTRz.js";
|
|
4
|
-
import { l as T, m as E, n as D, o as O, s as k } from "./api-
|
|
4
|
+
import { l as T, m as E, n as D, o as O, s as k } from "./api-C-N5AVos.js";
|
|
5
5
|
import { r as A } from "./busy-DsMWrSzc.js";
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
6
|
+
import { ATTACH_FRAME_KEY as j, ATTACH_WINDOW_KEY as ee, ATTACH_WINDOW_MESSAGE as M, RELAY_CHOICE_UNSUPPORTED as N, WINDOW_HANDSHAKE_TIMEOUT_MS as te } from "./contract.js";
|
|
7
|
+
import { a as P, i as F, t as I } from "./relay-choice-BGwXRC5d.js";
|
|
8
|
+
import { t as L } from "./proxy-C1RlnrDC.js";
|
|
9
|
+
import { frameFetchVerdict as R } from "./attach-policy.js";
|
|
9
10
|
import { t as ne } from "./dns.js";
|
|
10
11
|
import { t as re } from "./cloud/fs.js";
|
|
11
12
|
import { t as ie } from "./net.js";
|
|
12
13
|
import { t as ae } from "./dgram.js";
|
|
13
14
|
import { t as oe } from "./http.js";
|
|
14
|
-
import { expose as
|
|
15
|
+
import { expose as z } from "osra";
|
|
15
16
|
//#region src/cloud/frame-broker.ts
|
|
16
17
|
var se = async () => {
|
|
17
18
|
let e = () => k("frame consent");
|
|
@@ -28,15 +29,15 @@ var se = async () => {
|
|
|
28
29
|
ensure: (t) => e().then((e) => e.frameConsent.ensure(t))
|
|
29
30
|
};
|
|
30
31
|
}
|
|
31
|
-
},
|
|
32
|
-
|
|
32
|
+
}, B = "frame: this frame no longer holds the document the app attached it to", V = !1, ce = () => {
|
|
33
|
+
V || (V = !0, console.warn("[fkn-frame] this FKN broker is too old to ask for permission categories, so nothing was asked for upfront and each capability is asked for as it is first used. Reloading the page picks up the current broker."));
|
|
33
34
|
}, le = (e) => [...e].flatMap((e) => {
|
|
34
35
|
try {
|
|
35
36
|
return [new URL(e).hostname];
|
|
36
37
|
} catch {
|
|
37
38
|
return [];
|
|
38
39
|
}
|
|
39
|
-
}),
|
|
40
|
+
}), H = (e) => typeof e?.reason == "string" ? { reason: e.reason } : {}, U = (e, t, n) => n === null ? `frame.${e}: the user did not grant ${t} here` : `frame.${e}: the user did not grant ${t} on ${n}`, ue = (e) => {
|
|
40
41
|
let { assertLive: t, attach: n, consent: r, current: i, declaredHosts: o, documentHost: s, freshBlank: l, session: u, approvedOrigins: f } = e, m = /* @__PURE__ */ new Set(), g = () => {
|
|
41
42
|
try {
|
|
42
43
|
return new URL(i()).hostname;
|
|
@@ -52,7 +53,7 @@ var se = async () => {
|
|
|
52
53
|
let _ = d(c);
|
|
53
54
|
if (_ === void 0 || _ === "auto") return;
|
|
54
55
|
if (e === "fetch") {
|
|
55
|
-
let e =
|
|
56
|
+
let e = R({
|
|
56
57
|
session: u,
|
|
57
58
|
declaredHosts: o,
|
|
58
59
|
approvedOrigins: f
|
|
@@ -73,18 +74,18 @@ var se = async () => {
|
|
|
73
74
|
if (await b(t, {
|
|
74
75
|
category: "network",
|
|
75
76
|
hosts: l,
|
|
76
|
-
...
|
|
77
|
-
}) === !1) throw p(
|
|
77
|
+
...H(a(i))
|
|
78
|
+
}) === !1) throw p(U("fetch", "network", c || null), "fetch");
|
|
78
79
|
return;
|
|
79
80
|
}
|
|
80
81
|
let x = await v();
|
|
81
82
|
if (!x) throw p(`frame: navigate the frame before ${e}`, e);
|
|
82
|
-
if (!y().includes(x)) throw p(
|
|
83
|
+
if (!y().includes(x)) throw p(B, e);
|
|
83
84
|
let T = h(c);
|
|
84
85
|
if (T === void 0 || T === "evaluation" && x === g() && await l?.() || _ === "critical" && m.has(`${c} ${x}`)) return;
|
|
85
86
|
let { request: E } = await r();
|
|
86
87
|
if (!E) return;
|
|
87
|
-
let D = w([x, ...o]), O =
|
|
88
|
+
let D = w([x, ...o]), O = H(a(i)), k = _ === "critical" ? {
|
|
88
89
|
key: c,
|
|
89
90
|
hosts: D,
|
|
90
91
|
attach: n,
|
|
@@ -94,7 +95,7 @@ var se = async () => {
|
|
|
94
95
|
hosts: D,
|
|
95
96
|
...O
|
|
96
97
|
}, A = await b(E, k);
|
|
97
|
-
if (A === !1) throw p(
|
|
98
|
+
if (A === !1) throw p(U(e, T, null), e);
|
|
98
99
|
if (A === "once" && s !== "ensure") for (let e of D) m.add(`${c} ${e}`);
|
|
99
100
|
},
|
|
100
101
|
requestCategories: async (e) => {
|
|
@@ -120,7 +121,7 @@ var se = async () => {
|
|
|
120
121
|
}), { request: u } = await r();
|
|
121
122
|
if (!u) return ce(), s.map((e) => l(e, !1));
|
|
122
123
|
let f = await u(s.map(({ named: t, critical: r, category: i }, o) => {
|
|
123
|
-
let s =
|
|
124
|
+
let s = H(e[o]);
|
|
124
125
|
return r ? {
|
|
125
126
|
key: t,
|
|
126
127
|
hosts: a,
|
|
@@ -136,21 +137,21 @@ var se = async () => {
|
|
|
136
137
|
},
|
|
137
138
|
boundary: y
|
|
138
139
|
};
|
|
139
|
-
},
|
|
140
|
+
}, W = (e) => e, de = 5e3, fe = /* @__PURE__ */ new Set([]), G = () => "https://fkn.app", K = (e) => e === "persistent" ? "" : `incognito-${crypto.randomUUID()}`, q = (e, t, r) => {
|
|
140
141
|
let i, a = new Promise((e, a) => {
|
|
141
142
|
i = setTimeout(() => a(typeof r == "string" ? new n(r) : r()), t);
|
|
142
143
|
});
|
|
143
144
|
return Promise.race([e, a]).finally(() => clearTimeout(i));
|
|
144
|
-
},
|
|
145
|
-
if (typeof e.seed != "function") throw r(
|
|
145
|
+
}, J = (e) => Object.assign(Error(e), { name: t }), pe = "frame.postMessage: this FKN page predates frame messaging; reload the app to load the current one", me = "frame.addScriptTag: this render proxy predates addScriptTag; reload the app", he = `frame.addScriptTag: no answer within ${m}ms; the script may or may not have run`, ge = "frame.clearCookies: this FKN page predates clearCookies; reload the app to load the current one", _e = "frame.clearCookies: this attachment reaches no site yet; attach a url, goto one, or declare it in domains", Y = 3e4, X = "attachFrame: this FKN page predates storageState; reload the app to load the current one", ve = 2e4, ye = async (e, t) => {
|
|
146
|
+
if (typeof e.seed != "function") throw r(X, "storageState", "cloud");
|
|
146
147
|
try {
|
|
147
|
-
await
|
|
148
|
+
await q(e.seed(t), ve, "attachFrame: the render proxy did not take the storageState seed");
|
|
148
149
|
} catch (e) {
|
|
149
|
-
throw i(e) ? r(
|
|
150
|
+
throw i(e) ? r(X, "storageState", "cloud") : e;
|
|
150
151
|
}
|
|
151
|
-
},
|
|
152
|
-
|
|
153
|
-
},
|
|
152
|
+
}, be = `frame.clearCookies: the render proxy did not answer within ${Y}ms; the cookies may or may not be gone, and calling it again is safe`, xe = (e) => i(e) && e.message === f("addScriptTag").message, Se = !1, Ce = () => {
|
|
153
|
+
Se || (Se = !0, console.warn("[fkn-frame] this FKN page predates frame messaging, so the page's messages and documents are never reported. Reloading the app loads the current one."));
|
|
154
|
+
}, we = ({ from: e, origin: t, attach: n, signal: r }) => (i) => {
|
|
154
155
|
let a = (r) => {
|
|
155
156
|
if (r.source === null || r.source !== e() || r.origin !== t) return;
|
|
156
157
|
let a = r.data;
|
|
@@ -165,13 +166,13 @@ var se = async () => {
|
|
|
165
166
|
}));
|
|
166
167
|
};
|
|
167
168
|
return window.addEventListener("message", a, { signal: r }), () => window.removeEventListener("message", a);
|
|
168
|
-
},
|
|
169
|
+
}, Te = (e) => {
|
|
169
170
|
if (typeof e != "function") return () => Promise.resolve(e);
|
|
170
171
|
let t = null;
|
|
171
172
|
return () => t ??= e().catch((e) => {
|
|
172
173
|
throw t = null, e;
|
|
173
174
|
});
|
|
174
|
-
},
|
|
175
|
+
}, Ee = ({ control: e, target: t, blank: n = !1, session: i, declaredHosts: a, approvedOrigins: o, attach: c, assertLive: l, guard: u, consent: d, onNavigated: h, relay: g }) => {
|
|
175
176
|
let _ = t, v = n && i !== "", b = async () => {
|
|
176
177
|
if (!v) return !1;
|
|
177
178
|
let n = typeof e.blank == "function" ? await u(() => e.blank()) : "";
|
|
@@ -184,7 +185,7 @@ var se = async () => {
|
|
|
184
185
|
assertLive: l,
|
|
185
186
|
documentHost: typeof e.documentHost == "function" ? () => u(() => e.documentHost()) : void 0,
|
|
186
187
|
current: () => _,
|
|
187
|
-
consent:
|
|
188
|
+
consent: Te(d),
|
|
188
189
|
freshBlank: b
|
|
189
190
|
});
|
|
190
191
|
return x({
|
|
@@ -200,7 +201,7 @@ var se = async () => {
|
|
|
200
201
|
operation: "evaluate",
|
|
201
202
|
args: [t],
|
|
202
203
|
phase: "execute"
|
|
203
|
-
}),
|
|
204
|
+
}), q(u(() => e.executeLocator([], "evaluate", [t, n])), m, y)),
|
|
204
205
|
addScriptTag: async (t, n) => {
|
|
205
206
|
l();
|
|
206
207
|
let i = [t, n];
|
|
@@ -211,19 +212,19 @@ var se = async () => {
|
|
|
211
212
|
phase: "execute"
|
|
212
213
|
});
|
|
213
214
|
try {
|
|
214
|
-
await
|
|
215
|
+
await q(u(() => e.executeLocator([], "addScriptTag", i)), m, he);
|
|
215
216
|
} catch (e) {
|
|
216
|
-
throw
|
|
217
|
+
throw xe(e) ? r(me, "addScriptTag", "cloud") : e;
|
|
217
218
|
}
|
|
218
219
|
},
|
|
219
220
|
clearCookies: async (t) => {
|
|
220
221
|
if (l(), typeof e.clearCookies != "function") throw r(ge, "clearCookies", "cloud");
|
|
221
222
|
if (T().length === 0) throw p(_e, "clearCookies");
|
|
222
|
-
await
|
|
223
|
+
await q(u(() => e.clearCookies(t)), Y, be);
|
|
223
224
|
},
|
|
224
225
|
postMessage: (t, n, i) => {
|
|
225
226
|
if (l(), typeof e.messaging != "function") throw r(pe, "postMessage", "cloud");
|
|
226
|
-
if (n !== "*" && !T().includes(new URL(n).hostname)) throw p(
|
|
227
|
+
if (n !== "*" && !T().includes(new URL(n).hostname)) throw p(B, "postMessage");
|
|
227
228
|
let { port1: a, port2: o } = new MessageChannel();
|
|
228
229
|
a.postMessage({
|
|
229
230
|
data: t,
|
|
@@ -239,7 +240,7 @@ var se = async () => {
|
|
|
239
240
|
await e;
|
|
240
241
|
});
|
|
241
242
|
},
|
|
242
|
-
listen: (t) => (typeof e.messaging != "function" &&
|
|
243
|
+
listen: (t) => (typeof e.messaging != "function" && Ce(), g(t)),
|
|
243
244
|
goto: async (t, { timeout: n, ...r } = {}) => {
|
|
244
245
|
let i = new URL(t, location.href).href;
|
|
245
246
|
l(), v = !1;
|
|
@@ -252,7 +253,7 @@ var se = async () => {
|
|
|
252
253
|
})(), c = a !== "" && !o.has(a);
|
|
253
254
|
c && o.add(a);
|
|
254
255
|
try {
|
|
255
|
-
await
|
|
256
|
+
await q(u(() => e.goto(i, n === void 0 ? r : {
|
|
256
257
|
...r,
|
|
257
258
|
timeoutMs: n
|
|
258
259
|
})), (n ?? 3e4) + de, "cloud.attachFrame: the render proxy did not answer goto; the frame may have been detached or its page reloaded");
|
|
@@ -263,87 +264,106 @@ var se = async () => {
|
|
|
263
264
|
},
|
|
264
265
|
url: () => _
|
|
265
266
|
});
|
|
266
|
-
},
|
|
267
|
+
}, De = async (e) => {
|
|
268
|
+
if (e === void 0) {
|
|
269
|
+
let e = await k("a relay").catch(() => void 0);
|
|
270
|
+
if (typeof e?.relay?.resolve != "function") return;
|
|
271
|
+
let t = await e.relay.resolve().catch(() => void 0);
|
|
272
|
+
return t && "id" in t ? t.id : void 0;
|
|
273
|
+
}
|
|
274
|
+
let t = await k("a relay choice");
|
|
275
|
+
I(t, "attachFrame");
|
|
276
|
+
let n = await t.relay.resolve(e);
|
|
277
|
+
if ("refused" in n) throw F(`attachFrame: ${n.refused}`);
|
|
278
|
+
return n.id;
|
|
279
|
+
}, Oe = async (e, t) => {
|
|
280
|
+
if ((typeof e.relay == "function" ? await e.relay() : "") !== t) throw F(`attachFrame: ${N}`);
|
|
281
|
+
}, ke = 250, Ae = 500, je = 65e3, Me = 2e3, Ne = 2e3, Pe = 2, Fe = 2e3, Ie = 2e3, Le = ({ origin: e, target: t, session: n, domains: r, attach: i }) => {
|
|
267
282
|
let a = new URL("/attach-window", e);
|
|
268
283
|
return a.searchParams.set("attach", i), t && a.searchParams.set("url", t), n && a.searchParams.set("session", n), r.length && a.searchParams.set("domains", r.join(",")), a.href;
|
|
269
|
-
},
|
|
284
|
+
}, Re = (e, t) => {
|
|
270
285
|
let n = document.createElement("iframe"), r = new URL("/attach-jar", e);
|
|
271
286
|
return r.searchParams.set("attach", t), n.src = r.href, n.tabIndex = -1, n.setAttribute("aria-hidden", "true"), n.setAttribute("style", "display:none"), (document.body ?? document.documentElement).appendChild(n), n;
|
|
272
|
-
},
|
|
287
|
+
}, ze = (e, t) => {
|
|
273
288
|
let n = new MutationObserver(() => {
|
|
274
289
|
e.isConnected || t.aborted || (n.disconnect(), console.warn("cloud.attachFrame: the window's jar anchor was removed from this page, so a sign-in in the window no longer reaches this app's cookie jar"));
|
|
275
290
|
});
|
|
276
291
|
e.parentNode && n.observe(e.parentNode, { childList: !0 }), n.observe(document.documentElement, { childList: !0 }), t.addEventListener("abort", () => n.disconnect(), { once: !0 });
|
|
277
|
-
}, Z = () =>
|
|
292
|
+
}, Z = () => J("cloud.attachFrame: the attached window closed, reloaded or left the page FKN attached; attach a fresh window"), Be = () => J("cloud.attachFrame: the attached window stopped answering; attach a fresh window"), Ve = () => J("cloud.attachFrame: the window went away before it connected; attach a fresh window"), He = () => J("cloud.attachFrame: the window closed before it connected. Either the user closed it, or this page's Cross-Origin-Opener-Policy cut its link to the window"), Ue = async (e, t, n) => {
|
|
278
293
|
if (typeof window > "u") throw Error("cloud.attachFrame needs a window realm");
|
|
279
|
-
let { domains: r = [], permissions: i } = e, { url:
|
|
294
|
+
let { domains: r = [], permissions: i, relay: a } = e, { url: s, width: c, height: d } = v(e.window);
|
|
280
295
|
if (window.origin === "null") throw new o("opaque-opener");
|
|
281
|
-
let
|
|
282
|
-
|
|
283
|
-
let
|
|
284
|
-
origin:
|
|
285
|
-
target: n === void 0 ?
|
|
286
|
-
session:
|
|
287
|
-
domains:
|
|
288
|
-
attach:
|
|
289
|
-
}), "_blank", `popup,width=${
|
|
290
|
-
if (!
|
|
291
|
-
let
|
|
292
|
-
if (
|
|
293
|
-
|
|
296
|
+
let f = G(), p = crypto.randomUUID(), m = K(t), h = w(r), g = /* @__PURE__ */ new Set();
|
|
297
|
+
s && g.add(new URL(s).origin);
|
|
298
|
+
let _ = t === "persistent" ? Re(f, p) : null, y = window.open(Le({
|
|
299
|
+
origin: f,
|
|
300
|
+
target: n === void 0 ? s : "",
|
|
301
|
+
session: m,
|
|
302
|
+
domains: h,
|
|
303
|
+
attach: p
|
|
304
|
+
}), "_blank", `popup,width=${c},height=${d}`);
|
|
305
|
+
if (!y) throw _?.remove(), new u();
|
|
306
|
+
let b = new AbortController(), x = !1, S = null, C = (e, t = !1) => {
|
|
307
|
+
if (S === null) {
|
|
308
|
+
S = e, b.abort(t ? Be() : Z());
|
|
294
309
|
try {
|
|
295
|
-
|
|
296
|
-
type:
|
|
297
|
-
attach:
|
|
310
|
+
y.closed || y.postMessage({
|
|
311
|
+
type: M.detach,
|
|
312
|
+
attach: p,
|
|
298
313
|
...t ? { unanswered: t } : {}
|
|
299
|
-
},
|
|
314
|
+
}, f);
|
|
300
315
|
} catch {}
|
|
301
|
-
|
|
316
|
+
_ && setTimeout(() => _.remove(), Ie);
|
|
302
317
|
}
|
|
303
318
|
};
|
|
304
|
-
|
|
305
|
-
let
|
|
306
|
-
|
|
319
|
+
_ && ze(_, b.signal);
|
|
320
|
+
let T = new Promise((e, t) => {
|
|
321
|
+
b.signal.addEventListener("abort", () => t(b.signal.reason), { once: !0 });
|
|
307
322
|
});
|
|
308
|
-
|
|
309
|
-
let
|
|
310
|
-
if (
|
|
311
|
-
},
|
|
323
|
+
T.catch(() => {});
|
|
324
|
+
let E = T.then(() => {}, () => {}), D = () => {
|
|
325
|
+
if (b.signal.aborted) throw b.signal.reason;
|
|
326
|
+
}, O = (e) => b.signal.aborted ? Promise.reject(b.signal.reason) : Promise.race([e(), T]), k = (e) => e.source === y && e.origin === f;
|
|
312
327
|
window.addEventListener("message", (e) => {
|
|
313
|
-
if (!
|
|
328
|
+
if (!k(e)) return;
|
|
314
329
|
let t = e.data;
|
|
315
|
-
typeof t == "object" && t && t.attach ===
|
|
316
|
-
}, { signal:
|
|
317
|
-
let
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
330
|
+
typeof t == "object" && t && t.attach === p && (t.type === M.refused ? C(new o(t.reason)) : t.type === M.gone && C(x ? Z() : Ve()));
|
|
331
|
+
}, { signal: b.signal }), window.addEventListener("pagehide", () => C(Z()), { signal: b.signal });
|
|
332
|
+
let j = De(a), N, F, I = () => {
|
|
333
|
+
let e = () => {
|
|
334
|
+
try {
|
|
335
|
+
y.postMessage({
|
|
336
|
+
type: M.hello,
|
|
337
|
+
attach: p,
|
|
338
|
+
...N ? { relay: N } : {}
|
|
339
|
+
}, f);
|
|
340
|
+
} catch {}
|
|
341
|
+
};
|
|
342
|
+
e(), F = setInterval(e, ke);
|
|
324
343
|
};
|
|
325
|
-
|
|
326
|
-
let
|
|
327
|
-
|
|
328
|
-
},
|
|
329
|
-
|
|
330
|
-
clearInterval(
|
|
344
|
+
a === void 0 && I();
|
|
345
|
+
let L = setInterval(() => {
|
|
346
|
+
y.closed && C(x ? Z() : He());
|
|
347
|
+
}, Ae);
|
|
348
|
+
b.signal.addEventListener("abort", () => {
|
|
349
|
+
clearInterval(F), clearInterval(L);
|
|
331
350
|
}, { once: !0 });
|
|
332
|
-
let
|
|
351
|
+
let R = async (e) => {
|
|
333
352
|
try {
|
|
334
|
-
return await Promise.race([e,
|
|
353
|
+
return await Promise.race([e, T]);
|
|
335
354
|
} catch (e) {
|
|
336
|
-
throw
|
|
355
|
+
throw S ?? e;
|
|
337
356
|
}
|
|
338
357
|
};
|
|
339
358
|
try {
|
|
340
|
-
|
|
359
|
+
a !== void 0 && (N = await R(j), I());
|
|
360
|
+
let e = await R(q(z({}, {
|
|
341
361
|
key: ee,
|
|
342
362
|
transport: {
|
|
343
|
-
emit: (e, t) =>
|
|
363
|
+
emit: (e, t) => y.postMessage(e, f, t ?? []),
|
|
344
364
|
receive: (e) => {
|
|
345
365
|
let t = (t) => {
|
|
346
|
-
|
|
366
|
+
k(t) && e(t.data, {
|
|
347
367
|
source: t.source,
|
|
348
368
|
origin: t.origin
|
|
349
369
|
});
|
|
@@ -351,57 +371,57 @@ var se = async () => {
|
|
|
351
371
|
return window.addEventListener("message", t), () => window.removeEventListener("message", t);
|
|
352
372
|
}
|
|
353
373
|
},
|
|
354
|
-
unregisterSignal:
|
|
355
|
-
revivableModules:
|
|
374
|
+
unregisterSignal: b.signal,
|
|
375
|
+
revivableModules: W(l)
|
|
356
376
|
}), te, "cloud.attachFrame: timed out connecting to the window"));
|
|
357
|
-
|
|
377
|
+
x = !0, clearInterval(F);
|
|
358
378
|
let t = 0, r = setInterval(() => {
|
|
359
|
-
|
|
379
|
+
q(O(() => e.ping()), Ne, "ping").then(() => {
|
|
360
380
|
t = 0;
|
|
361
381
|
}, () => {
|
|
362
|
-
|
|
382
|
+
b.signal.aborted || (document.visibilityState === "hidden" ? t = 0 : ++t >= Pe && C(Be(), !0));
|
|
363
383
|
});
|
|
364
|
-
},
|
|
365
|
-
|
|
366
|
-
let o =
|
|
384
|
+
}, Me);
|
|
385
|
+
b.signal.addEventListener("abort", () => clearInterval(r), { once: !0 }), N && await R(q(Oe(e, N), je, "cloud.attachFrame: the window never became ready")), await R(q(e.ready(), je, "cloud.attachFrame: the window never became ready")), n !== void 0 && await R(ye(e, n)), A("attached frame", b.signal);
|
|
386
|
+
let o = Ee({
|
|
367
387
|
control: e,
|
|
368
|
-
target:
|
|
369
|
-
session:
|
|
370
|
-
declaredHosts:
|
|
371
|
-
approvedOrigins:
|
|
372
|
-
attach:
|
|
373
|
-
assertLive:
|
|
374
|
-
guard:
|
|
388
|
+
target: s,
|
|
389
|
+
session: m,
|
|
390
|
+
declaredHosts: h,
|
|
391
|
+
approvedOrigins: g,
|
|
392
|
+
attach: p,
|
|
393
|
+
assertLive: D,
|
|
394
|
+
guard: O,
|
|
375
395
|
consent: {
|
|
376
|
-
request: (t) =>
|
|
377
|
-
ensure: (t) =>
|
|
396
|
+
request: (t) => O(() => e.requestConsent(t)),
|
|
397
|
+
ensure: (t) => O(() => e.requestConsent([t])).then(([e]) => e !== void 0 && e !== !1)
|
|
378
398
|
},
|
|
379
399
|
onNavigated: () => {},
|
|
380
|
-
relay:
|
|
381
|
-
from: () =>
|
|
382
|
-
origin:
|
|
383
|
-
attach:
|
|
384
|
-
signal:
|
|
400
|
+
relay: we({
|
|
401
|
+
from: () => y,
|
|
402
|
+
origin: f,
|
|
403
|
+
attach: p,
|
|
404
|
+
signal: b.signal
|
|
385
405
|
})
|
|
386
|
-
}),
|
|
387
|
-
close: () =>
|
|
388
|
-
|
|
406
|
+
}), c = null, u = Object.assign(o, {
|
|
407
|
+
close: () => c ??= (async () => {
|
|
408
|
+
b.signal.aborted || await q(Promise.allSettled([O(() => e.flushCookies()), O(() => e.sweepStorage())]), Fe, "close").catch(() => {});
|
|
389
409
|
try {
|
|
390
|
-
|
|
410
|
+
y.close();
|
|
391
411
|
} catch {}
|
|
392
|
-
|
|
412
|
+
C(Z());
|
|
393
413
|
})(),
|
|
394
|
-
closed:
|
|
414
|
+
closed: E
|
|
395
415
|
});
|
|
396
|
-
return n !== void 0 &&
|
|
416
|
+
return N ? P(u, N) : j.then((e) => P(u, e)), n !== void 0 && s && await R(u.goto(s)), i?.length && await R(u.requestPermissions(i)), u;
|
|
397
417
|
} catch (e) {
|
|
398
|
-
let t =
|
|
418
|
+
let t = S ?? e;
|
|
399
419
|
if (!(t instanceof o)) try {
|
|
400
|
-
|
|
420
|
+
y.close();
|
|
401
421
|
} catch {}
|
|
402
|
-
throw
|
|
422
|
+
throw C(t), t;
|
|
403
423
|
}
|
|
404
|
-
},
|
|
424
|
+
}, We = 2e4, Q = 65e3, $ = (e) => !e || e === "about:blank", Ge = "cloud.attachFrame: this FKN page predates blank pages; reload the app to load the current one", Ke = "cloud.attachFrame: cookies: 'native' needs the FKN browser extension; the cloud render proxy has no browser cookies", qe = (e) => e.split("#")[0] ?? "", Je = ({ iframe: e, lockdown: t, cookies: n, blank: r }) => {
|
|
405
425
|
if (r === void 0) return "";
|
|
406
426
|
if (typeof r != "object" || !r) throw TypeError("attachFrame: blank must be an object { url }");
|
|
407
427
|
let i = Object.keys(r).find((e) => e !== "url");
|
|
@@ -415,15 +435,15 @@ var se = async () => {
|
|
|
415
435
|
})();
|
|
416
436
|
if (!o || o.protocol !== "http:" && o.protocol !== "https:") throw TypeError(`attachFrame: blank.url must be an absolute http or https url, not "${String(a)}"`);
|
|
417
437
|
let s = e.getAttribute("src") ?? "";
|
|
418
|
-
if (
|
|
438
|
+
if (!$(s)) throw TypeError(`attachFrame: blank needs an iframe with no src; this one has "${s}"`);
|
|
419
439
|
if (t) throw TypeError("attachFrame: blank does not combine with lockdown");
|
|
420
440
|
if (n === "native") throw TypeError("attachFrame: blank runs on the cloud render proxy, which has no browser cookies; pass cookies: 'persistent' or 'ephemeral'");
|
|
421
|
-
if (b(o.href), !
|
|
441
|
+
if (b(o.href), !at()) throw Error("attachFrame: a blank page is served by the cloud render proxy, which this build does not configure");
|
|
422
442
|
return o.href;
|
|
423
|
-
},
|
|
424
|
-
let
|
|
425
|
-
return t ?
|
|
426
|
-
},
|
|
443
|
+
}, Ye = ({ target: e, blank: t, session: n, domains: r, attach: i, relay: a }) => {
|
|
444
|
+
let o = new URL("/attach-frame", G());
|
|
445
|
+
return t ? o.searchParams.set("blank", t) : e && o.searchParams.set("url", e), n && o.searchParams.set("session", n), r.length && o.searchParams.set("domains", r.join(",")), o.searchParams.set("attach", i), a && o.searchParams.set("relay", a), o.href;
|
|
446
|
+
}, Xe = (e, t) => {
|
|
427
447
|
let n = () => {
|
|
428
448
|
a(), t();
|
|
429
449
|
}, r = e.parentNode, i = new MutationObserver(() => {
|
|
@@ -432,14 +452,14 @@ var se = async () => {
|
|
|
432
452
|
window.removeEventListener("pagehide", n), i.disconnect();
|
|
433
453
|
};
|
|
434
454
|
window.addEventListener("pagehide", n, { once: !0 }), r && i.observe(r, { childList: !0 }), e.isConnected || (a(), t());
|
|
435
|
-
},
|
|
455
|
+
}, Ze = () => J("cloud.attachFrame: the attached iframe left the document or was reloaded; attach a fresh iframe"), Qe = (e, t) => {
|
|
436
456
|
let n = [...e.split(";"), ...t.split(";")].map((e) => e.trim()).filter(Boolean);
|
|
437
457
|
return [...new Set(n)].join("; ");
|
|
438
|
-
},
|
|
458
|
+
}, $e = [
|
|
439
459
|
300,
|
|
440
460
|
1200,
|
|
441
461
|
4e3
|
|
442
|
-
],
|
|
462
|
+
], et = (e) => {
|
|
443
463
|
let t = () => {
|
|
444
464
|
if (!e.isConnected) return;
|
|
445
465
|
let t = e.style.height, n = e.getBoundingClientRect();
|
|
@@ -448,88 +468,89 @@ var se = async () => {
|
|
|
448
468
|
}, 50));
|
|
449
469
|
};
|
|
450
470
|
t();
|
|
451
|
-
for (let e of
|
|
452
|
-
},
|
|
471
|
+
for (let e of $e) setTimeout(t, e);
|
|
472
|
+
}, tt = (e) => {
|
|
453
473
|
let t = e.getAttribute("sandbox");
|
|
454
474
|
if (t === null) return;
|
|
455
475
|
let n = new Set(t.toLowerCase().split(/\s+/).filter(Boolean)), r = ["allow-scripts", "allow-same-origin"].filter((e) => !n.has(e));
|
|
456
476
|
if (r.length) throw Error(`cloud.attachFrame: the iframe's sandbox attribute must include ${r.join(" and ")} for the render proxy to load`);
|
|
457
|
-
},
|
|
458
|
-
let n = typeof e.blank == "function" ? await
|
|
459
|
-
if (typeof n != "string" ||
|
|
460
|
-
},
|
|
461
|
-
let r =
|
|
477
|
+
}, nt = async (e, t) => {
|
|
478
|
+
let n = typeof e.blank == "function" ? await q(e.blank(), Q, "cloud.attachFrame: the render proxy never became ready") : "";
|
|
479
|
+
if (typeof n != "string" || qe(n) !== qe(t)) throw r(Ge, "blank", "cloud");
|
|
480
|
+
}, rt = async (e, t, n) => {
|
|
481
|
+
let r = Je(e), { iframe: i, domains: a = [], permissions: o, relay: s } = e;
|
|
462
482
|
if (typeof window > "u") throw Error("cloud.attachFrame needs a window realm");
|
|
463
483
|
if (!i.isConnected) throw Error("cloud.attachFrame: the iframe must be connected to the document before attaching");
|
|
464
|
-
|
|
465
|
-
let
|
|
466
|
-
if (
|
|
484
|
+
tt(i);
|
|
485
|
+
let c = i.getAttribute("src") ?? "", u = (() => {
|
|
486
|
+
if ($(c)) return null;
|
|
467
487
|
try {
|
|
468
|
-
return new URL(i.src ||
|
|
488
|
+
return new URL(i.src || c, location.href);
|
|
469
489
|
} catch {
|
|
470
|
-
throw Error(`cloud.attachFrame: the iframe src is not a valid URL: ${
|
|
490
|
+
throw Error(`cloud.attachFrame: the iframe src is not a valid URL: ${c}`);
|
|
471
491
|
}
|
|
472
492
|
})();
|
|
473
|
-
if (
|
|
474
|
-
let e = new URL("/attach-frame",
|
|
475
|
-
if (
|
|
493
|
+
if (u) {
|
|
494
|
+
let e = new URL("/attach-frame", G());
|
|
495
|
+
if (u.origin === e.origin && u.pathname === e.pathname) throw Error("cloud.attachFrame: this iframe is already attached; navigate with the Frame returned by that attach or use a fresh iframe");
|
|
476
496
|
}
|
|
477
|
-
let
|
|
478
|
-
|
|
479
|
-
let
|
|
497
|
+
let d = u?.href ?? "";
|
|
498
|
+
d && b(d);
|
|
499
|
+
let f = n === void 0 ? d : "", p = K(t), m = w(a), h = /* @__PURE__ */ new Set();
|
|
480
500
|
try {
|
|
481
|
-
|
|
501
|
+
h.add(new URL(r || d).origin);
|
|
482
502
|
} catch {}
|
|
483
|
-
let
|
|
484
|
-
if (i.referrerPolicy = "origin", i.allow =
|
|
485
|
-
target:
|
|
503
|
+
let g = De(s), _ = s === void 0 ? void 0 : await g, v = new AbortController(), y = i.referrerPolicy, x = i.allow, S = crypto.randomUUID();
|
|
504
|
+
if (i.referrerPolicy = "origin", i.allow = Qe(E(), i.allow), i.src = Ye({
|
|
505
|
+
target: f,
|
|
486
506
|
blank: r,
|
|
487
|
-
session:
|
|
488
|
-
domains:
|
|
489
|
-
attach:
|
|
507
|
+
session: p,
|
|
508
|
+
domains: m,
|
|
509
|
+
attach: S,
|
|
510
|
+
relay: _
|
|
490
511
|
}), !i.contentWindow) throw Error("cloud.attachFrame: the iframe window is not available");
|
|
491
512
|
try {
|
|
492
|
-
let e = await
|
|
493
|
-
key:
|
|
494
|
-
origin:
|
|
513
|
+
let e = await q(z({}, {
|
|
514
|
+
key: j,
|
|
515
|
+
origin: G(),
|
|
495
516
|
transport: {
|
|
496
517
|
receive: window,
|
|
497
518
|
emit: i.contentWindow
|
|
498
519
|
},
|
|
499
|
-
unregisterSignal:
|
|
500
|
-
revivableModules:
|
|
501
|
-
}),
|
|
502
|
-
await
|
|
503
|
-
let t = i.contentWindow, a =
|
|
520
|
+
unregisterSignal: v.signal,
|
|
521
|
+
revivableModules: W(l)
|
|
522
|
+
}), We, "cloud.attachFrame: timed out connecting to the render proxy page");
|
|
523
|
+
_ && await q(Oe(e, _), Q, "cloud.attachFrame: the render proxy never became ready"), await q(e.ready(), Q, "cloud.attachFrame: the render proxy never became ready"), r && await nt(e, r), n !== void 0 && await ye(e, n), (d || r) && et(i), Xe(i, () => v.abort()), A("attached frame", v.signal);
|
|
524
|
+
let t = i.contentWindow, a = Ee({
|
|
504
525
|
control: e,
|
|
505
|
-
target: r ||
|
|
526
|
+
target: r || d,
|
|
506
527
|
blank: r !== "",
|
|
507
|
-
session:
|
|
508
|
-
declaredHosts:
|
|
509
|
-
approvedOrigins:
|
|
510
|
-
attach:
|
|
528
|
+
session: p,
|
|
529
|
+
declaredHosts: m,
|
|
530
|
+
approvedOrigins: h,
|
|
531
|
+
attach: S,
|
|
511
532
|
assertLive: () => {
|
|
512
|
-
if (
|
|
533
|
+
if (v.signal.aborted || !i.isConnected || i.contentWindow !== t) throw v.abort(), Ze();
|
|
513
534
|
},
|
|
514
535
|
guard: (e) => e(),
|
|
515
536
|
consent: se,
|
|
516
|
-
onNavigated: () =>
|
|
517
|
-
relay:
|
|
537
|
+
onNavigated: () => et(i),
|
|
538
|
+
relay: we({
|
|
518
539
|
from: () => t,
|
|
519
|
-
origin:
|
|
520
|
-
attach:
|
|
521
|
-
signal:
|
|
540
|
+
origin: G(),
|
|
541
|
+
attach: S,
|
|
542
|
+
signal: v.signal
|
|
522
543
|
})
|
|
523
544
|
});
|
|
524
|
-
return n !== void 0 &&
|
|
545
|
+
return _ ? P(a, _) : g.then((e) => P(a, e)), n !== void 0 && d && await a.goto(d), o?.length && await a.requestPermissions(o), a;
|
|
525
546
|
} catch (e) {
|
|
526
|
-
throw
|
|
547
|
+
throw v.abort(), i.referrerPolicy = y, i.allow = x, i.src = f || "about:blank", e;
|
|
527
548
|
}
|
|
528
|
-
},
|
|
549
|
+
}, it = (async (e) => {
|
|
529
550
|
let { kind: t, cookies: n, storageState: r } = g(e);
|
|
530
|
-
if (n === "native") throw TypeError(
|
|
531
|
-
return t === "window" ?
|
|
532
|
-
}),
|
|
551
|
+
if (n === "native") throw TypeError(Ke);
|
|
552
|
+
return t === "window" ? Ue(e, n, r) : rt(e, n, r);
|
|
553
|
+
}), at = () => typeof window < "u" && !0, ot = async () => {
|
|
533
554
|
let e = await O.then((e) => e.cloud.quota());
|
|
534
555
|
return {
|
|
535
556
|
premium: e.premium,
|
|
@@ -541,16 +562,16 @@ var se = async () => {
|
|
|
541
562
|
bytesPerSecond: e.bytesPerSecond,
|
|
542
563
|
bitsPerSecond: e.bytesPerSecond * 8
|
|
543
564
|
};
|
|
544
|
-
},
|
|
545
|
-
attachFrame: () =>
|
|
546
|
-
available: () =>
|
|
565
|
+
}, st = /* @__PURE__ */ e({
|
|
566
|
+
attachFrame: () => it,
|
|
567
|
+
available: () => ct,
|
|
547
568
|
dgram: () => ae,
|
|
548
569
|
dns: () => ne,
|
|
549
|
-
fetch: () =>
|
|
570
|
+
fetch: () => L,
|
|
550
571
|
fs: () => re,
|
|
551
572
|
http: () => oe,
|
|
552
573
|
net: () => ie,
|
|
553
|
-
quota: () =>
|
|
554
|
-
}),
|
|
574
|
+
quota: () => ot
|
|
575
|
+
}), ct = () => T;
|
|
555
576
|
//#endregion
|
|
556
|
-
export {
|
|
577
|
+
export { Je as a, it as i, st as n, ot as r, ct as t };
|