@fkn/lib 0.9.38 → 0.9.39

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 (69) hide show
  1. package/account.cjs +1 -1
  2. package/account.js +1 -1
  3. package/{api-DF4nHz2Q.d.ts → api-BxXnHxbd.d.ts} +7 -1
  4. package/{api-CtiKFcK3.js → api-Dp-2AT3u.js} +84 -77
  5. package/api-jOTOA-5n.cjs +3 -0
  6. package/api.cjs +1 -1
  7. package/api.d.ts +2 -2
  8. package/api.js +1 -1
  9. package/cloud/dns.d.ts +1 -1
  10. package/cloud/fetch.cjs +1 -1
  11. package/cloud/fetch.d.ts +1 -1
  12. package/cloud/fetch.js +1 -1
  13. package/cloud/fs.cjs +1 -1
  14. package/cloud/fs.js +1 -1
  15. package/cloud/net.d.ts +1 -1
  16. package/{cloud-Bfc6rkF2.d.ts → cloud-B8QYSmW3.d.ts} +3 -3
  17. package/cloud-BZIJFvPF.cjs +1 -0
  18. package/{cloud-EfyYfgVT.js → cloud-oMACx7NL.js} +75 -75
  19. package/cloud.cjs +1 -1
  20. package/cloud.d.ts +3 -3
  21. package/cloud.js +2 -2
  22. package/{contract-InuLU8bI.d.ts → contract-sDmsw-9f.d.ts} +44 -2
  23. package/contract.cjs +1 -1
  24. package/contract.d.ts +2 -2
  25. package/contract.js +6 -2
  26. package/dgram.cjs +1 -1
  27. package/dgram.d.ts +2 -2
  28. package/dgram.js +1 -1
  29. package/dns.cjs +1 -1
  30. package/dns.d.ts +1 -1
  31. package/dns.js +1 -1
  32. package/{extension-B7jDaJVp.cjs → extension-Bl5ZNj0d.cjs} +1 -1
  33. package/{extension-sNRjVbET.js → extension-ChZyZgAL.js} +3 -3
  34. package/{extension-Bm5x5R4R.d.ts → extension-DMU-CwMw.d.ts} +1 -1
  35. package/extension.cjs +1 -1
  36. package/extension.d.ts +2 -2
  37. package/extension.js +2 -2
  38. package/fs/promises.cjs +1 -1
  39. package/fs/promises.js +1 -1
  40. package/{fs-D8RCGFNc.cjs → fs-CaQFRiIT.cjs} +1 -1
  41. package/{fs-BvNZePtN.js → fs-D3IsGdnN.js} +1 -1
  42. package/fs.cjs +1 -1
  43. package/fs.js +1 -1
  44. package/http.d.ts +1 -1
  45. package/{index-DiOxvYoa.d.ts → index-D2CA-NX5.d.ts} +6 -0
  46. package/index.cjs +1 -1
  47. package/index.d.ts +4 -4
  48. package/index.js +5 -5
  49. package/{lib-FD1Ssqjt.js → lib-BlyFPeSv.js} +16 -11
  50. package/lib-tQKlXzhv.cjs +53 -0
  51. package/{net-DnXxFGm8.d.ts → net-Qmt9L_7t.d.ts} +2 -2
  52. package/net.cjs +1 -1
  53. package/net.d.ts +1 -1
  54. package/net.js +1 -1
  55. package/package.json +1 -1
  56. package/packages.cjs +1 -1
  57. package/packages.d.ts +1 -1
  58. package/packages.js +1 -1
  59. package/{proxy-BkaVTZAf.d.ts → proxy-CxRQLGNG.d.ts} +2 -2
  60. package/{proxy-DDwY3AVG.js → proxy-DMTdQ4dN.js} +1 -1
  61. package/{proxy-CYcaW5ew.cjs → proxy-DjoPtJH9.cjs} +1 -1
  62. package/rooms.cjs +1 -1
  63. package/rooms.d.ts +16 -3
  64. package/rooms.js +111 -97
  65. package/{storage-dSi2dUKx.cjs → storage-BJd-mWHE.cjs} +1 -1
  66. package/{storage-BbcnDCnc.js → storage-DSvL-t80.js} +1 -1
  67. package/api-Djf-XdZ4.cjs +0 -3
  68. package/cloud-Beg4iCRU.cjs +0 -1
  69. package/lib-DYKLnpWs.cjs +0 -53
@@ -1,20 +1,20 @@
1
1
  import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
2
- import { C as t, E as n, S as r, T as i, b as a, c as o, d as s, f as c, g as l, l as u, m as d, nt as f, o as p, s as m, u as h } from "./lib-FD1Ssqjt.js";
2
+ import { C as t, E as n, S as r, T as i, b as a, c as o, d as s, f as c, g as l, l as u, m as d, nt as f, o as p, s as m, u as h } from "./lib-BlyFPeSv.js";
3
3
  import { c as g, m as _, t as v } from "./hosts-BzbzOhG8.js";
4
- import { a as y, c as b, n as x, o as S } from "./api-CtiKFcK3.js";
5
- import { t as C } from "./busy-B189uX--.js";
6
- import { t as w } from "./proxy-DDwY3AVG.js";
7
- import { frameFetchVerdict as T } from "./attach-policy.js";
8
- import { ATTACH_FRAME_KEY as E, ATTACH_WINDOW_KEY as ee, ATTACH_WINDOW_MESSAGE as D, WINDOW_HANDSHAKE_TIMEOUT_MS as te } from "./contract.js";
9
- import { t as O } from "./dns.js";
10
- import { t as k } from "./cloud/fs.js";
11
- import { t as A } from "./net.js";
12
- import { t as j } from "./dgram.js";
13
- import { t as M } from "./http.js";
14
- import { expose as N } from "osra";
4
+ import { a as y, c as b, f as x, n as S, o as C } from "./api-Dp-2AT3u.js";
5
+ import { t as w } from "./busy-B189uX--.js";
6
+ import { t as T } from "./proxy-DMTdQ4dN.js";
7
+ import { frameFetchVerdict as E } from "./attach-policy.js";
8
+ import { ATTACH_FRAME_KEY as D, ATTACH_WINDOW_KEY as ee, ATTACH_WINDOW_MESSAGE as O, WINDOW_HANDSHAKE_TIMEOUT_MS as te } from "./contract.js";
9
+ import { t as k } from "./dns.js";
10
+ import { t as A } from "./cloud/fs.js";
11
+ import { t as j } from "./net.js";
12
+ import { t as M } from "./dgram.js";
13
+ import { t as N } from "./http.js";
14
+ import { expose as P } from "osra";
15
15
  //#region src/cloud/frame-broker.ts
16
- var P = async () => {
17
- let e = () => S("frame consent");
16
+ var ne = async () => {
17
+ let e = () => C("frame consent");
18
18
  try {
19
19
  let t = await e();
20
20
  return {
@@ -22,28 +22,28 @@ var P = async () => {
22
22
  ensure: t.frameConsent.ensure
23
23
  };
24
24
  } catch (t) {
25
- if (!(t instanceof x)) throw t;
25
+ if (!(t instanceof S)) 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, ne = () => r(`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, re = () => {
31
+ }, F = 3e4, re = () => r(`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, ie = () => {
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
- }, ie = (e) => [...e].flatMap((e) => {
33
+ }, ae = (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}`, ae = (e) => {
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}`, oe = (e) => {
40
40
  let { assertLive: n, attach: r, current: i, declaredHosts: a, documentHost: s, ensure: c, request: l, session: d, approvedOrigins: f } = e, p = /* @__PURE__ */ new Set(), m = async () => s ? await s() : (() => {
41
41
  try {
42
42
  return new URL(i()).hostname;
43
43
  } catch {
44
44
  return "";
45
45
  }
46
- })(), y = () => v([...a, ...ie(f)]), b = async (e) => (await l([e]))[0] ?? !1;
46
+ })(), y = () => v([...a, ...ae(f)]), b = async (e) => (await l([e]))[0] ?? !1;
47
47
  return {
48
48
  gate: async ({ operation: e, args: i, phase: o }) => {
49
49
  n();
@@ -52,7 +52,7 @@ var P = async () => {
52
52
  let x = h(s);
53
53
  if (x === void 0 || x === "auto") return;
54
54
  if (e === "fetch") {
55
- let e = T({
55
+ let e = E({
56
56
  session: d,
57
57
  declaredHosts: a,
58
58
  approvedOrigins: f
@@ -81,7 +81,7 @@ var P = async () => {
81
81
  if (!l) return;
82
82
  let C = u(s);
83
83
  if (C === void 0 || x === "critical" && p.has(`${s} ${S}`)) return;
84
- let w = v([S, ...a]), E = await b(x === "critical" ? {
84
+ let w = v([S, ...a]), T = await b(x === "critical" ? {
85
85
  key: s,
86
86
  hosts: w,
87
87
  attach: r
@@ -89,8 +89,8 @@ var P = async () => {
89
89
  category: C,
90
90
  hosts: w
91
91
  });
92
- if (E === !1) throw t(R(e, C, null), e);
93
- if (E === "once" && o !== "ensure") for (let e of w) p.add(`${s} ${e}`);
92
+ if (T === !1) throw t(R(e, C, null), e);
93
+ if (T === "once" && o !== "ensure") for (let e of w) p.add(`${s} ${e}`);
94
94
  },
95
95
  requestCategories: async (e) => {
96
96
  n();
@@ -109,7 +109,7 @@ var P = async () => {
109
109
  hosts: i,
110
110
  allow: r
111
111
  });
112
- if (!l) return re(), s.map((e) => c(e, !1));
112
+ if (!l) return ie(), s.map((e) => c(e, !1));
113
113
  let u = await l(s.map(({ named: e, critical: t, category: n }) => t ? {
114
114
  key: e,
115
115
  hosts: i,
@@ -122,12 +122,12 @@ var P = async () => {
122
122
  },
123
123
  boundary: y
124
124
  };
125
- }, z = (e) => e, oe = 5e3, se = /* @__PURE__ */ new Set([]), B = () => "https://fkn.app", V = (e) => e ? "" : `incognito-${crypto.randomUUID()}`, H = (e, t, n) => {
125
+ }, z = (e) => e, se = 5e3, ce = /* @__PURE__ */ new Set([]), B = () => "https://fkn.app", V = (e) => e ? "" : `incognito-${crypto.randomUUID()}`, H = (e, t, n) => {
126
126
  let r, i = new Promise((e, i) => {
127
127
  r = setTimeout(() => i(typeof n == "string" ? Error(n) : n()), t);
128
128
  });
129
129
  return Promise.race([e, i]).finally(() => clearTimeout(r));
130
- }, U = (e) => Object.assign(Error(e), { name: a }), ce = "frame.postMessage: this FKN page predates frame messaging; reload the app to load the current one", W = !1, le = () => {
130
+ }, U = (e) => Object.assign(Error(e), { name: a }), le = "frame.postMessage: this FKN page predates frame messaging; reload the app to load the current one", W = !1, ue = () => {
131
131
  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
132
  }, G = ({ from: e, origin: t, attach: n, signal: r }) => (i) => {
133
133
  let a = (r) => {
@@ -145,7 +145,7 @@ var P = async () => {
145
145
  };
146
146
  return window.addEventListener("message", a, { signal: r }), () => window.removeEventListener("message", a);
147
147
  }, K = ({ control: e, target: r, session: a, declaredHosts: o, approvedOrigins: s, attach: c, assertLive: l, guard: u, consent: f, onNavigated: p, relay: m }) => {
148
- let h = r, g = Promise.resolve(), { gate: _, requestCategories: v, boundary: y } = ae({
148
+ let h = r, g = Promise.resolve(), { gate: _, requestCategories: v, boundary: y } = oe({
149
149
  session: a,
150
150
  declaredHosts: o,
151
151
  approvedOrigins: s,
@@ -157,7 +157,7 @@ var P = async () => {
157
157
  });
158
158
  return d({
159
159
  executor: {
160
- execute: (t, n, r) => se.has(n) ? Promise.reject(i(n, "cloud")) : (l(), u(() => e.executeLocator(t, n, r))),
160
+ execute: (t, n, r) => ce.has(n) ? Promise.reject(i(n, "cloud")) : (l(), u(() => e.executeLocator(t, n, r))),
161
161
  highlight: async () => {}
162
162
  },
163
163
  gate: _,
@@ -167,9 +167,9 @@ var P = async () => {
167
167
  operation: "evaluate",
168
168
  args: [t, n],
169
169
  phase: "execute"
170
- }), H(u(() => e.executeLocator([], "evaluate", [t, n])), F, ne)),
170
+ }), H(u(() => e.executeLocator([], "evaluate", [t, n])), F, re)),
171
171
  postMessage: (r, i, a) => {
172
- if (l(), typeof e.messaging != "function") throw n(ce, "postMessage", "cloud");
172
+ if (l(), typeof e.messaging != "function") throw n(le, "postMessage", "cloud");
173
173
  if (i !== "*" && !y().includes(new URL(i).hostname)) throw t(I, "postMessage");
174
174
  let { port1: o, port2: s } = new MessageChannel();
175
175
  o.postMessage({
@@ -186,7 +186,7 @@ var P = async () => {
186
186
  await e;
187
187
  });
188
188
  },
189
- listen: (t) => (typeof e.messaging != "function" && le(), m(t)),
189
+ listen: (t) => (typeof e.messaging != "function" && ue(), m(t)),
190
190
  goto: async (t, n = {}) => {
191
191
  let r = new URL(t, location.href).href;
192
192
  l();
@@ -199,7 +199,7 @@ var P = async () => {
199
199
  })(), o = a !== "" && !s.has(a);
200
200
  o && s.add(a);
201
201
  try {
202
- await H(u(() => e.goto(r, n)), (i ?? 3e4) + oe, "cloud.attachFrame: the render proxy did not answer goto; the frame may have been detached or its page reloaded");
202
+ await H(u(() => e.goto(r, n)), (i ?? 3e4) + se, "cloud.attachFrame: the render proxy did not answer goto; the frame may have been detached or its page reloaded");
203
203
  } catch (e) {
204
204
  throw o && s.delete(a), e;
205
205
  }
@@ -207,24 +207,24 @@ var P = async () => {
207
207
  },
208
208
  url: () => h
209
209
  });
210
- }, ue = 250, de = 500, fe = 65e3, pe = 2e3, q = 2e3, me = 2, he = 2e3, ge = 2e3, _e = ({ origin: e, target: t, session: n, domains: r, attach: i }) => {
210
+ }, de = 250, fe = 500, pe = 65e3, q = 2e3, me = 2e3, he = 2, ge = 2e3, _e = 2e3, ve = ({ origin: e, target: t, session: n, domains: r, attach: i }) => {
211
211
  let a = new URL("/attach-window", e);
212
212
  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
- }, ve = (e, t) => {
213
+ }, ye = (e, t) => {
214
214
  let n = document.createElement("iframe"), r = new URL("/attach-jar", e);
215
215
  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
- }, ye = (e, t) => {
216
+ }, be = (e, t) => {
217
217
  let n = new MutationObserver(() => {
218
218
  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
219
  });
220
220
  e.parentNode && n.observe(e.parentNode, { childList: !0 }), n.observe(document.documentElement, { childList: !0 }), t.addEventListener("abort", () => n.disconnect(), { once: !0 });
221
- }, J = () => U("cloud.attachFrame: the attached window closed, reloaded or left the page FKN attached; attach a fresh window"), Y = () => U("cloud.attachFrame: the attached window stopped answering; attach a fresh window"), be = () => U("cloud.attachFrame: the window went away before it connected; attach a fresh window"), xe = () => 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"), Se = async (e) => {
221
+ }, J = () => U("cloud.attachFrame: the attached window closed, reloaded or left the page FKN attached; attach a fresh window"), Y = () => U("cloud.attachFrame: the attached window stopped answering; attach a fresh window"), xe = () => U("cloud.attachFrame: the window went away before it connected; attach a fresh window"), Se = () => 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"), Ce = async (e) => {
222
222
  if (typeof window > "u") throw Error("cloud.attachFrame needs a window realm");
223
223
  let { domains: t = [], syncCookies: n = !0, permissions: r } = e, { url: i, width: a, height: o } = m(e.window);
224
224
  if (window.origin === "null") throw new c("opaque-opener");
225
225
  let l = B(), u = crypto.randomUUID(), d = V(n), p = v(t), h = /* @__PURE__ */ new Set();
226
226
  i && h.add(new URL(i).origin);
227
- let g = n ? ve(l, u) : null, _ = window.open(_e({
227
+ let g = n ? ye(l, u) : null, _ = window.open(ve({
228
228
  origin: l,
229
229
  target: i,
230
230
  session: d,
@@ -237,51 +237,51 @@ var P = async () => {
237
237
  x = e, y.abort(t ? Y() : J());
238
238
  try {
239
239
  _.closed || _.postMessage({
240
- type: D.detach,
240
+ type: O.detach,
241
241
  attach: u,
242
242
  ...t ? { unanswered: t } : {}
243
243
  }, l);
244
244
  } catch {}
245
- g && setTimeout(() => g.remove(), ge);
245
+ g && setTimeout(() => g.remove(), _e);
246
246
  }
247
247
  };
248
- g && ye(g, y.signal);
249
- let w = new Promise((e, t) => {
248
+ g && be(g, y.signal);
249
+ let C = new Promise((e, t) => {
250
250
  y.signal.addEventListener("abort", () => t(y.signal.reason), { once: !0 });
251
251
  });
252
- w.catch(() => {});
253
- let T = w.then(() => {}, () => {}), E = () => {
252
+ C.catch(() => {});
253
+ let T = C.then(() => {}, () => {}), E = () => {
254
254
  if (y.signal.aborted) throw y.signal.reason;
255
- }, O = (e) => y.signal.aborted ? Promise.reject(y.signal.reason) : Promise.race([e(), w]), k = (e) => e.source === _ && e.origin === l;
255
+ }, D = (e) => y.signal.aborted ? Promise.reject(y.signal.reason) : Promise.race([e(), C]), k = (e) => e.source === _ && e.origin === l;
256
256
  window.addEventListener("message", (e) => {
257
257
  if (!k(e)) return;
258
258
  let t = e.data;
259
- typeof t == "object" && t && t.attach === u && (t.type === D.refused ? S(new c(t.reason)) : t.type === D.gone && S(b ? J() : be()));
259
+ typeof t == "object" && t && t.attach === u && (t.type === O.refused ? S(new c(t.reason)) : t.type === O.gone && S(b ? J() : xe()));
260
260
  }, { signal: y.signal }), window.addEventListener("pagehide", () => S(J()), { signal: y.signal });
261
261
  let A = () => {
262
262
  try {
263
263
  _.postMessage({
264
- type: D.hello,
264
+ type: O.hello,
265
265
  attach: u
266
266
  }, l);
267
267
  } catch {}
268
268
  };
269
269
  A();
270
- let j = setInterval(A, ue), M = setInterval(() => {
271
- _.closed && S(b ? J() : xe());
272
- }, de);
270
+ let j = setInterval(A, de), M = setInterval(() => {
271
+ _.closed && S(b ? J() : Se());
272
+ }, fe);
273
273
  y.signal.addEventListener("abort", () => {
274
274
  clearInterval(j), clearInterval(M);
275
275
  }, { once: !0 });
276
- let P = async (e) => {
276
+ let N = async (e) => {
277
277
  try {
278
- return await Promise.race([e, w]);
278
+ return await Promise.race([e, C]);
279
279
  } catch (e) {
280
280
  throw x ?? e;
281
281
  }
282
282
  };
283
283
  try {
284
- let e = await P(H(N({}, {
284
+ let e = await N(H(P({}, {
285
285
  key: ee,
286
286
  transport: {
287
287
  emit: (e, t) => _.postMessage(e, l, t ?? []),
@@ -300,14 +300,14 @@ var P = async () => {
300
300
  }), te, "cloud.attachFrame: timed out connecting to the window"));
301
301
  b = !0, clearInterval(j);
302
302
  let t = 0, n = setInterval(() => {
303
- H(O(() => e.ping()), q, "ping").then(() => {
303
+ H(D(() => e.ping()), me, "ping").then(() => {
304
304
  t = 0;
305
305
  }, () => {
306
- y.signal.aborted || (document.visibilityState === "hidden" ? t = 0 : ++t >= me && S(Y(), !0));
306
+ y.signal.aborted || (document.visibilityState === "hidden" ? t = 0 : ++t >= he && S(Y(), !0));
307
307
  });
308
- }, pe);
309
- y.signal.addEventListener("abort", () => clearInterval(n), { once: !0 }), await P(H(e.ready(), fe, "cloud.attachFrame: the window never became ready"));
310
- let a = C("attached frame");
308
+ }, q);
309
+ y.signal.addEventListener("abort", () => clearInterval(n), { once: !0 }), await N(H(e.ready(), pe, "cloud.attachFrame: the window never became ready"));
310
+ let a = w("attached frame");
311
311
  y.signal.aborted ? a() : y.signal.addEventListener("abort", a, { once: !0 });
312
312
  let o = K({
313
313
  control: e,
@@ -317,10 +317,10 @@ var P = async () => {
317
317
  approvedOrigins: h,
318
318
  attach: u,
319
319
  assertLive: E,
320
- guard: O,
320
+ guard: D,
321
321
  consent: {
322
- request: (t) => O(() => e.requestConsent(t)),
323
- ensure: (t) => O(() => e.requestConsent([t])).then(([e]) => e !== void 0 && e !== !1)
322
+ request: (t) => D(() => e.requestConsent(t)),
323
+ ensure: (t) => D(() => e.requestConsent([t])).then(([e]) => e !== void 0 && e !== !1)
324
324
  },
325
325
  onNavigated: () => {},
326
326
  relay: G({
@@ -331,7 +331,7 @@ var P = async () => {
331
331
  })
332
332
  }), s = null, c = Object.assign(o, {
333
333
  close: () => s ??= (async () => {
334
- y.signal.aborted || await H(Promise.allSettled([O(() => e.flushCookies()), O(() => e.sweepStorage())]), he, "close").catch(() => {});
334
+ y.signal.aborted || await H(Promise.allSettled([D(() => e.flushCookies()), D(() => e.sweepStorage())]), ge, "close").catch(() => {});
335
335
  try {
336
336
  _.close();
337
337
  } catch {}
@@ -339,7 +339,7 @@ var P = async () => {
339
339
  })(),
340
340
  closed: T
341
341
  });
342
- return r?.length && await P(c.request(r)), c;
342
+ return r?.length && await N(c.request(r)), c;
343
343
  } catch (e) {
344
344
  let t = x ?? e;
345
345
  if (!(t instanceof c)) try {
@@ -347,7 +347,7 @@ var P = async () => {
347
347
  } catch {}
348
348
  throw S(t), t;
349
349
  }
350
- }, Ce = "autoplay; fullscreen; encrypted-media; picture-in-picture; clipboard-read; clipboard-write", we = 2e4, Te = 65e3, Ee = (e) => !e || e === "about:blank", De = ({ target: e, session: t, domains: n, attach: r }) => {
350
+ }, we = 2e4, Te = 65e3, Ee = (e) => !e || e === "about:blank", De = ({ target: e, session: t, domains: n, attach: r }) => {
351
351
  let i = new URL("/attach-frame", B());
352
352
  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
353
  }, Oe = (e, t) => {
@@ -405,15 +405,15 @@ var P = async () => {
405
405
  d.add(new URL(s).origin);
406
406
  } catch {}
407
407
  let p = new AbortController(), m = e.referrerPolicy, h = e.allow, g = crypto.randomUUID();
408
- if (e.referrerPolicy = "origin", e.allow = Ae(Ce, e.allow), e.src = De({
408
+ if (e.referrerPolicy = "origin", e.allow = Ae(x(), e.allow), e.src = De({
409
409
  target: s,
410
410
  session: c,
411
411
  domains: u,
412
412
  attach: g
413
413
  }), !e.contentWindow) throw Error("cloud.attachFrame: the iframe window is not available");
414
414
  try {
415
- let t = await H(N({}, {
416
- key: E,
415
+ let t = await H(P({}, {
416
+ key: D,
417
417
  origin: B(),
418
418
  transport: {
419
419
  receive: window,
@@ -423,7 +423,7 @@ var P = async () => {
423
423
  revivableModules: z(f)
424
424
  }), we, "cloud.attachFrame: timed out connecting to the render proxy page");
425
425
  await H(t.ready(), Te, "cloud.attachFrame: the render proxy never became ready"), s && X(e), Oe(e, () => p.abort());
426
- let n = C("attached frame");
426
+ let n = w("attached frame");
427
427
  p.signal.aborted ? n() : p.signal.addEventListener("abort", n, { once: !0 });
428
428
  let r = e.contentWindow, a = K({
429
429
  control: t,
@@ -436,7 +436,7 @@ var P = async () => {
436
436
  if (p.signal.aborted || !e.isConnected || e.contentWindow !== r) throw p.abort(), ke();
437
437
  },
438
438
  guard: (e) => e(),
439
- consent: await P(),
439
+ consent: await ne(),
440
440
  onNavigated: () => X(e),
441
441
  relay: G({
442
442
  from: () => r,
@@ -449,7 +449,7 @@ var P = async () => {
449
449
  } catch (t) {
450
450
  throw p.abort(), e.referrerPolicy = m, e.allow = h, e.src = s || "about:blank", t;
451
451
  }
452
- }, Z = (async (e) => p(e) === "window" ? Se(e) : Ne(e)), Pe = () => typeof window < "u" && !0, Q = async () => {
452
+ }, Z = (async (e) => p(e) === "window" ? Ce(e) : Ne(e)), Pe = () => typeof window < "u" && !0, Q = async () => {
453
453
  let e = await y.then((e) => e.cloud.quota());
454
454
  return {
455
455
  premium: e.premium,
@@ -464,12 +464,12 @@ var P = async () => {
464
464
  }, Fe = /* @__PURE__ */ e({
465
465
  attachFrame: () => Z,
466
466
  available: () => $,
467
- dgram: () => j,
468
- dns: () => O,
469
- fetch: () => w,
470
- fs: () => k,
471
- http: () => M,
472
- net: () => A,
467
+ dgram: () => M,
468
+ dns: () => k,
469
+ fetch: () => T,
470
+ fs: () => A,
471
+ http: () => N,
472
+ net: () => j,
473
473
  quota: () => Q
474
474
  }), $ = () => b;
475
475
  //#endregion
package/cloud.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./proxy-CYcaW5ew.cjs"),t=require("./cloud-Beg4iCRU.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-DjoPtJH9.cjs"),t=require("./cloud-BZIJFvPF.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-BkaVTZAf.js";
2
- import { a as attachFrame, i as quota, r as QuotaStatus, t as available } from "./cloud-Bfc6rkF2.js";
1
+ import { t as cloudFetch } from "./proxy-CxRQLGNG.js";
2
+ import { a as attachFrame, i as quota, r as QuotaStatus, t as available } from "./cloud-B8QYSmW3.js";
3
3
  import { t as dns_d_exports } from "./dns.js";
4
4
  import { n as fs_d_exports } from "./fs--NhtUyYa.js";
5
- import { s as net_d_exports } from "./net-DnXxFGm8.js";
5
+ import { s as net_d_exports } from "./net-Qmt9L_7t.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-DDwY3AVG.js";
2
- import { i as t, r as n, t as r } from "./cloud-EfyYfgVT.js";
1
+ import { t as e } from "./proxy-DMTdQ4dN.js";
2
+ import { i as t, r as n, t as r } from "./cloud-oMACx7NL.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,4 +1,4 @@
1
- import { K as SelectorPart, v as GotoOptions } from "./index-DiOxvYoa.js";
1
+ import { K as SelectorPart, v as GotoOptions } from "./index-D2CA-NX5.js";
2
2
  import { o as TcpSocketOption, v as UdpSocketOption } from "./wire-Gbo-D74t.js";
3
3
  //#region src/contract.d.ts
4
4
  /** The signed-in account, or null when nobody is. */
@@ -479,6 +479,15 @@ type RoomCreateOptions = RoomOpenOptions;
479
479
  type RoomJoinOptions = {
480
480
  signal?: AbortSignal;
481
481
  };
482
+ /**
483
+ * How long a temporary claim may last, in milliseconds: `default` is what `temporary: true` means (7
484
+ * days), and a number outside `min` (1 minute) to `max` (365 days) is refused `invalid`.
485
+ */
486
+ declare const ROOM_TEMPORARY_MS: {
487
+ readonly default: 604800000;
488
+ readonly min: 60000;
489
+ readonly max: 31536000000;
490
+ };
482
491
  /** What a claim carries besides the name. */
483
492
  type RoomClaimOptions = {
484
493
  /**
@@ -490,6 +499,26 @@ type RoomClaimOptions = {
490
499
  * that claimed the room only (the same app once it is verified); claiming without one keeps it.
491
500
  */
492
501
  description?: string;
502
+ /**
503
+ * Makes the claim end by itself, in milliseconds: `true` is 7 days (`ROOM_TEMPORARY_MS.default`), a
504
+ * number is that many milliseconds, a whole number from 60,000 (1 minute) to 31,536,000,000 (365 days),
505
+ * and anything else is refused `invalid`. `false` or no value makes the claim permanent.
506
+ *
507
+ * The clock restarts on every claim, so a temporary room ends that long after its LAST claim: a room
508
+ * the app keeps claiming on open stays, and an abandoned one goes. Restarting the clock needs the
509
+ * service: while it cannot be reached, a claim answers `unavailable` and the room keeps the end it had,
510
+ * so a room in use can still end if an outage outlasts the time it has left. Pick a duration with margin
511
+ * over how often the app is opened. When it ends, it ends exactly as an
512
+ * Unclaim from the account's fkn.app settings does: the name is given back, the stored messages are
513
+ * deleted, and whoever is present hears a `claim` event with `claimed: false` and stays in an ordinary
514
+ * room. It counts toward the account's room limit while it lasts and frees the slot when it ends.
515
+ *
516
+ * The latest claim decides: claiming again without it makes the room permanent, and with it makes it
517
+ * temporary again. Only the app that claimed the room (the same app once it is verified) sets or
518
+ * changes it; from another app it is refused `denied`, and a claim from another app without it leaves
519
+ * the room as it was.
520
+ */
521
+ temporary?: boolean | number;
493
522
  };
494
523
  /** What a backlog page answered: the highest seq it sent, and whether another page follows. */
495
524
  type RoomBacklog = {
@@ -515,6 +544,12 @@ type RoomHandle = {
515
544
  owner: string;
516
545
  claimed: boolean;
517
546
  mailbox: RoomMailbox | null;
547
+ /**
548
+ * set by a broker that carries `temporary` on a claim. A broker older than that drops the option and
549
+ * makes the claim permanent, so the lib refuses a temporary claim on a handle without it rather than
550
+ * let the room outlive what the app asked for.
551
+ */
552
+ temporaryClaims?: true;
518
553
  defaults: () => Promise<RoomDefaults>;
519
554
  members: () => Promise<RoomMember[]>;
520
555
  /** sealed before it leaves the browser and refused, never truncated, past this member's `maxMessageBytes` on the wire */
@@ -556,6 +591,13 @@ type RoomHandle = {
556
591
  /**
557
592
  * keeps the name and a mailbox for the signed-in premium account; the only thing in rooms that premium
558
593
  * buys. `description` says what the room is for, shown to the account in its fkn.app settings.
594
+ * `temporary` makes the claim end by itself that many milliseconds after its last claim (`true` is 7
595
+ * days); the broker carries it as a number of milliseconds and never as `true`.
596
+ *
597
+ * Past the account's room limit the call waits while fkn.app shows the person their claimed rooms over
598
+ * your app, with Unclaim on each: it answers `{ ok: true }` once one is unclaimed and this claim is
599
+ * made, and `full` (`rooms: too many claims`) when they close the card or when fkn.app cannot show it.
600
+ * Nothing about the account's other rooms reaches your app.
559
601
  */
560
602
  claim: (options?: RoomClaimOptions) => Promise<RoomsFail | {
561
603
  ok: true;
@@ -822,4 +864,4 @@ type Resolvers = {
822
864
  hideInstallPrompt: () => void;
823
865
  };
824
866
  //#endregion
825
- export { RoomMessage as $, OverlayState as A, Quota as B, InstallOptions as C, UdpSocketOptions as Ct, MiddleControl as D, WINDOW_JAR_MODE_TIMEOUT_MS as Dt, JAR_ANCHOR_MESSAGE as E, WINDOW_HELLO_TIMEOUT_MS as Et, PickOptions as F, RoomCreateOptions as G, Resolvers as H, Placement as I, RoomEvent as J, RoomDefaults as K, ProxyFetch as L, PackageResult as M, PackagesErrorCode as N, MountDescriptor as O, WindowMiddleControl as Ot, PackagesFail as P, RoomMember as Q, ProxyFetchInit as R, HiddenSurface as S, UdpDatagram as St, IpFamily as T, WINDOW_HANDSHAKE_TIMEOUT_MS as Tt, RoomBacklog as U, Radii as V, RoomClaimOptions as W, RoomJoinOptions as X, RoomHandle as Y, RoomMailbox as Z, FRAME_MESSAGE as _, SurfaceRect as _t, AddressLookupResult as a, SHELL_ATTACH_ERROR as at, FrameFetchScope as b, TcpSocketOptions as bt, ConflictChoice as c, SHELL_JAR_MESSAGE as ct, ConnectAvailability as d, ShellControl as dt, RoomOpenOptions as et, ConnectOptions as f, ShellFrameMessage as ft, EncryptionState as g, StorageQuota as gt, DnsLookup as h, StorageEntry as ht, Account as i, RoomsFail as it, PackageQuery as j, OverlayRect as k, WriteData as kt, ConflictRequest as l, SHELL_JAR_UNREACHABLE as lt, DisplayLevel as m, ShellJarUnreachable as mt, ATTACH_WINDOW_KEY as n, RoomPermissions as nt, AdoptRequest as o, SHELL_CONTROL_KEY as ot, DisplayCause as p, ShellGotoOptions as pt, RoomEnd as q, ATTACH_WINDOW_MESSAGE as r, RoomsErrorCode as rt, AdoptState as s, SHELL_FRAME_MESSAGE as st, ATTACH_FRAME_KEY as t, RoomPermission as tt, ConflictSide as u, SetOverlayHost as ut, FrameConsentAnswer as v, TcpSocketListenerOptions as vt, InstalledPackage as w, UdpSocketResult as wt, FrameMessageRelay as x, TcpSocketResult as xt, FrameConsentRequest as y, TcpSocketListenerResult as yt, ProxyFetchInput as z };
867
+ export { RoomMember as $, OverlayState as A, WriteData as At, Quota as B, InstallOptions as C, UdpDatagram as Ct, MiddleControl as D, WINDOW_HELLO_TIMEOUT_MS as Dt, JAR_ANCHOR_MESSAGE as E, WINDOW_HANDSHAKE_TIMEOUT_MS as Et, PickOptions as F, RoomClaimOptions as G, Radii as H, Placement as I, RoomEnd as J, RoomCreateOptions as K, ProxyFetch as L, PackageResult as M, PackagesErrorCode as N, MountDescriptor as O, WINDOW_JAR_MODE_TIMEOUT_MS as Ot, PackagesFail as P, RoomMailbox as Q, ProxyFetchInit as R, HiddenSurface as S, TcpSocketResult as St, IpFamily as T, UdpSocketResult as Tt, Resolvers as U, ROOM_TEMPORARY_MS as V, RoomBacklog as W, RoomHandle as X, RoomEvent as Y, RoomJoinOptions as Z, FRAME_MESSAGE as _, StorageQuota as _t, AddressLookupResult as a, RoomsFail as at, FrameFetchScope as b, TcpSocketListenerResult as bt, ConflictChoice as c, SHELL_FRAME_MESSAGE as ct, ConnectAvailability as d, SetOverlayHost as dt, RoomMessage as et, ConnectOptions as f, ShellControl as ft, EncryptionState as g, StorageEntry as gt, DnsLookup as h, ShellJarUnreachable as ht, Account as i, RoomsErrorCode as it, PackageQuery as j, OverlayRect as k, WindowMiddleControl as kt, ConflictRequest as l, SHELL_JAR_MESSAGE as lt, DisplayLevel as m, ShellGotoOptions as mt, ATTACH_WINDOW_KEY as n, RoomPermission as nt, AdoptRequest as o, SHELL_ATTACH_ERROR as ot, DisplayCause as p, ShellFrameMessage as pt, RoomDefaults as q, ATTACH_WINDOW_MESSAGE as r, RoomPermissions as rt, AdoptState as s, SHELL_CONTROL_KEY as st, ATTACH_FRAME_KEY as t, RoomOpenOptions as tt, ConflictSide as u, SHELL_JAR_UNREACHABLE as ut, FrameConsentAnswer as v, SurfaceRect as vt, InstalledPackage as w, UdpSocketOptions as wt, FrameMessageRelay as x, TcpSocketOptions as xt, FrameConsentRequest as y, TcpSocketListenerOptions as yt, ProxyFetchInput as z };
package/contract.cjs CHANGED
@@ -1 +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=`fkn-frame-message`,a=`sdbx-frame-message`,o={hello:`fkn-attach-window`,refused:`fkn-attach-window-refused`,gone:`fkn-attach-window-gone`,detach:`fkn-attach-window-detach`},s={request:`sdbx-jar-request`,port:`sdbx-jar-port`,mode:`sdbx-jar-mode`},c=[`bad-attach`,`no-storage`,`bad-jar`,`no-parent`,`no-jar-host`,`no-token`,`no-indexeddb`,`failed`],l={hello:`fkn-jar-hello`,ready:`fkn-jar-ready`,port:`fkn-jar-port`,who:`fkn-jar-who`,host:`fkn-jar-host`},u=2e4,d=3e4,f=6e4;exports.ATTACH_FRAME_KEY=e,exports.ATTACH_WINDOW_KEY=t,exports.ATTACH_WINDOW_MESSAGE=o,exports.FRAME_MESSAGE=i,exports.JAR_ANCHOR_MESSAGE=l,exports.SHELL_ATTACH_ERROR=r,exports.SHELL_CONTROL_KEY=n,exports.SHELL_FRAME_MESSAGE=a,exports.SHELL_JAR_MESSAGE=s,exports.SHELL_JAR_UNREACHABLE=c,exports.WINDOW_HANDSHAKE_TIMEOUT_MS=f,exports.WINDOW_HELLO_TIMEOUT_MS=u,exports.WINDOW_JAR_MODE_TIMEOUT_MS=d;
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=`fkn-frame-message`,a=`sdbx-frame-message`,o={hello:`fkn-attach-window`,refused:`fkn-attach-window-refused`,gone:`fkn-attach-window-gone`,detach:`fkn-attach-window-detach`},s={request:`sdbx-jar-request`,port:`sdbx-jar-port`,mode:`sdbx-jar-mode`},c=[`bad-attach`,`no-storage`,`bad-jar`,`no-parent`,`no-jar-host`,`no-token`,`no-indexeddb`,`failed`],l={hello:`fkn-jar-hello`,ready:`fkn-jar-ready`,port:`fkn-jar-port`,who:`fkn-jar-who`,host:`fkn-jar-host`},u=2e4,d=3e4,f=6e4,p={default:6048e5,min:6e4,max:31536e6};exports.ATTACH_FRAME_KEY=e,exports.ATTACH_WINDOW_KEY=t,exports.ATTACH_WINDOW_MESSAGE=o,exports.FRAME_MESSAGE=i,exports.JAR_ANCHOR_MESSAGE=l,exports.ROOM_TEMPORARY_MS=p,exports.SHELL_ATTACH_ERROR=r,exports.SHELL_CONTROL_KEY=n,exports.SHELL_FRAME_MESSAGE=a,exports.SHELL_JAR_MESSAGE=s,exports.SHELL_JAR_UNREACHABLE=c,exports.WINDOW_HANDSHAKE_TIMEOUT_MS=f,exports.WINDOW_HELLO_TIMEOUT_MS=u,exports.WINDOW_JAR_MODE_TIMEOUT_MS=d;
package/contract.d.ts CHANGED
@@ -1,3 +1,3 @@
1
1
  import { o as TcpSocketOption, v as UdpSocketOption } from "./wire-Gbo-D74t.js";
2
- import { $ as RoomMessage, A as OverlayState, B as Quota, C as InstallOptions, Ct as UdpSocketOptions, D as MiddleControl, Dt as WINDOW_JAR_MODE_TIMEOUT_MS, E as JAR_ANCHOR_MESSAGE, Et as WINDOW_HELLO_TIMEOUT_MS, F as PickOptions, G as RoomCreateOptions, H as Resolvers, I as Placement, J as RoomEvent, K as RoomDefaults, L as ProxyFetch, M as PackageResult, N as PackagesErrorCode, O as MountDescriptor, Ot as WindowMiddleControl, P as PackagesFail, Q as RoomMember, R as ProxyFetchInit, S as HiddenSurface, St as UdpDatagram, T as IpFamily, Tt as WINDOW_HANDSHAKE_TIMEOUT_MS, U as RoomBacklog, V as Radii, W as RoomClaimOptions, X as RoomJoinOptions, Y as RoomHandle, Z as RoomMailbox, _ as FRAME_MESSAGE, _t as SurfaceRect, a as AddressLookupResult, at as SHELL_ATTACH_ERROR, b as FrameFetchScope, bt as TcpSocketOptions, c as ConflictChoice, ct as SHELL_JAR_MESSAGE, d as ConnectAvailability, dt as ShellControl, et as RoomOpenOptions, f as ConnectOptions, ft as ShellFrameMessage, g as EncryptionState, gt as StorageQuota, h as DnsLookup, ht as StorageEntry, i as Account, it as RoomsFail, j as PackageQuery, k as OverlayRect, kt as WriteData, l as ConflictRequest, lt as SHELL_JAR_UNREACHABLE, m as DisplayLevel, mt as ShellJarUnreachable, n as ATTACH_WINDOW_KEY, nt as RoomPermissions, o as AdoptRequest, ot as SHELL_CONTROL_KEY, p as DisplayCause, pt as ShellGotoOptions, q as RoomEnd, r as ATTACH_WINDOW_MESSAGE, rt as RoomsErrorCode, s as AdoptState, st as SHELL_FRAME_MESSAGE, t as ATTACH_FRAME_KEY, tt as RoomPermission, u as ConflictSide, ut as SetOverlayHost, v as FrameConsentAnswer, vt as TcpSocketListenerOptions, w as InstalledPackage, wt as UdpSocketResult, x as FrameMessageRelay, xt as TcpSocketResult, y as FrameConsentRequest, yt as TcpSocketListenerResult, z as ProxyFetchInput } from "./contract-InuLU8bI.js";
3
- export { ATTACH_FRAME_KEY, ATTACH_WINDOW_KEY, ATTACH_WINDOW_MESSAGE, Account, AddressLookupResult, AdoptRequest, AdoptState, ConflictChoice, ConflictRequest, ConflictSide, ConnectAvailability, ConnectOptions, DisplayCause, DisplayLevel, DnsLookup, EncryptionState, FRAME_MESSAGE, FrameConsentAnswer, FrameConsentRequest, FrameFetchScope, FrameMessageRelay, HiddenSurface, InstallOptions, InstalledPackage, IpFamily, JAR_ANCHOR_MESSAGE, MiddleControl, MountDescriptor, OverlayRect, OverlayState, PackageQuery, PackageResult, PackagesErrorCode, PackagesFail, PickOptions, Placement, ProxyFetch, ProxyFetchInit, ProxyFetchInput, Quota, Radii, Resolvers, RoomBacklog, RoomClaimOptions, RoomCreateOptions, RoomDefaults, RoomEnd, RoomEvent, RoomHandle, RoomJoinOptions, RoomMailbox, RoomMember, RoomMessage, RoomOpenOptions, RoomPermission, RoomPermissions, RoomsErrorCode, RoomsFail, SHELL_ATTACH_ERROR, SHELL_CONTROL_KEY, SHELL_FRAME_MESSAGE, SHELL_JAR_MESSAGE, SHELL_JAR_UNREACHABLE, SetOverlayHost, ShellControl, ShellFrameMessage, ShellGotoOptions, ShellJarUnreachable, StorageEntry, StorageQuota, SurfaceRect, TcpSocketListenerOptions, TcpSocketListenerResult, type TcpSocketOption, TcpSocketOptions, TcpSocketResult, UdpDatagram, type UdpSocketOption, UdpSocketOptions, UdpSocketResult, WINDOW_HANDSHAKE_TIMEOUT_MS, WINDOW_HELLO_TIMEOUT_MS, WINDOW_JAR_MODE_TIMEOUT_MS, WindowMiddleControl, WriteData };
2
+ import { $ as RoomMember, A as OverlayState, At as WriteData, B as Quota, C as InstallOptions, Ct as UdpDatagram, D as MiddleControl, Dt as WINDOW_HELLO_TIMEOUT_MS, E as JAR_ANCHOR_MESSAGE, Et as WINDOW_HANDSHAKE_TIMEOUT_MS, F as PickOptions, G as RoomClaimOptions, H as Radii, I as Placement, J as RoomEnd, K as RoomCreateOptions, L as ProxyFetch, M as PackageResult, N as PackagesErrorCode, O as MountDescriptor, Ot as WINDOW_JAR_MODE_TIMEOUT_MS, P as PackagesFail, Q as RoomMailbox, R as ProxyFetchInit, S as HiddenSurface, St as TcpSocketResult, T as IpFamily, Tt as UdpSocketResult, U as Resolvers, V as ROOM_TEMPORARY_MS, W as RoomBacklog, X as RoomHandle, Y as RoomEvent, Z as RoomJoinOptions, _ as FRAME_MESSAGE, _t as StorageQuota, a as AddressLookupResult, at as RoomsFail, b as FrameFetchScope, bt as TcpSocketListenerResult, c as ConflictChoice, ct as SHELL_FRAME_MESSAGE, d as ConnectAvailability, dt as SetOverlayHost, et as RoomMessage, f as ConnectOptions, ft as ShellControl, g as EncryptionState, gt as StorageEntry, h as DnsLookup, ht as ShellJarUnreachable, i as Account, it as RoomsErrorCode, j as PackageQuery, k as OverlayRect, kt as WindowMiddleControl, l as ConflictRequest, lt as SHELL_JAR_MESSAGE, m as DisplayLevel, mt as ShellGotoOptions, n as ATTACH_WINDOW_KEY, nt as RoomPermission, o as AdoptRequest, ot as SHELL_ATTACH_ERROR, p as DisplayCause, pt as ShellFrameMessage, q as RoomDefaults, r as ATTACH_WINDOW_MESSAGE, rt as RoomPermissions, s as AdoptState, st as SHELL_CONTROL_KEY, t as ATTACH_FRAME_KEY, tt as RoomOpenOptions, u as ConflictSide, ut as SHELL_JAR_UNREACHABLE, v as FrameConsentAnswer, vt as SurfaceRect, w as InstalledPackage, wt as UdpSocketOptions, x as FrameMessageRelay, xt as TcpSocketOptions, y as FrameConsentRequest, yt as TcpSocketListenerOptions, z as ProxyFetchInput } from "./contract-sDmsw-9f.js";
3
+ export { ATTACH_FRAME_KEY, ATTACH_WINDOW_KEY, ATTACH_WINDOW_MESSAGE, Account, AddressLookupResult, AdoptRequest, AdoptState, ConflictChoice, ConflictRequest, ConflictSide, ConnectAvailability, ConnectOptions, DisplayCause, DisplayLevel, DnsLookup, EncryptionState, FRAME_MESSAGE, FrameConsentAnswer, FrameConsentRequest, FrameFetchScope, FrameMessageRelay, HiddenSurface, InstallOptions, InstalledPackage, IpFamily, JAR_ANCHOR_MESSAGE, MiddleControl, MountDescriptor, OverlayRect, OverlayState, PackageQuery, PackageResult, PackagesErrorCode, PackagesFail, PickOptions, Placement, ProxyFetch, ProxyFetchInit, ProxyFetchInput, Quota, ROOM_TEMPORARY_MS, Radii, Resolvers, RoomBacklog, RoomClaimOptions, RoomCreateOptions, RoomDefaults, RoomEnd, RoomEvent, RoomHandle, RoomJoinOptions, RoomMailbox, RoomMember, RoomMessage, RoomOpenOptions, RoomPermission, RoomPermissions, RoomsErrorCode, RoomsFail, SHELL_ATTACH_ERROR, SHELL_CONTROL_KEY, SHELL_FRAME_MESSAGE, SHELL_JAR_MESSAGE, SHELL_JAR_UNREACHABLE, SetOverlayHost, ShellControl, ShellFrameMessage, ShellGotoOptions, ShellJarUnreachable, StorageEntry, StorageQuota, SurfaceRect, TcpSocketListenerOptions, TcpSocketListenerResult, type TcpSocketOption, TcpSocketOptions, TcpSocketResult, UdpDatagram, type UdpSocketOption, UdpSocketOptions, UdpSocketResult, WINDOW_HANDSHAKE_TIMEOUT_MS, WINDOW_HELLO_TIMEOUT_MS, WINDOW_JAR_MODE_TIMEOUT_MS, WindowMiddleControl, WriteData };
package/contract.js CHANGED
@@ -23,6 +23,10 @@ var e = "fkn-attach-frame", t = "fkn-attach-window", n = "sdbx-control", r = "sd
23
23
  port: "fkn-jar-port",
24
24
  who: "fkn-jar-who",
25
25
  host: "fkn-jar-host"
26
- }, u = 2e4, d = 3e4, f = 6e4;
26
+ }, u = 2e4, d = 3e4, f = 6e4, p = {
27
+ default: 6048e5,
28
+ min: 6e4,
29
+ max: 31536e6
30
+ };
27
31
  //#endregion
28
- export { e as ATTACH_FRAME_KEY, t as ATTACH_WINDOW_KEY, o as ATTACH_WINDOW_MESSAGE, i as FRAME_MESSAGE, l as JAR_ANCHOR_MESSAGE, r as SHELL_ATTACH_ERROR, n as SHELL_CONTROL_KEY, a as SHELL_FRAME_MESSAGE, s as SHELL_JAR_MESSAGE, c as SHELL_JAR_UNREACHABLE, f as WINDOW_HANDSHAKE_TIMEOUT_MS, u as WINDOW_HELLO_TIMEOUT_MS, d as WINDOW_JAR_MODE_TIMEOUT_MS };
32
+ export { e as ATTACH_FRAME_KEY, t as ATTACH_WINDOW_KEY, o as ATTACH_WINDOW_MESSAGE, i as FRAME_MESSAGE, l as JAR_ANCHOR_MESSAGE, p as ROOM_TEMPORARY_MS, r as SHELL_ATTACH_ERROR, n as SHELL_CONTROL_KEY, a as SHELL_FRAME_MESSAGE, s as SHELL_JAR_MESSAGE, c as SHELL_JAR_UNREACHABLE, f as WINDOW_HANDSHAKE_TIMEOUT_MS, u as WINDOW_HELLO_TIMEOUT_MS, d as WINDOW_JAR_MODE_TIMEOUT_MS };
package/dgram.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./api-Djf-XdZ4.cjs"),n=require("./busy-Dv8wzE5M.cjs"),r=require("./utils-BvgGdrgN.cjs");require("./wire.cjs");let i=require("buffer"),a=require("events"),o=require("ip-address");var s=e.t({Socket:()=>c,createSocket:()=>m,default:()=>h}),c=class extends a.EventEmitter{_type;_localAddress;_remoteAddress;_connectedLocally;_connectGeneration=0;_destroyed=!1;_busyRelease;_webVPNUdpSocketPromise;_dataPort;_socketId;_sendQueue=[];_sendQueueBytes=0;_sendFlushScheduled=!1;_peerTailCache=new Map;constructor(e){if(super(e),!e)throw Error(`Missing options`);this._type=e.type,e.connection&&this.__webvpn_udp_socket_init__(e.connection)}_lastRecvBufferSize=0;_lastSendBufferSize=0;_lastTtl=64;_lastMulticastTtl=1;_lastMulticastLoopback=!0;_setUdpOption(e){if(!this._webVPNUdpSocketPromise){this.emit(`error`,Error(`Cannot set socket option before bind`));return}this._webVPNUdpSocketPromise.then(async t=>{if(t)try{await t.setOption(e)}catch(e){this.emit(`error`,e)}})}_dataPortAcks=!1;_dataPortConsumedBytes=0;_dataPortAckedBytes=0;_ackDataPortBatch(e){if(!this._dataPortAcks||!this._dataPort||(this._dataPortConsumedBytes+=e,this._dataPortAckedBytes!==0&&this._dataPortConsumedBytes-this._dataPortAckedBytes<524288))return;this._dataPortAckedBytes=this._dataPortConsumedBytes;let t={type:r.n,consumedBytes:this._dataPortConsumedBytes};this._dataPort.postMessage(t)}_onTransportClosed(e){this._destroyed||(this._destroyed=!0,this._busyRelease?.(),this._dataPort?.close(),this._dataPort=void 0,this.listenerCount(`error`)>0&&this.emit(`error`,Error(e||`WebVPN session closed`)),this.emit(`close`))}_onDataPortBatch(e){let t=new DataView(e),n=!1,r,a=0;for(;a+4<=e.byteLength;){let o=t.getUint32(a);a+=4;let s=a+o;if(s>e.byteLength)break;let c=a+4,l=t.getUint8(c);c+=1;let u,d,p;if(l===2){if(!this._remoteAddress){a=s;continue}u=this._remoteAddress.address,d=this._remoteAddress.family,p=this._remoteAddress.port}else{let n=new Uint8Array(e,c,l===0?4:16);l===0?(d=`IPv4`,u=`${n[0]}.${n[1]}.${n[2]}.${n[3]}`):(d=`IPv6`,u=f(n)),c+=n.byteLength,p=t.getUint16(c),c+=2}let m=t.getUint32(c);c+=4;try{this.emit(`message`,i.Buffer.from(e.slice(c,c+m)),{address:u,family:d,port:p,size:m})}catch(e){n||(n=!0,r=e)}a=s}if(n)throw r}_peerTail(e,t){if(e===void 0||t===void 0)return l;let n=`${e}|${t}`,r=this._peerTailCache.get(n);if(r)return r;let i=o.Address4.isValid(e)?d(e):p(e),a=new Uint8Array(1+i.byteLength+2);return a[0]=i.byteLength===4?0:1,a.set(i,1),new DataView(a.buffer).setUint16(1+i.byteLength,t),this._peerTailCache.size>=4096&&this._peerTailCache.clear(),this._peerTailCache.set(n,a),a}_portSend(e,t,n){let r=this._peerTail(t,n),i=new Uint8Array(8+r.byteLength+4+e.byteLength),a=new DataView(i.buffer);a.setUint32(0,i.byteLength-4),a.setUint32(4,this._socketId),i.set(r,8),a.setUint32(8+r.byteLength,e.byteLength),i.set(e,12+r.byteLength),this._sendQueue.push(i),this._sendQueueBytes+=i.byteLength,!this._sendFlushScheduled&&(this._sendFlushScheduled=!0,queueMicrotask(()=>{this._sendFlushScheduled=!1;let e=this._sendQueue,t=this._sendQueueBytes;if(this._sendQueue=[],this._sendQueueBytes=0,!e.length||!this._dataPort)return;let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.byteLength;this._dataPort.postMessage(n.buffer,[n.buffer])}))}addMembership(e,t){if(o.Address4.isValid(e)){let n=d(e),r=t&&o.Address4.isValid(t)?d(t):new Uint8Array([0,0,0,0]);this._setUdpOption({type:5,group:n,interface:r})}else if(o.Address6.isValid(e)){let t=p(e);this._setUdpOption({type:7,group:t,ifIndex:0})}else this.emit(`error`,Error(`Invalid multicast address: ${e}`))}address(){if(!this._localAddress)throw Error(`EBADF`);return this._localAddress}bind(...e){let n=r.o(...e),i=this._type===`udp6`?`::`:`0.0.0.0`,a=this.__webvpn_udp_socket_init__(t.o(`a udp socket`).then(e=>e.cloud.webvpn.udpSocket({type:this._type,address:n.address??i,port:n.port,dataPort:!0})));return n.callback&&a.then(e=>{e&&n.callback.call(this)}),this}__webvpn_udp_socket_init__(e,t){return t&&(this._localAddress={address:t.localAddress,family:t.localFamily,port:t.localPort}),this._busyRelease??=n.t(`udp socket`),this._webVPNUdpSocketPromise=e.then(e=>{if(e.dataPort)this._socketId=e.socketId,this._dataPort=e.dataPort,this._dataPortAcks=e.dataPortAcks===!0,this._dataPort.onmessage=e=>{try{this._onDataPortBatch(e.data)}finally{this._ackDataPortBatch(e.data.byteLength)}};else{let t=e.dataReadableStream.getReader();(async()=>{for(;;){let{value:e,done:n}=await t.read();if(n)return;this.emit(`message`,i.Buffer.from(e.data),{address:e.address,family:e.family,port:e.port,size:e.size})}})().catch(e=>this._onTransportClosed(e instanceof Error?e.message:void 0))}return e.closed?.then(e=>this._onTransportClosed(e?.reason)).catch(()=>{}),this._localAddress={address:e.localAddress,family:e.localFamily,port:e.localPort},e}).catch(e=>{this.emit(`error`,e)}),this._webVPNUdpSocketPromise.then(e=>{if(!e){this._busyRelease?.();return}this.emit(`listening`)}),this._webVPNUdpSocketPromise}close(e){if(!this._webVPNUdpSocketPromise)throw Error(`Socket not bound`);return this._webVPNUdpSocketPromise.then(async t=>{if(!t)throw Error(`Socket not bound`);let n=this._destroyed;this._destroyed=!0,this._busyRelease?.(),this._dataPort?.close(),this._dataPort=void 0;try{await t.close()}finally{try{e&&e()}finally{n||this.emit(`close`)}}}).catch(()=>{}),this}connect(...e){if(!this._webVPNUdpSocketPromise)throw Error(`Socket not bound`);this._webVPNUdpSocketPromise.then(async t=>{if(!t)throw Error(`Socket not bound`);let n=e[0],r=this._type===`udp6`?`::1`:`127.0.0.1`,i=typeof e[1]==`string`?e[1]:r,a=typeof e.at(-1)==`function`?e.at(-1):void 0,o=await t.connect({remotePort:n,remoteAddress:i});this._connectedLocally=o?.local===!0,this._remoteAddress=o?.address?{address:o.address,family:o.family,port:o.port}:{address:i,family:this._type===`udp6`?`IPv6`:`IPv4`,port:n},this._connectGeneration+=1,a&&a()}).catch(e=>{this.emit(`error`,e)})}disconnect(){if(!this._webVPNUdpSocketPromise)throw Error(`Socket not bound`);if(!this._remoteAddress)throw Error(`ERR_SOCKET_DGRAM_NOT_CONNECTED`);let e=this._remoteAddress,t=this._connectedLocally,n=this._connectGeneration;this._remoteAddress=void 0,this._connectedLocally=void 0,this._webVPNUdpSocketPromise.then(e=>e?.disconnect?.()).catch(r=>{this._connectGeneration===n&&(this._remoteAddress=e,this._connectedLocally=t),this.emit(`error`,r)})}dropMembership(e,t){if(o.Address4.isValid(e)){let n=d(e),r=t&&o.Address4.isValid(t)?d(t):new Uint8Array([0,0,0,0]);this._setUdpOption({type:6,group:n,interface:r})}else if(o.Address6.isValid(e)){let t=p(e);this._setUdpOption({type:8,group:t,ifIndex:0})}else this.emit(`error`,Error(`Invalid multicast address: ${e}`))}getRecvBufferSize(){return this._lastRecvBufferSize}getSendBufferSize(){return this._lastSendBufferSize}getSendQueueSize(){return 0}getSendQueueCount(){return 0}ref(){return this}remoteAddress(){if(!this._remoteAddress)throw Error(`ERR_SOCKET_DGRAM_NOT_CONNECTED`);return{address:this._remoteAddress.address,family:this._remoteAddress.family,port:this._remoteAddress.port}}send(...e){this._webVPNUdpSocketPromise||this.bind();let t=r.s(...e),n=u(t.message),i=n;if(t.hasRange){let{offset:e,length:r}=t;if(!Number.isInteger(e)||e<0||e>n.byteLength)throw Object.assign(RangeError(`"offset" is outside of buffer bounds`),{code:`ERR_BUFFER_OUT_OF_BOUNDS`});if(!Number.isInteger(r)||r<0||r>n.byteLength-e)throw Object.assign(RangeError(`"length" is outside of buffer bounds`),{code:`ERR_BUFFER_OUT_OF_BOUNDS`});i=n.subarray(e,e+r)}let a=this._type===`udp6`?`::1`:`127.0.0.1`;if(!this._webVPNUdpSocketPromise)throw Error(`Socket not bound`);this._webVPNUdpSocketPromise.then(e=>{if(!e)throw Error(`Socket not bound`);let n=t.callback,r=t.address??a,s=this._remoteAddress!==void 0&&t.address===void 0;if(this._dataPort&&(s||o.Address4.isValid(r)||o.Address6.isValid(r))){this._portSend(i,s?void 0:r,s?void 0:t.port),n?.call(this,null,i.byteLength);return}e.send({port:t.port,address:r,message:i.byteOffset===0&&i.byteLength===i.buffer.byteLength?i.buffer:i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength)}).then(()=>n?.call(this,null,i.byteLength),e=>n?n.call(this,e,0):this.emit(`error`,e))})}setBroadcast(e){this._setUdpOption({type:0,value:e})}setMulticastInterface(e){}setMulticastLoopback(e){return this._setUdpOption({type:3,value:e}),this._setUdpOption({type:4,value:e}),this._lastMulticastLoopback=e,e}setMulticastTTL(e){return this._setUdpOption({type:2,value:e}),this._lastMulticastTtl=e,e}setRecvBufferSize(e){this._setUdpOption({type:10,value:e}),this._lastRecvBufferSize=e}setSendBufferSize(e){this._setUdpOption({type:9,value:e}),this._lastSendBufferSize=e}setTTL(e){return this._setUdpOption({type:1,value:e}),this._lastTtl=e,e}unref(){return this}addSourceSpecificMembership(e,t,n){}dropSourceSpecificMembership(e,t,n){}async[Symbol.asyncDispose](){await new Promise(e=>{this.close(e)})}},l=new Uint8Array([2]),u=e=>{if(typeof e==`string`)return r.l.encode(e);if(e instanceof Uint8Array)return e;if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);if(Array.isArray(e)){let t=e.map(u),n=new Uint8Array(t.reduce((e,t)=>e+t.byteLength,0)),r=0;for(let e of t)n.set(e,r),r+=e.byteLength;return n}return new Uint8Array(e)},d=e=>{let t=e.split(`.`).map(e=>parseInt(e,10));if(t.length!==4||t.some(e=>Number.isNaN(e)||e<0||e>255))throw Error(`Invalid IPv4 address: ${e}`);return new Uint8Array(t)},f=e=>{let t=[];for(let n=0;n<16;n+=2)t.push(e[n]<<8|e[n+1]);let n=-1,r=1;for(let e=0;e<8;){if(t[e]!==0){e++;continue}let i=e;for(;i<8&&t[i]===0;)i++;i-e>r&&(n=e,r=i-e),e=i}return n===-1?t.map(e=>e.toString(16)).join(`:`):`${t.slice(0,n).map(e=>e.toString(16)).join(`:`)}::${t.slice(n+r).map(e=>e.toString(16)).join(`:`)}`},p=e=>{let t=new o.Address6(e).getBitsBase16(0,128).match(/.{2}/g);if(!t||t.length!==16)throw Error(`Invalid IPv6 address: ${e}`);return new Uint8Array(t.map(e=>parseInt(e,16)))},m=(e,t)=>{let n=new c(typeof e==`string`?{type:e}:e);return t&&n.on(`message`,t),n},h={Socket:c,createSocket:m};exports.Socket=c,exports.createSocket=m,exports.default=h,Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return s}});
1
+ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./api-jOTOA-5n.cjs"),n=require("./busy-Dv8wzE5M.cjs"),r=require("./utils-BvgGdrgN.cjs");require("./wire.cjs");let i=require("buffer"),a=require("events"),o=require("ip-address");var s=e.t({Socket:()=>c,createSocket:()=>m,default:()=>h}),c=class extends a.EventEmitter{_type;_localAddress;_remoteAddress;_connectedLocally;_connectGeneration=0;_destroyed=!1;_busyRelease;_webVPNUdpSocketPromise;_dataPort;_socketId;_sendQueue=[];_sendQueueBytes=0;_sendFlushScheduled=!1;_peerTailCache=new Map;constructor(e){if(super(e),!e)throw Error(`Missing options`);this._type=e.type,e.connection&&this.__webvpn_udp_socket_init__(e.connection)}_lastRecvBufferSize=0;_lastSendBufferSize=0;_lastTtl=64;_lastMulticastTtl=1;_lastMulticastLoopback=!0;_setUdpOption(e){if(!this._webVPNUdpSocketPromise){this.emit(`error`,Error(`Cannot set socket option before bind`));return}this._webVPNUdpSocketPromise.then(async t=>{if(t)try{await t.setOption(e)}catch(e){this.emit(`error`,e)}})}_dataPortAcks=!1;_dataPortConsumedBytes=0;_dataPortAckedBytes=0;_ackDataPortBatch(e){if(!this._dataPortAcks||!this._dataPort||(this._dataPortConsumedBytes+=e,this._dataPortAckedBytes!==0&&this._dataPortConsumedBytes-this._dataPortAckedBytes<524288))return;this._dataPortAckedBytes=this._dataPortConsumedBytes;let t={type:r.n,consumedBytes:this._dataPortConsumedBytes};this._dataPort.postMessage(t)}_onTransportClosed(e){this._destroyed||(this._destroyed=!0,this._busyRelease?.(),this._dataPort?.close(),this._dataPort=void 0,this.listenerCount(`error`)>0&&this.emit(`error`,Error(e||`WebVPN session closed`)),this.emit(`close`))}_onDataPortBatch(e){let t=new DataView(e),n=!1,r,a=0;for(;a+4<=e.byteLength;){let o=t.getUint32(a);a+=4;let s=a+o;if(s>e.byteLength)break;let c=a+4,l=t.getUint8(c);c+=1;let u,d,p;if(l===2){if(!this._remoteAddress){a=s;continue}u=this._remoteAddress.address,d=this._remoteAddress.family,p=this._remoteAddress.port}else{let n=new Uint8Array(e,c,l===0?4:16);l===0?(d=`IPv4`,u=`${n[0]}.${n[1]}.${n[2]}.${n[3]}`):(d=`IPv6`,u=f(n)),c+=n.byteLength,p=t.getUint16(c),c+=2}let m=t.getUint32(c);c+=4;try{this.emit(`message`,i.Buffer.from(e.slice(c,c+m)),{address:u,family:d,port:p,size:m})}catch(e){n||(n=!0,r=e)}a=s}if(n)throw r}_peerTail(e,t){if(e===void 0||t===void 0)return l;let n=`${e}|${t}`,r=this._peerTailCache.get(n);if(r)return r;let i=o.Address4.isValid(e)?d(e):p(e),a=new Uint8Array(1+i.byteLength+2);return a[0]=i.byteLength===4?0:1,a.set(i,1),new DataView(a.buffer).setUint16(1+i.byteLength,t),this._peerTailCache.size>=4096&&this._peerTailCache.clear(),this._peerTailCache.set(n,a),a}_portSend(e,t,n){let r=this._peerTail(t,n),i=new Uint8Array(8+r.byteLength+4+e.byteLength),a=new DataView(i.buffer);a.setUint32(0,i.byteLength-4),a.setUint32(4,this._socketId),i.set(r,8),a.setUint32(8+r.byteLength,e.byteLength),i.set(e,12+r.byteLength),this._sendQueue.push(i),this._sendQueueBytes+=i.byteLength,!this._sendFlushScheduled&&(this._sendFlushScheduled=!0,queueMicrotask(()=>{this._sendFlushScheduled=!1;let e=this._sendQueue,t=this._sendQueueBytes;if(this._sendQueue=[],this._sendQueueBytes=0,!e.length||!this._dataPort)return;let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.byteLength;this._dataPort.postMessage(n.buffer,[n.buffer])}))}addMembership(e,t){if(o.Address4.isValid(e)){let n=d(e),r=t&&o.Address4.isValid(t)?d(t):new Uint8Array([0,0,0,0]);this._setUdpOption({type:5,group:n,interface:r})}else if(o.Address6.isValid(e)){let t=p(e);this._setUdpOption({type:7,group:t,ifIndex:0})}else this.emit(`error`,Error(`Invalid multicast address: ${e}`))}address(){if(!this._localAddress)throw Error(`EBADF`);return this._localAddress}bind(...e){let n=r.o(...e),i=this._type===`udp6`?`::`:`0.0.0.0`,a=this.__webvpn_udp_socket_init__(t.o(`a udp socket`).then(e=>e.cloud.webvpn.udpSocket({type:this._type,address:n.address??i,port:n.port,dataPort:!0})));return n.callback&&a.then(e=>{e&&n.callback.call(this)}),this}__webvpn_udp_socket_init__(e,t){return t&&(this._localAddress={address:t.localAddress,family:t.localFamily,port:t.localPort}),this._busyRelease??=n.t(`udp socket`),this._webVPNUdpSocketPromise=e.then(e=>{if(e.dataPort)this._socketId=e.socketId,this._dataPort=e.dataPort,this._dataPortAcks=e.dataPortAcks===!0,this._dataPort.onmessage=e=>{try{this._onDataPortBatch(e.data)}finally{this._ackDataPortBatch(e.data.byteLength)}};else{let t=e.dataReadableStream.getReader();(async()=>{for(;;){let{value:e,done:n}=await t.read();if(n)return;this.emit(`message`,i.Buffer.from(e.data),{address:e.address,family:e.family,port:e.port,size:e.size})}})().catch(e=>this._onTransportClosed(e instanceof Error?e.message:void 0))}return e.closed?.then(e=>this._onTransportClosed(e?.reason)).catch(()=>{}),this._localAddress={address:e.localAddress,family:e.localFamily,port:e.localPort},e}).catch(e=>{this.emit(`error`,e)}),this._webVPNUdpSocketPromise.then(e=>{if(!e){this._busyRelease?.();return}this.emit(`listening`)}),this._webVPNUdpSocketPromise}close(e){if(!this._webVPNUdpSocketPromise)throw Error(`Socket not bound`);return this._webVPNUdpSocketPromise.then(async t=>{if(!t)throw Error(`Socket not bound`);let n=this._destroyed;this._destroyed=!0,this._busyRelease?.(),this._dataPort?.close(),this._dataPort=void 0;try{await t.close()}finally{try{e&&e()}finally{n||this.emit(`close`)}}}).catch(()=>{}),this}connect(...e){if(!this._webVPNUdpSocketPromise)throw Error(`Socket not bound`);this._webVPNUdpSocketPromise.then(async t=>{if(!t)throw Error(`Socket not bound`);let n=e[0],r=this._type===`udp6`?`::1`:`127.0.0.1`,i=typeof e[1]==`string`?e[1]:r,a=typeof e.at(-1)==`function`?e.at(-1):void 0,o=await t.connect({remotePort:n,remoteAddress:i});this._connectedLocally=o?.local===!0,this._remoteAddress=o?.address?{address:o.address,family:o.family,port:o.port}:{address:i,family:this._type===`udp6`?`IPv6`:`IPv4`,port:n},this._connectGeneration+=1,a&&a()}).catch(e=>{this.emit(`error`,e)})}disconnect(){if(!this._webVPNUdpSocketPromise)throw Error(`Socket not bound`);if(!this._remoteAddress)throw Error(`ERR_SOCKET_DGRAM_NOT_CONNECTED`);let e=this._remoteAddress,t=this._connectedLocally,n=this._connectGeneration;this._remoteAddress=void 0,this._connectedLocally=void 0,this._webVPNUdpSocketPromise.then(e=>e?.disconnect?.()).catch(r=>{this._connectGeneration===n&&(this._remoteAddress=e,this._connectedLocally=t),this.emit(`error`,r)})}dropMembership(e,t){if(o.Address4.isValid(e)){let n=d(e),r=t&&o.Address4.isValid(t)?d(t):new Uint8Array([0,0,0,0]);this._setUdpOption({type:6,group:n,interface:r})}else if(o.Address6.isValid(e)){let t=p(e);this._setUdpOption({type:8,group:t,ifIndex:0})}else this.emit(`error`,Error(`Invalid multicast address: ${e}`))}getRecvBufferSize(){return this._lastRecvBufferSize}getSendBufferSize(){return this._lastSendBufferSize}getSendQueueSize(){return 0}getSendQueueCount(){return 0}ref(){return this}remoteAddress(){if(!this._remoteAddress)throw Error(`ERR_SOCKET_DGRAM_NOT_CONNECTED`);return{address:this._remoteAddress.address,family:this._remoteAddress.family,port:this._remoteAddress.port}}send(...e){this._webVPNUdpSocketPromise||this.bind();let t=r.s(...e),n=u(t.message),i=n;if(t.hasRange){let{offset:e,length:r}=t;if(!Number.isInteger(e)||e<0||e>n.byteLength)throw Object.assign(RangeError(`"offset" is outside of buffer bounds`),{code:`ERR_BUFFER_OUT_OF_BOUNDS`});if(!Number.isInteger(r)||r<0||r>n.byteLength-e)throw Object.assign(RangeError(`"length" is outside of buffer bounds`),{code:`ERR_BUFFER_OUT_OF_BOUNDS`});i=n.subarray(e,e+r)}let a=this._type===`udp6`?`::1`:`127.0.0.1`;if(!this._webVPNUdpSocketPromise)throw Error(`Socket not bound`);this._webVPNUdpSocketPromise.then(e=>{if(!e)throw Error(`Socket not bound`);let n=t.callback,r=t.address??a,s=this._remoteAddress!==void 0&&t.address===void 0;if(this._dataPort&&(s||o.Address4.isValid(r)||o.Address6.isValid(r))){this._portSend(i,s?void 0:r,s?void 0:t.port),n?.call(this,null,i.byteLength);return}e.send({port:t.port,address:r,message:i.byteOffset===0&&i.byteLength===i.buffer.byteLength?i.buffer:i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength)}).then(()=>n?.call(this,null,i.byteLength),e=>n?n.call(this,e,0):this.emit(`error`,e))})}setBroadcast(e){this._setUdpOption({type:0,value:e})}setMulticastInterface(e){}setMulticastLoopback(e){return this._setUdpOption({type:3,value:e}),this._setUdpOption({type:4,value:e}),this._lastMulticastLoopback=e,e}setMulticastTTL(e){return this._setUdpOption({type:2,value:e}),this._lastMulticastTtl=e,e}setRecvBufferSize(e){this._setUdpOption({type:10,value:e}),this._lastRecvBufferSize=e}setSendBufferSize(e){this._setUdpOption({type:9,value:e}),this._lastSendBufferSize=e}setTTL(e){return this._setUdpOption({type:1,value:e}),this._lastTtl=e,e}unref(){return this}addSourceSpecificMembership(e,t,n){}dropSourceSpecificMembership(e,t,n){}async[Symbol.asyncDispose](){await new Promise(e=>{this.close(e)})}},l=new Uint8Array([2]),u=e=>{if(typeof e==`string`)return r.l.encode(e);if(e instanceof Uint8Array)return e;if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);if(Array.isArray(e)){let t=e.map(u),n=new Uint8Array(t.reduce((e,t)=>e+t.byteLength,0)),r=0;for(let e of t)n.set(e,r),r+=e.byteLength;return n}return new Uint8Array(e)},d=e=>{let t=e.split(`.`).map(e=>parseInt(e,10));if(t.length!==4||t.some(e=>Number.isNaN(e)||e<0||e>255))throw Error(`Invalid IPv4 address: ${e}`);return new Uint8Array(t)},f=e=>{let t=[];for(let n=0;n<16;n+=2)t.push(e[n]<<8|e[n+1]);let n=-1,r=1;for(let e=0;e<8;){if(t[e]!==0){e++;continue}let i=e;for(;i<8&&t[i]===0;)i++;i-e>r&&(n=e,r=i-e),e=i}return n===-1?t.map(e=>e.toString(16)).join(`:`):`${t.slice(0,n).map(e=>e.toString(16)).join(`:`)}::${t.slice(n+r).map(e=>e.toString(16)).join(`:`)}`},p=e=>{let t=new o.Address6(e).getBitsBase16(0,128).match(/.{2}/g);if(!t||t.length!==16)throw Error(`Invalid IPv6 address: ${e}`);return new Uint8Array(t.map(e=>parseInt(e,16)))},m=(e,t)=>{let n=new c(typeof e==`string`?{type:e}:e);return t&&n.on(`message`,t),n},h={Socket:c,createSocket:m};exports.Socket=c,exports.createSocket=m,exports.default=h,Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return s}});
package/dgram.d.ts CHANGED
@@ -1,6 +1,6 @@
1
1
  import { v as UdpSocketOption } from "./wire-Gbo-D74t.js";
2
- import { H as Resolvers, wt as UdpSocketResult } from "./contract-InuLU8bI.js";
3
- import "./api-DF4nHz2Q.js";
2
+ import { Tt as UdpSocketResult, U as Resolvers } from "./contract-sDmsw-9f.js";
3
+ import "./api-BxXnHxbd.js";
4
4
  import { Buffer } from "buffer";
5
5
  import { AddressInfo } from "net";
6
6
  import { EventEmitter } from "events";
package/dgram.js CHANGED
@@ -1,5 +1,5 @@
1
1
  import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
2
- import { o as t } from "./api-CtiKFcK3.js";
2
+ import { o as t } from "./api-Dp-2AT3u.js";
3
3
  import { t as n } from "./busy-B189uX--.js";
4
4
  import { l as r, n as i, o as a, s as o } from "./utils-C-cAd4r4.js";
5
5
  import "./wire.js";
package/dns.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./api-Djf-XdZ4.cjs");var n=e.t({lookup:()=>r}),r=(e,n)=>t.a.then(t=>t.cloud.dns.lookup(e,n));exports.lookup=r,Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return n}});
1
+ Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./api-jOTOA-5n.cjs");var n=e.t({lookup:()=>r}),r=(e,n)=>t.a.then(t=>t.cloud.dns.lookup(e,n));exports.lookup=r,Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return n}});
package/dns.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { a as AddressLookupResult } from "./contract-InuLU8bI.js";
1
+ import { a as AddressLookupResult } from "./contract-sDmsw-9f.js";
2
2
  declare namespace dns_d_exports {
3
3
  export { AddressLookupResult, lookup };
4
4
  }