@fkn/lib 0.3.11 → 0.3.12
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/{background-BLtG2SKm.js → background-C5D7dhf2.js} +1 -1
- package/{background-DsN_xRAy.cjs → background-DdXHHDsS.cjs} +1 -1
- package/index.cjs +5 -5
- package/index.d.ts +32 -9
- package/index.js +185 -164
- package/{locator-DhCNXAk2.js → locator-DUbu14FW.js} +3 -3
- package/{locator-B2frkQPZ.cjs → locator-jHaMLjtv.cjs} +2 -2
- package/package.json +1 -1
package/index.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { d as e, f as t, g as n, i as r, l as i, m as a, p as o, r as s, t as c, u as l } from "./locator-
|
|
1
|
+
import { d as e, f as t, g as n, i as r, l as i, m as a, p as o, r as s, t as c, u as l } from "./locator-DUbu14FW.js";
|
|
2
2
|
import { createTypedEventTarget as ee, expose as te, relay as ne } from "osra";
|
|
3
3
|
import { Stream as u } from "stream";
|
|
4
4
|
import { EventEmitter as d } from "events";
|
|
@@ -8,7 +8,7 @@ import { Buffer as m } from "buffer";
|
|
|
8
8
|
var re = 32, ie = typeof CSS < "u" && CSS.supports("clip-path", "path('M0 0H1V1H0Z')"), ae = (e) => {
|
|
9
9
|
let t = e.style;
|
|
10
10
|
t.setProperty("display", "block", "important"), t.setProperty("position", "fixed", "important"), t.setProperty("top", "0", "important"), t.setProperty("left", "0", "important"), t.setProperty("width", "100%", "important"), t.setProperty("height", "100%", "important"), t.setProperty("border", "none", "important"), t.setProperty("clip-path", "inset(100%)", "important"), t.setProperty("background", "transparent"), t.setProperty("color-scheme", "normal"), t.setProperty("z-index", "2147483647"), e.setAttribute("title", "FKN");
|
|
11
|
-
}, oe = ({ x: e, y: t, width: n, height: r }) => `M${e} ${t}h${n}v${r}h${-n}Z`,
|
|
11
|
+
}, oe = ({ x: e, y: t, width: n, height: r }) => `M${e} ${t}h${n}v${r}h${-n}Z`, se = (e, { modal: t, rects: n }) => {
|
|
12
12
|
if (!ie) {
|
|
13
13
|
let r = t || n.length > 0;
|
|
14
14
|
e.style.setProperty("pointer-events", r ? "auto" : "none", "important"), e.style.setProperty("visibility", r ? "visible" : "hidden", "important");
|
|
@@ -16,7 +16,7 @@ var re = 32, ie = typeof CSS < "u" && CSS.supports("clip-path", "path('M0 0H1V1H
|
|
|
16
16
|
}
|
|
17
17
|
let r = t ? "none" : n.length === 0 ? "inset(100%)" : `path('${n.map(oe).join("")}')`, i = r === "none" || CSS.supports("clip-path", r) ? r : "inset(100%)";
|
|
18
18
|
e.style.setProperty("clip-path", i, "important");
|
|
19
|
-
},
|
|
19
|
+
}, ce = (e) => {
|
|
20
20
|
if (typeof e != "object" || !e) return null;
|
|
21
21
|
let { x: t, y: n, width: r, height: i } = e;
|
|
22
22
|
if (![
|
|
@@ -32,45 +32,45 @@ var re = 32, ie = typeof CSS < "u" && CSS.supports("clip-path", "path('M0 0H1V1H
|
|
|
32
32
|
width: l - s,
|
|
33
33
|
height: ee - c
|
|
34
34
|
};
|
|
35
|
-
},
|
|
35
|
+
}, le = (e) => {
|
|
36
36
|
if (typeof e != "object" || !e) return null;
|
|
37
|
-
let t = e, n = (Array.isArray(t.rects) ? t.rects.slice(0, re) : []).map(
|
|
37
|
+
let t = e, n = (Array.isArray(t.rects) ? t.rects.slice(0, re) : []).map(ce).filter((e) => e !== null && e.width > 0 && e.height > 0);
|
|
38
38
|
return {
|
|
39
39
|
modal: t.modal === !0,
|
|
40
40
|
rects: n
|
|
41
41
|
};
|
|
42
|
-
},
|
|
43
|
-
ae(e),
|
|
42
|
+
}, h = null, ue = () => h !== null, de = (e) => {
|
|
43
|
+
ae(e), se(e, {
|
|
44
44
|
modal: !1,
|
|
45
45
|
rects: []
|
|
46
|
-
}),
|
|
47
|
-
},
|
|
48
|
-
if (!
|
|
49
|
-
let t =
|
|
50
|
-
t && h
|
|
51
|
-
},
|
|
52
|
-
!
|
|
53
|
-
var b =
|
|
54
|
-
b &&
|
|
55
|
-
var
|
|
56
|
-
if (typeof window < "u") return
|
|
46
|
+
}), h = e;
|
|
47
|
+
}, fe = (e) => {
|
|
48
|
+
if (!h) return;
|
|
49
|
+
let t = le(e);
|
|
50
|
+
t && se(h, t);
|
|
51
|
+
}, g = "https://fkn.app", _ = typeof globalThis < "u" && globalThis.document ? globalThis.document : void 0, v = _?.querySelector(`iframe[src="${g}/api"]`) ?? null, y = _?.createElement("iframe") ?? null;
|
|
52
|
+
!v && y && _ && (y.src = `${g}/api`, _.body.appendChild(y));
|
|
53
|
+
var b = v ?? y, x = b?.contentWindow ?? null;
|
|
54
|
+
b && _ && de(b);
|
|
55
|
+
var pe = (() => {
|
|
56
|
+
if (typeof window < "u") return x ? {
|
|
57
57
|
receive: window,
|
|
58
|
-
emit:
|
|
58
|
+
emit: x
|
|
59
59
|
} : void 0;
|
|
60
60
|
if (typeof self < "u") return {
|
|
61
61
|
receive: self,
|
|
62
62
|
emit: self
|
|
63
63
|
};
|
|
64
|
-
})(),
|
|
64
|
+
})(), S = pe ? te({}, {
|
|
65
65
|
key: "fkn-api",
|
|
66
|
-
transport:
|
|
66
|
+
transport: pe
|
|
67
67
|
}) : new Promise(() => {});
|
|
68
|
-
|
|
69
|
-
|
|
68
|
+
S.then((e) => {
|
|
69
|
+
ue() && e.setOverlayHost(fe);
|
|
70
70
|
}, () => {});
|
|
71
71
|
//#endregion
|
|
72
72
|
//#region src/lib/proxy.ts
|
|
73
|
-
var
|
|
73
|
+
var me = (e, t) => S.then((n) => n.proxyFetch(e, t)), he = "https://fkn.app", ge = (e, t) => {
|
|
74
74
|
if (typeof window > "u") throw Error("FKN @fkn/lib: relayWorker must be called from the main thread");
|
|
75
75
|
if (!b?.contentWindow) throw Error("FKN @fkn/lib: relayWorker called before the FKN iframe was injected");
|
|
76
76
|
ne({
|
|
@@ -78,90 +78,90 @@ var he = (e, t) => x.then((n) => n.proxyFetch(e, t)), ge = "https://fkn.app", _e
|
|
|
78
78
|
emit: b.contentWindow
|
|
79
79
|
}, e, {
|
|
80
80
|
key: "fkn-api",
|
|
81
|
-
originA: t?.originA ??
|
|
81
|
+
originA: t?.originA ?? he,
|
|
82
82
|
originB: t?.originB ?? "*",
|
|
83
83
|
unregisterSignal: t?.unregisterSignal
|
|
84
84
|
});
|
|
85
|
-
},
|
|
86
|
-
typeof document < "u" && document.addEventListener(
|
|
87
|
-
|
|
85
|
+
}, _e = "FKN_WEB_EXTENSION_MAIN_WORLD_CONTENT_SCRIPT_ENABLED_EVENT_KEY", ve = "fknExtension", C = ee();
|
|
86
|
+
typeof document < "u" && document.addEventListener(_e, (e) => {
|
|
87
|
+
C.dispatchEvent(new CustomEvent("statuschange", { detail: { enabled: e.detail.enabled } }));
|
|
88
88
|
});
|
|
89
|
-
var
|
|
90
|
-
|
|
91
|
-
},
|
|
92
|
-
if (
|
|
89
|
+
var w = () => document.documentElement.dataset[ve] === "true", T = null, E = (e) => {
|
|
90
|
+
T = e;
|
|
91
|
+
}, ye = 150, D = (e = 1e3) => new Promise((t, n) => {
|
|
92
|
+
if (w()) return t();
|
|
93
93
|
let r, i = (e) => {
|
|
94
94
|
clearTimeout(r), s.disconnect(), document.removeEventListener("readystatechange", c), e();
|
|
95
95
|
}, a = () => i(async () => {
|
|
96
|
-
if (
|
|
96
|
+
if (T && (await T().catch(() => {}), w())) return t();
|
|
97
97
|
n(/* @__PURE__ */ Error("The FKN WebExtension is not installed, enabled or not exposed on this page."));
|
|
98
98
|
}), o = () => {
|
|
99
|
-
clearTimeout(r), r = setTimeout(() =>
|
|
99
|
+
clearTimeout(r), r = setTimeout(() => w() ? i(t) : a(), ye);
|
|
100
100
|
}, s = new MutationObserver(() => {
|
|
101
|
-
|
|
101
|
+
w() && i(t);
|
|
102
102
|
}), c = () => {
|
|
103
|
-
document.readyState === "complete" && !
|
|
103
|
+
document.readyState === "complete" && !w() && o();
|
|
104
104
|
};
|
|
105
105
|
if (r = setTimeout(a, e), s.observe(document.documentElement, {
|
|
106
106
|
attributes: !0,
|
|
107
107
|
attributeFilter: ["data-fkn-extension"]
|
|
108
108
|
}), document.addEventListener("readystatechange", c), document.readyState === "complete") return o();
|
|
109
|
-
|
|
110
|
-
}),
|
|
111
|
-
await
|
|
109
|
+
w() && i(t);
|
|
110
|
+
}), O, k = new Proxy({}, { get: (e, t) => async (...e) => {
|
|
111
|
+
await D(), O ??= te({}, {
|
|
112
112
|
transport: window,
|
|
113
113
|
revivableModules: i
|
|
114
114
|
});
|
|
115
|
-
let n = (await
|
|
115
|
+
let n = (await O)[t];
|
|
116
116
|
return n(...e);
|
|
117
|
-
} }),
|
|
117
|
+
} }), be = {
|
|
118
118
|
scope: "network.fetch",
|
|
119
119
|
category: "network",
|
|
120
120
|
severity: 0,
|
|
121
121
|
title: "Fetch data from other sites",
|
|
122
122
|
description: "Lets the app download public data from other websites directly, past the usual cross-origin limits."
|
|
123
|
-
},
|
|
123
|
+
}, xe = {
|
|
124
124
|
scope: "network.fetchCredentialed",
|
|
125
125
|
category: "network",
|
|
126
126
|
severity: 3,
|
|
127
127
|
unsafe: !0,
|
|
128
|
-
title: "Fetch from other sites
|
|
128
|
+
title: "Fetch from other sites, signed in as you",
|
|
129
129
|
description: "Lets the app fetch other sites using your logged-in session cookies, so it can read data only you should see."
|
|
130
|
-
},
|
|
130
|
+
}, Se = ["origin", "referer"], Ce = (e) => {
|
|
131
131
|
if (!e?.headers) return;
|
|
132
|
-
let t = new Headers(e.headers), n =
|
|
132
|
+
let t = new Headers(e.headers), n = Se.map((e) => {
|
|
133
133
|
let n = t.get(e);
|
|
134
134
|
return n === null ? void 0 : [e, n];
|
|
135
135
|
}).filter((e) => e !== void 0);
|
|
136
136
|
return n.length ? n : void 0;
|
|
137
|
-
},
|
|
137
|
+
}, we = async (e, t) => {
|
|
138
138
|
let n = new Request(e, t), r = n.body ? await n.arrayBuffer() : null;
|
|
139
|
-
return
|
|
139
|
+
return k.proxyFetch({
|
|
140
140
|
url: n.url,
|
|
141
141
|
method: n.method,
|
|
142
142
|
headers: [...n.headers],
|
|
143
143
|
body: r,
|
|
144
144
|
credentials: t?.credentials === "include" ? "include" : "omit",
|
|
145
145
|
redirect: n.redirect,
|
|
146
|
-
unsafeHeaders:
|
|
146
|
+
unsafeHeaders: Ce(t),
|
|
147
147
|
reason: t?.reason,
|
|
148
148
|
signal: t?.signal ?? void 0
|
|
149
149
|
});
|
|
150
|
-
},
|
|
150
|
+
}, Te = {
|
|
151
151
|
scope: "network.readCookie",
|
|
152
152
|
category: "network",
|
|
153
153
|
severity: 3,
|
|
154
154
|
unsafe: !0,
|
|
155
155
|
title: "Read a site’s cookie",
|
|
156
156
|
description: "Lets the app read a named cookie from another site, which can include the login token only that site should see."
|
|
157
|
-
},
|
|
157
|
+
}, Ee = { get: (e) => k.getCookie(e) }, De = {
|
|
158
158
|
scope: "network.modifyRequestHeaders",
|
|
159
159
|
category: "network",
|
|
160
160
|
severity: 2,
|
|
161
161
|
unsafe: !0,
|
|
162
162
|
title: "Rewrite request headers to other sites",
|
|
163
163
|
description: "Lets the app set or remove headers (like Origin and Referer) on this page’s own requests to the listed sites."
|
|
164
|
-
},
|
|
164
|
+
}, Oe = (e) => k.setRequestHeaderRule(e), ke = (e) => k.removeRequestHeaderRule({ ruleId: e });
|
|
165
165
|
(() => {
|
|
166
166
|
let e = {}, t = [...c.selectorModules, ...r.selectorModules];
|
|
167
167
|
for (let n of t) n.render && !(n.type in e) && (e[n.type] = n.render);
|
|
@@ -169,7 +169,7 @@ var C = () => document.documentElement.dataset[ye] === "true", w = null, T = (e)
|
|
|
169
169
|
})();
|
|
170
170
|
//#endregion
|
|
171
171
|
//#region node_modules/@mfkn/web-extension/lib/lib/frame.js
|
|
172
|
-
var
|
|
172
|
+
var A = "FKN_WEB_EXTENSION_ATTACH_FRAME_EVENT_KEY", j = (e) => {
|
|
173
173
|
if (!e || e === "about:blank") return !1;
|
|
174
174
|
let t;
|
|
175
175
|
try {
|
|
@@ -181,28 +181,28 @@ var k = "FKN_WEB_EXTENSION_ATTACH_FRAME_EVENT_KEY", A = (e) => {
|
|
|
181
181
|
if (t.protocol === "about:") return !1;
|
|
182
182
|
let n = t.hostname;
|
|
183
183
|
return n === "fkn.app" || n.endsWith(".fkn.app");
|
|
184
|
-
},
|
|
185
|
-
if (
|
|
186
|
-
},
|
|
184
|
+
}, M = (e) => {
|
|
185
|
+
if (j(e)) throw Error("attachFrame: refusing to target the extension's own pages or fkn.app");
|
|
186
|
+
}, Ae = {
|
|
187
187
|
scope: "embed.iframe",
|
|
188
188
|
category: "embed",
|
|
189
189
|
severity: 0,
|
|
190
190
|
title: "Load another website inside this app",
|
|
191
191
|
description: "Lets the app embed external pages directly inside its own view."
|
|
192
|
-
},
|
|
192
|
+
}, je = {
|
|
193
193
|
scope: "embed.open",
|
|
194
194
|
category: "embed",
|
|
195
195
|
severity: 0,
|
|
196
196
|
title: "Open a website inside this app",
|
|
197
197
|
description: "Lets the app navigate to another site without leaving its window."
|
|
198
|
-
},
|
|
198
|
+
}, Me = async ({ iframe: e, domains: t = [] }) => {
|
|
199
199
|
let n = crypto.randomUUID();
|
|
200
|
-
if (
|
|
201
|
-
e.dispatchEvent(new CustomEvent(
|
|
202
|
-
let { executeLocator: r, ensureLocatorPermission: i, goto: a } = await
|
|
200
|
+
if (M(e.src), await D(), !e.isConnected) throw Error("attachFrame: the iframe must be connected to the document before attaching");
|
|
201
|
+
e.dispatchEvent(new CustomEvent(A, { detail: n }));
|
|
202
|
+
let { executeLocator: r, ensureLocatorPermission: i, goto: a } = await k.attachFrame({
|
|
203
203
|
marker: n,
|
|
204
204
|
domains: t
|
|
205
|
-
}), o = s(r, i), c = (e, t = {}) => (
|
|
205
|
+
}), o = s(r, i), c = (e, t = {}) => (M(e), a({
|
|
206
206
|
url: e,
|
|
207
207
|
...t
|
|
208
208
|
})), l = () => e.src;
|
|
@@ -211,28 +211,49 @@ var k = "FKN_WEB_EXTENSION_ATTACH_FRAME_EVENT_KEY", A = (e) => {
|
|
|
211
211
|
goto: c,
|
|
212
212
|
url: l
|
|
213
213
|
};
|
|
214
|
-
},
|
|
214
|
+
}, Ne = { request: (e) => k.requestPermissions(e.map((e) => ({
|
|
215
215
|
key: e.key,
|
|
216
216
|
scope: e.scope ?? "",
|
|
217
217
|
reason: e.reason
|
|
218
|
-
}))) },
|
|
218
|
+
}))) }, N = async (e) => {
|
|
219
219
|
if (typeof window > "u") return !1;
|
|
220
|
-
if (
|
|
221
|
-
let t = await
|
|
220
|
+
if (w()) return !0;
|
|
221
|
+
let t = await S, n = null, r = new Promise((e) => {
|
|
222
222
|
n = () => {
|
|
223
|
-
|
|
224
|
-
},
|
|
223
|
+
w() && e(!0);
|
|
224
|
+
}, C.addEventListener("statuschange", n);
|
|
225
225
|
}), i = t.showInstallPrompt(e).then(() => !1), a = await Promise.race([r, i]);
|
|
226
|
-
return n &&
|
|
227
|
-
},
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
}),
|
|
226
|
+
return n && C.removeEventListener("statuschange", n), await t.hideInstallPrompt().catch(() => {}), a;
|
|
227
|
+
}, P = null;
|
|
228
|
+
E(() => (P ||= N().then(() => void 0).finally(() => {
|
|
229
|
+
P = null;
|
|
230
|
+
}), P));
|
|
231
231
|
//#endregion
|
|
232
|
-
//#region src/lib/
|
|
233
|
-
var
|
|
232
|
+
//#region src/lib/fs.ts
|
|
233
|
+
var Pe = /* @__PURE__ */ n({
|
|
234
|
+
ensureDirectoryPermission: () => Ie,
|
|
235
|
+
isLocalDirectorySupported: () => F,
|
|
236
|
+
pickLocalDirectory: () => Fe,
|
|
237
|
+
queryDirectoryPermission: () => I
|
|
238
|
+
}), F = () => typeof window < "u" && "showDirectoryPicker" in window, Fe = async (e = {}) => {
|
|
239
|
+
if (!F()) return;
|
|
240
|
+
let t = window.showDirectoryPicker;
|
|
241
|
+
return t({
|
|
242
|
+
mode: "readwrite",
|
|
243
|
+
...e
|
|
244
|
+
}).catch((e) => {
|
|
245
|
+
if (e?.name !== "AbortError") throw e;
|
|
246
|
+
});
|
|
247
|
+
}, I = async (e, t = "readwrite") => {
|
|
248
|
+
let { queryPermission: n } = e;
|
|
249
|
+
return await n?.call(e, { mode: t }) ?? "granted";
|
|
250
|
+
}, Ie = async (e, t = "readwrite") => {
|
|
251
|
+
if (await I(e, t) === "granted") return !0;
|
|
252
|
+
let { requestPermission: n } = e;
|
|
253
|
+
return await n?.call(e, { mode: t }) === "granted";
|
|
254
|
+
}, Le = new TextEncoder();
|
|
234
255
|
new TextDecoder();
|
|
235
|
-
var
|
|
256
|
+
var L = (e) => f.isValid(e), R = (e) => p.isValid(e), Re = (e) => L(e) ? 4 : R(e) ? 6 : 0, ze = (...e) => {
|
|
236
257
|
if (typeof e[0] == "string") throw Error("FKN WebVPN does not support IPC connections");
|
|
237
258
|
let t = typeof e.at(-1) == "function" ? e.at(-1) : void 0;
|
|
238
259
|
return e[0] && typeof e[0] == "object" ? {
|
|
@@ -243,7 +264,7 @@ var P = (e) => f.isValid(e), F = (e) => p.isValid(e), I = (e) => P(e) ? 4 : F(e)
|
|
|
243
264
|
host: typeof e[1] == "string" ? e[1] : void 0,
|
|
244
265
|
callback: t
|
|
245
266
|
};
|
|
246
|
-
},
|
|
267
|
+
}, Be = (...e) => {
|
|
247
268
|
let t = typeof e.at(-1) == "function" ? e.at(-1) : void 0, n = e[0] ?? 0, r = typeof e[1] == "string" ? e[1] : void 0;
|
|
248
269
|
return typeof e[0] == "object" ? {
|
|
249
270
|
...e[0],
|
|
@@ -255,7 +276,7 @@ var P = (e) => f.isValid(e), F = (e) => p.isValid(e), I = (e) => P(e) ? 4 : F(e)
|
|
|
255
276
|
port: n,
|
|
256
277
|
callback: t
|
|
257
278
|
};
|
|
258
|
-
},
|
|
279
|
+
}, Ve = (...e) => {
|
|
259
280
|
let t = typeof e.at(-1) == "function" ? e.at(-1) : void 0, n = e[0];
|
|
260
281
|
if (typeof e[2] == "number") return {
|
|
261
282
|
message: n,
|
|
@@ -280,18 +301,18 @@ var P = (e) => f.isValid(e), F = (e) => p.isValid(e), I = (e) => P(e) ? 4 : F(e)
|
|
|
280
301
|
new TextEncoder(), new TextDecoder();
|
|
281
302
|
//#endregion
|
|
282
303
|
//#region src/lib/webvpn/net.ts
|
|
283
|
-
var
|
|
284
|
-
Server: () =>
|
|
285
|
-
Socket: () =>
|
|
286
|
-
_default: () =>
|
|
287
|
-
connect: () =>
|
|
288
|
-
createConnection: () =>
|
|
289
|
-
createServer: () =>
|
|
290
|
-
default: () =>
|
|
291
|
-
isIP: () =>
|
|
292
|
-
isIPv4: () =>
|
|
293
|
-
isIPv6: () =>
|
|
294
|
-
}),
|
|
304
|
+
var He = /* @__PURE__ */ n({
|
|
305
|
+
Server: () => B,
|
|
306
|
+
Socket: () => z,
|
|
307
|
+
_default: () => Ke,
|
|
308
|
+
connect: () => Ue,
|
|
309
|
+
createConnection: () => We,
|
|
310
|
+
createServer: () => Ge,
|
|
311
|
+
default: () => Ke,
|
|
312
|
+
isIP: () => Re,
|
|
313
|
+
isIPv4: () => L,
|
|
314
|
+
isIPv6: () => R
|
|
315
|
+
}), z = class extends u.Duplex {
|
|
295
316
|
_localAddress;
|
|
296
317
|
_remoteAddress;
|
|
297
318
|
_webVPNTcpSocketPromise;
|
|
@@ -351,7 +372,7 @@ var Re = /* @__PURE__ */ n({
|
|
|
351
372
|
}).catch(n);
|
|
352
373
|
}
|
|
353
374
|
connect(...e) {
|
|
354
|
-
let t =
|
|
375
|
+
let t = ze(...e), n = this.__webvpn_tcp_socket_init__(S.then((e) => e.webVpnTcpSocket({
|
|
355
376
|
remoteAddress: t.host ?? "localhost",
|
|
356
377
|
remotePort: t.port
|
|
357
378
|
})));
|
|
@@ -478,7 +499,7 @@ var Re = /* @__PURE__ */ n({
|
|
|
478
499
|
return this._remoteAddress.family;
|
|
479
500
|
}
|
|
480
501
|
timeout;
|
|
481
|
-
},
|
|
502
|
+
}, B = class extends d {
|
|
482
503
|
_localAddress;
|
|
483
504
|
_webVPNTcpSocketListenerPromise;
|
|
484
505
|
constructor(e, t) {
|
|
@@ -496,10 +517,10 @@ var Re = /* @__PURE__ */ n({
|
|
|
496
517
|
}), this._webVPNTcpSocketListenerPromise;
|
|
497
518
|
}
|
|
498
519
|
listen(...e) {
|
|
499
|
-
let t =
|
|
500
|
-
let t = new
|
|
520
|
+
let t = ze(...e), n = (e) => {
|
|
521
|
+
let t = new z({ connection: Promise.resolve(e) });
|
|
501
522
|
this.emit("connection", t);
|
|
502
|
-
}, r = (e) =>
|
|
523
|
+
}, r = (e) => S.then((r) => r.webVpnTcpSocketListener({
|
|
503
524
|
localAddress: e,
|
|
504
525
|
localPort: t.port,
|
|
505
526
|
onConnection: n
|
|
@@ -533,23 +554,23 @@ var Re = /* @__PURE__ */ n({
|
|
|
533
554
|
connections;
|
|
534
555
|
listening;
|
|
535
556
|
async [Symbol.asyncDispose]() {}
|
|
536
|
-
},
|
|
557
|
+
}, Ue = (e, t) => new z().connect(e, t), We = (e, t) => new z().connect(e, t), Ge = (e, t) => {
|
|
537
558
|
typeof e == "function" && (t = e, e = void 0);
|
|
538
|
-
let n = new
|
|
559
|
+
let n = new B(e);
|
|
539
560
|
return t && n.on("connection", t), n;
|
|
540
|
-
},
|
|
541
|
-
Socket:
|
|
542
|
-
Server:
|
|
543
|
-
connect:
|
|
544
|
-
createConnection:
|
|
545
|
-
createServer:
|
|
546
|
-
isIP:
|
|
547
|
-
isIPv4:
|
|
548
|
-
isIPv6:
|
|
549
|
-
},
|
|
550
|
-
Socket: () =>
|
|
551
|
-
createSocket: () =>
|
|
552
|
-
}),
|
|
561
|
+
}, Ke = {
|
|
562
|
+
Socket: z,
|
|
563
|
+
Server: B,
|
|
564
|
+
connect: Ue,
|
|
565
|
+
createConnection: We,
|
|
566
|
+
createServer: Ge,
|
|
567
|
+
isIP: Re,
|
|
568
|
+
isIPv4: L,
|
|
569
|
+
isIPv6: R
|
|
570
|
+
}, qe = /* @__PURE__ */ n({
|
|
571
|
+
Socket: () => Je,
|
|
572
|
+
createSocket: () => Xe
|
|
573
|
+
}), Je = class extends d {
|
|
553
574
|
_type;
|
|
554
575
|
_localAddress;
|
|
555
576
|
_remoteAddress;
|
|
@@ -578,7 +599,7 @@ var Re = /* @__PURE__ */ n({
|
|
|
578
599
|
}
|
|
579
600
|
addMembership(e, t) {
|
|
580
601
|
if (f.isValid(e)) {
|
|
581
|
-
let n =
|
|
602
|
+
let n = V(e), r = t && f.isValid(t) ? V(t) : new Uint8Array([
|
|
582
603
|
0,
|
|
583
604
|
0,
|
|
584
605
|
0,
|
|
@@ -590,7 +611,7 @@ var Re = /* @__PURE__ */ n({
|
|
|
590
611
|
interface: r
|
|
591
612
|
});
|
|
592
613
|
} else if (p.isValid(e)) {
|
|
593
|
-
let t =
|
|
614
|
+
let t = Ye(e);
|
|
594
615
|
this._setUdpOption({
|
|
595
616
|
type: 7,
|
|
596
617
|
group: t,
|
|
@@ -603,8 +624,8 @@ var Re = /* @__PURE__ */ n({
|
|
|
603
624
|
return this._localAddress;
|
|
604
625
|
}
|
|
605
626
|
bind(...e) {
|
|
606
|
-
let t =
|
|
607
|
-
return this._webVPNUdpSocketPromise =
|
|
627
|
+
let t = Be(...e), n = this._type === "udp6" ? "::" : "0.0.0.0";
|
|
628
|
+
return this._webVPNUdpSocketPromise = S.then((e) => e.webVpnUdpSocket({
|
|
608
629
|
type: this._type,
|
|
609
630
|
address: t.address ?? n,
|
|
610
631
|
port: t.port
|
|
@@ -665,7 +686,7 @@ var Re = /* @__PURE__ */ n({
|
|
|
665
686
|
}
|
|
666
687
|
dropMembership(e, t) {
|
|
667
688
|
if (f.isValid(e)) {
|
|
668
|
-
let n =
|
|
689
|
+
let n = V(e), r = t && f.isValid(t) ? V(t) : new Uint8Array([
|
|
669
690
|
0,
|
|
670
691
|
0,
|
|
671
692
|
0,
|
|
@@ -677,7 +698,7 @@ var Re = /* @__PURE__ */ n({
|
|
|
677
698
|
interface: r
|
|
678
699
|
});
|
|
679
700
|
} else if (p.isValid(e)) {
|
|
680
|
-
let t =
|
|
701
|
+
let t = Ye(e);
|
|
681
702
|
this._setUdpOption({
|
|
682
703
|
type: 8,
|
|
683
704
|
group: t,
|
|
@@ -710,11 +731,11 @@ var Re = /* @__PURE__ */ n({
|
|
|
710
731
|
}
|
|
711
732
|
send(...e) {
|
|
712
733
|
this._webVPNUdpSocketPromise || this.bind();
|
|
713
|
-
let t =
|
|
734
|
+
let t = Ve(...e), n = this._type === "udp6" ? "::1" : "127.0.0.1";
|
|
714
735
|
if (!this._webVPNUdpSocketPromise) throw Error("Socket not bound");
|
|
715
736
|
this._webVPNUdpSocketPromise.then((e) => {
|
|
716
737
|
if (!e) throw Error("Socket not bound");
|
|
717
|
-
let r = typeof t.message == "string" ?
|
|
738
|
+
let r = typeof t.message == "string" ? Le.encode(t.message) : t.message;
|
|
718
739
|
e.send({
|
|
719
740
|
...t,
|
|
720
741
|
address: t.address ?? n,
|
|
@@ -772,33 +793,33 @@ var Re = /* @__PURE__ */ n({
|
|
|
772
793
|
this.close(e);
|
|
773
794
|
});
|
|
774
795
|
}
|
|
775
|
-
},
|
|
796
|
+
}, V = (e) => {
|
|
776
797
|
let t = e.split(".").map((e) => parseInt(e, 10));
|
|
777
798
|
if (t.length !== 4 || t.some((e) => Number.isNaN(e) || e < 0 || e > 255)) throw Error(`Invalid IPv4 address: ${e}`);
|
|
778
799
|
return new Uint8Array(t);
|
|
779
|
-
},
|
|
800
|
+
}, Ye = (e) => {
|
|
780
801
|
let t = new p(e).getBitsBase16(0, 128).match(/.{2}/g);
|
|
781
802
|
if (!t || t.length !== 16) throw Error(`Invalid IPv6 address: ${e}`);
|
|
782
803
|
return new Uint8Array(t.map((e) => parseInt(e, 16)));
|
|
783
|
-
},
|
|
784
|
-
let n = new
|
|
804
|
+
}, Xe = (e, t) => {
|
|
805
|
+
let n = new Je(typeof e == "string" ? { type: e } : e);
|
|
785
806
|
return t && n.on("message", t), n;
|
|
786
|
-
},
|
|
807
|
+
}, Ze = /* @__PURE__ */ n({
|
|
787
808
|
Agent: () => Q,
|
|
788
809
|
ClientRequest: () => X,
|
|
789
810
|
HTTPParser: () => K,
|
|
790
811
|
IncomingMessage: () => q,
|
|
791
|
-
METHODS: () =>
|
|
792
|
-
STATUS_CODES: () =>
|
|
812
|
+
METHODS: () => $e,
|
|
813
|
+
STATUS_CODES: () => H,
|
|
793
814
|
Server: () => Z,
|
|
794
815
|
ServerResponse: () => Y,
|
|
795
|
-
_default: () =>
|
|
796
|
-
createServer: () =>
|
|
797
|
-
default: () =>
|
|
798
|
-
get: () =>
|
|
799
|
-
globalAgent: () =>
|
|
816
|
+
_default: () => ut,
|
|
817
|
+
createServer: () => lt,
|
|
818
|
+
default: () => ut,
|
|
819
|
+
get: () => ct,
|
|
820
|
+
globalAgent: () => st,
|
|
800
821
|
request: () => $
|
|
801
|
-
}),
|
|
822
|
+
}), Qe = new TextDecoder("latin1"), $e = /* @__PURE__ */ "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("."), H = {
|
|
802
823
|
100: "Continue",
|
|
803
824
|
101: "Switching Protocols",
|
|
804
825
|
102: "Processing",
|
|
@@ -862,7 +883,7 @@ var Re = /* @__PURE__ */ n({
|
|
|
862
883
|
509: "Bandwidth Limit Exceeded",
|
|
863
884
|
510: "Not Extended",
|
|
864
885
|
511: "Network Authentication Required"
|
|
865
|
-
},
|
|
886
|
+
}, et = new Set([
|
|
866
887
|
"content-type",
|
|
867
888
|
"content-length",
|
|
868
889
|
"user-agent",
|
|
@@ -881,16 +902,16 @@ var Re = /* @__PURE__ */ n({
|
|
|
881
902
|
"server",
|
|
882
903
|
"age",
|
|
883
904
|
"expires"
|
|
884
|
-
]),
|
|
905
|
+
]), U = 13, W = 10, tt = /^[\^_`a-zA-Z\-0-9!#$%&'*+.|~]+$/, G = (e, t) => (e.code = t, e), nt = (e, t) => {
|
|
885
906
|
if (e.length === 0) return t;
|
|
886
907
|
if (t.length === 0) return e;
|
|
887
908
|
let n = new Uint8Array(e.length + t.length);
|
|
888
909
|
return n.set(e, 0), n.set(t, e.length), n;
|
|
889
|
-
},
|
|
890
|
-
for (let n = t; n + 1 < e.length; n++) if (e[n] ===
|
|
910
|
+
}, rt = (e, t) => {
|
|
911
|
+
for (let n = t; n + 1 < e.length; n++) if (e[n] === U && e[n + 1] === W) return n;
|
|
891
912
|
return -1;
|
|
892
|
-
},
|
|
893
|
-
for (let t = 0; t + 3 < e.length; t++) if (e[t] ===
|
|
913
|
+
}, it = (e) => {
|
|
914
|
+
for (let t = 0; t + 3 < e.length; t++) if (e[t] === U && e[t + 1] === W && e[t + 2] === U && e[t + 3] === W) return t;
|
|
894
915
|
return -1;
|
|
895
916
|
}, K = class {
|
|
896
917
|
buf = new Uint8Array();
|
|
@@ -903,10 +924,10 @@ var Re = /* @__PURE__ */ n({
|
|
|
903
924
|
this.mode = e, this.handlers = t;
|
|
904
925
|
}
|
|
905
926
|
execute(e) {
|
|
906
|
-
this.buf =
|
|
927
|
+
this.buf = nt(this.buf, e);
|
|
907
928
|
let t = !0;
|
|
908
929
|
for (; t;) if (t = !1, this.state === "HEAD") {
|
|
909
|
-
let e =
|
|
930
|
+
let e = it(this.buf);
|
|
910
931
|
if (e === -1) return;
|
|
911
932
|
let n = this.buf.subarray(0, e);
|
|
912
933
|
this.buf = this.buf.subarray(e + 4);
|
|
@@ -921,7 +942,7 @@ var Re = /* @__PURE__ */ n({
|
|
|
921
942
|
this.state = "HEAD", this.framing = "none", this.bodyRemaining = 0, this.chunkState = "size", this.skipBody = !1;
|
|
922
943
|
}
|
|
923
944
|
parseHead(e) {
|
|
924
|
-
let t =
|
|
945
|
+
let t = Qe.decode(e).split("\r\n"), n = t.shift() ?? "", r = [];
|
|
925
946
|
for (let e of t) (e.startsWith(" ") || e.startsWith(" ")) && r.length > 0 ? r[r.length - 1] += " " + e.trim() : r.push(e);
|
|
926
947
|
let i = [], a = {};
|
|
927
948
|
for (let e of r) {
|
|
@@ -959,7 +980,7 @@ var Re = /* @__PURE__ */ n({
|
|
|
959
980
|
return;
|
|
960
981
|
}
|
|
961
982
|
let i = e[r];
|
|
962
|
-
i === void 0 ? e[r] = n :
|
|
983
|
+
i === void 0 ? e[r] = n : et.has(r) || (e[r] = `${i}, ${n}`);
|
|
963
984
|
}
|
|
964
985
|
setupBody(e) {
|
|
965
986
|
if (this.skipBody) {
|
|
@@ -992,9 +1013,9 @@ var Re = /* @__PURE__ */ n({
|
|
|
992
1013
|
}
|
|
993
1014
|
consumeChunked() {
|
|
994
1015
|
for (;;) if (this.chunkState === "size") {
|
|
995
|
-
let e =
|
|
1016
|
+
let e = rt(this.buf, 0);
|
|
996
1017
|
if (e === -1) return !1;
|
|
997
|
-
let t =
|
|
1018
|
+
let t = Qe.decode(this.buf.subarray(0, e)), n = parseInt(t.split(";")[0].trim(), 16);
|
|
998
1019
|
if (this.buf = this.buf.subarray(e + 2), Number.isNaN(n)) return !0;
|
|
999
1020
|
n === 0 ? this.chunkState = "trailer" : (this.bodyRemaining = n, this.chunkState = "data");
|
|
1000
1021
|
} else if (this.chunkState === "data") {
|
|
@@ -1005,13 +1026,13 @@ var Re = /* @__PURE__ */ n({
|
|
|
1005
1026
|
if (this.buf.length < 2) return !1;
|
|
1006
1027
|
this.buf = this.buf.subarray(2), this.chunkState = "size";
|
|
1007
1028
|
} else {
|
|
1008
|
-
let e =
|
|
1029
|
+
let e = rt(this.buf, 0);
|
|
1009
1030
|
if (e === -1) return !1;
|
|
1010
1031
|
let t = e === 0;
|
|
1011
1032
|
if (this.buf = this.buf.subarray(e + 2), t) return !0;
|
|
1012
1033
|
}
|
|
1013
1034
|
}
|
|
1014
|
-
},
|
|
1035
|
+
}, at = (e, t) => m.isBuffer(e) ? e : typeof e == "string" ? m.from(e, t ?? "utf8") : e instanceof Uint8Array ? m.from(e) : e instanceof ArrayBuffer ? m.from(new Uint8Array(e)) : m.from(String(e)), q = class extends u.Readable {
|
|
1015
1036
|
httpVersion = "1.1";
|
|
1016
1037
|
httpVersionMajor = 1;
|
|
1017
1038
|
httpVersionMinor = 1;
|
|
@@ -1045,9 +1066,9 @@ var Re = /* @__PURE__ */ n({
|
|
|
1045
1066
|
finished = !1;
|
|
1046
1067
|
_bodyWritten = !1;
|
|
1047
1068
|
setHeader(e, t) {
|
|
1048
|
-
if (this.headersSent) throw
|
|
1049
|
-
if (typeof e != "string" || !
|
|
1050
|
-
if (t === void 0) throw
|
|
1069
|
+
if (this.headersSent) throw G(/* @__PURE__ */ Error("Cannot set headers after they are sent to the client"), "ERR_HTTP_HEADERS_SENT");
|
|
1070
|
+
if (typeof e != "string" || !tt.test(e)) throw G(/* @__PURE__ */ TypeError(`Header name must be a valid HTTP token [${JSON.stringify(String(e))}]`), "ERR_INVALID_HTTP_TOKEN");
|
|
1071
|
+
if (t === void 0) throw G(/* @__PURE__ */ TypeError(`Invalid value "undefined" for header "${e}"`), "ERR_HTTP_INVALID_HEADER_VALUE");
|
|
1051
1072
|
return this._headerStore.set(e.toLowerCase(), [e, Array.isArray(t) ? [...t] : t]), this;
|
|
1052
1073
|
}
|
|
1053
1074
|
getHeader(e) {
|
|
@@ -1087,7 +1108,7 @@ var Re = /* @__PURE__ */ n({
|
|
|
1087
1108
|
return this._bodyWritten = !0, super.write(e, t, n);
|
|
1088
1109
|
}
|
|
1089
1110
|
_write(e, t, n) {
|
|
1090
|
-
let r =
|
|
1111
|
+
let r = at(e), i = [];
|
|
1091
1112
|
if (this.headersSent ||= (this._implicitHeader(), i.push(m.from(this._headBlock, "latin1")), !0), this.chunkedEncoding ? r.length > 0 && (i.push(m.from(`${r.length.toString(16)}\r\n`, "latin1")), i.push(r), i.push(m.from("\r\n", "latin1"))) : i.push(r), i.length === 0) {
|
|
1092
1113
|
n();
|
|
1093
1114
|
return;
|
|
@@ -1105,7 +1126,7 @@ var Re = /* @__PURE__ */ n({
|
|
|
1105
1126
|
end(e, t, n) {
|
|
1106
1127
|
if (e != null && typeof e != "function" && !this._bodyWritten && !this.headersSent && !this.chunkedEncoding && !this.hasHeader("content-length")) {
|
|
1107
1128
|
let n = typeof t == "string" ? t : void 0;
|
|
1108
|
-
this.setHeader("Content-Length",
|
|
1129
|
+
this.setHeader("Content-Length", at(e, n).length);
|
|
1109
1130
|
}
|
|
1110
1131
|
return super.end(e, t, n);
|
|
1111
1132
|
}
|
|
@@ -1127,7 +1148,7 @@ var Re = /* @__PURE__ */ n({
|
|
|
1127
1148
|
return !(e >= 100 && e < 200 || e === 204 || e === 304);
|
|
1128
1149
|
}
|
|
1129
1150
|
writeHead(e, t, n) {
|
|
1130
|
-
if (this._writeHeadCalled || this.headersSent) throw
|
|
1151
|
+
if (this._writeHeadCalled || this.headersSent) throw G(/* @__PURE__ */ Error("Cannot render headers after they are sent to the client"), "ERR_HTTP_HEADERS_SENT");
|
|
1131
1152
|
this._writeHeadCalled = !0, this.statusCode = e;
|
|
1132
1153
|
let r = n;
|
|
1133
1154
|
if (typeof t == "string" ? this.statusMessage = t : t != null && (r = t), Array.isArray(r)) {
|
|
@@ -1145,7 +1166,7 @@ var Re = /* @__PURE__ */ n({
|
|
|
1145
1166
|
}
|
|
1146
1167
|
}
|
|
1147
1168
|
_implicitHeader() {
|
|
1148
|
-
let e = this.statusMessage ??
|
|
1169
|
+
let e = this.statusMessage ?? H[this.statusCode] ?? "unknown";
|
|
1149
1170
|
this.sendDate && !this.hasHeader("date") && this.setHeader("Date", (/* @__PURE__ */ new Date()).toUTCString()), this.hasHeader("connection") || this.setHeader("Connection", this._keepAlive ? "keep-alive" : "close"), this._headBlock = this._storeHeader(`HTTP/1.1 ${this.statusCode} ${e}`);
|
|
1150
1171
|
}
|
|
1151
1172
|
writeContinue() {
|
|
@@ -1154,7 +1175,7 @@ var Re = /* @__PURE__ */ n({
|
|
|
1154
1175
|
setTimeout(e, t) {
|
|
1155
1176
|
return this.socket?.setTimeout(e, t), this;
|
|
1156
1177
|
}
|
|
1157
|
-
},
|
|
1178
|
+
}, ot = (...e) => {
|
|
1158
1179
|
let t = {}, n = {}, r, i = [...e], a = i.shift();
|
|
1159
1180
|
if (typeof a == "string" || a instanceof URL) {
|
|
1160
1181
|
let e = typeof a == "string" ? new URL(a) : a;
|
|
@@ -1198,7 +1219,7 @@ var Re = /* @__PURE__ */ n({
|
|
|
1198
1219
|
let e = this.protocol === "https:" && r === 443 || this.protocol !== "https:" && r === 80;
|
|
1199
1220
|
this.setHeader("Host", e ? n : `${n}:${r}`);
|
|
1200
1221
|
}
|
|
1201
|
-
e.auth && !this.hasHeader("authorization") && this.setHeader("Authorization", `Basic ${m.from(e.auth).toString("base64")}`), this.socket = new
|
|
1222
|
+
e.auth && !this.hasHeader("authorization") && this.setHeader("Authorization", `Basic ${m.from(e.auth).toString("base64")}`), this.socket = new z(), this.emit("socket", this.socket), this.socket.on("error", (e) => {
|
|
1202
1223
|
this._aborted || this.emit("error", e);
|
|
1203
1224
|
}), this._attachResponseParser(), this.socket.connect({
|
|
1204
1225
|
host: n,
|
|
@@ -1258,7 +1279,7 @@ var Re = /* @__PURE__ */ n({
|
|
|
1258
1279
|
setSocketKeepAlive(e, t) {
|
|
1259
1280
|
this.socket.setKeepAlive(e, t);
|
|
1260
1281
|
}
|
|
1261
|
-
}, Z = new Proxy(class extends
|
|
1282
|
+
}, Z = new Proxy(class extends B {
|
|
1262
1283
|
constructor(e, t) {
|
|
1263
1284
|
let n = {}, r = t;
|
|
1264
1285
|
typeof e == "function" ? r = e : e && (n = e), super(n), r && this.on("request", r), this.on("connection", (e) => this._handleConnection(e));
|
|
@@ -1295,25 +1316,25 @@ var Re = /* @__PURE__ */ n({
|
|
|
1295
1316
|
return `${e.host ?? "localhost"}:${e.port ?? ""}:${e.localAddress ?? ""}`;
|
|
1296
1317
|
}
|
|
1297
1318
|
destroy() {}
|
|
1298
|
-
},
|
|
1299
|
-
let { options: t, callback: n } =
|
|
1319
|
+
}, st = new Q(), $ = (...e) => {
|
|
1320
|
+
let { options: t, callback: n } = ot(...e);
|
|
1300
1321
|
return new X(t, n);
|
|
1301
|
-
},
|
|
1322
|
+
}, ct = (...e) => {
|
|
1302
1323
|
let t = $(...e);
|
|
1303
1324
|
return t.end(), t;
|
|
1304
|
-
},
|
|
1305
|
-
METHODS:
|
|
1306
|
-
STATUS_CODES:
|
|
1325
|
+
}, lt = (e, t) => new Z(e, t), ut = {
|
|
1326
|
+
METHODS: $e,
|
|
1327
|
+
STATUS_CODES: H,
|
|
1307
1328
|
Agent: Q,
|
|
1308
|
-
globalAgent:
|
|
1329
|
+
globalAgent: st,
|
|
1309
1330
|
Server: Z,
|
|
1310
1331
|
ServerResponse: Y,
|
|
1311
1332
|
IncomingMessage: q,
|
|
1312
1333
|
ClientRequest: X,
|
|
1313
1334
|
OutgoingMessage: J,
|
|
1314
|
-
createServer:
|
|
1335
|
+
createServer: lt,
|
|
1315
1336
|
request: $,
|
|
1316
|
-
get:
|
|
1337
|
+
get: ct
|
|
1317
1338
|
};
|
|
1318
1339
|
//#endregion
|
|
1319
|
-
export {
|
|
1340
|
+
export { A as ATTACH_FRAME_EVENT_KEY, M as assertAttachableFrameUrl, Me as attachFrame, Ae as attachFramePermission, l as box, Ee as cookies, e as createVideoElementHandle, qe as dgram, C as extension, we as fetch, xe as fetchCredentialedPermission, be as fetchPermission, Pe as fs, je as gotoPermission, i as handleRevivableModules, Ze as http, j as isBlockedFrameUrl, w as isExtensionExposed, t as isType, De as modifyRequestHeadersPermission, He as net, Ne as permissions, N as promptInstall, Te as readCookiePermission, ge as relayWorker, ke as removeRequestHeaderRule, o as revive, me as serverProxyFetch, E as setMissingExtensionHandler, Oe as setRequestHeaderRule, a as type, D as waitForExtensionExposure };
|