@fkn/lib 0.3.7 → 0.3.9

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/index.js CHANGED
@@ -1,38 +1,236 @@
1
- import { a as e, c as t, h as n, i as r, l as i, o as a, r as o, s, t as c, u as l } from "./locator-DpMUq6q3.js";
2
- import { createTypedEventTarget as u, expose as d } from "osra";
3
- import { Stream as f } from "stream";
4
- import { EventEmitter as p } from "events";
5
- import { Address4 as m, Address6 as h } from "ip-address";
6
- import { Buffer as g } from "buffer";
7
- //#region src/lib/dom.ts
8
- var _ = "https://fkn.app", v = globalThis?.document.querySelector(`iframe[src="${_}/api"]`), y = globalThis.document?.createElement("iframe");
9
- !v && y && (y.src = `${_}/api`, y.style.display = "none", document.body.appendChild(y));
10
- var b = v || y, x = b.contentWindow;
11
- if (!b.contentWindow) throw Error("Missing iframe content window");
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-fXEVniGP.js";
2
+ import { createTypedEventTarget as ee, expose as te, relay as ne } from "osra";
3
+ import { Stream as u } from "stream";
4
+ import { EventEmitter as d } from "events";
5
+ import { Address4 as f, Address6 as p } from "ip-address";
6
+ import { Buffer as m } from "buffer";
7
+ //#region src/lib/overlay.ts
8
+ var re = 32, ie = typeof CSS < "u" && CSS.supports("clip-path", "path('M0 0H1V1H0Z')"), ae = (e) => {
9
+ let t = e.style;
10
+ 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`, se = (e, { modal: t, rects: n }) => {
12
+ if (!ie) {
13
+ let r = t || n.length > 0;
14
+ e.style.setProperty("pointer-events", r ? "auto" : "none", "important"), e.style.setProperty("visibility", r ? "visible" : "hidden", "important");
15
+ return;
16
+ }
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
+ e.style.setProperty("clip-path", i, "important");
19
+ }, ce = (e) => {
20
+ if (typeof e != "object" || !e) return null;
21
+ let { x: t, y: n, width: r, height: i } = e;
22
+ if (![
23
+ t,
24
+ n,
25
+ r,
26
+ i
27
+ ].every((e) => typeof e == "number" && Number.isFinite(e))) return null;
28
+ let a = window.innerWidth, o = window.innerHeight, s = Math.max(0, Math.min(Math.round(t), a)), c = Math.max(0, Math.min(Math.round(n), o)), l = Math.max(s, Math.min(Math.round(t + r), a)), ee = Math.max(c, Math.min(Math.round(n + i), o));
29
+ return {
30
+ x: s,
31
+ y: c,
32
+ width: l - s,
33
+ height: ee - c
34
+ };
35
+ }, le = (e) => {
36
+ if (typeof e != "object" || !e) return null;
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
+ return {
39
+ modal: t.modal === !0,
40
+ rects: n
41
+ };
42
+ }, h = null, ue = () => h !== null, de = (e) => {
43
+ ae(e), se(e, {
44
+ modal: !1,
45
+ rects: []
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 S = (() => {
56
+ if (typeof window < "u") return x ? {
57
+ receive: window,
58
+ emit: x
59
+ } : void 0;
60
+ if (typeof self < "u") return {
61
+ receive: self,
62
+ emit: self
63
+ };
64
+ })(), C = S ? te({}, {
65
+ key: "fkn-api",
66
+ transport: S
67
+ }) : new Promise(() => {});
68
+ C.then((e) => {
69
+ ue() && e.setOverlayHost(fe);
70
+ }, () => {});
12
71
  //#endregion
13
- //#region src/lib/api.ts
14
- var S = (e) => new Promise((t, n) => {
15
- let r = new AbortController(), i = setTimeout(() => {
16
- r.abort(), n(/* @__PURE__ */ Error("Timeout waiting for api to be exposed"));
17
- }, e);
18
- d({}, {
72
+ //#region src/lib/proxy.ts
73
+ var pe = (e, t) => C.then((n) => n.proxyFetch(e, t)), me = "https://fkn.app", he = (e, t) => {
74
+ if (typeof window > "u") throw Error("FKN @fkn/lib: relayWorker must be called from the main thread");
75
+ if (!b?.contentWindow) throw Error("FKN @fkn/lib: relayWorker called before the FKN iframe was injected");
76
+ ne({
77
+ receive: window,
78
+ emit: b.contentWindow
79
+ }, e, {
19
80
  key: "fkn-api",
20
- unregisterSignal: r.signal,
21
- transport: {
22
- receive: window,
23
- emit: x
24
- }
25
- }).then((e) => {
26
- clearTimeout(i), t(e);
27
- }).catch((e) => {
28
- clearTimeout(i), n(e);
81
+ originA: t?.originA ?? me,
82
+ originB: t?.originB ?? "*",
83
+ unregisterSignal: t?.unregisterSignal
84
+ });
85
+ }, ge = "FKN_WEB_EXTENSION_MAIN_WORLD_CONTENT_SCRIPT_ENABLED_EVENT_KEY", _e = "fknExtension", w = ee();
86
+ typeof document < "u" && document.addEventListener(ge, (e) => {
87
+ w.dispatchEvent(new CustomEvent("statuschange", { detail: { enabled: e.detail.enabled } }));
88
+ });
89
+ var T = () => document.documentElement.dataset[_e] === "true", E = null, D = (e) => {
90
+ E = e;
91
+ }, O = (e = 1e3) => new Promise((t, n) => {
92
+ if (T()) return t();
93
+ let r = (e) => {
94
+ clearTimeout(s), a.disconnect(), document.removeEventListener("readystatechange", o), e();
95
+ }, i = () => r(async () => {
96
+ if (E && (await E().catch(() => {}), T())) return t();
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
+ }), o = () => {
101
+ document.readyState === "complete" && !T() && i();
102
+ }, s = setTimeout(i, e);
103
+ if (document.readyState === "complete") return i();
104
+ a.observe(document.documentElement, {
105
+ attributes: !0,
106
+ attributeFilter: ["data-fkn-extension"]
107
+ }), document.addEventListener("readystatechange", o), T() && r(t);
108
+ }), k, A = new Proxy({}, { get: (e, t) => async (...e) => {
109
+ await O(), k ??= te({}, {
110
+ transport: window,
111
+ revivableModules: i
112
+ });
113
+ let n = (await k)[t];
114
+ return n(...e);
115
+ } }), ve = {
116
+ scope: "network.fetch",
117
+ category: "network",
118
+ severity: 0,
119
+ title: "Fetch data from other sites",
120
+ description: "Lets the app download public data from other websites directly, past the usual cross-origin limits."
121
+ }, ye = {
122
+ scope: "network.fetchCredentialed",
123
+ category: "network",
124
+ severity: 3,
125
+ unsafe: !0,
126
+ title: "Fetch from other sites — signed in as you",
127
+ description: "Lets the app fetch other sites using your logged-in session cookies, so it can read data only you should see."
128
+ }, be = ["origin", "referer"], xe = (e) => {
129
+ if (!e?.headers) return;
130
+ let t = new Headers(e.headers), n = be.map((e) => {
131
+ let n = t.get(e);
132
+ return n === null ? void 0 : [e, n];
133
+ }).filter((e) => e !== void 0);
134
+ return n.length ? n : void 0;
135
+ }, Se = async (e, t) => {
136
+ let n = new Request(e, t), r = n.body ? await n.arrayBuffer() : null;
137
+ return A.proxyFetch({
138
+ url: n.url,
139
+ method: n.method,
140
+ headers: [...n.headers],
141
+ body: r,
142
+ credentials: t?.credentials === "include" ? "include" : "omit",
143
+ redirect: n.redirect,
144
+ unsafeHeaders: xe(t),
145
+ reason: t?.reason,
146
+ signal: t?.signal ?? void 0
29
147
  });
30
- }), C = (e = 50) => S(e).then((e) => e).catch((t) => {
31
- if (t.message === "Timeout waiting for api to be exposed") return C(Math.min(e * 2, 500));
32
- throw t;
33
- }), w = C(), T = (e, t) => w.then((n) => n.proxyFetch(e, t)), E = new TextEncoder();
148
+ }, Ce = {
149
+ scope: "network.readCookie",
150
+ category: "network",
151
+ severity: 3,
152
+ unsafe: !0,
153
+ title: "Read a site’s cookie",
154
+ description: "Lets the app read a named cookie from another site, which can include the login token only that site should see."
155
+ }, we = { get: (e) => A.getCookie(e) }, Te = {
156
+ scope: "network.modifyRequestHeaders",
157
+ category: "network",
158
+ severity: 2,
159
+ unsafe: !0,
160
+ title: "Rewrite request headers to other sites",
161
+ description: "Lets the app set or remove headers (like Origin and Referer) on this page’s own requests to the listed sites."
162
+ }, Ee = (e) => A.setRequestHeaderRule(e), De = (e) => A.removeRequestHeaderRule({ ruleId: e });
163
+ (() => {
164
+ let e = {}, t = [...c.selectorModules, ...r.selectorModules];
165
+ for (let n of t) n.render && !(n.type in e) && (e[n.type] = n.render);
166
+ return e;
167
+ })();
168
+ //#endregion
169
+ //#region node_modules/@mfkn/web-extension/lib/lib/frame.js
170
+ var j = "FKN_WEB_EXTENSION_ATTACH_FRAME_EVENT_KEY", M = (e) => {
171
+ if (!e || e === "about:blank") return !1;
172
+ let t;
173
+ try {
174
+ t = new URL(e, location.href);
175
+ } catch {
176
+ return !1;
177
+ }
178
+ if (t.protocol === "chrome-extension:" || t.protocol === "moz-extension:") return !0;
179
+ if (t.protocol === "about:") return !1;
180
+ let n = t.hostname;
181
+ return n === "fkn.app" || n.endsWith(".fkn.app");
182
+ }, N = (e) => {
183
+ if (M(e)) throw Error("attachFrame: refusing to target the extension's own pages or fkn.app");
184
+ }, Oe = {
185
+ scope: "embed.iframe",
186
+ category: "embed",
187
+ severity: 0,
188
+ title: "Load another website inside this app",
189
+ description: "Lets the app embed external pages directly inside its own view."
190
+ }, ke = {
191
+ scope: "embed.open",
192
+ category: "embed",
193
+ severity: 0,
194
+ title: "Open a website inside this app",
195
+ description: "Lets the app navigate to another site without leaving its window."
196
+ }, Ae = async ({ iframe: e, domains: t = [] }) => {
197
+ let n = crypto.randomUUID();
198
+ if (N(e.src), await O(), !e.isConnected) throw Error("attachFrame: the iframe must be connected to the document before attaching");
199
+ e.dispatchEvent(new CustomEvent(j, { detail: n }));
200
+ let { executeLocator: r, ensureLocatorPermission: i, goto: a } = await A.attachFrame({
201
+ marker: n,
202
+ domains: t
203
+ }), o = s(r, i), c = (e, t = {}) => (N(e), a({
204
+ url: e,
205
+ ...t
206
+ })), l = () => e.src;
207
+ return {
208
+ ...o,
209
+ goto: c,
210
+ url: l
211
+ };
212
+ }, je = { request: (e) => A.requestPermissions(e.map((e) => ({
213
+ key: e.key,
214
+ scope: e.scope ?? "",
215
+ reason: e.reason
216
+ }))) }, P = async (e) => {
217
+ if (typeof window > "u") return !1;
218
+ if (T()) return !0;
219
+ let t = await C, n = null, r = new Promise((e) => {
220
+ n = () => {
221
+ T() && e(!0);
222
+ }, w.addEventListener("statuschange", n);
223
+ }), i = t.showInstallPrompt(e).then(() => !1), a = await Promise.race([r, i]);
224
+ return n && w.removeEventListener("statuschange", n), await t.hideInstallPrompt().catch(() => {}), a;
225
+ }, F = null;
226
+ D(() => (F ||= P().then(() => void 0).finally(() => {
227
+ F = null;
228
+ }), F));
229
+ //#endregion
230
+ //#region src/lib/webvpn/utils.ts
231
+ var Me = new TextEncoder();
34
232
  new TextDecoder();
35
- var D = (e) => m.isValid(e), O = (e) => h.isValid(e), k = (e) => D(e) ? 4 : O(e) ? 6 : 0, A = (...e) => {
233
+ var I = (e) => f.isValid(e), L = (e) => p.isValid(e), Ne = (e) => I(e) ? 4 : L(e) ? 6 : 0, Pe = (...e) => {
36
234
  if (typeof e[0] == "string") throw Error("FKN WebVPN does not support IPC connections");
37
235
  let t = typeof e.at(-1) == "function" ? e.at(-1) : void 0;
38
236
  return e[0] && typeof e[0] == "object" ? {
@@ -43,7 +241,7 @@ var D = (e) => m.isValid(e), O = (e) => h.isValid(e), k = (e) => D(e) ? 4 : O(e)
43
241
  host: typeof e[1] == "string" ? e[1] : void 0,
44
242
  callback: t
45
243
  };
46
- }, j = (...e) => {
244
+ }, Fe = (...e) => {
47
245
  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;
48
246
  return typeof e[0] == "object" ? {
49
247
  ...e[0],
@@ -55,7 +253,7 @@ var D = (e) => m.isValid(e), O = (e) => h.isValid(e), k = (e) => D(e) ? 4 : O(e)
55
253
  port: n,
56
254
  callback: t
57
255
  };
58
- }, M = (...e) => {
256
+ }, Ie = (...e) => {
59
257
  let t = typeof e.at(-1) == "function" ? e.at(-1) : void 0, n = e[0];
60
258
  if (typeof e[2] == "number") return {
61
259
  message: n,
@@ -80,18 +278,18 @@ var D = (e) => m.isValid(e), O = (e) => h.isValid(e), k = (e) => D(e) ? 4 : O(e)
80
278
  new TextEncoder(), new TextDecoder();
81
279
  //#endregion
82
280
  //#region src/lib/webvpn/net.ts
83
- var N = /* @__PURE__ */ n({
84
- Server: () => F,
85
- Socket: () => P,
86
- _default: () => z,
87
- connect: () => I,
88
- createConnection: () => L,
89
- createServer: () => R,
90
- default: () => z,
91
- isIP: () => k,
92
- isIPv4: () => D,
93
- isIPv6: () => O
94
- }), P = class extends f.Duplex {
281
+ var Le = /* @__PURE__ */ n({
282
+ Server: () => z,
283
+ Socket: () => R,
284
+ _default: () => Ve,
285
+ connect: () => Re,
286
+ createConnection: () => ze,
287
+ createServer: () => Be,
288
+ default: () => Ve,
289
+ isIP: () => Ne,
290
+ isIPv4: () => I,
291
+ isIPv6: () => L
292
+ }), R = class extends u.Duplex {
95
293
  _localAddress;
96
294
  _remoteAddress;
97
295
  _webVPNTcpSocketPromise;
@@ -125,7 +323,10 @@ var N = /* @__PURE__ */ n({
125
323
  _read(e) {
126
324
  if (!this._webVPNTcpSocketPromise) throw Error("Socket not connected");
127
325
  this._webVPNTcpSocketPromise.then((e) => {
128
- if (!e) throw Error("Socket not connected");
326
+ if (!e) {
327
+ this.push(null);
328
+ return;
329
+ }
129
330
  e.reader.read().then(({ value: e, done: t }) => {
130
331
  if (t) {
131
332
  this.push(null);
@@ -148,12 +349,12 @@ var N = /* @__PURE__ */ n({
148
349
  }).catch(n);
149
350
  }
150
351
  connect(...e) {
151
- let t = A(...e), n = this.__webvpn_tcp_socket_init__(w.then((e) => e.webVpnTcpSocket({
352
+ let t = Pe(...e), n = this.__webvpn_tcp_socket_init__(C.then((e) => e.webVpnTcpSocket({
152
353
  remoteAddress: t.host ?? "localhost",
153
354
  remotePort: t.port
154
355
  })));
155
356
  return t.callback && n.then((e) => {
156
- e && t.callback();
357
+ e && t.callback.call(this);
157
358
  }), this;
158
359
  }
159
360
  _end(...e) {
@@ -211,6 +412,13 @@ var N = /* @__PURE__ */ n({
211
412
  value: e
212
413
  }), this;
213
414
  }
415
+ _typeOfService;
416
+ getTypeOfService() {
417
+ return this._typeOfService ?? 0;
418
+ }
419
+ setTypeOfService(e) {
420
+ return this._typeOfService = e, this;
421
+ }
214
422
  _setTcpOption(e) {
215
423
  if (!this._webVPNTcpSocketPromise) {
216
424
  this.emit("error", /* @__PURE__ */ Error("Cannot set socket option before connect"));
@@ -268,7 +476,7 @@ var N = /* @__PURE__ */ n({
268
476
  return this._remoteAddress.family;
269
477
  }
270
478
  timeout;
271
- }, F = class extends p {
479
+ }, z = class extends d {
272
480
  _localAddress;
273
481
  _webVPNTcpSocketListenerPromise;
274
482
  constructor(e, t) {
@@ -286,16 +494,16 @@ var N = /* @__PURE__ */ n({
286
494
  }), this._webVPNTcpSocketListenerPromise;
287
495
  }
288
496
  listen(...e) {
289
- let t = A(...e), n = this.__webvpn_tcp_socket_listener_init__(w.then((e) => e.webVpnTcpSocketListener({
290
- localAddress: t.host ?? "::",
497
+ let t = Pe(...e), n = (e) => {
498
+ let t = new R({ connection: Promise.resolve(e) });
499
+ this.emit("connection", t);
500
+ }, r = (e) => C.then((r) => r.webVpnTcpSocketListener({
501
+ localAddress: e,
291
502
  localPort: t.port,
292
- onConnection: (e) => {
293
- let t = new P({ connection: Promise.resolve(e) });
294
- this.emit("connection", t);
295
- }
296
- })));
297
- return t.callback && n.then((e) => {
298
- e && t.callback();
503
+ onConnection: n
504
+ })), i = t.host ? r(t.host) : r("::").catch(() => r("0.0.0.0")), a = this.__webvpn_tcp_socket_listener_init__(i);
505
+ return t.callback && a.then((e) => {
506
+ e && t.callback.call(this);
299
507
  }), this;
300
508
  }
301
509
  close(e) {
@@ -314,31 +522,32 @@ var N = /* @__PURE__ */ n({
314
522
  throw Error("Method not implemented.");
315
523
  }
316
524
  ref() {
317
- throw Error("Method not implemented.");
525
+ return this;
318
526
  }
319
527
  unref() {
320
- throw Error("Method not implemented.");
528
+ return this;
321
529
  }
322
530
  maxConnections;
323
531
  connections;
324
532
  listening;
325
533
  async [Symbol.asyncDispose]() {}
326
- }, I = (e, t) => new P().connect(e, t), L = (e, t) => new P().connect(e, t), R = (e, t) => {
327
- let n = new F(e);
534
+ }, Re = (e, t) => new R().connect(e, t), ze = (e, t) => new R().connect(e, t), Be = (e, t) => {
535
+ typeof e == "function" && (t = e, e = void 0);
536
+ let n = new z(e);
328
537
  return t && n.on("connection", t), n;
329
- }, z = {
330
- Socket: P,
331
- Server: F,
332
- connect: I,
333
- createConnection: L,
334
- createServer: R,
335
- isIP: k,
336
- isIPv4: D,
337
- isIPv6: O
338
- }, B = /* @__PURE__ */ n({
339
- Socket: () => V,
340
- createSocket: () => W
341
- }), V = class extends p {
538
+ }, Ve = {
539
+ Socket: R,
540
+ Server: z,
541
+ connect: Re,
542
+ createConnection: ze,
543
+ createServer: Be,
544
+ isIP: Ne,
545
+ isIPv4: I,
546
+ isIPv6: L
547
+ }, He = /* @__PURE__ */ n({
548
+ Socket: () => Ue,
549
+ createSocket: () => Ge
550
+ }), Ue = class extends d {
342
551
  _type;
343
552
  _localAddress;
344
553
  _remoteAddress;
@@ -366,8 +575,8 @@ var N = /* @__PURE__ */ n({
366
575
  });
367
576
  }
368
577
  addMembership(e, t) {
369
- if (m.isValid(e)) {
370
- let n = H(e), r = t && m.isValid(t) ? H(t) : new Uint8Array([
578
+ if (f.isValid(e)) {
579
+ let n = B(e), r = t && f.isValid(t) ? B(t) : new Uint8Array([
371
580
  0,
372
581
  0,
373
582
  0,
@@ -378,8 +587,8 @@ var N = /* @__PURE__ */ n({
378
587
  group: n,
379
588
  interface: r
380
589
  });
381
- } else if (h.isValid(e)) {
382
- let t = U(e);
590
+ } else if (p.isValid(e)) {
591
+ let t = We(e);
383
592
  this._setUdpOption({
384
593
  type: 7,
385
594
  group: t,
@@ -392,15 +601,15 @@ var N = /* @__PURE__ */ n({
392
601
  return this._localAddress;
393
602
  }
394
603
  bind(...e) {
395
- let t = j(...e), n = this._type === "udp6" ? "::" : "0.0.0.0";
396
- return this._webVPNUdpSocketPromise = w.then((e) => e.webVpnUdpSocket({
604
+ let t = Fe(...e), n = this._type === "udp6" ? "::" : "0.0.0.0";
605
+ return this._webVPNUdpSocketPromise = C.then((e) => e.webVpnUdpSocket({
397
606
  type: this._type,
398
607
  address: t.address ?? n,
399
608
  port: t.port
400
609
  })).then((e) => {
401
610
  let t = e.dataReadableStream.getReader(), n = async () => {
402
611
  let { value: e, done: r } = await t.read();
403
- r || (this.emit("message", g.from(e.data), {
612
+ r || (this.emit("message", m.from(e.data), {
404
613
  address: e.address,
405
614
  family: e.family,
406
615
  port: e.port,
@@ -453,8 +662,8 @@ var N = /* @__PURE__ */ n({
453
662
  });
454
663
  }
455
664
  dropMembership(e, t) {
456
- if (m.isValid(e)) {
457
- let n = H(e), r = t && m.isValid(t) ? H(t) : new Uint8Array([
665
+ if (f.isValid(e)) {
666
+ let n = B(e), r = t && f.isValid(t) ? B(t) : new Uint8Array([
458
667
  0,
459
668
  0,
460
669
  0,
@@ -465,8 +674,8 @@ var N = /* @__PURE__ */ n({
465
674
  group: n,
466
675
  interface: r
467
676
  });
468
- } else if (h.isValid(e)) {
469
- let t = U(e);
677
+ } else if (p.isValid(e)) {
678
+ let t = We(e);
470
679
  this._setUdpOption({
471
680
  type: 8,
472
681
  group: t,
@@ -499,11 +708,11 @@ var N = /* @__PURE__ */ n({
499
708
  }
500
709
  send(...e) {
501
710
  this._webVPNUdpSocketPromise || this.bind();
502
- let t = M(...e), n = this._type === "udp6" ? "::1" : "127.0.0.1";
711
+ let t = Ie(...e), n = this._type === "udp6" ? "::1" : "127.0.0.1";
503
712
  if (!this._webVPNUdpSocketPromise) throw Error("Socket not bound");
504
713
  this._webVPNUdpSocketPromise.then((e) => {
505
714
  if (!e) throw Error("Socket not bound");
506
- let r = typeof t.message == "string" ? E.encode(t.message) : t.message;
715
+ let r = typeof t.message == "string" ? Me.encode(t.message) : t.message;
507
716
  e.send({
508
717
  ...t,
509
718
  address: t.address ?? n,
@@ -561,50 +770,548 @@ var N = /* @__PURE__ */ n({
561
770
  this.close(e);
562
771
  });
563
772
  }
564
- }, H = (e) => {
773
+ }, B = (e) => {
565
774
  let t = e.split(".").map((e) => parseInt(e, 10));
566
775
  if (t.length !== 4 || t.some((e) => Number.isNaN(e) || e < 0 || e > 255)) throw Error(`Invalid IPv4 address: ${e}`);
567
776
  return new Uint8Array(t);
568
- }, U = (e) => {
569
- let t = new h(e).getBitsBase16(0, 128).match(/.{2}/g);
777
+ }, We = (e) => {
778
+ let t = new p(e).getBitsBase16(0, 128).match(/.{2}/g);
570
779
  if (!t || t.length !== 16) throw Error(`Invalid IPv6 address: ${e}`);
571
780
  return new Uint8Array(t.map((e) => parseInt(e, 16)));
572
- }, W = (e, t) => {
573
- let n = new V(typeof e == "string" ? { type: e } : e);
781
+ }, Ge = (e, t) => {
782
+ let n = new Ue(typeof e == "string" ? { type: e } : e);
574
783
  return t && n.on("message", t), n;
575
- };
576
- (() => {
577
- let e = {}, t = [...c.selectorModules, ...l.selectorModules];
578
- for (let n of t) n.render && !(n.type in e) && (e[n.type] = n.render);
579
- return e;
580
- })();
581
- //#endregion
582
- //#region node_modules/@mfkn/web-extension/lib/utils/extension.js
583
- var G = "FKN_WEB_EXTENSION_MAIN_WORLD_CONTENT_SCRIPT_ENABLED_EVENT_KEY", K = "fknExtension", q = u();
584
- typeof document < "u" && document.addEventListener(G, (e) => {
585
- q.dispatchEvent(new CustomEvent("statuschange", { detail: { enabled: e.detail.enabled } }));
586
- });
587
- var J = () => document.documentElement.dataset[K] === "true", Y = "FKN_WEB_EXTENSION_ATTACH_FRAME_EVENT_KEY", X, Z = new Proxy({}, { get: (e, t) => async (...e) => {
588
- if (!J()) throw Error("The FKN WebExtension is not installed, enabled or not exposed on this page.");
589
- return X ??= d({}, {
590
- transport: window,
591
- revivableModules: o
592
- }), (await X)[t](...e);
593
- } }), Q = async ({ iframe: e, domains: t = [] }) => {
594
- let n = crypto.randomUUID();
595
- e.dispatchEvent(new CustomEvent(Y, { detail: n }));
596
- let { executeLocator: r, goto: a } = await Z.attachFrame({
597
- marker: n,
598
- domains: t
599
- }), o = i(r), s = (e, t = {}) => a({
600
- url: e,
601
- ...t
602
- }), c = () => e.src;
784
+ }, Ke = /* @__PURE__ */ n({
785
+ Agent: () => Q,
786
+ ClientRequest: () => X,
787
+ HTTPParser: () => G,
788
+ IncomingMessage: () => q,
789
+ METHODS: () => Je,
790
+ STATUS_CODES: () => V,
791
+ Server: () => Z,
792
+ ServerResponse: () => Y,
793
+ _default: () => it,
794
+ createServer: () => rt,
795
+ default: () => it,
796
+ get: () => nt,
797
+ globalAgent: () => tt,
798
+ request: () => $
799
+ }), qe = new TextDecoder("latin1"), Je = /* @__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("."), V = {
800
+ 100: "Continue",
801
+ 101: "Switching Protocols",
802
+ 102: "Processing",
803
+ 103: "Early Hints",
804
+ 200: "OK",
805
+ 201: "Created",
806
+ 202: "Accepted",
807
+ 203: "Non-Authoritative Information",
808
+ 204: "No Content",
809
+ 205: "Reset Content",
810
+ 206: "Partial Content",
811
+ 207: "Multi-Status",
812
+ 208: "Already Reported",
813
+ 226: "IM Used",
814
+ 300: "Multiple Choices",
815
+ 301: "Moved Permanently",
816
+ 302: "Found",
817
+ 303: "See Other",
818
+ 304: "Not Modified",
819
+ 305: "Use Proxy",
820
+ 307: "Temporary Redirect",
821
+ 308: "Permanent Redirect",
822
+ 400: "Bad Request",
823
+ 401: "Unauthorized",
824
+ 402: "Payment Required",
825
+ 403: "Forbidden",
826
+ 404: "Not Found",
827
+ 405: "Method Not Allowed",
828
+ 406: "Not Acceptable",
829
+ 407: "Proxy Authentication Required",
830
+ 408: "Request Timeout",
831
+ 409: "Conflict",
832
+ 410: "Gone",
833
+ 411: "Length Required",
834
+ 412: "Precondition Failed",
835
+ 413: "Payload Too Large",
836
+ 414: "URI Too Long",
837
+ 415: "Unsupported Media Type",
838
+ 416: "Range Not Satisfiable",
839
+ 417: "Expectation Failed",
840
+ 418: "I'm a Teapot",
841
+ 421: "Misdirected Request",
842
+ 422: "Unprocessable Entity",
843
+ 423: "Locked",
844
+ 424: "Failed Dependency",
845
+ 425: "Too Early",
846
+ 426: "Upgrade Required",
847
+ 428: "Precondition Required",
848
+ 429: "Too Many Requests",
849
+ 431: "Request Header Fields Too Large",
850
+ 451: "Unavailable For Legal Reasons",
851
+ 500: "Internal Server Error",
852
+ 501: "Not Implemented",
853
+ 502: "Bad Gateway",
854
+ 503: "Service Unavailable",
855
+ 504: "Gateway Timeout",
856
+ 505: "HTTP Version Not Supported",
857
+ 506: "Variant Also Negotiates",
858
+ 507: "Insufficient Storage",
859
+ 508: "Loop Detected",
860
+ 509: "Bandwidth Limit Exceeded",
861
+ 510: "Not Extended",
862
+ 511: "Network Authentication Required"
863
+ }, Ye = new Set([
864
+ "content-type",
865
+ "content-length",
866
+ "user-agent",
867
+ "referer",
868
+ "host",
869
+ "authorization",
870
+ "proxy-authorization",
871
+ "if-modified-since",
872
+ "if-unmodified-since",
873
+ "from",
874
+ "location",
875
+ "max-forwards",
876
+ "retry-after",
877
+ "etag",
878
+ "last-modified",
879
+ "server",
880
+ "age",
881
+ "expires"
882
+ ]), H = 13, U = 10, Xe = /^[\^_`a-zA-Z\-0-9!#$%&'*+.|~]+$/, W = (e, t) => (e.code = t, e), Ze = (e, t) => {
883
+ if (e.length === 0) return t;
884
+ if (t.length === 0) return e;
885
+ let n = new Uint8Array(e.length + t.length);
886
+ return n.set(e, 0), n.set(t, e.length), n;
887
+ }, Qe = (e, t) => {
888
+ for (let n = t; n + 1 < e.length; n++) if (e[n] === H && e[n + 1] === U) return n;
889
+ return -1;
890
+ }, $e = (e) => {
891
+ for (let t = 0; t + 3 < e.length; t++) if (e[t] === H && e[t + 1] === U && e[t + 2] === H && e[t + 3] === U) return t;
892
+ return -1;
893
+ }, G = class {
894
+ buf = new Uint8Array();
895
+ state = "HEAD";
896
+ framing = "none";
897
+ bodyRemaining = 0;
898
+ chunkState = "size";
899
+ skipBody = !1;
900
+ constructor(e, t) {
901
+ this.mode = e, this.handlers = t;
902
+ }
903
+ execute(e) {
904
+ this.buf = Ze(this.buf, e);
905
+ let t = !0;
906
+ for (; t;) if (t = !1, this.state === "HEAD") {
907
+ let e = $e(this.buf);
908
+ if (e === -1) return;
909
+ let n = this.buf.subarray(0, e);
910
+ this.buf = this.buf.subarray(e + 4);
911
+ let r = this.parseHead(n);
912
+ 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);
913
+ } else this.consumeBody() && (this.handlers.onComplete(), this.reset(), t = this.buf.length > 0);
914
+ }
915
+ finish() {
916
+ this.state === "BODY" && this.framing === "eof" && (this.handlers.onComplete(), this.reset());
917
+ }
918
+ reset() {
919
+ this.state = "HEAD", this.framing = "none", this.bodyRemaining = 0, this.chunkState = "size", this.skipBody = !1;
920
+ }
921
+ parseHead(e) {
922
+ let t = qe.decode(e).split("\r\n"), n = t.shift() ?? "", r = [];
923
+ for (let e of t) (e.startsWith(" ") || e.startsWith(" ")) && r.length > 0 ? r[r.length - 1] += " " + e.trim() : r.push(e);
924
+ let i = [], a = {};
925
+ for (let e of r) {
926
+ if (!e) continue;
927
+ let t = e.indexOf(":");
928
+ if (t === -1) continue;
929
+ let n = e.slice(0, t).trim(), r = e.slice(t + 1).trim();
930
+ i.push(n, r), this.addHeader(a, n, r);
931
+ }
932
+ let o = {
933
+ httpVersionMajor: 1,
934
+ httpVersionMinor: 1,
935
+ httpVersion: "1.1",
936
+ headers: a,
937
+ rawHeaders: i
938
+ };
939
+ if (this.mode === "request") {
940
+ let [e, t, r] = n.split(" ");
941
+ o.method = (e ?? "GET").toUpperCase(), o.url = t ?? "/", this.applyVersion(o, r);
942
+ } else {
943
+ 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);
944
+ o.statusCode = parseInt(a, 10) || 0, o.statusMessage = i === -1 ? "" : r.slice(i + 1), this.applyVersion(o, t);
945
+ }
946
+ return o;
947
+ }
948
+ applyVersion(e, t) {
949
+ let n = /HTTP\/(\d)\.(\d)/i.exec(t ?? "");
950
+ n && (e.httpVersionMajor = parseInt(n[1], 10), e.httpVersionMinor = parseInt(n[2], 10), e.httpVersion = `${e.httpVersionMajor}.${e.httpVersionMinor}`);
951
+ }
952
+ addHeader(e, t, n) {
953
+ let r = t.toLowerCase();
954
+ if (r === "set-cookie") {
955
+ let t = e["set-cookie"];
956
+ Array.isArray(t) ? t.push(n) : e["set-cookie"] = [n];
957
+ return;
958
+ }
959
+ let i = e[r];
960
+ i === void 0 ? e[r] = n : Ye.has(r) || (e[r] = `${i}, ${n}`);
961
+ }
962
+ setupBody(e) {
963
+ if (this.skipBody) {
964
+ this.framing = "none";
965
+ return;
966
+ }
967
+ let t = e.headers["transfer-encoding"];
968
+ if (typeof t == "string" && t.toLowerCase().includes("chunked")) {
969
+ this.framing = "chunked", this.chunkState = "size";
970
+ return;
971
+ }
972
+ let n = e.headers["content-length"];
973
+ if (typeof n == "string" && n !== "") {
974
+ let e = parseInt(n, 10);
975
+ e > 0 ? (this.framing = "length", this.bodyRemaining = e) : this.framing = "none";
976
+ return;
977
+ }
978
+ if (this.mode === "response") {
979
+ let t = e.statusCode ?? 0;
980
+ t >= 100 && t < 200 || t === 204 || t === 304 ? this.framing = "none" : this.framing = "eof";
981
+ } else this.framing = "none";
982
+ }
983
+ consumeBody() {
984
+ if (this.framing === "length") {
985
+ if (this.buf.length === 0) return !1;
986
+ let e = Math.min(this.bodyRemaining, this.buf.length);
987
+ return this.handlers.onBody(this.buf.subarray(0, e)), this.buf = this.buf.subarray(e), this.bodyRemaining -= e, this.bodyRemaining === 0;
988
+ }
989
+ return this.framing === "eof" ? (this.buf.length > 0 && (this.handlers.onBody(this.buf), this.buf = new Uint8Array()), !1) : this.framing === "chunked" ? this.consumeChunked() : !0;
990
+ }
991
+ consumeChunked() {
992
+ for (;;) if (this.chunkState === "size") {
993
+ let e = Qe(this.buf, 0);
994
+ if (e === -1) return !1;
995
+ let t = qe.decode(this.buf.subarray(0, e)), n = parseInt(t.split(";")[0].trim(), 16);
996
+ if (this.buf = this.buf.subarray(e + 2), Number.isNaN(n)) return !0;
997
+ n === 0 ? this.chunkState = "trailer" : (this.bodyRemaining = n, this.chunkState = "data");
998
+ } else if (this.chunkState === "data") {
999
+ if (this.buf.length === 0) return !1;
1000
+ let e = Math.min(this.bodyRemaining, this.buf.length);
1001
+ this.handlers.onBody(this.buf.subarray(0, e)), this.buf = this.buf.subarray(e), this.bodyRemaining -= e, this.bodyRemaining === 0 && (this.chunkState = "dataCRLF");
1002
+ } else if (this.chunkState === "dataCRLF") {
1003
+ if (this.buf.length < 2) return !1;
1004
+ this.buf = this.buf.subarray(2), this.chunkState = "size";
1005
+ } else {
1006
+ let e = Qe(this.buf, 0);
1007
+ if (e === -1) return !1;
1008
+ let t = e === 0;
1009
+ if (this.buf = this.buf.subarray(e + 2), t) return !0;
1010
+ }
1011
+ }
1012
+ }, K = (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
+ httpVersion = "1.1";
1014
+ httpVersionMajor = 1;
1015
+ httpVersionMinor = 1;
1016
+ headers = {};
1017
+ rawHeaders = [];
1018
+ trailers = {};
1019
+ rawTrailers = [];
1020
+ method;
1021
+ url;
1022
+ statusCode;
1023
+ statusMessage;
1024
+ complete = !1;
1025
+ socket;
1026
+ constructor(e) {
1027
+ super(), this.socket = e;
1028
+ }
1029
+ get connection() {
1030
+ return this.socket;
1031
+ }
1032
+ _applyHead(e) {
1033
+ 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;
1034
+ }
1035
+ _read() {}
1036
+ setTimeout(e, t) {
1037
+ return this.socket.setTimeout(e, t), this;
1038
+ }
1039
+ }, J = class extends u.Writable {
1040
+ _headerStore = /* @__PURE__ */ new Map();
1041
+ headersSent = !1;
1042
+ chunkedEncoding = !1;
1043
+ finished = !1;
1044
+ _bodyWritten = !1;
1045
+ setHeader(e, t) {
1046
+ if (this.headersSent) throw W(/* @__PURE__ */ Error("Cannot set headers after they are sent to the client"), "ERR_HTTP_HEADERS_SENT");
1047
+ if (typeof e != "string" || !Xe.test(e)) throw W(/* @__PURE__ */ TypeError(`Header name must be a valid HTTP token [${JSON.stringify(String(e))}]`), "ERR_INVALID_HTTP_TOKEN");
1048
+ if (t === void 0) throw W(/* @__PURE__ */ TypeError(`Invalid value "undefined" for header "${e}"`), "ERR_HTTP_INVALID_HEADER_VALUE");
1049
+ return this._headerStore.set(e.toLowerCase(), [e, Array.isArray(t) ? [...t] : t]), this;
1050
+ }
1051
+ getHeader(e) {
1052
+ return this._headerStore.get(e.toLowerCase())?.[1];
1053
+ }
1054
+ getHeaderNames() {
1055
+ return [...this._headerStore.values()].map(([e]) => e);
1056
+ }
1057
+ getHeaders() {
1058
+ let e = {};
1059
+ for (let [t, n] of this._headerStore.values()) e[t] = n;
1060
+ return e;
1061
+ }
1062
+ hasHeader(e) {
1063
+ return this._headerStore.has(e.toLowerCase());
1064
+ }
1065
+ removeHeader(e) {
1066
+ if (this.headersSent) throw Error("Cannot remove headers after they are sent to the client");
1067
+ this._headerStore.delete(e.toLowerCase());
1068
+ }
1069
+ _storeHeader(e) {
1070
+ let t = this.hasHeader("content-length"), n = this.getHeader("transfer-encoding");
1071
+ typeof n == "string" && n.toLowerCase().includes("chunked") ? this.chunkedEncoding = !0 : !t && this._shouldSendBody() && (this.chunkedEncoding = !0, this.setHeader("Transfer-Encoding", "chunked"));
1072
+ let r = e + "\r\n";
1073
+ for (let [e, t] of this._headerStore.values()) if (Array.isArray(t)) for (let n of t) r += `${e}: ${n}\r\n`;
1074
+ else r += `${e}: ${t}\r\n`;
1075
+ return r += "\r\n", r;
1076
+ }
1077
+ _writeToSocket(e, t) {
1078
+ if (!this.socket) {
1079
+ t(/* @__PURE__ */ Error("Socket is not available"));
1080
+ return;
1081
+ }
1082
+ this.socket.write(e, t);
1083
+ }
1084
+ write(e, t, n) {
1085
+ return this._bodyWritten = !0, super.write(e, t, n);
1086
+ }
1087
+ _write(e, t, n) {
1088
+ let r = K(e), i = [];
1089
+ 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
+ n();
1091
+ return;
1092
+ }
1093
+ this._writeToSocket(m.concat(i), n);
1094
+ }
1095
+ _final(e) {
1096
+ let t = [];
1097
+ if (this.headersSent ||= (!this.chunkedEncoding && !this.hasHeader("content-length") && this.setHeader("Content-Length", 0), this._implicitHeader(), t.push(m.from(this._headBlock, "latin1")), !0), this.chunkedEncoding && t.push(m.from("0\r\n\r\n", "latin1")), this.finished = !0, t.length === 0) {
1098
+ e();
1099
+ return;
1100
+ }
1101
+ this._writeToSocket(m.concat(t), e);
1102
+ }
1103
+ end(e, t, n) {
1104
+ if (e != null && typeof e != "function" && !this._bodyWritten && !this.headersSent && !this.chunkedEncoding && !this.hasHeader("content-length")) {
1105
+ let n = typeof t == "string" ? t : void 0;
1106
+ this.setHeader("Content-Length", K(e, n).length);
1107
+ }
1108
+ return super.end(e, t, n);
1109
+ }
1110
+ _headBlock;
1111
+ }, Y = class extends J {
1112
+ statusCode = 200;
1113
+ statusMessage;
1114
+ _writeHeadCalled = !1;
1115
+ sendDate = !0;
1116
+ req;
1117
+ socket;
1118
+ _keepAlive = !0;
1119
+ constructor(e) {
1120
+ super(), this.req = e, this.socket = e.socket;
1121
+ }
1122
+ _shouldSendBody() {
1123
+ if (this.req.method === "HEAD") return !1;
1124
+ let e = this.statusCode;
1125
+ return !(e >= 100 && e < 200 || e === 204 || e === 304);
1126
+ }
1127
+ writeHead(e, t, n) {
1128
+ if (this._writeHeadCalled || this.headersSent) throw W(/* @__PURE__ */ Error("Cannot render headers after they are sent to the client"), "ERR_HTTP_HEADERS_SENT");
1129
+ this._writeHeadCalled = !0, this.statusCode = e;
1130
+ let r = n;
1131
+ if (typeof t == "string" ? this.statusMessage = t : t != null && (r = t), Array.isArray(r)) {
1132
+ let e = Array.isArray(r[0]) ? r : Array.from({ length: Math.floor(r.length / 2) }, (e, t) => [r[t * 2], r[t * 2 + 1]]);
1133
+ for (let [t, n] of e) n !== void 0 && this._appendHeader(t, n);
1134
+ } else if (r) for (let [e, t] of Object.entries(r)) t !== void 0 && this.setHeader(e, t);
1135
+ return this;
1136
+ }
1137
+ _appendHeader(e, t) {
1138
+ let n = this.getHeader(e);
1139
+ if (n === void 0) this.setHeader(e, t);
1140
+ else {
1141
+ let r = [...Array.isArray(n) ? n : [n], ...Array.isArray(t) ? t : [t]].map(String);
1142
+ this.setHeader(e, r);
1143
+ }
1144
+ }
1145
+ _implicitHeader() {
1146
+ let e = this.statusMessage ?? V[this.statusCode] ?? "unknown";
1147
+ 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
+ }
1149
+ writeContinue() {
1150
+ this._writeToSocket(m.from("HTTP/1.1 100 Continue\r\n\r\n", "latin1"), () => {});
1151
+ }
1152
+ setTimeout(e, t) {
1153
+ return this.socket?.setTimeout(e, t), this;
1154
+ }
1155
+ }, et = (...e) => {
1156
+ let t = {}, n = {}, r, i = [...e], a = i.shift();
1157
+ if (typeof a == "string" || a instanceof URL) {
1158
+ let e = typeof a == "string" ? new URL(a) : a;
1159
+ t = {
1160
+ protocol: e.protocol,
1161
+ hostname: e.hostname,
1162
+ host: e.hostname,
1163
+ port: e.port,
1164
+ path: `${e.pathname}${e.search}`,
1165
+ auth: e.username ? `${e.username}:${e.password}` : void 0
1166
+ };
1167
+ let o = i.shift();
1168
+ typeof o == "function" ? r = o : o && typeof o == "object" && (n = o, r = i.shift());
1169
+ } else a && typeof a == "object" && (n = a, r = i.shift());
603
1170
  return {
604
- ...o,
605
- goto: s,
606
- url: c
1171
+ options: {
1172
+ ...t,
1173
+ ...n
1174
+ },
1175
+ callback: r
607
1176
  };
1177
+ }, X = class extends J {
1178
+ method;
1179
+ path;
1180
+ host;
1181
+ protocol;
1182
+ socket;
1183
+ get connection() {
1184
+ return this.socket;
1185
+ }
1186
+ res = null;
1187
+ aborted = !1;
1188
+ _aborted = !1;
1189
+ constructor(e, t) {
1190
+ super(), this.method = (e.method ?? "GET").toUpperCase(), this.path = e.path ?? "/", this.protocol = e.protocol ?? "http:";
1191
+ let n = e.hostname ?? e.host ?? "localhost";
1192
+ this.host = n;
1193
+ let r = Number(e.port ?? (this.protocol === "https:" ? 443 : 80));
1194
+ if (t && this.once("response", t), e.headers) for (let [t, n] of Object.entries(e.headers)) n !== void 0 && this.setHeader(t, n);
1195
+ if (!this.hasHeader("host")) {
1196
+ let e = this.protocol === "https:" && r === 443 || this.protocol !== "https:" && r === 80;
1197
+ this.setHeader("Host", e ? n : `${n}:${r}`);
1198
+ }
1199
+ e.auth && !this.hasHeader("authorization") && this.setHeader("Authorization", `Basic ${m.from(e.auth).toString("base64")}`), this.socket = new R(), this.emit("socket", this.socket), this.socket.on("error", (e) => {
1200
+ this._aborted || this.emit("error", e);
1201
+ }), this._attachResponseParser(), this.socket.connect({
1202
+ host: n,
1203
+ port: r
1204
+ }, () => {
1205
+ this.emit("connect");
1206
+ });
1207
+ }
1208
+ _shouldSendBody() {
1209
+ return this.method !== "GET" && this.method !== "HEAD" && this.method !== "DELETE";
1210
+ }
1211
+ _implicitHeader() {
1212
+ this._headBlock = this._storeHeader(`${this.method} ${this.path} HTTP/1.1`);
1213
+ }
1214
+ _attachResponseParser() {
1215
+ let e = new q(this.socket), t = new G("response", {
1216
+ onHeaders: (n) => {
1217
+ e._applyHead(n), this.method === "HEAD" && (t.skipBody = !0), this.res = e, this.emit("response", e);
1218
+ },
1219
+ onBody: (t) => {
1220
+ e.push(m.from(t));
1221
+ },
1222
+ onComplete: () => {
1223
+ e.complete = !0, e.push(null);
1224
+ }
1225
+ });
1226
+ this.socket.on("data", (e) => {
1227
+ this._aborted || t.execute(e);
1228
+ }), this.socket.on("end", () => {
1229
+ t.finish();
1230
+ }), this.socket.on("close", () => {
1231
+ this.emit("close");
1232
+ });
1233
+ }
1234
+ abort() {
1235
+ this._aborted || (this._aborted = !0, this.aborted = !0, this.emit("abort"), this.socket.destroy());
1236
+ }
1237
+ destroy(e) {
1238
+ return this._aborted ? this : (this._aborted = !0, this.socket.destroy(e), super.destroy(e), this);
1239
+ }
1240
+ end(e, t, n) {
1241
+ return this._aborted ? this : super.end(e, t, n);
1242
+ }
1243
+ _writeToSocket(e, t) {
1244
+ if (this._aborted) {
1245
+ t();
1246
+ return;
1247
+ }
1248
+ super._writeToSocket(e, t);
1249
+ }
1250
+ setTimeout(e, t) {
1251
+ return this.socket.setTimeout(e, t), this;
1252
+ }
1253
+ setNoDelay(e) {
1254
+ this.socket.setNoDelay(e);
1255
+ }
1256
+ setSocketKeepAlive(e, t) {
1257
+ this.socket.setKeepAlive(e, t);
1258
+ }
1259
+ }, Z = new Proxy(class extends z {
1260
+ constructor(e, t) {
1261
+ let n = {}, r = t;
1262
+ typeof e == "function" ? r = e : e && (n = e), super(n), r && this.on("request", r), this.on("connection", (e) => this._handleConnection(e));
1263
+ }
1264
+ _handleConnection(e) {
1265
+ let t = null, n = new G("request", {
1266
+ onHeaders: (r) => {
1267
+ t = new q(e), t._applyHead(r), r.method === "HEAD" && (n.skipBody = !0);
1268
+ let i = new Y(t), a = String(r.headers.connection ?? "").toLowerCase();
1269
+ i._keepAlive = r.httpVersionMinor >= 1 ? a !== "close" : a === "keep-alive", i.on("finish", () => {
1270
+ i._keepAlive || e.end();
1271
+ }), this.emit("request", t, i);
1272
+ },
1273
+ onBody: (e) => {
1274
+ t?.push(m.from(e));
1275
+ },
1276
+ onComplete: () => {
1277
+ t && (t.complete = !0, t.push(null)), t = null;
1278
+ }
1279
+ });
1280
+ e.on("data", (e) => n.execute(e)), e.on("end", () => {
1281
+ n.finish(), t && t.push(null);
1282
+ }), e.on("error", (t) => this.emit("clientError", t, e));
1283
+ }
1284
+ }, { apply: (e, t, n) => new e(...n) }), Q = class {
1285
+ maxSockets;
1286
+ maxFreeSockets;
1287
+ keepAlive;
1288
+ options;
1289
+ constructor(e = {}) {
1290
+ this.options = e, this.keepAlive = !!e.keepAlive, this.maxSockets = e.maxSockets ?? Infinity, this.maxFreeSockets = e.maxFreeSockets ?? 256;
1291
+ }
1292
+ getName(e = {}) {
1293
+ return `${e.host ?? "localhost"}:${e.port ?? ""}:${e.localAddress ?? ""}`;
1294
+ }
1295
+ destroy() {}
1296
+ }, tt = new Q(), $ = (...e) => {
1297
+ let { options: t, callback: n } = et(...e);
1298
+ return new X(t, n);
1299
+ }, nt = (...e) => {
1300
+ let t = $(...e);
1301
+ return t.end(), t;
1302
+ }, rt = (e, t) => new Z(e, t), it = {
1303
+ METHODS: Je,
1304
+ STATUS_CODES: V,
1305
+ Agent: Q,
1306
+ globalAgent: tt,
1307
+ Server: Z,
1308
+ ServerResponse: Y,
1309
+ IncomingMessage: q,
1310
+ ClientRequest: X,
1311
+ OutgoingMessage: J,
1312
+ createServer: rt,
1313
+ request: $,
1314
+ get: nt
608
1315
  };
609
1316
  //#endregion
610
- export { Y as ATTACH_FRAME_EVENT_KEY, Q as attachFrame, r as box, e as createVideoElementHandle, B as dgram, o as handleRevivableModules, a as isType, N as net, s as revive, T as serverProxyFetch, t as type };
1317
+ export { j as ATTACH_FRAME_EVENT_KEY, N as assertAttachableFrameUrl, Ae as attachFrame, Oe as attachFramePermission, l as box, we as cookies, e as createVideoElementHandle, He as dgram, w as extension, Se as fetch, ye as fetchCredentialedPermission, ve as fetchPermission, ke as gotoPermission, i as handleRevivableModules, Ke as http, M as isBlockedFrameUrl, T as isExtensionExposed, t as isType, Te as modifyRequestHeadersPermission, Le as net, je as permissions, P as promptInstall, Ce as readCookiePermission, he as relayWorker, De as removeRequestHeaderRule, o as revive, pe as serverProxyFetch, D as setMissingExtensionHandler, Ee as setRequestHeaderRule, a as type, O as waitForExtensionExposure };