@fkn/lib 0.9.36 → 0.9.38
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/{api-CaFuvyyV.d.ts → api-DF4nHz2Q.d.ts} +7 -7
- package/api.d.ts +2 -2
- package/attach-policy.cjs +1 -1
- package/attach-policy.js +1 -1
- package/cloud/dns.d.ts +1 -1
- package/cloud/fetch.d.ts +1 -1
- package/cloud/net.d.ts +1 -1
- package/cloud-Beg4iCRU.cjs +1 -0
- package/{cloud-Cqdq7Ujd.d.ts → cloud-Bfc6rkF2.d.ts} +3 -3
- package/cloud-EfyYfgVT.js +476 -0
- package/cloud.cjs +1 -1
- package/cloud.d.ts +3 -3
- package/cloud.js +1 -1
- package/{contract-BIHGp6cz.d.ts → contract-InuLU8bI.d.ts} +85 -7
- package/contract.cjs +1 -1
- package/contract.d.ts +2 -2
- package/contract.js +6 -6
- package/dgram.d.ts +2 -2
- package/dns.d.ts +1 -1
- package/extension-B7jDaJVp.cjs +1 -0
- package/{extension-C9BRlqEY.d.ts → extension-Bm5x5R4R.d.ts} +2 -2
- package/extension-sNRjVbET.js +89 -0
- package/extension.cjs +1 -1
- package/extension.d.ts +3 -3
- package/extension.js +3 -3
- package/hosts-9dYv63ud.cjs +1 -0
- package/{hosts-77UAJbm1.js → hosts-BzbzOhG8.js} +31 -19
- package/http.d.ts +1 -1
- package/{index-BWJSnpRB.d.ts → index-DiOxvYoa.d.ts} +170 -1
- package/index.cjs +1 -1
- package/index.d.ts +5 -5
- package/index.js +12 -12
- package/lib-DYKLnpWs.cjs +53 -0
- package/{lib-hd9k5xOX.js → lib-FD1Ssqjt.js} +461 -332
- package/{net-BWFTx3k_.d.ts → net-DnXxFGm8.d.ts} +2 -2
- package/net.d.ts +1 -1
- package/package.json +1 -1
- package/packages.d.ts +1 -1
- package/{proxy-DaljzPSa.d.ts → proxy-BkaVTZAf.d.ts} +2 -2
- package/rooms.cjs +1 -1
- package/rooms.d.ts +26 -8
- package/rooms.js +9 -1
- package/cloud-CDRoRstb.js +0 -428
- package/cloud-DG_-Rt-L.cjs +0 -1
- package/extension-DisWHU7m.cjs +0 -1
- package/extension-jDvl0U_P.js +0 -89
- package/hosts-COiOMjp-.cjs +0 -1
- package/lib-DCPdYk-N.cjs +0 -53
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { o as TcpSocketOption, v as UdpSocketOption } from "./wire-Gbo-D74t.js";
|
|
2
|
-
import {
|
|
2
|
+
import { A as OverlayState, C as InstallOptions, Ct as UdpSocketOptions, F as PickOptions, H as Resolvers, I as Placement, J as RoomEvent, N as PackagesErrorCode, R as ProxyFetchInit, St as UdpDatagram, T as IpFamily, W as RoomClaimOptions, X as RoomJoinOptions, Z as RoomMailbox, bt as TcpSocketOptions, c as ConflictChoice, d as ConnectAvailability, et as RoomOpenOptions, f as ConnectOptions, j as PackageQuery, kt as WriteData, l as ConflictRequest, o as AdoptRequest, rt as RoomsErrorCode, s as AdoptState, tt as RoomPermission, v as FrameConsentAnswer, vt as TcpSocketListenerOptions, y as FrameConsentRequest, z as ProxyFetchInput } from "./contract-InuLU8bI.js";
|
|
3
3
|
import { Remote } from "osra";
|
|
4
4
|
//#region src/api-epochs.d.ts
|
|
5
5
|
type EpochListener<T> = (remote: T, epoch: number) => void;
|
|
@@ -380,7 +380,7 @@ declare const onApiEpoch: (listener: EpochListener<{
|
|
|
380
380
|
} | {
|
|
381
381
|
ok: true;
|
|
382
382
|
}>;
|
|
383
|
-
claim: () => Promise<{
|
|
383
|
+
claim: (options?: RoomClaimOptions | undefined) => Promise<{
|
|
384
384
|
error: RoomsErrorCode;
|
|
385
385
|
message: string;
|
|
386
386
|
} | {
|
|
@@ -510,7 +510,7 @@ declare const onApiEpoch: (listener: EpochListener<{
|
|
|
510
510
|
} | {
|
|
511
511
|
ok: true;
|
|
512
512
|
}>;
|
|
513
|
-
claim: () => Promise<{
|
|
513
|
+
claim: (options?: RoomClaimOptions | undefined) => Promise<{
|
|
514
514
|
error: RoomsErrorCode;
|
|
515
515
|
message: string;
|
|
516
516
|
} | {
|
|
@@ -640,7 +640,7 @@ declare const onApiEpoch: (listener: EpochListener<{
|
|
|
640
640
|
} | {
|
|
641
641
|
ok: true;
|
|
642
642
|
}>;
|
|
643
|
-
claim: () => Promise<{
|
|
643
|
+
claim: (options?: RoomClaimOptions | undefined) => Promise<{
|
|
644
644
|
error: RoomsErrorCode;
|
|
645
645
|
message: string;
|
|
646
646
|
} | {
|
|
@@ -1093,7 +1093,7 @@ declare const currentApiEpoch: () => {
|
|
|
1093
1093
|
} | {
|
|
1094
1094
|
ok: true;
|
|
1095
1095
|
}>;
|
|
1096
|
-
claim: () => Promise<{
|
|
1096
|
+
claim: (options?: RoomClaimOptions | undefined) => Promise<{
|
|
1097
1097
|
error: RoomsErrorCode;
|
|
1098
1098
|
message: string;
|
|
1099
1099
|
} | {
|
|
@@ -1223,7 +1223,7 @@ declare const currentApiEpoch: () => {
|
|
|
1223
1223
|
} | {
|
|
1224
1224
|
ok: true;
|
|
1225
1225
|
}>;
|
|
1226
|
-
claim: () => Promise<{
|
|
1226
|
+
claim: (options?: RoomClaimOptions | undefined) => Promise<{
|
|
1227
1227
|
error: RoomsErrorCode;
|
|
1228
1228
|
message: string;
|
|
1229
1229
|
} | {
|
|
@@ -1353,7 +1353,7 @@ declare const currentApiEpoch: () => {
|
|
|
1353
1353
|
} | {
|
|
1354
1354
|
ok: true;
|
|
1355
1355
|
}>;
|
|
1356
|
-
claim: () => Promise<{
|
|
1356
|
+
claim: (options?: RoomClaimOptions | undefined) => Promise<{
|
|
1357
1357
|
error: RoomsErrorCode;
|
|
1358
1358
|
message: string;
|
|
1359
1359
|
} | {
|
package/api.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { a as apiPromise, c as hasTransport, i as apiLastCall, l as onApiEpoch, n as BrokerUnreachableError, o as apiWithin, r as apiInFlight, s as currentApiEpoch, t as API_DEADLINE_MS } from "./api-
|
|
1
|
+
import { H as Resolvers } from "./contract-InuLU8bI.js";
|
|
2
|
+
import { a as apiPromise, c as hasTransport, i as apiLastCall, l as onApiEpoch, n as BrokerUnreachableError, o as apiWithin, r as apiInFlight, s as currentApiEpoch, t as API_DEADLINE_MS } from "./api-DF4nHz2Q.js";
|
|
3
3
|
export { API_DEADLINE_MS, BrokerUnreachableError, type Resolvers, apiInFlight, apiLastCall, apiPromise, apiWithin, currentApiEpoch, hasTransport, onApiEpoch };
|
package/attach-policy.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./hosts-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./hosts-9dYv63ud.cjs");var t=(t,n,{classifier:r=`no-base`}={})=>{if(!t.session)return{kind:`refuse`,reason:`frame.fetch on the cloud backend needs its own session: attach with syncCookies: false`};if(typeof n!=`string`)return{kind:`refuse`,reason:`frame.fetch: url must be a string`};let i;try{i=new URL(n)}catch{return{kind:`refuse`,reason:`frame.fetch on the cloud backend needs an absolute url`}}if(r===`fetchTarget`&&e.l(n).kind!==`absolute`)return{kind:`refuse`,reason:`frame.fetch on the cloud backend needs an absolute url`};if(i.protocol!==`https:`&&i.protocol!==`http:`)return{kind:`refuse`,reason:`frame.fetch: only http(s) urls are supported`};if(!(t.declaredHosts.includes(i.hostname)||t.approvedOrigins.has(i.origin)))return{kind:`refuse`,reason:`frame.fetch: the target is outside the origins this attachment declared`};let a=t.declaredHosts.length?t.declaredHosts:[i.hostname];return{kind:`consent`,targetHost:i.hostname,promptHosts:a}};exports.frameFetchVerdict=t,exports.normalizeDeclaredHosts=e.t;
|
package/attach-policy.js
CHANGED
package/cloud/dns.d.ts
CHANGED
package/cloud/fetch.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { t as cloudFetch } from "../proxy-
|
|
1
|
+
import { t as cloudFetch } from "../proxy-BkaVTZAf.js";
|
|
2
2
|
export { cloudFetch as fetch };
|
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-DnXxFGm8.js";
|
|
2
2
|
export { Server, Socket, _default, _default as default, connect, createConnection, createServer, isIP, isIPv4, isIPv6 };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./lib-DYKLnpWs.cjs"),n=require("./hosts-9dYv63ud.cjs"),r=require("./api-Djf-XdZ4.cjs"),i=require("./busy-Dv8wzE5M.cjs"),a=require("./proxy-CYcaW5ew.cjs"),o=require("./attach-policy.cjs"),s=require("./contract.cjs"),c=require("./dns.cjs"),l=require("./cloud/fs.cjs"),u=require("./net.cjs"),d=require("./dgram.cjs"),f=require("./http.cjs");let p=require("osra");var m=async()=>{let e=()=>r.o(`frame consent`);try{let t=await e();return{request:typeof t.frameConsent.request==`function`?t.frameConsent.request:void 0,ensure:t.frameConsent.ensure}}catch(t){if(!(t instanceof r.n))throw t;return{request:void 0,ensure:t=>e().then(e=>e.frameConsent.ensure(t))}}},h=3e4,g=()=>t.S(`frame.evaluate: the code did not settle within ${h}ms`,`evaluate`),_=`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,t,n)=>n===null?`frame.${e}: the user did not grant ${t} here`:`frame.${e}: the user did not grant ${t} on ${n}`,S=e=>{let{assertLive:r,attach:i,current:a,declaredHosts:s,documentHost:c,ensure:l,request:u,session:d,approvedOrigins:f}=e,p=new Set,m=async()=>c?await c():(()=>{try{return new URL(a()).hostname}catch{return``}})(),h=()=>n.t([...s,...b(f)]),g=async e=>(await u([e]))[0]??!1;return{gate:async({operation:e,args:a,phase:c})=>{r();let v=n.m(e,a);if(v===null)return;let y=t.u(v);if(y===void 0||y===`auto`)return;if(e===`fetch`){let e=o.frameFetchVerdict({session:d,declaredHosts:s,approvedOrigins:f},c===`ensure`?void 0:a[0],{classifier:`fetchTarget`});if(c===`ensure`&&!d)throw t.C(e.kind===`refuse`?e.reason:``,`fetch`);if(c!==`ensure`&&e.kind===`refuse`)throw t.C(e.reason,`fetch`);if(!u){if(e.kind===`refuse`)throw t.C(e.reason,`fetch`);if(!await l({scope:n.c(a[0],a[1]).scope,hosts:e.promptHosts}))throw t.C(`frame.fetch: the user did not grant this`,`fetch`);return}let r=e.kind===`consent`?e.targetHost:await m(),i=n.t([r,...s]);if(!i.length)throw t.C(`frame: navigate the frame before fetch`,`fetch`);if(await g({category:`network`,hosts:i})===!1)throw t.C(x(`fetch`,`network`,r||null),`fetch`);return}let b=await m();if(!b)throw t.C(`frame: navigate the frame before ${e}`,e);if(!h().includes(b))throw t.C(_,e);if(!u)return;let S=t.l(v);if(S===void 0||y===`critical`&&p.has(`${v} ${b}`))return;let C=n.t([b,...s]),w=await g(y===`critical`?{key:v,hosts:C,attach:i}:{category:S,hosts:C});if(w===!1)throw t.C(x(e,S,null),e);if(w===`once`&&c!==`ensure`)for(let e of C)p.add(`${v} ${e}`)},requestCategories:async e=>{r();let a=await m(),o=n.t(a?[a,...s]:s);if(!o.length)throw TypeError(`frame.request: navigate the frame or declare domains first`);let c=e.map(e=>{let n=e.key;return{named:n,critical:n!==void 0&&t.u(n)===`critical`,category:e.category??(n===void 0?void 0:t.c(n))??`interaction`}}),l=({named:e,critical:t,category:n},r)=>({category:n,...t?{key:e}:{},hosts:o,allow:r});if(!u)return y(),c.map(e=>l(e,!1));let d=await u(c.map(({named:e,critical:t,category:n})=>t?{key:e,hosts:o,attach:i}:{category:n,hosts:o}));return c.map((e,t)=>l(e,d[t]!==void 0&&d[t]!==!1))},boundary:h}},C=e=>e,w=5e3,T=new Set([]),E=()=>`https://fkn.app`,D=e=>e?``:`incognito-${crypto.randomUUID()}`,O=(e,t,n)=>{let r,i=new Promise((e,i)=>{r=setTimeout(()=>i(typeof n==`string`?Error(n):n()),t)});return Promise.race([e,i]).finally(()=>clearTimeout(r))},k=e=>Object.assign(Error(e),{name:t.b}),A=`frame.postMessage: this FKN page predates frame messaging; reload the app to load the current one`,j=!1,M=()=>{j||(j=!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.`))},N=({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)},P=({control:e,target:n,session:r,declaredHosts:i,approvedOrigins:a,attach:o,assertLive:s,guard:c,consent:l,onNavigated:u,relay:d})=>{let f=n,p=Promise.resolve(),{gate:m,requestCategories:v,boundary:y}=S({session:r,declaredHosts:i,approvedOrigins:a,attach:o,assertLive:s,documentHost:typeof e.documentHost==`function`?()=>c(()=>e.documentHost()):void 0,current:()=>f,...l});return t.m({executor:{execute:(n,r,i)=>T.has(r)?Promise.reject(t.T(r,`cloud`)):(s(),c(()=>e.executeLocator(n,r,i))),highlight:async()=>{}},gate:m,request:v,evaluate:async(t,n)=>(s(),await m({parts:[],operation:`evaluate`,args:[t,n],phase:`execute`}),O(c(()=>e.executeLocator([],`evaluate`,[t,n])),h,g)),postMessage:(n,r,i)=>{if(s(),typeof e.messaging!=`function`)throw t.E(A,`postMessage`,`cloud`);if(r!==`*`&&!y().includes(new URL(r).hostname))throw t.C(_,`postMessage`);let{port1:a,port2:o}=new MessageChannel;a.postMessage({data:n,transfer:i},i);let l=[o,r],u=p.then(async()=>(await m({parts:[],operation:`postMessage`,args:l,phase:`execute`}),{answer:c(()=>e.executeLocator([],`postMessage`,l))}));return p=u.catch(()=>{}),u.then(async({answer:e})=>{await e})},listen:t=>(typeof e.messaging!=`function`&&M(),d(t)),goto:async(t,n={})=>{let r=new URL(t,location.href).href;s();let{timeoutMs:i}=n,o=(()=>{try{return new URL(r).origin}catch{return``}})(),l=o!==``&&!a.has(o);l&&a.add(o);try{await O(c(()=>e.goto(r,n)),(i??3e4)+w,`cloud.attachFrame: the render proxy did not answer goto; the frame may have been detached or its page reloaded`)}catch(e){throw l&&a.delete(o),e}f=r,u()},url:()=>f})},F=250,I=500,L=65e3,R=2e3,z=2e3,B=2,ee=2e3,te=2e3,ne=({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},re=(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},V=(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})},H=()=>k(`cloud.attachFrame: the attached window closed, reloaded or left the page FKN attached; attach a fresh window`),U=()=>k(`cloud.attachFrame: the attached window stopped answering; attach a fresh window`),W=()=>k(`cloud.attachFrame: the window went away before it connected; attach a fresh window`),G=()=>k(`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`),K=async e=>{if(typeof window>`u`)throw Error(`cloud.attachFrame needs a window realm`);let{domains:r=[],syncCookies:a=!0,permissions:o}=e,{url:c,width:l,height:u}=t.s(e.window);if(window.origin===`null`)throw new t.f(`opaque-opener`);let d=E(),f=crypto.randomUUID(),m=D(a),h=n.t(r),g=new Set;c&&g.add(new URL(c).origin);let _=a?re(d,f):null,v=window.open(ne({origin:d,target:c,session:m,domains:h,attach:f}),`_blank`,`popup,width=${l},height=${u}`);if(!v)throw _?.remove(),new t.d;let y=new AbortController,b=!1,x=null,S=(e,t=!1)=>{if(x===null){x=e,y.abort(t?U():H());try{v.closed||v.postMessage({type:s.ATTACH_WINDOW_MESSAGE.detach,attach:f,...t?{unanswered:t}:{}},d)}catch{}_&&setTimeout(()=>_.remove(),te)}};_&&V(_,y.signal);let w=new Promise((e,t)=>{y.signal.addEventListener(`abort`,()=>t(y.signal.reason),{once:!0})});w.catch(()=>{});let T=w.then(()=>{},()=>{}),k=()=>{if(y.signal.aborted)throw y.signal.reason},A=e=>y.signal.aborted?Promise.reject(y.signal.reason):Promise.race([e(),w]),j=e=>e.source===v&&e.origin===d;window.addEventListener(`message`,e=>{if(!j(e))return;let n=e.data;typeof n==`object`&&n&&n.attach===f&&(n.type===s.ATTACH_WINDOW_MESSAGE.refused?S(new t.f(n.reason)):n.type===s.ATTACH_WINDOW_MESSAGE.gone&&S(b?H():W()))},{signal:y.signal}),window.addEventListener(`pagehide`,()=>S(H()),{signal:y.signal});let M=()=>{try{v.postMessage({type:s.ATTACH_WINDOW_MESSAGE.hello,attach:f},d)}catch{}};M();let K=setInterval(M,F),q=setInterval(()=>{v.closed&&S(b?H():G())},I);y.signal.addEventListener(`abort`,()=>{clearInterval(K),clearInterval(q)},{once:!0});let J=async e=>{try{return await Promise.race([e,w])}catch(e){throw x??e}};try{let e=await J(O((0,p.expose)({},{key:s.ATTACH_WINDOW_KEY,transport:{emit:(e,t)=>v.postMessage(e,d,t??[]),receive:e=>{let t=t=>{j(t)&&e(t.data,{source:t.source,origin:t.origin})};return window.addEventListener(`message`,t),()=>window.removeEventListener(`message`,t)}},unregisterSignal:y.signal,revivableModules:C(t.nt)}),s.WINDOW_HANDSHAKE_TIMEOUT_MS,`cloud.attachFrame: timed out connecting to the window`));b=!0,clearInterval(K);let n=0,r=setInterval(()=>{O(A(()=>e.ping()),z,`ping`).then(()=>{n=0},()=>{y.signal.aborted||(document.visibilityState===`hidden`?n=0:++n>=B&&S(U(),!0))})},R);y.signal.addEventListener(`abort`,()=>clearInterval(r),{once:!0}),await J(O(e.ready(),L,`cloud.attachFrame: the window never became ready`));let a=i.t(`attached frame`);y.signal.aborted?a():y.signal.addEventListener(`abort`,a,{once:!0});let l=P({control:e,target:c,session:m,declaredHosts:h,approvedOrigins:g,attach:f,assertLive:k,guard:A,consent:{request:t=>A(()=>e.requestConsent(t)),ensure:t=>A(()=>e.requestConsent([t])).then(([e])=>e!==void 0&&e!==!1)},onNavigated:()=>{},relay:N({from:()=>v,origin:d,attach:f,signal:y.signal})}),u=null,_=Object.assign(l,{close:()=>u??=(async()=>{y.signal.aborted||await O(Promise.allSettled([A(()=>e.flushCookies()),A(()=>e.sweepStorage())]),ee,`close`).catch(()=>{});try{v.close()}catch{}S(H())})(),closed:T});return o?.length&&await J(_.request(o)),_}catch(e){let n=x??e;if(!(n instanceof t.f))try{v.close()}catch{}throw S(n),n}},q=`autoplay; fullscreen; encrypted-media; picture-in-picture; clipboard-read; clipboard-write`,J=2e4,Y=65e3,ie=e=>!e||e===`about:blank`,ae=({target:e,session:t,domains:n,attach:r})=>{let i=new URL(`/attach-frame`,E());return e&&i.searchParams.set(`url`,e),t&&i.searchParams.set(`session`,t),n.length&&i.searchParams.set(`domains`,n.join(`,`)),i.searchParams.set(`attach`,r),i.href},oe=(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())},se=()=>k(`cloud.attachFrame: the attached iframe left the document or was reloaded; attach a fresh iframe`),ce=(e,t)=>{let n=[...e.split(`;`),...t.split(`;`)].map(e=>e.trim()).filter(Boolean);return[...new Set(n)].join(`; `)},le=[300,1200,4e3],X=e=>{let t=()=>{if(!e.isConnected)return;let t=e.style.height,n=e.getBoundingClientRect();n.height&&(e.style.height=`${n.height-1}px`,setTimeout(()=>{e.style.height=t},50))};t();for(let e of le)setTimeout(t,e)},ue=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`)},de=async({iframe:e,domains:r=[],syncCookies:a=!0,lockdown:o=!1,permissions:c})=>{if(typeof window>`u`)throw Error(`cloud.attachFrame needs a window realm`);if(o)throw Error(`cloud.attachFrame does not support lockdown; use the extension backend for a sealed frame`);if(!e.isConnected)throw Error(`cloud.attachFrame: the iframe must be connected to the document before attaching`);ue(e);let l=e.getAttribute(`src`)??``,u=(()=>{if(ie(l))return null;try{return new URL(e.src||l,location.href)}catch{throw Error(`cloud.attachFrame: the iframe src is not a valid URL: ${l}`)}})();if(u){let e=new URL(`/attach-frame`,E());if(u.origin===e.origin&&u.pathname===e.pathname)throw Error(`cloud.attachFrame: this iframe is already attached; navigate with the Frame returned by that attach or use a fresh iframe`)}let d=u?.href??``;d&&t.g(d);let f=D(a),h=n.t(r),g=new Set;try{g.add(new URL(d).origin)}catch{}let _=new AbortController,v=e.referrerPolicy,y=e.allow,b=crypto.randomUUID();if(e.referrerPolicy=`origin`,e.allow=ce(q,e.allow),e.src=ae({target:d,session:f,domains:h,attach:b}),!e.contentWindow)throw Error(`cloud.attachFrame: the iframe window is not available`);try{let n=await O((0,p.expose)({},{key:s.ATTACH_FRAME_KEY,origin:E(),transport:{receive:window,emit:e.contentWindow},unregisterSignal:_.signal,revivableModules:C(t.nt)}),J,`cloud.attachFrame: timed out connecting to the render proxy page`);await O(n.ready(),Y,`cloud.attachFrame: the render proxy never became ready`),d&&X(e),oe(e,()=>_.abort());let r=i.t(`attached frame`);_.signal.aborted?r():_.signal.addEventListener(`abort`,r,{once:!0});let a=e.contentWindow,o=P({control:n,target:d,session:f,declaredHosts:h,approvedOrigins:g,attach:b,assertLive:()=>{if(_.signal.aborted||!e.isConnected||e.contentWindow!==a)throw _.abort(),se()},guard:e=>e(),consent:await m(),onNavigated:()=>X(e),relay:N({from:()=>a,origin:E(),attach:b,signal:_.signal})});return c?.length&&await o.request(c),o}catch(t){throw _.abort(),e.referrerPolicy=v,e.allow=y,e.src=d||`about:blank`,t}},Z=(async e=>t.o(e)===`window`?K(e):de(e)),fe=()=>typeof window<`u`&&!0,Q=async()=>{let e=await r.a.then(e=>e.cloud.quota());return{premium:e.premium,overQuota:e.overQuota,throttled:e.overQuota&&!e.premium,usedBytes:e.usedBytes,limitBytes:e.limitBytes,remainingBytes:e.remaining,bytesPerSecond:e.bytesPerSecond,bitsPerSecond:e.bytesPerSecond*8}},pe=e.t({attachFrame:()=>Z,available:()=>$,dgram:()=>d.t,dns:()=>c.t,fetch:()=>a.t,fs:()=>l.t,http:()=>f.t,net:()=>u.t,quota:()=>Q}),$=()=>r.c;Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return fe}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return Z}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return pe}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return Q}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return $}});
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { r as AttachFrameFunction } from "./index-
|
|
2
|
-
import { t as cloudFetch } from "./proxy-
|
|
1
|
+
import { r as AttachFrameFunction } from "./index-DiOxvYoa.js";
|
|
2
|
+
import { t as cloudFetch } from "./proxy-BkaVTZAf.js";
|
|
3
3
|
import { t as dns_d_exports } from "./dns.js";
|
|
4
4
|
import { n as fs_d_exports } from "./fs--NhtUyYa.js";
|
|
5
|
-
import { s as net_d_exports } from "./net-
|
|
5
|
+
import { s as net_d_exports } from "./net-DnXxFGm8.js";
|
|
6
6
|
import { t as dgram_d_exports } from "./dgram.js";
|
|
7
7
|
import { t as http_d_exports } from "./http.js";
|
|
8
8
|
//#region src/cloud/frame.d.ts
|
|
@@ -0,0 +1,476 @@
|
|
|
1
|
+
import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
|
|
2
|
+
import { C as t, E as n, S as r, T as i, b as a, c as o, d as s, f as c, g as l, l as u, m as d, nt as f, o as p, s as m, u as h } from "./lib-FD1Ssqjt.js";
|
|
3
|
+
import { c as g, m as _, t as v } from "./hosts-BzbzOhG8.js";
|
|
4
|
+
import { a as y, c as b, n as x, o as S } from "./api-CtiKFcK3.js";
|
|
5
|
+
import { t as C } from "./busy-B189uX--.js";
|
|
6
|
+
import { t as w } from "./proxy-DDwY3AVG.js";
|
|
7
|
+
import { frameFetchVerdict as T } from "./attach-policy.js";
|
|
8
|
+
import { ATTACH_FRAME_KEY as E, ATTACH_WINDOW_KEY as ee, ATTACH_WINDOW_MESSAGE as D, WINDOW_HANDSHAKE_TIMEOUT_MS as te } from "./contract.js";
|
|
9
|
+
import { t as O } from "./dns.js";
|
|
10
|
+
import { t as k } from "./cloud/fs.js";
|
|
11
|
+
import { t as A } from "./net.js";
|
|
12
|
+
import { t as j } from "./dgram.js";
|
|
13
|
+
import { t as M } from "./http.js";
|
|
14
|
+
import { expose as N } from "osra";
|
|
15
|
+
//#region src/cloud/frame-broker.ts
|
|
16
|
+
var P = async () => {
|
|
17
|
+
let e = () => S("frame consent");
|
|
18
|
+
try {
|
|
19
|
+
let t = await e();
|
|
20
|
+
return {
|
|
21
|
+
request: typeof t.frameConsent.request == "function" ? t.frameConsent.request : void 0,
|
|
22
|
+
ensure: t.frameConsent.ensure
|
|
23
|
+
};
|
|
24
|
+
} catch (t) {
|
|
25
|
+
if (!(t instanceof x)) throw t;
|
|
26
|
+
return {
|
|
27
|
+
request: void 0,
|
|
28
|
+
ensure: (t) => e().then((e) => e.frameConsent.ensure(t))
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
}, F = 3e4, ne = () => r(`frame.evaluate: the code did not settle within ${F}ms`, "evaluate"), I = "frame: this frame no longer holds the document the app attached it to", L = !1, re = () => {
|
|
32
|
+
L || (L = !0, console.warn("[fkn-frame] this FKN broker is too old to ask for permission categories, so nothing was asked for upfront and each capability is asked for as it is first used. Reloading the page picks up the current broker."));
|
|
33
|
+
}, ie = (e) => [...e].flatMap((e) => {
|
|
34
|
+
try {
|
|
35
|
+
return [new URL(e).hostname];
|
|
36
|
+
} catch {
|
|
37
|
+
return [];
|
|
38
|
+
}
|
|
39
|
+
}), R = (e, t, n) => n === null ? `frame.${e}: the user did not grant ${t} here` : `frame.${e}: the user did not grant ${t} on ${n}`, ae = (e) => {
|
|
40
|
+
let { assertLive: n, attach: r, current: i, declaredHosts: a, documentHost: s, ensure: c, request: l, session: d, approvedOrigins: f } = e, p = /* @__PURE__ */ new Set(), m = async () => s ? await s() : (() => {
|
|
41
|
+
try {
|
|
42
|
+
return new URL(i()).hostname;
|
|
43
|
+
} catch {
|
|
44
|
+
return "";
|
|
45
|
+
}
|
|
46
|
+
})(), y = () => v([...a, ...ie(f)]), b = async (e) => (await l([e]))[0] ?? !1;
|
|
47
|
+
return {
|
|
48
|
+
gate: async ({ operation: e, args: i, phase: o }) => {
|
|
49
|
+
n();
|
|
50
|
+
let s = _(e, i);
|
|
51
|
+
if (s === null) return;
|
|
52
|
+
let x = h(s);
|
|
53
|
+
if (x === void 0 || x === "auto") return;
|
|
54
|
+
if (e === "fetch") {
|
|
55
|
+
let e = T({
|
|
56
|
+
session: d,
|
|
57
|
+
declaredHosts: a,
|
|
58
|
+
approvedOrigins: f
|
|
59
|
+
}, o === "ensure" ? void 0 : i[0], { classifier: "fetchTarget" });
|
|
60
|
+
if (o === "ensure" && !d) throw t(e.kind === "refuse" ? e.reason : "", "fetch");
|
|
61
|
+
if (o !== "ensure" && e.kind === "refuse") throw t(e.reason, "fetch");
|
|
62
|
+
if (!l) {
|
|
63
|
+
if (e.kind === "refuse") throw t(e.reason, "fetch");
|
|
64
|
+
if (!await c({
|
|
65
|
+
scope: g(i[0], i[1]).scope,
|
|
66
|
+
hosts: e.promptHosts
|
|
67
|
+
})) throw t("frame.fetch: the user did not grant this", "fetch");
|
|
68
|
+
return;
|
|
69
|
+
}
|
|
70
|
+
let n = e.kind === "consent" ? e.targetHost : await m(), r = v([n, ...a]);
|
|
71
|
+
if (!r.length) throw t("frame: navigate the frame before fetch", "fetch");
|
|
72
|
+
if (await b({
|
|
73
|
+
category: "network",
|
|
74
|
+
hosts: r
|
|
75
|
+
}) === !1) throw t(R("fetch", "network", n || null), "fetch");
|
|
76
|
+
return;
|
|
77
|
+
}
|
|
78
|
+
let S = await m();
|
|
79
|
+
if (!S) throw t(`frame: navigate the frame before ${e}`, e);
|
|
80
|
+
if (!y().includes(S)) throw t(I, e);
|
|
81
|
+
if (!l) return;
|
|
82
|
+
let C = u(s);
|
|
83
|
+
if (C === void 0 || x === "critical" && p.has(`${s} ${S}`)) return;
|
|
84
|
+
let w = v([S, ...a]), E = await b(x === "critical" ? {
|
|
85
|
+
key: s,
|
|
86
|
+
hosts: w,
|
|
87
|
+
attach: r
|
|
88
|
+
} : {
|
|
89
|
+
category: C,
|
|
90
|
+
hosts: w
|
|
91
|
+
});
|
|
92
|
+
if (E === !1) throw t(R(e, C, null), e);
|
|
93
|
+
if (E === "once" && o !== "ensure") for (let e of w) p.add(`${s} ${e}`);
|
|
94
|
+
},
|
|
95
|
+
requestCategories: async (e) => {
|
|
96
|
+
n();
|
|
97
|
+
let t = await m(), i = v(t ? [t, ...a] : a);
|
|
98
|
+
if (!i.length) throw TypeError("frame.request: navigate the frame or declare domains first");
|
|
99
|
+
let s = e.map((e) => {
|
|
100
|
+
let t = e.key;
|
|
101
|
+
return {
|
|
102
|
+
named: t,
|
|
103
|
+
critical: t !== void 0 && h(t) === "critical",
|
|
104
|
+
category: e.category ?? (t === void 0 ? void 0 : o(t)) ?? "interaction"
|
|
105
|
+
};
|
|
106
|
+
}), c = ({ named: e, critical: t, category: n }, r) => ({
|
|
107
|
+
category: n,
|
|
108
|
+
...t ? { key: e } : {},
|
|
109
|
+
hosts: i,
|
|
110
|
+
allow: r
|
|
111
|
+
});
|
|
112
|
+
if (!l) return re(), s.map((e) => c(e, !1));
|
|
113
|
+
let u = await l(s.map(({ named: e, critical: t, category: n }) => t ? {
|
|
114
|
+
key: e,
|
|
115
|
+
hosts: i,
|
|
116
|
+
attach: r
|
|
117
|
+
} : {
|
|
118
|
+
category: n,
|
|
119
|
+
hosts: i
|
|
120
|
+
}));
|
|
121
|
+
return s.map((e, t) => c(e, u[t] !== void 0 && u[t] !== !1));
|
|
122
|
+
},
|
|
123
|
+
boundary: y
|
|
124
|
+
};
|
|
125
|
+
}, z = (e) => e, oe = 5e3, se = /* @__PURE__ */ new Set([]), B = () => "https://fkn.app", V = (e) => e ? "" : `incognito-${crypto.randomUUID()}`, H = (e, t, n) => {
|
|
126
|
+
let r, i = new Promise((e, i) => {
|
|
127
|
+
r = setTimeout(() => i(typeof n == "string" ? Error(n) : n()), t);
|
|
128
|
+
});
|
|
129
|
+
return Promise.race([e, i]).finally(() => clearTimeout(r));
|
|
130
|
+
}, U = (e) => Object.assign(Error(e), { name: a }), ce = "frame.postMessage: this FKN page predates frame messaging; reload the app to load the current one", W = !1, le = () => {
|
|
131
|
+
W || (W = !0, console.warn("[fkn-frame] this FKN page predates frame messaging, so the page's messages and documents are never reported. Reloading the app loads the current one."));
|
|
132
|
+
}, G = ({ from: e, origin: t, attach: n, signal: r }) => (i) => {
|
|
133
|
+
let a = (r) => {
|
|
134
|
+
if (r.source === null || r.source !== e() || r.origin !== t) return;
|
|
135
|
+
let a = r.data;
|
|
136
|
+
typeof a == "object" && a && a.type === "fkn-frame-message" && a.attach === n && typeof a.origin == "string" && (a.kind === "message" ? i({
|
|
137
|
+
type: "message",
|
|
138
|
+
data: a.data,
|
|
139
|
+
origin: a.origin,
|
|
140
|
+
ports: r.ports
|
|
141
|
+
}) : a.kind === "document" && i({
|
|
142
|
+
type: "document",
|
|
143
|
+
origin: a.origin
|
|
144
|
+
}));
|
|
145
|
+
};
|
|
146
|
+
return window.addEventListener("message", a, { signal: r }), () => window.removeEventListener("message", a);
|
|
147
|
+
}, K = ({ control: e, target: r, session: a, declaredHosts: o, approvedOrigins: s, attach: c, assertLive: l, guard: u, consent: f, onNavigated: p, relay: m }) => {
|
|
148
|
+
let h = r, g = Promise.resolve(), { gate: _, requestCategories: v, boundary: y } = ae({
|
|
149
|
+
session: a,
|
|
150
|
+
declaredHosts: o,
|
|
151
|
+
approvedOrigins: s,
|
|
152
|
+
attach: c,
|
|
153
|
+
assertLive: l,
|
|
154
|
+
documentHost: typeof e.documentHost == "function" ? () => u(() => e.documentHost()) : void 0,
|
|
155
|
+
current: () => h,
|
|
156
|
+
...f
|
|
157
|
+
});
|
|
158
|
+
return d({
|
|
159
|
+
executor: {
|
|
160
|
+
execute: (t, n, r) => se.has(n) ? Promise.reject(i(n, "cloud")) : (l(), u(() => e.executeLocator(t, n, r))),
|
|
161
|
+
highlight: async () => {}
|
|
162
|
+
},
|
|
163
|
+
gate: _,
|
|
164
|
+
request: v,
|
|
165
|
+
evaluate: async (t, n) => (l(), await _({
|
|
166
|
+
parts: [],
|
|
167
|
+
operation: "evaluate",
|
|
168
|
+
args: [t, n],
|
|
169
|
+
phase: "execute"
|
|
170
|
+
}), H(u(() => e.executeLocator([], "evaluate", [t, n])), F, ne)),
|
|
171
|
+
postMessage: (r, i, a) => {
|
|
172
|
+
if (l(), typeof e.messaging != "function") throw n(ce, "postMessage", "cloud");
|
|
173
|
+
if (i !== "*" && !y().includes(new URL(i).hostname)) throw t(I, "postMessage");
|
|
174
|
+
let { port1: o, port2: s } = new MessageChannel();
|
|
175
|
+
o.postMessage({
|
|
176
|
+
data: r,
|
|
177
|
+
transfer: a
|
|
178
|
+
}, a);
|
|
179
|
+
let c = [s, i], d = g.then(async () => (await _({
|
|
180
|
+
parts: [],
|
|
181
|
+
operation: "postMessage",
|
|
182
|
+
args: c,
|
|
183
|
+
phase: "execute"
|
|
184
|
+
}), { answer: u(() => e.executeLocator([], "postMessage", c)) }));
|
|
185
|
+
return g = d.catch(() => {}), d.then(async ({ answer: e }) => {
|
|
186
|
+
await e;
|
|
187
|
+
});
|
|
188
|
+
},
|
|
189
|
+
listen: (t) => (typeof e.messaging != "function" && le(), m(t)),
|
|
190
|
+
goto: async (t, n = {}) => {
|
|
191
|
+
let r = new URL(t, location.href).href;
|
|
192
|
+
l();
|
|
193
|
+
let { timeoutMs: i } = n, a = (() => {
|
|
194
|
+
try {
|
|
195
|
+
return new URL(r).origin;
|
|
196
|
+
} catch {
|
|
197
|
+
return "";
|
|
198
|
+
}
|
|
199
|
+
})(), o = a !== "" && !s.has(a);
|
|
200
|
+
o && s.add(a);
|
|
201
|
+
try {
|
|
202
|
+
await H(u(() => e.goto(r, n)), (i ?? 3e4) + oe, "cloud.attachFrame: the render proxy did not answer goto; the frame may have been detached or its page reloaded");
|
|
203
|
+
} catch (e) {
|
|
204
|
+
throw o && s.delete(a), e;
|
|
205
|
+
}
|
|
206
|
+
h = r, p();
|
|
207
|
+
},
|
|
208
|
+
url: () => h
|
|
209
|
+
});
|
|
210
|
+
}, ue = 250, de = 500, fe = 65e3, pe = 2e3, q = 2e3, me = 2, he = 2e3, ge = 2e3, _e = ({ origin: e, target: t, session: n, domains: r, attach: i }) => {
|
|
211
|
+
let a = new URL("/attach-window", e);
|
|
212
|
+
return a.searchParams.set("attach", i), t && a.searchParams.set("url", t), n && a.searchParams.set("session", n), r.length && a.searchParams.set("domains", r.join(",")), a.href;
|
|
213
|
+
}, ve = (e, t) => {
|
|
214
|
+
let n = document.createElement("iframe"), r = new URL("/attach-jar", e);
|
|
215
|
+
return r.searchParams.set("attach", t), n.src = r.href, n.tabIndex = -1, n.setAttribute("aria-hidden", "true"), n.setAttribute("style", "display:none"), (document.body ?? document.documentElement).appendChild(n), n;
|
|
216
|
+
}, ye = (e, t) => {
|
|
217
|
+
let n = new MutationObserver(() => {
|
|
218
|
+
e.isConnected || t.aborted || (n.disconnect(), console.warn("cloud.attachFrame: the window's jar anchor was removed from this page, so a sign-in in the window no longer reaches this app's cookie jar"));
|
|
219
|
+
});
|
|
220
|
+
e.parentNode && n.observe(e.parentNode, { childList: !0 }), n.observe(document.documentElement, { childList: !0 }), t.addEventListener("abort", () => n.disconnect(), { once: !0 });
|
|
221
|
+
}, J = () => U("cloud.attachFrame: the attached window closed, reloaded or left the page FKN attached; attach a fresh window"), Y = () => U("cloud.attachFrame: the attached window stopped answering; attach a fresh window"), be = () => U("cloud.attachFrame: the window went away before it connected; attach a fresh window"), xe = () => U("cloud.attachFrame: the window closed before it connected. Either the user closed it, or this page's Cross-Origin-Opener-Policy cut its link to the window"), Se = async (e) => {
|
|
222
|
+
if (typeof window > "u") throw Error("cloud.attachFrame needs a window realm");
|
|
223
|
+
let { domains: t = [], syncCookies: n = !0, permissions: r } = e, { url: i, width: a, height: o } = m(e.window);
|
|
224
|
+
if (window.origin === "null") throw new c("opaque-opener");
|
|
225
|
+
let l = B(), u = crypto.randomUUID(), d = V(n), p = v(t), h = /* @__PURE__ */ new Set();
|
|
226
|
+
i && h.add(new URL(i).origin);
|
|
227
|
+
let g = n ? ve(l, u) : null, _ = window.open(_e({
|
|
228
|
+
origin: l,
|
|
229
|
+
target: i,
|
|
230
|
+
session: d,
|
|
231
|
+
domains: p,
|
|
232
|
+
attach: u
|
|
233
|
+
}), "_blank", `popup,width=${a},height=${o}`);
|
|
234
|
+
if (!_) throw g?.remove(), new s();
|
|
235
|
+
let y = new AbortController(), b = !1, x = null, S = (e, t = !1) => {
|
|
236
|
+
if (x === null) {
|
|
237
|
+
x = e, y.abort(t ? Y() : J());
|
|
238
|
+
try {
|
|
239
|
+
_.closed || _.postMessage({
|
|
240
|
+
type: D.detach,
|
|
241
|
+
attach: u,
|
|
242
|
+
...t ? { unanswered: t } : {}
|
|
243
|
+
}, l);
|
|
244
|
+
} catch {}
|
|
245
|
+
g && setTimeout(() => g.remove(), ge);
|
|
246
|
+
}
|
|
247
|
+
};
|
|
248
|
+
g && ye(g, y.signal);
|
|
249
|
+
let w = new Promise((e, t) => {
|
|
250
|
+
y.signal.addEventListener("abort", () => t(y.signal.reason), { once: !0 });
|
|
251
|
+
});
|
|
252
|
+
w.catch(() => {});
|
|
253
|
+
let T = w.then(() => {}, () => {}), E = () => {
|
|
254
|
+
if (y.signal.aborted) throw y.signal.reason;
|
|
255
|
+
}, O = (e) => y.signal.aborted ? Promise.reject(y.signal.reason) : Promise.race([e(), w]), k = (e) => e.source === _ && e.origin === l;
|
|
256
|
+
window.addEventListener("message", (e) => {
|
|
257
|
+
if (!k(e)) return;
|
|
258
|
+
let t = e.data;
|
|
259
|
+
typeof t == "object" && t && t.attach === u && (t.type === D.refused ? S(new c(t.reason)) : t.type === D.gone && S(b ? J() : be()));
|
|
260
|
+
}, { signal: y.signal }), window.addEventListener("pagehide", () => S(J()), { signal: y.signal });
|
|
261
|
+
let A = () => {
|
|
262
|
+
try {
|
|
263
|
+
_.postMessage({
|
|
264
|
+
type: D.hello,
|
|
265
|
+
attach: u
|
|
266
|
+
}, l);
|
|
267
|
+
} catch {}
|
|
268
|
+
};
|
|
269
|
+
A();
|
|
270
|
+
let j = setInterval(A, ue), M = setInterval(() => {
|
|
271
|
+
_.closed && S(b ? J() : xe());
|
|
272
|
+
}, de);
|
|
273
|
+
y.signal.addEventListener("abort", () => {
|
|
274
|
+
clearInterval(j), clearInterval(M);
|
|
275
|
+
}, { once: !0 });
|
|
276
|
+
let P = async (e) => {
|
|
277
|
+
try {
|
|
278
|
+
return await Promise.race([e, w]);
|
|
279
|
+
} catch (e) {
|
|
280
|
+
throw x ?? e;
|
|
281
|
+
}
|
|
282
|
+
};
|
|
283
|
+
try {
|
|
284
|
+
let e = await P(H(N({}, {
|
|
285
|
+
key: ee,
|
|
286
|
+
transport: {
|
|
287
|
+
emit: (e, t) => _.postMessage(e, l, t ?? []),
|
|
288
|
+
receive: (e) => {
|
|
289
|
+
let t = (t) => {
|
|
290
|
+
k(t) && e(t.data, {
|
|
291
|
+
source: t.source,
|
|
292
|
+
origin: t.origin
|
|
293
|
+
});
|
|
294
|
+
};
|
|
295
|
+
return window.addEventListener("message", t), () => window.removeEventListener("message", t);
|
|
296
|
+
}
|
|
297
|
+
},
|
|
298
|
+
unregisterSignal: y.signal,
|
|
299
|
+
revivableModules: z(f)
|
|
300
|
+
}), te, "cloud.attachFrame: timed out connecting to the window"));
|
|
301
|
+
b = !0, clearInterval(j);
|
|
302
|
+
let t = 0, n = setInterval(() => {
|
|
303
|
+
H(O(() => e.ping()), q, "ping").then(() => {
|
|
304
|
+
t = 0;
|
|
305
|
+
}, () => {
|
|
306
|
+
y.signal.aborted || (document.visibilityState === "hidden" ? t = 0 : ++t >= me && S(Y(), !0));
|
|
307
|
+
});
|
|
308
|
+
}, pe);
|
|
309
|
+
y.signal.addEventListener("abort", () => clearInterval(n), { once: !0 }), await P(H(e.ready(), fe, "cloud.attachFrame: the window never became ready"));
|
|
310
|
+
let a = C("attached frame");
|
|
311
|
+
y.signal.aborted ? a() : y.signal.addEventListener("abort", a, { once: !0 });
|
|
312
|
+
let o = K({
|
|
313
|
+
control: e,
|
|
314
|
+
target: i,
|
|
315
|
+
session: d,
|
|
316
|
+
declaredHosts: p,
|
|
317
|
+
approvedOrigins: h,
|
|
318
|
+
attach: u,
|
|
319
|
+
assertLive: E,
|
|
320
|
+
guard: O,
|
|
321
|
+
consent: {
|
|
322
|
+
request: (t) => O(() => e.requestConsent(t)),
|
|
323
|
+
ensure: (t) => O(() => e.requestConsent([t])).then(([e]) => e !== void 0 && e !== !1)
|
|
324
|
+
},
|
|
325
|
+
onNavigated: () => {},
|
|
326
|
+
relay: G({
|
|
327
|
+
from: () => _,
|
|
328
|
+
origin: l,
|
|
329
|
+
attach: u,
|
|
330
|
+
signal: y.signal
|
|
331
|
+
})
|
|
332
|
+
}), s = null, c = Object.assign(o, {
|
|
333
|
+
close: () => s ??= (async () => {
|
|
334
|
+
y.signal.aborted || await H(Promise.allSettled([O(() => e.flushCookies()), O(() => e.sweepStorage())]), he, "close").catch(() => {});
|
|
335
|
+
try {
|
|
336
|
+
_.close();
|
|
337
|
+
} catch {}
|
|
338
|
+
S(J());
|
|
339
|
+
})(),
|
|
340
|
+
closed: T
|
|
341
|
+
});
|
|
342
|
+
return r?.length && await P(c.request(r)), c;
|
|
343
|
+
} catch (e) {
|
|
344
|
+
let t = x ?? e;
|
|
345
|
+
if (!(t instanceof c)) try {
|
|
346
|
+
_.close();
|
|
347
|
+
} catch {}
|
|
348
|
+
throw S(t), t;
|
|
349
|
+
}
|
|
350
|
+
}, Ce = "autoplay; fullscreen; encrypted-media; picture-in-picture; clipboard-read; clipboard-write", we = 2e4, Te = 65e3, Ee = (e) => !e || e === "about:blank", De = ({ target: e, session: t, domains: n, attach: r }) => {
|
|
351
|
+
let i = new URL("/attach-frame", B());
|
|
352
|
+
return e && i.searchParams.set("url", e), t && i.searchParams.set("session", t), n.length && i.searchParams.set("domains", n.join(",")), i.searchParams.set("attach", r), i.href;
|
|
353
|
+
}, Oe = (e, t) => {
|
|
354
|
+
let n = () => {
|
|
355
|
+
a(), t();
|
|
356
|
+
}, r = e.parentNode, i = new MutationObserver(() => {
|
|
357
|
+
(!e.isConnected || e.parentNode !== r) && (a(), t());
|
|
358
|
+
}), a = () => {
|
|
359
|
+
window.removeEventListener("pagehide", n), i.disconnect();
|
|
360
|
+
};
|
|
361
|
+
window.addEventListener("pagehide", n, { once: !0 }), r && i.observe(r, { childList: !0 }), e.isConnected || (a(), t());
|
|
362
|
+
}, ke = () => U("cloud.attachFrame: the attached iframe left the document or was reloaded; attach a fresh iframe"), Ae = (e, t) => {
|
|
363
|
+
let n = [...e.split(";"), ...t.split(";")].map((e) => e.trim()).filter(Boolean);
|
|
364
|
+
return [...new Set(n)].join("; ");
|
|
365
|
+
}, je = [
|
|
366
|
+
300,
|
|
367
|
+
1200,
|
|
368
|
+
4e3
|
|
369
|
+
], X = (e) => {
|
|
370
|
+
let t = () => {
|
|
371
|
+
if (!e.isConnected) return;
|
|
372
|
+
let t = e.style.height, n = e.getBoundingClientRect();
|
|
373
|
+
n.height && (e.style.height = `${n.height - 1}px`, setTimeout(() => {
|
|
374
|
+
e.style.height = t;
|
|
375
|
+
}, 50));
|
|
376
|
+
};
|
|
377
|
+
t();
|
|
378
|
+
for (let e of je) setTimeout(t, e);
|
|
379
|
+
}, Me = (e) => {
|
|
380
|
+
let t = e.getAttribute("sandbox");
|
|
381
|
+
if (t === null) return;
|
|
382
|
+
let n = new Set(t.toLowerCase().split(/\s+/).filter(Boolean)), r = ["allow-scripts", "allow-same-origin"].filter((e) => !n.has(e));
|
|
383
|
+
if (r.length) throw Error(`cloud.attachFrame: the iframe's sandbox attribute must include ${r.join(" and ")} for the render proxy to load`);
|
|
384
|
+
}, Ne = async ({ iframe: e, domains: t = [], syncCookies: n = !0, lockdown: r = !1, permissions: i }) => {
|
|
385
|
+
if (typeof window > "u") throw Error("cloud.attachFrame needs a window realm");
|
|
386
|
+
if (r) throw Error("cloud.attachFrame does not support lockdown; use the extension backend for a sealed frame");
|
|
387
|
+
if (!e.isConnected) throw Error("cloud.attachFrame: the iframe must be connected to the document before attaching");
|
|
388
|
+
Me(e);
|
|
389
|
+
let a = e.getAttribute("src") ?? "", o = (() => {
|
|
390
|
+
if (Ee(a)) return null;
|
|
391
|
+
try {
|
|
392
|
+
return new URL(e.src || a, location.href);
|
|
393
|
+
} catch {
|
|
394
|
+
throw Error(`cloud.attachFrame: the iframe src is not a valid URL: ${a}`);
|
|
395
|
+
}
|
|
396
|
+
})();
|
|
397
|
+
if (o) {
|
|
398
|
+
let e = new URL("/attach-frame", B());
|
|
399
|
+
if (o.origin === e.origin && o.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");
|
|
400
|
+
}
|
|
401
|
+
let s = o?.href ?? "";
|
|
402
|
+
s && l(s);
|
|
403
|
+
let c = V(n), u = v(t), d = /* @__PURE__ */ new Set();
|
|
404
|
+
try {
|
|
405
|
+
d.add(new URL(s).origin);
|
|
406
|
+
} catch {}
|
|
407
|
+
let p = new AbortController(), m = e.referrerPolicy, h = e.allow, g = crypto.randomUUID();
|
|
408
|
+
if (e.referrerPolicy = "origin", e.allow = Ae(Ce, e.allow), e.src = De({
|
|
409
|
+
target: s,
|
|
410
|
+
session: c,
|
|
411
|
+
domains: u,
|
|
412
|
+
attach: g
|
|
413
|
+
}), !e.contentWindow) throw Error("cloud.attachFrame: the iframe window is not available");
|
|
414
|
+
try {
|
|
415
|
+
let t = await H(N({}, {
|
|
416
|
+
key: E,
|
|
417
|
+
origin: B(),
|
|
418
|
+
transport: {
|
|
419
|
+
receive: window,
|
|
420
|
+
emit: e.contentWindow
|
|
421
|
+
},
|
|
422
|
+
unregisterSignal: p.signal,
|
|
423
|
+
revivableModules: z(f)
|
|
424
|
+
}), we, "cloud.attachFrame: timed out connecting to the render proxy page");
|
|
425
|
+
await H(t.ready(), Te, "cloud.attachFrame: the render proxy never became ready"), s && X(e), Oe(e, () => p.abort());
|
|
426
|
+
let n = C("attached frame");
|
|
427
|
+
p.signal.aborted ? n() : p.signal.addEventListener("abort", n, { once: !0 });
|
|
428
|
+
let r = e.contentWindow, a = K({
|
|
429
|
+
control: t,
|
|
430
|
+
target: s,
|
|
431
|
+
session: c,
|
|
432
|
+
declaredHosts: u,
|
|
433
|
+
approvedOrigins: d,
|
|
434
|
+
attach: g,
|
|
435
|
+
assertLive: () => {
|
|
436
|
+
if (p.signal.aborted || !e.isConnected || e.contentWindow !== r) throw p.abort(), ke();
|
|
437
|
+
},
|
|
438
|
+
guard: (e) => e(),
|
|
439
|
+
consent: await P(),
|
|
440
|
+
onNavigated: () => X(e),
|
|
441
|
+
relay: G({
|
|
442
|
+
from: () => r,
|
|
443
|
+
origin: B(),
|
|
444
|
+
attach: g,
|
|
445
|
+
signal: p.signal
|
|
446
|
+
})
|
|
447
|
+
});
|
|
448
|
+
return i?.length && await a.request(i), a;
|
|
449
|
+
} catch (t) {
|
|
450
|
+
throw p.abort(), e.referrerPolicy = m, e.allow = h, e.src = s || "about:blank", t;
|
|
451
|
+
}
|
|
452
|
+
}, Z = (async (e) => p(e) === "window" ? Se(e) : Ne(e)), Pe = () => typeof window < "u" && !0, Q = async () => {
|
|
453
|
+
let e = await y.then((e) => e.cloud.quota());
|
|
454
|
+
return {
|
|
455
|
+
premium: e.premium,
|
|
456
|
+
overQuota: e.overQuota,
|
|
457
|
+
throttled: e.overQuota && !e.premium,
|
|
458
|
+
usedBytes: e.usedBytes,
|
|
459
|
+
limitBytes: e.limitBytes,
|
|
460
|
+
remainingBytes: e.remaining,
|
|
461
|
+
bytesPerSecond: e.bytesPerSecond,
|
|
462
|
+
bitsPerSecond: e.bytesPerSecond * 8
|
|
463
|
+
};
|
|
464
|
+
}, Fe = /* @__PURE__ */ e({
|
|
465
|
+
attachFrame: () => Z,
|
|
466
|
+
available: () => $,
|
|
467
|
+
dgram: () => j,
|
|
468
|
+
dns: () => O,
|
|
469
|
+
fetch: () => w,
|
|
470
|
+
fs: () => k,
|
|
471
|
+
http: () => M,
|
|
472
|
+
net: () => A,
|
|
473
|
+
quota: () => Q
|
|
474
|
+
}), $ = () => b;
|
|
475
|
+
//#endregion
|
|
476
|
+
export { Pe as a, Z as i, Fe as n, Q as r, $ as t };
|
package/cloud.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./proxy-CYcaW5ew.cjs"),t=require("./cloud-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./proxy-CYcaW5ew.cjs"),t=require("./cloud-Beg4iCRU.cjs"),n=require("./dns.cjs"),r=require("./cloud/fs.cjs"),i=require("./net.cjs"),a=require("./dgram.cjs"),o=require("./http.cjs");exports.attachFrame=t.i,exports.available=t.t,Object.defineProperty(exports,"dgram",{enumerable:!0,get:function(){return a.t}}),Object.defineProperty(exports,"dns",{enumerable:!0,get:function(){return n.t}}),exports.fetch=e.t,Object.defineProperty(exports,"fs",{enumerable:!0,get:function(){return r.t}}),Object.defineProperty(exports,"http",{enumerable:!0,get:function(){return o.t}}),Object.defineProperty(exports,"net",{enumerable:!0,get:function(){return i.t}}),exports.quota=t.r;
|
package/cloud.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { t as cloudFetch } from "./proxy-
|
|
2
|
-
import { a as attachFrame, i as quota, r as QuotaStatus, t as available } from "./cloud-
|
|
1
|
+
import { t as cloudFetch } from "./proxy-BkaVTZAf.js";
|
|
2
|
+
import { a as attachFrame, i as quota, r as QuotaStatus, t as available } from "./cloud-Bfc6rkF2.js";
|
|
3
3
|
import { t as dns_d_exports } from "./dns.js";
|
|
4
4
|
import { n as fs_d_exports } from "./fs--NhtUyYa.js";
|
|
5
|
-
import { s as net_d_exports } from "./net-
|
|
5
|
+
import { s as net_d_exports } from "./net-DnXxFGm8.js";
|
|
6
6
|
import { t as dgram_d_exports } from "./dgram.js";
|
|
7
7
|
import { t as http_d_exports } from "./http.js";
|
|
8
8
|
export { type QuotaStatus, attachFrame, available, dgram_d_exports as dgram, dns_d_exports as dns, cloudFetch as fetch, fs_d_exports as fs, http_d_exports as http, net_d_exports as net, quota };
|
package/cloud.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as e } from "./proxy-DDwY3AVG.js";
|
|
2
|
-
import { i as t, r as n, t as r } from "./cloud-
|
|
2
|
+
import { i as t, r as n, t as r } from "./cloud-EfyYfgVT.js";
|
|
3
3
|
import { t as i } from "./dns.js";
|
|
4
4
|
import { t as a } from "./cloud/fs.js";
|
|
5
5
|
import { t as o } from "./net.js";
|