@fkn/lib 0.9.46 → 0.9.48

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 (98) hide show
  1. package/{account-generation-B-6Pn0b5.cjs → account-generation-9VhfEDoW.cjs} +1 -1
  2. package/{account-generation-XNWOvLea.js → account-generation-hUekEHGW.js} +1 -1
  3. package/account.cjs +1 -1
  4. package/account.js +2 -2
  5. package/{api-DOXb_WrB.d.ts → api-Cpi-qz1j.d.ts} +108 -24
  6. package/api-DMnVye0K.cjs +3 -0
  7. package/{api-DIgTslNb.js → api-ySazPAwN.js} +97 -59
  8. package/api.cjs +1 -1
  9. package/api.d.ts +2 -2
  10. package/api.js +1 -1
  11. package/busy-BXbVH595.cjs +1 -0
  12. package/{busy-B189uX--.js → busy-DsMWrSzc.js} +6 -3
  13. package/cloud/dns.d.ts +1 -1
  14. package/cloud/fetch.cjs +1 -1
  15. package/cloud/fetch.d.ts +1 -1
  16. package/cloud/fetch.js +1 -1
  17. package/cloud/fs/promises.d.ts +1 -1
  18. package/cloud/fs.cjs +1 -1
  19. package/cloud/fs.d.ts +2 -2
  20. package/cloud/fs.js +2 -2
  21. package/cloud/net.cjs +1 -1
  22. package/cloud/net.d.ts +1 -1
  23. package/cloud/net.js +2 -2
  24. package/{cloud-v5x4uhDC.js → cloud-B4_qsdaE.js} +14 -18
  25. package/{cloud-CUzZFzG3.cjs → cloud-BmwojOb5.cjs} +1 -1
  26. package/{cloud-DSx-jDFk.d.ts → cloud-DK3DtdsU.d.ts} +4 -4
  27. package/cloud.cjs +1 -1
  28. package/cloud.d.ts +4 -4
  29. package/cloud.js +2 -2
  30. package/{contract-BmLpSueo.d.ts → contract-XlEPwc7b.d.ts} +127 -46
  31. package/contract.cjs +1 -1
  32. package/contract.d.ts +4 -4
  33. package/contract.js +6 -9
  34. package/dgram.cjs +1 -1
  35. package/dgram.d.ts +3 -3
  36. package/dgram.js +19 -19
  37. package/dns.cjs +1 -1
  38. package/dns.d.ts +1 -1
  39. package/dns.js +1 -1
  40. package/{extension-C2tBRE9i.d.ts → extension-C4Don9vi.d.ts} +6 -6
  41. package/{extension-BnVG0YL4.js → extension-hOZN6A1U.js} +4 -4
  42. package/{extension-3bxlAW8M.cjs → extension-uAlpUogG.cjs} +1 -1
  43. package/extension.cjs +1 -1
  44. package/extension.d.ts +2 -2
  45. package/extension.js +2 -2
  46. package/fs/promises.cjs +1 -1
  47. package/fs/promises.d.ts +1 -1
  48. package/fs/promises.js +1 -1
  49. package/fs-BY0Csn2V.js +515 -0
  50. package/fs-DnF1cQuE.cjs +1 -0
  51. package/{fs-KA1Mgisv.d.ts → fs-lKZe5xIo.d.ts} +1 -1
  52. package/fs.cjs +1 -1
  53. package/fs.d.ts +2 -2
  54. package/fs.js +2 -2
  55. package/http.d.ts +1 -1
  56. package/{index-DKr9L2RI.d.ts → index-D9x6A-Gx.d.ts} +1 -1
  57. package/{index-B98wvTaI.d.ts → index-DlBWSKwV.d.ts} +92 -32
  58. package/index.cjs +1 -1
  59. package/index.d.ts +12 -9
  60. package/index.js +60 -60
  61. package/lib-5z-jA7ND.cjs +53 -0
  62. package/{lib-BFwrzgpu.js → lib-Dhq4W2V8.js} +662 -491
  63. package/links.cjs +1 -0
  64. package/links.d.ts +65 -0
  65. package/links.js +187 -0
  66. package/{net-BFjtzAK0.d.ts → net-C2Yz0job.d.ts} +5 -5
  67. package/net.cjs +1 -1
  68. package/net.d.ts +1 -1
  69. package/net.js +11 -12
  70. package/{node-fs-CK2wWIYS.js → node-fs-DY2fO5zd.js} +1 -1
  71. package/{node-fs-nfX7wisL.cjs → node-fs-vsWuoMGa.cjs} +1 -1
  72. package/opfs.cjs +1 -1
  73. package/opfs.js +1 -1
  74. package/package.json +6 -1
  75. package/packages.cjs +1 -1
  76. package/packages.d.ts +1 -1
  77. package/packages.js +2 -2
  78. package/{proxy-Dixbk1WL.js → proxy-BXkxwBxK.js} +2 -2
  79. package/{proxy-BrsMJmiK.d.ts → proxy-BZ-YFeXe.d.ts} +2 -2
  80. package/{proxy-CFK-KiwE.cjs → proxy-BfkfFsNI.cjs} +1 -1
  81. package/rooms.cjs +1 -1
  82. package/rooms.d.ts +1 -1
  83. package/rooms.js +13 -21
  84. package/{storage-BLBsmkmp.d.ts → storage-B_mXNAdB.d.ts} +4 -5
  85. package/{storage-Dn1gTLSZ.js → storage-C6F9SnDM.js} +2 -2
  86. package/{storage-D2cUJlVH.cjs → storage-DmRIhg1P.cjs} +1 -1
  87. package/utils-BpHmMkIR.cjs +1 -0
  88. package/{utils-C-cAd4r4.js → utils-Cyq8uJiy.js} +7 -9
  89. package/{wire-BwA4JjZH.d.ts → wire-Fk5pJaoy.d.ts} +8 -1
  90. package/wire.cjs +1 -1
  91. package/wire.d.ts +2 -2
  92. package/wire.js +2 -2
  93. package/api--LOXTOpv.cjs +0 -3
  94. package/busy-Dv8wzE5M.cjs +0 -1
  95. package/fs-CVnmXRf7.js +0 -513
  96. package/fs-p0bOOj5n.cjs +0 -1
  97. package/lib-47LPHYgB.cjs +0 -53
  98. package/utils-BvgGdrgN.cjs +0 -1
package/cloud/fs.d.ts CHANGED
@@ -1,5 +1,5 @@
1
1
  import { i as Stats } from "../index-BQgZVQl7.js";
2
- import { _ as unlock, a as StorageAccountChangedError, c as StorageNotFoundError, f as encryption, h as quota, i as SealedRead, l as StorageQuota, m as isNotFound, n as EncryptionStatus, o as StorageAccountPinUnsupportedError, p as isAccountChanged, r as FileEntry, s as StorageLockedError, t as CloudAvailability, u as availability } from "../storage-BLBsmkmp.js";
2
+ import { _ as unlock, a as StorageAccountChangedError, c as StorageNotFoundError, f as encryption, h as quota, i as SealedRead, l as StorageQuota, m as isNotFound, n as EncryptionStatus, o as StorageAccountPinUnsupportedError, p as isAccountChanged, r as FileEntry, s as StorageLockedError, t as CloudAvailability, u as availability } from "../storage-B_mXNAdB.js";
3
3
  import { c as STORAGE_ACCOUNT_CHANGED, l as STORAGE_ACCOUNT_PIN_UNSUPPORTED, u as STORAGE_NOT_FOUND } from "../messages-d7pvCXPn.js";
4
- import { a as promises, c as readdir, d as stat, f as unlink, i as mkdir, l as rename, o as readFile, p as writeFile, r as list, s as readFileSealed, t as available, u as rm } from "../fs-KA1Mgisv.js";
4
+ import { a as promises, c as readdir, d as stat, f as unlink, i as mkdir, l as rename, o as readFile, p as writeFile, r as list, s as readFileSealed, t as available, u as rm } from "../fs-lKZe5xIo.js";
5
5
  export { type CloudAvailability, type EncryptionStatus, type FileEntry, STORAGE_ACCOUNT_CHANGED, STORAGE_ACCOUNT_PIN_UNSUPPORTED, STORAGE_NOT_FOUND, type SealedRead, type Stats, StorageAccountChangedError, StorageAccountPinUnsupportedError, StorageLockedError, StorageNotFoundError, type StorageQuota, availability, available, encryption, isAccountChanged, isNotFound, list, mkdir, promises, quota, readFile, readFileSealed, readdir, rename, rm, stat, unlink, unlock, writeFile };
package/cloud/fs.js CHANGED
@@ -1,7 +1,7 @@
1
1
  import { t as e } from "../rolldown-runtime-Dy4uBu1J.js";
2
- import { t } from "../node-fs-CK2wWIYS.js";
2
+ import { t } from "../node-fs-DY2fO5zd.js";
3
3
  import { STORAGE_ACCOUNT_CHANGED as n, STORAGE_ACCOUNT_PIN_UNSUPPORTED as r, STORAGE_NOT_FOUND as i } from "../messages.js";
4
- import { a, c as o, f as s, g as c, i as l, m as u, n as d, r as f, s as p, t as m, u as h, v as g, y as _ } from "../storage-Dn1gTLSZ.js";
4
+ import { a, c as o, f as s, g as c, i as l, m as u, n as d, r as f, s as p, t as m, u as h, v as g, y as _ } from "../storage-C6F9SnDM.js";
5
5
  //#region src/cloud/fs.ts
6
6
  var v = /* @__PURE__ */ e({
7
7
  STORAGE_ACCOUNT_CHANGED: () => n,
package/cloud/net.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../utils-BvgGdrgN.cjs"),t=require("../net.cjs");exports.Server=t.Server,exports.Socket=t.Socket,exports._default=t._default,exports.default=t._default,exports.connect=t.connect,exports.createConnection=t.createConnection,exports.createServer=t.createServer,exports.isIP=e.r,exports.isIPv4=e.i,exports.isIPv6=e.a;
1
+ Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../utils-BpHmMkIR.cjs"),t=require("../net.cjs");exports.Server=t.Server,exports.Socket=t.Socket,exports._default=t._default,exports.default=t._default,exports.connect=t.connect,exports.createConnection=t.createConnection,exports.createServer=t.createServer,exports.isIP=e.t,exports.isIPv4=e.n,exports.isIPv6=e.r;
package/cloud/net.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { a as createConnection, c as isIP, i as connect, l as isIPv4, n as Socket, o as createServer, r as _default, t as Server, u as isIPv6 } from "../net-BFjtzAK0.js";
1
+ import { a as createConnection, c as isIP, i as connect, l as isIPv4, n as Socket, o as createServer, r as _default, t as Server, u as isIPv6 } from "../net-C2Yz0job.js";
2
2
  export { Server, Socket, _default, _default as default, connect, createConnection, createServer, isIP, isIPv4, isIPv6 };
package/cloud/net.js CHANGED
@@ -1,3 +1,3 @@
1
- import { a as e, i as t, r as n } from "../utils-C-cAd4r4.js";
1
+ import { n as e, r as t, t as n } from "../utils-Cyq8uJiy.js";
2
2
  import { Server as r, Socket as i, _default as a, connect as o, createConnection as s, createServer as c } from "../net.js";
3
- export { r as Server, i as Socket, a as _default, a as default, o as connect, s as createConnection, c as createServer, n as isIP, t as isIPv4, e as isIPv6 };
3
+ export { r as Server, i as Socket, a as _default, a as default, o as connect, s as createConnection, c as createServer, n as isIP, e as isIPv4, t as isIPv6 };
@@ -1,9 +1,9 @@
1
1
  import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
2
- import { A as t, D as n, E as r, M as i, O as a, T as o, _ as s, c, f as l, g as u, h as d, l as f, lt as p, m, o as h, p as g, s as _, u as v, x as y, y as b } from "./lib-BFwrzgpu.js";
2
+ import { A as t, D as n, E as r, M as i, O as a, T as o, _ as s, c, f as l, g as u, h as d, l as f, lt as p, m, o as h, p as g, s as _, u as v, x as y, y as b } from "./lib-Dhq4W2V8.js";
3
3
  import { c as x, m as S, t as C } from "./hosts-t7CKGTRz.js";
4
- import { l as w, m as T, n as E, o as D, s as O } from "./api-DIgTslNb.js";
5
- import { t as k } from "./busy-B189uX--.js";
6
- import { t as A } from "./proxy-Dixbk1WL.js";
4
+ import { l as w, m as T, n as E, o as D, s as O } from "./api-ySazPAwN.js";
5
+ import { r as k } from "./busy-DsMWrSzc.js";
6
+ import { t as A } from "./proxy-BXkxwBxK.js";
7
7
  import { frameFetchVerdict as j } from "./attach-policy.js";
8
8
  import { ATTACH_FRAME_KEY as M, ATTACH_WINDOW_KEY as ee, ATTACH_WINDOW_MESSAGE as N, WINDOW_HANDSHAKE_TIMEOUT_MS as te } from "./contract.js";
9
9
  import { t as P } from "./dns.js";
@@ -354,10 +354,8 @@ var oe = async () => {
354
354
  y.signal.aborted || (document.visibilityState === "hidden" ? t = 0 : ++t >= De && S(Z(), !0));
355
355
  });
356
356
  }, Te);
357
- y.signal.addEventListener("abort", () => clearInterval(r), { once: !0 }), await P(H(e.ready(), we, "cloud.attachFrame: the window never became ready")), n !== void 0 && await P(K(e, n));
358
- let o = k("attached frame");
359
- y.signal.aborted ? o() : y.signal.addEventListener("abort", o, { once: !0 });
360
- let s = Y({
357
+ y.signal.addEventListener("abort", () => clearInterval(r), { once: !0 }), await P(H(e.ready(), we, "cloud.attachFrame: the window never became ready")), n !== void 0 && await P(K(e, n)), k("attached frame", y.signal);
358
+ let o = Y({
361
359
  control: e,
362
360
  target: a,
363
361
  session: f,
@@ -377,8 +375,8 @@ var oe = async () => {
377
375
  attach: d,
378
376
  signal: y.signal
379
377
  })
380
- }), c = null, u = Object.assign(s, {
381
- close: () => c ??= (async () => {
378
+ }), s = null, c = Object.assign(o, {
379
+ close: () => s ??= (async () => {
382
380
  y.signal.aborted || await H(Promise.allSettled([D(() => e.flushCookies()), D(() => e.sweepStorage())]), Oe, "close").catch(() => {});
383
381
  try {
384
382
  v.close();
@@ -387,7 +385,7 @@ var oe = async () => {
387
385
  })(),
388
386
  closed: T
389
387
  });
390
- return n !== void 0 && a && await P(u.goto(a)), i?.length && await P(u.requestPermissions(i)), u;
388
+ return n !== void 0 && a && await P(c.goto(a)), i?.length && await P(c.requestPermissions(i)), c;
391
389
  } catch (e) {
392
390
  let t = x ?? e;
393
391
  if (!(t instanceof s)) try {
@@ -493,10 +491,8 @@ var oe = async () => {
493
491
  unregisterSignal: h.signal,
494
492
  revivableModules: z(p)
495
493
  }), Ie, "cloud.attachFrame: timed out connecting to the render proxy page");
496
- await H(e.ready(), Q, "cloud.attachFrame: the render proxy never became ready"), r && await Je(e, r), n !== void 0 && await K(e, n), (l || r) && Ke(i), He(i, () => h.abort());
497
- let t = k("attached frame");
498
- h.signal.aborted ? t() : h.signal.addEventListener("abort", t, { once: !0 });
499
- let a = i.contentWindow, s = Y({
494
+ await H(e.ready(), Q, "cloud.attachFrame: the render proxy never became ready"), r && await Je(e, r), n !== void 0 && await K(e, n), (l || r) && Ke(i), He(i, () => h.abort()), k("attached frame", h.signal);
495
+ let t = i.contentWindow, a = Y({
500
496
  control: e,
501
497
  target: r || l,
502
498
  blank: r !== "",
@@ -505,19 +501,19 @@ var oe = async () => {
505
501
  approvedOrigins: m,
506
502
  attach: v,
507
503
  assertLive: () => {
508
- if (h.signal.aborted || !i.isConnected || i.contentWindow !== a) throw h.abort(), Ue();
504
+ if (h.signal.aborted || !i.isConnected || i.contentWindow !== t) throw h.abort(), Ue();
509
505
  },
510
506
  guard: (e) => e(),
511
507
  consent: oe,
512
508
  onNavigated: () => Ke(i),
513
509
  relay: J({
514
- from: () => a,
510
+ from: () => t,
515
511
  origin: B(),
516
512
  attach: v,
517
513
  signal: h.signal
518
514
  })
519
515
  });
520
- return n !== void 0 && l && await s.goto(l), o?.length && await s.requestPermissions(o), s;
516
+ return n !== void 0 && l && await a.goto(l), o?.length && await a.requestPermissions(o), a;
521
517
  } catch (e) {
522
518
  throw h.abort(), i.referrerPolicy = g, i.allow = _, i.src = u || "about:blank", e;
523
519
  }
@@ -1 +1 @@
1
- const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./lib-47LPHYgB.cjs"),n=require("./hosts-GNBhZO3-.cjs"),r=require("./api--LOXTOpv.cjs"),i=require("./busy-Dv8wzE5M.cjs"),a=require("./proxy-CFK-KiwE.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.s(`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,consent:a,current:s,declaredHosts:c,documentHost:l,freshBlank:u,session:d,approvedOrigins:f}=e,p=new Set,m=()=>{try{return new URL(s()).hostname}catch{return``}},g=async()=>l?await l():m(),b=()=>n.t([...c,...v(f)]),x=async(e,t)=>(await e([t]))[0]??!1;return{gate:async({operation:e,args:s,phase:l})=>{r();let _=n.m(e,s);if(_===null)return;let v=t.h(_);if(v===void 0||v===`auto`)return;if(e===`fetch`){let e=o.frameFetchVerdict({session:d,declaredHosts:c,approvedOrigins:f},l===`ensure`?void 0:s[0],{classifier:`fetchTarget`});if(l===`ensure`&&!d)throw t.O(e.kind===`refuse`?e.reason:``,`fetch`);if(l!==`ensure`&&e.kind===`refuse`)throw t.O(e.reason,`fetch`);let{request:r,ensure:i}=await a();if(!r){if(e.kind===`refuse`)throw t.O(e.reason,`fetch`);if(!await i({scope:n.c(s[0],s[1]).scope,hosts:e.promptHosts}))throw t.O(`frame.fetch: the user did not grant this`,`fetch`);return}let u=e.kind===`consent`?e.targetHost:await g(),p=n.t([u,...c]);if(!p.length)throw t.O(`frame: navigate the frame before fetch`,`fetch`);if(await x(r,{category:`network`,hosts:p})===!1)throw t.O(y(`fetch`,`network`,u||null),`fetch`);return}let S=await g();if(!S)throw t.O(`frame: navigate the frame before ${e}`,e);if(!b().includes(S))throw t.O(h,e);let C=t.m(_);if(C===void 0||C===`evaluation`&&S===m()&&await u?.()||v===`critical`&&p.has(`${_} ${S}`))return;let{request:w}=await a();if(!w)return;let T=n.t([S,...c]),E=await x(w,v===`critical`?{key:_,hosts:T,attach:i}:{category:C,hosts:T});if(E===!1)throw t.O(y(e,C,null),e);if(E===`once`&&l!==`ensure`)for(let e of T)p.add(`${_} ${e}`)},requestCategories:async e=>{r(),t.f(`frame.requestPermissions`,e);let o=await g(),s=n.t(o?[o,...c]:c);if(!s.length)throw TypeError(`frame.requestPermissions: navigate the frame or declare domains first`);let l=e.map(e=>{let n=e.key;return n===void 0?{named:void 0,critical:!1,category:e.category}:{named:n,critical:t.h(n)===`critical`,category:t.p(n)}}),u=({named:e,critical:t,category:n},r)=>({category:n,...t?{key:e}:{},hosts:s,allow:r}),{request:d}=await a();if(!d)return _(),l.map(e=>u(e,!1));let f=await d(l.map(({named:e,critical:t,category:n})=>t?{key:e,hosts:s,attach:i}:{category:n,hosts:s}));return l.map((e,t)=>u(e,f[t]!==void 0&&f[t]!==!1))},boundary:b}},x=e=>e,S=5e3,C=new Set([]),w=()=>`https://fkn.app`,T=e=>e===`persistent`?``:`incognito-${crypto.randomUUID()}`,E=(e,n,r)=>{let i,a=new Promise((e,a)=>{i=setTimeout(()=>a(typeof r==`string`?new t.T(r):r()),n)});return Promise.race([e,a]).finally(()=>clearTimeout(i))},D=e=>Object.assign(Error(e),{name:t.E}),O=`frame.postMessage: this FKN page predates frame messaging; reload the app to load the current one`,k=`frame.addScriptTag: this render proxy predates addScriptTag; reload the app`,A=`frame.addScriptTag: no answer within ${t.l}ms; the script may or may not have run`,j=`frame.clearCookies: this FKN page predates clearCookies; reload the app to load the current one`,M=`frame.clearCookies: this attachment reaches no site yet; attach a url, goto one, or declare it in domains`,N=3e4,P=`attachFrame: this FKN page predates storageState; reload the app to load the current one`,F=2e4,I=async(e,n)=>{if(typeof e.seed!=`function`)throw t.M(P,`storageState`,`cloud`);try{await E(e.seed(n),F,`attachFrame: the render proxy did not take the storageState seed`)}catch(e){throw t.D(e)?t.M(P,`storageState`,`cloud`):e}},L=`frame.clearCookies: the render proxy did not answer within ${N}ms; the cookies may or may not be gone, and calling it again is safe`,ee=e=>t.D(e)&&e.message===t.A(`addScriptTag`).message,R=!1,te=()=>{R||(R=!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.`))},z=({from:e,origin:t,attach:n,signal:r})=>i=>{let a=r=>{if(r.source===null||r.source!==e()||r.origin!==t)return;let a=r.data;typeof a==`object`&&a&&a.type===`fkn-frame-message`&&a.attach===n&&typeof a.origin==`string`&&(a.kind===`message`?i({type:`message`,data:a.data,origin:a.origin,ports:r.ports}):a.kind===`document`&&i({type:`document`,origin:a.origin}))};return window.addEventListener(`message`,a,{signal:r}),()=>window.removeEventListener(`message`,a)},ne=e=>{if(typeof e!=`function`)return()=>Promise.resolve(e);let t=null;return()=>t??=e().catch(e=>{throw t=null,e})},B=({control:e,target:n,blank:r=!1,session:i,declaredHosts:a,approvedOrigins:o,attach:s,assertLive:c,guard:l,consent:u,onNavigated:d,relay:f})=>{let p=n,m=r&&i!==``,g=async()=>{if(!m)return!1;let t=typeof e.blank==`function`?await l(()=>e.blank()):``;return(typeof t!=`string`||t.split(`#`)[0]!==n.split(`#`)[0])&&(m=!1),m},_=Promise.resolve(),{gate:v,requestCategories:y,boundary:x}=b({session:i,declaredHosts:a,approvedOrigins:o,attach:s,assertLive:c,documentHost:typeof e.documentHost==`function`?()=>l(()=>e.documentHost()):void 0,current:()=>p,consent:ne(u),freshBlank:g});return t.y({backend:`cloud`,executor:{execute:(n,r,i)=>C.has(r)?Promise.reject(t.A(r,`cloud`)):(c(),l(()=>e.executeLocator(n,r,i))),highlight:async()=>{}},gate:v,requestPermissions:y,evaluate:async(n,r)=>(c(),await v({parts:[],operation:`evaluate`,args:[n,r],phase:`execute`}),E(l(()=>e.executeLocator([],`evaluate`,[n,r])),t.l,t.u)),addScriptTag:async(n,r)=>{c();let i=[n,r];await v({parts:[],operation:`addScriptTag`,args:i,phase:`execute`});try{await E(l(()=>e.executeLocator([],`addScriptTag`,i)),t.l,A)}catch(e){throw ee(e)?t.M(k,`addScriptTag`,`cloud`):e}},clearCookies:async n=>{if(c(),typeof e.clearCookies!=`function`)throw t.M(j,`clearCookies`,`cloud`);if(x().length===0)throw t.O(M,`clearCookies`);await E(l(()=>e.clearCookies(n)),N,L)},postMessage:(n,r,i)=>{if(c(),typeof e.messaging!=`function`)throw t.M(O,`postMessage`,`cloud`);if(r!==`*`&&!x().includes(new URL(r).hostname))throw t.O(h,`postMessage`);let{port1:a,port2:o}=new MessageChannel;a.postMessage({data:n,transfer:i},i);let s=[o,r],u=_.then(async()=>(await v({parts:[],operation:`postMessage`,args:s,phase:`execute`}),{answer:l(()=>e.executeLocator([],`postMessage`,s))}));return _=u.catch(()=>{}),u.then(async({answer:e})=>{await e})},listen:t=>(typeof e.messaging!=`function`&&te(),f(t)),goto:async(n,{timeout:r,...i}={})=>{let a=new URL(n,location.href).href;c(),m=!1;let s=(()=>{try{return new URL(a).origin}catch{return``}})(),u=s!==``&&!o.has(s);u&&o.add(s);try{await E(l(()=>e.goto(a,r===void 0?i:{...i,timeoutMs:r})),(r??3e4)+S,`cloud.attachFrame: the render proxy did not answer goto; the frame may have been detached or its page reloaded`)}catch(e){throw u&&o.delete(s),t.c(e)}p=a,d()},url:()=>p})},re=250,ie=500,ae=65e3,oe=2e3,se=2e3,ce=2,le=2e3,ue=2e3,V=({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},H=(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},de=(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})},U=()=>D(`cloud.attachFrame: the attached window closed, reloaded or left the page FKN attached; attach a fresh window`),W=()=>D(`cloud.attachFrame: the attached window stopped answering; attach a fresh window`),fe=()=>D(`cloud.attachFrame: the window went away before it connected; attach a fresh window`),pe=()=>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`),me=async(e,r,a)=>{if(typeof window>`u`)throw Error(`cloud.attachFrame needs a window realm`);let{domains:o=[],permissions:c}=e,{url:l,width:u,height:d}=t.s(e.window);if(window.origin===`null`)throw new t._(`opaque-opener`);let f=w(),m=crypto.randomUUID(),h=T(r),g=n.t(o),_=new Set;l&&_.add(new URL(l).origin);let v=r===`persistent`?H(f,m):null,y=window.open(V({origin:f,target:a===void 0?l:``,session:h,domains:g,attach:m}),`_blank`,`popup,width=${u},height=${d}`);if(!y)throw v?.remove(),new t.g;let b=new AbortController,S=!1,C=null,D=(e,t=!1)=>{if(C===null){C=e,b.abort(t?W():U());try{y.closed||y.postMessage({type:s.ATTACH_WINDOW_MESSAGE.detach,attach:m,...t?{unanswered:t}:{}},f)}catch{}v&&setTimeout(()=>v.remove(),ue)}};v&&de(v,b.signal);let O=new Promise((e,t)=>{b.signal.addEventListener(`abort`,()=>t(b.signal.reason),{once:!0})});O.catch(()=>{});let k=O.then(()=>{},()=>{}),A=()=>{if(b.signal.aborted)throw b.signal.reason},j=e=>b.signal.aborted?Promise.reject(b.signal.reason):Promise.race([e(),O]),M=e=>e.source===y&&e.origin===f;window.addEventListener(`message`,e=>{if(!M(e))return;let n=e.data;typeof n==`object`&&n&&n.attach===m&&(n.type===s.ATTACH_WINDOW_MESSAGE.refused?D(new t._(n.reason)):n.type===s.ATTACH_WINDOW_MESSAGE.gone&&D(S?U():fe()))},{signal:b.signal}),window.addEventListener(`pagehide`,()=>D(U()),{signal:b.signal});let N=()=>{try{y.postMessage({type:s.ATTACH_WINDOW_MESSAGE.hello,attach:m},f)}catch{}};N();let P=setInterval(N,re),F=setInterval(()=>{y.closed&&D(S?U():pe())},ie);b.signal.addEventListener(`abort`,()=>{clearInterval(P),clearInterval(F)},{once:!0});let L=async e=>{try{return await Promise.race([e,O])}catch(e){throw C??e}};try{let e=await L(E((0,p.expose)({},{key:s.ATTACH_WINDOW_KEY,transport:{emit:(e,t)=>y.postMessage(e,f,t??[]),receive:e=>{let t=t=>{M(t)&&e(t.data,{source:t.source,origin:t.origin})};return window.addEventListener(`message`,t),()=>window.removeEventListener(`message`,t)}},unregisterSignal:b.signal,revivableModules:x(t.lt)}),s.WINDOW_HANDSHAKE_TIMEOUT_MS,`cloud.attachFrame: timed out connecting to the window`));S=!0,clearInterval(P);let n=0,r=setInterval(()=>{E(j(()=>e.ping()),se,`ping`).then(()=>{n=0},()=>{b.signal.aborted||(document.visibilityState===`hidden`?n=0:++n>=ce&&D(W(),!0))})},oe);b.signal.addEventListener(`abort`,()=>clearInterval(r),{once:!0}),await L(E(e.ready(),ae,`cloud.attachFrame: the window never became ready`)),a!==void 0&&await L(I(e,a));let o=i.t(`attached frame`);b.signal.aborted?o():b.signal.addEventListener(`abort`,o,{once:!0});let u=B({control:e,target:l,session:h,declaredHosts:g,approvedOrigins:_,attach:m,assertLive:A,guard:j,consent:{request:t=>j(()=>e.requestConsent(t)),ensure:t=>j(()=>e.requestConsent([t])).then(([e])=>e!==void 0&&e!==!1)},onNavigated:()=>{},relay:z({from:()=>y,origin:f,attach:m,signal:b.signal})}),d=null,v=Object.assign(u,{close:()=>d??=(async()=>{b.signal.aborted||await E(Promise.allSettled([j(()=>e.flushCookies()),j(()=>e.sweepStorage())]),le,`close`).catch(()=>{});try{y.close()}catch{}D(U())})(),closed:k});return a!==void 0&&l&&await L(v.goto(l)),c?.length&&await L(v.requestPermissions(c)),v}catch(e){let n=C??e;if(!(n instanceof t._))try{y.close()}catch{}throw D(n),n}},he=2e4,G=65e3,K=e=>!e||e===`about:blank`,ge=`cloud.attachFrame: this FKN page predates blank pages; reload the app to load the current one`,_e=`cloud.attachFrame: cookies: 'native' needs the FKN browser extension; the cloud render proxy has no browser cookies`,q=e=>e.split(`#`)[0]??``,J=({iframe:e,lockdown:n,cookies:r,blank:i})=>{if(i===void 0)return``;if(typeof i!=`object`||!i)throw TypeError(`attachFrame: blank must be an object { url }`);let a=Object.keys(i).find(e=>e!==`url`);if(a!==void 0)throw TypeError(`attachFrame: blank takes { url }, not "${a}"`);let{url:o}=i,s=(()=>{try{return typeof o==`string`?new URL(o):null}catch{return null}})();if(!s||s.protocol!==`http:`&&s.protocol!==`https:`)throw TypeError(`attachFrame: blank.url must be an absolute http or https url, not "${String(o)}"`);let c=e.getAttribute(`src`)??``;if(!K(c))throw TypeError(`attachFrame: blank needs an iframe with no src; this one has "${c}"`);if(n)throw TypeError(`attachFrame: blank does not combine with lockdown`);if(r===`native`)throw TypeError(`attachFrame: blank runs on the cloud render proxy, which has no browser cookies; pass cookies: 'persistent' or 'ephemeral'`);if(t.x(s.href),!Te())throw Error(`attachFrame: a blank page is served by the cloud render proxy, which this build does not configure`);return s.href},ve=({target:e,blank:t,session:n,domains:r,attach:i})=>{let a=new URL(`/attach-frame`,w());return t?a.searchParams.set(`blank`,t):e&&a.searchParams.set(`url`,e),n&&a.searchParams.set(`session`,n),r.length&&a.searchParams.set(`domains`,r.join(`,`)),a.searchParams.set(`attach`,i),a.href},ye=(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())},be=()=>D(`cloud.attachFrame: the attached iframe left the document or was reloaded; attach a fresh iframe`),xe=(e,t)=>{let n=[...e.split(`;`),...t.split(`;`)].map(e=>e.trim()).filter(Boolean);return[...new Set(n)].join(`; `)},Se=[300,1200,4e3],Y=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 Se)setTimeout(t,e)},Ce=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`)},X=async(e,n)=>{let r=typeof e.blank==`function`?await E(e.blank(),G,`cloud.attachFrame: the render proxy never became ready`):``;if(typeof r!=`string`||q(r)!==q(n))throw t.M(ge,`blank`,`cloud`)},we=async(e,a,o)=>{let c=J(e),{iframe:l,domains:u=[],permissions:d}=e;if(typeof window>`u`)throw Error(`cloud.attachFrame needs a window realm`);if(!l.isConnected)throw Error(`cloud.attachFrame: the iframe must be connected to the document before attaching`);Ce(l);let f=l.getAttribute(`src`)??``,h=(()=>{if(K(f))return null;try{return new URL(l.src||f,location.href)}catch{throw Error(`cloud.attachFrame: the iframe src is not a valid URL: ${f}`)}})();if(h){let e=new URL(`/attach-frame`,w());if(h.origin===e.origin&&h.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 g=h?.href??``;g&&t.x(g);let _=o===void 0?g:``,v=T(a),y=n.t(u),b=new Set;try{b.add(new URL(c||g).origin)}catch{}let S=new AbortController,C=l.referrerPolicy,D=l.allow,O=crypto.randomUUID();if(l.referrerPolicy=`origin`,l.allow=xe(r.m(),l.allow),l.src=ve({target:_,blank:c,session:v,domains:y,attach:O}),!l.contentWindow)throw Error(`cloud.attachFrame: the iframe window is not available`);try{let e=await E((0,p.expose)({},{key:s.ATTACH_FRAME_KEY,origin:w(),transport:{receive:window,emit:l.contentWindow},unregisterSignal:S.signal,revivableModules:x(t.lt)}),he,`cloud.attachFrame: timed out connecting to the render proxy page`);await E(e.ready(),G,`cloud.attachFrame: the render proxy never became ready`),c&&await X(e,c),o!==void 0&&await I(e,o),(g||c)&&Y(l),ye(l,()=>S.abort());let n=i.t(`attached frame`);S.signal.aborted?n():S.signal.addEventListener(`abort`,n,{once:!0});let r=l.contentWindow,a=B({control:e,target:c||g,blank:c!==``,session:v,declaredHosts:y,approvedOrigins:b,attach:O,assertLive:()=>{if(S.signal.aborted||!l.isConnected||l.contentWindow!==r)throw S.abort(),be()},guard:e=>e(),consent:m,onNavigated:()=>Y(l),relay:z({from:()=>r,origin:w(),attach:O,signal:S.signal})});return o!==void 0&&g&&await a.goto(g),d?.length&&await a.requestPermissions(d),a}catch(e){throw S.abort(),l.referrerPolicy=C,l.allow=D,l.src=_||`about:blank`,e}},Z=(async e=>{let{kind:n,cookies:r,storageState:i}=t.o(e);if(r===`native`)throw TypeError(_e);return n===`window`?me(e,r,i):we(e,r,i)}),Te=()=>typeof window<`u`&&!0,Q=async()=>{let e=await r.o.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}},Ee=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.l;Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return J}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return $}});
1
+ const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./lib-5z-jA7ND.cjs"),n=require("./hosts-GNBhZO3-.cjs"),r=require("./api-DMnVye0K.cjs"),i=require("./busy-BXbVH595.cjs"),a=require("./proxy-BfkfFsNI.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.s(`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,consent:a,current:s,declaredHosts:c,documentHost:l,freshBlank:u,session:d,approvedOrigins:f}=e,p=new Set,m=()=>{try{return new URL(s()).hostname}catch{return``}},g=async()=>l?await l():m(),b=()=>n.t([...c,...v(f)]),x=async(e,t)=>(await e([t]))[0]??!1;return{gate:async({operation:e,args:s,phase:l})=>{r();let _=n.m(e,s);if(_===null)return;let v=t.h(_);if(v===void 0||v===`auto`)return;if(e===`fetch`){let e=o.frameFetchVerdict({session:d,declaredHosts:c,approvedOrigins:f},l===`ensure`?void 0:s[0],{classifier:`fetchTarget`});if(l===`ensure`&&!d)throw t.O(e.kind===`refuse`?e.reason:``,`fetch`);if(l!==`ensure`&&e.kind===`refuse`)throw t.O(e.reason,`fetch`);let{request:r,ensure:i}=await a();if(!r){if(e.kind===`refuse`)throw t.O(e.reason,`fetch`);if(!await i({scope:n.c(s[0],s[1]).scope,hosts:e.promptHosts}))throw t.O(`frame.fetch: the user did not grant this`,`fetch`);return}let u=e.kind===`consent`?e.targetHost:await g(),p=n.t([u,...c]);if(!p.length)throw t.O(`frame: navigate the frame before fetch`,`fetch`);if(await x(r,{category:`network`,hosts:p})===!1)throw t.O(y(`fetch`,`network`,u||null),`fetch`);return}let S=await g();if(!S)throw t.O(`frame: navigate the frame before ${e}`,e);if(!b().includes(S))throw t.O(h,e);let C=t.m(_);if(C===void 0||C===`evaluation`&&S===m()&&await u?.()||v===`critical`&&p.has(`${_} ${S}`))return;let{request:w}=await a();if(!w)return;let T=n.t([S,...c]),E=await x(w,v===`critical`?{key:_,hosts:T,attach:i}:{category:C,hosts:T});if(E===!1)throw t.O(y(e,C,null),e);if(E===`once`&&l!==`ensure`)for(let e of T)p.add(`${_} ${e}`)},requestCategories:async e=>{r(),t.f(`frame.requestPermissions`,e);let o=await g(),s=n.t(o?[o,...c]:c);if(!s.length)throw TypeError(`frame.requestPermissions: navigate the frame or declare domains first`);let l=e.map(e=>{let n=e.key;return n===void 0?{named:void 0,critical:!1,category:e.category}:{named:n,critical:t.h(n)===`critical`,category:t.p(n)}}),u=({named:e,critical:t,category:n},r)=>({category:n,...t?{key:e}:{},hosts:s,allow:r}),{request:d}=await a();if(!d)return _(),l.map(e=>u(e,!1));let f=await d(l.map(({named:e,critical:t,category:n})=>t?{key:e,hosts:s,attach:i}:{category:n,hosts:s}));return l.map((e,t)=>u(e,f[t]!==void 0&&f[t]!==!1))},boundary:b}},x=e=>e,S=5e3,C=new Set([]),w=()=>`https://fkn.app`,T=e=>e===`persistent`?``:`incognito-${crypto.randomUUID()}`,E=(e,n,r)=>{let i,a=new Promise((e,a)=>{i=setTimeout(()=>a(typeof r==`string`?new t.T(r):r()),n)});return Promise.race([e,a]).finally(()=>clearTimeout(i))},D=e=>Object.assign(Error(e),{name:t.E}),O=`frame.postMessage: this FKN page predates frame messaging; reload the app to load the current one`,k=`frame.addScriptTag: this render proxy predates addScriptTag; reload the app`,A=`frame.addScriptTag: no answer within ${t.l}ms; the script may or may not have run`,j=`frame.clearCookies: this FKN page predates clearCookies; reload the app to load the current one`,M=`frame.clearCookies: this attachment reaches no site yet; attach a url, goto one, or declare it in domains`,N=3e4,P=`attachFrame: this FKN page predates storageState; reload the app to load the current one`,F=2e4,I=async(e,n)=>{if(typeof e.seed!=`function`)throw t.M(P,`storageState`,`cloud`);try{await E(e.seed(n),F,`attachFrame: the render proxy did not take the storageState seed`)}catch(e){throw t.D(e)?t.M(P,`storageState`,`cloud`):e}},L=`frame.clearCookies: the render proxy did not answer within ${N}ms; the cookies may or may not be gone, and calling it again is safe`,ee=e=>t.D(e)&&e.message===t.A(`addScriptTag`).message,R=!1,te=()=>{R||(R=!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.`))},z=({from:e,origin:t,attach:n,signal:r})=>i=>{let a=r=>{if(r.source===null||r.source!==e()||r.origin!==t)return;let a=r.data;typeof a==`object`&&a&&a.type===`fkn-frame-message`&&a.attach===n&&typeof a.origin==`string`&&(a.kind===`message`?i({type:`message`,data:a.data,origin:a.origin,ports:r.ports}):a.kind===`document`&&i({type:`document`,origin:a.origin}))};return window.addEventListener(`message`,a,{signal:r}),()=>window.removeEventListener(`message`,a)},ne=e=>{if(typeof e!=`function`)return()=>Promise.resolve(e);let t=null;return()=>t??=e().catch(e=>{throw t=null,e})},B=({control:e,target:n,blank:r=!1,session:i,declaredHosts:a,approvedOrigins:o,attach:s,assertLive:c,guard:l,consent:u,onNavigated:d,relay:f})=>{let p=n,m=r&&i!==``,g=async()=>{if(!m)return!1;let t=typeof e.blank==`function`?await l(()=>e.blank()):``;return(typeof t!=`string`||t.split(`#`)[0]!==n.split(`#`)[0])&&(m=!1),m},_=Promise.resolve(),{gate:v,requestCategories:y,boundary:x}=b({session:i,declaredHosts:a,approvedOrigins:o,attach:s,assertLive:c,documentHost:typeof e.documentHost==`function`?()=>l(()=>e.documentHost()):void 0,current:()=>p,consent:ne(u),freshBlank:g});return t.y({backend:`cloud`,executor:{execute:(n,r,i)=>C.has(r)?Promise.reject(t.A(r,`cloud`)):(c(),l(()=>e.executeLocator(n,r,i))),highlight:async()=>{}},gate:v,requestPermissions:y,evaluate:async(n,r)=>(c(),await v({parts:[],operation:`evaluate`,args:[n,r],phase:`execute`}),E(l(()=>e.executeLocator([],`evaluate`,[n,r])),t.l,t.u)),addScriptTag:async(n,r)=>{c();let i=[n,r];await v({parts:[],operation:`addScriptTag`,args:i,phase:`execute`});try{await E(l(()=>e.executeLocator([],`addScriptTag`,i)),t.l,A)}catch(e){throw ee(e)?t.M(k,`addScriptTag`,`cloud`):e}},clearCookies:async n=>{if(c(),typeof e.clearCookies!=`function`)throw t.M(j,`clearCookies`,`cloud`);if(x().length===0)throw t.O(M,`clearCookies`);await E(l(()=>e.clearCookies(n)),N,L)},postMessage:(n,r,i)=>{if(c(),typeof e.messaging!=`function`)throw t.M(O,`postMessage`,`cloud`);if(r!==`*`&&!x().includes(new URL(r).hostname))throw t.O(h,`postMessage`);let{port1:a,port2:o}=new MessageChannel;a.postMessage({data:n,transfer:i},i);let s=[o,r],u=_.then(async()=>(await v({parts:[],operation:`postMessage`,args:s,phase:`execute`}),{answer:l(()=>e.executeLocator([],`postMessage`,s))}));return _=u.catch(()=>{}),u.then(async({answer:e})=>{await e})},listen:t=>(typeof e.messaging!=`function`&&te(),f(t)),goto:async(n,{timeout:r,...i}={})=>{let a=new URL(n,location.href).href;c(),m=!1;let s=(()=>{try{return new URL(a).origin}catch{return``}})(),u=s!==``&&!o.has(s);u&&o.add(s);try{await E(l(()=>e.goto(a,r===void 0?i:{...i,timeoutMs:r})),(r??3e4)+S,`cloud.attachFrame: the render proxy did not answer goto; the frame may have been detached or its page reloaded`)}catch(e){throw u&&o.delete(s),t.c(e)}p=a,d()},url:()=>p})},re=250,ie=500,ae=65e3,oe=2e3,se=2e3,ce=2,le=2e3,ue=2e3,V=({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},H=(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},de=(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})},U=()=>D(`cloud.attachFrame: the attached window closed, reloaded or left the page FKN attached; attach a fresh window`),W=()=>D(`cloud.attachFrame: the attached window stopped answering; attach a fresh window`),fe=()=>D(`cloud.attachFrame: the window went away before it connected; attach a fresh window`),pe=()=>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`),me=async(e,r,a)=>{if(typeof window>`u`)throw Error(`cloud.attachFrame needs a window realm`);let{domains:o=[],permissions:c}=e,{url:l,width:u,height:d}=t.s(e.window);if(window.origin===`null`)throw new t._(`opaque-opener`);let f=w(),m=crypto.randomUUID(),h=T(r),g=n.t(o),_=new Set;l&&_.add(new URL(l).origin);let v=r===`persistent`?H(f,m):null,y=window.open(V({origin:f,target:a===void 0?l:``,session:h,domains:g,attach:m}),`_blank`,`popup,width=${u},height=${d}`);if(!y)throw v?.remove(),new t.g;let b=new AbortController,S=!1,C=null,D=(e,t=!1)=>{if(C===null){C=e,b.abort(t?W():U());try{y.closed||y.postMessage({type:s.ATTACH_WINDOW_MESSAGE.detach,attach:m,...t?{unanswered:t}:{}},f)}catch{}v&&setTimeout(()=>v.remove(),ue)}};v&&de(v,b.signal);let O=new Promise((e,t)=>{b.signal.addEventListener(`abort`,()=>t(b.signal.reason),{once:!0})});O.catch(()=>{});let k=O.then(()=>{},()=>{}),A=()=>{if(b.signal.aborted)throw b.signal.reason},j=e=>b.signal.aborted?Promise.reject(b.signal.reason):Promise.race([e(),O]),M=e=>e.source===y&&e.origin===f;window.addEventListener(`message`,e=>{if(!M(e))return;let n=e.data;typeof n==`object`&&n&&n.attach===m&&(n.type===s.ATTACH_WINDOW_MESSAGE.refused?D(new t._(n.reason)):n.type===s.ATTACH_WINDOW_MESSAGE.gone&&D(S?U():fe()))},{signal:b.signal}),window.addEventListener(`pagehide`,()=>D(U()),{signal:b.signal});let N=()=>{try{y.postMessage({type:s.ATTACH_WINDOW_MESSAGE.hello,attach:m},f)}catch{}};N();let P=setInterval(N,re),F=setInterval(()=>{y.closed&&D(S?U():pe())},ie);b.signal.addEventListener(`abort`,()=>{clearInterval(P),clearInterval(F)},{once:!0});let L=async e=>{try{return await Promise.race([e,O])}catch(e){throw C??e}};try{let e=await L(E((0,p.expose)({},{key:s.ATTACH_WINDOW_KEY,transport:{emit:(e,t)=>y.postMessage(e,f,t??[]),receive:e=>{let t=t=>{M(t)&&e(t.data,{source:t.source,origin:t.origin})};return window.addEventListener(`message`,t),()=>window.removeEventListener(`message`,t)}},unregisterSignal:b.signal,revivableModules:x(t.lt)}),s.WINDOW_HANDSHAKE_TIMEOUT_MS,`cloud.attachFrame: timed out connecting to the window`));S=!0,clearInterval(P);let n=0,r=setInterval(()=>{E(j(()=>e.ping()),se,`ping`).then(()=>{n=0},()=>{b.signal.aborted||(document.visibilityState===`hidden`?n=0:++n>=ce&&D(W(),!0))})},oe);b.signal.addEventListener(`abort`,()=>clearInterval(r),{once:!0}),await L(E(e.ready(),ae,`cloud.attachFrame: the window never became ready`)),a!==void 0&&await L(I(e,a)),i.r(`attached frame`,b.signal);let o=B({control:e,target:l,session:h,declaredHosts:g,approvedOrigins:_,attach:m,assertLive:A,guard:j,consent:{request:t=>j(()=>e.requestConsent(t)),ensure:t=>j(()=>e.requestConsent([t])).then(([e])=>e!==void 0&&e!==!1)},onNavigated:()=>{},relay:z({from:()=>y,origin:f,attach:m,signal:b.signal})}),u=null,d=Object.assign(o,{close:()=>u??=(async()=>{b.signal.aborted||await E(Promise.allSettled([j(()=>e.flushCookies()),j(()=>e.sweepStorage())]),le,`close`).catch(()=>{});try{y.close()}catch{}D(U())})(),closed:k});return a!==void 0&&l&&await L(d.goto(l)),c?.length&&await L(d.requestPermissions(c)),d}catch(e){let n=C??e;if(!(n instanceof t._))try{y.close()}catch{}throw D(n),n}},he=2e4,G=65e3,K=e=>!e||e===`about:blank`,ge=`cloud.attachFrame: this FKN page predates blank pages; reload the app to load the current one`,_e=`cloud.attachFrame: cookies: 'native' needs the FKN browser extension; the cloud render proxy has no browser cookies`,q=e=>e.split(`#`)[0]??``,J=({iframe:e,lockdown:n,cookies:r,blank:i})=>{if(i===void 0)return``;if(typeof i!=`object`||!i)throw TypeError(`attachFrame: blank must be an object { url }`);let a=Object.keys(i).find(e=>e!==`url`);if(a!==void 0)throw TypeError(`attachFrame: blank takes { url }, not "${a}"`);let{url:o}=i,s=(()=>{try{return typeof o==`string`?new URL(o):null}catch{return null}})();if(!s||s.protocol!==`http:`&&s.protocol!==`https:`)throw TypeError(`attachFrame: blank.url must be an absolute http or https url, not "${String(o)}"`);let c=e.getAttribute(`src`)??``;if(!K(c))throw TypeError(`attachFrame: blank needs an iframe with no src; this one has "${c}"`);if(n)throw TypeError(`attachFrame: blank does not combine with lockdown`);if(r===`native`)throw TypeError(`attachFrame: blank runs on the cloud render proxy, which has no browser cookies; pass cookies: 'persistent' or 'ephemeral'`);if(t.x(s.href),!Te())throw Error(`attachFrame: a blank page is served by the cloud render proxy, which this build does not configure`);return s.href},ve=({target:e,blank:t,session:n,domains:r,attach:i})=>{let a=new URL(`/attach-frame`,w());return t?a.searchParams.set(`blank`,t):e&&a.searchParams.set(`url`,e),n&&a.searchParams.set(`session`,n),r.length&&a.searchParams.set(`domains`,r.join(`,`)),a.searchParams.set(`attach`,i),a.href},ye=(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())},be=()=>D(`cloud.attachFrame: the attached iframe left the document or was reloaded; attach a fresh iframe`),xe=(e,t)=>{let n=[...e.split(`;`),...t.split(`;`)].map(e=>e.trim()).filter(Boolean);return[...new Set(n)].join(`; `)},Se=[300,1200,4e3],Y=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 Se)setTimeout(t,e)},Ce=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`)},X=async(e,n)=>{let r=typeof e.blank==`function`?await E(e.blank(),G,`cloud.attachFrame: the render proxy never became ready`):``;if(typeof r!=`string`||q(r)!==q(n))throw t.M(ge,`blank`,`cloud`)},we=async(e,a,o)=>{let c=J(e),{iframe:l,domains:u=[],permissions:d}=e;if(typeof window>`u`)throw Error(`cloud.attachFrame needs a window realm`);if(!l.isConnected)throw Error(`cloud.attachFrame: the iframe must be connected to the document before attaching`);Ce(l);let f=l.getAttribute(`src`)??``,h=(()=>{if(K(f))return null;try{return new URL(l.src||f,location.href)}catch{throw Error(`cloud.attachFrame: the iframe src is not a valid URL: ${f}`)}})();if(h){let e=new URL(`/attach-frame`,w());if(h.origin===e.origin&&h.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 g=h?.href??``;g&&t.x(g);let _=o===void 0?g:``,v=T(a),y=n.t(u),b=new Set;try{b.add(new URL(c||g).origin)}catch{}let S=new AbortController,C=l.referrerPolicy,D=l.allow,O=crypto.randomUUID();if(l.referrerPolicy=`origin`,l.allow=xe(r.m(),l.allow),l.src=ve({target:_,blank:c,session:v,domains:y,attach:O}),!l.contentWindow)throw Error(`cloud.attachFrame: the iframe window is not available`);try{let e=await E((0,p.expose)({},{key:s.ATTACH_FRAME_KEY,origin:w(),transport:{receive:window,emit:l.contentWindow},unregisterSignal:S.signal,revivableModules:x(t.lt)}),he,`cloud.attachFrame: timed out connecting to the render proxy page`);await E(e.ready(),G,`cloud.attachFrame: the render proxy never became ready`),c&&await X(e,c),o!==void 0&&await I(e,o),(g||c)&&Y(l),ye(l,()=>S.abort()),i.r(`attached frame`,S.signal);let n=l.contentWindow,r=B({control:e,target:c||g,blank:c!==``,session:v,declaredHosts:y,approvedOrigins:b,attach:O,assertLive:()=>{if(S.signal.aborted||!l.isConnected||l.contentWindow!==n)throw S.abort(),be()},guard:e=>e(),consent:m,onNavigated:()=>Y(l),relay:z({from:()=>n,origin:w(),attach:O,signal:S.signal})});return o!==void 0&&g&&await r.goto(g),d?.length&&await r.requestPermissions(d),r}catch(e){throw S.abort(),l.referrerPolicy=C,l.allow=D,l.src=_||`about:blank`,e}},Z=(async e=>{let{kind:n,cookies:r,storageState:i}=t.o(e);if(r===`native`)throw TypeError(_e);return n===`window`?me(e,r,i):we(e,r,i)}),Te=()=>typeof window<`u`&&!0,Q=async()=>{let e=await r.o.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}},Ee=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.l;Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return J}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return Ee}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return $}});
@@ -1,8 +1,8 @@
1
- import { r as AttachFrameFunction } from "./index-B98wvTaI.js";
2
- import { t as cloudFetch } from "./proxy-BrsMJmiK.js";
1
+ import { r as AttachFrameFunction } from "./index-DlBWSKwV.js";
2
+ import { t as cloudFetch } from "./proxy-BZ-YFeXe.js";
3
3
  import { t as dns_d_exports } from "./dns.js";
4
- import { n as fs_d_exports } from "./fs-KA1Mgisv.js";
5
- import { s as net_d_exports } from "./net-BFjtzAK0.js";
4
+ import { n as fs_d_exports } from "./fs-lKZe5xIo.js";
5
+ import { s as net_d_exports } from "./net-C2Yz0job.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
package/cloud.cjs CHANGED
@@ -1 +1 @@
1
- Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./proxy-CFK-KiwE.cjs"),t=require("./cloud-CUzZFzG3.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-BfkfFsNI.cjs"),t=require("./cloud-BmwojOb5.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-BrsMJmiK.js";
2
- import { a as attachFrame, i as quota, r as QuotaStatus, t as available } from "./cloud-DSx-jDFk.js";
1
+ import { t as cloudFetch } from "./proxy-BZ-YFeXe.js";
2
+ import { a as attachFrame, i as quota, r as QuotaStatus, t as available } from "./cloud-DK3DtdsU.js";
3
3
  import { t as dns_d_exports } from "./dns.js";
4
- import { n as fs_d_exports } from "./fs-KA1Mgisv.js";
5
- import { s as net_d_exports } from "./net-BFjtzAK0.js";
4
+ import { n as fs_d_exports } from "./fs-lKZe5xIo.js";
5
+ import { s as net_d_exports } from "./net-C2Yz0job.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-Dixbk1WL.js";
2
- import { i as t, r as n, t as r } from "./cloud-v5x4uhDC.js";
1
+ import { t as e } from "./proxy-BXkxwBxK.js";
2
+ import { i as t, r as n, t as r } from "./cloud-B4_qsdaE.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,5 +1,5 @@
1
- import { D as StorageState, tt as SelectorPart, u as ClearCookiesWire } from "./index-B98wvTaI.js";
2
- import { o as TcpSocketOption, v as UdpSocketOption } from "./wire-BwA4JjZH.js";
1
+ import { D as StorageState, tt as SelectorPart, u as ClearCookiesWire } from "./index-DlBWSKwV.js";
2
+ import { o as TcpSocketOption, x as UdpSocketOption } from "./wire-Fk5pJaoy.js";
3
3
  //#region ../web-extension/lib/lib/storage-state.d.ts
4
4
  /**
5
5
  * A `storageState` cookie in the cloud jar's own shape (mirage's `Cookie`): `domain` always with
@@ -215,33 +215,6 @@ declare const SHELL_JAR_MESSAGE: {
215
215
  */
216
216
  declare const SHELL_JAR_UNREACHABLE: readonly ['bad-attach', 'no-storage', 'bad-jar', 'no-parent', 'no-jar-host', 'no-token', 'no-indexeddb', 'failed'];
217
217
  type ShellJarUnreachable = (typeof SHELL_JAR_UNREACHABLE)[number];
218
- /**
219
- * FKN internal: why `Resolvers.proxyJar.key` answered no key. Only the render proxy's own documents
220
- * ask, and only these names cross the wire.
221
- *
222
- * - `not-proxy`: the caller is not the render proxy's own origin.
223
- * - `signed-out`: no account backs the app the proxy is attached to.
224
- * - `not-enrolled`: the account has no key material, so there is nothing to seal under.
225
- * - `locked`: the account has key material, and this partition holds no key for it.
226
- * - `unconfirmed`: nothing answered in time, so neither of the two above is known.
227
- */
228
- declare const PROXY_JAR_REFUSALS: readonly ['not-proxy', 'signed-out', 'not-enrolled', 'locked', 'unconfirmed'];
229
- type ProxyJarRefusal = (typeof PROXY_JAR_REFUSALS)[number];
230
- /**
231
- * The key the render proxy seals one jar under. `key` is 32 bytes for AES-GCM and `jar` the name of the
232
- * record (43 base64url characters); both are derived from the account's key for the top-level site the
233
- * jar's storage partition belongs to, so a key handed out in one partition opens no other partition's
234
- * jar. `verified` is false when no api answer vouched for the key's generation: such a key may open a
235
- * record that exists, and must not create one or move a clear jar into one.
236
- */
237
- type ProxyJarKey = {
238
- key: Uint8Array;
239
- jar: string;
240
- verified: boolean;
241
- };
242
- type ProxyJarAnswer = ProxyJarKey | {
243
- refused: ProxyJarRefusal;
244
- };
245
218
  /**
246
219
  * What a window's middle page, the jar anchor its app mounted (`/attach-jar`) and the anchor's jar
247
220
  * host say, all with the attach id.
@@ -337,12 +310,9 @@ type ShellControl = {
337
310
  *
338
311
  * Refuses, before anything is removed: a filter of any other shape (a TypeError
339
312
  * `frame.clearCookies: malformed filter`), an empty `scope.hosts`, and a string `domain` whose
340
- * registered domain is none of the hosts' (each a LocatorDeniedError naming why), and, on a jar
341
- * sealed under the FKN account's key while this device does not hold the key, every filter (an
342
- * Error `frame.clearCookies: this attachment's jar is sealed under the FKN account's key, which this
343
- * device does not hold yet; unlock it and call it again`, from a shell from 2026-10 on). Rejects
344
- * with the library's own message when the jar's store did not take the removal. Absent from a shell
345
- * that predates it.
313
+ * registered domain is none of the hosts' (each a LocatorDeniedError naming why). Rejects with the
314
+ * library's own message when the jar's store did not take the removal. Absent from a shell that
315
+ * predates it.
346
316
  */
347
317
  clearCookies?(filter: ClearCookiesWire, scope: {
348
318
  hosts: string[];
@@ -883,6 +853,103 @@ type RoomHandle = {
883
853
  /** settles once, when the room ends for this app. Never rejects. */
884
854
  closed: Promise<RoomEnd>;
885
855
  };
856
+ /**
857
+ * How far ahead a link's `expires` may be, in milliseconds: from 60,000 (1 minute) to 31,536,000,000
858
+ * (365 days). Anything outside is refused `invalid`.
859
+ */
860
+ declare const LINK_EXPIRES_MS: {
861
+ readonly min: 60000;
862
+ readonly max: 31536000000;
863
+ };
864
+ /** What a links refusal is about. Branch on it, never on the message. */
865
+ type LinksErrorCode = 'invalid' | 'not-found' | 'integrity' | 'denied' | 'quota' | 'too-many' | 'rate-limited' | 'account-changed' | 'unavailable';
866
+ /**
867
+ * A refusal, as data, the `RoomsFail` shape. `aborted` is the app's own signal, which the library turns
868
+ * back into the signal's reason rather than a `LinksError`.
869
+ */
870
+ type LinksFail = {
871
+ error: LinksErrorCode | 'aborted';
872
+ message: string;
873
+ };
874
+ /**
875
+ * A link as `list` answers it: what the service holds, which names no file and opens nothing, since
876
+ * the service never holds a link's key. Every time is epoch milliseconds.
877
+ */
878
+ type ListedLink = {
879
+ /** for `revoke` and `list`; it opens nothing */
880
+ id: string;
881
+ /** the file's own bytes; the account's storage counts 28 bytes more per 1 MiB */
882
+ size: number;
883
+ /** `uploading` until every part has landed */
884
+ status: 'uploading' | 'ready';
885
+ created: number;
886
+ /** null while the link lasts until it is revoked */
887
+ expires: number | null;
888
+ };
889
+ /** A link as `create` answers it: the listed fields, and what only the app that made it holds. */
890
+ type Link = ListedLink & {
891
+ /** `https://fkn.app/file#<key>`: anyone holding it opens the file */
892
+ url: string;
893
+ name: string;
894
+ type: string;
895
+ };
896
+ /** Progress of an upload, `ProgressEvent`'s two figures, in bytes of the file itself. */
897
+ type LinkProgress = {
898
+ loaded: number;
899
+ total: number;
900
+ };
901
+ type LinkCreateOptions = {
902
+ /** defaults to the File's own name, or '' for a Blob or a stream */
903
+ name?: string;
904
+ /** defaults to the Blob's own type */
905
+ type?: string;
906
+ /**
907
+ * epoch milliseconds on this page's clock, from 60,000 to 31,536,000,000 ahead of now
908
+ * (`LINK_EXPIRES_MS`), else `invalid`. The library turns it into a duration at the call, and the
909
+ * service adds that duration to its own clock, so `Link.expires` is read back from the service.
910
+ * Omitted, the link lasts until it is revoked.
911
+ */
912
+ expires?: number;
913
+ /** required for a ReadableStream: the bytes it will deliver, exactly */
914
+ size?: number;
915
+ /**
916
+ * the link key, 32 bytes base64url, minted when absent, as a room key is. It is what the url carries
917
+ * after the `#`, the service never sees it, and the account's own key has no part in it, so a key
918
+ * reset leaves the link opening. One key names one link at a time: a key that already names one is
919
+ * refused `invalid`.
920
+ */
921
+ key?: string;
922
+ /** aborts the upload and releases the storage it reserved */
923
+ signal?: AbortSignal;
924
+ /** called as each part lands */
925
+ onProgress?: (progress: LinkProgress) => void;
926
+ };
927
+ /** What the library hands the broker for a create, resolved at the moment of the call. */
928
+ type LinkCreateWire = {
929
+ name?: string;
930
+ type?: string;
931
+ lastModified?: number;
932
+ size?: number;
933
+ /** milliseconds from now, from `LINK_EXPIRES_MS.min` to `.max`; absent for a link that lasts until revoked */
934
+ expiresIn?: number;
935
+ /** the app's own link key, as `LinkCreateOptions.key`; absent, the broker mints one */
936
+ key?: string;
937
+ accountPin: string;
938
+ signal?: AbortSignal;
939
+ onProgress?: (progress: LinkProgress) => void;
940
+ };
941
+ /**
942
+ * An opened link, held by the broker, which keeps its key and reads the file by range. `read` hands
943
+ * over the bytes from `start` to `end` (exclusive), each 1 MiB record checked before it is handed over,
944
+ * and errors the stream on the first that is not what the link sealed.
945
+ */
946
+ type LinkHandle = {
947
+ name: string;
948
+ type: string;
949
+ size: number;
950
+ lastModified: number;
951
+ read: (start: number, end: number) => Promise<LinksFail | ReadableStream<Uint8Array>>;
952
+ };
886
953
  type IpFamily = 'IPv4' | 'IPv6';
887
954
  /** Viewport rect plus optional corner radii, as the overlay host reports them. */
888
955
  type OverlayRect = {
@@ -1116,6 +1183,30 @@ type Resolvers = {
1116
1183
  create: (options?: RoomCreateOptions) => Promise<RoomsFail | RoomHandle>;
1117
1184
  join: (invite: string, options?: RoomJoinOptions) => Promise<RoomsFail | RoomHandle>;
1118
1185
  };
1186
+ /**
1187
+ * Links to sealed files. Making, listing and revoking act for the calling app under the account its
1188
+ * pin was taken under; opening needs no account at all.
1189
+ */
1190
+ links: {
1191
+ /** whether a link can be made here now: an account is connected and the broker serves links */
1192
+ available: () => Promise<boolean>;
1193
+ create: (data: Blob | ReadableStream<Uint8Array>, options: LinkCreateWire) => Promise<LinksFail | Link>;
1194
+ open: (url: string, options?: {
1195
+ signal?: AbortSignal;
1196
+ }) => Promise<LinksFail | LinkHandle>;
1197
+ /** the calling app's links, newest first, uploads in progress included */
1198
+ list: (options: {
1199
+ accountPin: string;
1200
+ }) => Promise<LinksFail | {
1201
+ links: ListedLink[];
1202
+ }>;
1203
+ /** `target` is a link's url or its id; an upload in progress is aborted */
1204
+ revoke: (target: string, options: {
1205
+ accountPin: string;
1206
+ }) => Promise<LinksFail | {
1207
+ ok: true;
1208
+ }>;
1209
+ };
1119
1210
  account: {
1120
1211
  info: () => Promise<Account | null>;
1121
1212
  login: (consumerOrigin: string) => Promise<boolean>;
@@ -1128,16 +1219,6 @@ type Resolvers = {
1128
1219
  onUpdateTaken: (callback: () => void) => () => void;
1129
1220
  applyUpdate: () => Promise<boolean>;
1130
1221
  };
1131
- /** FKN internal: answers the render proxy's own origin only, every other caller gets `not-proxy`. */
1132
- proxyJar: {
1133
- /**
1134
- * The key of the cookie jar in the caller's storage partition. Refusals cross as data. `prompt`
1135
- * raises the key card, at most once per broker document, when the answer would be `locked`.
1136
- */
1137
- key: (options?: {
1138
- prompt?: boolean;
1139
- }) => Promise<ProxyJarAnswer>;
1140
- };
1141
1222
  proxyFetch: ProxyFetch;
1142
1223
  webVpnTcpSocket: (options: TcpSocketOptions) => Promise<TcpSocketResult>;
1143
1224
  webVpnTcpSocketListener: (options: TcpSocketListenerOptions) => Promise<TcpSocketListenerResult>;
@@ -1148,4 +1229,4 @@ type Resolvers = {
1148
1229
  hideInstallPrompt: () => void;
1149
1230
  };
1150
1231
  //#endregion
1151
- export { RoomCreateOptions as $, MiddleGotoOptions as A, UdpDatagram as At, Placement as B, FrameMessageRelay as C, StorageEntry as Ct, IpFamily as D, TcpSocketListenerResult as Dt, InstalledPackage as E, TcpSocketListenerOptions as Et, PackageQuery as F, WINDOW_JAR_MODE_TIMEOUT_MS as Ft, ProxyJarKey as G, ProxyFetchInit as H, PackageResult as I, WindowMiddleControl as It, ROOM_TEMPORARY_MS as J, ProxyJarRefusal as K, PackagesErrorCode as L, WriteData as Lt, OverlayRect as M, UdpSocketResult as Mt, OverlayState as N, WINDOW_HANDSHAKE_TIMEOUT_MS as Nt, JAR_ANCHOR_MESSAGE as O, TcpSocketOptions as Ot, PROXY_JAR_REFUSALS as P, WINDOW_HELLO_TIMEOUT_MS as Pt, RoomClaimOptions as Q, PackagesFail as R, JarSeed as Rt, FrameFetchScope as S, ShellJarUnreachable as St, InstallOptions as T, SurfaceRect as Tt, ProxyFetchInput as U, ProxyFetch as V, ProxyJarAnswer as W, Resolvers as X, Radii as Y, RoomBacklog as Z, DnsLookup as _, SHELL_JAR_UNREACHABLE as _t, AccountChange as a, RoomMailbox as at, FrameConsentAnswer as b, ShellFrameMessage as bt, AdoptRequest as c, RoomOpenOptions as ct, ConflictRequest as d, RoomsErrorCode as dt, RoomDefaults as et, ConflictSide as f, RoomsFail as ft, DisplayLevel as g, SHELL_JAR_MESSAGE as gt, DisplayCause as h, SHELL_FRAME_MESSAGE as ht, Account as i, RoomJoinOptions as it, MountDescriptor as j, UdpSocketOptions as jt, MiddleControl as k, TcpSocketResult as kt, AdoptState as l, RoomPermission as lt, ConnectOptions as m, SHELL_CONTROL_KEY as mt, ATTACH_WINDOW_KEY as n, RoomEvent as nt, AccountPinOptions as o, RoomMember as ot, ConnectAvailability as p, SHELL_ATTACH_ERROR as pt, Quota as q, ATTACH_WINDOW_MESSAGE as r, RoomHandle as rt, AddressLookupResult as s, RoomMessage as st, ATTACH_FRAME_KEY as t, RoomEnd as tt, ConflictChoice as u, RoomPermissions as ut, EncryptionState as v, SetOverlayHost as vt, HiddenSurface as w, StorageQuota as wt, FrameConsentRequest as x, ShellGotoOptions as xt, FRAME_MESSAGE as y, ShellControl as yt, PickOptions as z, JarSeedCookie as zt };
1232
+ export { ROOM_TEMPORARY_MS as $, Link as A, SurfaceRect as At, MountDescriptor as B, WINDOW_JAR_MODE_TIMEOUT_MS as Bt, FrameMessageRelay as C, SetOverlayHost as Ct, IpFamily as D, ShellJarUnreachable as Dt, InstalledPackage as E, ShellGotoOptions as Et, LinksErrorCode as F, UdpDatagram as Ft, PackagesErrorCode as G, OverlayState as H, WriteData as Ht, LinksFail as I, UdpSocketOptions as It, Placement as J, PackagesFail as K, ListedLink as L, UdpSocketResult as Lt, LinkCreateWire as M, TcpSocketListenerResult as Mt, LinkHandle as N, TcpSocketOptions as Nt, JAR_ANCHOR_MESSAGE as O, StorageEntry as Ot, LinkProgress as P, TcpSocketResult as Pt, Quota as Q, MiddleControl as R, WINDOW_HANDSHAKE_TIMEOUT_MS as Rt, FrameFetchScope as S, SHELL_JAR_UNREACHABLE as St, InstallOptions as T, ShellFrameMessage as Tt, PackageQuery as U, JarSeed as Ut, OverlayRect as V, WindowMiddleControl as Vt, PackageResult as W, JarSeedCookie as Wt, ProxyFetchInit as X, ProxyFetch as Y, ProxyFetchInput as Z, DnsLookup as _, RoomsFail as _t, AccountChange as a, RoomDefaults as at, FrameConsentAnswer as b, SHELL_FRAME_MESSAGE as bt, AdoptRequest as c, RoomHandle as ct, ConflictRequest as d, RoomMember as dt, Radii as et, ConflictSide as f, RoomMessage as ft, DisplayLevel as g, RoomsErrorCode as gt, DisplayCause as h, RoomPermissions as ht, Account as i, RoomCreateOptions as it, LinkCreateOptions as j, TcpSocketListenerOptions as jt, LINK_EXPIRES_MS as k, StorageQuota as kt, AdoptState as l, RoomJoinOptions as lt, ConnectOptions as m, RoomPermission as mt, ATTACH_WINDOW_KEY as n, RoomBacklog as nt, AccountPinOptions as o, RoomEnd as ot, ConnectAvailability as p, RoomOpenOptions as pt, PickOptions as q, ATTACH_WINDOW_MESSAGE as r, RoomClaimOptions as rt, AddressLookupResult as s, RoomEvent as st, ATTACH_FRAME_KEY as t, Resolvers as tt, ConflictChoice as u, RoomMailbox as ut, EncryptionState as v, SHELL_ATTACH_ERROR as vt, HiddenSurface as w, ShellControl as wt, FrameConsentRequest as x, SHELL_JAR_MESSAGE as xt, FRAME_MESSAGE as y, SHELL_CONTROL_KEY as yt, MiddleGotoOptions as z, WINDOW_HELLO_TIMEOUT_MS as zt };
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=[`not-proxy`,`signed-out`,`not-enrolled`,`locked`,`unconfirmed`],u={hello:`fkn-jar-hello`,ready:`fkn-jar-ready`,port:`fkn-jar-port`,who:`fkn-jar-who`,host:`fkn-jar-host`},d=2e4,f=3e4,p=6e4,m={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=u,exports.PROXY_JAR_REFUSALS=l,exports.ROOM_TEMPORARY_MS=m,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=p,exports.WINDOW_HELLO_TIMEOUT_MS=d,exports.WINDOW_JAR_MODE_TIMEOUT_MS=f;
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},m={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.LINK_EXPIRES_MS=m,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,4 +1,4 @@
1
- import { d as CookieMatchWire, u as ClearCookiesWire } from "./index-B98wvTaI.js";
2
- import { $ as RoomCreateOptions, A as MiddleGotoOptions, At as UdpDatagram, B as Placement, C as FrameMessageRelay, Ct as StorageEntry, D as IpFamily, Dt as TcpSocketListenerResult, E as InstalledPackage, Et as TcpSocketListenerOptions, F as PackageQuery, Ft as WINDOW_JAR_MODE_TIMEOUT_MS, G as ProxyJarKey, H as ProxyFetchInit, I as PackageResult, It as WindowMiddleControl, J as ROOM_TEMPORARY_MS, K as ProxyJarRefusal, L as PackagesErrorCode, Lt as WriteData, M as OverlayRect, Mt as UdpSocketResult, N as OverlayState, Nt as WINDOW_HANDSHAKE_TIMEOUT_MS, O as JAR_ANCHOR_MESSAGE, Ot as TcpSocketOptions, P as PROXY_JAR_REFUSALS, Pt as WINDOW_HELLO_TIMEOUT_MS, Q as RoomClaimOptions, R as PackagesFail, Rt as JarSeed, S as FrameFetchScope, St as ShellJarUnreachable, T as InstallOptions, Tt as SurfaceRect, U as ProxyFetchInput, V as ProxyFetch, W as ProxyJarAnswer, X as Resolvers, Y as Radii, Z as RoomBacklog, _ as DnsLookup, _t as SHELL_JAR_UNREACHABLE, a as AccountChange, at as RoomMailbox, b as FrameConsentAnswer, bt as ShellFrameMessage, c as AdoptRequest, ct as RoomOpenOptions, d as ConflictRequest, dt as RoomsErrorCode, et as RoomDefaults, f as ConflictSide, ft as RoomsFail, g as DisplayLevel, gt as SHELL_JAR_MESSAGE, h as DisplayCause, ht as SHELL_FRAME_MESSAGE, i as Account, it as RoomJoinOptions, j as MountDescriptor, jt as UdpSocketOptions, k as MiddleControl, kt as TcpSocketResult, l as AdoptState, lt as RoomPermission, m as ConnectOptions, mt as SHELL_CONTROL_KEY, n as ATTACH_WINDOW_KEY, nt as RoomEvent, o as AccountPinOptions, ot as RoomMember, p as ConnectAvailability, pt as SHELL_ATTACH_ERROR, q as Quota, r as ATTACH_WINDOW_MESSAGE, rt as RoomHandle, s as AddressLookupResult, st as RoomMessage, t as ATTACH_FRAME_KEY, tt as RoomEnd, u as ConflictChoice, ut as RoomPermissions, v as EncryptionState, vt as SetOverlayHost, w as HiddenSurface, wt as StorageQuota, x as FrameConsentRequest, xt as ShellGotoOptions, y as FRAME_MESSAGE, yt as ShellControl, z as PickOptions, zt as JarSeedCookie } from "./contract-BmLpSueo.js";
3
- import { o as TcpSocketOption, v as UdpSocketOption } from "./wire-BwA4JjZH.js";
4
- export { ATTACH_FRAME_KEY, ATTACH_WINDOW_KEY, ATTACH_WINDOW_MESSAGE, Account, AccountChange, AccountPinOptions, AddressLookupResult, AdoptRequest, AdoptState, type ClearCookiesWire, ConflictChoice, ConflictRequest, ConflictSide, ConnectAvailability, ConnectOptions, type CookieMatchWire, DisplayCause, DisplayLevel, DnsLookup, EncryptionState, FRAME_MESSAGE, FrameConsentAnswer, FrameConsentRequest, FrameFetchScope, FrameMessageRelay, HiddenSurface, InstallOptions, InstalledPackage, IpFamily, JAR_ANCHOR_MESSAGE, type JarSeed, type JarSeedCookie, MiddleControl, MiddleGotoOptions, MountDescriptor, OverlayRect, OverlayState, PROXY_JAR_REFUSALS, PackageQuery, PackageResult, PackagesErrorCode, PackagesFail, PickOptions, Placement, ProxyFetch, ProxyFetchInit, ProxyFetchInput, ProxyJarAnswer, ProxyJarKey, ProxyJarRefusal, 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 };
1
+ import { d as CookieMatchWire, u as ClearCookiesWire } from "./index-DlBWSKwV.js";
2
+ import { $ as ROOM_TEMPORARY_MS, A as Link, At as SurfaceRect, B as MountDescriptor, Bt as WINDOW_JAR_MODE_TIMEOUT_MS, C as FrameMessageRelay, Ct as SetOverlayHost, D as IpFamily, Dt as ShellJarUnreachable, E as InstalledPackage, Et as ShellGotoOptions, F as LinksErrorCode, Ft as UdpDatagram, G as PackagesErrorCode, H as OverlayState, Ht as WriteData, I as LinksFail, It as UdpSocketOptions, J as Placement, K as PackagesFail, L as ListedLink, Lt as UdpSocketResult, M as LinkCreateWire, Mt as TcpSocketListenerResult, N as LinkHandle, Nt as TcpSocketOptions, O as JAR_ANCHOR_MESSAGE, Ot as StorageEntry, P as LinkProgress, Pt as TcpSocketResult, Q as Quota, R as MiddleControl, Rt as WINDOW_HANDSHAKE_TIMEOUT_MS, S as FrameFetchScope, St as SHELL_JAR_UNREACHABLE, T as InstallOptions, Tt as ShellFrameMessage, U as PackageQuery, Ut as JarSeed, V as OverlayRect, Vt as WindowMiddleControl, W as PackageResult, Wt as JarSeedCookie, X as ProxyFetchInit, Y as ProxyFetch, Z as ProxyFetchInput, _ as DnsLookup, _t as RoomsFail, a as AccountChange, at as RoomDefaults, b as FrameConsentAnswer, bt as SHELL_FRAME_MESSAGE, c as AdoptRequest, ct as RoomHandle, d as ConflictRequest, dt as RoomMember, et as Radii, f as ConflictSide, ft as RoomMessage, g as DisplayLevel, gt as RoomsErrorCode, h as DisplayCause, ht as RoomPermissions, i as Account, it as RoomCreateOptions, j as LinkCreateOptions, jt as TcpSocketListenerOptions, k as LINK_EXPIRES_MS, kt as StorageQuota, l as AdoptState, lt as RoomJoinOptions, m as ConnectOptions, mt as RoomPermission, n as ATTACH_WINDOW_KEY, nt as RoomBacklog, o as AccountPinOptions, ot as RoomEnd, p as ConnectAvailability, pt as RoomOpenOptions, q as PickOptions, r as ATTACH_WINDOW_MESSAGE, rt as RoomClaimOptions, s as AddressLookupResult, st as RoomEvent, t as ATTACH_FRAME_KEY, tt as Resolvers, u as ConflictChoice, ut as RoomMailbox, v as EncryptionState, vt as SHELL_ATTACH_ERROR, w as HiddenSurface, wt as ShellControl, x as FrameConsentRequest, xt as SHELL_JAR_MESSAGE, y as FRAME_MESSAGE, yt as SHELL_CONTROL_KEY, z as MiddleGotoOptions, zt as WINDOW_HELLO_TIMEOUT_MS } from "./contract-XlEPwc7b.js";
3
+ import { o as TcpSocketOption, x as UdpSocketOption } from "./wire-Fk5pJaoy.js";
4
+ export { ATTACH_FRAME_KEY, ATTACH_WINDOW_KEY, ATTACH_WINDOW_MESSAGE, Account, AccountChange, AccountPinOptions, AddressLookupResult, AdoptRequest, AdoptState, type ClearCookiesWire, ConflictChoice, ConflictRequest, ConflictSide, ConnectAvailability, ConnectOptions, type CookieMatchWire, DisplayCause, DisplayLevel, DnsLookup, EncryptionState, FRAME_MESSAGE, FrameConsentAnswer, FrameConsentRequest, FrameFetchScope, FrameMessageRelay, HiddenSurface, InstallOptions, InstalledPackage, IpFamily, JAR_ANCHOR_MESSAGE, type JarSeed, type JarSeedCookie, LINK_EXPIRES_MS, Link, LinkCreateOptions, LinkCreateWire, LinkHandle, LinkProgress, LinksErrorCode, LinksFail, ListedLink, MiddleControl, MiddleGotoOptions, 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
@@ -17,22 +17,19 @@ var e = "fkn-attach-frame", t = "fkn-attach-window", n = "sdbx-control", r = "sd
17
17
  "no-token",
18
18
  "no-indexeddb",
19
19
  "failed"
20
- ], l = [
21
- "not-proxy",
22
- "signed-out",
23
- "not-enrolled",
24
- "locked",
25
- "unconfirmed"
26
- ], u = {
20
+ ], l = {
27
21
  hello: "fkn-jar-hello",
28
22
  ready: "fkn-jar-ready",
29
23
  port: "fkn-jar-port",
30
24
  who: "fkn-jar-who",
31
25
  host: "fkn-jar-host"
32
- }, d = 2e4, f = 3e4, p = 6e4, m = {
26
+ }, u = 2e4, d = 3e4, f = 6e4, p = {
33
27
  default: 6048e5,
34
28
  min: 6e4,
35
29
  max: 31536e6
30
+ }, m = {
31
+ min: 6e4,
32
+ max: 31536e6
36
33
  };
37
34
  //#endregion
38
- export { e as ATTACH_FRAME_KEY, t as ATTACH_WINDOW_KEY, o as ATTACH_WINDOW_MESSAGE, i as FRAME_MESSAGE, u as JAR_ANCHOR_MESSAGE, l as PROXY_JAR_REFUSALS, m 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, p as WINDOW_HANDSHAKE_TIMEOUT_MS, d as WINDOW_HELLO_TIMEOUT_MS, f as WINDOW_JAR_MODE_TIMEOUT_MS };
35
+ 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, m as LINK_EXPIRES_MS, 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--LOXTOpv.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.s(`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-DMnVye0K.cjs"),n=require("./busy-BXbVH595.cjs"),r=require("./utils-BpHmMkIR.cjs"),i=require("./wire.cjs");let a=require("buffer"),o=require("events"),s=require("ip-address");var c=e.t({Socket:()=>l,createSocket:()=>h,default:()=>g}),l=class extends o.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:i.UDP_PORT_ACK_TYPE,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,i=0;for(;i+4<=e.byteLength;){let o=t.getUint32(i);i+=4;let s=i+o;if(s>e.byteLength)break;let c=i+4,l=t.getUint8(c);c+=1;let u,d,f;if(l===2){if(!this._remoteAddress){i=s;continue}u=this._remoteAddress.address,d=this._remoteAddress.family,f=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=p(n)),c+=n.byteLength,f=t.getUint16(c),c+=2}let m=t.getUint32(c);c+=4;try{this.emit(`message`,a.Buffer.from(e.slice(c,c+m)),{address:u,family:d,port:f,size:m})}catch(e){n||(n=!0,r=e)}i=s}if(n)throw r}_peerTail(e,t){if(e===void 0||t===void 0)return u;let n=`${e}|${t}`,r=this._peerTailCache.get(n);if(r)return r;let i=s.Address4.isValid(e)?f(e):m(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(s.Address4.isValid(e)){let n=f(e),r=t&&s.Address4.isValid(t)?f(t):new Uint8Array([0,0,0,0]);this._setUdpOption({type:5,group:n,interface:r})}else if(s.Address6.isValid(e)){let t=m(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.i(...e),i=this._type===`udp6`?`::`:`0.0.0.0`,a=this.__webvpn_udp_socket_init__(t.s(`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`,a.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(s.Address4.isValid(e)){let n=f(e),r=t&&s.Address4.isValid(t)?f(t):new Uint8Array([0,0,0,0]);this._setUdpOption({type:6,group:n,interface:r})}else if(s.Address6.isValid(e)){let t=m(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.a(...e),n=d(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,o=this._remoteAddress!==void 0&&t.address===void 0;if(this._dataPort&&(o||s.Address4.isValid(r)||s.Address6.isValid(r))){this._portSend(i,o?void 0:r,o?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)})}},u=new Uint8Array([2]),d=e=>{if(typeof e==`string`)return r.s.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(d),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)},f=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)},p=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(`:`)}`},m=e=>{let t=new s.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)))},h=(e,t)=>{let n=new l(typeof e==`string`?{type:e}:e);return t&&n.on(`message`,t),n},g={Socket:l,createSocket:h};exports.Socket=l,exports.createSocket=h,exports.default=g,Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return c}});
package/dgram.d.ts CHANGED
@@ -1,6 +1,6 @@
1
- import { Mt as UdpSocketResult, X as Resolvers } from "./contract-BmLpSueo.js";
2
- import { v as UdpSocketOption } from "./wire-BwA4JjZH.js";
3
- import "./api-DOXb_WrB.js";
1
+ import { Lt as UdpSocketResult, tt as Resolvers } from "./contract-XlEPwc7b.js";
2
+ import { x as UdpSocketOption } from "./wire-Fk5pJaoy.js";
3
+ import "./api-Cpi-qz1j.js";
4
4
  import { Buffer } from "buffer";
5
5
  import { AddressInfo } from "net";
6
6
  import { EventEmitter } from "events";