@fkn/lib 0.9.39 → 0.9.41
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-CSnZiN18.cjs +1 -0
- package/account-generation-D7TpIoKt.js +28 -0
- package/account.cjs +1 -1
- package/account.d.ts +11 -0
- package/account.js +5 -17
- package/{api-BxXnHxbd.d.ts → api-Cbty0JUM.d.ts} +15 -13
- package/api.d.ts +2 -2
- package/cloud/dns.d.ts +1 -1
- package/cloud/fetch.d.ts +1 -1
- package/cloud/fs/promises.d.ts +1 -1
- package/cloud/fs.cjs +1 -1
- package/cloud/fs.d.ts +4 -4
- package/cloud/fs.js +31 -24
- package/cloud/net.d.ts +1 -1
- package/{cloud-B8QYSmW3.d.ts → cloud-4t1WoEZn.d.ts} +3 -3
- package/{cloud-oMACx7NL.js → cloud-BLv19j-W.js} +200 -196
- package/cloud-D7aQY4GH.cjs +1 -0
- package/cloud.cjs +1 -1
- package/cloud.d.ts +4 -4
- package/cloud.js +1 -1
- package/{contract-sDmsw-9f.d.ts → contract-BRc2ptdC.d.ts} +33 -10
- package/contract.d.ts +2 -2
- package/dgram.d.ts +2 -2
- package/dns.d.ts +1 -1
- package/extension-B9v933cT.js +89 -0
- package/extension-D2zMdc2f.cjs +1 -0
- package/extension.cjs +1 -1
- package/extension.js +3 -3
- package/fs/promises.cjs +1 -1
- package/fs/promises.d.ts +1 -1
- package/fs/promises.js +1 -1
- package/fs-BTyRnUPI.cjs +1 -0
- package/{fs--NhtUyYa.d.ts → fs-D0MMRnHC.d.ts} +8 -4
- package/fs-q7Kg51hq.js +513 -0
- package/fs.cjs +1 -1
- package/fs.d.ts +4 -3
- package/fs.js +4 -2
- package/http.d.ts +1 -1
- package/{index-kuPqkS_-.d.ts → index-D2lvaQDs.d.ts} +28 -38
- package/index.cjs +1 -1
- package/index.d.ts +3 -3
- package/index.js +13 -13
- package/{lib-tQKlXzhv.cjs → lib-BfAg9mHD.cjs} +1 -1
- package/{lib-BlyFPeSv.js → lib-C4Eeg9eM.js} +2 -2
- package/{messages-C66ghz_A.d.ts → messages-CRcziTuC.d.ts} +17 -1
- package/messages.cjs +1 -1
- package/messages.d.ts +2 -2
- package/messages.js +2 -2
- package/{net-Qmt9L_7t.d.ts → net-CcEZP6Bb.d.ts} +2 -2
- package/net.d.ts +1 -1
- package/{node-fs-BZy9bzKd.js → node-fs-CK2wWIYS.js} +140 -137
- package/node-fs-nfX7wisL.cjs +1 -0
- package/opfs.cjs +1 -1
- package/opfs.js +1 -1
- package/package.json +1 -1
- package/packages.d.ts +1 -1
- package/{proxy-CxRQLGNG.d.ts → proxy-D6YtsO1g.d.ts} +2 -2
- package/rooms.d.ts +1 -1
- package/storage-BS5WMO4f.cjs +1 -0
- package/storage-BVr2Rb-d.d.ts +167 -0
- package/storage-BWmGrO6a.js +123 -0
- package/cloud-BZIJFvPF.cjs +0 -1
- package/extension-Bl5ZNj0d.cjs +0 -1
- package/extension-ChZyZgAL.js +0 -89
- package/fs-CaQFRiIT.cjs +0 -1
- package/fs-D3IsGdnN.js +0 -360
- package/node-fs-BNTPsX5c.cjs +0 -1
- package/storage-BJd-mWHE.cjs +0 -1
- package/storage-DSvL-t80.js +0 -67
- package/storage-ZrY4Y4L5.d.ts +0 -88
|
@@ -1,20 +1,20 @@
|
|
|
1
1
|
import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
|
|
2
|
-
import { C as t,
|
|
3
|
-
import { c as
|
|
4
|
-
import { a as
|
|
5
|
-
import { t as
|
|
6
|
-
import { t as
|
|
7
|
-
import { frameFetchVerdict as
|
|
8
|
-
import { ATTACH_FRAME_KEY as
|
|
9
|
-
import { t as
|
|
10
|
-
import { t as
|
|
11
|
-
import { t as
|
|
12
|
-
import { t as
|
|
13
|
-
import { t as
|
|
2
|
+
import { C as t, D as n, E as r, _ as i, c as a, d as o, f as s, h as c, l, o as u, p as d, rt as f, s as p, u as m, w as h, x as g } from "./lib-C4Eeg9eM.js";
|
|
3
|
+
import { c as _, m as v, t as y } from "./hosts-BzbzOhG8.js";
|
|
4
|
+
import { a as b, c as x, f as S, n as C, o as w } from "./api-Dp-2AT3u.js";
|
|
5
|
+
import { t as T } from "./busy-B189uX--.js";
|
|
6
|
+
import { t as E } from "./proxy-DMTdQ4dN.js";
|
|
7
|
+
import { frameFetchVerdict as D } from "./attach-policy.js";
|
|
8
|
+
import { ATTACH_FRAME_KEY as O, ATTACH_WINDOW_KEY as ee, ATTACH_WINDOW_MESSAGE as k, WINDOW_HANDSHAKE_TIMEOUT_MS as te } from "./contract.js";
|
|
9
|
+
import { t as A } from "./dns.js";
|
|
10
|
+
import { t as j } from "./cloud/fs.js";
|
|
11
|
+
import { t as M } from "./net.js";
|
|
12
|
+
import { t as N } from "./dgram.js";
|
|
13
|
+
import { t as ne } from "./http.js";
|
|
14
14
|
import { expose as P } from "osra";
|
|
15
15
|
//#region src/cloud/frame-broker.ts
|
|
16
|
-
var
|
|
17
|
-
let e = () =>
|
|
16
|
+
var re = async () => {
|
|
17
|
+
let e = () => w("frame consent");
|
|
18
18
|
try {
|
|
19
19
|
let t = await e();
|
|
20
20
|
return {
|
|
@@ -22,112 +22,116 @@ var ne = async () => {
|
|
|
22
22
|
ensure: t.frameConsent.ensure
|
|
23
23
|
};
|
|
24
24
|
} catch (t) {
|
|
25
|
-
if (!(t instanceof
|
|
25
|
+
if (!(t instanceof C)) throw t;
|
|
26
26
|
return {
|
|
27
27
|
request: void 0,
|
|
28
28
|
ensure: (t) => e().then((e) => e.frameConsent.ensure(t))
|
|
29
29
|
};
|
|
30
30
|
}
|
|
31
|
-
}, F = 3e4,
|
|
31
|
+
}, F = 3e4, ie = () => t(`frame.evaluate: the code did not settle within ${F}ms`, "evaluate"), I = "frame: this frame no longer holds the document the app attached it to", L = !1, ae = () => {
|
|
32
32
|
L || (L = !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
|
-
},
|
|
33
|
+
}, oe = (e) => [...e].flatMap((e) => {
|
|
34
34
|
try {
|
|
35
35
|
return [new URL(e).hostname];
|
|
36
36
|
} catch {
|
|
37
37
|
return [];
|
|
38
38
|
}
|
|
39
|
-
}), R = (e, t, n) => n === null ? `frame.${e}: the user did not grant ${t} here` : `frame.${e}: the user did not grant ${t} on ${n}`,
|
|
40
|
-
let { assertLive:
|
|
39
|
+
}), R = (e, t, n) => n === null ? `frame.${e}: the user did not grant ${t} here` : `frame.${e}: the user did not grant ${t} on ${n}`, se = (e) => {
|
|
40
|
+
let { assertLive: t, attach: n, current: r, declaredHosts: i, documentHost: s, ensure: c, request: u, session: d, approvedOrigins: f } = e, p = /* @__PURE__ */ new Set(), g = async () => s ? await s() : (() => {
|
|
41
41
|
try {
|
|
42
|
-
return new URL(
|
|
42
|
+
return new URL(r()).hostname;
|
|
43
43
|
} catch {
|
|
44
44
|
return "";
|
|
45
45
|
}
|
|
46
|
-
})(),
|
|
46
|
+
})(), b = () => y([...i, ...oe(f)]), x = async (e) => (await u([e]))[0] ?? !1;
|
|
47
47
|
return {
|
|
48
|
-
gate: async ({ operation: e, args:
|
|
49
|
-
|
|
50
|
-
let s =
|
|
48
|
+
gate: async ({ operation: e, args: r, phase: a }) => {
|
|
49
|
+
t();
|
|
50
|
+
let s = v(e, r);
|
|
51
51
|
if (s === null) return;
|
|
52
|
-
let
|
|
53
|
-
if (
|
|
52
|
+
let l = o(s);
|
|
53
|
+
if (l === void 0 || l === "auto") return;
|
|
54
54
|
if (e === "fetch") {
|
|
55
|
-
let e =
|
|
55
|
+
let e = D({
|
|
56
56
|
session: d,
|
|
57
|
-
declaredHosts:
|
|
57
|
+
declaredHosts: i,
|
|
58
58
|
approvedOrigins: f
|
|
59
|
-
},
|
|
60
|
-
if (
|
|
61
|
-
if (
|
|
62
|
-
if (!
|
|
63
|
-
if (e.kind === "refuse") throw
|
|
59
|
+
}, a === "ensure" ? void 0 : r[0], { classifier: "fetchTarget" });
|
|
60
|
+
if (a === "ensure" && !d) throw h(e.kind === "refuse" ? e.reason : "", "fetch");
|
|
61
|
+
if (a !== "ensure" && e.kind === "refuse") throw h(e.reason, "fetch");
|
|
62
|
+
if (!u) {
|
|
63
|
+
if (e.kind === "refuse") throw h(e.reason, "fetch");
|
|
64
64
|
if (!await c({
|
|
65
|
-
scope:
|
|
65
|
+
scope: _(r[0], r[1]).scope,
|
|
66
66
|
hosts: e.promptHosts
|
|
67
|
-
})) throw
|
|
67
|
+
})) throw h("frame.fetch: the user did not grant this", "fetch");
|
|
68
68
|
return;
|
|
69
69
|
}
|
|
70
|
-
let
|
|
71
|
-
if (!
|
|
72
|
-
if (await
|
|
70
|
+
let t = e.kind === "consent" ? e.targetHost : await g(), n = y([t, ...i]);
|
|
71
|
+
if (!n.length) throw h("frame: navigate the frame before fetch", "fetch");
|
|
72
|
+
if (await x({
|
|
73
73
|
category: "network",
|
|
74
|
-
hosts:
|
|
75
|
-
}) === !1) throw
|
|
74
|
+
hosts: n
|
|
75
|
+
}) === !1) throw h(R("fetch", "network", t || null), "fetch");
|
|
76
76
|
return;
|
|
77
77
|
}
|
|
78
|
-
let S = await
|
|
79
|
-
if (!S) throw
|
|
80
|
-
if (!
|
|
81
|
-
if (!
|
|
82
|
-
let C =
|
|
83
|
-
if (C === void 0 ||
|
|
84
|
-
let w =
|
|
78
|
+
let S = await g();
|
|
79
|
+
if (!S) throw h(`frame: navigate the frame before ${e}`, e);
|
|
80
|
+
if (!b().includes(S)) throw h(I, e);
|
|
81
|
+
if (!u) return;
|
|
82
|
+
let C = m(s);
|
|
83
|
+
if (C === void 0 || l === "critical" && p.has(`${s} ${S}`)) return;
|
|
84
|
+
let w = y([S, ...i]), T = await x(l === "critical" ? {
|
|
85
85
|
key: s,
|
|
86
86
|
hosts: w,
|
|
87
|
-
attach:
|
|
87
|
+
attach: n
|
|
88
88
|
} : {
|
|
89
89
|
category: C,
|
|
90
90
|
hosts: w
|
|
91
91
|
});
|
|
92
|
-
if (T === !1) throw
|
|
93
|
-
if (T === "once" &&
|
|
92
|
+
if (T === !1) throw h(R(e, C, null), e);
|
|
93
|
+
if (T === "once" && a !== "ensure") for (let e of w) p.add(`${s} ${e}`);
|
|
94
94
|
},
|
|
95
95
|
requestCategories: async (e) => {
|
|
96
|
-
|
|
97
|
-
let
|
|
98
|
-
if (!
|
|
99
|
-
let
|
|
96
|
+
t(), a("frame.request", e);
|
|
97
|
+
let r = await g(), s = y(r ? [r, ...i] : i);
|
|
98
|
+
if (!s.length) throw TypeError("frame.request: navigate the frame or declare domains first");
|
|
99
|
+
let c = e.map((e) => {
|
|
100
100
|
let t = e.key;
|
|
101
|
-
return {
|
|
101
|
+
return t === void 0 ? {
|
|
102
|
+
named: void 0,
|
|
103
|
+
critical: !1,
|
|
104
|
+
category: e.category
|
|
105
|
+
} : {
|
|
102
106
|
named: t,
|
|
103
|
-
critical:
|
|
104
|
-
category:
|
|
107
|
+
critical: o(t) === "critical",
|
|
108
|
+
category: l(t)
|
|
105
109
|
};
|
|
106
|
-
}),
|
|
110
|
+
}), d = ({ named: e, critical: t, category: n }, r) => ({
|
|
107
111
|
category: n,
|
|
108
112
|
...t ? { key: e } : {},
|
|
109
|
-
hosts:
|
|
113
|
+
hosts: s,
|
|
110
114
|
allow: r
|
|
111
115
|
});
|
|
112
|
-
if (!
|
|
113
|
-
let
|
|
116
|
+
if (!u) return ae(), c.map((e) => d(e, !1));
|
|
117
|
+
let f = await u(c.map(({ named: e, critical: t, category: r }) => t ? {
|
|
114
118
|
key: e,
|
|
115
|
-
hosts:
|
|
116
|
-
attach:
|
|
119
|
+
hosts: s,
|
|
120
|
+
attach: n
|
|
117
121
|
} : {
|
|
118
|
-
category:
|
|
119
|
-
hosts:
|
|
122
|
+
category: r,
|
|
123
|
+
hosts: s
|
|
120
124
|
}));
|
|
121
|
-
return
|
|
125
|
+
return c.map((e, t) => d(e, f[t] !== void 0 && f[t] !== !1));
|
|
122
126
|
},
|
|
123
|
-
boundary:
|
|
127
|
+
boundary: b
|
|
124
128
|
};
|
|
125
|
-
}, z = (e) => e,
|
|
129
|
+
}, z = (e) => e, ce = 5e3, le = /* @__PURE__ */ new Set([]), B = () => "https://fkn.app", V = (e) => e ? "" : `incognito-${crypto.randomUUID()}`, H = (e, t, n) => {
|
|
126
130
|
let r, i = new Promise((e, i) => {
|
|
127
131
|
r = setTimeout(() => i(typeof n == "string" ? Error(n) : n()), t);
|
|
128
132
|
});
|
|
129
133
|
return Promise.race([e, i]).finally(() => clearTimeout(r));
|
|
130
|
-
}, U = (e) => Object.assign(Error(e), { name:
|
|
134
|
+
}, U = (e) => Object.assign(Error(e), { name: g }), ue = "frame.postMessage: this FKN page predates frame messaging; reload the app to load the current one", W = !1, de = () => {
|
|
131
135
|
W || (W = !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."));
|
|
132
136
|
}, G = ({ from: e, origin: t, attach: n, signal: r }) => (i) => {
|
|
133
137
|
let a = (r) => {
|
|
@@ -144,20 +148,20 @@ var ne = async () => {
|
|
|
144
148
|
}));
|
|
145
149
|
};
|
|
146
150
|
return window.addEventListener("message", a, { signal: r }), () => window.removeEventListener("message", a);
|
|
147
|
-
}, K = ({ control: e, target:
|
|
148
|
-
let
|
|
149
|
-
session:
|
|
150
|
-
declaredHosts:
|
|
151
|
-
approvedOrigins:
|
|
152
|
-
attach:
|
|
151
|
+
}, K = ({ control: e, target: t, session: i, declaredHosts: a, approvedOrigins: o, attach: s, assertLive: l, guard: u, consent: d, onNavigated: f, relay: p }) => {
|
|
152
|
+
let m = t, g = Promise.resolve(), { gate: _, requestCategories: v, boundary: y } = se({
|
|
153
|
+
session: i,
|
|
154
|
+
declaredHosts: a,
|
|
155
|
+
approvedOrigins: o,
|
|
156
|
+
attach: s,
|
|
153
157
|
assertLive: l,
|
|
154
158
|
documentHost: typeof e.documentHost == "function" ? () => u(() => e.documentHost()) : void 0,
|
|
155
|
-
current: () =>
|
|
156
|
-
...
|
|
159
|
+
current: () => m,
|
|
160
|
+
...d
|
|
157
161
|
});
|
|
158
|
-
return
|
|
162
|
+
return c({
|
|
159
163
|
executor: {
|
|
160
|
-
execute: (t, n,
|
|
164
|
+
execute: (t, n, i) => le.has(n) ? Promise.reject(r(n, "cloud")) : (l(), u(() => e.executeLocator(t, n, i))),
|
|
161
165
|
highlight: async () => {}
|
|
162
166
|
},
|
|
163
167
|
gate: _,
|
|
@@ -167,26 +171,26 @@ var ne = async () => {
|
|
|
167
171
|
operation: "evaluate",
|
|
168
172
|
args: [t, n],
|
|
169
173
|
phase: "execute"
|
|
170
|
-
}), H(u(() => e.executeLocator([], "evaluate", [t, n])), F,
|
|
171
|
-
postMessage: (r, i
|
|
172
|
-
if (l(), typeof e.messaging != "function") throw n(
|
|
173
|
-
if (
|
|
174
|
-
let { port1:
|
|
175
|
-
|
|
176
|
-
data:
|
|
177
|
-
transfer:
|
|
178
|
-
},
|
|
179
|
-
let
|
|
174
|
+
}), H(u(() => e.executeLocator([], "evaluate", [t, n])), F, ie)),
|
|
175
|
+
postMessage: (t, r, i) => {
|
|
176
|
+
if (l(), typeof e.messaging != "function") throw n(ue, "postMessage", "cloud");
|
|
177
|
+
if (r !== "*" && !y().includes(new URL(r).hostname)) throw h(I, "postMessage");
|
|
178
|
+
let { port1: a, port2: o } = new MessageChannel();
|
|
179
|
+
a.postMessage({
|
|
180
|
+
data: t,
|
|
181
|
+
transfer: i
|
|
182
|
+
}, i);
|
|
183
|
+
let s = [o, r], c = g.then(async () => (await _({
|
|
180
184
|
parts: [],
|
|
181
185
|
operation: "postMessage",
|
|
182
|
-
args:
|
|
186
|
+
args: s,
|
|
183
187
|
phase: "execute"
|
|
184
|
-
}), { answer: u(() => e.executeLocator([], "postMessage",
|
|
185
|
-
return g =
|
|
188
|
+
}), { answer: u(() => e.executeLocator([], "postMessage", s)) }));
|
|
189
|
+
return g = c.catch(() => {}), c.then(async ({ answer: e }) => {
|
|
186
190
|
await e;
|
|
187
191
|
});
|
|
188
192
|
},
|
|
189
|
-
listen: (t) => (typeof e.messaging != "function" &&
|
|
193
|
+
listen: (t) => (typeof e.messaging != "function" && de(), p(t)),
|
|
190
194
|
goto: async (t, n = {}) => {
|
|
191
195
|
let r = new URL(t, location.href).href;
|
|
192
196
|
l();
|
|
@@ -196,81 +200,81 @@ var ne = async () => {
|
|
|
196
200
|
} catch {
|
|
197
201
|
return "";
|
|
198
202
|
}
|
|
199
|
-
})(),
|
|
200
|
-
|
|
203
|
+
})(), s = a !== "" && !o.has(a);
|
|
204
|
+
s && o.add(a);
|
|
201
205
|
try {
|
|
202
|
-
await H(u(() => e.goto(r, n)), (i ?? 3e4) +
|
|
206
|
+
await H(u(() => e.goto(r, n)), (i ?? 3e4) + ce, "cloud.attachFrame: the render proxy did not answer goto; the frame may have been detached or its page reloaded");
|
|
203
207
|
} catch (e) {
|
|
204
|
-
throw
|
|
208
|
+
throw s && o.delete(a), e;
|
|
205
209
|
}
|
|
206
|
-
|
|
210
|
+
m = r, f();
|
|
207
211
|
},
|
|
208
|
-
url: () =>
|
|
212
|
+
url: () => m
|
|
209
213
|
});
|
|
210
|
-
},
|
|
214
|
+
}, fe = 250, pe = 500, me = 65e3, he = 2e3, ge = 2e3, _e = 2, ve = 2e3, ye = 2e3, be = ({ origin: e, target: t, session: n, domains: r, attach: i }) => {
|
|
211
215
|
let a = new URL("/attach-window", e);
|
|
212
216
|
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;
|
|
213
|
-
},
|
|
217
|
+
}, xe = (e, t) => {
|
|
214
218
|
let n = document.createElement("iframe"), r = new URL("/attach-jar", e);
|
|
215
219
|
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;
|
|
216
|
-
},
|
|
220
|
+
}, Se = (e, t) => {
|
|
217
221
|
let n = new MutationObserver(() => {
|
|
218
222
|
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"));
|
|
219
223
|
});
|
|
220
224
|
e.parentNode && n.observe(e.parentNode, { childList: !0 }), n.observe(document.documentElement, { childList: !0 }), t.addEventListener("abort", () => n.disconnect(), { once: !0 });
|
|
221
|
-
},
|
|
225
|
+
}, q = () => U("cloud.attachFrame: the attached window closed, reloaded or left the page FKN attached; attach a fresh window"), J = () => U("cloud.attachFrame: the attached window stopped answering; attach a fresh window"), Ce = () => U("cloud.attachFrame: the window went away before it connected; attach a fresh window"), we = () => U("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"), Te = async (e) => {
|
|
222
226
|
if (typeof window > "u") throw Error("cloud.attachFrame needs a window realm");
|
|
223
|
-
let { domains: t = [], syncCookies: n = !0, permissions: r } = e, { url: i, width: a, height: o } =
|
|
224
|
-
if (window.origin === "null") throw new
|
|
225
|
-
let
|
|
227
|
+
let { domains: t = [], syncCookies: n = !0, permissions: r } = e, { url: i, width: a, height: o } = p(e.window);
|
|
228
|
+
if (window.origin === "null") throw new d("opaque-opener");
|
|
229
|
+
let c = B(), l = crypto.randomUUID(), u = V(n), m = y(t), h = /* @__PURE__ */ new Set();
|
|
226
230
|
i && h.add(new URL(i).origin);
|
|
227
|
-
let g = n ?
|
|
228
|
-
origin:
|
|
231
|
+
let g = n ? xe(c, l) : null, _ = window.open(be({
|
|
232
|
+
origin: c,
|
|
229
233
|
target: i,
|
|
230
|
-
session:
|
|
231
|
-
domains:
|
|
232
|
-
attach:
|
|
234
|
+
session: u,
|
|
235
|
+
domains: m,
|
|
236
|
+
attach: l
|
|
233
237
|
}), "_blank", `popup,width=${a},height=${o}`);
|
|
234
238
|
if (!_) throw g?.remove(), new s();
|
|
235
|
-
let
|
|
239
|
+
let v = new AbortController(), b = !1, x = null, S = (e, t = !1) => {
|
|
236
240
|
if (x === null) {
|
|
237
|
-
x = e,
|
|
241
|
+
x = e, v.abort(t ? J() : q());
|
|
238
242
|
try {
|
|
239
243
|
_.closed || _.postMessage({
|
|
240
|
-
type:
|
|
241
|
-
attach:
|
|
244
|
+
type: k.detach,
|
|
245
|
+
attach: l,
|
|
242
246
|
...t ? { unanswered: t } : {}
|
|
243
|
-
},
|
|
247
|
+
}, c);
|
|
244
248
|
} catch {}
|
|
245
|
-
g && setTimeout(() => g.remove(),
|
|
249
|
+
g && setTimeout(() => g.remove(), ye);
|
|
246
250
|
}
|
|
247
251
|
};
|
|
248
|
-
g &&
|
|
252
|
+
g && Se(g, v.signal);
|
|
249
253
|
let C = new Promise((e, t) => {
|
|
250
|
-
|
|
254
|
+
v.signal.addEventListener("abort", () => t(v.signal.reason), { once: !0 });
|
|
251
255
|
});
|
|
252
256
|
C.catch(() => {});
|
|
253
|
-
let
|
|
254
|
-
if (
|
|
255
|
-
}, D = (e) =>
|
|
257
|
+
let w = C.then(() => {}, () => {}), E = () => {
|
|
258
|
+
if (v.signal.aborted) throw v.signal.reason;
|
|
259
|
+
}, D = (e) => v.signal.aborted ? Promise.reject(v.signal.reason) : Promise.race([e(), C]), O = (e) => e.source === _ && e.origin === c;
|
|
256
260
|
window.addEventListener("message", (e) => {
|
|
257
|
-
if (!
|
|
261
|
+
if (!O(e)) return;
|
|
258
262
|
let t = e.data;
|
|
259
|
-
typeof t == "object" && t && t.attach ===
|
|
260
|
-
}, { signal:
|
|
263
|
+
typeof t == "object" && t && t.attach === l && (t.type === k.refused ? S(new d(t.reason)) : t.type === k.gone && S(b ? q() : Ce()));
|
|
264
|
+
}, { signal: v.signal }), window.addEventListener("pagehide", () => S(q()), { signal: v.signal });
|
|
261
265
|
let A = () => {
|
|
262
266
|
try {
|
|
263
267
|
_.postMessage({
|
|
264
|
-
type:
|
|
265
|
-
attach:
|
|
266
|
-
},
|
|
268
|
+
type: k.hello,
|
|
269
|
+
attach: l
|
|
270
|
+
}, c);
|
|
267
271
|
} catch {}
|
|
268
272
|
};
|
|
269
273
|
A();
|
|
270
|
-
let j = setInterval(A,
|
|
271
|
-
_.closed && S(b ?
|
|
272
|
-
},
|
|
273
|
-
|
|
274
|
+
let j = setInterval(A, fe), M = setInterval(() => {
|
|
275
|
+
_.closed && S(b ? q() : we());
|
|
276
|
+
}, pe);
|
|
277
|
+
v.signal.addEventListener("abort", () => {
|
|
274
278
|
clearInterval(j), clearInterval(M);
|
|
275
279
|
}, { once: !0 });
|
|
276
280
|
let N = async (e) => {
|
|
@@ -284,10 +288,10 @@ var ne = async () => {
|
|
|
284
288
|
let e = await N(H(P({}, {
|
|
285
289
|
key: ee,
|
|
286
290
|
transport: {
|
|
287
|
-
emit: (e, t) => _.postMessage(e,
|
|
291
|
+
emit: (e, t) => _.postMessage(e, c, t ?? []),
|
|
288
292
|
receive: (e) => {
|
|
289
293
|
let t = (t) => {
|
|
290
|
-
|
|
294
|
+
O(t) && e(t.data, {
|
|
291
295
|
source: t.source,
|
|
292
296
|
origin: t.origin
|
|
293
297
|
});
|
|
@@ -295,27 +299,27 @@ var ne = async () => {
|
|
|
295
299
|
return window.addEventListener("message", t), () => window.removeEventListener("message", t);
|
|
296
300
|
}
|
|
297
301
|
},
|
|
298
|
-
unregisterSignal:
|
|
302
|
+
unregisterSignal: v.signal,
|
|
299
303
|
revivableModules: z(f)
|
|
300
304
|
}), te, "cloud.attachFrame: timed out connecting to the window"));
|
|
301
305
|
b = !0, clearInterval(j);
|
|
302
306
|
let t = 0, n = setInterval(() => {
|
|
303
|
-
H(D(() => e.ping()),
|
|
307
|
+
H(D(() => e.ping()), ge, "ping").then(() => {
|
|
304
308
|
t = 0;
|
|
305
309
|
}, () => {
|
|
306
|
-
|
|
310
|
+
v.signal.aborted || (document.visibilityState === "hidden" ? t = 0 : ++t >= _e && S(J(), !0));
|
|
307
311
|
});
|
|
308
|
-
},
|
|
309
|
-
|
|
310
|
-
let a =
|
|
311
|
-
|
|
312
|
+
}, he);
|
|
313
|
+
v.signal.addEventListener("abort", () => clearInterval(n), { once: !0 }), await N(H(e.ready(), me, "cloud.attachFrame: the window never became ready"));
|
|
314
|
+
let a = T("attached frame");
|
|
315
|
+
v.signal.aborted ? a() : v.signal.addEventListener("abort", a, { once: !0 });
|
|
312
316
|
let o = K({
|
|
313
317
|
control: e,
|
|
314
318
|
target: i,
|
|
315
|
-
session:
|
|
316
|
-
declaredHosts:
|
|
319
|
+
session: u,
|
|
320
|
+
declaredHosts: m,
|
|
317
321
|
approvedOrigins: h,
|
|
318
|
-
attach:
|
|
322
|
+
attach: l,
|
|
319
323
|
assertLive: E,
|
|
320
324
|
guard: D,
|
|
321
325
|
consent: {
|
|
@@ -325,32 +329,32 @@ var ne = async () => {
|
|
|
325
329
|
onNavigated: () => {},
|
|
326
330
|
relay: G({
|
|
327
331
|
from: () => _,
|
|
328
|
-
origin:
|
|
329
|
-
attach:
|
|
330
|
-
signal:
|
|
332
|
+
origin: c,
|
|
333
|
+
attach: l,
|
|
334
|
+
signal: v.signal
|
|
331
335
|
})
|
|
332
|
-
}), s = null,
|
|
336
|
+
}), s = null, d = Object.assign(o, {
|
|
333
337
|
close: () => s ??= (async () => {
|
|
334
|
-
|
|
338
|
+
v.signal.aborted || await H(Promise.allSettled([D(() => e.flushCookies()), D(() => e.sweepStorage())]), ve, "close").catch(() => {});
|
|
335
339
|
try {
|
|
336
340
|
_.close();
|
|
337
341
|
} catch {}
|
|
338
|
-
S(
|
|
342
|
+
S(q());
|
|
339
343
|
})(),
|
|
340
|
-
closed:
|
|
344
|
+
closed: w
|
|
341
345
|
});
|
|
342
|
-
return r?.length && await N(
|
|
346
|
+
return r?.length && await N(d.request(r)), d;
|
|
343
347
|
} catch (e) {
|
|
344
348
|
let t = x ?? e;
|
|
345
|
-
if (!(t instanceof
|
|
349
|
+
if (!(t instanceof d)) try {
|
|
346
350
|
_.close();
|
|
347
351
|
} catch {}
|
|
348
352
|
throw S(t), t;
|
|
349
353
|
}
|
|
350
|
-
},
|
|
354
|
+
}, Ee = 2e4, De = 65e3, Oe = (e) => !e || e === "about:blank", ke = ({ target: e, session: t, domains: n, attach: r }) => {
|
|
351
355
|
let i = new URL("/attach-frame", B());
|
|
352
356
|
return e && i.searchParams.set("url", e), t && i.searchParams.set("session", t), n.length && i.searchParams.set("domains", n.join(",")), i.searchParams.set("attach", r), i.href;
|
|
353
|
-
},
|
|
357
|
+
}, Ae = (e, t) => {
|
|
354
358
|
let n = () => {
|
|
355
359
|
a(), t();
|
|
356
360
|
}, r = e.parentNode, i = new MutationObserver(() => {
|
|
@@ -359,10 +363,10 @@ var ne = async () => {
|
|
|
359
363
|
window.removeEventListener("pagehide", n), i.disconnect();
|
|
360
364
|
};
|
|
361
365
|
window.addEventListener("pagehide", n, { once: !0 }), r && i.observe(r, { childList: !0 }), e.isConnected || (a(), t());
|
|
362
|
-
},
|
|
366
|
+
}, je = () => U("cloud.attachFrame: the attached iframe left the document or was reloaded; attach a fresh iframe"), Y = (e, t) => {
|
|
363
367
|
let n = [...e.split(";"), ...t.split(";")].map((e) => e.trim()).filter(Boolean);
|
|
364
368
|
return [...new Set(n)].join("; ");
|
|
365
|
-
},
|
|
369
|
+
}, Me = [
|
|
366
370
|
300,
|
|
367
371
|
1200,
|
|
368
372
|
4e3
|
|
@@ -375,45 +379,45 @@ var ne = async () => {
|
|
|
375
379
|
}, 50));
|
|
376
380
|
};
|
|
377
381
|
t();
|
|
378
|
-
for (let e of
|
|
379
|
-
},
|
|
382
|
+
for (let e of Me) setTimeout(t, e);
|
|
383
|
+
}, Ne = (e) => {
|
|
380
384
|
let t = e.getAttribute("sandbox");
|
|
381
385
|
if (t === null) return;
|
|
382
386
|
let n = new Set(t.toLowerCase().split(/\s+/).filter(Boolean)), r = ["allow-scripts", "allow-same-origin"].filter((e) => !n.has(e));
|
|
383
387
|
if (r.length) throw Error(`cloud.attachFrame: the iframe's sandbox attribute must include ${r.join(" and ")} for the render proxy to load`);
|
|
384
|
-
},
|
|
388
|
+
}, Pe = async ({ iframe: e, domains: t = [], syncCookies: n = !0, lockdown: r = !1, permissions: a }) => {
|
|
385
389
|
if (typeof window > "u") throw Error("cloud.attachFrame needs a window realm");
|
|
386
390
|
if (r) throw Error("cloud.attachFrame does not support lockdown; use the extension backend for a sealed frame");
|
|
387
391
|
if (!e.isConnected) throw Error("cloud.attachFrame: the iframe must be connected to the document before attaching");
|
|
388
|
-
|
|
389
|
-
let
|
|
390
|
-
if (
|
|
392
|
+
Ne(e);
|
|
393
|
+
let o = e.getAttribute("src") ?? "", s = (() => {
|
|
394
|
+
if (Oe(o)) return null;
|
|
391
395
|
try {
|
|
392
|
-
return new URL(e.src ||
|
|
396
|
+
return new URL(e.src || o, location.href);
|
|
393
397
|
} catch {
|
|
394
|
-
throw Error(`cloud.attachFrame: the iframe src is not a valid URL: ${
|
|
398
|
+
throw Error(`cloud.attachFrame: the iframe src is not a valid URL: ${o}`);
|
|
395
399
|
}
|
|
396
400
|
})();
|
|
397
|
-
if (
|
|
401
|
+
if (s) {
|
|
398
402
|
let e = new URL("/attach-frame", B());
|
|
399
|
-
if (
|
|
403
|
+
if (s.origin === e.origin && s.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");
|
|
400
404
|
}
|
|
401
|
-
let
|
|
402
|
-
|
|
403
|
-
let
|
|
405
|
+
let c = s?.href ?? "";
|
|
406
|
+
c && i(c);
|
|
407
|
+
let l = V(n), u = y(t), d = /* @__PURE__ */ new Set();
|
|
404
408
|
try {
|
|
405
|
-
d.add(new URL(
|
|
409
|
+
d.add(new URL(c).origin);
|
|
406
410
|
} catch {}
|
|
407
411
|
let p = new AbortController(), m = e.referrerPolicy, h = e.allow, g = crypto.randomUUID();
|
|
408
|
-
if (e.referrerPolicy = "origin", e.allow =
|
|
409
|
-
target:
|
|
410
|
-
session:
|
|
412
|
+
if (e.referrerPolicy = "origin", e.allow = Y(S(), e.allow), e.src = ke({
|
|
413
|
+
target: c,
|
|
414
|
+
session: l,
|
|
411
415
|
domains: u,
|
|
412
416
|
attach: g
|
|
413
417
|
}), !e.contentWindow) throw Error("cloud.attachFrame: the iframe window is not available");
|
|
414
418
|
try {
|
|
415
419
|
let t = await H(P({}, {
|
|
416
|
-
key:
|
|
420
|
+
key: O,
|
|
417
421
|
origin: B(),
|
|
418
422
|
transport: {
|
|
419
423
|
receive: window,
|
|
@@ -421,22 +425,22 @@ var ne = async () => {
|
|
|
421
425
|
},
|
|
422
426
|
unregisterSignal: p.signal,
|
|
423
427
|
revivableModules: z(f)
|
|
424
|
-
}),
|
|
425
|
-
await H(t.ready(),
|
|
426
|
-
let n =
|
|
428
|
+
}), Ee, "cloud.attachFrame: timed out connecting to the render proxy page");
|
|
429
|
+
await H(t.ready(), De, "cloud.attachFrame: the render proxy never became ready"), c && X(e), Ae(e, () => p.abort());
|
|
430
|
+
let n = T("attached frame");
|
|
427
431
|
p.signal.aborted ? n() : p.signal.addEventListener("abort", n, { once: !0 });
|
|
428
|
-
let r = e.contentWindow,
|
|
432
|
+
let r = e.contentWindow, i = K({
|
|
429
433
|
control: t,
|
|
430
|
-
target:
|
|
431
|
-
session:
|
|
434
|
+
target: c,
|
|
435
|
+
session: l,
|
|
432
436
|
declaredHosts: u,
|
|
433
437
|
approvedOrigins: d,
|
|
434
438
|
attach: g,
|
|
435
439
|
assertLive: () => {
|
|
436
|
-
if (p.signal.aborted || !e.isConnected || e.contentWindow !== r) throw p.abort(),
|
|
440
|
+
if (p.signal.aborted || !e.isConnected || e.contentWindow !== r) throw p.abort(), je();
|
|
437
441
|
},
|
|
438
442
|
guard: (e) => e(),
|
|
439
|
-
consent: await
|
|
443
|
+
consent: await re(),
|
|
440
444
|
onNavigated: () => X(e),
|
|
441
445
|
relay: G({
|
|
442
446
|
from: () => r,
|
|
@@ -445,12 +449,12 @@ var ne = async () => {
|
|
|
445
449
|
signal: p.signal
|
|
446
450
|
})
|
|
447
451
|
});
|
|
448
|
-
return
|
|
452
|
+
return a?.length && await i.request(a), i;
|
|
449
453
|
} catch (t) {
|
|
450
|
-
throw p.abort(), e.referrerPolicy = m, e.allow = h, e.src =
|
|
454
|
+
throw p.abort(), e.referrerPolicy = m, e.allow = h, e.src = c || "about:blank", t;
|
|
451
455
|
}
|
|
452
|
-
}, Z = (async (e) =>
|
|
453
|
-
let e = await
|
|
456
|
+
}, Z = (async (e) => u(e) === "window" ? Te(e) : Pe(e)), Fe = () => typeof window < "u" && !0, Q = async () => {
|
|
457
|
+
let e = await b.then((e) => e.cloud.quota());
|
|
454
458
|
return {
|
|
455
459
|
premium: e.premium,
|
|
456
460
|
overQuota: e.overQuota,
|
|
@@ -461,16 +465,16 @@ var ne = async () => {
|
|
|
461
465
|
bytesPerSecond: e.bytesPerSecond,
|
|
462
466
|
bitsPerSecond: e.bytesPerSecond * 8
|
|
463
467
|
};
|
|
464
|
-
},
|
|
468
|
+
}, Ie = /* @__PURE__ */ e({
|
|
465
469
|
attachFrame: () => Z,
|
|
466
470
|
available: () => $,
|
|
467
|
-
dgram: () =>
|
|
468
|
-
dns: () =>
|
|
469
|
-
fetch: () =>
|
|
470
|
-
fs: () =>
|
|
471
|
-
http: () =>
|
|
472
|
-
net: () =>
|
|
471
|
+
dgram: () => N,
|
|
472
|
+
dns: () => A,
|
|
473
|
+
fetch: () => E,
|
|
474
|
+
fs: () => j,
|
|
475
|
+
http: () => ne,
|
|
476
|
+
net: () => M,
|
|
473
477
|
quota: () => Q
|
|
474
|
-
}), $ = () =>
|
|
478
|
+
}), $ = () => x;
|
|
475
479
|
//#endregion
|
|
476
|
-
export {
|
|
480
|
+
export { Fe as a, Z as i, Ie as n, Q as r, $ as t };
|