@fkn/lib 0.9.71 → 0.9.72
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-CZYGFU5m.cjs} +1 -1
- package/{account-DF9jsI5N.js → account-Czik26yc.js} +2 -2
- package/{account-generation-BsXJ6WWS.cjs → account-generation-BTxZWNQz.cjs} +1 -1
- package/{account-generation-C0BizGmy.js → account-generation-D2hoQYXp.js} +1 -1
- package/{account-storage-B7QBr9aX.cjs → account-storage-CIfiAHa1.cjs} +1 -1
- package/{account-storage-Jgp8ycMy.js → account-storage-DcbJCOvI.js} +2 -2
- package/account.cjs +1 -1
- package/account.js +1 -1
- package/{api-dxNQsC_v.js → api-e82hhULK.js} +116 -108
- package/api-oE2v5tpj.cjs +3 -0
- package/api.cjs +1 -1
- package/api.js +1 -1
- package/cloud/dgram.cjs +1 -1
- package/cloud/dgram.js +1 -1
- package/cloud/dns.cjs +1 -1
- package/cloud/dns.js +1 -1
- package/cloud/fetch.cjs +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.js +1 -1
- package/cloud/net.cjs +1 -1
- package/cloud/net.js +1 -1
- package/{cloud-pJ8R_Dmx.cjs → cloud-6ddOLS37.cjs} +1 -1
- package/{cloud-CyU_k-d9.js → cloud-BV96BYFR.js} +120 -120
- package/cloud.cjs +1 -1
- package/cloud.js +7 -7
- package/{dgram-B14T5Lqo.js → dgram-CTcHo7BL.js} +1 -1
- package/{dgram-BPXm8haL.cjs → dgram-wTKAuRI3.cjs} +1 -1
- package/dgram.cjs +1 -1
- package/dgram.js +1 -1
- package/{dns-BQkSttLP.js → dns-Cdmp7tw4.js} +1 -1
- package/{dns-DlTvtfVk.cjs → dns-OXiS-nXH.cjs} +1 -1
- package/dns.cjs +1 -1
- package/dns.js +1 -1
- package/{extension-Ce1wlb_F.js → extension-DlPOuZum.js} +9 -9
- package/{extension-veLhWipR.cjs → extension-eA0r72hp.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-sR6cw1ay.js → fs-9LWii1mp.js} +3 -3
- package/{fs-DJ4wpfml.js → fs-BHfRf_xt.js} +1 -1
- package/{fs-DgPbKycT.cjs → fs-CLvS_YSq.cjs} +1 -1
- package/{fs-DxECe50Z.cjs → fs-CiZZf0ne.cjs} +1 -1
- package/fs.cjs +1 -1
- package/fs.js +2 -2
- package/{http-aUVH9bBn.js → http-Cg5aK6Jn.js} +1 -1
- package/{http-hIJh5XTX.cjs → http-KKqCypOh.cjs} +1 -1
- package/http.cjs +1 -1
- package/http.js +1 -1
- package/index.cjs +1 -1
- package/index.js +13 -13
- package/{lib-6lykV0aT.js → lib-B895LZTn.js} +514 -508
- package/lib-BJzKHh4X.cjs +53 -0
- package/{net-DVYOBov-.js → net-BUeelrnH.js} +1 -1
- package/{net-DUyZ7_3E.cjs → net-i4BzwpoN.cjs} +1 -1
- package/net.cjs +1 -1
- package/net.js +1 -1
- package/package.json +1 -1
- package/{packages-BTDKiQyC.cjs → packages-Bw1OE9Ra.cjs} +1 -1
- package/{packages-XWRhSAUe.js → packages-C27FhPmh.js} +1 -1
- package/packages.cjs +1 -1
- package/packages.js +1 -1
- package/proxy-BET3xNJw.js +81 -0
- package/proxy-khQQJbGw.cjs +1 -0
- package/{rooms-CZZfCZRv.cjs → rooms-C8FW4mDY.cjs} +1 -1
- package/{rooms-CYP8Bf6L.js → rooms-r09iUhIA.js} +1 -1
- package/rooms.cjs +1 -1
- package/rooms.js +1 -1
- package/{storage-DtynxQDJ.cjs → storage-BINUKDl1.cjs} +1 -1
- package/{storage-d61R3-P1.js → storage-CFk2AT4V.js} +3 -3
- package/storage.cjs +1 -1
- package/storage.js +1 -1
- package/api-b88Y1QDE.cjs +0 -3
- package/lib-C1OPIW6F.cjs +0 -53
- package/proxy-BOHZkjk-.js +0 -61
- package/proxy-vI5LhXLv.cjs +0 -1
|
@@ -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-BJzKHh4X.cjs"),n=require("./proxy-khQQJbGw.cjs"),r=require("./hosts-GNBhZO3-.cjs"),i=require("./broker-frame-BKHtDSjv.cjs"),a=require("./api-oE2v5tpj.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-OXiS-nXH.cjs"),d=require("./fs-CiZZf0ne.cjs"),f=require("./net-i4BzwpoN.cjs"),p=require("./dgram-wTKAuRI3.cjs"),m=require("./http-KKqCypOh.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.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: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}});
|
|
@@ -1,22 +1,22 @@
|
|
|
1
1
|
import { t as e } from "./rolldown-runtime-CGnMp29N.js";
|
|
2
|
-
import { D as t, E as n, N as r, O as i, T as a, _ as o, c as s, f as c, ft as l, g as u, h as d, j as f, k as p, l as m, m as h, o as g, p as _, s as v, u as y, x as b, y as x } from "./lib-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import { t as L } from "./
|
|
2
|
+
import { D as t, E as n, N as r, O as i, T as a, _ as o, c as s, f as c, ft as l, g as u, h as d, j as f, k as p, l as m, m as h, o as g, p as _, s as v, u as y, x as b, y as x } from "./lib-B895LZTn.js";
|
|
3
|
+
import { t as S } from "./proxy-BET3xNJw.js";
|
|
4
|
+
import { c as C, m as w, t as T } from "./hosts-HUfgMimI.js";
|
|
5
|
+
import { i as E } from "./broker-frame-BClLp2ZV.js";
|
|
6
|
+
import { l as D, n as O, o as k, s as A } from "./api-e82hhULK.js";
|
|
7
|
+
import { r as j } from "./busy-C1JPjoZ_.js";
|
|
8
|
+
import { ATTACH_FRAME_KEY as M, ATTACH_WINDOW_KEY as ee, ATTACH_WINDOW_MESSAGE as N, RELAY_CHOICE_UNSUPPORTED as P, WINDOW_HANDSHAKE_TIMEOUT_MS as te } from "./contract.js";
|
|
9
|
+
import { a as F, i as I, t as L } from "./relay-choice-Bb3oP2gw.js";
|
|
10
10
|
import { frameFetchVerdict as R } from "./attach-policy.js";
|
|
11
|
-
import { t as ne } from "./dns-
|
|
12
|
-
import { n as re } from "./fs-
|
|
13
|
-
import { s as ie } from "./net-
|
|
14
|
-
import { i as ae } from "./dgram-
|
|
15
|
-
import { p as oe } from "./http-
|
|
11
|
+
import { t as ne } from "./dns-Cdmp7tw4.js";
|
|
12
|
+
import { n as re } from "./fs-BHfRf_xt.js";
|
|
13
|
+
import { s as ie } from "./net-BUeelrnH.js";
|
|
14
|
+
import { i as ae } from "./dgram-CTcHo7BL.js";
|
|
15
|
+
import { p as oe } from "./http-Cg5aK6Jn.js";
|
|
16
16
|
import { expose as z } from "osra";
|
|
17
17
|
// src/cloud/frame-broker.ts
|
|
18
18
|
var se = async () => {
|
|
19
|
-
let e = () =>
|
|
19
|
+
let e = () => A("frame consent");
|
|
20
20
|
try {
|
|
21
21
|
let t = await e();
|
|
22
22
|
return {
|
|
@@ -24,7 +24,7 @@ var se = async () => {
|
|
|
24
24
|
ensure: t.frameConsent.ensure
|
|
25
25
|
};
|
|
26
26
|
} catch (t) {
|
|
27
|
-
if (!(t instanceof
|
|
27
|
+
if (!(t instanceof O)) throw t;
|
|
28
28
|
return {
|
|
29
29
|
request: void 0,
|
|
30
30
|
ensure: (t) => e().then((e) => e.frameConsent.ensure(t))
|
|
@@ -45,11 +45,11 @@ var se = async () => {
|
|
|
45
45
|
} catch {
|
|
46
46
|
return "";
|
|
47
47
|
}
|
|
48
|
-
}, v = async () => s ? await s() : g(), y = () =>
|
|
48
|
+
}, v = async () => s ? await s() : g(), y = () => T([...o, ...le(f)]), b = async (e, t) => (await e([t]))[0] ?? !1;
|
|
49
49
|
return {
|
|
50
50
|
gate: async ({ operation: e, args: i, phase: s }) => {
|
|
51
51
|
t();
|
|
52
|
-
let c =
|
|
52
|
+
let c = w(e, i);
|
|
53
53
|
if (c === null) return;
|
|
54
54
|
let _ = d(c);
|
|
55
55
|
if (_ === void 0 || _ === "auto") return;
|
|
@@ -65,12 +65,12 @@ var se = async () => {
|
|
|
65
65
|
if (!t) {
|
|
66
66
|
if (e.kind === "refuse") throw p(e.reason, "fetch");
|
|
67
67
|
if (!await n({
|
|
68
|
-
scope:
|
|
68
|
+
scope: C(i[0], i[1]).scope,
|
|
69
69
|
hosts: e.promptHosts
|
|
70
70
|
})) throw p("frame.fetch: the user did not grant this", "fetch");
|
|
71
71
|
return;
|
|
72
72
|
}
|
|
73
|
-
let c = e.kind === "consent" ? e.targetHost : await v(), l =
|
|
73
|
+
let c = e.kind === "consent" ? e.targetHost : await v(), l = T([c, ...o]);
|
|
74
74
|
if (!l.length) throw p("frame: navigate the frame before fetch", "fetch");
|
|
75
75
|
if (await b(t, {
|
|
76
76
|
category: "network",
|
|
@@ -82,26 +82,26 @@ var se = async () => {
|
|
|
82
82
|
let x = await v();
|
|
83
83
|
if (!x) throw p(`frame: navigate the frame before ${e}`, e);
|
|
84
84
|
if (!y().includes(x)) throw p(B, e);
|
|
85
|
-
let
|
|
86
|
-
if (
|
|
85
|
+
let S = h(c);
|
|
86
|
+
if (S === void 0 || S === "evaluation" && x === g() && await l?.() || _ === "critical" && m.has(`${c} ${x}`)) return;
|
|
87
87
|
let { request: E } = await r();
|
|
88
88
|
if (!E) return;
|
|
89
|
-
let D =
|
|
89
|
+
let D = T([x, ...o]), O = H(a(i)), k = _ === "critical" ? {
|
|
90
90
|
key: c,
|
|
91
91
|
hosts: D,
|
|
92
92
|
attach: n,
|
|
93
93
|
...O
|
|
94
94
|
} : {
|
|
95
|
-
category:
|
|
95
|
+
category: S,
|
|
96
96
|
hosts: D,
|
|
97
97
|
...O
|
|
98
98
|
}, A = await b(E, k);
|
|
99
|
-
if (A === !1) throw p(U(e,
|
|
99
|
+
if (A === !1) throw p(U(e, S, null), e);
|
|
100
100
|
if (A === "once" && s !== "ensure") for (let e of D) m.add(`${c} ${e}`);
|
|
101
101
|
},
|
|
102
102
|
requestCategories: async (e) => {
|
|
103
103
|
t(), c("frame.requestPermissions", e);
|
|
104
|
-
let i = await v(), a =
|
|
104
|
+
let i = await v(), a = T(i ? [i, ...o] : o);
|
|
105
105
|
if (!a.length) throw TypeError("frame.requestPermissions: navigate the frame or declare domains first");
|
|
106
106
|
let s = e.map((e) => {
|
|
107
107
|
let t = e.key;
|
|
@@ -143,16 +143,16 @@ var se = async () => {
|
|
|
143
143
|
i = setTimeout(() => a(typeof r == "string" ? new n(r) : r()), t);
|
|
144
144
|
});
|
|
145
145
|
return Promise.race([e, a]).finally(() => clearTimeout(i));
|
|
146
|
-
}, J = (e) => Object.assign(Error(e), { name: t }), pe = "frame.postMessage: this FKN page predates frame messaging; reload the app to load the current one", me = "frame.addScriptTag: this render proxy predates addScriptTag; reload the app", he = `frame.addScriptTag: no answer within ${m}ms; the script may or may not have run`, ge = "frame.clearCookies: this FKN page predates clearCookies; reload the app to load the current one", _e = "frame.clearCookies: this attachment reaches no site yet; attach a url, goto one, or declare it in domains", Y = 3e4,
|
|
147
|
-
if (typeof e.seed != "function") throw r(
|
|
146
|
+
}, J = (e) => Object.assign(Error(e), { name: t }), pe = "frame.postMessage: this FKN page predates frame messaging; reload the app to load the current one", me = "frame.addScriptTag: this render proxy predates addScriptTag; reload the app", he = `frame.addScriptTag: no answer within ${m}ms; the script may or may not have run`, ge = "frame.clearCookies: this FKN page predates clearCookies; reload the app to load the current one", _e = "frame.clearCookies: this attachment reaches no site yet; attach a url, goto one, or declare it in domains", Y = 3e4, ve = "attachFrame: this FKN page predates storageState; reload the app to load the current one", ye = 2e4, be = async (e, t) => {
|
|
147
|
+
if (typeof e.seed != "function") throw r(ve, "storageState", "cloud");
|
|
148
148
|
try {
|
|
149
|
-
await q(e.seed(t),
|
|
149
|
+
await q(e.seed(t), ye, "attachFrame: the render proxy did not take the storageState seed");
|
|
150
150
|
} catch (e) {
|
|
151
|
-
throw i(e) ? r(
|
|
151
|
+
throw i(e) ? r(ve, "storageState", "cloud") : e;
|
|
152
152
|
}
|
|
153
|
-
},
|
|
154
|
-
|
|
155
|
-
},
|
|
153
|
+
}, xe = `frame.clearCookies: the render proxy did not answer within ${Y}ms; the cookies may or may not be gone, and calling it again is safe`, Se = (e) => i(e) && e.message === f("addScriptTag").message, Ce = !1, we = () => {
|
|
154
|
+
Ce || (Ce = !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."));
|
|
155
|
+
}, Te = ({ from: e, origin: t, attach: n, signal: r }) => (i) => {
|
|
156
156
|
let a = (r) => {
|
|
157
157
|
if (r.source === null || r.source !== e() || r.origin !== t) return;
|
|
158
158
|
let a = r.data;
|
|
@@ -167,13 +167,13 @@ var se = async () => {
|
|
|
167
167
|
}));
|
|
168
168
|
};
|
|
169
169
|
return window.addEventListener("message", a, { signal: r }), () => window.removeEventListener("message", a);
|
|
170
|
-
},
|
|
170
|
+
}, Ee = (e) => {
|
|
171
171
|
if (typeof e != "function") return () => Promise.resolve(e);
|
|
172
172
|
let t = null;
|
|
173
173
|
return () => t ??= e().catch((e) => {
|
|
174
174
|
throw t = null, e;
|
|
175
175
|
});
|
|
176
|
-
},
|
|
176
|
+
}, De = ({ control: e, target: t, blank: n = !1, session: i, declaredHosts: a, approvedOrigins: o, attach: c, assertLive: l, guard: u, consent: d, onNavigated: h, relay: g }) => {
|
|
177
177
|
let _ = t, v = n && i !== "", b = async () => {
|
|
178
178
|
if (!v) return !1;
|
|
179
179
|
let n = typeof e.blank == "function" ? await u(() => e.blank()) : "";
|
|
@@ -186,7 +186,7 @@ var se = async () => {
|
|
|
186
186
|
assertLive: l,
|
|
187
187
|
documentHost: typeof e.documentHost == "function" ? () => u(() => e.documentHost()) : void 0,
|
|
188
188
|
current: () => _,
|
|
189
|
-
consent:
|
|
189
|
+
consent: Ee(d),
|
|
190
190
|
freshBlank: b
|
|
191
191
|
});
|
|
192
192
|
return x({
|
|
@@ -215,13 +215,13 @@ var se = async () => {
|
|
|
215
215
|
try {
|
|
216
216
|
await q(u(() => e.executeLocator([], "addScriptTag", i)), m, he);
|
|
217
217
|
} catch (e) {
|
|
218
|
-
throw
|
|
218
|
+
throw Se(e) ? r(me, "addScriptTag", "cloud") : e;
|
|
219
219
|
}
|
|
220
220
|
},
|
|
221
221
|
clearCookies: async (t) => {
|
|
222
222
|
if (l(), typeof e.clearCookies != "function") throw r(ge, "clearCookies", "cloud");
|
|
223
223
|
if (T().length === 0) throw p(_e, "clearCookies");
|
|
224
|
-
await q(u(() => e.clearCookies(t)), Y,
|
|
224
|
+
await q(u(() => e.clearCookies(t)), Y, xe);
|
|
225
225
|
},
|
|
226
226
|
postMessage: (t, n, i) => {
|
|
227
227
|
if (l(), typeof e.messaging != "function") throw r(pe, "postMessage", "cloud");
|
|
@@ -241,7 +241,7 @@ var se = async () => {
|
|
|
241
241
|
await e;
|
|
242
242
|
});
|
|
243
243
|
},
|
|
244
|
-
listen: (t) => (typeof e.messaging != "function" &&
|
|
244
|
+
listen: (t) => (typeof e.messaging != "function" && we(), g(t)),
|
|
245
245
|
goto: async (t, { timeout: n, ...r } = {}) => {
|
|
246
246
|
let i = new URL(t, location.href).href;
|
|
247
247
|
l(), v = !1;
|
|
@@ -265,38 +265,38 @@ var se = async () => {
|
|
|
265
265
|
},
|
|
266
266
|
url: () => _
|
|
267
267
|
});
|
|
268
|
-
},
|
|
268
|
+
}, Oe = async (e) => {
|
|
269
269
|
if (e === void 0) {
|
|
270
|
-
let e = await
|
|
270
|
+
let e = await A("a relay").catch(() => void 0);
|
|
271
271
|
if (typeof e?.relay?.resolve != "function") return;
|
|
272
272
|
let t = await e.relay.resolve().catch(() => void 0);
|
|
273
273
|
return t && "id" in t ? t.id : void 0;
|
|
274
274
|
}
|
|
275
|
-
let t = await
|
|
276
|
-
|
|
275
|
+
let t = await A("a relay choice");
|
|
276
|
+
L(t, "attachFrame");
|
|
277
277
|
let n = await t.relay.resolve(e);
|
|
278
|
-
if ("refused" in n) throw
|
|
278
|
+
if ("refused" in n) throw I(`attachFrame: ${n.refused}`);
|
|
279
279
|
return n.id;
|
|
280
|
-
},
|
|
281
|
-
if ((typeof e.relay == "function" ? await e.relay() : "") !== t) throw
|
|
282
|
-
},
|
|
280
|
+
}, ke = async (e, t) => {
|
|
281
|
+
if ((typeof e.relay == "function" ? await e.relay() : "") !== t) throw I(`attachFrame: ${P}`);
|
|
282
|
+
}, Ae = 250, je = 500, Me = 65e3, Ne = 2e3, Pe = 2e3, Fe = 2, Ie = 2e3, Le = 2e3, Re = ({ origin: e, target: t, session: n, domains: r, attach: i }) => {
|
|
283
283
|
let a = new URL("/attach-window", e);
|
|
284
284
|
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;
|
|
285
|
-
},
|
|
285
|
+
}, ze = (e, t) => {
|
|
286
286
|
let n = document.createElement("iframe"), r = new URL("/attach-jar", e);
|
|
287
287
|
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;
|
|
288
|
-
},
|
|
288
|
+
}, Be = (e, t) => {
|
|
289
289
|
let n = new MutationObserver(() => {
|
|
290
290
|
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"));
|
|
291
291
|
});
|
|
292
292
|
e.parentNode && n.observe(e.parentNode, { childList: !0 }), n.observe(document.documentElement, { childList: !0 }), t.addEventListener("abort", () => n.disconnect(), { once: !0 });
|
|
293
|
-
},
|
|
293
|
+
}, X = () => J("cloud.attachFrame: the attached window closed, reloaded or left the page FKN attached; attach a fresh window"), Ve = () => J("cloud.attachFrame: the attached window stopped answering; attach a fresh window"), He = () => J("cloud.attachFrame: the window went away before it connected; attach a fresh window"), Ue = () => J("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"), We = async (e, t, n) => {
|
|
294
294
|
if (typeof window > "u") throw Error("cloud.attachFrame needs a window realm");
|
|
295
295
|
let { domains: r = [], permissions: i, relay: a } = e, { url: s, width: c, height: d } = v(e.window);
|
|
296
296
|
if (window.origin === "null") throw new o("opaque-opener");
|
|
297
|
-
let f = G(), p = crypto.randomUUID(), m = K(t), h =
|
|
297
|
+
let f = G(), p = crypto.randomUUID(), m = K(t), h = T(r), g = /* @__PURE__ */ new Set();
|
|
298
298
|
s && g.add(new URL(s).origin);
|
|
299
|
-
let _ = t === "persistent" ?
|
|
299
|
+
let _ = t === "persistent" ? ze(f, p) : null, y = window.open(Re({
|
|
300
300
|
origin: f,
|
|
301
301
|
target: n === void 0 ? s : "",
|
|
302
302
|
session: m,
|
|
@@ -306,59 +306,59 @@ var se = async () => {
|
|
|
306
306
|
if (!y) throw _?.remove(), new u();
|
|
307
307
|
let b = new AbortController(), x = !1, S = null, C = (e, t = !1) => {
|
|
308
308
|
if (S === null) {
|
|
309
|
-
S = e, b.abort(t ?
|
|
309
|
+
S = e, b.abort(t ? Ve() : X());
|
|
310
310
|
try {
|
|
311
311
|
y.closed || y.postMessage({
|
|
312
|
-
type:
|
|
312
|
+
type: N.detach,
|
|
313
313
|
attach: p,
|
|
314
314
|
...t ? { unanswered: t } : {}
|
|
315
315
|
}, f);
|
|
316
316
|
} catch {}
|
|
317
|
-
_ && setTimeout(() => _.remove(),
|
|
317
|
+
_ && setTimeout(() => _.remove(), Le);
|
|
318
318
|
}
|
|
319
319
|
};
|
|
320
|
-
_ &&
|
|
321
|
-
let
|
|
320
|
+
_ && Be(_, b.signal);
|
|
321
|
+
let w = new Promise((e, t) => {
|
|
322
322
|
b.signal.addEventListener("abort", () => t(b.signal.reason), { once: !0 });
|
|
323
323
|
});
|
|
324
|
-
|
|
325
|
-
let E =
|
|
324
|
+
w.catch(() => {});
|
|
325
|
+
let E = w.then(() => {}, () => {}), D = () => {
|
|
326
326
|
if (b.signal.aborted) throw b.signal.reason;
|
|
327
|
-
}, O = (e) => b.signal.aborted ? Promise.reject(b.signal.reason) : Promise.race([e(),
|
|
327
|
+
}, O = (e) => b.signal.aborted ? Promise.reject(b.signal.reason) : Promise.race([e(), w]), k = (e) => e.source === y && e.origin === f;
|
|
328
328
|
window.addEventListener("message", (e) => {
|
|
329
329
|
let t = e.source === null && e.origin === f;
|
|
330
330
|
if (!k(e) && !t) return;
|
|
331
331
|
let n = e.data;
|
|
332
|
-
typeof n == "object" && n && n.attach === p && (n.type ===
|
|
333
|
-
}, { signal: b.signal }), window.addEventListener("pagehide", () => C(
|
|
334
|
-
let
|
|
332
|
+
typeof n == "object" && n && n.attach === p && (n.type === N.gone ? C(x ? X() : He()) : n.type === N.refused && !t && C(new o(n.reason)));
|
|
333
|
+
}, { signal: b.signal }), window.addEventListener("pagehide", () => C(X()), { signal: b.signal });
|
|
334
|
+
let A = Oe(a), M, P, I = () => {
|
|
335
335
|
let e = () => {
|
|
336
336
|
try {
|
|
337
337
|
y.postMessage({
|
|
338
|
-
type:
|
|
338
|
+
type: N.hello,
|
|
339
339
|
attach: p,
|
|
340
|
-
...
|
|
340
|
+
...M ? { relay: M } : {}
|
|
341
341
|
}, f);
|
|
342
342
|
} catch {}
|
|
343
343
|
};
|
|
344
|
-
e(),
|
|
344
|
+
e(), P = setInterval(e, Ae);
|
|
345
345
|
};
|
|
346
346
|
a === void 0 && I();
|
|
347
347
|
let L = setInterval(() => {
|
|
348
|
-
y.closed && C(x ?
|
|
349
|
-
},
|
|
348
|
+
y.closed && C(x ? X() : Ue());
|
|
349
|
+
}, je);
|
|
350
350
|
b.signal.addEventListener("abort", () => {
|
|
351
|
-
clearInterval(
|
|
351
|
+
clearInterval(P), clearInterval(L);
|
|
352
352
|
}, { once: !0 });
|
|
353
353
|
let R = async (e) => {
|
|
354
354
|
try {
|
|
355
|
-
return await Promise.race([e,
|
|
355
|
+
return await Promise.race([e, w]);
|
|
356
356
|
} catch (e) {
|
|
357
357
|
throw S ?? e;
|
|
358
358
|
}
|
|
359
359
|
};
|
|
360
360
|
try {
|
|
361
|
-
a !== void 0 && (
|
|
361
|
+
a !== void 0 && (M = await R(A), I());
|
|
362
362
|
let e = await R(q(z({}, {
|
|
363
363
|
key: ee,
|
|
364
364
|
transport: {
|
|
@@ -376,16 +376,16 @@ var se = async () => {
|
|
|
376
376
|
unregisterSignal: b.signal,
|
|
377
377
|
revivableModules: W(l)
|
|
378
378
|
}), te, "cloud.attachFrame: timed out connecting to the window"));
|
|
379
|
-
x = !0, clearInterval(
|
|
379
|
+
x = !0, clearInterval(P);
|
|
380
380
|
let t = 0, r = setInterval(() => {
|
|
381
|
-
q(O(() => e.ping()),
|
|
381
|
+
q(O(() => e.ping()), Pe, "ping").then(() => {
|
|
382
382
|
t = 0;
|
|
383
383
|
}, () => {
|
|
384
|
-
b.signal.aborted || (document.visibilityState === "hidden" ? t = 0 : ++t >=
|
|
384
|
+
b.signal.aborted || (document.visibilityState === "hidden" ? t = 0 : ++t >= Fe && C(Ve(), !0));
|
|
385
385
|
});
|
|
386
|
-
},
|
|
387
|
-
b.signal.addEventListener("abort", () => clearInterval(r), { once: !0 }),
|
|
388
|
-
let o =
|
|
386
|
+
}, Ne);
|
|
387
|
+
b.signal.addEventListener("abort", () => clearInterval(r), { once: !0 }), M && await R(q(ke(e, M), Me, "cloud.attachFrame: the window never became ready")), await R(q(e.ready(), Me, "cloud.attachFrame: the window never became ready")), n !== void 0 && await R(be(e, n)), j("attached frame", b.signal);
|
|
388
|
+
let o = De({
|
|
389
389
|
control: e,
|
|
390
390
|
target: s,
|
|
391
391
|
session: m,
|
|
@@ -399,7 +399,7 @@ var se = async () => {
|
|
|
399
399
|
ensure: (t) => O(() => e.requestConsent([t])).then(([e]) => e !== void 0 && e !== !1)
|
|
400
400
|
},
|
|
401
401
|
onNavigated: () => {},
|
|
402
|
-
relay:
|
|
402
|
+
relay: Te({
|
|
403
403
|
from: () => y,
|
|
404
404
|
origin: f,
|
|
405
405
|
attach: p,
|
|
@@ -407,15 +407,15 @@ var se = async () => {
|
|
|
407
407
|
})
|
|
408
408
|
}), c = null, u = Object.assign(o, {
|
|
409
409
|
close: () => c ??= (async () => {
|
|
410
|
-
b.signal.aborted || await q(Promise.allSettled([O(() => e.flushCookies()), O(() => e.sweepStorage())]),
|
|
410
|
+
b.signal.aborted || await q(Promise.allSettled([O(() => e.flushCookies()), O(() => e.sweepStorage())]), Ie, "close").catch(() => {});
|
|
411
411
|
try {
|
|
412
412
|
y.close();
|
|
413
413
|
} catch {}
|
|
414
|
-
C(
|
|
414
|
+
C(X());
|
|
415
415
|
})(),
|
|
416
416
|
closed: E
|
|
417
417
|
});
|
|
418
|
-
return
|
|
418
|
+
return M ? F(u, M) : A.then((e) => F(u, e)), n !== void 0 && s && await R(u.goto(s)), i?.length && await R(u.requestPermissions(i)), u;
|
|
419
419
|
} catch (e) {
|
|
420
420
|
let t = S ?? e;
|
|
421
421
|
if (!(t instanceof o)) try {
|
|
@@ -423,7 +423,7 @@ var se = async () => {
|
|
|
423
423
|
} catch {}
|
|
424
424
|
throw C(t), t;
|
|
425
425
|
}
|
|
426
|
-
},
|
|
426
|
+
}, Ge = 2e4, Z = 65e3, Q = (e) => !e || e === "about:blank", Ke = "cloud.attachFrame: this FKN page predates blank pages; reload the app to load the current one", qe = "cloud.attachFrame: cookies: 'native' needs the FKN browser extension; the cloud render proxy has no browser cookies", Je = (e) => e.split("#")[0] ?? "", Ye = ({ iframe: e, lockdown: t, cookies: n, blank: r }) => {
|
|
427
427
|
if (r === void 0) return "";
|
|
428
428
|
if (typeof r != "object" || !r) throw TypeError("attachFrame: blank must be an object { url }");
|
|
429
429
|
let i = Object.keys(r).find((e) => e !== "url");
|
|
@@ -437,15 +437,15 @@ var se = async () => {
|
|
|
437
437
|
})();
|
|
438
438
|
if (!o || o.protocol !== "http:" && o.protocol !== "https:") throw TypeError(`attachFrame: blank.url must be an absolute http or https url, not "${String(a)}"`);
|
|
439
439
|
let s = e.getAttribute("src") ?? "";
|
|
440
|
-
if (
|
|
440
|
+
if (!Q(s)) throw TypeError(`attachFrame: blank needs an iframe with no src; this one has "${s}"`);
|
|
441
441
|
if (t) throw TypeError("attachFrame: blank does not combine with lockdown");
|
|
442
442
|
if (n === "native") throw TypeError("attachFrame: blank runs on the cloud render proxy, which has no browser cookies; pass cookies: 'persistent' or 'ephemeral'");
|
|
443
|
-
if (b(o.href), !
|
|
443
|
+
if (b(o.href), !ot()) throw Error("attachFrame: a blank page is served by the cloud render proxy, which this build does not configure");
|
|
444
444
|
return o.href;
|
|
445
|
-
},
|
|
445
|
+
}, Xe = ({ target: e, blank: t, session: n, domains: r, attach: i, relay: a }) => {
|
|
446
446
|
let o = new URL("/attach-frame", G());
|
|
447
447
|
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;
|
|
448
|
-
},
|
|
448
|
+
}, Ze = (e, t) => {
|
|
449
449
|
let n = () => {
|
|
450
450
|
a(), t();
|
|
451
451
|
}, r = e.parentNode, i = new MutationObserver(() => {
|
|
@@ -454,14 +454,14 @@ var se = async () => {
|
|
|
454
454
|
window.removeEventListener("pagehide", n), i.disconnect();
|
|
455
455
|
};
|
|
456
456
|
window.addEventListener("pagehide", n, { once: !0 }), r && i.observe(r, { childList: !0 }), e.isConnected || (a(), t());
|
|
457
|
-
},
|
|
457
|
+
}, Qe = () => J("cloud.attachFrame: the attached iframe left the document or was reloaded; attach a fresh iframe"), $e = (e, t) => {
|
|
458
458
|
let n = [...e.split(";"), ...t.split(";")].map((e) => e.trim()).filter(Boolean);
|
|
459
459
|
return [...new Set(n)].join("; ");
|
|
460
|
-
},
|
|
460
|
+
}, et = [
|
|
461
461
|
300,
|
|
462
462
|
1200,
|
|
463
463
|
4e3
|
|
464
|
-
],
|
|
464
|
+
], tt = (e) => {
|
|
465
465
|
let t = () => {
|
|
466
466
|
if (!e.isConnected) return;
|
|
467
467
|
let t = e.style.height, n = e.getBoundingClientRect();
|
|
@@ -470,22 +470,22 @@ var se = async () => {
|
|
|
470
470
|
}, 50));
|
|
471
471
|
};
|
|
472
472
|
t();
|
|
473
|
-
for (let e of
|
|
474
|
-
},
|
|
473
|
+
for (let e of et) setTimeout(t, e);
|
|
474
|
+
}, nt = (e) => {
|
|
475
475
|
let t = e.getAttribute("sandbox");
|
|
476
476
|
if (t === null) return;
|
|
477
477
|
let n = new Set(t.toLowerCase().split(/\s+/).filter(Boolean)), r = ["allow-scripts", "allow-same-origin"].filter((e) => !n.has(e));
|
|
478
478
|
if (r.length) throw Error(`cloud.attachFrame: the iframe's sandbox attribute must include ${r.join(" and ")} for the render proxy to load`);
|
|
479
|
-
},
|
|
480
|
-
let n = typeof e.blank == "function" ? await q(e.blank(),
|
|
481
|
-
if (typeof n != "string" ||
|
|
482
|
-
},
|
|
483
|
-
let r =
|
|
479
|
+
}, rt = async (e, t) => {
|
|
480
|
+
let n = typeof e.blank == "function" ? await q(e.blank(), Z, "cloud.attachFrame: the render proxy never became ready") : "";
|
|
481
|
+
if (typeof n != "string" || Je(n) !== Je(t)) throw r(Ke, "blank", "cloud");
|
|
482
|
+
}, it = async (e, t, n) => {
|
|
483
|
+
let r = Ye(e), { iframe: i, domains: a = [], permissions: o, relay: s } = e;
|
|
484
484
|
if (typeof window > "u") throw Error("cloud.attachFrame needs a window realm");
|
|
485
485
|
if (!i.isConnected) throw Error("cloud.attachFrame: the iframe must be connected to the document before attaching");
|
|
486
|
-
|
|
486
|
+
nt(i);
|
|
487
487
|
let c = i.getAttribute("src") ?? "", u = (() => {
|
|
488
|
-
if (
|
|
488
|
+
if (Q(c)) return null;
|
|
489
489
|
try {
|
|
490
490
|
return new URL(i.src || c, location.href);
|
|
491
491
|
} catch {
|
|
@@ -498,12 +498,12 @@ var se = async () => {
|
|
|
498
498
|
}
|
|
499
499
|
let d = u?.href ?? "";
|
|
500
500
|
d && b(d);
|
|
501
|
-
let f = n === void 0 ? d : "", p = K(t), m =
|
|
501
|
+
let f = n === void 0 ? d : "", p = K(t), m = T(a), h = /* @__PURE__ */ new Set();
|
|
502
502
|
try {
|
|
503
503
|
h.add(new URL(r || d).origin);
|
|
504
504
|
} catch {}
|
|
505
|
-
let g =
|
|
506
|
-
if (i.referrerPolicy = "origin", i.allow =
|
|
505
|
+
let g = Oe(s), _ = s === void 0 ? void 0 : await g, v = new AbortController(), y = i.referrerPolicy, x = i.allow, S = crypto.randomUUID();
|
|
506
|
+
if (i.referrerPolicy = "origin", i.allow = $e(E(), i.allow), i.src = Xe({
|
|
507
507
|
target: f,
|
|
508
508
|
blank: r,
|
|
509
509
|
session: p,
|
|
@@ -513,7 +513,7 @@ var se = async () => {
|
|
|
513
513
|
}), !i.contentWindow) throw Error("cloud.attachFrame: the iframe window is not available");
|
|
514
514
|
try {
|
|
515
515
|
let e = await q(z({}, {
|
|
516
|
-
key:
|
|
516
|
+
key: M,
|
|
517
517
|
origin: G(),
|
|
518
518
|
transport: {
|
|
519
519
|
receive: window,
|
|
@@ -521,9 +521,9 @@ var se = async () => {
|
|
|
521
521
|
},
|
|
522
522
|
unregisterSignal: v.signal,
|
|
523
523
|
revivableModules: W(l)
|
|
524
|
-
}),
|
|
525
|
-
_ && await q(
|
|
526
|
-
let t = i.contentWindow, a =
|
|
524
|
+
}), Ge, "cloud.attachFrame: timed out connecting to the render proxy page");
|
|
525
|
+
_ && await q(ke(e, _), Z, "cloud.attachFrame: the render proxy never became ready"), await q(e.ready(), Z, "cloud.attachFrame: the render proxy never became ready"), r && await rt(e, r), n !== void 0 && await be(e, n), (d || r) && tt(i), Ze(i, () => v.abort()), j("attached frame", v.signal);
|
|
526
|
+
let t = i.contentWindow, a = De({
|
|
527
527
|
control: e,
|
|
528
528
|
target: r || d,
|
|
529
529
|
blank: r !== "",
|
|
@@ -532,28 +532,28 @@ var se = async () => {
|
|
|
532
532
|
approvedOrigins: h,
|
|
533
533
|
attach: S,
|
|
534
534
|
assertLive: () => {
|
|
535
|
-
if (v.signal.aborted || !i.isConnected || i.contentWindow !== t) throw v.abort(),
|
|
535
|
+
if (v.signal.aborted || !i.isConnected || i.contentWindow !== t) throw v.abort(), Qe();
|
|
536
536
|
},
|
|
537
537
|
guard: (e) => e(),
|
|
538
538
|
consent: se,
|
|
539
|
-
onNavigated: () =>
|
|
540
|
-
relay:
|
|
539
|
+
onNavigated: () => tt(i),
|
|
540
|
+
relay: Te({
|
|
541
541
|
from: () => t,
|
|
542
542
|
origin: G(),
|
|
543
543
|
attach: S,
|
|
544
544
|
signal: v.signal
|
|
545
545
|
})
|
|
546
546
|
});
|
|
547
|
-
return _ ?
|
|
547
|
+
return _ ? F(a, _) : g.then((e) => F(a, e)), n !== void 0 && d && await a.goto(d), o?.length && await a.requestPermissions(o), a;
|
|
548
548
|
} catch (e) {
|
|
549
549
|
throw v.abort(), i.referrerPolicy = y, i.allow = x, i.src = f || "about:blank", e;
|
|
550
550
|
}
|
|
551
|
-
},
|
|
551
|
+
}, at = (async (e) => {
|
|
552
552
|
let { kind: t, cookies: n, storageState: r } = g(e);
|
|
553
|
-
if (n === "native") throw TypeError(
|
|
554
|
-
return t === "window" ?
|
|
555
|
-
}),
|
|
556
|
-
let e = await
|
|
553
|
+
if (n === "native") throw TypeError(qe);
|
|
554
|
+
return t === "window" ? We(e, n, r) : it(e, n, r);
|
|
555
|
+
}), ot = () => typeof window < "u" && !0, st = async () => {
|
|
556
|
+
let e = await k.then((e) => e.cloud.quota());
|
|
557
557
|
return {
|
|
558
558
|
premium: e.premium,
|
|
559
559
|
overQuota: e.overQuota,
|
|
@@ -564,15 +564,15 @@ var se = async () => {
|
|
|
564
564
|
bytesPerSecond: e.bytesPerSecond,
|
|
565
565
|
bitsPerSecond: e.bytesPerSecond * 8
|
|
566
566
|
};
|
|
567
|
-
},
|
|
568
|
-
attachFrame: () =>
|
|
569
|
-
available: () =>
|
|
567
|
+
}, ct = /* @__PURE__ */ e({
|
|
568
|
+
attachFrame: () => at,
|
|
569
|
+
available: () => $,
|
|
570
570
|
dgram: () => ae,
|
|
571
571
|
dns: () => ne,
|
|
572
|
-
fetch: () =>
|
|
572
|
+
fetch: () => S,
|
|
573
573
|
fs: () => re,
|
|
574
574
|
http: () => oe,
|
|
575
575
|
net: () => ie,
|
|
576
|
-
quota: () =>
|
|
577
|
-
}),
|
|
578
|
-
export {
|
|
576
|
+
quota: () => st
|
|
577
|
+
}), $ = () => D;
|
|
578
|
+
export { Ye as a, at as i, ct as n, st as r, $ as t };
|