@fkn/lib 0.3.10 → 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-DCdL9DVK.js → background-C5D7dhf2.js} +1 -1
- package/{background-D-gZyvaP.cjs → background-DdXHHDsS.cjs} +1 -1
- package/index.cjs +5 -5
- package/index.d.ts +33 -9
- package/index.js +179 -156
- package/{locator-fXEVniGP.js → locator-DUbu14FW.js} +145 -145
- package/locator-jHaMLjtv.cjs +53 -0
- package/package.json +1 -1
- package/locator-Bz_60Zup.cjs +0 -53
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";
|
|
@@ -52,7 +52,7 @@ var re = 32, ie = typeof CSS < "u" && CSS.supports("clip-path", "path('M0 0H1V1H
|
|
|
52
52
|
!v && y && _ && (y.src = `${g}/api`, _.body.appendChild(y));
|
|
53
53
|
var b = v ?? y, x = b?.contentWindow ?? null;
|
|
54
54
|
b && _ && de(b);
|
|
55
|
-
var
|
|
55
|
+
var pe = (() => {
|
|
56
56
|
if (typeof window < "u") return x ? {
|
|
57
57
|
receive: window,
|
|
58
58
|
emit: x
|
|
@@ -61,16 +61,16 @@ var S = (() => {
|
|
|
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
|
-
|
|
68
|
+
S.then((e) => {
|
|
69
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,88 +78,90 @@ var pe = (e, t) => C.then((n) => n.proxyFetch(e, t)), me = "https://fkn.app", he
|
|
|
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 (
|
|
93
|
-
let r = (e) => {
|
|
94
|
-
clearTimeout(
|
|
95
|
-
},
|
|
96
|
-
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
|
+
let r, i = (e) => {
|
|
94
|
+
clearTimeout(r), s.disconnect(), document.removeEventListener("readystatechange", c), e();
|
|
95
|
+
}, a = () => i(async () => {
|
|
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
|
-
}), a = new MutationObserver(() => {
|
|
99
|
-
T() && r(t);
|
|
100
98
|
}), o = () => {
|
|
101
|
-
|
|
102
|
-
}, s =
|
|
103
|
-
|
|
104
|
-
|
|
99
|
+
clearTimeout(r), r = setTimeout(() => w() ? i(t) : a(), ye);
|
|
100
|
+
}, s = new MutationObserver(() => {
|
|
101
|
+
w() && i(t);
|
|
102
|
+
}), c = () => {
|
|
103
|
+
document.readyState === "complete" && !w() && o();
|
|
104
|
+
};
|
|
105
|
+
if (r = setTimeout(a, e), s.observe(document.documentElement, {
|
|
105
106
|
attributes: !0,
|
|
106
107
|
attributeFilter: ["data-fkn-extension"]
|
|
107
|
-
}), document.addEventListener("readystatechange",
|
|
108
|
-
|
|
109
|
-
|
|
108
|
+
}), document.addEventListener("readystatechange", c), document.readyState === "complete") return o();
|
|
109
|
+
w() && i(t);
|
|
110
|
+
}), O, k = new Proxy({}, { get: (e, t) => async (...e) => {
|
|
111
|
+
await D(), O ??= te({}, {
|
|
110
112
|
transport: window,
|
|
111
113
|
revivableModules: i
|
|
112
114
|
});
|
|
113
|
-
let n = (await
|
|
115
|
+
let n = (await O)[t];
|
|
114
116
|
return n(...e);
|
|
115
|
-
} }),
|
|
117
|
+
} }), be = {
|
|
116
118
|
scope: "network.fetch",
|
|
117
119
|
category: "network",
|
|
118
120
|
severity: 0,
|
|
119
121
|
title: "Fetch data from other sites",
|
|
120
122
|
description: "Lets the app download public data from other websites directly, past the usual cross-origin limits."
|
|
121
|
-
},
|
|
123
|
+
}, xe = {
|
|
122
124
|
scope: "network.fetchCredentialed",
|
|
123
125
|
category: "network",
|
|
124
126
|
severity: 3,
|
|
125
127
|
unsafe: !0,
|
|
126
|
-
title: "Fetch from other sites
|
|
128
|
+
title: "Fetch from other sites, signed in as you",
|
|
127
129
|
description: "Lets the app fetch other sites using your logged-in session cookies, so it can read data only you should see."
|
|
128
|
-
},
|
|
130
|
+
}, Se = ["origin", "referer"], Ce = (e) => {
|
|
129
131
|
if (!e?.headers) return;
|
|
130
|
-
let t = new Headers(e.headers), n =
|
|
132
|
+
let t = new Headers(e.headers), n = Se.map((e) => {
|
|
131
133
|
let n = t.get(e);
|
|
132
134
|
return n === null ? void 0 : [e, n];
|
|
133
135
|
}).filter((e) => e !== void 0);
|
|
134
136
|
return n.length ? n : void 0;
|
|
135
|
-
},
|
|
137
|
+
}, we = async (e, t) => {
|
|
136
138
|
let n = new Request(e, t), r = n.body ? await n.arrayBuffer() : null;
|
|
137
|
-
return
|
|
139
|
+
return k.proxyFetch({
|
|
138
140
|
url: n.url,
|
|
139
141
|
method: n.method,
|
|
140
142
|
headers: [...n.headers],
|
|
141
143
|
body: r,
|
|
142
144
|
credentials: t?.credentials === "include" ? "include" : "omit",
|
|
143
145
|
redirect: n.redirect,
|
|
144
|
-
unsafeHeaders:
|
|
146
|
+
unsafeHeaders: Ce(t),
|
|
145
147
|
reason: t?.reason,
|
|
146
148
|
signal: t?.signal ?? void 0
|
|
147
149
|
});
|
|
148
|
-
},
|
|
150
|
+
}, Te = {
|
|
149
151
|
scope: "network.readCookie",
|
|
150
152
|
category: "network",
|
|
151
153
|
severity: 3,
|
|
152
154
|
unsafe: !0,
|
|
153
155
|
title: "Read a site’s cookie",
|
|
154
156
|
description: "Lets the app read a named cookie from another site, which can include the login token only that site should see."
|
|
155
|
-
},
|
|
157
|
+
}, Ee = { get: (e) => k.getCookie(e) }, De = {
|
|
156
158
|
scope: "network.modifyRequestHeaders",
|
|
157
159
|
category: "network",
|
|
158
160
|
severity: 2,
|
|
159
161
|
unsafe: !0,
|
|
160
162
|
title: "Rewrite request headers to other sites",
|
|
161
163
|
description: "Lets the app set or remove headers (like Origin and Referer) on this page’s own requests to the listed sites."
|
|
162
|
-
},
|
|
164
|
+
}, Oe = (e) => k.setRequestHeaderRule(e), ke = (e) => k.removeRequestHeaderRule({ ruleId: e });
|
|
163
165
|
(() => {
|
|
164
166
|
let e = {}, t = [...c.selectorModules, ...r.selectorModules];
|
|
165
167
|
for (let n of t) n.render && !(n.type in e) && (e[n.type] = n.render);
|
|
@@ -167,7 +169,7 @@ var T = () => document.documentElement.dataset[_e] === "true", E = null, D = (e)
|
|
|
167
169
|
})();
|
|
168
170
|
//#endregion
|
|
169
171
|
//#region node_modules/@mfkn/web-extension/lib/lib/frame.js
|
|
170
|
-
var
|
|
172
|
+
var A = "FKN_WEB_EXTENSION_ATTACH_FRAME_EVENT_KEY", j = (e) => {
|
|
171
173
|
if (!e || e === "about:blank") return !1;
|
|
172
174
|
let t;
|
|
173
175
|
try {
|
|
@@ -179,28 +181,28 @@ var j = "FKN_WEB_EXTENSION_ATTACH_FRAME_EVENT_KEY", M = (e) => {
|
|
|
179
181
|
if (t.protocol === "about:") return !1;
|
|
180
182
|
let n = t.hostname;
|
|
181
183
|
return n === "fkn.app" || n.endsWith(".fkn.app");
|
|
182
|
-
},
|
|
183
|
-
if (
|
|
184
|
-
},
|
|
184
|
+
}, M = (e) => {
|
|
185
|
+
if (j(e)) throw Error("attachFrame: refusing to target the extension's own pages or fkn.app");
|
|
186
|
+
}, Ae = {
|
|
185
187
|
scope: "embed.iframe",
|
|
186
188
|
category: "embed",
|
|
187
189
|
severity: 0,
|
|
188
190
|
title: "Load another website inside this app",
|
|
189
191
|
description: "Lets the app embed external pages directly inside its own view."
|
|
190
|
-
},
|
|
192
|
+
}, je = {
|
|
191
193
|
scope: "embed.open",
|
|
192
194
|
category: "embed",
|
|
193
195
|
severity: 0,
|
|
194
196
|
title: "Open a website inside this app",
|
|
195
197
|
description: "Lets the app navigate to another site without leaving its window."
|
|
196
|
-
},
|
|
198
|
+
}, Me = async ({ iframe: e, domains: t = [] }) => {
|
|
197
199
|
let n = crypto.randomUUID();
|
|
198
|
-
if (
|
|
199
|
-
e.dispatchEvent(new CustomEvent(
|
|
200
|
-
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({
|
|
201
203
|
marker: n,
|
|
202
204
|
domains: t
|
|
203
|
-
}), o = s(r, i), c = (e, t = {}) => (
|
|
205
|
+
}), o = s(r, i), c = (e, t = {}) => (M(e), a({
|
|
204
206
|
url: e,
|
|
205
207
|
...t
|
|
206
208
|
})), l = () => e.src;
|
|
@@ -209,28 +211,49 @@ var j = "FKN_WEB_EXTENSION_ATTACH_FRAME_EVENT_KEY", M = (e) => {
|
|
|
209
211
|
goto: c,
|
|
210
212
|
url: l
|
|
211
213
|
};
|
|
212
|
-
},
|
|
214
|
+
}, Ne = { request: (e) => k.requestPermissions(e.map((e) => ({
|
|
213
215
|
key: e.key,
|
|
214
216
|
scope: e.scope ?? "",
|
|
215
217
|
reason: e.reason
|
|
216
|
-
}))) },
|
|
218
|
+
}))) }, N = async (e) => {
|
|
217
219
|
if (typeof window > "u") return !1;
|
|
218
|
-
if (
|
|
219
|
-
let t = await
|
|
220
|
+
if (w()) return !0;
|
|
221
|
+
let t = await S, n = null, r = new Promise((e) => {
|
|
220
222
|
n = () => {
|
|
221
|
-
|
|
222
|
-
},
|
|
223
|
+
w() && e(!0);
|
|
224
|
+
}, C.addEventListener("statuschange", n);
|
|
223
225
|
}), i = t.showInstallPrompt(e).then(() => !1), a = await Promise.race([r, i]);
|
|
224
|
-
return n &&
|
|
225
|
-
},
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
}),
|
|
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));
|
|
229
231
|
//#endregion
|
|
230
|
-
//#region src/lib/
|
|
231
|
-
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();
|
|
232
255
|
new TextDecoder();
|
|
233
|
-
var
|
|
256
|
+
var L = (e) => f.isValid(e), R = (e) => p.isValid(e), Re = (e) => L(e) ? 4 : R(e) ? 6 : 0, ze = (...e) => {
|
|
234
257
|
if (typeof e[0] == "string") throw Error("FKN WebVPN does not support IPC connections");
|
|
235
258
|
let t = typeof e.at(-1) == "function" ? e.at(-1) : void 0;
|
|
236
259
|
return e[0] && typeof e[0] == "object" ? {
|
|
@@ -241,7 +264,7 @@ var I = (e) => f.isValid(e), L = (e) => p.isValid(e), Ne = (e) => I(e) ? 4 : L(e
|
|
|
241
264
|
host: typeof e[1] == "string" ? e[1] : void 0,
|
|
242
265
|
callback: t
|
|
243
266
|
};
|
|
244
|
-
},
|
|
267
|
+
}, Be = (...e) => {
|
|
245
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;
|
|
246
269
|
return typeof e[0] == "object" ? {
|
|
247
270
|
...e[0],
|
|
@@ -253,7 +276,7 @@ var I = (e) => f.isValid(e), L = (e) => p.isValid(e), Ne = (e) => I(e) ? 4 : L(e
|
|
|
253
276
|
port: n,
|
|
254
277
|
callback: t
|
|
255
278
|
};
|
|
256
|
-
},
|
|
279
|
+
}, Ve = (...e) => {
|
|
257
280
|
let t = typeof e.at(-1) == "function" ? e.at(-1) : void 0, n = e[0];
|
|
258
281
|
if (typeof e[2] == "number") return {
|
|
259
282
|
message: n,
|
|
@@ -278,18 +301,18 @@ var I = (e) => f.isValid(e), L = (e) => p.isValid(e), Ne = (e) => I(e) ? 4 : L(e
|
|
|
278
301
|
new TextEncoder(), new TextDecoder();
|
|
279
302
|
//#endregion
|
|
280
303
|
//#region src/lib/webvpn/net.ts
|
|
281
|
-
var
|
|
282
|
-
Server: () =>
|
|
283
|
-
Socket: () =>
|
|
284
|
-
_default: () =>
|
|
285
|
-
connect: () =>
|
|
286
|
-
createConnection: () =>
|
|
287
|
-
createServer: () =>
|
|
288
|
-
default: () =>
|
|
289
|
-
isIP: () =>
|
|
290
|
-
isIPv4: () =>
|
|
291
|
-
isIPv6: () =>
|
|
292
|
-
}),
|
|
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 {
|
|
293
316
|
_localAddress;
|
|
294
317
|
_remoteAddress;
|
|
295
318
|
_webVPNTcpSocketPromise;
|
|
@@ -349,7 +372,7 @@ var Le = /* @__PURE__ */ n({
|
|
|
349
372
|
}).catch(n);
|
|
350
373
|
}
|
|
351
374
|
connect(...e) {
|
|
352
|
-
let t =
|
|
375
|
+
let t = ze(...e), n = this.__webvpn_tcp_socket_init__(S.then((e) => e.webVpnTcpSocket({
|
|
353
376
|
remoteAddress: t.host ?? "localhost",
|
|
354
377
|
remotePort: t.port
|
|
355
378
|
})));
|
|
@@ -476,7 +499,7 @@ var Le = /* @__PURE__ */ n({
|
|
|
476
499
|
return this._remoteAddress.family;
|
|
477
500
|
}
|
|
478
501
|
timeout;
|
|
479
|
-
},
|
|
502
|
+
}, B = class extends d {
|
|
480
503
|
_localAddress;
|
|
481
504
|
_webVPNTcpSocketListenerPromise;
|
|
482
505
|
constructor(e, t) {
|
|
@@ -494,10 +517,10 @@ var Le = /* @__PURE__ */ n({
|
|
|
494
517
|
}), this._webVPNTcpSocketListenerPromise;
|
|
495
518
|
}
|
|
496
519
|
listen(...e) {
|
|
497
|
-
let t =
|
|
498
|
-
let t = new
|
|
520
|
+
let t = ze(...e), n = (e) => {
|
|
521
|
+
let t = new z({ connection: Promise.resolve(e) });
|
|
499
522
|
this.emit("connection", t);
|
|
500
|
-
}, r = (e) =>
|
|
523
|
+
}, r = (e) => S.then((r) => r.webVpnTcpSocketListener({
|
|
501
524
|
localAddress: e,
|
|
502
525
|
localPort: t.port,
|
|
503
526
|
onConnection: n
|
|
@@ -531,23 +554,23 @@ var Le = /* @__PURE__ */ n({
|
|
|
531
554
|
connections;
|
|
532
555
|
listening;
|
|
533
556
|
async [Symbol.asyncDispose]() {}
|
|
534
|
-
},
|
|
557
|
+
}, Ue = (e, t) => new z().connect(e, t), We = (e, t) => new z().connect(e, t), Ge = (e, t) => {
|
|
535
558
|
typeof e == "function" && (t = e, e = void 0);
|
|
536
|
-
let n = new
|
|
559
|
+
let n = new B(e);
|
|
537
560
|
return t && n.on("connection", t), n;
|
|
538
|
-
},
|
|
539
|
-
Socket:
|
|
540
|
-
Server:
|
|
541
|
-
connect:
|
|
542
|
-
createConnection:
|
|
543
|
-
createServer:
|
|
544
|
-
isIP:
|
|
545
|
-
isIPv4:
|
|
546
|
-
isIPv6:
|
|
547
|
-
},
|
|
548
|
-
Socket: () =>
|
|
549
|
-
createSocket: () =>
|
|
550
|
-
}),
|
|
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 {
|
|
551
574
|
_type;
|
|
552
575
|
_localAddress;
|
|
553
576
|
_remoteAddress;
|
|
@@ -576,7 +599,7 @@ var Le = /* @__PURE__ */ n({
|
|
|
576
599
|
}
|
|
577
600
|
addMembership(e, t) {
|
|
578
601
|
if (f.isValid(e)) {
|
|
579
|
-
let n =
|
|
602
|
+
let n = V(e), r = t && f.isValid(t) ? V(t) : new Uint8Array([
|
|
580
603
|
0,
|
|
581
604
|
0,
|
|
582
605
|
0,
|
|
@@ -588,7 +611,7 @@ var Le = /* @__PURE__ */ n({
|
|
|
588
611
|
interface: r
|
|
589
612
|
});
|
|
590
613
|
} else if (p.isValid(e)) {
|
|
591
|
-
let t =
|
|
614
|
+
let t = Ye(e);
|
|
592
615
|
this._setUdpOption({
|
|
593
616
|
type: 7,
|
|
594
617
|
group: t,
|
|
@@ -601,8 +624,8 @@ var Le = /* @__PURE__ */ n({
|
|
|
601
624
|
return this._localAddress;
|
|
602
625
|
}
|
|
603
626
|
bind(...e) {
|
|
604
|
-
let t =
|
|
605
|
-
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({
|
|
606
629
|
type: this._type,
|
|
607
630
|
address: t.address ?? n,
|
|
608
631
|
port: t.port
|
|
@@ -663,7 +686,7 @@ var Le = /* @__PURE__ */ n({
|
|
|
663
686
|
}
|
|
664
687
|
dropMembership(e, t) {
|
|
665
688
|
if (f.isValid(e)) {
|
|
666
|
-
let n =
|
|
689
|
+
let n = V(e), r = t && f.isValid(t) ? V(t) : new Uint8Array([
|
|
667
690
|
0,
|
|
668
691
|
0,
|
|
669
692
|
0,
|
|
@@ -675,7 +698,7 @@ var Le = /* @__PURE__ */ n({
|
|
|
675
698
|
interface: r
|
|
676
699
|
});
|
|
677
700
|
} else if (p.isValid(e)) {
|
|
678
|
-
let t =
|
|
701
|
+
let t = Ye(e);
|
|
679
702
|
this._setUdpOption({
|
|
680
703
|
type: 8,
|
|
681
704
|
group: t,
|
|
@@ -708,11 +731,11 @@ var Le = /* @__PURE__ */ n({
|
|
|
708
731
|
}
|
|
709
732
|
send(...e) {
|
|
710
733
|
this._webVPNUdpSocketPromise || this.bind();
|
|
711
|
-
let t =
|
|
734
|
+
let t = Ve(...e), n = this._type === "udp6" ? "::1" : "127.0.0.1";
|
|
712
735
|
if (!this._webVPNUdpSocketPromise) throw Error("Socket not bound");
|
|
713
736
|
this._webVPNUdpSocketPromise.then((e) => {
|
|
714
737
|
if (!e) throw Error("Socket not bound");
|
|
715
|
-
let r = typeof t.message == "string" ?
|
|
738
|
+
let r = typeof t.message == "string" ? Le.encode(t.message) : t.message;
|
|
716
739
|
e.send({
|
|
717
740
|
...t,
|
|
718
741
|
address: t.address ?? n,
|
|
@@ -770,33 +793,33 @@ var Le = /* @__PURE__ */ n({
|
|
|
770
793
|
this.close(e);
|
|
771
794
|
});
|
|
772
795
|
}
|
|
773
|
-
},
|
|
796
|
+
}, V = (e) => {
|
|
774
797
|
let t = e.split(".").map((e) => parseInt(e, 10));
|
|
775
798
|
if (t.length !== 4 || t.some((e) => Number.isNaN(e) || e < 0 || e > 255)) throw Error(`Invalid IPv4 address: ${e}`);
|
|
776
799
|
return new Uint8Array(t);
|
|
777
|
-
},
|
|
800
|
+
}, Ye = (e) => {
|
|
778
801
|
let t = new p(e).getBitsBase16(0, 128).match(/.{2}/g);
|
|
779
802
|
if (!t || t.length !== 16) throw Error(`Invalid IPv6 address: ${e}`);
|
|
780
803
|
return new Uint8Array(t.map((e) => parseInt(e, 16)));
|
|
781
|
-
},
|
|
782
|
-
let n = new
|
|
804
|
+
}, Xe = (e, t) => {
|
|
805
|
+
let n = new Je(typeof e == "string" ? { type: e } : e);
|
|
783
806
|
return t && n.on("message", t), n;
|
|
784
|
-
},
|
|
807
|
+
}, Ze = /* @__PURE__ */ n({
|
|
785
808
|
Agent: () => Q,
|
|
786
809
|
ClientRequest: () => X,
|
|
787
|
-
HTTPParser: () =>
|
|
810
|
+
HTTPParser: () => K,
|
|
788
811
|
IncomingMessage: () => q,
|
|
789
|
-
METHODS: () =>
|
|
790
|
-
STATUS_CODES: () =>
|
|
812
|
+
METHODS: () => $e,
|
|
813
|
+
STATUS_CODES: () => H,
|
|
791
814
|
Server: () => Z,
|
|
792
815
|
ServerResponse: () => Y,
|
|
793
|
-
_default: () =>
|
|
794
|
-
createServer: () =>
|
|
795
|
-
default: () =>
|
|
796
|
-
get: () =>
|
|
797
|
-
globalAgent: () =>
|
|
816
|
+
_default: () => ut,
|
|
817
|
+
createServer: () => lt,
|
|
818
|
+
default: () => ut,
|
|
819
|
+
get: () => ct,
|
|
820
|
+
globalAgent: () => st,
|
|
798
821
|
request: () => $
|
|
799
|
-
}),
|
|
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 = {
|
|
800
823
|
100: "Continue",
|
|
801
824
|
101: "Switching Protocols",
|
|
802
825
|
102: "Processing",
|
|
@@ -860,7 +883,7 @@ var Le = /* @__PURE__ */ n({
|
|
|
860
883
|
509: "Bandwidth Limit Exceeded",
|
|
861
884
|
510: "Not Extended",
|
|
862
885
|
511: "Network Authentication Required"
|
|
863
|
-
},
|
|
886
|
+
}, et = new Set([
|
|
864
887
|
"content-type",
|
|
865
888
|
"content-length",
|
|
866
889
|
"user-agent",
|
|
@@ -879,18 +902,18 @@ var Le = /* @__PURE__ */ n({
|
|
|
879
902
|
"server",
|
|
880
903
|
"age",
|
|
881
904
|
"expires"
|
|
882
|
-
]),
|
|
905
|
+
]), U = 13, W = 10, tt = /^[\^_`a-zA-Z\-0-9!#$%&'*+.|~]+$/, G = (e, t) => (e.code = t, e), nt = (e, t) => {
|
|
883
906
|
if (e.length === 0) return t;
|
|
884
907
|
if (t.length === 0) return e;
|
|
885
908
|
let n = new Uint8Array(e.length + t.length);
|
|
886
909
|
return n.set(e, 0), n.set(t, e.length), n;
|
|
887
|
-
},
|
|
888
|
-
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;
|
|
889
912
|
return -1;
|
|
890
|
-
},
|
|
891
|
-
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;
|
|
892
915
|
return -1;
|
|
893
|
-
},
|
|
916
|
+
}, K = class {
|
|
894
917
|
buf = new Uint8Array();
|
|
895
918
|
state = "HEAD";
|
|
896
919
|
framing = "none";
|
|
@@ -901,10 +924,10 @@ var Le = /* @__PURE__ */ n({
|
|
|
901
924
|
this.mode = e, this.handlers = t;
|
|
902
925
|
}
|
|
903
926
|
execute(e) {
|
|
904
|
-
this.buf =
|
|
927
|
+
this.buf = nt(this.buf, e);
|
|
905
928
|
let t = !0;
|
|
906
929
|
for (; t;) if (t = !1, this.state === "HEAD") {
|
|
907
|
-
let e =
|
|
930
|
+
let e = it(this.buf);
|
|
908
931
|
if (e === -1) return;
|
|
909
932
|
let n = this.buf.subarray(0, e);
|
|
910
933
|
this.buf = this.buf.subarray(e + 4);
|
|
@@ -919,7 +942,7 @@ var Le = /* @__PURE__ */ n({
|
|
|
919
942
|
this.state = "HEAD", this.framing = "none", this.bodyRemaining = 0, this.chunkState = "size", this.skipBody = !1;
|
|
920
943
|
}
|
|
921
944
|
parseHead(e) {
|
|
922
|
-
let t =
|
|
945
|
+
let t = Qe.decode(e).split("\r\n"), n = t.shift() ?? "", r = [];
|
|
923
946
|
for (let e of t) (e.startsWith(" ") || e.startsWith(" ")) && r.length > 0 ? r[r.length - 1] += " " + e.trim() : r.push(e);
|
|
924
947
|
let i = [], a = {};
|
|
925
948
|
for (let e of r) {
|
|
@@ -957,7 +980,7 @@ var Le = /* @__PURE__ */ n({
|
|
|
957
980
|
return;
|
|
958
981
|
}
|
|
959
982
|
let i = e[r];
|
|
960
|
-
i === void 0 ? e[r] = n :
|
|
983
|
+
i === void 0 ? e[r] = n : et.has(r) || (e[r] = `${i}, ${n}`);
|
|
961
984
|
}
|
|
962
985
|
setupBody(e) {
|
|
963
986
|
if (this.skipBody) {
|
|
@@ -990,9 +1013,9 @@ var Le = /* @__PURE__ */ n({
|
|
|
990
1013
|
}
|
|
991
1014
|
consumeChunked() {
|
|
992
1015
|
for (;;) if (this.chunkState === "size") {
|
|
993
|
-
let e =
|
|
1016
|
+
let e = rt(this.buf, 0);
|
|
994
1017
|
if (e === -1) return !1;
|
|
995
|
-
let t =
|
|
1018
|
+
let t = Qe.decode(this.buf.subarray(0, e)), n = parseInt(t.split(";")[0].trim(), 16);
|
|
996
1019
|
if (this.buf = this.buf.subarray(e + 2), Number.isNaN(n)) return !0;
|
|
997
1020
|
n === 0 ? this.chunkState = "trailer" : (this.bodyRemaining = n, this.chunkState = "data");
|
|
998
1021
|
} else if (this.chunkState === "data") {
|
|
@@ -1003,13 +1026,13 @@ var Le = /* @__PURE__ */ n({
|
|
|
1003
1026
|
if (this.buf.length < 2) return !1;
|
|
1004
1027
|
this.buf = this.buf.subarray(2), this.chunkState = "size";
|
|
1005
1028
|
} else {
|
|
1006
|
-
let e =
|
|
1029
|
+
let e = rt(this.buf, 0);
|
|
1007
1030
|
if (e === -1) return !1;
|
|
1008
1031
|
let t = e === 0;
|
|
1009
1032
|
if (this.buf = this.buf.subarray(e + 2), t) return !0;
|
|
1010
1033
|
}
|
|
1011
1034
|
}
|
|
1012
|
-
},
|
|
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 {
|
|
1013
1036
|
httpVersion = "1.1";
|
|
1014
1037
|
httpVersionMajor = 1;
|
|
1015
1038
|
httpVersionMinor = 1;
|
|
@@ -1043,9 +1066,9 @@ var Le = /* @__PURE__ */ n({
|
|
|
1043
1066
|
finished = !1;
|
|
1044
1067
|
_bodyWritten = !1;
|
|
1045
1068
|
setHeader(e, t) {
|
|
1046
|
-
if (this.headersSent) throw
|
|
1047
|
-
if (typeof e != "string" || !
|
|
1048
|
-
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");
|
|
1049
1072
|
return this._headerStore.set(e.toLowerCase(), [e, Array.isArray(t) ? [...t] : t]), this;
|
|
1050
1073
|
}
|
|
1051
1074
|
getHeader(e) {
|
|
@@ -1085,7 +1108,7 @@ var Le = /* @__PURE__ */ n({
|
|
|
1085
1108
|
return this._bodyWritten = !0, super.write(e, t, n);
|
|
1086
1109
|
}
|
|
1087
1110
|
_write(e, t, n) {
|
|
1088
|
-
let r =
|
|
1111
|
+
let r = at(e), i = [];
|
|
1089
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) {
|
|
1090
1113
|
n();
|
|
1091
1114
|
return;
|
|
@@ -1103,7 +1126,7 @@ var Le = /* @__PURE__ */ n({
|
|
|
1103
1126
|
end(e, t, n) {
|
|
1104
1127
|
if (e != null && typeof e != "function" && !this._bodyWritten && !this.headersSent && !this.chunkedEncoding && !this.hasHeader("content-length")) {
|
|
1105
1128
|
let n = typeof t == "string" ? t : void 0;
|
|
1106
|
-
this.setHeader("Content-Length",
|
|
1129
|
+
this.setHeader("Content-Length", at(e, n).length);
|
|
1107
1130
|
}
|
|
1108
1131
|
return super.end(e, t, n);
|
|
1109
1132
|
}
|
|
@@ -1125,7 +1148,7 @@ var Le = /* @__PURE__ */ n({
|
|
|
1125
1148
|
return !(e >= 100 && e < 200 || e === 204 || e === 304);
|
|
1126
1149
|
}
|
|
1127
1150
|
writeHead(e, t, n) {
|
|
1128
|
-
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");
|
|
1129
1152
|
this._writeHeadCalled = !0, this.statusCode = e;
|
|
1130
1153
|
let r = n;
|
|
1131
1154
|
if (typeof t == "string" ? this.statusMessage = t : t != null && (r = t), Array.isArray(r)) {
|
|
@@ -1143,7 +1166,7 @@ var Le = /* @__PURE__ */ n({
|
|
|
1143
1166
|
}
|
|
1144
1167
|
}
|
|
1145
1168
|
_implicitHeader() {
|
|
1146
|
-
let e = this.statusMessage ??
|
|
1169
|
+
let e = this.statusMessage ?? H[this.statusCode] ?? "unknown";
|
|
1147
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}`);
|
|
1148
1171
|
}
|
|
1149
1172
|
writeContinue() {
|
|
@@ -1152,7 +1175,7 @@ var Le = /* @__PURE__ */ n({
|
|
|
1152
1175
|
setTimeout(e, t) {
|
|
1153
1176
|
return this.socket?.setTimeout(e, t), this;
|
|
1154
1177
|
}
|
|
1155
|
-
},
|
|
1178
|
+
}, ot = (...e) => {
|
|
1156
1179
|
let t = {}, n = {}, r, i = [...e], a = i.shift();
|
|
1157
1180
|
if (typeof a == "string" || a instanceof URL) {
|
|
1158
1181
|
let e = typeof a == "string" ? new URL(a) : a;
|
|
@@ -1196,7 +1219,7 @@ var Le = /* @__PURE__ */ n({
|
|
|
1196
1219
|
let e = this.protocol === "https:" && r === 443 || this.protocol !== "https:" && r === 80;
|
|
1197
1220
|
this.setHeader("Host", e ? n : `${n}:${r}`);
|
|
1198
1221
|
}
|
|
1199
|
-
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) => {
|
|
1200
1223
|
this._aborted || this.emit("error", e);
|
|
1201
1224
|
}), this._attachResponseParser(), this.socket.connect({
|
|
1202
1225
|
host: n,
|
|
@@ -1212,7 +1235,7 @@ var Le = /* @__PURE__ */ n({
|
|
|
1212
1235
|
this._headBlock = this._storeHeader(`${this.method} ${this.path} HTTP/1.1`);
|
|
1213
1236
|
}
|
|
1214
1237
|
_attachResponseParser() {
|
|
1215
|
-
let e = new q(this.socket), t = new
|
|
1238
|
+
let e = new q(this.socket), t = new K("response", {
|
|
1216
1239
|
onHeaders: (n) => {
|
|
1217
1240
|
e._applyHead(n), this.method === "HEAD" && (t.skipBody = !0), this.res = e, this.emit("response", e);
|
|
1218
1241
|
},
|
|
@@ -1256,13 +1279,13 @@ var Le = /* @__PURE__ */ n({
|
|
|
1256
1279
|
setSocketKeepAlive(e, t) {
|
|
1257
1280
|
this.socket.setKeepAlive(e, t);
|
|
1258
1281
|
}
|
|
1259
|
-
}, Z = new Proxy(class extends
|
|
1282
|
+
}, Z = new Proxy(class extends B {
|
|
1260
1283
|
constructor(e, t) {
|
|
1261
1284
|
let n = {}, r = t;
|
|
1262
1285
|
typeof e == "function" ? r = e : e && (n = e), super(n), r && this.on("request", r), this.on("connection", (e) => this._handleConnection(e));
|
|
1263
1286
|
}
|
|
1264
1287
|
_handleConnection(e) {
|
|
1265
|
-
let t = null, n = new
|
|
1288
|
+
let t = null, n = new K("request", {
|
|
1266
1289
|
onHeaders: (r) => {
|
|
1267
1290
|
t = new q(e), t._applyHead(r), r.method === "HEAD" && (n.skipBody = !0);
|
|
1268
1291
|
let i = new Y(t), a = String(r.headers.connection ?? "").toLowerCase();
|
|
@@ -1293,25 +1316,25 @@ var Le = /* @__PURE__ */ n({
|
|
|
1293
1316
|
return `${e.host ?? "localhost"}:${e.port ?? ""}:${e.localAddress ?? ""}`;
|
|
1294
1317
|
}
|
|
1295
1318
|
destroy() {}
|
|
1296
|
-
},
|
|
1297
|
-
let { options: t, callback: n } =
|
|
1319
|
+
}, st = new Q(), $ = (...e) => {
|
|
1320
|
+
let { options: t, callback: n } = ot(...e);
|
|
1298
1321
|
return new X(t, n);
|
|
1299
|
-
},
|
|
1322
|
+
}, ct = (...e) => {
|
|
1300
1323
|
let t = $(...e);
|
|
1301
1324
|
return t.end(), t;
|
|
1302
|
-
},
|
|
1303
|
-
METHODS:
|
|
1304
|
-
STATUS_CODES:
|
|
1325
|
+
}, lt = (e, t) => new Z(e, t), ut = {
|
|
1326
|
+
METHODS: $e,
|
|
1327
|
+
STATUS_CODES: H,
|
|
1305
1328
|
Agent: Q,
|
|
1306
|
-
globalAgent:
|
|
1329
|
+
globalAgent: st,
|
|
1307
1330
|
Server: Z,
|
|
1308
1331
|
ServerResponse: Y,
|
|
1309
1332
|
IncomingMessage: q,
|
|
1310
1333
|
ClientRequest: X,
|
|
1311
1334
|
OutgoingMessage: J,
|
|
1312
|
-
createServer:
|
|
1335
|
+
createServer: lt,
|
|
1313
1336
|
request: $,
|
|
1314
|
-
get:
|
|
1337
|
+
get: ct
|
|
1315
1338
|
};
|
|
1316
1339
|
//#endregion
|
|
1317
|
-
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 };
|