@fkn/lib 0.9.71 → 0.9.73
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{account-DFWaytT5.cjs → account-BdwCDacQ.cjs} +1 -1
- package/{account-CXUwroRM.d.ts → account-C9w41S0_.d.ts} +1 -1
- package/{account-DF9jsI5N.js → account-URj9bMMj.js} +2 -2
- package/{account-generation-BsXJ6WWS.cjs → account-generation--7m_60Fl.cjs} +1 -1
- package/{account-generation-C0BizGmy.js → account-generation-DgK9YHiL.js} +1 -1
- package/{account-storage-B7QBr9aX.cjs → account-storage-CQ8k71N3.cjs} +1 -1
- package/{account-storage-Jgp8ycMy.js → account-storage-CcdeHbnj.js} +2 -2
- package/account.cjs +1 -1
- package/account.d.ts +2 -2
- package/account.js +1 -1
- package/api-BORAfb8e.cjs +3 -0
- package/{api-dxNQsC_v.js → api-De7vAubY.js} +117 -109
- package/{api-DhwJz0vo.d.ts → api-iKK1u-V0.d.ts} +25 -1
- package/api.cjs +1 -1
- package/api.d.ts +2 -2
- package/api.js +1 -1
- package/{broker-frame-BClLp2ZV.js → broker-frame-AQDD3D9E.js} +1 -1
- package/{broker-frame-BKHtDSjv.cjs → broker-frame-cVEhez7A.cjs} +1 -1
- package/broker-frame.cjs +1 -1
- package/broker-frame.js +1 -1
- package/cloud/dgram.cjs +1 -1
- package/cloud/dgram.d.ts +1 -1
- package/cloud/dgram.js +1 -1
- package/cloud/dns.cjs +1 -1
- package/cloud/dns.d.ts +2 -2
- package/cloud/dns.js +1 -1
- package/cloud/fetch.cjs +1 -1
- package/cloud/fetch.d.ts +1 -1
- package/cloud/fetch.js +1 -1
- package/cloud/fs/promises.cjs +1 -1
- package/cloud/fs/promises.js +1 -1
- package/cloud/fs.cjs +1 -1
- package/cloud/fs.js +2 -2
- package/cloud/http.cjs +1 -1
- package/cloud/http.d.ts +1 -1
- package/cloud/http.js +1 -1
- package/cloud/net.cjs +1 -1
- package/cloud/net.d.ts +1 -1
- package/cloud/net.js +1 -1
- package/{cloud-DRfcPLdB.d.ts → cloud-BDTtnMtj.d.ts} +5 -5
- package/{cloud-pJ8R_Dmx.cjs → cloud-Buku7KQJ.cjs} +1 -1
- package/{cloud-CyU_k-d9.js → cloud-Bv_GUwcG.js} +120 -120
- package/cloud.cjs +1 -1
- package/cloud.d.ts +6 -6
- package/cloud.js +7 -7
- package/{contract-CDdIE_Es.d.ts → contract-Cqq1vOqF.d.ts} +35 -1
- package/contract.cjs +1 -1
- package/contract.d.ts +2 -2
- package/contract.js +2 -2
- package/{dgram-BPXm8haL.cjs → dgram-BgWDRjw-.cjs} +1 -1
- package/{dgram-CPQqam5Z.d.ts → dgram-BggVwnRp.d.ts} +3 -3
- package/{dgram-B14T5Lqo.js → dgram-CYegbMMa.js} +1 -1
- package/dgram.cjs +1 -1
- package/dgram.d.ts +1 -1
- package/dgram.js +1 -1
- package/{dns-DlTvtfVk.cjs → dns-CtxN7cCj.cjs} +1 -1
- package/{dns-BQkSttLP.js → dns-DTbLD2s6.js} +1 -1
- package/{dns-_NCe2YLS.d.ts → dns-DeuTGd8C.d.ts} +1 -1
- package/dns.cjs +1 -1
- package/dns.d.ts +2 -2
- package/dns.js +1 -1
- package/{extension-Ce1wlb_F.js → extension-0RxQ4Bor.js} +9 -9
- package/{extension-veLhWipR.cjs → extension-DHx7sHE4.cjs} +1 -1
- package/extension.cjs +1 -1
- package/extension.js +2 -2
- package/fs/promises.cjs +1 -1
- package/fs/promises.js +1 -1
- package/{fs-DxECe50Z.cjs → fs-1Q6VCx3d.cjs} +1 -1
- package/{fs-DJ4wpfml.js → fs-BJdr72O6.js} +1 -1
- package/{fs-DgPbKycT.cjs → fs-BPfRlX_R.cjs} +1 -1
- package/{fs-sR6cw1ay.js → fs-C0RZ54fk.js} +3 -3
- package/fs.cjs +1 -1
- package/fs.js +2 -2
- package/{http-aUVH9bBn.js → http-D-rs8b6m.js} +1 -1
- package/{http-hIJh5XTX.cjs → http-DkvhaPVT.cjs} +1 -1
- package/{http-rzQOrCmq.d.ts → http-LhyEQ2D8.d.ts} +1 -1
- package/http.cjs +1 -1
- package/http.d.ts +1 -1
- package/http.js +1 -1
- package/index.cjs +1 -1
- package/index.d.ts +11 -11
- package/index.js +13 -13
- package/{lib-6lykV0aT.js → lib-B4Th0aXQ.js} +514 -508
- package/lib-By2YAF1s.cjs +53 -0
- package/{net-DUyZ7_3E.cjs → net-B3SziNT3.cjs} +1 -1
- package/{net-B4IqLeN8.d.ts → net-CK_1P9_C.d.ts} +3 -3
- package/{net-DVYOBov-.js → net-C_R3PDi7.js} +1 -1
- package/net.cjs +1 -1
- package/net.d.ts +1 -1
- package/net.js +1 -1
- package/package.json +6 -1
- package/{packages-BTDKiQyC.cjs → packages-BwD1QMOz.cjs} +1 -1
- package/{packages-XWRhSAUe.js → packages-CNXf-8A8.js} +1 -1
- package/{packages-SwO4CxMl.d.ts → packages-FCSR6WEw.d.ts} +1 -1
- package/packages.cjs +1 -1
- package/packages.d.ts +2 -2
- package/packages.js +1 -1
- package/proxy-CgISk6T6.cjs +1 -0
- package/proxy-OrF-WHyi.js +81 -0
- package/{proxy-CzP07me0.d.ts → proxy-Xe45WiQU.d.ts} +2 -2
- package/{relay-choice-DB1F7bcn.d.ts → relay-choice-BhdjlopH.d.ts} +1 -1
- package/{rooms-CZZfCZRv.cjs → rooms-B_sM_Z93.cjs} +1 -1
- package/{rooms-CYP8Bf6L.js → rooms-Dz13jhtS.js} +1 -1
- package/{rooms-3XplwXzb.d.ts → rooms-lJGFgMXH.d.ts} +1 -1
- package/rooms.cjs +1 -1
- package/rooms.d.ts +2 -2
- package/rooms.js +1 -1
- package/{storage-DtynxQDJ.cjs → storage-B49NeC-h.cjs} +1 -1
- package/{storage-d61R3-P1.js → storage-Dd3miXPI.js} +3 -3
- package/{storage-C38adB-z.d.ts → storage-ngeijVxI.d.ts} +1 -1
- package/storage.cjs +1 -1
- package/storage.d.ts +2 -2
- package/storage.js +1 -1
- package/websocket.cjs +1 -0
- package/websocket.d.ts +48 -0
- package/websocket.js +179 -0
- package/api-b88Y1QDE.cjs +0 -3
- package/lib-C1OPIW6F.cjs +0 -53
- package/proxy-BOHZkjk-.js +0 -61
- package/proxy-vI5LhXLv.cjs +0 -1
package/cloud/fetch.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as cloudFetch } from "../proxy-
|
|
1
|
+
import { t as cloudFetch } from "../proxy-Xe45WiQU.js";
|
|
2
2
|
export { cloudFetch as fetch };
|
package/cloud/fetch.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as fetch } from "../proxy-
|
|
1
|
+
export { t as fetch } from "../proxy-OrF-WHyi.js";
|
package/cloud/fs/promises.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var{readFile:e,writeFile:t,unlink:n,rename:r,readdir:i,mkdir:a,rm:o,rmdir:s,stat:c,lstat:l,access:u}=require("../../fs-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});var{readFile:e,writeFile:t,unlink:n,rename:r,readdir:i,mkdir:a,rm:o,rmdir:s,stat:c,lstat:l,access:u}=require("../../fs-1Q6VCx3d.cjs").a;exports.access=u,exports.lstat=l,exports.mkdir=a,exports.readFile=e,exports.readdir=i,exports.rename=r,exports.rm=o,exports.rmdir=s,exports.stat=c,exports.unlink=n,exports.writeFile=t;
|
package/cloud/fs/promises.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { a as e } from "../../fs-
|
|
1
|
+
import { a as e } from "../../fs-BJdr72O6.js";
|
|
2
2
|
// src/cloud/fs-promises.ts
|
|
3
3
|
var { readFile: t, writeFile: n, unlink: r, rename: i, readdir: a, mkdir: o, rm: s, rmdir: c, stat: l, lstat: u, access: d } = e;
|
|
4
4
|
export { d as access, u as lstat, o as mkdir, t as readFile, a as readdir, i as rename, s as rm, c as rmdir, l as stat, r as unlink, n as writeFile };
|
package/cloud/fs.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../messages.cjs"),t=require("../account-storage-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("../messages.cjs"),t=require("../account-storage-CQ8k71N3.cjs"),n=require("../fs-1Q6VCx3d.cjs");exports.STORAGE_ACCOUNT_CHANGED=e.STORAGE_ACCOUNT_CHANGED,exports.STORAGE_ACCOUNT_PIN_UNSUPPORTED=e.STORAGE_ACCOUNT_PIN_UNSUPPORTED,exports.STORAGE_NOT_FOUND=e.STORAGE_NOT_FOUND,exports.StorageAccountChangedError=t.t,exports.StorageAccountPinUnsupportedError=t.n,exports.StorageLockedError=t.r,exports.StorageNotFoundError=t.i,exports.availability=t.o,exports.available=n.t,exports.encryption=t.c,exports.isAccountChanged=t.l,exports.isNotFound=t.d,exports.list=n.r,exports.mkdir=n.i,exports.promises=n.a,exports.quota=t.h,exports.readFile=n.o,exports.readFileSealed=n.s,exports.readdir=n.c,exports.rename=n.l,exports.rm=n.u,exports.stat=n.d,exports.unlink=n.f,exports.unlock=t.y,exports.writeFile=n.p;
|
package/cloud/fs.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
1
|
import { STORAGE_ACCOUNT_CHANGED as e, STORAGE_ACCOUNT_PIN_UNSUPPORTED as t, STORAGE_NOT_FOUND as n } from "../messages.js";
|
|
2
|
-
import { c as r, d as i, h as a, i as o, l as s, n as c, o as l, r as u, t as d, y as f } from "../account-storage-
|
|
3
|
-
import { a as p, c as m, d as h, f as g, i as _, l as v, o as y, p as b, r as x, s as S, t as C, u as w } from "../fs-
|
|
2
|
+
import { c as r, d as i, h as a, i as o, l as s, n as c, o as l, r as u, t as d, y as f } from "../account-storage-CcdeHbnj.js";
|
|
3
|
+
import { a as p, c as m, d as h, f as g, i as _, l as v, o as y, p as b, r as x, s as S, t as C, u as w } from "../fs-BJdr72O6.js";
|
|
4
4
|
export { e as STORAGE_ACCOUNT_CHANGED, t as STORAGE_ACCOUNT_PIN_UNSUPPORTED, n as STORAGE_NOT_FOUND, d as StorageAccountChangedError, c as StorageAccountPinUnsupportedError, u as StorageLockedError, o as StorageNotFoundError, l as availability, C as available, r as encryption, s as isAccountChanged, i as isNotFound, x as list, _ as mkdir, p as promises, a as quota, y as readFile, S as readFileSealed, m as readdir, v as rename, w as rm, h as stat, g as unlink, f as unlock, b as writeFile };
|
package/cloud/http.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../http-
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../http-DkvhaPVT.cjs");exports.Agent=e.t,exports.ClientRequest=e.n,exports.HTTPParser=e.r,exports.IncomingMessage=e.i,exports.METHODS=e.a,exports.STATUS_CODES=e.o,exports.Server=e.s,exports.ServerResponse=e.c,exports._default=e.l,exports.default=e.l,exports.createServer=e.u,exports.get=e.d,exports.globalAgent=e.f,exports.request=e.m;
|
package/cloud/http.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as IncomingMessage, c as RequestListener, d as ServerResponse, f as ServerResponseOptions, g as globalAgent, h as get, i as HTTPParser, l as STATUS_CODES, m as createServer, n as ClientRequest, o as METHODS, p as _default, r as ClientRequestArgs, s as ParsedHead, t as Agent, u as Server, v as request } from "../http-
|
|
1
|
+
import { a as IncomingMessage, c as RequestListener, d as ServerResponse, f as ServerResponseOptions, g as globalAgent, h as get, i as HTTPParser, l as STATUS_CODES, m as createServer, n as ClientRequest, o as METHODS, p as _default, r as ClientRequestArgs, s as ParsedHead, t as Agent, u as Server, v as request } from "../http-LhyEQ2D8.js";
|
|
2
2
|
export { Agent, ClientRequest, ClientRequestArgs, HTTPParser, IncomingMessage, METHODS, ParsedHead, RequestListener, STATUS_CODES, Server, ServerResponse, ServerResponseOptions, _default, _default as default, createServer, get, globalAgent, request };
|
package/cloud/http.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export { t as Agent, n as ClientRequest, r as HTTPParser, i as IncomingMessage, a as METHODS, o as STATUS_CODES, s as Server, c as ServerResponse, l as _default, l as default, u as createServer, d as get, f as globalAgent, m as request } from "../http-
|
|
1
|
+
export { t as Agent, n as ClientRequest, r as HTTPParser, i as IncomingMessage, a as METHODS, o as STATUS_CODES, s as Server, c as ServerResponse, l as _default, l as default, u as createServer, d as get, f as globalAgent, m as request } from "../http-D-rs8b6m.js";
|
package/cloud/net.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../utils-BpHmMkIR.cjs"),t=require("../net-
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../utils-BpHmMkIR.cjs"),t=require("../net-B3SziNT3.cjs");exports.Server=t.t,exports.Socket=t.n,exports._default=t.r,exports.default=t.r,exports.connect=t.i,exports.createConnection=t.a,exports.createServer=t.o,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-
|
|
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-CK_1P9_C.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
1
|
import { n as e, r as t, t as n } from "../utils-DtWP-E9x.js";
|
|
2
|
-
import { a as r, i, n as a, o, r as s, t as c } from "../net-
|
|
2
|
+
import { a as r, i, n as a, o, r as s, t as c } from "../net-C_R3PDi7.js";
|
|
3
3
|
export { c as Server, a as Socket, s as _default, s as default, i as connect, r as createConnection, o as createServer, n as isIP, e as isIPv4, t as isIPv6 };
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { r as AttachFrameFunction } from "./index-HMfzm6dF.js";
|
|
2
|
-
import { t as cloudFetch } from "./proxy-
|
|
3
|
-
import { t as dns_d_exports } from "./dns-
|
|
2
|
+
import { t as cloudFetch } from "./proxy-Xe45WiQU.js";
|
|
3
|
+
import { t as dns_d_exports } from "./dns-DeuTGd8C.js";
|
|
4
4
|
import { n as fs_d_exports } from "./fs-ChOYC6VD.js";
|
|
5
|
-
import { s as net_d_exports } from "./net-
|
|
6
|
-
import { i as dgram_d_exports } from "./dgram-
|
|
7
|
-
import { _ as http_d_exports } from "./http-
|
|
5
|
+
import { s as net_d_exports } from "./net-CK_1P9_C.js";
|
|
6
|
+
import { i as dgram_d_exports } from "./dgram-BggVwnRp.js";
|
|
7
|
+
import { _ as http_d_exports } from "./http-LhyEQ2D8.js";
|
|
8
8
|
/**
|
|
9
9
|
* Attaches the render proxy to an iframe the app mounted, or opens it in a window of its own with
|
|
10
10
|
* `{ window }`. A window opens before the first await, so call this directly in a click handler.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./lib-C1OPIW6F.cjs"),n=require("./hosts-GNBhZO3-.cjs"),r=require("./broker-frame-BKHtDSjv.cjs"),i=require("./api-b88Y1QDE.cjs"),a=require("./busy-BXbVH595.cjs"),o=require("./contract.cjs"),s=require("./relay-choice-JC_JJY_M.cjs"),c=require("./proxy-vI5LhXLv.cjs"),l=require("./attach-policy.cjs"),u=require("./dns-DlTvtfVk.cjs"),d=require("./fs-DxECe50Z.cjs"),f=require("./net-DUyZ7_3E.cjs"),p=require("./dgram-BPXm8haL.cjs"),m=require("./http-hIJh5XTX.cjs");let h=require("osra");var g=async()=>{let e=()=>i.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 i.n))throw t;return{request:void 0,ensure:t=>e().then(e=>e.frameConsent.ensure(t))}}},_=`frame: this frame no longer holds the document the app attached it to`,v=!1,y=()=>{v||(v=!0,console.warn(`[fkn-frame] this FKN broker is too old to ask for permission categories, so nothing was asked for upfront and each capability is asked for as it is first used. Reloading the page picks up the current broker.`))},b=e=>[...e].flatMap(e=>{try{return[new URL(e).hostname]}catch{return[]}}),x=e=>typeof e?.reason==`string`?{reason:e.reason}:{},S=(e,t,n)=>n===null?`frame.${e}: the user did not grant ${t} here`:`frame.${e}: the user did not grant ${t} on ${n}`,C=e=>{let{assertLive:r,attach:i,consent:a,current:o,declaredHosts:s,documentHost:c,freshBlank:u,session:d,approvedOrigins:f}=e,p=new Set,m=()=>{try{return new URL(o()).hostname}catch{return``}},h=async()=>c?await c():m(),g=()=>n.t([...s,...b(f)]),v=async(e,t)=>(await e([t]))[0]??!1;return{gate:async({operation:e,args:o,phase:c})=>{r();let y=n.m(e,o);if(y===null)return;let b=t.h(y);if(b===void 0||b===`auto`)return;if(e===`fetch`){let e=l.frameFetchVerdict({session:d,declaredHosts:s,approvedOrigins:f},c===`ensure`?void 0:o[0],{classifier:`fetchTarget`});if(c===`ensure`&&!d)throw t.k(e.kind===`refuse`?e.reason:``,`fetch`);if(c!==`ensure`&&e.kind===`refuse`)throw t.k(e.reason,`fetch`);let{request:r,ensure:i}=await a();if(!r){if(e.kind===`refuse`)throw t.k(e.reason,`fetch`);if(!await i({scope:n.c(o[0],o[1]).scope,hosts:e.promptHosts}))throw t.k(`frame.fetch: the user did not grant this`,`fetch`);return}let u=e.kind===`consent`?e.targetHost:await h(),p=n.t([u,...s]);if(!p.length)throw t.k(`frame: navigate the frame before fetch`,`fetch`);if(await v(r,{category:`network`,hosts:p,...x(t.T(o))})===!1)throw t.k(S(`fetch`,`network`,u||null),`fetch`);return}let C=await h();if(!C)throw t.k(`frame: navigate the frame before ${e}`,e);if(!g().includes(C))throw t.k(_,e);let w=t.m(y);if(w===void 0||w===`evaluation`&&C===m()&&await u?.()||b===`critical`&&p.has(`${y} ${C}`))return;let{request:T}=await a();if(!T)return;let E=n.t([C,...s]),D=x(t.T(o)),O=b===`critical`?{key:y,hosts:E,attach:i,...D}:{category:w,hosts:E,...D},k=await v(T,O);if(k===!1)throw t.k(S(e,w,null),e);if(k===`once`&&c!==`ensure`)for(let e of E)p.add(`${y} ${e}`)},requestCategories:async e=>{r(),t.f(`frame.requestPermissions`,e);let o=await h(),c=n.t(o?[o,...s]:s);if(!c.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:c,allow:r}),{request:d}=await a();if(!d)return y(),l.map(e=>u(e,!1));let f=await d(l.map(({named:t,critical:n,category:r},a)=>{let o=x(e[a]);return n?{key:t,hosts:c,attach:i,...o}:{category:r,hosts:c,...o}}));return l.map((e,t)=>u(e,f[t]!==void 0&&f[t]!==!1))},boundary:g}},w=e=>e,T=5e3,E=new Set([]),D=()=>`https://fkn.app`,O=e=>e===`persistent`?``:`incognito-${crypto.randomUUID()}`,k=(e,n,r)=>{let i,a=new Promise((e,a)=>{i=setTimeout(()=>a(typeof r==`string`?new t.E(r):r()),n)});return Promise.race([e,a]).finally(()=>clearTimeout(i))},A=e=>Object.assign(Error(e),{name:t.D}),j=`frame.postMessage: this FKN page predates frame messaging; reload the app to load the current one`,M=`frame.addScriptTag: this render proxy predates addScriptTag; reload the app`,N=`frame.addScriptTag: no answer within ${t.l}ms; the script may or may not have run`,P=`frame.clearCookies: this FKN page predates clearCookies; reload the app to load the current one`,F=`frame.clearCookies: this attachment reaches no site yet; attach a url, goto one, or declare it in domains`,I=3e4,L=`attachFrame: this FKN page predates storageState; reload the app to load the current one`,R=2e4,z=async(e,n)=>{if(typeof e.seed!=`function`)throw t.N(L,`storageState`,`cloud`);try{await k(e.seed(n),R,`attachFrame: the render proxy did not take the storageState seed`)}catch(e){throw t.O(e)?t.N(L,`storageState`,`cloud`):e}},B=`frame.clearCookies: the render proxy did not answer within ${I}ms; the cookies may or may not be gone, and calling it again is safe`,V=e=>t.O(e)&&e.message===t.j(`addScriptTag`).message,H=!1,ee=()=>{H||(H=!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.`))},U=({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)},te=e=>{if(typeof e!=`function`)return()=>Promise.resolve(e);let t=null;return()=>t??=e().catch(e=>{throw t=null,e})},W=({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!==``,h=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},g=Promise.resolve(),{gate:v,requestCategories:y,boundary:b}=C({session:i,declaredHosts:a,approvedOrigins:o,attach:s,assertLive:c,documentHost:typeof e.documentHost==`function`?()=>l(()=>e.documentHost()):void 0,current:()=>p,consent:te(u),freshBlank:h});return t.y({backend:`cloud`,executor:{execute:(n,r,i)=>E.has(r)?Promise.reject(t.j(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],phase:`execute`}),k(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 k(l(()=>e.executeLocator([],`addScriptTag`,i)),t.l,N)}catch(e){throw V(e)?t.N(M,`addScriptTag`,`cloud`):e}},clearCookies:async n=>{if(c(),typeof e.clearCookies!=`function`)throw t.N(P,`clearCookies`,`cloud`);if(b().length===0)throw t.k(F,`clearCookies`);await k(l(()=>e.clearCookies(n)),I,B)},postMessage:(n,r,i)=>{if(c(),typeof e.messaging!=`function`)throw t.N(j,`postMessage`,`cloud`);if(r!==`*`&&!b().includes(new URL(r).hostname))throw t.k(_,`postMessage`);let{port1:a,port2:o}=new MessageChannel;a.postMessage({data:n,transfer:i},i);let s=[o,r],u=g.then(async()=>(await v({parts:[],operation:`postMessage`,args:s,phase:`execute`}),{answer:l(()=>e.executeLocator([],`postMessage`,s))}));return g=u.catch(()=>{}),u.then(async({answer:e})=>{await e})},listen:t=>(typeof e.messaging!=`function`&&ee(),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 k(l(()=>e.goto(a,r===void 0?i:{...i,timeoutMs:r})),(r??3e4)+T,`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})},G=async e=>{if(e===void 0){let e=await i.s(`a relay`).catch(()=>void 0);if(typeof e?.relay?.resolve!=`function`)return;let t=await e.relay.resolve().catch(()=>void 0);return t&&`id`in t?t.id:void 0}let t=await i.s(`a relay choice`);s.t(t,`attachFrame`);let n=await t.relay.resolve(e);if(`refused`in n)throw s.i(`attachFrame: ${n.refused}`);return n.id},K=async(e,t)=>{if((typeof e.relay==`function`?await e.relay():``)!==t)throw s.i(`attachFrame: ${o.RELAY_CHOICE_UNSUPPORTED}`)},ne=250,re=500,q=65e3,ie=2e3,ae=2e3,oe=2,se=2e3,ce=2e3,le=({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},ue=(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})},J=()=>A(`cloud.attachFrame: the attached window closed, reloaded or left the page FKN attached; attach a fresh window`),Y=()=>A(`cloud.attachFrame: the attached window stopped answering; attach a fresh window`),fe=()=>A(`cloud.attachFrame: the window went away before it connected; attach a fresh window`),pe=()=>A(`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,i)=>{if(typeof window>`u`)throw Error(`cloud.attachFrame needs a window realm`);let{domains:c=[],permissions:l,relay:u}=e,{url:d,width:f,height:p}=t.s(e.window);if(window.origin===`null`)throw new t._(`opaque-opener`);let m=D(),g=crypto.randomUUID(),_=O(r),v=n.t(c),y=new Set;d&&y.add(new URL(d).origin);let b=r===`persistent`?ue(m,g):null,x=window.open(le({origin:m,target:i===void 0?d:``,session:_,domains:v,attach:g}),`_blank`,`popup,width=${f},height=${p}`);if(!x)throw b?.remove(),new t.g;let S=new AbortController,C=!1,T=null,E=(e,t=!1)=>{if(T===null){T=e,S.abort(t?Y():J());try{x.closed||x.postMessage({type:o.ATTACH_WINDOW_MESSAGE.detach,attach:g,...t?{unanswered:t}:{}},m)}catch{}b&&setTimeout(()=>b.remove(),ce)}};b&&de(b,S.signal);let A=new Promise((e,t)=>{S.signal.addEventListener(`abort`,()=>t(S.signal.reason),{once:!0})});A.catch(()=>{});let j=A.then(()=>{},()=>{}),M=()=>{if(S.signal.aborted)throw S.signal.reason},N=e=>S.signal.aborted?Promise.reject(S.signal.reason):Promise.race([e(),A]),P=e=>e.source===x&&e.origin===m;window.addEventListener(`message`,e=>{let n=e.source===null&&e.origin===m;if(!P(e)&&!n)return;let r=e.data;typeof r==`object`&&r&&r.attach===g&&(r.type===o.ATTACH_WINDOW_MESSAGE.gone?E(C?J():fe()):r.type===o.ATTACH_WINDOW_MESSAGE.refused&&!n&&E(new t._(r.reason)))},{signal:S.signal}),window.addEventListener(`pagehide`,()=>E(J()),{signal:S.signal});let F=G(u),I,L,R=()=>{let e=()=>{try{x.postMessage({type:o.ATTACH_WINDOW_MESSAGE.hello,attach:g,...I?{relay:I}:{}},m)}catch{}};e(),L=setInterval(e,ne)};u===void 0&&R();let B=setInterval(()=>{x.closed&&E(C?J():pe())},re);S.signal.addEventListener(`abort`,()=>{clearInterval(L),clearInterval(B)},{once:!0});let V=async e=>{try{return await Promise.race([e,A])}catch(e){throw T??e}};try{u!==void 0&&(I=await V(F),R());let e=await V(k((0,h.expose)({},{key:o.ATTACH_WINDOW_KEY,transport:{emit:(e,t)=>x.postMessage(e,m,t??[]),receive:e=>{let t=t=>{P(t)&&e(t.data,{source:t.source,origin:t.origin})};return window.addEventListener(`message`,t),()=>window.removeEventListener(`message`,t)}},unregisterSignal:S.signal,revivableModules:w(t.ft)}),o.WINDOW_HANDSHAKE_TIMEOUT_MS,`cloud.attachFrame: timed out connecting to the window`));C=!0,clearInterval(L);let n=0,r=setInterval(()=>{k(N(()=>e.ping()),ae,`ping`).then(()=>{n=0},()=>{S.signal.aborted||(document.visibilityState===`hidden`?n=0:++n>=oe&&E(Y(),!0))})},ie);S.signal.addEventListener(`abort`,()=>clearInterval(r),{once:!0}),I&&await V(k(K(e,I),q,`cloud.attachFrame: the window never became ready`)),await V(k(e.ready(),q,`cloud.attachFrame: the window never became ready`)),i!==void 0&&await V(z(e,i)),a.r(`attached frame`,S.signal);let c=W({control:e,target:d,session:_,declaredHosts:v,approvedOrigins:y,attach:g,assertLive:M,guard:N,consent:{request:t=>N(()=>e.requestConsent(t)),ensure:t=>N(()=>e.requestConsent([t])).then(([e])=>e!==void 0&&e!==!1)},onNavigated:()=>{},relay:U({from:()=>x,origin:m,attach:g,signal:S.signal})}),f=null,p=Object.assign(c,{close:()=>f??=(async()=>{S.signal.aborted||await k(Promise.allSettled([N(()=>e.flushCookies()),N(()=>e.sweepStorage())]),se,`close`).catch(()=>{});try{x.close()}catch{}E(J())})(),closed:j});return I?s.a(p,I):F.then(e=>s.a(p,e)),i!==void 0&&d&&await V(p.goto(d)),l?.length&&await V(p.requestPermissions(l)),p}catch(e){let n=T??e;if(!(n instanceof t._))try{x.close()}catch{}throw E(n),n}},he=2e4,X=65e3,Z=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]??``,$=({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(!Z(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),!Oe())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,relay:a})=>{let o=new URL(`/attach-frame`,D());return t?o.searchParams.set(`blank`,t):e&&o.searchParams.set(`url`,e),n&&o.searchParams.set(`session`,n),r.length&&o.searchParams.set(`domains`,r.join(`,`)),o.searchParams.set(`attach`,i),a&&o.searchParams.set(`relay`,a),o.href},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=()=>A(`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],Ce=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)},we=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`)},Te=async(e,n)=>{let r=typeof e.blank==`function`?await k(e.blank(),X,`cloud.attachFrame: the render proxy never became ready`):``;if(typeof r!=`string`||Q(r)!==Q(n))throw t.N(ge,`blank`,`cloud`)},Ee=async(e,i,c)=>{let l=$(e),{iframe:u,domains:d=[],permissions:f,relay:p}=e;if(typeof window>`u`)throw Error(`cloud.attachFrame needs a window realm`);if(!u.isConnected)throw Error(`cloud.attachFrame: the iframe must be connected to the document before attaching`);we(u);let m=u.getAttribute(`src`)??``,_=(()=>{if(Z(m))return null;try{return new URL(u.src||m,location.href)}catch{throw Error(`cloud.attachFrame: the iframe src is not a valid URL: ${m}`)}})();if(_){let e=new URL(`/attach-frame`,D());if(_.origin===e.origin&&_.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 v=_?.href??``;v&&t.x(v);let y=c===void 0?v:``,b=O(i),x=n.t(d),S=new Set;try{S.add(new URL(l||v).origin)}catch{}let C=G(p),T=p===void 0?void 0:await C,E=new AbortController,A=u.referrerPolicy,j=u.allow,M=crypto.randomUUID();if(u.referrerPolicy=`origin`,u.allow=xe(r.i(),u.allow),u.src=ve({target:y,blank:l,session:b,domains:x,attach:M,relay:T}),!u.contentWindow)throw Error(`cloud.attachFrame: the iframe window is not available`);try{let e=await k((0,h.expose)({},{key:o.ATTACH_FRAME_KEY,origin:D(),transport:{receive:window,emit:u.contentWindow},unregisterSignal:E.signal,revivableModules:w(t.ft)}),he,`cloud.attachFrame: timed out connecting to the render proxy page`);T&&await k(K(e,T),X,`cloud.attachFrame: the render proxy never became ready`),await k(e.ready(),X,`cloud.attachFrame: the render proxy never became ready`),l&&await Te(e,l),c!==void 0&&await z(e,c),(v||l)&&Ce(u),ye(u,()=>E.abort()),a.r(`attached frame`,E.signal);let n=u.contentWindow,r=W({control:e,target:l||v,blank:l!==``,session:b,declaredHosts:x,approvedOrigins:S,attach:M,assertLive:()=>{if(E.signal.aborted||!u.isConnected||u.contentWindow!==n)throw E.abort(),be()},guard:e=>e(),consent:g,onNavigated:()=>Ce(u),relay:U({from:()=>n,origin:D(),attach:M,signal:E.signal})});return T?s.a(r,T):C.then(e=>s.a(r,e)),c!==void 0&&v&&await r.goto(v),f?.length&&await r.requestPermissions(f),r}catch(e){throw E.abort(),u.referrerPolicy=A,u.allow=j,u.src=y||`about:blank`,e}},De=(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):Ee(e,r,i)}),Oe=()=>typeof window<`u`&&!0,ke=async()=>{let e=await i.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}},Ae=e.t({attachFrame:()=>De,available:()=>je,dgram:()=>p.i,dns:()=>u.t,fetch:()=>c.t,fs:()=>d.n,http:()=>m.p,net:()=>f.s,quota:()=>ke}),je=()=>i.l;Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return $}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return De}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return je}});
|
|
1
|
+
const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./lib-By2YAF1s.cjs"),n=require("./proxy-CgISk6T6.cjs"),r=require("./hosts-GNBhZO3-.cjs"),i=require("./broker-frame-cVEhez7A.cjs"),a=require("./api-BORAfb8e.cjs"),o=require("./busy-BXbVH595.cjs"),s=require("./contract.cjs"),c=require("./relay-choice-JC_JJY_M.cjs"),l=require("./attach-policy.cjs"),u=require("./dns-CtxN7cCj.cjs"),d=require("./fs-1Q6VCx3d.cjs"),f=require("./net-B3SziNT3.cjs"),p=require("./dgram-BgWDRjw-.cjs"),m=require("./http-DkvhaPVT.cjs");let h=require("osra");var g=async()=>{let e=()=>a.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 a.n))throw t;return{request:void 0,ensure:t=>e().then(e=>e.frameConsent.ensure(t))}}},_=`frame: this frame no longer holds the document the app attached it to`,v=!1,y=()=>{v||(v=!0,console.warn(`[fkn-frame] this FKN broker is too old to ask for permission categories, so nothing was asked for upfront and each capability is asked for as it is first used. Reloading the page picks up the current broker.`))},b=e=>[...e].flatMap(e=>{try{return[new URL(e).hostname]}catch{return[]}}),x=e=>typeof e?.reason==`string`?{reason:e.reason}:{},S=(e,t,n)=>n===null?`frame.${e}: the user did not grant ${t} here`:`frame.${e}: the user did not grant ${t} on ${n}`,C=e=>{let{assertLive:n,attach:i,consent:a,current:o,declaredHosts:s,documentHost:c,freshBlank:u,session:d,approvedOrigins:f}=e,p=new Set,m=()=>{try{return new URL(o()).hostname}catch{return``}},h=async()=>c?await c():m(),g=()=>r.t([...s,...b(f)]),v=async(e,t)=>(await e([t]))[0]??!1;return{gate:async({operation:e,args:o,phase:c})=>{n();let y=r.m(e,o);if(y===null)return;let b=t.h(y);if(b===void 0||b===`auto`)return;if(e===`fetch`){let e=l.frameFetchVerdict({session:d,declaredHosts:s,approvedOrigins:f},c===`ensure`?void 0:o[0],{classifier:`fetchTarget`});if(c===`ensure`&&!d)throw t.k(e.kind===`refuse`?e.reason:``,`fetch`);if(c!==`ensure`&&e.kind===`refuse`)throw t.k(e.reason,`fetch`);let{request:n,ensure:i}=await a();if(!n){if(e.kind===`refuse`)throw t.k(e.reason,`fetch`);if(!await i({scope:r.c(o[0],o[1]).scope,hosts:e.promptHosts}))throw t.k(`frame.fetch: the user did not grant this`,`fetch`);return}let u=e.kind===`consent`?e.targetHost:await h(),p=r.t([u,...s]);if(!p.length)throw t.k(`frame: navigate the frame before fetch`,`fetch`);if(await v(n,{category:`network`,hosts:p,...x(t.T(o))})===!1)throw t.k(S(`fetch`,`network`,u||null),`fetch`);return}let C=await h();if(!C)throw t.k(`frame: navigate the frame before ${e}`,e);if(!g().includes(C))throw t.k(_,e);let w=t.m(y);if(w===void 0||w===`evaluation`&&C===m()&&await u?.()||b===`critical`&&p.has(`${y} ${C}`))return;let{request:T}=await a();if(!T)return;let E=r.t([C,...s]),D=x(t.T(o)),O=b===`critical`?{key:y,hosts:E,attach:i,...D}:{category:w,hosts:E,...D},k=await v(T,O);if(k===!1)throw t.k(S(e,w,null),e);if(k===`once`&&c!==`ensure`)for(let e of E)p.add(`${y} ${e}`)},requestCategories:async e=>{n(),t.f(`frame.requestPermissions`,e);let o=await h(),c=r.t(o?[o,...s]:s);if(!c.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:c,allow:r}),{request:d}=await a();if(!d)return y(),l.map(e=>u(e,!1));let f=await d(l.map(({named:t,critical:n,category:r},a)=>{let o=x(e[a]);return n?{key:t,hosts:c,attach:i,...o}:{category:r,hosts:c,...o}}));return l.map((e,t)=>u(e,f[t]!==void 0&&f[t]!==!1))},boundary:g}},w=e=>e,T=5e3,E=new Set([]),D=()=>`https://fkn.app`,O=e=>e===`persistent`?``:`incognito-${crypto.randomUUID()}`,k=(e,n,r)=>{let i,a=new Promise((e,a)=>{i=setTimeout(()=>a(typeof r==`string`?new t.E(r):r()),n)});return Promise.race([e,a]).finally(()=>clearTimeout(i))},A=e=>Object.assign(Error(e),{name:t.D}),j=`frame.postMessage: this FKN page predates frame messaging; reload the app to load the current one`,M=`frame.addScriptTag: this render proxy predates addScriptTag; reload the app`,N=`frame.addScriptTag: no answer within ${t.l}ms; the script may or may not have run`,P=`frame.clearCookies: this FKN page predates clearCookies; reload the app to load the current one`,F=`frame.clearCookies: this attachment reaches no site yet; attach a url, goto one, or declare it in domains`,I=3e4,L=`attachFrame: this FKN page predates storageState; reload the app to load the current one`,R=2e4,z=async(e,n)=>{if(typeof e.seed!=`function`)throw t.N(L,`storageState`,`cloud`);try{await k(e.seed(n),R,`attachFrame: the render proxy did not take the storageState seed`)}catch(e){throw t.O(e)?t.N(L,`storageState`,`cloud`):e}},B=`frame.clearCookies: the render proxy did not answer within ${I}ms; the cookies may or may not be gone, and calling it again is safe`,V=e=>t.O(e)&&e.message===t.j(`addScriptTag`).message,H=!1,ee=()=>{H||(H=!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.`))},U=({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)},te=e=>{if(typeof e!=`function`)return()=>Promise.resolve(e);let t=null;return()=>t??=e().catch(e=>{throw t=null,e})},W=({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!==``,h=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},g=Promise.resolve(),{gate:v,requestCategories:y,boundary:b}=C({session:i,declaredHosts:a,approvedOrigins:o,attach:s,assertLive:c,documentHost:typeof e.documentHost==`function`?()=>l(()=>e.documentHost()):void 0,current:()=>p,consent:te(u),freshBlank:h});return t.y({backend:`cloud`,executor:{execute:(n,r,i)=>E.has(r)?Promise.reject(t.j(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],phase:`execute`}),k(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 k(l(()=>e.executeLocator([],`addScriptTag`,i)),t.l,N)}catch(e){throw V(e)?t.N(M,`addScriptTag`,`cloud`):e}},clearCookies:async n=>{if(c(),typeof e.clearCookies!=`function`)throw t.N(P,`clearCookies`,`cloud`);if(b().length===0)throw t.k(F,`clearCookies`);await k(l(()=>e.clearCookies(n)),I,B)},postMessage:(n,r,i)=>{if(c(),typeof e.messaging!=`function`)throw t.N(j,`postMessage`,`cloud`);if(r!==`*`&&!b().includes(new URL(r).hostname))throw t.k(_,`postMessage`);let{port1:a,port2:o}=new MessageChannel;a.postMessage({data:n,transfer:i},i);let s=[o,r],u=g.then(async()=>(await v({parts:[],operation:`postMessage`,args:s,phase:`execute`}),{answer:l(()=>e.executeLocator([],`postMessage`,s))}));return g=u.catch(()=>{}),u.then(async({answer:e})=>{await e})},listen:t=>(typeof e.messaging!=`function`&&ee(),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 k(l(()=>e.goto(a,r===void 0?i:{...i,timeoutMs:r})),(r??3e4)+T,`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})},G=async e=>{if(e===void 0){let e=await a.s(`a relay`).catch(()=>void 0);if(typeof e?.relay?.resolve!=`function`)return;let t=await e.relay.resolve().catch(()=>void 0);return t&&`id`in t?t.id:void 0}let t=await a.s(`a relay choice`);c.t(t,`attachFrame`);let n=await t.relay.resolve(e);if(`refused`in n)throw c.i(`attachFrame: ${n.refused}`);return n.id},K=async(e,t)=>{if((typeof e.relay==`function`?await e.relay():``)!==t)throw c.i(`attachFrame: ${s.RELAY_CHOICE_UNSUPPORTED}`)},ne=250,re=500,q=65e3,ie=2e3,ae=2e3,oe=2,se=2e3,ce=2e3,le=({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},ue=(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})},J=()=>A(`cloud.attachFrame: the attached window closed, reloaded or left the page FKN attached; attach a fresh window`),Y=()=>A(`cloud.attachFrame: the attached window stopped answering; attach a fresh window`),fe=()=>A(`cloud.attachFrame: the window went away before it connected; attach a fresh window`),pe=()=>A(`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,n,i)=>{if(typeof window>`u`)throw Error(`cloud.attachFrame needs a window realm`);let{domains:a=[],permissions:l,relay:u}=e,{url:d,width:f,height:p}=t.s(e.window);if(window.origin===`null`)throw new t._(`opaque-opener`);let m=D(),g=crypto.randomUUID(),_=O(n),v=r.t(a),y=new Set;d&&y.add(new URL(d).origin);let b=n===`persistent`?ue(m,g):null,x=window.open(le({origin:m,target:i===void 0?d:``,session:_,domains:v,attach:g}),`_blank`,`popup,width=${f},height=${p}`);if(!x)throw b?.remove(),new t.g;let S=new AbortController,C=!1,T=null,E=(e,t=!1)=>{if(T===null){T=e,S.abort(t?Y():J());try{x.closed||x.postMessage({type:s.ATTACH_WINDOW_MESSAGE.detach,attach:g,...t?{unanswered:t}:{}},m)}catch{}b&&setTimeout(()=>b.remove(),ce)}};b&&de(b,S.signal);let A=new Promise((e,t)=>{S.signal.addEventListener(`abort`,()=>t(S.signal.reason),{once:!0})});A.catch(()=>{});let j=A.then(()=>{},()=>{}),M=()=>{if(S.signal.aborted)throw S.signal.reason},N=e=>S.signal.aborted?Promise.reject(S.signal.reason):Promise.race([e(),A]),P=e=>e.source===x&&e.origin===m;window.addEventListener(`message`,e=>{let n=e.source===null&&e.origin===m;if(!P(e)&&!n)return;let r=e.data;typeof r==`object`&&r&&r.attach===g&&(r.type===s.ATTACH_WINDOW_MESSAGE.gone?E(C?J():fe()):r.type===s.ATTACH_WINDOW_MESSAGE.refused&&!n&&E(new t._(r.reason)))},{signal:S.signal}),window.addEventListener(`pagehide`,()=>E(J()),{signal:S.signal});let F=G(u),I,L,R=()=>{let e=()=>{try{x.postMessage({type:s.ATTACH_WINDOW_MESSAGE.hello,attach:g,...I?{relay:I}:{}},m)}catch{}};e(),L=setInterval(e,ne)};u===void 0&&R();let B=setInterval(()=>{x.closed&&E(C?J():pe())},re);S.signal.addEventListener(`abort`,()=>{clearInterval(L),clearInterval(B)},{once:!0});let V=async e=>{try{return await Promise.race([e,A])}catch(e){throw T??e}};try{u!==void 0&&(I=await V(F),R());let e=await V(k((0,h.expose)({},{key:s.ATTACH_WINDOW_KEY,transport:{emit:(e,t)=>x.postMessage(e,m,t??[]),receive:e=>{let t=t=>{P(t)&&e(t.data,{source:t.source,origin:t.origin})};return window.addEventListener(`message`,t),()=>window.removeEventListener(`message`,t)}},unregisterSignal:S.signal,revivableModules:w(t.ft)}),s.WINDOW_HANDSHAKE_TIMEOUT_MS,`cloud.attachFrame: timed out connecting to the window`));C=!0,clearInterval(L);let n=0,r=setInterval(()=>{k(N(()=>e.ping()),ae,`ping`).then(()=>{n=0},()=>{S.signal.aborted||(document.visibilityState===`hidden`?n=0:++n>=oe&&E(Y(),!0))})},ie);S.signal.addEventListener(`abort`,()=>clearInterval(r),{once:!0}),I&&await V(k(K(e,I),q,`cloud.attachFrame: the window never became ready`)),await V(k(e.ready(),q,`cloud.attachFrame: the window never became ready`)),i!==void 0&&await V(z(e,i)),o.r(`attached frame`,S.signal);let a=W({control:e,target:d,session:_,declaredHosts:v,approvedOrigins:y,attach:g,assertLive:M,guard:N,consent:{request:t=>N(()=>e.requestConsent(t)),ensure:t=>N(()=>e.requestConsent([t])).then(([e])=>e!==void 0&&e!==!1)},onNavigated:()=>{},relay:U({from:()=>x,origin:m,attach:g,signal:S.signal})}),f=null,p=Object.assign(a,{close:()=>f??=(async()=>{S.signal.aborted||await k(Promise.allSettled([N(()=>e.flushCookies()),N(()=>e.sweepStorage())]),se,`close`).catch(()=>{});try{x.close()}catch{}E(J())})(),closed:j});return I?c.a(p,I):F.then(e=>c.a(p,e)),i!==void 0&&d&&await V(p.goto(d)),l?.length&&await V(p.requestPermissions(l)),p}catch(e){let n=T??e;if(!(n instanceof t._))try{x.close()}catch{}throw E(n),n}},he=2e4,X=65e3,Z=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]??``,$=({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(!Z(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),!Oe())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,relay:a})=>{let o=new URL(`/attach-frame`,D());return t?o.searchParams.set(`blank`,t):e&&o.searchParams.set(`url`,e),n&&o.searchParams.set(`session`,n),r.length&&o.searchParams.set(`domains`,r.join(`,`)),o.searchParams.set(`attach`,i),a&&o.searchParams.set(`relay`,a),o.href},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=()=>A(`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],Ce=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)},we=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`)},Te=async(e,n)=>{let r=typeof e.blank==`function`?await k(e.blank(),X,`cloud.attachFrame: the render proxy never became ready`):``;if(typeof r!=`string`||Q(r)!==Q(n))throw t.N(ge,`blank`,`cloud`)},Ee=async(e,n,a)=>{let l=$(e),{iframe:u,domains:d=[],permissions:f,relay:p}=e;if(typeof window>`u`)throw Error(`cloud.attachFrame needs a window realm`);if(!u.isConnected)throw Error(`cloud.attachFrame: the iframe must be connected to the document before attaching`);we(u);let m=u.getAttribute(`src`)??``,_=(()=>{if(Z(m))return null;try{return new URL(u.src||m,location.href)}catch{throw Error(`cloud.attachFrame: the iframe src is not a valid URL: ${m}`)}})();if(_){let e=new URL(`/attach-frame`,D());if(_.origin===e.origin&&_.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 v=_?.href??``;v&&t.x(v);let y=a===void 0?v:``,b=O(n),x=r.t(d),S=new Set;try{S.add(new URL(l||v).origin)}catch{}let C=G(p),T=p===void 0?void 0:await C,E=new AbortController,A=u.referrerPolicy,j=u.allow,M=crypto.randomUUID();if(u.referrerPolicy=`origin`,u.allow=xe(i.a(),u.allow),u.src=ve({target:y,blank:l,session:b,domains:x,attach:M,relay:T}),!u.contentWindow)throw Error(`cloud.attachFrame: the iframe window is not available`);try{let e=await k((0,h.expose)({},{key:s.ATTACH_FRAME_KEY,origin:D(),transport:{receive:window,emit:u.contentWindow},unregisterSignal:E.signal,revivableModules:w(t.ft)}),he,`cloud.attachFrame: timed out connecting to the render proxy page`);T&&await k(K(e,T),X,`cloud.attachFrame: the render proxy never became ready`),await k(e.ready(),X,`cloud.attachFrame: the render proxy never became ready`),l&&await Te(e,l),a!==void 0&&await z(e,a),(v||l)&&Ce(u),ye(u,()=>E.abort()),o.r(`attached frame`,E.signal);let n=u.contentWindow,r=W({control:e,target:l||v,blank:l!==``,session:b,declaredHosts:x,approvedOrigins:S,attach:M,assertLive:()=>{if(E.signal.aborted||!u.isConnected||u.contentWindow!==n)throw E.abort(),be()},guard:e=>e(),consent:g,onNavigated:()=>Ce(u),relay:U({from:()=>n,origin:D(),attach:M,signal:E.signal})});return T?c.a(r,T):C.then(e=>c.a(r,e)),a!==void 0&&v&&await r.goto(v),f?.length&&await r.requestPermissions(f),r}catch(e){throw E.abort(),u.referrerPolicy=A,u.allow=j,u.src=y||`about:blank`,e}},De=(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):Ee(e,r,i)}),Oe=()=>typeof window<`u`&&!0,ke=async()=>{let e=await a.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}},Ae=e.t({attachFrame:()=>De,available:()=>je,dgram:()=>p.i,dns:()=>u.t,fetch:()=>n.t,fs:()=>d.n,http:()=>m.p,net:()=>f.s,quota:()=>ke}),je=()=>a.l;Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return $}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return De}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return Ae}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return ke}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return je}});
|