@fkn/lib 0.3.9 → 0.3.11

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,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-fXEVniGP.js";
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-DhCNXAk2.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";
@@ -7,8 +7,8 @@ import { Buffer as m } from "buffer";
7
7
  //#region src/lib/overlay.ts
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
- 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 }) => {
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`, h = (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
- }, ce = (e) => {
19
+ }, se = (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
- }, le = (e) => {
35
+ }, ce = (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(ce).filter((e) => e !== null && e.width > 0 && e.height > 0);
37
+ let t = e, n = (Array.isArray(t.rects) ? t.rects.slice(0, re) : []).map(se).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
- }, h = null, ue = () => h !== null, de = (e) => {
43
- ae(e), se(e, {
42
+ }, g = null, le = () => g !== null, ue = (e) => {
43
+ ae(e), h(e, {
44
44
  modal: !1,
45
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 ? {
46
+ }), g = e;
47
+ }, de = (e) => {
48
+ if (!g) return;
49
+ let t = ce(e);
50
+ t && h(g, t);
51
+ }, _ = "https://fkn.app", v = typeof globalThis < "u" && globalThis.document ? globalThis.document : void 0, fe = v?.querySelector(`iframe[src="${_}/api"]`) ?? null, y = v?.createElement("iframe") ?? null;
52
+ !fe && y && v && (y.src = `${_}/api`, v.body.appendChild(y));
53
+ var b = fe ?? y, pe = b?.contentWindow ?? null;
54
+ b && v && ue(b);
55
+ var me = (() => {
56
+ if (typeof window < "u") return pe ? {
57
57
  receive: window,
58
- emit: x
58
+ emit: pe
59
59
  } : void 0;
60
60
  if (typeof self < "u") return {
61
61
  receive: self,
62
62
  emit: self
63
63
  };
64
- })(), C = S ? te({}, {
64
+ })(), x = me ? te({}, {
65
65
  key: "fkn-api",
66
- transport: S
66
+ transport: me
67
67
  }) : new Promise(() => {});
68
- C.then((e) => {
69
- ue() && e.setOverlayHost(fe);
68
+ x.then((e) => {
69
+ le() && e.setOverlayHost(de);
70
70
  }, () => {});
71
71
  //#endregion
72
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) => {
73
+ var he = (e, t) => x.then((n) => n.proxyFetch(e, t)), ge = "https://fkn.app", _e = (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 ?? me,
81
+ originA: t?.originA ?? ge,
82
82
  originB: t?.originB ?? "*",
83
83
  unregisterSignal: t?.unregisterSignal
84
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 } }));
85
+ }, ve = "FKN_WEB_EXTENSION_MAIN_WORLD_CONTENT_SCRIPT_ENABLED_EVENT_KEY", ye = "fknExtension", S = ee();
86
+ typeof document < "u" && document.addEventListener(ve, (e) => {
87
+ S.dispatchEvent(new CustomEvent("statuschange", { detail: { enabled: e.detail.enabled } }));
88
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();
89
+ var C = () => document.documentElement.dataset[ye] === "true", w = null, T = (e) => {
90
+ w = e;
91
+ }, be = 150, E = (e = 1e3) => new Promise((t, n) => {
92
+ if (C()) return t();
93
+ let r, i = (e) => {
94
+ clearTimeout(r), s.disconnect(), document.removeEventListener("readystatechange", c), e();
95
+ }, a = () => i(async () => {
96
+ if (w && (await w().catch(() => {}), C())) 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
- document.readyState === "complete" && !T() && i();
102
- }, s = setTimeout(i, e);
103
- if (document.readyState === "complete") return i();
104
- a.observe(document.documentElement, {
99
+ clearTimeout(r), r = setTimeout(() => C() ? i(t) : a(), be);
100
+ }, s = new MutationObserver(() => {
101
+ C() && i(t);
102
+ }), c = () => {
103
+ document.readyState === "complete" && !C() && 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", o), T() && r(t);
108
- }), k, A = new Proxy({}, { get: (e, t) => async (...e) => {
109
- await O(), k ??= te({}, {
108
+ }), document.addEventListener("readystatechange", c), document.readyState === "complete") return o();
109
+ C() && i(t);
110
+ }), D, O = new Proxy({}, { get: (e, t) => async (...e) => {
111
+ await E(), D ??= te({}, {
110
112
  transport: window,
111
113
  revivableModules: i
112
114
  });
113
- let n = (await k)[t];
115
+ let n = (await D)[t];
114
116
  return n(...e);
115
- } }), ve = {
117
+ } }), xe = {
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
- }, ye = {
123
+ }, Se = {
122
124
  scope: "network.fetchCredentialed",
123
125
  category: "network",
124
126
  severity: 3,
125
127
  unsafe: !0,
126
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
- }, be = ["origin", "referer"], xe = (e) => {
130
+ }, Ce = ["origin", "referer"], we = (e) => {
129
131
  if (!e?.headers) return;
130
- let t = new Headers(e.headers), n = be.map((e) => {
132
+ let t = new Headers(e.headers), n = Ce.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
- }, Se = async (e, t) => {
137
+ }, Te = async (e, t) => {
136
138
  let n = new Request(e, t), r = n.body ? await n.arrayBuffer() : null;
137
- return A.proxyFetch({
139
+ return O.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: xe(t),
146
+ unsafeHeaders: we(t),
145
147
  reason: t?.reason,
146
148
  signal: t?.signal ?? void 0
147
149
  });
148
- }, Ce = {
150
+ }, Ee = {
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
- }, we = { get: (e) => A.getCookie(e) }, Te = {
157
+ }, De = { get: (e) => O.getCookie(e) }, Oe = {
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
- }, Ee = (e) => A.setRequestHeaderRule(e), De = (e) => A.removeRequestHeaderRule({ ruleId: e });
164
+ }, ke = (e) => O.setRequestHeaderRule(e), Ae = (e) => O.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 j = "FKN_WEB_EXTENSION_ATTACH_FRAME_EVENT_KEY", M = (e) => {
172
+ var k = "FKN_WEB_EXTENSION_ATTACH_FRAME_EVENT_KEY", A = (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
- }, N = (e) => {
183
- if (M(e)) throw Error("attachFrame: refusing to target the extension's own pages or fkn.app");
184
- }, Oe = {
184
+ }, j = (e) => {
185
+ if (A(e)) throw Error("attachFrame: refusing to target the extension's own pages or fkn.app");
186
+ }, je = {
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
- }, ke = {
192
+ }, Me = {
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
- }, Ae = async ({ iframe: e, domains: t = [] }) => {
198
+ }, Ne = async ({ iframe: e, domains: t = [] }) => {
197
199
  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({
200
+ if (j(e.src), await E(), !e.isConnected) throw Error("attachFrame: the iframe must be connected to the document before attaching");
201
+ e.dispatchEvent(new CustomEvent(k, { detail: n }));
202
+ let { executeLocator: r, ensureLocatorPermission: i, goto: a } = await O.attachFrame({
201
203
  marker: n,
202
204
  domains: t
203
- }), o = s(r, i), c = (e, t = {}) => (N(e), a({
205
+ }), o = s(r, i), c = (e, t = {}) => (j(e), a({
204
206
  url: e,
205
207
  ...t
206
208
  })), l = () => e.src;
@@ -209,28 +211,28 @@ var j = "FKN_WEB_EXTENSION_ATTACH_FRAME_EVENT_KEY", M = (e) => {
209
211
  goto: c,
210
212
  url: l
211
213
  };
212
- }, je = { request: (e) => A.requestPermissions(e.map((e) => ({
214
+ }, Pe = { request: (e) => O.requestPermissions(e.map((e) => ({
213
215
  key: e.key,
214
216
  scope: e.scope ?? "",
215
217
  reason: e.reason
216
- }))) }, P = async (e) => {
218
+ }))) }, M = async (e) => {
217
219
  if (typeof window > "u") return !1;
218
- if (T()) return !0;
219
- let t = await C, n = null, r = new Promise((e) => {
220
+ if (C()) return !0;
221
+ let t = await x, n = null, r = new Promise((e) => {
220
222
  n = () => {
221
- T() && e(!0);
222
- }, w.addEventListener("statuschange", n);
223
+ C() && e(!0);
224
+ }, S.addEventListener("statuschange", n);
223
225
  }), 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));
226
+ return n && S.removeEventListener("statuschange", n), await t.hideInstallPrompt().catch(() => {}), a;
227
+ }, N = null;
228
+ T(() => (N ||= M().then(() => void 0).finally(() => {
229
+ N = null;
230
+ }), N));
229
231
  //#endregion
230
232
  //#region src/lib/webvpn/utils.ts
231
- var Me = new TextEncoder();
233
+ var Fe = new TextEncoder();
232
234
  new TextDecoder();
233
- var I = (e) => f.isValid(e), L = (e) => p.isValid(e), Ne = (e) => I(e) ? 4 : L(e) ? 6 : 0, Pe = (...e) => {
235
+ var P = (e) => f.isValid(e), F = (e) => p.isValid(e), I = (e) => P(e) ? 4 : F(e) ? 6 : 0, L = (...e) => {
234
236
  if (typeof e[0] == "string") throw Error("FKN WebVPN does not support IPC connections");
235
237
  let t = typeof e.at(-1) == "function" ? e.at(-1) : void 0;
236
238
  return e[0] && typeof e[0] == "object" ? {
@@ -241,7 +243,7 @@ var I = (e) => f.isValid(e), L = (e) => p.isValid(e), Ne = (e) => I(e) ? 4 : L(e
241
243
  host: typeof e[1] == "string" ? e[1] : void 0,
242
244
  callback: t
243
245
  };
244
- }, Fe = (...e) => {
246
+ }, Ie = (...e) => {
245
247
  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
248
  return typeof e[0] == "object" ? {
247
249
  ...e[0],
@@ -253,7 +255,7 @@ var I = (e) => f.isValid(e), L = (e) => p.isValid(e), Ne = (e) => I(e) ? 4 : L(e
253
255
  port: n,
254
256
  callback: t
255
257
  };
256
- }, Ie = (...e) => {
258
+ }, Le = (...e) => {
257
259
  let t = typeof e.at(-1) == "function" ? e.at(-1) : void 0, n = e[0];
258
260
  if (typeof e[2] == "number") return {
259
261
  message: n,
@@ -278,17 +280,17 @@ var I = (e) => f.isValid(e), L = (e) => p.isValid(e), Ne = (e) => I(e) ? 4 : L(e
278
280
  new TextEncoder(), new TextDecoder();
279
281
  //#endregion
280
282
  //#region src/lib/webvpn/net.ts
281
- var Le = /* @__PURE__ */ n({
283
+ var Re = /* @__PURE__ */ n({
282
284
  Server: () => z,
283
285
  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
286
+ _default: () => He,
287
+ connect: () => ze,
288
+ createConnection: () => Be,
289
+ createServer: () => Ve,
290
+ default: () => He,
291
+ isIP: () => I,
292
+ isIPv4: () => P,
293
+ isIPv6: () => F
292
294
  }), R = class extends u.Duplex {
293
295
  _localAddress;
294
296
  _remoteAddress;
@@ -349,7 +351,7 @@ var Le = /* @__PURE__ */ n({
349
351
  }).catch(n);
350
352
  }
351
353
  connect(...e) {
352
- let t = Pe(...e), n = this.__webvpn_tcp_socket_init__(C.then((e) => e.webVpnTcpSocket({
354
+ let t = L(...e), n = this.__webvpn_tcp_socket_init__(x.then((e) => e.webVpnTcpSocket({
353
355
  remoteAddress: t.host ?? "localhost",
354
356
  remotePort: t.port
355
357
  })));
@@ -494,10 +496,10 @@ var Le = /* @__PURE__ */ n({
494
496
  }), this._webVPNTcpSocketListenerPromise;
495
497
  }
496
498
  listen(...e) {
497
- let t = Pe(...e), n = (e) => {
499
+ let t = L(...e), n = (e) => {
498
500
  let t = new R({ connection: Promise.resolve(e) });
499
501
  this.emit("connection", t);
500
- }, r = (e) => C.then((r) => r.webVpnTcpSocketListener({
502
+ }, r = (e) => x.then((r) => r.webVpnTcpSocketListener({
501
503
  localAddress: e,
502
504
  localPort: t.port,
503
505
  onConnection: n
@@ -531,23 +533,23 @@ var Le = /* @__PURE__ */ n({
531
533
  connections;
532
534
  listening;
533
535
  async [Symbol.asyncDispose]() {}
534
- }, Re = (e, t) => new R().connect(e, t), ze = (e, t) => new R().connect(e, t), Be = (e, t) => {
536
+ }, ze = (e, t) => new R().connect(e, t), Be = (e, t) => new R().connect(e, t), Ve = (e, t) => {
535
537
  typeof e == "function" && (t = e, e = void 0);
536
538
  let n = new z(e);
537
539
  return t && n.on("connection", t), n;
538
- }, Ve = {
540
+ }, He = {
539
541
  Socket: R,
540
542
  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 {
543
+ connect: ze,
544
+ createConnection: Be,
545
+ createServer: Ve,
546
+ isIP: I,
547
+ isIPv4: P,
548
+ isIPv6: F
549
+ }, Ue = /* @__PURE__ */ n({
550
+ Socket: () => We,
551
+ createSocket: () => Ke
552
+ }), We = class extends d {
551
553
  _type;
552
554
  _localAddress;
553
555
  _remoteAddress;
@@ -588,7 +590,7 @@ var Le = /* @__PURE__ */ n({
588
590
  interface: r
589
591
  });
590
592
  } else if (p.isValid(e)) {
591
- let t = We(e);
593
+ let t = Ge(e);
592
594
  this._setUdpOption({
593
595
  type: 7,
594
596
  group: t,
@@ -601,8 +603,8 @@ var Le = /* @__PURE__ */ n({
601
603
  return this._localAddress;
602
604
  }
603
605
  bind(...e) {
604
- let t = Fe(...e), n = this._type === "udp6" ? "::" : "0.0.0.0";
605
- return this._webVPNUdpSocketPromise = C.then((e) => e.webVpnUdpSocket({
606
+ let t = Ie(...e), n = this._type === "udp6" ? "::" : "0.0.0.0";
607
+ return this._webVPNUdpSocketPromise = x.then((e) => e.webVpnUdpSocket({
606
608
  type: this._type,
607
609
  address: t.address ?? n,
608
610
  port: t.port
@@ -675,7 +677,7 @@ var Le = /* @__PURE__ */ n({
675
677
  interface: r
676
678
  });
677
679
  } else if (p.isValid(e)) {
678
- let t = We(e);
680
+ let t = Ge(e);
679
681
  this._setUdpOption({
680
682
  type: 8,
681
683
  group: t,
@@ -708,11 +710,11 @@ var Le = /* @__PURE__ */ n({
708
710
  }
709
711
  send(...e) {
710
712
  this._webVPNUdpSocketPromise || this.bind();
711
- let t = Ie(...e), n = this._type === "udp6" ? "::1" : "127.0.0.1";
713
+ let t = Le(...e), n = this._type === "udp6" ? "::1" : "127.0.0.1";
712
714
  if (!this._webVPNUdpSocketPromise) throw Error("Socket not bound");
713
715
  this._webVPNUdpSocketPromise.then((e) => {
714
716
  if (!e) throw Error("Socket not bound");
715
- let r = typeof t.message == "string" ? Me.encode(t.message) : t.message;
717
+ let r = typeof t.message == "string" ? Fe.encode(t.message) : t.message;
716
718
  e.send({
717
719
  ...t,
718
720
  address: t.address ?? n,
@@ -774,29 +776,29 @@ var Le = /* @__PURE__ */ n({
774
776
  let t = e.split(".").map((e) => parseInt(e, 10));
775
777
  if (t.length !== 4 || t.some((e) => Number.isNaN(e) || e < 0 || e > 255)) throw Error(`Invalid IPv4 address: ${e}`);
776
778
  return new Uint8Array(t);
777
- }, We = (e) => {
779
+ }, Ge = (e) => {
778
780
  let t = new p(e).getBitsBase16(0, 128).match(/.{2}/g);
779
781
  if (!t || t.length !== 16) throw Error(`Invalid IPv6 address: ${e}`);
780
782
  return new Uint8Array(t.map((e) => parseInt(e, 16)));
781
- }, Ge = (e, t) => {
782
- let n = new Ue(typeof e == "string" ? { type: e } : e);
783
+ }, Ke = (e, t) => {
784
+ let n = new We(typeof e == "string" ? { type: e } : e);
783
785
  return t && n.on("message", t), n;
784
- }, Ke = /* @__PURE__ */ n({
786
+ }, qe = /* @__PURE__ */ n({
785
787
  Agent: () => Q,
786
788
  ClientRequest: () => X,
787
- HTTPParser: () => G,
789
+ HTTPParser: () => K,
788
790
  IncomingMessage: () => q,
789
- METHODS: () => Je,
791
+ METHODS: () => Ye,
790
792
  STATUS_CODES: () => V,
791
793
  Server: () => Z,
792
794
  ServerResponse: () => Y,
793
- _default: () => it,
794
- createServer: () => rt,
795
- default: () => it,
796
- get: () => nt,
797
- globalAgent: () => tt,
795
+ _default: () => at,
796
+ createServer: () => it,
797
+ default: () => at,
798
+ get: () => rt,
799
+ globalAgent: () => nt,
798
800
  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 = {
801
+ }), Je = new TextDecoder("latin1"), Ye = /* @__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
802
  100: "Continue",
801
803
  101: "Switching Protocols",
802
804
  102: "Processing",
@@ -860,7 +862,7 @@ var Le = /* @__PURE__ */ n({
860
862
  509: "Bandwidth Limit Exceeded",
861
863
  510: "Not Extended",
862
864
  511: "Network Authentication Required"
863
- }, Ye = new Set([
865
+ }, Xe = new Set([
864
866
  "content-type",
865
867
  "content-length",
866
868
  "user-agent",
@@ -879,18 +881,18 @@ var Le = /* @__PURE__ */ n({
879
881
  "server",
880
882
  "age",
881
883
  "expires"
882
- ]), H = 13, U = 10, Xe = /^[\^_`a-zA-Z\-0-9!#$%&'*+.|~]+$/, W = (e, t) => (e.code = t, e), Ze = (e, t) => {
884
+ ]), H = 13, U = 10, Ze = /^[\^_`a-zA-Z\-0-9!#$%&'*+.|~]+$/, W = (e, t) => (e.code = t, e), Qe = (e, t) => {
883
885
  if (e.length === 0) return t;
884
886
  if (t.length === 0) return e;
885
887
  let n = new Uint8Array(e.length + t.length);
886
888
  return n.set(e, 0), n.set(t, e.length), n;
887
- }, Qe = (e, t) => {
889
+ }, G = (e, t) => {
888
890
  for (let n = t; n + 1 < e.length; n++) if (e[n] === H && e[n + 1] === U) return n;
889
891
  return -1;
890
892
  }, $e = (e) => {
891
893
  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
894
  return -1;
893
- }, G = class {
895
+ }, K = class {
894
896
  buf = new Uint8Array();
895
897
  state = "HEAD";
896
898
  framing = "none";
@@ -901,7 +903,7 @@ var Le = /* @__PURE__ */ n({
901
903
  this.mode = e, this.handlers = t;
902
904
  }
903
905
  execute(e) {
904
- this.buf = Ze(this.buf, e);
906
+ this.buf = Qe(this.buf, e);
905
907
  let t = !0;
906
908
  for (; t;) if (t = !1, this.state === "HEAD") {
907
909
  let e = $e(this.buf);
@@ -919,7 +921,7 @@ var Le = /* @__PURE__ */ n({
919
921
  this.state = "HEAD", this.framing = "none", this.bodyRemaining = 0, this.chunkState = "size", this.skipBody = !1;
920
922
  }
921
923
  parseHead(e) {
922
- let t = qe.decode(e).split("\r\n"), n = t.shift() ?? "", r = [];
924
+ let t = Je.decode(e).split("\r\n"), n = t.shift() ?? "", r = [];
923
925
  for (let e of t) (e.startsWith(" ") || e.startsWith(" ")) && r.length > 0 ? r[r.length - 1] += " " + e.trim() : r.push(e);
924
926
  let i = [], a = {};
925
927
  for (let e of r) {
@@ -957,7 +959,7 @@ var Le = /* @__PURE__ */ n({
957
959
  return;
958
960
  }
959
961
  let i = e[r];
960
- i === void 0 ? e[r] = n : Ye.has(r) || (e[r] = `${i}, ${n}`);
962
+ i === void 0 ? e[r] = n : Xe.has(r) || (e[r] = `${i}, ${n}`);
961
963
  }
962
964
  setupBody(e) {
963
965
  if (this.skipBody) {
@@ -990,9 +992,9 @@ var Le = /* @__PURE__ */ n({
990
992
  }
991
993
  consumeChunked() {
992
994
  for (;;) if (this.chunkState === "size") {
993
- let e = Qe(this.buf, 0);
995
+ let e = G(this.buf, 0);
994
996
  if (e === -1) return !1;
995
- let t = qe.decode(this.buf.subarray(0, e)), n = parseInt(t.split(";")[0].trim(), 16);
997
+ let t = Je.decode(this.buf.subarray(0, e)), n = parseInt(t.split(";")[0].trim(), 16);
996
998
  if (this.buf = this.buf.subarray(e + 2), Number.isNaN(n)) return !0;
997
999
  n === 0 ? this.chunkState = "trailer" : (this.bodyRemaining = n, this.chunkState = "data");
998
1000
  } else if (this.chunkState === "data") {
@@ -1003,13 +1005,13 @@ var Le = /* @__PURE__ */ n({
1003
1005
  if (this.buf.length < 2) return !1;
1004
1006
  this.buf = this.buf.subarray(2), this.chunkState = "size";
1005
1007
  } else {
1006
- let e = Qe(this.buf, 0);
1008
+ let e = G(this.buf, 0);
1007
1009
  if (e === -1) return !1;
1008
1010
  let t = e === 0;
1009
1011
  if (this.buf = this.buf.subarray(e + 2), t) return !0;
1010
1012
  }
1011
1013
  }
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 {
1014
+ }, et = (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
1015
  httpVersion = "1.1";
1014
1016
  httpVersionMajor = 1;
1015
1017
  httpVersionMinor = 1;
@@ -1044,7 +1046,7 @@ var Le = /* @__PURE__ */ n({
1044
1046
  _bodyWritten = !1;
1045
1047
  setHeader(e, t) {
1046
1048
  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");
1049
+ if (typeof e != "string" || !Ze.test(e)) throw W(/* @__PURE__ */ TypeError(`Header name must be a valid HTTP token [${JSON.stringify(String(e))}]`), "ERR_INVALID_HTTP_TOKEN");
1048
1050
  if (t === void 0) throw W(/* @__PURE__ */ TypeError(`Invalid value "undefined" for header "${e}"`), "ERR_HTTP_INVALID_HEADER_VALUE");
1049
1051
  return this._headerStore.set(e.toLowerCase(), [e, Array.isArray(t) ? [...t] : t]), this;
1050
1052
  }
@@ -1085,7 +1087,7 @@ var Le = /* @__PURE__ */ n({
1085
1087
  return this._bodyWritten = !0, super.write(e, t, n);
1086
1088
  }
1087
1089
  _write(e, t, n) {
1088
- let r = K(e), i = [];
1090
+ let r = et(e), i = [];
1089
1091
  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
1092
  n();
1091
1093
  return;
@@ -1103,7 +1105,7 @@ var Le = /* @__PURE__ */ n({
1103
1105
  end(e, t, n) {
1104
1106
  if (e != null && typeof e != "function" && !this._bodyWritten && !this.headersSent && !this.chunkedEncoding && !this.hasHeader("content-length")) {
1105
1107
  let n = typeof t == "string" ? t : void 0;
1106
- this.setHeader("Content-Length", K(e, n).length);
1108
+ this.setHeader("Content-Length", et(e, n).length);
1107
1109
  }
1108
1110
  return super.end(e, t, n);
1109
1111
  }
@@ -1152,7 +1154,7 @@ var Le = /* @__PURE__ */ n({
1152
1154
  setTimeout(e, t) {
1153
1155
  return this.socket?.setTimeout(e, t), this;
1154
1156
  }
1155
- }, et = (...e) => {
1157
+ }, tt = (...e) => {
1156
1158
  let t = {}, n = {}, r, i = [...e], a = i.shift();
1157
1159
  if (typeof a == "string" || a instanceof URL) {
1158
1160
  let e = typeof a == "string" ? new URL(a) : a;
@@ -1212,7 +1214,7 @@ var Le = /* @__PURE__ */ n({
1212
1214
  this._headBlock = this._storeHeader(`${this.method} ${this.path} HTTP/1.1`);
1213
1215
  }
1214
1216
  _attachResponseParser() {
1215
- let e = new q(this.socket), t = new G("response", {
1217
+ let e = new q(this.socket), t = new K("response", {
1216
1218
  onHeaders: (n) => {
1217
1219
  e._applyHead(n), this.method === "HEAD" && (t.skipBody = !0), this.res = e, this.emit("response", e);
1218
1220
  },
@@ -1262,7 +1264,7 @@ var Le = /* @__PURE__ */ n({
1262
1264
  typeof e == "function" ? r = e : e && (n = e), super(n), r && this.on("request", r), this.on("connection", (e) => this._handleConnection(e));
1263
1265
  }
1264
1266
  _handleConnection(e) {
1265
- let t = null, n = new G("request", {
1267
+ let t = null, n = new K("request", {
1266
1268
  onHeaders: (r) => {
1267
1269
  t = new q(e), t._applyHead(r), r.method === "HEAD" && (n.skipBody = !0);
1268
1270
  let i = new Y(t), a = String(r.headers.connection ?? "").toLowerCase();
@@ -1293,25 +1295,25 @@ var Le = /* @__PURE__ */ n({
1293
1295
  return `${e.host ?? "localhost"}:${e.port ?? ""}:${e.localAddress ?? ""}`;
1294
1296
  }
1295
1297
  destroy() {}
1296
- }, tt = new Q(), $ = (...e) => {
1297
- let { options: t, callback: n } = et(...e);
1298
+ }, nt = new Q(), $ = (...e) => {
1299
+ let { options: t, callback: n } = tt(...e);
1298
1300
  return new X(t, n);
1299
- }, nt = (...e) => {
1301
+ }, rt = (...e) => {
1300
1302
  let t = $(...e);
1301
1303
  return t.end(), t;
1302
- }, rt = (e, t) => new Z(e, t), it = {
1303
- METHODS: Je,
1304
+ }, it = (e, t) => new Z(e, t), at = {
1305
+ METHODS: Ye,
1304
1306
  STATUS_CODES: V,
1305
1307
  Agent: Q,
1306
- globalAgent: tt,
1308
+ globalAgent: nt,
1307
1309
  Server: Z,
1308
1310
  ServerResponse: Y,
1309
1311
  IncomingMessage: q,
1310
1312
  ClientRequest: X,
1311
1313
  OutgoingMessage: J,
1312
- createServer: rt,
1314
+ createServer: it,
1313
1315
  request: $,
1314
- get: nt
1316
+ get: rt
1315
1317
  };
1316
1318
  //#endregion
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 };
1319
+ export { k as ATTACH_FRAME_EVENT_KEY, j as assertAttachableFrameUrl, Ne as attachFrame, je as attachFramePermission, l as box, De as cookies, e as createVideoElementHandle, Ue as dgram, S as extension, Te as fetch, Se as fetchCredentialedPermission, xe as fetchPermission, Me as gotoPermission, i as handleRevivableModules, qe as http, A as isBlockedFrameUrl, C as isExtensionExposed, t as isType, Oe as modifyRequestHeadersPermission, Re as net, Pe as permissions, M as promptInstall, Ee as readCookiePermission, _e as relayWorker, Ae as removeRequestHeaderRule, o as revive, he as serverProxyFetch, T as setMissingExtensionHandler, ke as setRequestHeaderRule, a as type, E as waitForExtensionExposure };