@fkn/lib 0.9.34 → 0.9.35

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.
Files changed (89) hide show
  1. package/account.cjs +1 -1
  2. package/account.d.ts +6 -6
  3. package/account.js +3 -3
  4. package/{api-Bgsg9t9D.d.ts → api-CfmRAze5.d.ts} +1 -1
  5. package/{api-BdTgLphT.js → api-CtiKFcK3.js} +2 -2
  6. package/{api-MW-Lm0u8.cjs → api-Djf-XdZ4.cjs} +2 -2
  7. package/api.cjs +1 -1
  8. package/api.d.ts +2 -2
  9. package/api.js +1 -1
  10. package/attach-policy.d.ts +5 -5
  11. package/cloud/dns.d.ts +1 -1
  12. package/cloud/fetch.cjs +1 -1
  13. package/cloud/fetch.d.ts +1 -1
  14. package/cloud/fetch.js +1 -1
  15. package/cloud/fs/promises.d.ts +3 -4
  16. package/cloud/fs.cjs +1 -1
  17. package/cloud/fs.d.ts +2 -2
  18. package/cloud/fs.js +2 -2
  19. package/cloud/net.d.ts +1 -1
  20. package/cloud-B9Sd7V1g.js +422 -0
  21. package/cloud-DCWD_0sd.cjs +1 -0
  22. package/{cloud-C40YCPuv.d.ts → cloud-DxitkM7z.d.ts} +9 -5
  23. package/cloud.cjs +1 -1
  24. package/cloud.d.ts +4 -4
  25. package/cloud.js +2 -2
  26. package/{contract-Gd543I6m.d.ts → contract-D37GGkou.d.ts} +126 -1
  27. package/contract.cjs +1 -0
  28. package/contract.d.ts +2 -2
  29. package/contract.js +28 -0
  30. package/desktop.d.ts +7 -7
  31. package/dgram.cjs +1 -1
  32. package/dgram.d.ts +5 -5
  33. package/dgram.js +1 -1
  34. package/dns.cjs +1 -1
  35. package/dns.d.ts +3 -3
  36. package/dns.js +1 -1
  37. package/extension-DJQ0oYdk.js +89 -0
  38. package/extension-DSrUjoLw.cjs +1 -0
  39. package/{extension-Bm-PwsD6.d.ts → extension-TRYu_aG-.d.ts} +16 -13
  40. package/extension.cjs +1 -1
  41. package/extension.d.ts +3 -3
  42. package/extension.js +3 -3
  43. package/fs/promises.cjs +1 -1
  44. package/fs/promises.d.ts +3 -3
  45. package/fs/promises.js +1 -1
  46. package/{fs-CYcErwc4.d.ts → fs--NhtUyYa.d.ts} +1 -1
  47. package/{fs-O2bp9J0x.js → fs-BvNZePtN.js} +4 -4
  48. package/{fs-Bv3aFjqA.cjs → fs-D8RCGFNc.cjs} +1 -1
  49. package/fs.cjs +1 -1
  50. package/fs.d.ts +2 -2
  51. package/fs.js +1 -1
  52. package/http.d.ts +20 -20
  53. package/{index-DIK21kfh.d.ts → index-C_Lqta5o.d.ts} +110 -5
  54. package/{index-Cg6y_FTi.d.ts → index-kuPqkS_-.d.ts} +26 -3
  55. package/index.cjs +1 -1
  56. package/index.d.ts +25 -10
  57. package/index.js +51 -45
  58. package/{lib-C3f3XmGZ.js → lib-B-jGWfsv.js} +110 -60
  59. package/lib-Cjd91q7g.cjs +53 -0
  60. package/{net-BBtYFEzu.d.ts → net-0SlODFSM.d.ts} +2 -2
  61. package/net.cjs +1 -1
  62. package/net.d.ts +1 -1
  63. package/net.js +1 -1
  64. package/node-fs-BNTPsX5c.cjs +1 -0
  65. package/{node-fs-C9ECR_9H.js → node-fs-BZy9bzKd.js} +2 -2
  66. package/opfs/promises.d.ts +2 -2
  67. package/opfs.cjs +1 -1
  68. package/opfs.d.ts +2 -2
  69. package/opfs.js +1 -1
  70. package/package.json +1 -1
  71. package/packages.cjs +1 -1
  72. package/packages.d.ts +27 -27
  73. package/packages.js +1 -1
  74. package/{proxy-XeHtHIdZ.d.ts → proxy-Bmb2wxG1.d.ts} +2 -2
  75. package/{proxy-_m6Sqcr6.cjs → proxy-CYcaW5ew.cjs} +1 -1
  76. package/{proxy-fXckOcRn.js → proxy-DDwY3AVG.js} +1 -1
  77. package/react.d.ts +3 -3
  78. package/rooms.cjs +1 -1
  79. package/rooms.d.ts +8 -8
  80. package/rooms.js +1 -1
  81. package/{storage-C6Cd4J5E.js → storage-BbcnDCnc.js} +1 -1
  82. package/{storage-WZEvw3KN.d.ts → storage-ZrY4Y4L5.d.ts} +21 -2
  83. package/{storage-D2eBifiu.cjs → storage-dSi2dUKx.cjs} +1 -1
  84. package/cloud-DBNeXS9R.js +0 -272
  85. package/cloud-DHuqVKrl.cjs +0 -1
  86. package/extension-DALH11b4.js +0 -87
  87. package/extension-lR-cSs2P.cjs +0 -1
  88. package/lib-WiHTYaNP.cjs +0 -53
  89. package/node-fs-DZPGCYWg.cjs +0 -1
@@ -0,0 +1,422 @@
1
+ import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
2
+ import { b as t, c as n, d as r, et as i, f as a, g as o, l as s, m as c, o as l, s as u, u as d, w as f, x as p } from "./lib-B-jGWfsv.js";
3
+ import { f as m, s as h, t as g } from "./hosts-C4-8lWwz.js";
4
+ import { a as _, c as v, n as y, o as b } from "./api-CtiKFcK3.js";
5
+ import { t as x } from "./busy-B189uX--.js";
6
+ import { t as S } from "./proxy-DDwY3AVG.js";
7
+ import { frameFetchVerdict as C } from "./attach-policy.js";
8
+ import { ATTACH_FRAME_KEY as w, ATTACH_WINDOW_KEY as T, ATTACH_WINDOW_MESSAGE as E, WINDOW_HANDSHAKE_TIMEOUT_MS as ee } from "./contract.js";
9
+ import { t as D } from "./dns.js";
10
+ import { t as O } from "./cloud/fs.js";
11
+ import { t as k } from "./net.js";
12
+ import { t as A } from "./dgram.js";
13
+ import { t as j } from "./http.js";
14
+ import { expose as M } from "osra";
15
+ //#region src/cloud/frame-broker.ts
16
+ var N = async () => {
17
+ let e = () => b("frame consent");
18
+ try {
19
+ let t = await e();
20
+ return {
21
+ request: typeof t.frameConsent.request == "function" ? t.frameConsent.request : void 0,
22
+ ensure: t.frameConsent.ensure
23
+ };
24
+ } catch (t) {
25
+ if (!(t instanceof y)) throw t;
26
+ return {
27
+ request: void 0,
28
+ ensure: (t) => e().then((e) => e.frameConsent.ensure(t))
29
+ };
30
+ }
31
+ }, P = "frame: this frame no longer holds the document the app attached it to", F = !1, te = () => {
32
+ F || (F = !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
+ }, ne = (e) => [...e].flatMap((e) => {
34
+ try {
35
+ return [new URL(e).hostname];
36
+ } catch {
37
+ return [];
38
+ }
39
+ }), I = (e, t, n) => n === null ? `frame.${e}: the user did not grant ${t} here` : `frame.${e}: the user did not grant ${t} on ${n}`, re = (e) => {
40
+ let { assertLive: t, attach: r, current: i, declaredHosts: a, documentHost: o, ensure: c, request: l, session: u, approvedOrigins: p } = e, _ = /* @__PURE__ */ new Set(), v = async () => o ? await o() : (() => {
41
+ try {
42
+ return new URL(i()).hostname;
43
+ } catch {
44
+ return "";
45
+ }
46
+ })(), y = () => g([...a, ...ne(p)]), b = async (e) => (await l([e]))[0] ?? !1;
47
+ return {
48
+ gate: async ({ operation: e, args: n, phase: i }) => {
49
+ t();
50
+ let o = m(e, n);
51
+ if (o === null) return;
52
+ let x = d(o);
53
+ if (x === void 0 || x === "auto") return;
54
+ if (e === "fetch") {
55
+ let e = C({
56
+ session: u,
57
+ declaredHosts: a,
58
+ approvedOrigins: p
59
+ }, i === "ensure" ? void 0 : n[0], { classifier: "fetchTarget" });
60
+ if (i === "ensure" && !u) throw f(e.kind === "refuse" ? e.reason : "", "fetch");
61
+ if (i !== "ensure" && e.kind === "refuse") throw f(e.reason, "fetch");
62
+ if (!l) {
63
+ if (e.kind === "refuse") throw f(e.reason, "fetch");
64
+ if (!await c({
65
+ scope: h(n[0], n[1]).scope,
66
+ hosts: e.promptHosts
67
+ })) throw f("frame.fetch: the user did not grant this", "fetch");
68
+ return;
69
+ }
70
+ let t = e.kind === "consent" ? e.targetHost : await v(), r = g([t, ...a]);
71
+ if (!r.length) throw f("frame: navigate the frame before fetch", "fetch");
72
+ if (await b({
73
+ category: "network",
74
+ hosts: r
75
+ }) === !1) throw f(I("fetch", "network", t || null), "fetch");
76
+ return;
77
+ }
78
+ let S = await v();
79
+ if (!S) throw f(`frame: navigate the frame before ${e}`, e);
80
+ if (!y().includes(S)) throw f(P, e);
81
+ if (!l) return;
82
+ let w = s(o);
83
+ if (w === void 0 || x === "critical" && _.has(`${o} ${S}`)) return;
84
+ let T = g([S, ...a]), E = await b(x === "critical" ? {
85
+ key: o,
86
+ hosts: T,
87
+ attach: r
88
+ } : {
89
+ category: w,
90
+ hosts: T
91
+ });
92
+ if (E === !1) throw f(I(e, w, null), e);
93
+ if (E === "once" && i !== "ensure") for (let e of T) _.add(`${o} ${e}`);
94
+ },
95
+ requestCategories: async (e) => {
96
+ t();
97
+ let i = await v(), o = g(i ? [i, ...a] : a);
98
+ if (!o.length) throw TypeError("frame.request: navigate the frame or declare domains first");
99
+ let s = e.map((e) => {
100
+ let t = e.key;
101
+ return {
102
+ named: t,
103
+ critical: t !== void 0 && d(t) === "critical",
104
+ category: e.category ?? (t === void 0 ? void 0 : n(t)) ?? "interaction"
105
+ };
106
+ }), c = ({ named: e, critical: t, category: n }, r) => ({
107
+ category: n,
108
+ ...t ? { key: e } : {},
109
+ hosts: o,
110
+ allow: r
111
+ });
112
+ if (!l) return te(), s.map((e) => c(e, !1));
113
+ let u = await l(s.map(({ named: e, critical: t, category: n }) => t ? {
114
+ key: e,
115
+ hosts: o,
116
+ attach: r
117
+ } : {
118
+ category: n,
119
+ hosts: o
120
+ }));
121
+ return s.map((e, t) => c(e, u[t] !== void 0 && u[t] !== !1));
122
+ }
123
+ };
124
+ }, L = (e) => e, ie = 5e3, ae = /* @__PURE__ */ new Set([]), R = () => "https://fkn.app", z = (e) => e ? "" : `incognito-${crypto.randomUUID()}`, B = (e, t, n) => {
125
+ let r, i = new Promise((e, i) => {
126
+ r = setTimeout(() => i(Error(n)), t);
127
+ });
128
+ return Promise.race([e, i]).finally(() => clearTimeout(r));
129
+ }, V = (e) => Object.assign(Error(e), { name: t }), H = ({ control: e, target: t, session: n, declaredHosts: r, approvedOrigins: i, attach: a, assertLive: o, guard: s, consent: l, onNavigated: u }) => {
130
+ let d = t, { gate: f, requestCategories: m } = re({
131
+ session: n,
132
+ declaredHosts: r,
133
+ approvedOrigins: i,
134
+ attach: a,
135
+ assertLive: o,
136
+ documentHost: typeof e.documentHost == "function" ? () => s(() => e.documentHost()) : void 0,
137
+ current: () => d,
138
+ ...l
139
+ });
140
+ return c({
141
+ executor: {
142
+ execute: (t, n, r) => ae.has(n) ? Promise.reject(p(n, "cloud")) : (o(), s(() => e.executeLocator(t, n, r))),
143
+ highlight: async () => {}
144
+ },
145
+ gate: f,
146
+ request: m,
147
+ goto: async (t, n = {}) => {
148
+ let r = new URL(t, location.href).href;
149
+ o();
150
+ let { timeoutMs: a } = n, c = (() => {
151
+ try {
152
+ return new URL(r).origin;
153
+ } catch {
154
+ return "";
155
+ }
156
+ })(), l = c !== "" && !i.has(c);
157
+ l && i.add(c);
158
+ try {
159
+ await B(s(() => e.goto(r, n)), (a ?? 3e4) + ie, "cloud.attachFrame: the render proxy did not answer goto; the frame may have been detached or its page reloaded");
160
+ } catch (e) {
161
+ throw l && i.delete(c), e;
162
+ }
163
+ d = r, u();
164
+ },
165
+ url: () => d
166
+ });
167
+ }, oe = 250, U = 500, W = 65e3, G = 2e3, K = 2e3, se = 2, ce = 2e3, le = 2e3, ue = ({ origin: e, target: t, session: n, domains: r, attach: i }) => {
168
+ let a = new URL("/attach-window", e);
169
+ 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;
170
+ }, de = (e, t) => {
171
+ let n = document.createElement("iframe"), r = new URL("/attach-jar", e);
172
+ 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;
173
+ }, fe = (e, t) => {
174
+ let n = new MutationObserver(() => {
175
+ 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"));
176
+ });
177
+ e.parentNode && n.observe(e.parentNode, { childList: !0 }), n.observe(document.documentElement, { childList: !0 }), t.addEventListener("abort", () => n.disconnect(), { once: !0 });
178
+ }, q = () => V("cloud.attachFrame: the attached window closed, reloaded or left the page FKN attached; attach a fresh window"), J = () => V("cloud.attachFrame: the attached window stopped answering; attach a fresh window"), pe = () => V("cloud.attachFrame: the window went away before it connected; attach a fresh window"), me = () => V("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"), he = async (e) => {
179
+ if (typeof window > "u") throw Error("cloud.attachFrame needs a window realm");
180
+ let { domains: t = [], syncCookies: n = !0, permissions: o } = e, { url: s, width: c, height: l } = u(e.window);
181
+ if (window.origin === "null") throw new a("opaque-opener");
182
+ let d = R(), f = crypto.randomUUID(), p = z(n), m = g(t), h = /* @__PURE__ */ new Set();
183
+ s && h.add(new URL(s).origin);
184
+ let _ = n ? de(d, f) : null, v = window.open(ue({
185
+ origin: d,
186
+ target: s,
187
+ session: p,
188
+ domains: m,
189
+ attach: f
190
+ }), "_blank", `popup,width=${c},height=${l}`);
191
+ if (!v) throw _?.remove(), new r();
192
+ let y = new AbortController(), b = !1, S = null, C = (e, t = !1) => {
193
+ if (S === null) {
194
+ S = e, y.abort(t ? J() : q());
195
+ try {
196
+ v.closed || v.postMessage({
197
+ type: E.detach,
198
+ attach: f,
199
+ ...t ? { unanswered: t } : {}
200
+ }, d);
201
+ } catch {}
202
+ _ && setTimeout(() => _.remove(), le);
203
+ }
204
+ };
205
+ _ && fe(_, y.signal);
206
+ let w = new Promise((e, t) => {
207
+ y.signal.addEventListener("abort", () => t(y.signal.reason), { once: !0 });
208
+ });
209
+ w.catch(() => {});
210
+ let D = w.then(() => {}, () => {}), O = () => {
211
+ if (y.signal.aborted) throw y.signal.reason;
212
+ }, k = (e) => y.signal.aborted ? Promise.reject(y.signal.reason) : Promise.race([e(), w]), A = (e) => e.source === v && e.origin === d;
213
+ window.addEventListener("message", (e) => {
214
+ if (!A(e)) return;
215
+ let t = e.data;
216
+ typeof t == "object" && t && t.attach === f && (t.type === E.refused ? C(new a(t.reason)) : t.type === E.gone && C(b ? q() : pe()));
217
+ }, { signal: y.signal }), window.addEventListener("pagehide", () => C(q()), { signal: y.signal });
218
+ let j = () => {
219
+ try {
220
+ v.postMessage({
221
+ type: E.hello,
222
+ attach: f
223
+ }, d);
224
+ } catch {}
225
+ };
226
+ j();
227
+ let N = setInterval(j, oe), P = setInterval(() => {
228
+ v.closed && C(b ? q() : me());
229
+ }, U);
230
+ y.signal.addEventListener("abort", () => {
231
+ clearInterval(N), clearInterval(P);
232
+ }, { once: !0 });
233
+ let F = async (e) => {
234
+ try {
235
+ return await Promise.race([e, w]);
236
+ } catch (e) {
237
+ throw S ?? e;
238
+ }
239
+ };
240
+ try {
241
+ let e = await F(B(M({}, {
242
+ key: T,
243
+ transport: {
244
+ emit: (e, t) => v.postMessage(e, d, t ?? []),
245
+ receive: (e) => {
246
+ let t = (t) => {
247
+ A(t) && e(t.data, {
248
+ source: t.source,
249
+ origin: t.origin
250
+ });
251
+ };
252
+ return window.addEventListener("message", t), () => window.removeEventListener("message", t);
253
+ }
254
+ },
255
+ unregisterSignal: y.signal,
256
+ revivableModules: L(i)
257
+ }), ee, "cloud.attachFrame: timed out connecting to the window"));
258
+ b = !0, clearInterval(N);
259
+ let t = 0, n = setInterval(() => {
260
+ B(k(() => e.ping()), K, "ping").then(() => {
261
+ t = 0;
262
+ }, () => {
263
+ y.signal.aborted || (document.visibilityState === "hidden" ? t = 0 : ++t >= se && C(J(), !0));
264
+ });
265
+ }, G);
266
+ y.signal.addEventListener("abort", () => clearInterval(n), { once: !0 }), await F(B(e.ready(), W, "cloud.attachFrame: the window never became ready"));
267
+ let r = x("attached frame");
268
+ y.signal.aborted ? r() : y.signal.addEventListener("abort", r, { once: !0 });
269
+ let a = H({
270
+ control: e,
271
+ target: s,
272
+ session: p,
273
+ declaredHosts: m,
274
+ approvedOrigins: h,
275
+ attach: f,
276
+ assertLive: O,
277
+ guard: k,
278
+ consent: {
279
+ request: (t) => k(() => e.requestConsent(t)),
280
+ ensure: (t) => k(() => e.requestConsent([t])).then(([e]) => e !== void 0 && e !== !1)
281
+ },
282
+ onNavigated: () => {}
283
+ }), c = null, l = () => c ??= (async () => {
284
+ y.signal.aborted || await B(Promise.allSettled([k(() => e.flushCookies()), k(() => e.sweepStorage())]), ce, "close").catch(() => {});
285
+ try {
286
+ v.close();
287
+ } catch {}
288
+ C(q());
289
+ })(), u = {
290
+ ...a,
291
+ close: l,
292
+ closed: D
293
+ };
294
+ return o?.length && await F(u.request(o)), u;
295
+ } catch (e) {
296
+ let t = S ?? e;
297
+ if (!(t instanceof a)) try {
298
+ v.close();
299
+ } catch {}
300
+ throw C(t), t;
301
+ }
302
+ }, ge = "autoplay; fullscreen; encrypted-media; picture-in-picture; clipboard-read; clipboard-write", _e = 2e4, ve = 65e3, ye = (e) => !e || e === "about:blank", be = ({ target: e, session: t, domains: n, attach: r }) => {
303
+ let i = new URL("/attach-frame", R());
304
+ 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;
305
+ }, xe = (e, t) => {
306
+ let n = () => {
307
+ a(), t();
308
+ }, r = e.parentNode, i = new MutationObserver(() => {
309
+ (!e.isConnected || e.parentNode !== r) && (a(), t());
310
+ }), a = () => {
311
+ window.removeEventListener("pagehide", n), i.disconnect();
312
+ };
313
+ window.addEventListener("pagehide", n, { once: !0 }), r && i.observe(r, { childList: !0 }), e.isConnected || (a(), t());
314
+ }, Se = () => V("cloud.attachFrame: the attached iframe left the document or was reloaded; attach a fresh iframe"), Ce = (e, t) => {
315
+ let n = [...e.split(";"), ...t.split(";")].map((e) => e.trim()).filter(Boolean);
316
+ return [...new Set(n)].join("; ");
317
+ }, Y = [
318
+ 300,
319
+ 1200,
320
+ 4e3
321
+ ], X = (e) => {
322
+ let t = () => {
323
+ if (!e.isConnected) return;
324
+ let t = e.style.height, n = e.getBoundingClientRect();
325
+ n.height && (e.style.height = `${n.height - 1}px`, setTimeout(() => {
326
+ e.style.height = t;
327
+ }, 50));
328
+ };
329
+ t();
330
+ for (let e of Y) setTimeout(t, e);
331
+ }, we = (e) => {
332
+ let t = e.getAttribute("sandbox");
333
+ if (t === null) return;
334
+ let n = new Set(t.toLowerCase().split(/\s+/).filter(Boolean)), r = ["allow-scripts", "allow-same-origin"].filter((e) => !n.has(e));
335
+ if (r.length) throw Error(`cloud.attachFrame: the iframe's sandbox attribute must include ${r.join(" and ")} for the render proxy to load`);
336
+ }, Te = async ({ iframe: e, domains: t = [], syncCookies: n = !0, lockdown: r = !1, permissions: a }) => {
337
+ if (typeof window > "u") throw Error("cloud.attachFrame needs a window realm");
338
+ if (r) throw Error("cloud.attachFrame does not support lockdown; use the extension backend for a sealed frame");
339
+ if (!e.isConnected) throw Error("cloud.attachFrame: the iframe must be connected to the document before attaching");
340
+ we(e);
341
+ let s = e.getAttribute("src") ?? "", c = (() => {
342
+ if (ye(s)) return null;
343
+ try {
344
+ return new URL(e.src || s, location.href);
345
+ } catch {
346
+ throw Error(`cloud.attachFrame: the iframe src is not a valid URL: ${s}`);
347
+ }
348
+ })();
349
+ if (c) {
350
+ let e = new URL("/attach-frame", R());
351
+ if (c.origin === e.origin && c.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");
352
+ }
353
+ let l = c?.href ?? "";
354
+ l && o(l);
355
+ let u = z(n), d = g(t), f = /* @__PURE__ */ new Set();
356
+ try {
357
+ f.add(new URL(l).origin);
358
+ } catch {}
359
+ let p = new AbortController(), m = e.referrerPolicy, h = e.allow, _ = crypto.randomUUID();
360
+ if (e.referrerPolicy = "origin", e.allow = Ce(ge, e.allow), e.src = be({
361
+ target: l,
362
+ session: u,
363
+ domains: d,
364
+ attach: _
365
+ }), !e.contentWindow) throw Error("cloud.attachFrame: the iframe window is not available");
366
+ try {
367
+ let t = await B(M({}, {
368
+ key: w,
369
+ origin: R(),
370
+ transport: {
371
+ receive: window,
372
+ emit: e.contentWindow
373
+ },
374
+ unregisterSignal: p.signal,
375
+ revivableModules: L(i)
376
+ }), _e, "cloud.attachFrame: timed out connecting to the render proxy page");
377
+ await B(t.ready(), ve, "cloud.attachFrame: the render proxy never became ready"), l && X(e), xe(e, () => p.abort());
378
+ let n = x("attached frame");
379
+ p.signal.aborted ? n() : p.signal.addEventListener("abort", n, { once: !0 });
380
+ let r = e.contentWindow, o = H({
381
+ control: t,
382
+ target: l,
383
+ session: u,
384
+ declaredHosts: d,
385
+ approvedOrigins: f,
386
+ attach: _,
387
+ assertLive: () => {
388
+ if (p.signal.aborted || !e.isConnected || e.contentWindow !== r) throw p.abort(), Se();
389
+ },
390
+ guard: (e) => e(),
391
+ consent: await N(),
392
+ onNavigated: () => X(e)
393
+ });
394
+ return a?.length && await o.request(a), o;
395
+ } catch (t) {
396
+ throw p.abort(), e.referrerPolicy = m, e.allow = h, e.src = l || "about:blank", t;
397
+ }
398
+ }, Z = (async (e) => l(e) === "window" ? he(e) : Te(e)), Ee = () => typeof window < "u" && !0, Q = async () => {
399
+ let e = await _.then((e) => e.cloud.quota());
400
+ return {
401
+ premium: e.premium,
402
+ overQuota: e.overQuota,
403
+ throttled: e.overQuota && !e.premium,
404
+ usedBytes: e.usedBytes,
405
+ limitBytes: e.limitBytes,
406
+ remainingBytes: e.remaining,
407
+ bytesPerSecond: e.bytesPerSecond,
408
+ bitsPerSecond: e.bytesPerSecond * 8
409
+ };
410
+ }, De = /* @__PURE__ */ e({
411
+ attachFrame: () => Z,
412
+ available: () => $,
413
+ dgram: () => A,
414
+ dns: () => D,
415
+ fetch: () => S,
416
+ fs: () => O,
417
+ http: () => j,
418
+ net: () => k,
419
+ quota: () => Q
420
+ }), $ = () => v;
421
+ //#endregion
422
+ export { Ee as a, Z as i, De as n, Q as r, $ as t };
@@ -0,0 +1 @@
1
+ const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./lib-Cjd91q7g.cjs"),n=require("./hosts-DD4rDeQH.cjs"),r=require("./api-Djf-XdZ4.cjs"),i=require("./busy-Dv8wzE5M.cjs"),a=require("./proxy-CYcaW5ew.cjs"),o=require("./attach-policy.cjs"),s=require("./contract.cjs"),c=require("./dns.cjs"),l=require("./cloud/fs.cjs"),u=require("./net.cjs"),d=require("./dgram.cjs"),f=require("./http.cjs");let p=require("osra");var m=async()=>{let e=()=>r.o(`frame consent`);try{let t=await e();return{request:typeof t.frameConsent.request==`function`?t.frameConsent.request:void 0,ensure:t.frameConsent.ensure}}catch(t){if(!(t instanceof r.n))throw t;return{request:void 0,ensure:t=>e().then(e=>e.frameConsent.ensure(t))}}},h=`frame: this frame no longer holds the document the app attached it to`,g=!1,_=()=>{g||(g=!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.`))},v=e=>[...e].flatMap(e=>{try{return[new URL(e).hostname]}catch{return[]}}),y=(e,t,n)=>n===null?`frame.${e}: the user did not grant ${t} here`:`frame.${e}: the user did not grant ${t} on ${n}`,b=e=>{let{assertLive:r,attach:i,current:a,declaredHosts:s,documentHost:c,ensure:l,request:u,session:d,approvedOrigins:f}=e,p=new Set,m=async()=>c?await c():(()=>{try{return new URL(a()).hostname}catch{return``}})(),g=()=>n.t([...s,...v(f)]),b=async e=>(await u([e]))[0]??!1;return{gate:async({operation:e,args:a,phase:c})=>{r();let _=n.f(e,a);if(_===null)return;let v=t.u(_);if(v===void 0||v===`auto`)return;if(e===`fetch`){let e=o.frameFetchVerdict({session:d,declaredHosts:s,approvedOrigins:f},c===`ensure`?void 0:a[0],{classifier:`fetchTarget`});if(c===`ensure`&&!d)throw t.w(e.kind===`refuse`?e.reason:``,`fetch`);if(c!==`ensure`&&e.kind===`refuse`)throw t.w(e.reason,`fetch`);if(!u){if(e.kind===`refuse`)throw t.w(e.reason,`fetch`);if(!await l({scope:n.s(a[0],a[1]).scope,hosts:e.promptHosts}))throw t.w(`frame.fetch: the user did not grant this`,`fetch`);return}let r=e.kind===`consent`?e.targetHost:await m(),i=n.t([r,...s]);if(!i.length)throw t.w(`frame: navigate the frame before fetch`,`fetch`);if(await b({category:`network`,hosts:i})===!1)throw t.w(y(`fetch`,`network`,r||null),`fetch`);return}let x=await m();if(!x)throw t.w(`frame: navigate the frame before ${e}`,e);if(!g().includes(x))throw t.w(h,e);if(!u)return;let S=t.l(_);if(S===void 0||v===`critical`&&p.has(`${_} ${x}`))return;let C=n.t([x,...s]),w=await b(v===`critical`?{key:_,hosts:C,attach:i}:{category:S,hosts:C});if(w===!1)throw t.w(y(e,S,null),e);if(w===`once`&&c!==`ensure`)for(let e of C)p.add(`${_} ${e}`)},requestCategories:async e=>{r();let a=await m(),o=n.t(a?[a,...s]:s);if(!o.length)throw TypeError(`frame.request: navigate the frame or declare domains first`);let c=e.map(e=>{let n=e.key;return{named:n,critical:n!==void 0&&t.u(n)===`critical`,category:e.category??(n===void 0?void 0:t.c(n))??`interaction`}}),l=({named:e,critical:t,category:n},r)=>({category:n,...t?{key:e}:{},hosts:o,allow:r});if(!u)return _(),c.map(e=>l(e,!1));let d=await u(c.map(({named:e,critical:t,category:n})=>t?{key:e,hosts:o,attach:i}:{category:n,hosts:o}));return c.map((e,t)=>l(e,d[t]!==void 0&&d[t]!==!1))}}},x=e=>e,S=5e3,C=new Set([]),w=()=>`https://fkn.app`,T=e=>e?``:`incognito-${crypto.randomUUID()}`,E=(e,t,n)=>{let r,i=new Promise((e,i)=>{r=setTimeout(()=>i(Error(n)),t)});return Promise.race([e,i]).finally(()=>clearTimeout(r))},D=e=>Object.assign(Error(e),{name:t.b}),O=({control:e,target:n,session:r,declaredHosts:i,approvedOrigins:a,attach:o,assertLive:s,guard:c,consent:l,onNavigated:u})=>{let d=n,{gate:f,requestCategories:p}=b({session:r,declaredHosts:i,approvedOrigins:a,attach:o,assertLive:s,documentHost:typeof e.documentHost==`function`?()=>c(()=>e.documentHost()):void 0,current:()=>d,...l});return t.m({executor:{execute:(n,r,i)=>C.has(r)?Promise.reject(t.x(r,`cloud`)):(s(),c(()=>e.executeLocator(n,r,i))),highlight:async()=>{}},gate:f,request:p,goto:async(t,n={})=>{let r=new URL(t,location.href).href;s();let{timeoutMs:i}=n,o=(()=>{try{return new URL(r).origin}catch{return``}})(),l=o!==``&&!a.has(o);l&&a.add(o);try{await E(c(()=>e.goto(r,n)),(i??3e4)+S,`cloud.attachFrame: the render proxy did not answer goto; the frame may have been detached or its page reloaded`)}catch(e){throw l&&a.delete(o),e}d=r,u()},url:()=>d})},ee=250,te=500,k=65e3,A=2e3,j=2e3,M=2,N=2e3,P=2e3,F=({origin:e,target:t,session:n,domains:r,attach:i})=>{let a=new URL(`/attach-window`,e);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},I=(e,t)=>{let n=document.createElement(`iframe`),r=new URL(`/attach-jar`,e);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},L=(e,t)=>{let n=new MutationObserver(()=>{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`))});e.parentNode&&n.observe(e.parentNode,{childList:!0}),n.observe(document.documentElement,{childList:!0}),t.addEventListener(`abort`,()=>n.disconnect(),{once:!0})},R=()=>D(`cloud.attachFrame: the attached window closed, reloaded or left the page FKN attached; attach a fresh window`),z=()=>D(`cloud.attachFrame: the attached window stopped answering; attach a fresh window`),B=()=>D(`cloud.attachFrame: the window went away before it connected; attach a fresh window`),V=()=>D(`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`),H=async e=>{if(typeof window>`u`)throw Error(`cloud.attachFrame needs a window realm`);let{domains:r=[],syncCookies:a=!0,permissions:o}=e,{url:c,width:l,height:u}=t.s(e.window);if(window.origin===`null`)throw new t.f(`opaque-opener`);let d=w(),f=crypto.randomUUID(),m=T(a),h=n.t(r),g=new Set;c&&g.add(new URL(c).origin);let _=a?I(d,f):null,v=window.open(F({origin:d,target:c,session:m,domains:h,attach:f}),`_blank`,`popup,width=${l},height=${u}`);if(!v)throw _?.remove(),new t.d;let y=new AbortController,b=!1,S=null,C=(e,t=!1)=>{if(S===null){S=e,y.abort(t?z():R());try{v.closed||v.postMessage({type:s.ATTACH_WINDOW_MESSAGE.detach,attach:f,...t?{unanswered:t}:{}},d)}catch{}_&&setTimeout(()=>_.remove(),P)}};_&&L(_,y.signal);let D=new Promise((e,t)=>{y.signal.addEventListener(`abort`,()=>t(y.signal.reason),{once:!0})});D.catch(()=>{});let H=D.then(()=>{},()=>{}),U=()=>{if(y.signal.aborted)throw y.signal.reason},W=e=>y.signal.aborted?Promise.reject(y.signal.reason):Promise.race([e(),D]),G=e=>e.source===v&&e.origin===d;window.addEventListener(`message`,e=>{if(!G(e))return;let n=e.data;typeof n==`object`&&n&&n.attach===f&&(n.type===s.ATTACH_WINDOW_MESSAGE.refused?C(new t.f(n.reason)):n.type===s.ATTACH_WINDOW_MESSAGE.gone&&C(b?R():B()))},{signal:y.signal}),window.addEventListener(`pagehide`,()=>C(R()),{signal:y.signal});let K=()=>{try{v.postMessage({type:s.ATTACH_WINDOW_MESSAGE.hello,attach:f},d)}catch{}};K();let q=setInterval(K,ee),J=setInterval(()=>{v.closed&&C(b?R():V())},te);y.signal.addEventListener(`abort`,()=>{clearInterval(q),clearInterval(J)},{once:!0});let Y=async e=>{try{return await Promise.race([e,D])}catch(e){throw S??e}};try{let e=await Y(E((0,p.expose)({},{key:s.ATTACH_WINDOW_KEY,transport:{emit:(e,t)=>v.postMessage(e,d,t??[]),receive:e=>{let t=t=>{G(t)&&e(t.data,{source:t.source,origin:t.origin})};return window.addEventListener(`message`,t),()=>window.removeEventListener(`message`,t)}},unregisterSignal:y.signal,revivableModules:x(t.et)}),s.WINDOW_HANDSHAKE_TIMEOUT_MS,`cloud.attachFrame: timed out connecting to the window`));b=!0,clearInterval(q);let n=0,r=setInterval(()=>{E(W(()=>e.ping()),j,`ping`).then(()=>{n=0},()=>{y.signal.aborted||(document.visibilityState===`hidden`?n=0:++n>=M&&C(z(),!0))})},A);y.signal.addEventListener(`abort`,()=>clearInterval(r),{once:!0}),await Y(E(e.ready(),k,`cloud.attachFrame: the window never became ready`));let a=i.t(`attached frame`);y.signal.aborted?a():y.signal.addEventListener(`abort`,a,{once:!0});let l=O({control:e,target:c,session:m,declaredHosts:h,approvedOrigins:g,attach:f,assertLive:U,guard:W,consent:{request:t=>W(()=>e.requestConsent(t)),ensure:t=>W(()=>e.requestConsent([t])).then(([e])=>e!==void 0&&e!==!1)},onNavigated:()=>{}}),u=null,_=()=>u??=(async()=>{y.signal.aborted||await E(Promise.allSettled([W(()=>e.flushCookies()),W(()=>e.sweepStorage())]),N,`close`).catch(()=>{});try{v.close()}catch{}C(R())})(),S={...l,close:_,closed:H};return o?.length&&await Y(S.request(o)),S}catch(e){let n=S??e;if(!(n instanceof t.f))try{v.close()}catch{}throw C(n),n}},U=`autoplay; fullscreen; encrypted-media; picture-in-picture; clipboard-read; clipboard-write`,W=2e4,G=65e3,K=e=>!e||e===`about:blank`,q=({target:e,session:t,domains:n,attach:r})=>{let i=new URL(`/attach-frame`,w());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},J=(e,t)=>{let n=()=>{a(),t()},r=e.parentNode,i=new MutationObserver(()=>{(!e.isConnected||e.parentNode!==r)&&(a(),t())}),a=()=>{window.removeEventListener(`pagehide`,n),i.disconnect()};window.addEventListener(`pagehide`,n,{once:!0}),r&&i.observe(r,{childList:!0}),e.isConnected||(a(),t())},Y=()=>D(`cloud.attachFrame: the attached iframe left the document or was reloaded; attach a fresh iframe`),ne=(e,t)=>{let n=[...e.split(`;`),...t.split(`;`)].map(e=>e.trim()).filter(Boolean);return[...new Set(n)].join(`; `)},re=[300,1200,4e3],X=e=>{let t=()=>{if(!e.isConnected)return;let t=e.style.height,n=e.getBoundingClientRect();n.height&&(e.style.height=`${n.height-1}px`,setTimeout(()=>{e.style.height=t},50))};t();for(let e of re)setTimeout(t,e)},ie=e=>{let t=e.getAttribute(`sandbox`);if(t===null)return;let n=new Set(t.toLowerCase().split(/\s+/).filter(Boolean)),r=[`allow-scripts`,`allow-same-origin`].filter(e=>!n.has(e));if(r.length)throw Error(`cloud.attachFrame: the iframe's sandbox attribute must include ${r.join(` and `)} for the render proxy to load`)},ae=async({iframe:e,domains:r=[],syncCookies:a=!0,lockdown:o=!1,permissions:c})=>{if(typeof window>`u`)throw Error(`cloud.attachFrame needs a window realm`);if(o)throw Error(`cloud.attachFrame does not support lockdown; use the extension backend for a sealed frame`);if(!e.isConnected)throw Error(`cloud.attachFrame: the iframe must be connected to the document before attaching`);ie(e);let l=e.getAttribute(`src`)??``,u=(()=>{if(K(l))return null;try{return new URL(e.src||l,location.href)}catch{throw Error(`cloud.attachFrame: the iframe src is not a valid URL: ${l}`)}})();if(u){let e=new URL(`/attach-frame`,w());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`)}let d=u?.href??``;d&&t.g(d);let f=T(a),h=n.t(r),g=new Set;try{g.add(new URL(d).origin)}catch{}let _=new AbortController,v=e.referrerPolicy,y=e.allow,b=crypto.randomUUID();if(e.referrerPolicy=`origin`,e.allow=ne(U,e.allow),e.src=q({target:d,session:f,domains:h,attach:b}),!e.contentWindow)throw Error(`cloud.attachFrame: the iframe window is not available`);try{let n=await E((0,p.expose)({},{key:s.ATTACH_FRAME_KEY,origin:w(),transport:{receive:window,emit:e.contentWindow},unregisterSignal:_.signal,revivableModules:x(t.et)}),W,`cloud.attachFrame: timed out connecting to the render proxy page`);await E(n.ready(),G,`cloud.attachFrame: the render proxy never became ready`),d&&X(e),J(e,()=>_.abort());let r=i.t(`attached frame`);_.signal.aborted?r():_.signal.addEventListener(`abort`,r,{once:!0});let a=e.contentWindow,o=O({control:n,target:d,session:f,declaredHosts:h,approvedOrigins:g,attach:b,assertLive:()=>{if(_.signal.aborted||!e.isConnected||e.contentWindow!==a)throw _.abort(),Y()},guard:e=>e(),consent:await m(),onNavigated:()=>X(e)});return c?.length&&await o.request(c),o}catch(t){throw _.abort(),e.referrerPolicy=v,e.allow=y,e.src=d||`about:blank`,t}},Z=(async e=>t.o(e)===`window`?H(e):ae(e)),oe=()=>typeof window<`u`&&!0,Q=async()=>{let e=await r.a.then(e=>e.cloud.quota());return{premium:e.premium,overQuota:e.overQuota,throttled:e.overQuota&&!e.premium,usedBytes:e.usedBytes,limitBytes:e.limitBytes,remainingBytes:e.remaining,bytesPerSecond:e.bytesPerSecond,bitsPerSecond:e.bytesPerSecond*8}},se=e.t({attachFrame:()=>Z,available:()=>$,dgram:()=>d.t,dns:()=>c.t,fetch:()=>a.t,fs:()=>l.t,http:()=>f.t,net:()=>u.t,quota:()=>Q}),$=()=>r.c;Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return oe}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return se}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return $}});
@@ -1,12 +1,16 @@
1
- import { t as cloudFetch } from "./proxy-XeHtHIdZ.js";
2
- import { i as Frame, r as AttachFrameOptions } from "./index-DIK21kfh.js";
1
+ import { r as AttachFrameFunction } from "./index-C_Lqta5o.js";
2
+ import { t as cloudFetch } from "./proxy-Bmb2wxG1.js";
3
3
  import { t as dns_d_exports } from "./dns.js";
4
- import { n as fs_d_exports } from "./fs-CYcErwc4.js";
5
- import { s as net_d_exports } from "./net-BBtYFEzu.js";
4
+ import { n as fs_d_exports } from "./fs--NhtUyYa.js";
5
+ import { s as net_d_exports } from "./net-0SlODFSM.js";
6
6
  import { t as dgram_d_exports } from "./dgram.js";
7
7
  import { t as http_d_exports } from "./http.js";
8
8
  //#region src/cloud/frame.d.ts
9
- declare const attachFrame: ({ iframe, domains, syncCookies, lockdown, permissions }: AttachFrameOptions) => Promise<Frame>;
9
+ /**
10
+ * Attaches the render proxy to an iframe the app mounted, or opens it in a window of its own with
11
+ * `{ window }`. A window opens before the first await, so call this directly in a click handler.
12
+ */
13
+ declare const attachFrame: AttachFrameFunction;
10
14
  //#endregion
11
15
  //#region src/quota.d.ts
12
16
  type QuotaStatus = {
package/cloud.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./proxy-_m6Sqcr6.cjs"),t=require("./cloud-DHuqVKrl.cjs"),n=require("./dns.cjs"),r=require("./cloud/fs.cjs"),i=require("./net.cjs"),a=require("./dgram.cjs"),o=require("./http.cjs");exports.attachFrame=t.i,exports.available=t.t,Object.defineProperty(exports,"dgram",{enumerable:!0,get:function(){return a.t}}),Object.defineProperty(exports,"dns",{enumerable:!0,get:function(){return n.t}}),exports.fetch=e.t,Object.defineProperty(exports,"fs",{enumerable:!0,get:function(){return r.t}}),Object.defineProperty(exports,"http",{enumerable:!0,get:function(){return o.t}}),Object.defineProperty(exports,"net",{enumerable:!0,get:function(){return i.t}}),exports.quota=t.r;
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./proxy-CYcaW5ew.cjs"),t=require("./cloud-DCWD_0sd.cjs"),n=require("./dns.cjs"),r=require("./cloud/fs.cjs"),i=require("./net.cjs"),a=require("./dgram.cjs"),o=require("./http.cjs");exports.attachFrame=t.i,exports.available=t.t,Object.defineProperty(exports,"dgram",{enumerable:!0,get:function(){return a.t}}),Object.defineProperty(exports,"dns",{enumerable:!0,get:function(){return n.t}}),exports.fetch=e.t,Object.defineProperty(exports,"fs",{enumerable:!0,get:function(){return r.t}}),Object.defineProperty(exports,"http",{enumerable:!0,get:function(){return o.t}}),Object.defineProperty(exports,"net",{enumerable:!0,get:function(){return i.t}}),exports.quota=t.r;
package/cloud.d.ts CHANGED
@@ -1,8 +1,8 @@
1
- import { t as cloudFetch } from "./proxy-XeHtHIdZ.js";
2
- import { a as attachFrame, i as quota, r as QuotaStatus, t as available } from "./cloud-C40YCPuv.js";
1
+ import { t as cloudFetch } from "./proxy-Bmb2wxG1.js";
2
+ import { a as attachFrame, i as quota, r as QuotaStatus, t as available } from "./cloud-DxitkM7z.js";
3
3
  import { t as dns_d_exports } from "./dns.js";
4
- import { n as fs_d_exports } from "./fs-CYcErwc4.js";
5
- import { s as net_d_exports } from "./net-BBtYFEzu.js";
4
+ import { n as fs_d_exports } from "./fs--NhtUyYa.js";
5
+ import { s as net_d_exports } from "./net-0SlODFSM.js";
6
6
  import { t as dgram_d_exports } from "./dgram.js";
7
7
  import { t as http_d_exports } from "./http.js";
8
8
  export { type QuotaStatus, attachFrame, available, dgram_d_exports as dgram, dns_d_exports as dns, cloudFetch as fetch, fs_d_exports as fs, http_d_exports as http, net_d_exports as net, quota };
package/cloud.js CHANGED
@@ -1,5 +1,5 @@
1
- import { t as e } from "./proxy-fXckOcRn.js";
2
- import { i as t, r as n, t as r } from "./cloud-DBNeXS9R.js";
1
+ import { t as e } from "./proxy-DDwY3AVG.js";
2
+ import { i as t, r as n, t as r } from "./cloud-B9Sd7V1g.js";
3
3
  import { t as i } from "./dns.js";
4
4
  import { t as a } from "./cloud/fs.js";
5
5
  import { t as o } from "./net.js";
@@ -1,3 +1,4 @@
1
+ import { B as SelectorPart, f as GotoOptions } from "./index-C_Lqta5o.js";
1
2
  import { o as TcpSocketOption, v as UdpSocketOption } from "./wire-Gbo-D74t.js";
2
3
  //#region src/contract.d.ts
3
4
  /** The signed-in account, or null when nobody is. */
@@ -87,6 +88,130 @@ type FrameConsentRequest = {
87
88
  };
88
89
  /** `'once'` is a critical row answered Allow once, a handoff the middle page takes; `'session'` a row standing for the tab; `false` a refusal. */
89
90
  type FrameConsentAnswer = 'once' | 'session' | false;
91
+ /** The osra key of an inline attachment's channel, which `/attach-frame` exposes to the library. */
92
+ declare const ATTACH_FRAME_KEY = "fkn-attach-frame";
93
+ /** The osra key of a window attachment's channel, which `/attach-window` exposes to its opener. */
94
+ declare const ATTACH_WINDOW_KEY = "fkn-attach-window";
95
+ /** The osra key of the render proxy shell's control channel, which its middle page drives. */
96
+ declare const SHELL_CONTROL_KEY = "sdbx-control";
97
+ /** Posted by a shell that could not start, `{ type, message }`, to the middle page framing it. */
98
+ declare const SHELL_ATTACH_ERROR = "sdbx-attach-error";
99
+ /** What an app and its window post to each other, every message carrying the attach id. */
100
+ declare const ATTACH_WINDOW_MESSAGE: {
101
+ /** app to window, repeated until the channel connects */
102
+ readonly hello: 'fkn-attach-window';
103
+ /** window to app, `{ reason }`: the window loaded nothing and exposes nothing */
104
+ readonly refused: 'fkn-attach-window-refused';
105
+ /** window to app: this window no longer answers the app, because it is going away or was dropped */
106
+ readonly gone: 'fkn-attach-window-gone';
107
+ /**
108
+ * app to window, whenever the app ends the attachment (its pagehide included): stop answering this
109
+ * app. `unanswered: true` when it ended because the window stopped answering its pings.
110
+ */
111
+ readonly detach: 'fkn-attach-window-detach';
112
+ };
113
+ /** What a window's shell and its middle page say about the shell's cookie jar, all with the attach id. */
114
+ declare const SHELL_JAR_MESSAGE: {
115
+ /** shell to middle page, once per shell document: send me the port to the opener's jar host */
116
+ readonly request: 'sdbx-jar-request';
117
+ /** middle page to shell, carrying exactly one port */
118
+ readonly port: 'sdbx-jar-port';
119
+ /** shell to middle page, `{ mode, reason? }`, before the first navigation */
120
+ readonly mode: 'sdbx-jar-mode';
121
+ };
122
+ /**
123
+ * Why a window's shell reached no jar, sent as the `reason` of an `'unreachable'` mode report. Only
124
+ * these names cross the wire, never a value or an error's own text.
125
+ */
126
+ declare const SHELL_JAR_UNREACHABLE: readonly ['bad-attach', 'no-storage', 'bad-jar', 'no-parent', 'no-jar-host', 'no-token', 'no-indexeddb', 'failed'];
127
+ type ShellJarUnreachable = (typeof SHELL_JAR_UNREACHABLE)[number];
128
+ /**
129
+ * What a window's middle page, the jar anchor its app mounted (`/attach-jar`) and the anchor's jar
130
+ * host say, all with the attach id.
131
+ */
132
+ declare const JAR_ANCHOR_MESSAGE: {
133
+ /** window to each frame of its opener: is the anchor for this attachment here? */
134
+ readonly hello: 'fkn-jar-hello';
135
+ /** anchor to the window it accepted */
136
+ readonly ready: 'fkn-jar-ready';
137
+ /** window to anchor, and anchor to jar host, carrying exactly one port */
138
+ readonly port: 'fkn-jar-port';
139
+ /** anchor to jar host, after every load of the host frame: are you the jar host? */
140
+ readonly who: 'fkn-jar-who';
141
+ /** jar host to anchor: the answer, the only one a port is relayed to */
142
+ readonly host: 'fkn-jar-host';
143
+ };
144
+ /**
145
+ * How long a window waits for its app's first hello, from when its page runs. The app says hello
146
+ * every 250 ms from the moment it opens the window, so only an app that went away misses it.
147
+ */
148
+ declare const WINDOW_HELLO_TIMEOUT_MS = 20000;
149
+ /**
150
+ * How long a window waits, from mounting its shell, for the shell to report the jar it runs on: the
151
+ * shell's jar port wait (12 s), its partition token read (5 s) and a controller boot. The window
152
+ * exposes its channel only after that report, so the app waits for both of these and more.
153
+ */
154
+ declare const WINDOW_JAR_MODE_TIMEOUT_MS = 30000;
155
+ /**
156
+ * How long an app waits for a window's channel. The window exposes it only once it has heard the
157
+ * app's hello and its shell has reported a jar, each on its own deadline above and one after the
158
+ * other, and says by name when it cannot; the margin covers the window's own page load and the
159
+ * channel's handshake after it. Any shorter and the app gives up on a window that is about to
160
+ * connect, or to say why it cannot.
161
+ */
162
+ declare const WINDOW_HANDSHAKE_TIMEOUT_MS: number;
163
+ /** A goto on the shell's control channel. */
164
+ type ShellGotoOptions = GotoOptions & {
165
+ timeoutMs?: number;
166
+ /**
167
+ * For an attachment's first navigation: past its deadline, a document that committed but never
168
+ * fired load counts as loaded, the rule the inline attachment's first load follows. Ignored by a
169
+ * shell deployed before windows, which rejects at the deadline instead.
170
+ */
171
+ commitFallback?: boolean;
172
+ };
173
+ /**
174
+ * The render proxy shell's control channel (`SHELL_CONTROL_KEY`), as its middle page drives it.
175
+ * `policy` is the middle page's realm policy for the call; `flushCookies` and `sweepStorage` are
176
+ * absent from a shell deployed before windows.
177
+ */
178
+ type ShellControl = {
179
+ ready(): Promise<boolean>;
180
+ /** Pulls the committed jar first, so a sign-in another realm committed rides this navigation. */
181
+ goto(url: string, options?: ShellGotoOptions): Promise<void>;
182
+ executeLocator(parts: SelectorPart[], operation: string, args: unknown[], policy?: unknown): Promise<unknown>;
183
+ /** Resolves once every cookie change made so far is committed to the jar's store. */
184
+ flushCookies?(): Promise<void>;
185
+ /** Removes a window shell's own site storage; resolves at once for a shell whose storage is shared. */
186
+ sweepStorage?(): Promise<void>;
187
+ };
188
+ /**
189
+ * What a middle page exposes to the library, inline (`ATTACH_FRAME_KEY`) and for a window
190
+ * (`ATTACH_WINDOW_KEY`). `documentHost`, where the frame actually is, is absent from a middle page
191
+ * deployed before categories.
192
+ */
193
+ type MiddleControl = {
194
+ ready(): Promise<boolean>;
195
+ goto(url: string, options?: GotoOptions & {
196
+ timeoutMs?: number;
197
+ }): Promise<void>;
198
+ executeLocator(parts: SelectorPart[], operation: string, args: unknown[]): Promise<unknown>;
199
+ documentHost?(): Promise<string>;
200
+ };
201
+ /** What a window's middle page adds to its channel. */
202
+ type WindowMiddleControl = MiddleControl & {
203
+ /** Draws the consent card in the window and answers each request in order. */
204
+ requestConsent(requests: FrameConsentRequest[]): Promise<FrameConsentAnswer[]>;
205
+ /** The app's heartbeat: a window that hears none for long enough stops answering. */
206
+ ping(): Promise<true>;
207
+ /** Resolves once every cookie change made in the window so far is committed to its jar. */
208
+ flushCookies(): Promise<void>;
209
+ /**
210
+ * Removes the proxied site storage this window kept to itself, for an app about to close it.
211
+ * Resolves at once for a window on the web origin's own jar, whose storage is the app's.
212
+ */
213
+ sweepStorage(): Promise<void>;
214
+ };
90
215
  type DisplayCause =
91
216
  /** the frame is not being painted at all, so an ancestor is display:none, visibility:hidden or equivalent */
92
217
  'not-rendered' |
@@ -619,4 +744,4 @@ type Resolvers = {
619
744
  hideInstallPrompt: () => void;
620
745
  };
621
746
  //#endregion
622
- export { StorageQuota as $, ProxyFetch as A, RoomEvent as B, OverlayState as C, PackagesFail as D, PackagesErrorCode as E, Resolvers as F, RoomMessage as G, RoomJoinOptions as H, RoomBacklog as I, RoomPermissions as J, RoomOpenOptions as K, RoomCreateOptions as L, ProxyFetchInput as M, Quota as N, PickOptions as O, Radii as P, StorageEntry as Q, RoomDefaults as R, OverlayRect as S, PackageResult as T, RoomMailbox as U, RoomHandle as V, RoomMember as W, RoomsFail as X, RoomsErrorCode as Y, SetOverlayHost as Z, HiddenSurface as _, ConflictChoice as a, UdpDatagram as at, IpFamily as b, ConnectAvailability as c, WriteData as ct, DisplayLevel as d, SurfaceRect as et, DnsLookup as f, FrameFetchScope as g, FrameConsentRequest as h, AdoptState as i, TcpSocketResult as it, ProxyFetchInit as j, Placement as k, ConnectOptions as l, FrameConsentAnswer as m, AddressLookupResult as n, TcpSocketListenerResult as nt, ConflictRequest as o, UdpSocketOptions as ot, EncryptionState as p, RoomPermission as q, AdoptRequest as r, TcpSocketOptions as rt, ConflictSide as s, UdpSocketResult as st, Account as t, TcpSocketListenerOptions as tt, DisplayCause as u, InstallOptions as v, PackageQuery as w, MountDescriptor as x, InstalledPackage as y, RoomEnd as z };
747
+ export { RoomPermissions as $, PackageResult as A, Resolvers as B, IpFamily as C, WindowMiddleControl as Ct, OverlayRect as D, MountDescriptor as E, ProxyFetch as F, RoomEvent as G, RoomCreateOptions as H, ProxyFetchInit as I, RoomMailbox as J, RoomHandle as K, ProxyFetchInput as L, PackagesFail as M, PickOptions as N, OverlayState as O, Placement as P, RoomPermission as Q, Quota as R, InstalledPackage as S, WINDOW_JAR_MODE_TIMEOUT_MS as St, MiddleControl as T, RoomDefaults as U, RoomBacklog as V, RoomEnd as W, RoomMessage as X, RoomMember as Y, RoomOpenOptions as Z, FrameConsentAnswer as _, UdpDatagram as _t, AddressLookupResult as a, SHELL_JAR_UNREACHABLE as at, HiddenSurface as b, WINDOW_HANDSHAKE_TIMEOUT_MS as bt, ConflictChoice as c, ShellGotoOptions as ct, ConnectAvailability as d, StorageQuota as dt, RoomsErrorCode as et, ConnectOptions as f, SurfaceRect as ft, EncryptionState as g, TcpSocketResult as gt, DnsLookup as h, TcpSocketOptions as ht, Account as i, SHELL_JAR_MESSAGE as it, PackagesErrorCode as j, PackageQuery as k, ConflictRequest as l, ShellJarUnreachable as lt, DisplayLevel as m, TcpSocketListenerResult as mt, ATTACH_WINDOW_KEY as n, SHELL_ATTACH_ERROR as nt, AdoptRequest as o, SetOverlayHost as ot, DisplayCause as p, TcpSocketListenerOptions as pt, RoomJoinOptions as q, ATTACH_WINDOW_MESSAGE as r, SHELL_CONTROL_KEY as rt, AdoptState as s, ShellControl as st, ATTACH_FRAME_KEY as t, RoomsFail as tt, ConflictSide as u, StorageEntry as ut, FrameConsentRequest as v, UdpSocketOptions as vt, JAR_ANCHOR_MESSAGE as w, WriteData as wt, InstallOptions as x, WINDOW_HELLO_TIMEOUT_MS as xt, FrameFetchScope as y, UdpSocketResult as yt, Radii as z };
package/contract.cjs CHANGED
@@ -0,0 +1 @@
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var e=`fkn-attach-frame`,t=`fkn-attach-window`,n=`sdbx-control`,r=`sdbx-attach-error`,i={hello:`fkn-attach-window`,refused:`fkn-attach-window-refused`,gone:`fkn-attach-window-gone`,detach:`fkn-attach-window-detach`},a={request:`sdbx-jar-request`,port:`sdbx-jar-port`,mode:`sdbx-jar-mode`},o=[`bad-attach`,`no-storage`,`bad-jar`,`no-parent`,`no-jar-host`,`no-token`,`no-indexeddb`,`failed`],s={hello:`fkn-jar-hello`,ready:`fkn-jar-ready`,port:`fkn-jar-port`,who:`fkn-jar-who`,host:`fkn-jar-host`},c=2e4,l=3e4,u=6e4;exports.ATTACH_FRAME_KEY=e,exports.ATTACH_WINDOW_KEY=t,exports.ATTACH_WINDOW_MESSAGE=i,exports.JAR_ANCHOR_MESSAGE=s,exports.SHELL_ATTACH_ERROR=r,exports.SHELL_CONTROL_KEY=n,exports.SHELL_JAR_MESSAGE=a,exports.SHELL_JAR_UNREACHABLE=o,exports.WINDOW_HANDSHAKE_TIMEOUT_MS=u,exports.WINDOW_HELLO_TIMEOUT_MS=c,exports.WINDOW_JAR_MODE_TIMEOUT_MS=l;