@fkn/lib 0.9.14 → 0.9.16
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/cloud/dgram.cjs +1 -1
- package/cloud/dgram.js +1 -1
- package/cloud/net.cjs +1 -1
- package/cloud/net.d.ts +1 -1
- package/cloud/net.js +1 -1
- package/{cloud-xlvU7_rs.d.ts → cloud--8SYg1so.d.ts} +2 -2
- package/cloud-Djen7gmX.js +130 -0
- package/cloud-OOksFtTZ.cjs +1 -0
- package/cloud.cjs +1 -1
- package/cloud.d.ts +2 -2
- package/cloud.js +3 -3
- package/{dgram-BDXvc69t.js → dgram-BP0jykk_.js} +14 -7
- package/dgram-CECo4EQT.cjs +1 -0
- package/dgram.cjs +1 -1
- package/dgram.d.ts +55 -0
- package/dgram.js +1 -1
- package/{extension-B0qU5XuR.d.ts → extension-CN9oFZ0Q.d.ts} +1 -1
- package/extension-DPlyfEPO.cjs +1 -0
- package/extension-xVdvgkZL.js +78 -0
- package/extension.cjs +1 -1
- package/extension.d.ts +2 -2
- package/extension.js +3 -3
- package/http.cjs +1 -1
- package/http.d.ts +1 -1
- package/http.js +1 -1
- package/{index-DQfP-Uhy.d.ts → index-DLaonjpx.d.ts} +18 -18
- package/index.cjs +1 -1
- package/index.d.ts +4 -4
- package/index.js +11 -11
- package/{lib-BcEnB4iV.js → lib-CegQxwDI.js} +559 -298
- package/lib-ulyxIbTr.cjs +53 -0
- package/{net-CR3V3Q5W.js → net-BDAN5Mvc.js} +12 -4
- package/{net-1AjTrb23.d.ts → net-BnGcJpUb.d.ts} +14 -1
- package/net-kma1sFhK.cjs +1 -0
- package/net.cjs +1 -1
- package/net.d.ts +1 -1
- package/net.js +1 -1
- package/package.json +1 -1
- package/cloud-C28lGQEP.cjs +0 -1
- package/cloud-y88zoTpE.js +0 -283
- package/dgram-C1E6TUWN.cjs +0 -1
- package/extension-B8fd9lvk.cjs +0 -1
- package/extension-Cts968cO.js +0 -78
- package/lib-CQqdCndr.cjs +0 -31
- package/net-D3A-Z8RL.cjs +0 -1
package/cloud/dgram.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../dgram-
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../dgram-CECo4EQT.cjs");exports.Socket=e.t,exports.createSocket=e.n,exports.default=e.r;
|
package/cloud/dgram.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as e, r as t, t as n } from "../dgram-
|
|
1
|
+
import { n as e, r as t, t as n } from "../dgram-BP0jykk_.js";
|
|
2
2
|
export { n as Socket, e as createSocket, t as default };
|
package/cloud/net.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../utils-QfNXtEhb.cjs"),t=require("../net-
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("../utils-QfNXtEhb.cjs"),t=require("../net-kma1sFhK.cjs");exports.Server=t.t,exports.Socket=t.n,exports._default=t.r,exports.default=t.r,exports.connect=t.i,exports.createConnection=t.a,exports.createServer=t.o,exports.isIP=e.r,exports.isIPv4=e.i,exports.isIPv6=e.a;
|
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-BnGcJpUb.js";
|
|
2
2
|
export { Server, Socket, _default, _default as default, connect, createConnection, createServer, isIP, isIPv4, isIPv6 };
|
package/cloud/net.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { a as e, i as t, r as n } from "../utils-DVlbuXmW.js";
|
|
2
|
-
import { a as r, i, n as a, o, r as s, t as c } from "../net-
|
|
2
|
+
import { a as r, i, n as a, o, r as s, t as c } from "../net-BDAN5Mvc.js";
|
|
3
3
|
export { c as Server, a as Socket, s as _default, s as default, i as connect, r as createConnection, o as createServer, n as isIP, t as isIPv4, e as isIPv6 };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { t as cloudFetch } from "./proxy-BihVUSnB.js";
|
|
2
|
-
import { d as Frame, u as AttachFrameOptions } from "./index-
|
|
2
|
+
import { d as Frame, u as AttachFrameOptions } from "./index-DLaonjpx.js";
|
|
3
3
|
import { t as dns_d_exports } from "./dns.js";
|
|
4
4
|
import { n as fs_d_exports } from "./fs-DTmSCXwa.js";
|
|
5
|
-
import { s as net_d_exports } from "./net-
|
|
5
|
+
import { s as net_d_exports } from "./net-BnGcJpUb.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
|
|
|
@@ -0,0 +1,130 @@
|
|
|
1
|
+
import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
|
|
2
|
+
import { L as t, a as n, f as r, h as i, s as a } from "./lib-CegQxwDI.js";
|
|
3
|
+
import { r as o, t as s } from "./api-DAQQBty8.js";
|
|
4
|
+
import { t as c } from "./proxy-BthoIRuv.js";
|
|
5
|
+
import { t as l } from "./dns.js";
|
|
6
|
+
import { t as u } from "./cloud/fs.js";
|
|
7
|
+
import { s as d } from "./net-BDAN5Mvc.js";
|
|
8
|
+
import { i as f } from "./dgram-BP0jykk_.js";
|
|
9
|
+
import { t as p } from "./http.js";
|
|
10
|
+
import { expose as m } from "osra";
|
|
11
|
+
//#region src/lib/cloud/frame.ts
|
|
12
|
+
var h = (e) => e, g = "autoplay; fullscreen; encrypted-media; picture-in-picture; clipboard-read; clipboard-write", _ = 2e4, v = 65e3, y = 3e4, b = 5e3, x = /* @__PURE__ */ new Set(), S = () => "https://fkn.app", C = (e) => !e || e === "about:blank", w = (e) => e ? "" : `incognito-${crypto.randomUUID()}`, T = ({ target: e, session: t }) => {
|
|
13
|
+
let n = new URL("/attach-frame", S());
|
|
14
|
+
return e && n.searchParams.set("url", e), t && n.searchParams.set("session", t), n.href;
|
|
15
|
+
}, E = (e, t, n) => {
|
|
16
|
+
let r, i = new Promise((e, i) => {
|
|
17
|
+
r = setTimeout(() => i(Error(n)), t);
|
|
18
|
+
});
|
|
19
|
+
return Promise.race([e, i]).finally(() => clearTimeout(r));
|
|
20
|
+
}, D = (e, t) => {
|
|
21
|
+
let n = () => {
|
|
22
|
+
a(), t();
|
|
23
|
+
}, r = e.parentNode, i = new MutationObserver(() => {
|
|
24
|
+
(!e.isConnected || e.parentNode !== r) && (a(), t());
|
|
25
|
+
}), a = () => {
|
|
26
|
+
window.removeEventListener("pagehide", n), i.disconnect();
|
|
27
|
+
};
|
|
28
|
+
window.addEventListener("pagehide", n, { once: !0 }), r && i.observe(r, { childList: !0 }), e.isConnected || (a(), t());
|
|
29
|
+
}, O = () => Object.assign(/* @__PURE__ */ Error("cloud.attachFrame: the attached iframe left the document or was reloaded; attach a fresh iframe"), { name: i }), k = (e, t) => {
|
|
30
|
+
let n = [...e.split(";"), ...t.split(";")].map((e) => e.trim()).filter(Boolean);
|
|
31
|
+
return [...new Set(n)].join("; ");
|
|
32
|
+
}, A = [
|
|
33
|
+
300,
|
|
34
|
+
1200,
|
|
35
|
+
4e3
|
|
36
|
+
], j = (e) => {
|
|
37
|
+
let t = () => {
|
|
38
|
+
if (!e.isConnected) return;
|
|
39
|
+
let t = e.style.height, n = e.getBoundingClientRect();
|
|
40
|
+
n.height && (e.style.height = `${n.height - 1}px`, setTimeout(() => {
|
|
41
|
+
e.style.height = t;
|
|
42
|
+
}, 50));
|
|
43
|
+
};
|
|
44
|
+
t();
|
|
45
|
+
for (let e of A) setTimeout(t, e);
|
|
46
|
+
}, M = (e) => {
|
|
47
|
+
let t = e.getAttribute("sandbox");
|
|
48
|
+
if (t === null) return;
|
|
49
|
+
let n = new Set(t.toLowerCase().split(/\s+/).filter(Boolean)), r = ["allow-scripts", "allow-same-origin"].filter((e) => !n.has(e));
|
|
50
|
+
if (r.length) throw Error(`cloud.attachFrame: the iframe's sandbox attribute must include ${r.join(" and ")} for the render proxy to load`);
|
|
51
|
+
}, N = async ({ iframe: e, domains: i = [], syncCookies: o = !0, lockdown: s = !1 }) => {
|
|
52
|
+
if (typeof window > "u") throw Error("cloud.attachFrame needs a window realm");
|
|
53
|
+
if (s) throw Error("cloud.attachFrame does not support lockdown; use the extension backend for a sealed frame");
|
|
54
|
+
if (!e.isConnected) throw Error("cloud.attachFrame: the iframe must be connected to the document before attaching");
|
|
55
|
+
M(e);
|
|
56
|
+
let c = e.getAttribute("src") ?? "", l = (() => {
|
|
57
|
+
if (C(c)) return null;
|
|
58
|
+
try {
|
|
59
|
+
return new URL(e.src || c, location.href);
|
|
60
|
+
} catch {
|
|
61
|
+
throw Error(`cloud.attachFrame: the iframe src is not a valid URL: ${c}`);
|
|
62
|
+
}
|
|
63
|
+
})();
|
|
64
|
+
if (l) {
|
|
65
|
+
let e = new URL("/attach-frame", S());
|
|
66
|
+
if (l.origin === e.origin && l.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");
|
|
67
|
+
}
|
|
68
|
+
let u = l?.href ?? "";
|
|
69
|
+
u && a(u);
|
|
70
|
+
let d = u, f = w(o), p = new AbortController(), A = e.referrerPolicy, N = e.allow;
|
|
71
|
+
if (e.referrerPolicy = "origin", e.allow = k(g, e.allow), e.src = T({
|
|
72
|
+
target: u,
|
|
73
|
+
session: f
|
|
74
|
+
}), !e.contentWindow) throw Error("cloud.attachFrame: the iframe window is not available");
|
|
75
|
+
try {
|
|
76
|
+
let i = await E(m({}, {
|
|
77
|
+
key: "fkn-attach-frame",
|
|
78
|
+
origin: S(),
|
|
79
|
+
transport: {
|
|
80
|
+
receive: window,
|
|
81
|
+
emit: e.contentWindow
|
|
82
|
+
},
|
|
83
|
+
unregisterSignal: p.signal,
|
|
84
|
+
revivableModules: h(t)
|
|
85
|
+
}), _, "cloud.attachFrame: timed out connecting to the render proxy page");
|
|
86
|
+
await E(i.ready(), v, "cloud.attachFrame: the render proxy never became ready"), u && j(e), D(e, () => p.abort());
|
|
87
|
+
let a = e.contentWindow, o = () => {
|
|
88
|
+
if (!(!p.signal.aborted && e.isConnected && e.contentWindow === a)) throw p.abort(), O();
|
|
89
|
+
};
|
|
90
|
+
return n({
|
|
91
|
+
executor: {
|
|
92
|
+
execute: (e, t, n) => x.has(t) ? Promise.reject(r(t, "cloud")) : (o(), i.executeLocator(e, t, n)),
|
|
93
|
+
highlight: async () => {}
|
|
94
|
+
},
|
|
95
|
+
goto: async (t, n = {}) => {
|
|
96
|
+
let r = new URL(t, location.href).href;
|
|
97
|
+
o();
|
|
98
|
+
let { timeoutMs: a } = n;
|
|
99
|
+
await E(i.goto(r, n), (a ?? y) + b, "cloud.attachFrame: the render proxy did not answer goto; the frame may have been detached or its page reloaded"), d = r, j(e);
|
|
100
|
+
},
|
|
101
|
+
url: () => d
|
|
102
|
+
});
|
|
103
|
+
} catch (t) {
|
|
104
|
+
throw p.abort(), e.referrerPolicy = A, e.allow = N, e.src = u || "about:blank", t;
|
|
105
|
+
}
|
|
106
|
+
}, P = () => typeof window < "u" && !0, F = async () => {
|
|
107
|
+
let e = await s.then((e) => e.cloud.quota());
|
|
108
|
+
return {
|
|
109
|
+
premium: e.premium,
|
|
110
|
+
overQuota: e.overQuota,
|
|
111
|
+
throttled: e.overQuota && !e.premium,
|
|
112
|
+
usedBytes: e.usedBytes,
|
|
113
|
+
limitBytes: e.limitBytes,
|
|
114
|
+
remainingBytes: e.remaining,
|
|
115
|
+
bytesPerSecond: e.bytesPerSecond,
|
|
116
|
+
bitsPerSecond: e.bytesPerSecond * 8
|
|
117
|
+
};
|
|
118
|
+
}, I = /* @__PURE__ */ e({
|
|
119
|
+
attachFrame: () => N,
|
|
120
|
+
available: () => L,
|
|
121
|
+
dgram: () => f,
|
|
122
|
+
dns: () => l,
|
|
123
|
+
fetch: () => c,
|
|
124
|
+
fs: () => u,
|
|
125
|
+
http: () => p,
|
|
126
|
+
net: () => d,
|
|
127
|
+
quota: () => F
|
|
128
|
+
}), L = () => o;
|
|
129
|
+
//#endregion
|
|
130
|
+
export { P as a, N as i, I as n, F as r, L as t };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./lib-ulyxIbTr.cjs"),n=require("./api-D5ioM3pa.cjs"),r=require("./proxy-BsimoT14.cjs"),i=require("./dns.cjs"),a=require("./cloud/fs.cjs"),o=require("./net-kma1sFhK.cjs"),s=require("./dgram-CECo4EQT.cjs"),c=require("./http.cjs");let l=require("osra");var u=e=>e,d=`autoplay; fullscreen; encrypted-media; picture-in-picture; clipboard-read; clipboard-write`,f=2e4,p=65e3,m=3e4,h=5e3,g=new Set,_=()=>`https://fkn.app`,v=e=>!e||e===`about:blank`,y=e=>e?``:`incognito-${crypto.randomUUID()}`,b=({target:e,session:t})=>{let n=new URL(`/attach-frame`,_());return e&&n.searchParams.set(`url`,e),t&&n.searchParams.set(`session`,t),n.href},x=(e,t,n)=>{let r,i=new Promise((e,i)=>{r=setTimeout(()=>i(Error(n)),t)});return Promise.race([e,i]).finally(()=>clearTimeout(r))},S=(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())},C=()=>Object.assign(Error(`cloud.attachFrame: the attached iframe left the document or was reloaded; attach a fresh iframe`),{name:t.h}),w=(e,t)=>{let n=[...e.split(`;`),...t.split(`;`)].map(e=>e.trim()).filter(Boolean);return[...new Set(n)].join(`; `)},T=[300,1200,4e3],E=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 T)setTimeout(t,e)},D=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`)},O=async({iframe:e,domains:n=[],syncCookies:r=!0,lockdown:i=!1})=>{if(typeof window>`u`)throw Error(`cloud.attachFrame needs a window realm`);if(i)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`);D(e);let a=e.getAttribute(`src`)??``,o=(()=>{if(v(a))return null;try{return new URL(e.src||a,location.href)}catch{throw Error(`cloud.attachFrame: the iframe src is not a valid URL: ${a}`)}})();if(o){let e=new URL(`/attach-frame`,_());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`)}let s=o?.href??``;s&&t.s(s);let c=s,T=y(r),O=new AbortController,k=e.referrerPolicy,A=e.allow;if(e.referrerPolicy=`origin`,e.allow=w(d,e.allow),e.src=b({target:s,session:T}),!e.contentWindow)throw Error(`cloud.attachFrame: the iframe window is not available`);try{let n=await x((0,l.expose)({},{key:`fkn-attach-frame`,origin:_(),transport:{receive:window,emit:e.contentWindow},unregisterSignal:O.signal,revivableModules:u(t.L)}),f,`cloud.attachFrame: timed out connecting to the render proxy page`);await x(n.ready(),p,`cloud.attachFrame: the render proxy never became ready`),s&&E(e),S(e,()=>O.abort());let r=e.contentWindow,i=()=>{if(!(!O.signal.aborted&&e.isConnected&&e.contentWindow===r))throw O.abort(),C()};return t.a({executor:{execute:(e,r,a)=>g.has(r)?Promise.reject(t.f(r,`cloud`)):(i(),n.executeLocator(e,r,a)),highlight:async()=>{}},goto:async(t,r={})=>{let a=new URL(t,location.href).href;i();let{timeoutMs:o}=r;await x(n.goto(a,r),(o??m)+h,`cloud.attachFrame: the render proxy did not answer goto; the frame may have been detached or its page reloaded`),c=a,E(e)},url:()=>c})}catch(t){throw O.abort(),e.referrerPolicy=k,e.allow=A,e.src=s||`about:blank`,t}},k=()=>typeof window<`u`&&!0,A=async()=>{let e=await n.t.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}},j=e.t({attachFrame:()=>O,available:()=>M,dgram:()=>s.i,dns:()=>i.t,fetch:()=>r.t,fs:()=>a.t,http:()=>c.t,net:()=>o.s,quota:()=>A}),M=()=>n.r;Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return k}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return O}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return j}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return A}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return M}});
|
package/cloud.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./proxy-BsimoT14.cjs"),t=require("./cloud-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./proxy-BsimoT14.cjs"),t=require("./cloud-OOksFtTZ.cjs"),n=require("./dns.cjs"),r=require("./cloud/fs.cjs"),i=require("./net-kma1sFhK.cjs"),a=require("./dgram-CECo4EQT.cjs"),o=require("./http.cjs");exports.attachFrame=t.i,exports.available=t.t,Object.defineProperty(exports,"dgram",{enumerable:!0,get:function(){return a.i}}),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.s}}),exports.quota=t.r;
|
package/cloud.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { t as cloudFetch } from "./proxy-BihVUSnB.js";
|
|
2
|
-
import { a as attachFrame, i as quota, r as QuotaStatus, t as available } from "./cloud
|
|
2
|
+
import { a as attachFrame, i as quota, r as QuotaStatus, t as available } from "./cloud--8SYg1so.js";
|
|
3
3
|
import { t as dns_d_exports } from "./dns.js";
|
|
4
4
|
import { n as fs_d_exports } from "./fs-DTmSCXwa.js";
|
|
5
|
-
import { s as net_d_exports } from "./net-
|
|
5
|
+
import { s as net_d_exports } from "./net-BnGcJpUb.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,8 +1,8 @@
|
|
|
1
1
|
import { t as e } from "./proxy-BthoIRuv.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-Djen7gmX.js";
|
|
3
3
|
import { t as i } from "./dns.js";
|
|
4
4
|
import { t as a } from "./cloud/fs.js";
|
|
5
|
-
import { s as o } from "./net-
|
|
6
|
-
import { i as s } from "./dgram-
|
|
5
|
+
import { s as o } from "./net-BDAN5Mvc.js";
|
|
6
|
+
import { i as s } from "./dgram-BP0jykk_.js";
|
|
7
7
|
import { t as c } from "./http.js";
|
|
8
8
|
export { t as attachFrame, r as available, s as dgram, i as dns, e as fetch, a as fs, c as http, o as net, n as quota };
|
|
@@ -25,7 +25,7 @@ var u = /* @__PURE__ */ e({
|
|
|
25
25
|
_peerTailCache = /* @__PURE__ */ new Map();
|
|
26
26
|
constructor(e) {
|
|
27
27
|
if (super(e), !e) throw Error("Missing options");
|
|
28
|
-
this._type = e.type;
|
|
28
|
+
this._type = e.type, e.connection && this.__webvpn_udp_socket_init__(e.connection);
|
|
29
29
|
}
|
|
30
30
|
_lastRecvBufferSize = 0;
|
|
31
31
|
_lastSendBufferSize = 0;
|
|
@@ -141,13 +141,22 @@ var u = /* @__PURE__ */ e({
|
|
|
141
141
|
return this._localAddress;
|
|
142
142
|
}
|
|
143
143
|
bind(...e) {
|
|
144
|
-
let n = i(...e), r = this._type === "udp6" ? "::" : "0.0.0.0"
|
|
145
|
-
return this._webVPNUdpSocketPromise = t.then((e) => e.cloud.webvpn.udpSocket({
|
|
144
|
+
let n = i(...e), r = this._type === "udp6" ? "::" : "0.0.0.0", a = this.__webvpn_udp_socket_init__(t.then((e) => e.cloud.webvpn.udpSocket({
|
|
146
145
|
type: this._type,
|
|
147
146
|
address: n.address ?? r,
|
|
148
147
|
port: n.port,
|
|
149
148
|
dataPort: !0
|
|
150
|
-
}))
|
|
149
|
+
})));
|
|
150
|
+
return n.callback && a.then((e) => {
|
|
151
|
+
e && n.callback.call(this);
|
|
152
|
+
}), this;
|
|
153
|
+
}
|
|
154
|
+
__webvpn_udp_socket_init__(e, t) {
|
|
155
|
+
return t && (this._localAddress = {
|
|
156
|
+
address: t.localAddress,
|
|
157
|
+
family: t.localFamily,
|
|
158
|
+
port: t.localPort
|
|
159
|
+
}), this._webVPNUdpSocketPromise = e.then((e) => {
|
|
151
160
|
if (e.dataPort) this._socketId = e.socketId, this._dataPort = e.dataPort, this._dataPortAcks = e.dataPortAcks === !0, this._dataPort.onmessage = (e) => {
|
|
152
161
|
try {
|
|
153
162
|
this._onDataPortBatch(e.data);
|
|
@@ -179,9 +188,7 @@ var u = /* @__PURE__ */ e({
|
|
|
179
188
|
this.emit("error", e);
|
|
180
189
|
}), this._webVPNUdpSocketPromise.then((e) => {
|
|
181
190
|
e && this.emit("listening");
|
|
182
|
-
}),
|
|
183
|
-
e && n.callback.call(this);
|
|
184
|
-
}), this;
|
|
191
|
+
}), this._webVPNUdpSocketPromise;
|
|
185
192
|
}
|
|
186
193
|
close(e) {
|
|
187
194
|
if (!this._webVPNUdpSocketPromise) throw Error("Socket not bound");
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./api-D5ioM3pa.cjs"),n=require("./utils-QfNXtEhb.cjs");let r=require("buffer"),i=require("events"),a=require("ip-address");var o=e.t({Socket:()=>s,createSocket:()=>p,default:()=>m}),s=class extends i.EventEmitter{_type;_localAddress;_remoteAddress;_connectedLocally;_connectGeneration=0;_destroyed=!1;_webVPNUdpSocketPromise;_dataPort;_socketId;_sendQueue=[];_sendQueueBytes=0;_sendFlushScheduled=!1;_peerTailCache=new Map;constructor(e){if(super(e),!e)throw Error(`Missing options`);this._type=e.type,e.connection&&this.__webvpn_udp_socket_init__(e.connection)}_lastRecvBufferSize=0;_lastSendBufferSize=0;_lastTtl=64;_lastMulticastTtl=1;_lastMulticastLoopback=!0;_setUdpOption(e){if(!this._webVPNUdpSocketPromise){this.emit(`error`,Error(`Cannot set socket option before bind`));return}this._webVPNUdpSocketPromise.then(async t=>{if(t)try{await t.setOption(e)}catch(e){this.emit(`error`,e)}})}_dataPortAcks=!1;_dataPortConsumedBytes=0;_dataPortAckedBytes=0;_ackDataPortBatch(e){if(!this._dataPortAcks||!this._dataPort||(this._dataPortConsumedBytes+=e,this._dataPortAckedBytes!==0&&this._dataPortConsumedBytes-this._dataPortAckedBytes<524288))return;this._dataPortAckedBytes=this._dataPortConsumedBytes;let t={type:n.n,consumedBytes:this._dataPortConsumedBytes};this._dataPort.postMessage(t)}_onTransportClosed(e){this._destroyed||(this._destroyed=!0,this._dataPort?.close(),this._dataPort=void 0,this.listenerCount(`error`)>0&&this.emit(`error`,Error(e||`WebVPN session closed`)),this.emit(`close`))}_onDataPortBatch(e){let t=new DataView(e),n=!1,i,a=0;for(;a+4<=e.byteLength;){let o=t.getUint32(a);a+=4;let s=a+o;if(s>e.byteLength)break;let c=a+4,l=t.getUint8(c);c+=1;let u,f,p;if(l===2){if(!this._remoteAddress){a=s;continue}u=this._remoteAddress.address,f=this._remoteAddress.family,p=this._remoteAddress.port}else{let n=new Uint8Array(e,c,l===0?4:16);l===0?(f=`IPv4`,u=`${n[0]}.${n[1]}.${n[2]}.${n[3]}`):(f=`IPv6`,u=d(n)),c+=n.byteLength,p=t.getUint16(c),c+=2}let m=t.getUint32(c);c+=4;try{this.emit(`message`,r.Buffer.from(e.slice(c,c+m)),{address:u,family:f,port:p,size:m})}catch(e){n||(n=!0,i=e)}a=s}if(n)throw i}_peerTail(e,t){if(e===void 0||t===void 0)return c;let n=`${e}|${t}`,r=this._peerTailCache.get(n);if(r)return r;let i=a.Address4.isValid(e)?u(e):f(e),o=new Uint8Array(1+i.byteLength+2);return o[0]=i.byteLength===4?0:1,o.set(i,1),new DataView(o.buffer).setUint16(1+i.byteLength,t),this._peerTailCache.size>=4096&&this._peerTailCache.clear(),this._peerTailCache.set(n,o),o}_portSend(e,t,n){let r=this._peerTail(t,n),i=new Uint8Array(8+r.byteLength+4+e.byteLength),a=new DataView(i.buffer);a.setUint32(0,i.byteLength-4),a.setUint32(4,this._socketId),i.set(r,8),a.setUint32(8+r.byteLength,e.byteLength),i.set(e,12+r.byteLength),this._sendQueue.push(i),this._sendQueueBytes+=i.byteLength,!this._sendFlushScheduled&&(this._sendFlushScheduled=!0,queueMicrotask(()=>{this._sendFlushScheduled=!1;let e=this._sendQueue,t=this._sendQueueBytes;if(this._sendQueue=[],this._sendQueueBytes=0,!e.length||!this._dataPort)return;let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.byteLength;this._dataPort.postMessage(n.buffer,[n.buffer])}))}addMembership(e,t){if(a.Address4.isValid(e)){let n=u(e),r=t&&a.Address4.isValid(t)?u(t):new Uint8Array([0,0,0,0]);this._setUdpOption({type:5,group:n,interface:r})}else if(a.Address6.isValid(e)){let t=f(e);this._setUdpOption({type:7,group:t,ifIndex:0})}else this.emit(`error`,Error(`Invalid multicast address: ${e}`))}address(){if(!this._localAddress)throw Error(`EBADF`);return this._localAddress}bind(...e){let r=n.o(...e),i=this._type===`udp6`?`::`:`0.0.0.0`,a=this.__webvpn_udp_socket_init__(t.t.then(e=>e.cloud.webvpn.udpSocket({type:this._type,address:r.address??i,port:r.port,dataPort:!0})));return r.callback&&a.then(e=>{e&&r.callback.call(this)}),this}__webvpn_udp_socket_init__(e,t){return t&&(this._localAddress={address:t.localAddress,family:t.localFamily,port:t.localPort}),this._webVPNUdpSocketPromise=e.then(e=>{if(e.dataPort)this._socketId=e.socketId,this._dataPort=e.dataPort,this._dataPortAcks=e.dataPortAcks===!0,this._dataPort.onmessage=e=>{try{this._onDataPortBatch(e.data)}finally{this._ackDataPortBatch(e.data.byteLength)}};else{let t=e.dataReadableStream.getReader();(async()=>{for(;;){let{value:e,done:n}=await t.read();if(n)return;this.emit(`message`,r.Buffer.from(e.data),{address:e.address,family:e.family,port:e.port,size:e.size})}})().catch(e=>this._onTransportClosed(e instanceof Error?e.message:void 0))}return e.closed?.then(e=>this._onTransportClosed(e?.reason)).catch(()=>{}),this._localAddress={address:e.localAddress,family:e.localFamily,port:e.localPort},e}).catch(e=>{this.emit(`error`,e)}),this._webVPNUdpSocketPromise.then(e=>{e&&this.emit(`listening`)}),this._webVPNUdpSocketPromise}close(e){if(!this._webVPNUdpSocketPromise)throw Error(`Socket not bound`);return this._webVPNUdpSocketPromise.then(async t=>{if(!t)throw Error(`Socket not bound`);let n=this._destroyed;this._destroyed=!0,this._dataPort?.close(),this._dataPort=void 0;try{await t.close()}finally{try{e&&e()}finally{n||this.emit(`close`)}}}).catch(()=>{}),this}connect(...e){if(!this._webVPNUdpSocketPromise)throw Error(`Socket not bound`);this._webVPNUdpSocketPromise.then(async t=>{if(!t)throw Error(`Socket not bound`);let n=e[0],r=this._type===`udp6`?`::1`:`127.0.0.1`,i=typeof e[1]==`string`?e[1]:r,a=typeof e.at(-1)==`function`?e.at(-1):void 0,o=await t.connect({remotePort:n,remoteAddress:i});this._connectedLocally=o?.local===!0,this._remoteAddress=o?.address?{address:o.address,family:o.family,port:o.port}:{address:i,family:this._type===`udp6`?`IPv6`:`IPv4`,port:n},this._connectGeneration+=1,a&&a()}).catch(e=>{this.emit(`error`,e)})}disconnect(){if(!this._webVPNUdpSocketPromise)throw Error(`Socket not bound`);if(!this._remoteAddress)throw Error(`ERR_SOCKET_DGRAM_NOT_CONNECTED`);let e=this._remoteAddress,t=this._connectedLocally,n=this._connectGeneration;this._remoteAddress=void 0,this._connectedLocally=void 0,this._webVPNUdpSocketPromise.then(e=>e?.disconnect?.()).catch(r=>{this._connectGeneration===n&&(this._remoteAddress=e,this._connectedLocally=t),this.emit(`error`,r)})}dropMembership(e,t){if(a.Address4.isValid(e)){let n=u(e),r=t&&a.Address4.isValid(t)?u(t):new Uint8Array([0,0,0,0]);this._setUdpOption({type:6,group:n,interface:r})}else if(a.Address6.isValid(e)){let t=f(e);this._setUdpOption({type:8,group:t,ifIndex:0})}else this.emit(`error`,Error(`Invalid multicast address: ${e}`))}getRecvBufferSize(){return this._lastRecvBufferSize}getSendBufferSize(){return this._lastSendBufferSize}getSendQueueSize(){return 0}getSendQueueCount(){return 0}ref(){return this}remoteAddress(){if(!this._remoteAddress)throw Error(`ERR_SOCKET_DGRAM_NOT_CONNECTED`);return{address:this._remoteAddress.address,family:this._remoteAddress.family,port:this._remoteAddress.port}}send(...e){this._webVPNUdpSocketPromise||this.bind();let t=n.s(...e),r=l(t.message),i=r;if(t.hasRange){let{offset:e,length:n}=t;if(!Number.isInteger(e)||e<0||e>r.byteLength)throw Object.assign(RangeError(`"offset" is outside of buffer bounds`),{code:`ERR_BUFFER_OUT_OF_BOUNDS`});if(!Number.isInteger(n)||n<0||n>r.byteLength-e)throw Object.assign(RangeError(`"length" is outside of buffer bounds`),{code:`ERR_BUFFER_OUT_OF_BOUNDS`});i=r.subarray(e,e+n)}let o=this._type===`udp6`?`::1`:`127.0.0.1`;if(!this._webVPNUdpSocketPromise)throw Error(`Socket not bound`);this._webVPNUdpSocketPromise.then(e=>{if(!e)throw Error(`Socket not bound`);let n=t.callback,r=t.address??o,s=this._remoteAddress!==void 0&&t.address===void 0;if(this._dataPort&&(s||a.Address4.isValid(r)||a.Address6.isValid(r))){this._portSend(i,s?void 0:r,s?void 0:t.port),n?.call(this,null,i.byteLength);return}e.send({port:t.port,address:r,message:i.byteOffset===0&&i.byteLength===i.buffer.byteLength?i.buffer:i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength)}).then(()=>n?.call(this,null,i.byteLength),e=>n?n.call(this,e,0):this.emit(`error`,e))})}setBroadcast(e){this._setUdpOption({type:0,value:e})}setMulticastInterface(e){}setMulticastLoopback(e){return this._setUdpOption({type:3,value:e}),this._setUdpOption({type:4,value:e}),this._lastMulticastLoopback=e,e}setMulticastTTL(e){return this._setUdpOption({type:2,value:e}),this._lastMulticastTtl=e,e}setRecvBufferSize(e){this._setUdpOption({type:10,value:e}),this._lastRecvBufferSize=e}setSendBufferSize(e){this._setUdpOption({type:9,value:e}),this._lastSendBufferSize=e}setTTL(e){return this._setUdpOption({type:1,value:e}),this._lastTtl=e,e}unref(){return this}addSourceSpecificMembership(e,t,n){}dropSourceSpecificMembership(e,t,n){}async[Symbol.asyncDispose](){await new Promise(e=>{this.close(e)})}},c=new Uint8Array([2]),l=e=>{if(typeof e==`string`)return n.l.encode(e);if(e instanceof Uint8Array)return e;if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);if(Array.isArray(e)){let t=e.map(l),n=new Uint8Array(t.reduce((e,t)=>e+t.byteLength,0)),r=0;for(let e of t)n.set(e,r),r+=e.byteLength;return n}return new Uint8Array(e)},u=e=>{let t=e.split(`.`).map(e=>parseInt(e,10));if(t.length!==4||t.some(e=>Number.isNaN(e)||e<0||e>255))throw Error(`Invalid IPv4 address: ${e}`);return new Uint8Array(t)},d=e=>{let t=[];for(let n=0;n<16;n+=2)t.push(e[n]<<8|e[n+1]);let n=-1,r=1;for(let e=0;e<8;){if(t[e]!==0){e++;continue}let i=e;for(;i<8&&t[i]===0;)i++;i-e>r&&(n=e,r=i-e),e=i}return n===-1?t.map(e=>e.toString(16)).join(`:`):`${t.slice(0,n).map(e=>e.toString(16)).join(`:`)}::${t.slice(n+r).map(e=>e.toString(16)).join(`:`)}`},f=e=>{let t=new a.Address6(e).getBitsBase16(0,128).match(/.{2}/g);if(!t||t.length!==16)throw Error(`Invalid IPv6 address: ${e}`);return new Uint8Array(t.map(e=>parseInt(e,16)))},p=(e,t)=>{let n=new s(typeof e==`string`?{type:e}:e);return t&&n.on(`message`,t),n},m={Socket:s,createSocket:p};Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return p}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return s}});
|
package/dgram.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./dgram-
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./dgram-CECo4EQT.cjs");exports.Socket=e.t,exports.createSocket=e.n,exports.default=e.r;
|
package/dgram.d.ts
CHANGED
|
@@ -60,6 +60,61 @@ declare class Socket extends EventEmitter implements Socket$2 {
|
|
|
60
60
|
bind(port?: number | undefined, callback?: (() => void) | undefined): this;
|
|
61
61
|
bind(callback?: (() => void) | undefined): this;
|
|
62
62
|
bind(options: BindOptions, callback?: (() => void) | undefined): this;
|
|
63
|
+
/**
|
|
64
|
+
* Wire a datagram socket up from a connection already in hand, and report it as bound.
|
|
65
|
+
*
|
|
66
|
+
* `endpoints` publishes the local address SYNCHRONOUSLY, for the same reason net.ts's TCP
|
|
67
|
+
* equivalent does: `address()` throws EBADF until the promise below resolves, so a caller that
|
|
68
|
+
* reads it in the same turn as the bind gets an exception rather than the answer. Node fills an
|
|
69
|
+
* address in before it reports a socket as bound.
|
|
70
|
+
*
|
|
71
|
+
* Splitting this out of `bind()` is also what gives a test a seam. Everything a refused bind does
|
|
72
|
+
* lives past `apiPromise`, so without this the only way to reach it is to mock the resolver, and
|
|
73
|
+
* the guard on that path stayed untested through the whole period the relay could not refuse a
|
|
74
|
+
* bind at all.
|
|
75
|
+
*/
|
|
76
|
+
__webvpn_udp_socket_init__(connection: ReturnType<WebVpnUdpSocket>, endpoints?: Awaited<ReturnType<WebVpnUdpSocket>>): Promise<{
|
|
77
|
+
socketId: number;
|
|
78
|
+
dataPort: MessagePort | undefined;
|
|
79
|
+
dataPortAcks: true | undefined;
|
|
80
|
+
closed: Promise<{
|
|
81
|
+
reason: string;
|
|
82
|
+
}>;
|
|
83
|
+
localAddress: string;
|
|
84
|
+
localFamily: "IPv4" | "IPv6";
|
|
85
|
+
localPort: number;
|
|
86
|
+
dataReadableStream: ReadableStream<{
|
|
87
|
+
data: ArrayBuffer;
|
|
88
|
+
size: number;
|
|
89
|
+
family: 'IPv4' | 'IPv6';
|
|
90
|
+
address: string;
|
|
91
|
+
port: number;
|
|
92
|
+
}>;
|
|
93
|
+
connect: ({
|
|
94
|
+
remoteAddress: _remoteAddress,
|
|
95
|
+
remotePort
|
|
96
|
+
}: {
|
|
97
|
+
remoteAddress: string;
|
|
98
|
+
remotePort: number;
|
|
99
|
+
}) => Promise<{
|
|
100
|
+
local: boolean;
|
|
101
|
+
address: string;
|
|
102
|
+
family: "IPv4" | "IPv6";
|
|
103
|
+
port: number;
|
|
104
|
+
}>;
|
|
105
|
+
disconnect: () => Promise<void>;
|
|
106
|
+
send: ({
|
|
107
|
+
message,
|
|
108
|
+
address: _remoteAddress,
|
|
109
|
+
port: remotePort
|
|
110
|
+
}: {
|
|
111
|
+
message: ArrayBuffer;
|
|
112
|
+
address?: string;
|
|
113
|
+
port?: number;
|
|
114
|
+
}) => Promise<void>;
|
|
115
|
+
close: () => Promise<void>;
|
|
116
|
+
setOption: (option: UdpSocketOption) => Promise<void>;
|
|
117
|
+
} | undefined>;
|
|
63
118
|
close(callback?: (() => void) | undefined): this;
|
|
64
119
|
connect(port: number, address?: string, callback?: () => void): void;
|
|
65
120
|
connect(port: number, callback: () => void): void;
|
package/dgram.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as e, r as t, t as n } from "./dgram-
|
|
1
|
+
import { n as e, r as t, t as n } from "./dgram-BP0jykk_.js";
|
|
2
2
|
export { n as Socket, e as createSocket, t as default };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { $ as fetch$1, A as LOCATOR_DENIED, B as SelectorPart, C as RemoteVideoElement, D as isType, E as createVideoElementHandle, F as isTerminalError, G as setRequestHeaderRule, H as RequestHeaderRule, I as Executor, J as cookies, K as CookieDetails, L as Gate, M as LOCATOR_UNSUPPORTED, N as isLocatorDenied, O as revive, P as isLocatorUnsupported, Q as assertFetchableUrl, R as GateTools, S as BoxedVideoElement, T as box, U as modifyRequestHeadersPermission, V as HeaderOperation, W as removeRequestHeaderRule, X as FetchInit, Y as readCookiePermission, Z as ProxyFetchRequest, _ as gotoPermission, a as PermissionGrant, at as FORGEABLE_HEADERS, b as isBlockedFrameUrl, c as ATTACH_FRAME_EVENT_KEY, ct as hasForgedCookie, d as Frame, et as fetchCredentialedPermission, f as FrameBackend, g as createFrame, h as attachFramePermission, i as waitForExtensionExposure, it as isLocalNetworkUrl, j as LOCATOR_ERROR, k as type, l as attachFrame, m as Locator, n as isExtensionExposed, nt as fetchPermission, o as PermissionRequest, ot as assertForgeableHeaders, p as GotoOptions, q as SiteCookie, r as setMissingExtensionHandler, rt as isBlockedFetchUrl, s as permissions, st as assertOneCookieIdentity, t as extension, tt as fetchLocalPermission, u as AttachFrameOptions, v as assertAttachableFrameUrl, w as VideoElementState, x as handleRevivableModules, y as assertLockdownApplicable, z as OperationRequest } from "./index-
|
|
1
|
+
import { $ as fetch$1, A as LOCATOR_DENIED, B as SelectorPart, C as RemoteVideoElement, D as isType, E as createVideoElementHandle, F as isTerminalError, G as setRequestHeaderRule, H as RequestHeaderRule, I as Executor, J as cookies, K as CookieDetails, L as Gate, M as LOCATOR_UNSUPPORTED, N as isLocatorDenied, O as revive, P as isLocatorUnsupported, Q as assertFetchableUrl, R as GateTools, S as BoxedVideoElement, T as box, U as modifyRequestHeadersPermission, V as HeaderOperation, W as removeRequestHeaderRule, X as FetchInit, Y as readCookiePermission, Z as ProxyFetchRequest, _ as gotoPermission, a as PermissionGrant, at as FORGEABLE_HEADERS, b as isBlockedFrameUrl, c as ATTACH_FRAME_EVENT_KEY, ct as hasForgedCookie, d as Frame, et as fetchCredentialedPermission, f as FrameBackend, g as createFrame, h as attachFramePermission, i as waitForExtensionExposure, it as isLocalNetworkUrl, j as LOCATOR_ERROR, k as type, l as attachFrame, m as Locator, n as isExtensionExposed, nt as fetchPermission, o as PermissionRequest, ot as assertForgeableHeaders, p as GotoOptions, q as SiteCookie, r as setMissingExtensionHandler, rt as isBlockedFetchUrl, s as permissions, st as assertOneCookieIdentity, t as extension, tt as fetchLocalPermission, u as AttachFrameOptions, v as assertAttachableFrameUrl, w as VideoElementState, x as handleRevivableModules, y as assertLockdownApplicable, z as OperationRequest } from "./index-DLaonjpx.js";
|
|
2
2
|
|
|
3
3
|
//#region src/lib/extension-prompt.d.ts
|
|
4
4
|
declare const promptInstall: (reason?: string) => Promise<boolean>;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./lib-ulyxIbTr.cjs"),n=require("./api-D5ioM3pa.cjs"),r=require("./proxy-BsimoT14.cjs"),i=require("./desktop.cjs");var a=async e=>{if(typeof window>`u`)return!1;if(t.P())return!0;let r=await n.t,i=null,a=new Promise(e=>{i=()=>{t.P()&&e(!0)},t.N.addEventListener(`statuschange`,i)}),o=r.installPrompt.show(e).then(()=>!1),s=await Promise.race([a,o]);return i&&t.N.removeEventListener(`statuschange`,i),await r.installPrompt.hide().catch(()=>{}),s},o=null;t.F(()=>(o||=a().then(()=>void 0).finally(()=>{o=null}),o));var s=()=>typeof document<`u`&&t.P(),c=async(e,n)=>{if(r.n(e),n?.credentials===`include`){if(typeof document>`u`)throw Error(`fetch with credentials needs the FKN extension, which only exists in window realms`);return t.C(e,n)}return s()?t.C(e,{...n,credentials:`omit`}):i.available()?i.fetch(e,n):r.t(e,n)},l=e.t({ATTACH_FRAME_EVENT_KEY:()=>t.n,FORGEABLE_HEADERS:()=>t.k,LOCATOR_DENIED:()=>t.g,LOCATOR_ERROR:()=>t.u,LOCATOR_UNSUPPORTED:()=>t.h,assertAttachableFrameUrl:()=>t.s,assertFetchableUrl:()=>t.S,assertForgeableHeaders:()=>t.A,assertLockdownApplicable:()=>t.c,assertOneCookieIdentity:()=>t.j,attachFrame:()=>t.r,attachFramePermission:()=>t.i,available:()=>s,box:()=>t.R,cookies:()=>t.b,createFrame:()=>t.a,createVideoElementHandle:()=>t.z,events:()=>t.N,extension:()=>t.N,fetch:()=>t.C,fetchCredentialedPermission:()=>t.w,fetchLocalPermission:()=>t.T,fetchPermission:()=>t.E,gotoPermission:()=>t.o,handleRevivableModules:()=>t.L,hasForgedCookie:()=>t.M,isBlockedFetchUrl:()=>t.D,isBlockedFrameUrl:()=>t.l,isExtensionExposed:()=>t.P,isLocalNetworkUrl:()=>t.O,isLocatorDenied:()=>t.d,isLocatorUnsupported:()=>t.m,isTerminalError:()=>t.p,isType:()=>t.B,modifyRequestHeadersPermission:()=>t._,permissions:()=>t.t,promptInstall:()=>a,readCookiePermission:()=>t.x,removeRequestHeaderRule:()=>t.v,revive:()=>t.V,setMissingExtensionHandler:()=>t.F,setRequestHeaderRule:()=>t.y,type:()=>t.H,waitForExtensionExposure:()=>t.I});Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return l}});
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
|
|
2
|
+
import { A as t, B as n, C as r, D as i, E as a, F as o, H as s, I as c, L as l, M as u, N as d, O as f, P as p, R as m, S as h, T as g, V as _, _ as v, a as y, b, c as x, d as S, g as C, h as w, i as T, j as E, k as D, l as O, m as k, n as A, o as j, p as M, r as N, s as P, t as F, u as I, v as L, w as R, x as z, y as B, z as V } from "./lib-CegQxwDI.js";
|
|
3
|
+
import { t as H } from "./api-DAQQBty8.js";
|
|
4
|
+
import { n as U, t as W } from "./proxy-BthoIRuv.js";
|
|
5
|
+
import { available as G, fetch as K } from "./desktop.js";
|
|
6
|
+
//#region src/lib/extension-prompt.ts
|
|
7
|
+
var q = async (e) => {
|
|
8
|
+
if (typeof window > "u") return !1;
|
|
9
|
+
if (p()) return !0;
|
|
10
|
+
let t = await H, n = null, r = new Promise((e) => {
|
|
11
|
+
n = () => {
|
|
12
|
+
p() && e(!0);
|
|
13
|
+
}, d.addEventListener("statuschange", n);
|
|
14
|
+
}), i = t.installPrompt.show(e).then(() => !1), a = await Promise.race([r, i]);
|
|
15
|
+
return n && d.removeEventListener("statuschange", n), await t.installPrompt.hide().catch(() => {}), a;
|
|
16
|
+
}, J = null;
|
|
17
|
+
o(() => (J ||= q().then(() => void 0).finally(() => {
|
|
18
|
+
J = null;
|
|
19
|
+
}), J));
|
|
20
|
+
//#endregion
|
|
21
|
+
//#region src/lib/auto.ts
|
|
22
|
+
var Y = () => typeof document < "u" && p(), X = async (e, t) => {
|
|
23
|
+
if (U(e), t?.credentials === "include") {
|
|
24
|
+
if (typeof document > "u") throw Error("fetch with credentials needs the FKN extension, which only exists in window realms");
|
|
25
|
+
return r(e, t);
|
|
26
|
+
}
|
|
27
|
+
return Y() ? r(e, {
|
|
28
|
+
...t,
|
|
29
|
+
credentials: "omit"
|
|
30
|
+
}) : G() ? K(e, t) : W(e, t);
|
|
31
|
+
}, Z = /* @__PURE__ */ e({
|
|
32
|
+
ATTACH_FRAME_EVENT_KEY: () => A,
|
|
33
|
+
FORGEABLE_HEADERS: () => D,
|
|
34
|
+
LOCATOR_DENIED: () => C,
|
|
35
|
+
LOCATOR_ERROR: () => I,
|
|
36
|
+
LOCATOR_UNSUPPORTED: () => w,
|
|
37
|
+
assertAttachableFrameUrl: () => P,
|
|
38
|
+
assertFetchableUrl: () => h,
|
|
39
|
+
assertForgeableHeaders: () => t,
|
|
40
|
+
assertLockdownApplicable: () => x,
|
|
41
|
+
assertOneCookieIdentity: () => E,
|
|
42
|
+
attachFrame: () => N,
|
|
43
|
+
attachFramePermission: () => T,
|
|
44
|
+
available: () => Y,
|
|
45
|
+
box: () => m,
|
|
46
|
+
cookies: () => b,
|
|
47
|
+
createFrame: () => y,
|
|
48
|
+
createVideoElementHandle: () => V,
|
|
49
|
+
events: () => d,
|
|
50
|
+
extension: () => d,
|
|
51
|
+
fetch: () => r,
|
|
52
|
+
fetchCredentialedPermission: () => R,
|
|
53
|
+
fetchLocalPermission: () => g,
|
|
54
|
+
fetchPermission: () => a,
|
|
55
|
+
gotoPermission: () => j,
|
|
56
|
+
handleRevivableModules: () => l,
|
|
57
|
+
hasForgedCookie: () => u,
|
|
58
|
+
isBlockedFetchUrl: () => i,
|
|
59
|
+
isBlockedFrameUrl: () => O,
|
|
60
|
+
isExtensionExposed: () => p,
|
|
61
|
+
isLocalNetworkUrl: () => f,
|
|
62
|
+
isLocatorDenied: () => S,
|
|
63
|
+
isLocatorUnsupported: () => k,
|
|
64
|
+
isTerminalError: () => M,
|
|
65
|
+
isType: () => n,
|
|
66
|
+
modifyRequestHeadersPermission: () => v,
|
|
67
|
+
permissions: () => F,
|
|
68
|
+
promptInstall: () => q,
|
|
69
|
+
readCookiePermission: () => z,
|
|
70
|
+
removeRequestHeaderRule: () => L,
|
|
71
|
+
revive: () => _,
|
|
72
|
+
setMissingExtensionHandler: () => o,
|
|
73
|
+
setRequestHeaderRule: () => B,
|
|
74
|
+
type: () => s,
|
|
75
|
+
waitForExtensionExposure: () => c
|
|
76
|
+
});
|
|
77
|
+
//#endregion
|
|
78
|
+
export { q as i, X as n, Y as r, Z as t };
|
package/extension.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./lib-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./lib-ulyxIbTr.cjs"),t=require("./extension-DPlyfEPO.cjs");exports.ATTACH_FRAME_EVENT_KEY=e.n,exports.FORGEABLE_HEADERS=e.k,exports.LOCATOR_DENIED=e.g,exports.LOCATOR_ERROR=e.u,exports.LOCATOR_UNSUPPORTED=e.h,exports.assertAttachableFrameUrl=e.s,exports.assertFetchableUrl=e.S,exports.assertForgeableHeaders=e.A,exports.assertLockdownApplicable=e.c,exports.assertOneCookieIdentity=e.j,exports.attachFrame=e.r,exports.attachFramePermission=e.i,exports.available=t.r,exports.box=e.R,exports.cookies=e.b,exports.createFrame=e.a,exports.createVideoElementHandle=e.z,exports.events=e.N,exports.extension=e.N,exports.fetch=e.C,exports.fetchCredentialedPermission=e.w,exports.fetchLocalPermission=e.T,exports.fetchPermission=e.E,exports.gotoPermission=e.o,exports.handleRevivableModules=e.L,exports.hasForgedCookie=e.M,exports.isBlockedFetchUrl=e.D,exports.isBlockedFrameUrl=e.l,exports.isExtensionExposed=e.P,exports.isLocalNetworkUrl=e.O,exports.isLocatorDenied=e.d,exports.isLocatorUnsupported=e.m,exports.isTerminalError=e.p,exports.isType=e.B,exports.modifyRequestHeadersPermission=e._,exports.permissions=e.t,exports.promptInstall=t.i,exports.readCookiePermission=e.x,exports.removeRequestHeaderRule=e.v,exports.revive=e.V,exports.setMissingExtensionHandler=e.F,exports.setRequestHeaderRule=e.y,exports.type=e.H,exports.waitForExtensionExposure=e.I;
|
package/extension.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { $ as fetch, A as LOCATOR_DENIED, B as SelectorPart, C as RemoteVideoElement, D as isType, E as createVideoElementHandle, F as isTerminalError, G as setRequestHeaderRule, H as RequestHeaderRule, I as Executor, J as cookies, K as CookieDetails, L as Gate, M as LOCATOR_UNSUPPORTED, N as isLocatorDenied, O as revive, P as isLocatorUnsupported, Q as assertFetchableUrl, R as GateTools, S as BoxedVideoElement, T as box, U as modifyRequestHeadersPermission, V as HeaderOperation, W as removeRequestHeaderRule, X as FetchInit, Y as readCookiePermission, Z as ProxyFetchRequest, _ as gotoPermission, a as PermissionGrant, at as FORGEABLE_HEADERS, b as isBlockedFrameUrl, c as ATTACH_FRAME_EVENT_KEY, ct as hasForgedCookie, d as Frame, et as fetchCredentialedPermission, f as FrameBackend, g as createFrame, h as attachFramePermission, i as waitForExtensionExposure, it as isLocalNetworkUrl, j as LOCATOR_ERROR, k as type, l as attachFrame, m as Locator, n as isExtensionExposed, nt as fetchPermission, o as PermissionRequest, ot as assertForgeableHeaders, p as GotoOptions, q as SiteCookie, r as setMissingExtensionHandler, rt as isBlockedFetchUrl, s as permissions, st as assertOneCookieIdentity, t as extension, tt as fetchLocalPermission, u as AttachFrameOptions, v as assertAttachableFrameUrl, w as VideoElementState, x as handleRevivableModules, y as assertLockdownApplicable, z as OperationRequest } from "./index-
|
|
2
|
-
import { i as promptInstall, r as isExtensionAvailable } from "./extension-
|
|
1
|
+
import { $ as fetch, A as LOCATOR_DENIED, B as SelectorPart, C as RemoteVideoElement, D as isType, E as createVideoElementHandle, F as isTerminalError, G as setRequestHeaderRule, H as RequestHeaderRule, I as Executor, J as cookies, K as CookieDetails, L as Gate, M as LOCATOR_UNSUPPORTED, N as isLocatorDenied, O as revive, P as isLocatorUnsupported, Q as assertFetchableUrl, R as GateTools, S as BoxedVideoElement, T as box, U as modifyRequestHeadersPermission, V as HeaderOperation, W as removeRequestHeaderRule, X as FetchInit, Y as readCookiePermission, Z as ProxyFetchRequest, _ as gotoPermission, a as PermissionGrant, at as FORGEABLE_HEADERS, b as isBlockedFrameUrl, c as ATTACH_FRAME_EVENT_KEY, ct as hasForgedCookie, d as Frame, et as fetchCredentialedPermission, f as FrameBackend, g as createFrame, h as attachFramePermission, i as waitForExtensionExposure, it as isLocalNetworkUrl, j as LOCATOR_ERROR, k as type, l as attachFrame, m as Locator, n as isExtensionExposed, nt as fetchPermission, o as PermissionRequest, ot as assertForgeableHeaders, p as GotoOptions, q as SiteCookie, r as setMissingExtensionHandler, rt as isBlockedFetchUrl, s as permissions, st as assertOneCookieIdentity, t as extension, tt as fetchLocalPermission, u as AttachFrameOptions, v as assertAttachableFrameUrl, w as VideoElementState, x as handleRevivableModules, y as assertLockdownApplicable, z as OperationRequest } from "./index-DLaonjpx.js";
|
|
2
|
+
import { i as promptInstall, r as isExtensionAvailable } from "./extension-CN9oFZ0Q.js";
|
|
3
3
|
export { ATTACH_FRAME_EVENT_KEY, AttachFrameOptions, BoxedVideoElement, CookieDetails, type Executor, FORGEABLE_HEADERS, FetchInit, Frame, FrameBackend, type Gate, type GateTools, GotoOptions, HeaderOperation, LOCATOR_DENIED, LOCATOR_ERROR, LOCATOR_UNSUPPORTED, Locator, type OperationRequest, PermissionGrant, PermissionRequest, ProxyFetchRequest, RemoteVideoElement, RequestHeaderRule, type SelectorPart, SiteCookie, VideoElementState, assertAttachableFrameUrl, assertFetchableUrl, assertForgeableHeaders, assertLockdownApplicable, assertOneCookieIdentity, attachFrame, attachFramePermission, isExtensionAvailable as available, box, cookies, createFrame, createVideoElementHandle, extension as events, extension, fetch, fetchCredentialedPermission, fetchLocalPermission, fetchPermission, gotoPermission, handleRevivableModules, hasForgedCookie, isBlockedFetchUrl, isBlockedFrameUrl, isExtensionExposed, isLocalNetworkUrl, isLocatorDenied, isLocatorUnsupported, isTerminalError, isType, modifyRequestHeadersPermission, permissions, promptInstall, readCookiePermission, removeRequestHeaderRule, revive, setMissingExtensionHandler, setRequestHeaderRule, type, waitForExtensionExposure };
|
package/extension.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
import { A as e, B as t, C as n, D as r, E as i, F as a,
|
|
2
|
-
import { i as V, r as H } from "./extension-
|
|
3
|
-
export { k as ATTACH_FRAME_EVENT_KEY,
|
|
1
|
+
import { A as e, B as t, C as n, D as r, E as i, F as a, H as o, I as s, L as c, M as l, N as u, O as d, P as f, R as p, S as m, T as h, V as g, _, a as v, b as y, c as b, d as x, g as S, h as C, i as w, j as T, k as E, l as D, m as O, n as k, o as A, p as j, r as M, s as N, t as P, u as F, v as I, w as L, x as R, y as z, z as B } from "./lib-CegQxwDI.js";
|
|
2
|
+
import { i as V, r as H } from "./extension-xVdvgkZL.js";
|
|
3
|
+
export { k as ATTACH_FRAME_EVENT_KEY, E as FORGEABLE_HEADERS, S as LOCATOR_DENIED, F as LOCATOR_ERROR, C as LOCATOR_UNSUPPORTED, N as assertAttachableFrameUrl, m as assertFetchableUrl, e as assertForgeableHeaders, b as assertLockdownApplicable, T as assertOneCookieIdentity, M as attachFrame, w as attachFramePermission, H as available, p as box, y as cookies, v as createFrame, B as createVideoElementHandle, u as events, u as extension, n as fetch, L as fetchCredentialedPermission, h as fetchLocalPermission, i as fetchPermission, A as gotoPermission, c as handleRevivableModules, l as hasForgedCookie, r as isBlockedFetchUrl, D as isBlockedFrameUrl, f as isExtensionExposed, d as isLocalNetworkUrl, x as isLocatorDenied, O as isLocatorUnsupported, j as isTerminalError, t as isType, _ as modifyRequestHeadersPermission, P as permissions, V as promptInstall, R as readCookiePermission, I as removeRequestHeaderRule, g as revive, a as setMissingExtensionHandler, z as setRequestHeaderRule, o as type, s as waitForExtensionExposure };
|
package/http.cjs
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./net-
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./net-kma1sFhK.cjs");let n=require("buffer"),r=require("stream");var i=e.t({Agent:()=>T,ClientRequest:()=>S,HTTPParser:()=>g,IncomingMessage:()=>v,METHODS:()=>o,STATUS_CODES:()=>s,Server:()=>w,ServerResponse:()=>b,_default:()=>A,createServer:()=>k,default:()=>A,get:()=>O,globalAgent:()=>E,request:()=>D}),a=new TextDecoder(`latin1`),o=`ACL.BIND.CHECKOUT.CONNECT.COPY.DELETE.GET.HEAD.LINK.LOCK.M-SEARCH.MERGE.MKACTIVITY.MKCALENDAR.MKCOL.MOVE.NOTIFY.OPTIONS.PATCH.POST.PROPFIND.PROPPATCH.PURGE.PUT.REBIND.REPORT.SEARCH.SOURCE.SUBSCRIBE.TRACE.UNBIND.UNLINK.UNLOCK.UNSUBSCRIBE`.split(`.`),s={100:`Continue`,101:`Switching Protocols`,102:`Processing`,103:`Early Hints`,200:`OK`,201:`Created`,202:`Accepted`,203:`Non-Authoritative Information`,204:`No Content`,205:`Reset Content`,206:`Partial Content`,207:`Multi-Status`,208:`Already Reported`,226:`IM Used`,300:`Multiple Choices`,301:`Moved Permanently`,302:`Found`,303:`See Other`,304:`Not Modified`,305:`Use Proxy`,307:`Temporary Redirect`,308:`Permanent Redirect`,400:`Bad Request`,401:`Unauthorized`,402:`Payment Required`,403:`Forbidden`,404:`Not Found`,405:`Method Not Allowed`,406:`Not Acceptable`,407:`Proxy Authentication Required`,408:`Request Timeout`,409:`Conflict`,410:`Gone`,411:`Length Required`,412:`Precondition Failed`,413:`Payload Too Large`,414:`URI Too Long`,415:`Unsupported Media Type`,416:`Range Not Satisfiable`,417:`Expectation Failed`,418:`I'm a Teapot`,421:`Misdirected Request`,422:`Unprocessable Entity`,423:`Locked`,424:`Failed Dependency`,425:`Too Early`,426:`Upgrade Required`,428:`Precondition Required`,429:`Too Many Requests`,431:`Request Header Fields Too Large`,451:`Unavailable For Legal Reasons`,500:`Internal Server Error`,501:`Not Implemented`,502:`Bad Gateway`,503:`Service Unavailable`,504:`Gateway Timeout`,505:`HTTP Version Not Supported`,506:`Variant Also Negotiates`,507:`Insufficient Storage`,508:`Loop Detected`,509:`Bandwidth Limit Exceeded`,510:`Not Extended`,511:`Network Authentication Required`},c=new Set([`content-type`,`content-length`,`user-agent`,`referer`,`host`,`authorization`,`proxy-authorization`,`if-modified-since`,`if-unmodified-since`,`from`,`location`,`max-forwards`,`retry-after`,`etag`,`last-modified`,`server`,`age`,`expires`]),l=13,u=10,d=/^[\^_`a-zA-Z\-0-9!#$%&'*+.|~]+$/,f=(e,t)=>(e.code=t,e),p=(e,t)=>{if(e.length===0)return t;if(t.length===0)return e;let n=new Uint8Array(e.length+t.length);return n.set(e,0),n.set(t,e.length),n},m=(e,t)=>{for(let n=t;n+1<e.length;n++)if(e[n]===l&&e[n+1]===u)return n;return-1},h=e=>{for(let t=0;t+3<e.length;t++)if(e[t]===l&&e[t+1]===u&&e[t+2]===l&&e[t+3]===u)return t;return-1},g=class{mode;handlers;buf=new Uint8Array;state=`HEAD`;framing=`none`;bodyRemaining=0;chunkState=`size`;skipBody=!1;constructor(e,t){this.mode=e,this.handlers=t}execute(e){this.buf=p(this.buf,e);let t=!0;for(;t;)if(t=!1,this.state===`HEAD`){let e=h(this.buf);if(e===-1)return;let n=this.buf.subarray(0,e);this.buf=this.buf.subarray(e+4);let r=this.parseHead(n);this.handlers.onHeaders(r),this.setupBody(r),this.framing===`none`?(this.handlers.onComplete(),this.reset(),t=this.buf.length>0):(this.state=`BODY`,t=!0)}else this.consumeBody()&&(this.handlers.onComplete(),this.reset(),t=this.buf.length>0)}finish(){this.state===`BODY`&&this.framing===`eof`&&(this.handlers.onComplete(),this.reset())}reset(){this.state=`HEAD`,this.framing=`none`,this.bodyRemaining=0,this.chunkState=`size`,this.skipBody=!1}parseHead(e){let t=a.decode(e).split(`\r
|
|
2
2
|
`),n=t.shift()??``,r=[];for(let e of t)(e.startsWith(` `)||e.startsWith(` `))&&r.length>0?r[r.length-1]+=` `+e.trim():r.push(e);let i=[],o={};for(let e of r){if(!e)continue;let t=e.indexOf(`:`);if(t===-1)continue;let n=e.slice(0,t).trim(),r=e.slice(t+1).trim();i.push(n,r),this.addHeader(o,n,r)}let s={httpVersionMajor:1,httpVersionMinor:1,httpVersion:`1.1`,headers:o,rawHeaders:i};if(this.mode===`request`){let[e,t,r]=n.split(` `);s.method=(e??`GET`).toUpperCase(),s.url=t??`/`,this.applyVersion(s,r)}else{let e=n.indexOf(` `),t=n.slice(0,e),r=n.slice(e+1),i=r.indexOf(` `),a=i===-1?r:r.slice(0,i);s.statusCode=parseInt(a,10)||0,s.statusMessage=i===-1?``:r.slice(i+1),this.applyVersion(s,t)}return s}applyVersion(e,t){let n=/HTTP\/(\d)\.(\d)/i.exec(t??``);n&&(e.httpVersionMajor=parseInt(n[1],10),e.httpVersionMinor=parseInt(n[2],10),e.httpVersion=`${e.httpVersionMajor}.${e.httpVersionMinor}`)}addHeader(e,t,n){let r=t.toLowerCase();if(r===`set-cookie`){let t=e[`set-cookie`];Array.isArray(t)?t.push(n):e[`set-cookie`]=[n];return}let i=e[r];i===void 0?e[r]=n:c.has(r)||(e[r]=`${i}, ${n}`)}setupBody(e){if(this.skipBody){this.framing=`none`;return}let t=e.headers[`transfer-encoding`];if(typeof t==`string`&&t.toLowerCase().includes(`chunked`)){this.framing=`chunked`,this.chunkState=`size`;return}let n=e.headers[`content-length`];if(typeof n==`string`&&n!==``){let e=parseInt(n,10);e>0?(this.framing=`length`,this.bodyRemaining=e):this.framing=`none`;return}if(this.mode===`response`){let t=e.statusCode??0;t>=100&&t<200||t===204||t===304?this.framing=`none`:this.framing=`eof`}else this.framing=`none`}consumeBody(){if(this.framing===`length`){if(this.buf.length===0)return!1;let e=Math.min(this.bodyRemaining,this.buf.length);return this.handlers.onBody(this.buf.subarray(0,e)),this.buf=this.buf.subarray(e),this.bodyRemaining-=e,this.bodyRemaining===0}return this.framing===`eof`?(this.buf.length>0&&(this.handlers.onBody(this.buf),this.buf=new Uint8Array),!1):this.framing===`chunked`?this.consumeChunked():!0}consumeChunked(){for(;;)if(this.chunkState===`size`){let e=m(this.buf,0);if(e===-1)return!1;let t=a.decode(this.buf.subarray(0,e)),n=parseInt(t.split(`;`)[0].trim(),16);if(this.buf=this.buf.subarray(e+2),Number.isNaN(n))return!0;n===0?this.chunkState=`trailer`:(this.bodyRemaining=n,this.chunkState=`data`)}else if(this.chunkState===`data`){if(this.buf.length===0)return!1;let e=Math.min(this.bodyRemaining,this.buf.length);this.handlers.onBody(this.buf.subarray(0,e)),this.buf=this.buf.subarray(e),this.bodyRemaining-=e,this.bodyRemaining===0&&(this.chunkState=`dataCRLF`)}else if(this.chunkState===`dataCRLF`){if(this.buf.length<2)return!1;this.buf=this.buf.subarray(2),this.chunkState=`size`}else{let e=m(this.buf,0);if(e===-1)return!1;let t=e===0;if(this.buf=this.buf.subarray(e+2),t)return!0}}},_=(e,t)=>n.Buffer.isBuffer(e)?e:typeof e==`string`?n.Buffer.from(e,t??`utf8`):e instanceof Uint8Array?n.Buffer.from(e):e instanceof ArrayBuffer?n.Buffer.from(new Uint8Array(e)):n.Buffer.from(String(e)),v=class extends r.Stream.Readable{httpVersion=`1.1`;httpVersionMajor=1;httpVersionMinor=1;headers={};rawHeaders=[];trailers={};rawTrailers=[];method;url;statusCode;statusMessage;complete=!1;socket;constructor(e){super(),this.socket=e}get connection(){return this.socket}_applyHead(e){this.httpVersion=e.httpVersion,this.httpVersionMajor=e.httpVersionMajor,this.httpVersionMinor=e.httpVersionMinor,this.headers=e.headers,this.rawHeaders=e.rawHeaders,this.method=e.method,this.url=e.url,this.statusCode=e.statusCode,this.statusMessage=e.statusMessage}_read(){}setTimeout(e,t){return this.socket.setTimeout(e,t),this}},y=class extends r.Stream.Writable{_headerStore=new Map;headersSent=!1;chunkedEncoding=!1;finished=!1;_bodyWritten=!1;setHeader(e,t){if(this.headersSent)throw f(Error(`Cannot set headers after they are sent to the client`),`ERR_HTTP_HEADERS_SENT`);if(typeof e!=`string`||!d.test(e))throw f(TypeError(`Header name must be a valid HTTP token [${JSON.stringify(String(e))}]`),`ERR_INVALID_HTTP_TOKEN`);if(t===void 0)throw f(TypeError(`Invalid value "undefined" for header "${e}"`),`ERR_HTTP_INVALID_HEADER_VALUE`);return this._headerStore.set(e.toLowerCase(),[e,Array.isArray(t)?[...t]:t]),this}getHeader(e){return this._headerStore.get(e.toLowerCase())?.[1]}getHeaderNames(){return[...this._headerStore.values()].map(([e])=>e)}getHeaders(){let e={};for(let[t,n]of this._headerStore.values())e[t]=n;return e}hasHeader(e){return this._headerStore.has(e.toLowerCase())}removeHeader(e){if(this.headersSent)throw Error(`Cannot remove headers after they are sent to the client`);this._headerStore.delete(e.toLowerCase())}_storeHeader(e){let t=this.hasHeader(`content-length`),n=this.getHeader(`transfer-encoding`);typeof n==`string`&&n.toLowerCase().includes(`chunked`)?this.chunkedEncoding=!0:!t&&this._shouldSendBody()&&(this.chunkedEncoding=!0,this.setHeader(`Transfer-Encoding`,`chunked`));let r=e+`\r
|
|
3
3
|
`;for(let[e,t]of this._headerStore.values())if(Array.isArray(t))for(let n of t)r+=`${e}: ${n}\r\n`;else r+=`${e}: ${t}\r\n`;return r+=`\r
|
|
4
4
|
`,r}_writeToSocket(e,t){if(!this.socket){t(Error(`Socket is not available`));return}this.socket.write(e,t)}write(e,t,n){return this._bodyWritten=!0,super.write(e,t,n)}_write(e,t,r){let i=_(e),a=[];if(this.headersSent||=(this._implicitHeader(),a.push(n.Buffer.from(this._headBlock,`latin1`)),!0),this.chunkedEncoding?i.length>0&&(a.push(n.Buffer.from(`${i.length.toString(16)}\r\n`,`latin1`)),a.push(i),a.push(n.Buffer.from(`\r
|
package/http.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as Socket, t as Server$1 } from "./net-
|
|
1
|
+
import { n as Socket, t as Server$1 } from "./net-BnGcJpUb.js";
|
|
2
2
|
import { Buffer } from "buffer";
|
|
3
3
|
import { Stream } from "stream";
|
|
4
4
|
import { IncomingHttpHeaders, OutgoingHttpHeaders, RequestOptions } from "http";
|
package/http.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
|
|
2
|
-
import { n as t, t as n } from "./net-
|
|
2
|
+
import { n as t, t as n } from "./net-BDAN5Mvc.js";
|
|
3
3
|
import { Buffer as r } from "buffer";
|
|
4
4
|
import { Stream as i } from "stream";
|
|
5
5
|
//#region src/lib/webvpn/http.ts
|