@fkn/lib 0.4.7 → 0.4.8

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,69 +1,69 @@
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-CzKO_aEl.js";
2
- import { t as u } from "./connect-button-yKMuFxR9.js";
3
- import { createTypedEventTarget as ee, expose as te, relay as ne } from "osra";
4
- import { Stream as d } from "stream";
5
- import { EventEmitter as re } from "events";
6
- import { Address4 as f, Address6 as p } from "ip-address";
7
- import { Buffer as m } from "buffer";
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-Q5m8i40Z.js";
2
+ import { createTypedEventTarget as u, expose as d, relay as ee } from "osra";
3
+ import { Stream as f } from "stream";
4
+ import { EventEmitter as te } from "events";
5
+ import { Address4 as p, Address6 as m } from "ip-address";
6
+ import { Buffer as h } from "buffer";
7
+ import { createElement as ne } from "react";
8
8
  //#region node_modules/@mfkn/web-extension/lib/utils/extension.js
9
- var ie = "FKN_WEB_EXTENSION_MAIN_WORLD_CONTENT_SCRIPT_ENABLED_EVENT_KEY", ae = "fknExtension", h = ee();
10
- typeof document < "u" && document.addEventListener(ie, (e) => {
11
- h.dispatchEvent(new CustomEvent("statuschange", { detail: { enabled: e.detail.enabled } }));
9
+ var re = "FKN_WEB_EXTENSION_MAIN_WORLD_CONTENT_SCRIPT_ENABLED_EVENT_KEY", ie = "fknExtension", g = u();
10
+ typeof document < "u" && document.addEventListener(re, () => {
11
+ g.dispatchEvent(new CustomEvent("statuschange", { detail: { enabled: _() } }));
12
12
  });
13
- var g = () => typeof document > "u" ? !1 : document.documentElement.dataset[ae] === "true", _ = null, v = (e) => {
14
- _ = e;
15
- }, oe = 150, y = (e = 1e3) => new Promise((t, n) => {
16
- if (g()) return t();
13
+ var _ = () => typeof document > "u" ? !1 : document.documentElement.dataset[ie] === "true", v = null, y = (e) => {
14
+ v = e;
15
+ }, ae = 150, b = (e = 1e3) => new Promise((t, n) => {
16
+ if (_()) return t();
17
17
  let r, i = (e) => {
18
18
  clearTimeout(r), s.disconnect(), document.removeEventListener("readystatechange", c), e();
19
19
  }, a = () => i(async () => {
20
- if (_ && (await _().catch(() => {}), g())) return t();
20
+ if (v && (await v().catch(() => {}), _())) return t();
21
21
  n(/* @__PURE__ */ Error("The FKN WebExtension is not installed, enabled or not exposed on this page."));
22
22
  }), o = () => {
23
- clearTimeout(r), r = setTimeout(() => g() ? i(t) : a(), oe);
23
+ clearTimeout(r), r = setTimeout(() => _() ? i(t) : a(), ae);
24
24
  }, s = new MutationObserver(() => {
25
- g() && i(t);
25
+ _() && i(t);
26
26
  }), c = () => {
27
- document.readyState === "complete" && !g() && o();
27
+ document.readyState === "complete" && !_() && o();
28
28
  };
29
29
  if (r = setTimeout(a, e), s.observe(document.documentElement, {
30
30
  attributes: !0,
31
31
  attributeFilter: ["data-fkn-extension"]
32
32
  }), document.addEventListener("readystatechange", c), document.readyState === "complete") return o();
33
- g() && i(t);
34
- }), se, b = new Proxy({}, { get: (e, t) => async (...e) => {
35
- await y(), se ??= te({}, {
33
+ _() && i(t);
34
+ }), oe, x = new Proxy({}, { get: (e, t) => async (...e) => {
35
+ await b(), oe ??= d({}, {
36
36
  transport: window,
37
37
  revivableModules: i
38
38
  });
39
- let n = (await se)[t];
39
+ let n = (await oe)[t];
40
40
  return n(...e);
41
- } }), ce = {
41
+ } }), se = {
42
42
  scope: "network.fetch",
43
43
  category: "network",
44
44
  severity: 0,
45
45
  title: "Fetch data from other sites",
46
46
  description: "Lets the app download public data from other websites directly, past the usual cross-origin limits."
47
- }, le = {
47
+ }, ce = {
48
48
  scope: "network.fetchCredentialed",
49
49
  category: "network",
50
50
  severity: 3,
51
51
  unsafe: !0,
52
52
  title: "Fetch from other sites, signed in as you",
53
53
  description: "Lets the app fetch other sites using your logged-in session cookies, so it can read data only you should see."
54
- }, ue = {
54
+ }, le = {
55
55
  scope: "network.fetchLocal",
56
56
  category: "network",
57
57
  severity: 3,
58
58
  unsafe: !0,
59
59
  title: "Access devices on your local network",
60
60
  description: "Lets the app reach devices and services on your home or work network, which websites normally cannot touch."
61
- }, de = (e) => {
61
+ }, ue = (e) => {
62
62
  let t = e.match(/^(\d+)\.(\d+)\.\d+\.\d+$/);
63
63
  if (!t) return !1;
64
64
  let [n, r] = [Number(t[1]), Number(t[2])];
65
65
  return n === 10 || n === 127 || n === 0 || n === 169 && r === 254 || n === 172 && r >= 16 && r <= 31 || n === 192 && r === 168;
66
- }, fe = (e) => {
66
+ }, de = (e) => {
67
67
  let t;
68
68
  try {
69
69
  t = new URL(e);
@@ -71,8 +71,8 @@ var g = () => typeof document > "u" ? !1 : document.documentElement.dataset[ae]
71
71
  return !1;
72
72
  }
73
73
  let n = t.hostname.replace(/^\[|\]$/g, "").toLowerCase().replace(/\.$/, "");
74
- return n === "localhost" || n.endsWith(".localhost") || n.endsWith(".local") || n.endsWith(".internal") || n.endsWith(".home.arpa") ? !0 : n.includes(":") ? n === "::" || n === "::1" || n.startsWith("fc") || n.startsWith("fd") || /^fe[89ab]/.test(n) || n.startsWith("::ffff:") : de(n);
75
- }, pe = ["fkn.app", "fkn.dev"], x = (e) => {
74
+ return n === "localhost" || n.endsWith(".localhost") || n.endsWith(".local") || n.endsWith(".internal") || n.endsWith(".home.arpa") ? !0 : n.includes(":") ? n === "::" || n === "::1" || n.startsWith("fc") || n.startsWith("fd") || /^fe[89ab]/.test(n) || n.startsWith("::ffff:") : ue(n);
75
+ }, fe = ["fkn.app", "fkn.dev"], S = (e) => {
76
76
  let t;
77
77
  try {
78
78
  t = new URL(e);
@@ -81,28 +81,28 @@ var g = () => typeof document > "u" ? !1 : document.documentElement.dataset[ae]
81
81
  }
82
82
  if (t.protocol === "chrome-extension:" || t.protocol === "moz-extension:") return !0;
83
83
  let n = t.hostname;
84
- return pe.some((e) => n === e || n.endsWith(`.${e}`));
85
- }, S = (e) => {
86
- if (x(e)) throw Error("fetch: refusing to target the extension's own pages or FKN platform domains");
87
- }, me = ["origin", "referer"], he = (e) => {
84
+ return fe.some((e) => n === e || n.endsWith(`.${e}`));
85
+ }, C = (e) => {
86
+ if (S(e)) throw Error("fetch: refusing to target the extension's own pages or FKN platform domains");
87
+ }, pe = ["origin", "referer"], me = (e) => {
88
88
  if (!e?.headers) return;
89
- let t = new Headers(e.headers), n = me.map((e) => {
89
+ let t = new Headers(e.headers), n = pe.map((e) => {
90
90
  let n = t.get(e);
91
91
  return n === null ? void 0 : [e, n];
92
92
  }).filter((e) => e !== void 0);
93
93
  return n.length ? n : void 0;
94
- }, C = async (e, t) => {
94
+ }, he = async (e, t) => {
95
95
  let n = new Request(e, t);
96
- S(n.url);
96
+ C(n.url);
97
97
  let r = n.body ? await n.arrayBuffer() : null;
98
- return b.proxyFetch({
98
+ return x.proxyFetch({
99
99
  url: n.url,
100
100
  method: n.method,
101
101
  headers: [...n.headers],
102
102
  body: r,
103
103
  credentials: t?.credentials === "include" ? "include" : "omit",
104
104
  redirect: n.redirect,
105
- unsafeHeaders: he(t),
105
+ unsafeHeaders: me(t),
106
106
  reason: t?.reason,
107
107
  signal: t?.signal ?? void 0
108
108
  });
@@ -113,14 +113,14 @@ var g = () => typeof document > "u" ? !1 : document.documentElement.dataset[ae]
113
113
  unsafe: !0,
114
114
  title: "Read a site’s cookie",
115
115
  description: "Lets the app read a named cookie from another site, which can include the login token only that site should see."
116
- }, _e = { get: (e) => b.getCookie(e) }, ve = {
116
+ }, _e = { get: (e) => x.getCookie(e) }, ve = {
117
117
  scope: "network.modifyRequestHeaders",
118
118
  category: "network",
119
119
  severity: 2,
120
120
  unsafe: !0,
121
121
  title: "Rewrite request headers to other sites",
122
122
  description: "Lets the app set or remove headers (like Origin and Referer) on this page’s own requests to the listed sites."
123
- }, ye = (e) => b.setRequestHeaderRule(e), be = (e) => b.removeRequestHeaderRule({ ruleId: e });
123
+ }, ye = (e) => x.setRequestHeaderRule(e), be = (e) => x.removeRequestHeaderRule({ ruleId: e });
124
124
  (() => {
125
125
  let e = {}, t = [...c.selectorModules, ...r.selectorModules];
126
126
  for (let n of t) n.render && !(n.type in e) && (e[n.type] = n.render);
@@ -154,38 +154,47 @@ var w = "FKN_WEB_EXTENSION_ATTACH_FRAME_EVENT_KEY", T = (e) => {
154
154
  severity: 0,
155
155
  title: "Open a website inside this app",
156
156
  description: "Lets the app navigate to another site without leaving its window."
157
- }, Ce = async ({ iframe: e, domains: t = [] }) => {
158
- let n = crypto.randomUUID();
159
- if (E(e.src), await y(), !e.isConnected) throw Error("attachFrame: the iframe must be connected to the document before attaching");
160
- e.dispatchEvent(new CustomEvent(w, { detail: n }));
161
- let { executeLocator: r, ensureLocatorPermission: i, goto: a } = await b.attachFrame({
162
- marker: n,
163
- domains: t
164
- }), o = s(r, i), c = (e, t = {}) => (E(e), a({
157
+ }, Ce = {
158
+ scope: "embed.evaluate",
159
+ category: "embed",
160
+ severity: 0,
161
+ title: "Run app code inside an embedded frame",
162
+ description: "Lets the app execute its own code inside a page it embedded, to read back a computed result."
163
+ }, we = async ({ iframe: e, domains: t = [], syncCookies: n = !0, lockdown: r = !1 }) => {
164
+ let i = crypto.randomUUID();
165
+ if (E(e.src), await b(), !e.isConnected) throw Error("attachFrame: the iframe must be connected to the document before attaching");
166
+ e.dispatchEvent(new CustomEvent(w, { detail: i }));
167
+ let { executeLocator: a, ensureLocatorPermission: o, goto: c, evaluate: l } = await x.attachFrame({
168
+ marker: i,
169
+ domains: t,
170
+ syncCookies: n,
171
+ lockdown: r
172
+ }), u = s(a, o), d = (e, t = {}) => (E(e), c({
165
173
  url: e,
166
174
  ...t
167
- })), l = () => e.src;
175
+ })), ee = ((e, t) => l(e, t)), f = () => e.src;
168
176
  return {
169
- ...o,
170
- goto: c,
171
- url: l
177
+ ...u,
178
+ goto: d,
179
+ evaluate: ee,
180
+ url: f
172
181
  };
173
- }, we = { request: (e) => b.requestPermissions(e.map((e) => ({
182
+ }, Te = { request: (e) => x.requestPermissions(e.map((e) => ({
174
183
  key: e.key,
175
184
  scope: e.scope ?? "",
176
185
  reason: e.reason
177
- }))) }, Te = 32, Ee = typeof CSS < "u" && CSS.supports("clip-path", "path('M0 0H1V1H0Z')"), De = (e) => {
186
+ }))) }, Ee = 32, De = typeof CSS < "u" && CSS.supports("clip-path", "path('M0 0H1V1H0Z')"), Oe = (e) => {
178
187
  let t = e.style;
179
188
  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");
180
- }, Oe = ({ x: e, y: t, width: n, height: r }) => `M${e} ${t}h${n}v${r}h${-n}Z`, ke = (e, { modal: t, rects: n }) => {
181
- if (!Ee) {
189
+ }, ke = ({ x: e, y: t, width: n, height: r }) => `M${e} ${t}h${n}v${r}h${-n}Z`, Ae = (e, { modal: t, rects: n }) => {
190
+ if (!De) {
182
191
  let r = t || n.length > 0;
183
192
  e.style.setProperty("pointer-events", r ? "auto" : "none", "important"), e.style.setProperty("visibility", r ? "visible" : "hidden", "important");
184
193
  return;
185
194
  }
186
- 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%)";
195
+ let r = t ? "none" : n.length === 0 ? "inset(100%)" : `path('${n.map(ke).join("")}')`, i = r === "none" || CSS.supports("clip-path", r) ? r : "inset(100%)";
187
196
  e.style.setProperty("clip-path", i, "important");
188
- }, Ae = (e) => {
197
+ }, je = (e) => {
189
198
  if (typeof e != "object" || !e) return null;
190
199
  let { x: t, y: n, width: r, height: i } = e;
191
200
  if (![
@@ -201,45 +210,45 @@ var w = "FKN_WEB_EXTENSION_ATTACH_FRAME_EVENT_KEY", T = (e) => {
201
210
  width: l - s,
202
211
  height: u - c
203
212
  };
204
- }, je = (e) => {
213
+ }, Me = (e) => {
205
214
  if (typeof e != "object" || !e) return null;
206
- let t = e, n = (Array.isArray(t.rects) ? t.rects.slice(0, Te) : []).map(Ae).filter((e) => e !== null && e.width > 0 && e.height > 0);
215
+ let t = e, n = (Array.isArray(t.rects) ? t.rects.slice(0, Ee) : []).map(je).filter((e) => e !== null && e.width > 0 && e.height > 0);
207
216
  return {
208
217
  modal: t.modal === !0,
209
218
  rects: n
210
219
  };
211
- }, D = null, Me = () => D !== null, Ne = (e) => {
212
- De(e), ke(e, {
220
+ }, D = null, Ne = () => D !== null, Pe = (e) => {
221
+ Oe(e), Ae(e, {
213
222
  modal: !1,
214
223
  rects: []
215
224
  }), D = e;
216
- }, Pe = (e) => {
225
+ }, Fe = (e) => {
217
226
  if (!D) return;
218
- let t = je(e);
219
- t && ke(D, t);
220
- }, Fe = "https://fkn.app", O = typeof globalThis < "u" && globalThis.document ? globalThis.document : void 0, Ie = O?.querySelector(`iframe[src="${Fe}/api"]`) ?? null, k = O?.createElement("iframe") ?? null;
221
- !Ie && k && O && (k.src = `${Fe}/api`, O.body.appendChild(k));
222
- var A = Ie ?? k, Le = A?.contentWindow ?? null;
223
- A && O && Ne(A);
227
+ let t = Me(e);
228
+ t && Ae(D, t);
229
+ }, Ie = "https://fkn.app", O = typeof globalThis < "u" && globalThis.document ? globalThis.document : void 0, Le = O?.querySelector(`iframe[src="${Ie}/api"]`) ?? null, k = O?.createElement("iframe") ?? null;
230
+ !Le && k && O && (k.src = `${Ie}/api`, O.body.appendChild(k));
231
+ var A = Le ?? k, Re = A?.contentWindow ?? null;
232
+ A && O && Pe(A);
224
233
  var j = (() => {
225
- if (typeof window < "u") return Le ? {
234
+ if (typeof window < "u") return Re ? {
226
235
  receive: window,
227
- emit: Le
236
+ emit: Re
228
237
  } : void 0;
229
238
  if (typeof self < "u") return {
230
239
  receive: self,
231
240
  emit: self
232
241
  };
233
- })(), Re = j !== void 0, M = j ? te({}, {
242
+ })(), ze = j !== void 0, M = j ? d({}, {
234
243
  key: "fkn-api",
235
244
  transport: j
236
245
  }) : new Promise(() => {});
237
246
  M.then((e) => {
238
- Me() && e.overlay.setHost(Pe);
247
+ Ne() && e.overlay.setHost(Fe);
239
248
  }, () => {});
240
249
  //#endregion
241
250
  //#region src/lib/fkn-target.ts
242
- var ze = ["fkn.app", "fkn.dev"], Be = (e) => {
251
+ var Be = ["fkn.app", "fkn.dev"], Ve = (e) => {
243
252
  let t = typeof e == "string" ? e : e instanceof URL ? e.href : e.url, n;
244
253
  try {
245
254
  n = new URL(t);
@@ -247,8 +256,8 @@ var ze = ["fkn.app", "fkn.dev"], Be = (e) => {
247
256
  return;
248
257
  }
249
258
  let r = n.hostname;
250
- if (ze.some((e) => r === e || r.endsWith(`.${e}`))) throw Error(`fetch refuses FKN platform domains (${r})`);
251
- }, Ve = (e, t) => (Be(e), M.then((n) => n.cloud.fetch(e, t))), He = async () => {
259
+ if (Be.some((e) => r === e || r.endsWith(`.${e}`))) throw Error(`fetch refuses FKN platform domains (${r})`);
260
+ }, He = (e, t) => (Ve(e), M.then((n) => n.cloud.fetch(e, t))), Ue = async () => {
252
261
  let e = await M.then((e) => e.cloud.quota());
253
262
  return {
254
263
  premium: e.premium,
@@ -260,9 +269,9 @@ var ze = ["fkn.app", "fkn.dev"], Be = (e) => {
260
269
  bytesPerSecond: e.bytesPerSecond,
261
270
  bitsPerSecond: e.bytesPerSecond * 8
262
271
  };
263
- }, Ue = /* @__PURE__ */ n({ lookup: () => We }), We = (e, t) => M.then((n) => n.cloud.dns.lookup(e, t)), Ge = new TextEncoder();
272
+ }, We = /* @__PURE__ */ n({ lookup: () => Ge }), Ge = (e, t) => M.then((n) => n.cloud.dns.lookup(e, t)), Ke = new TextEncoder();
264
273
  new TextDecoder();
265
- var N = (e) => f.isValid(e), P = (e) => p.isValid(e), Ke = (e) => N(e) ? 4 : P(e) ? 6 : 0, qe = (...e) => {
274
+ var N = (e) => p.isValid(e), P = (e) => m.isValid(e), qe = (e) => N(e) ? 4 : P(e) ? 6 : 0, Je = (...e) => {
266
275
  if (typeof e[0] == "string") throw Error("FKN WebVPN does not support IPC connections");
267
276
  let t = typeof e.at(-1) == "function" ? e.at(-1) : void 0;
268
277
  return e[0] && typeof e[0] == "object" ? {
@@ -273,7 +282,7 @@ var N = (e) => f.isValid(e), P = (e) => p.isValid(e), Ke = (e) => N(e) ? 4 : P(e
273
282
  host: typeof e[1] == "string" ? e[1] : void 0,
274
283
  callback: t
275
284
  };
276
- }, Je = (...e) => {
285
+ }, Ye = (...e) => {
277
286
  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;
278
287
  return typeof e[0] == "object" ? {
279
288
  ...e[0],
@@ -285,7 +294,7 @@ var N = (e) => f.isValid(e), P = (e) => p.isValid(e), Ke = (e) => N(e) ? 4 : P(e
285
294
  port: n,
286
295
  callback: t
287
296
  };
288
- }, Ye = (...e) => {
297
+ }, Xe = (...e) => {
289
298
  let t = typeof e.at(-1) == "function" ? e.at(-1) : void 0, n = e[0];
290
299
  if (typeof e[2] == "number") return {
291
300
  message: n,
@@ -310,18 +319,18 @@ var N = (e) => f.isValid(e), P = (e) => p.isValid(e), Ke = (e) => N(e) ? 4 : P(e
310
319
  new TextEncoder(), new TextDecoder();
311
320
  //#endregion
312
321
  //#region src/lib/webvpn/net.ts
313
- var Xe = /* @__PURE__ */ n({
322
+ var Ze = /* @__PURE__ */ n({
314
323
  Server: () => I,
315
324
  Socket: () => F,
316
- _default: () => et,
317
- connect: () => Ze,
318
- createConnection: () => Qe,
319
- createServer: () => $e,
320
- default: () => et,
321
- isIP: () => Ke,
325
+ _default: () => tt,
326
+ connect: () => Qe,
327
+ createConnection: () => $e,
328
+ createServer: () => et,
329
+ default: () => tt,
330
+ isIP: () => qe,
322
331
  isIPv4: () => N,
323
332
  isIPv6: () => P
324
- }), F = class extends d.Duplex {
333
+ }), F = class extends f.Duplex {
325
334
  _localAddress;
326
335
  _remoteAddress;
327
336
  _webVPNTcpSocketPromise;
@@ -381,7 +390,7 @@ var Xe = /* @__PURE__ */ n({
381
390
  }).catch(n);
382
391
  }
383
392
  connect(...e) {
384
- let t = qe(...e), n = this.__webvpn_tcp_socket_init__(M.then((e) => e.cloud.webvpn.tcpSocket({
393
+ let t = Je(...e), n = this.__webvpn_tcp_socket_init__(M.then((e) => e.cloud.webvpn.tcpSocket({
385
394
  remoteAddress: t.host ?? "localhost",
386
395
  remotePort: t.port
387
396
  })));
@@ -508,7 +517,7 @@ var Xe = /* @__PURE__ */ n({
508
517
  return this._remoteAddress.family;
509
518
  }
510
519
  timeout;
511
- }, I = class extends re {
520
+ }, I = class extends te {
512
521
  _localAddress;
513
522
  _webVPNTcpSocketListenerPromise;
514
523
  constructor(e, t) {
@@ -526,7 +535,7 @@ var Xe = /* @__PURE__ */ n({
526
535
  }), this._webVPNTcpSocketListenerPromise;
527
536
  }
528
537
  listen(...e) {
529
- let t = qe(...e), n = (e) => {
538
+ let t = Je(...e), n = (e) => {
530
539
  let t = new F({ connection: Promise.resolve(e) });
531
540
  this.emit("connection", t);
532
541
  }, r = (e) => M.then((r) => r.cloud.webvpn.tcpSocketListener({
@@ -563,23 +572,23 @@ var Xe = /* @__PURE__ */ n({
563
572
  connections;
564
573
  listening;
565
574
  async [Symbol.asyncDispose]() {}
566
- }, Ze = (e, t) => new F().connect(e, t), Qe = (e, t) => new F().connect(e, t), $e = (e, t) => {
575
+ }, Qe = (e, t) => new F().connect(e, t), $e = (e, t) => new F().connect(e, t), et = (e, t) => {
567
576
  typeof e == "function" && (t = e, e = void 0);
568
577
  let n = new I(e);
569
578
  return t && n.on("connection", t), n;
570
- }, et = {
579
+ }, tt = {
571
580
  Socket: F,
572
581
  Server: I,
573
- connect: Ze,
574
- createConnection: Qe,
575
- createServer: $e,
576
- isIP: Ke,
582
+ connect: Qe,
583
+ createConnection: $e,
584
+ createServer: et,
585
+ isIP: qe,
577
586
  isIPv4: N,
578
587
  isIPv6: P
579
- }, tt = /* @__PURE__ */ n({
580
- Socket: () => nt,
581
- createSocket: () => at
582
- }), nt = class extends re {
588
+ }, nt = /* @__PURE__ */ n({
589
+ Socket: () => rt,
590
+ createSocket: () => ot
591
+ }), rt = class extends te {
583
592
  _type;
584
593
  _localAddress;
585
594
  _remoteAddress;
@@ -640,7 +649,7 @@ var Xe = /* @__PURE__ */ n({
640
649
  a += n.byteLength, l = t.getUint16(a), a += 2;
641
650
  }
642
651
  let u = t.getUint32(a);
643
- a += 4, this.emit("message", m.from(e.slice(a, a + u)), {
652
+ a += 4, this.emit("message", h.from(e.slice(a, a + u)), {
644
653
  address: s,
645
654
  family: c,
646
655
  port: l,
@@ -649,10 +658,10 @@ var Xe = /* @__PURE__ */ n({
649
658
  }
650
659
  }
651
660
  _peerTail(e, t) {
652
- if (e === void 0 || t === void 0) return rt;
661
+ if (e === void 0 || t === void 0) return it;
653
662
  let n = `${e}|${t}`, r = this._peerTailCache.get(n);
654
663
  if (r) return r;
655
- let i = f.isValid(e) ? L(e) : R(e), a = new Uint8Array(1 + i.byteLength + 2);
664
+ let i = p.isValid(e) ? L(e) : R(e), a = new Uint8Array(1 + i.byteLength + 2);
656
665
  return a[0] = i.byteLength === 4 ? 0 : 1, a.set(i, 1), new DataView(a.buffer).setUint16(1 + i.byteLength, t), this._peerTailCache.set(n, a), a;
657
666
  }
658
667
  _portSend(e, t, n) {
@@ -667,8 +676,8 @@ var Xe = /* @__PURE__ */ n({
667
676
  }));
668
677
  }
669
678
  addMembership(e, t) {
670
- if (f.isValid(e)) {
671
- let n = L(e), r = t && f.isValid(t) ? L(t) : new Uint8Array([
679
+ if (p.isValid(e)) {
680
+ let n = L(e), r = t && p.isValid(t) ? L(t) : new Uint8Array([
672
681
  0,
673
682
  0,
674
683
  0,
@@ -679,7 +688,7 @@ var Xe = /* @__PURE__ */ n({
679
688
  group: n,
680
689
  interface: r
681
690
  });
682
- } else if (p.isValid(e)) {
691
+ } else if (m.isValid(e)) {
683
692
  let t = R(e);
684
693
  this._setUdpOption({
685
694
  type: 7,
@@ -693,7 +702,7 @@ var Xe = /* @__PURE__ */ n({
693
702
  return this._localAddress;
694
703
  }
695
704
  bind(...e) {
696
- let t = Je(...e), n = this._type === "udp6" ? "::" : "0.0.0.0";
705
+ let t = Ye(...e), n = this._type === "udp6" ? "::" : "0.0.0.0";
697
706
  return this._webVPNUdpSocketPromise = M.then((e) => e.cloud.webvpn.udpSocket({
698
707
  type: this._type,
699
708
  address: t.address ?? n,
@@ -704,7 +713,7 @@ var Xe = /* @__PURE__ */ n({
704
713
  else {
705
714
  let t = e.dataReadableStream.getReader(), n = async () => {
706
715
  let { value: e, done: r } = await t.read();
707
- r || (this.emit("message", m.from(e.data), {
716
+ r || (this.emit("message", h.from(e.data), {
708
717
  address: e.address,
709
718
  family: e.family,
710
719
  port: e.port,
@@ -759,8 +768,8 @@ var Xe = /* @__PURE__ */ n({
759
768
  });
760
769
  }
761
770
  dropMembership(e, t) {
762
- if (f.isValid(e)) {
763
- let n = L(e), r = t && f.isValid(t) ? L(t) : new Uint8Array([
771
+ if (p.isValid(e)) {
772
+ let n = L(e), r = t && p.isValid(t) ? L(t) : new Uint8Array([
764
773
  0,
765
774
  0,
766
775
  0,
@@ -771,7 +780,7 @@ var Xe = /* @__PURE__ */ n({
771
780
  group: n,
772
781
  interface: r
773
782
  });
774
- } else if (p.isValid(e)) {
783
+ } else if (m.isValid(e)) {
775
784
  let t = R(e);
776
785
  this._setUdpOption({
777
786
  type: 8,
@@ -805,12 +814,12 @@ var Xe = /* @__PURE__ */ n({
805
814
  }
806
815
  send(...e) {
807
816
  this._webVPNUdpSocketPromise || this.bind();
808
- let t = Ye(...e), n = this._type === "udp6" ? "::1" : "127.0.0.1";
817
+ let t = Xe(...e), n = this._type === "udp6" ? "::1" : "127.0.0.1";
809
818
  if (!this._webVPNUdpSocketPromise) throw Error("Socket not bound");
810
819
  this._webVPNUdpSocketPromise.then((e) => {
811
820
  if (!e) throw Error("Socket not bound");
812
- let r = it(t.message), i = t.callback, a = t.address ?? n, o = this._remoteAddress !== void 0 && t.address === void 0;
813
- if (this._dataPort && (o || f.isValid(a) || p.isValid(a))) {
821
+ let r = at(t.message), i = t.callback, a = t.address ?? n, o = this._remoteAddress !== void 0 && t.address === void 0;
822
+ if (this._dataPort && (o || p.isValid(a) || m.isValid(a))) {
814
823
  this._portSend(r, o ? void 0 : a, o ? void 0 : t.port), i?.call(this, null, r.byteLength);
815
824
  return;
816
825
  }
@@ -871,12 +880,12 @@ var Xe = /* @__PURE__ */ n({
871
880
  this.close(e);
872
881
  });
873
882
  }
874
- }, rt = new Uint8Array([2]), it = (e) => {
875
- if (typeof e == "string") return Ge.encode(e);
883
+ }, it = new Uint8Array([2]), at = (e) => {
884
+ if (typeof e == "string") return Ke.encode(e);
876
885
  if (e instanceof Uint8Array) return e;
877
886
  if (ArrayBuffer.isView(e)) return new Uint8Array(e.buffer, e.byteOffset, e.byteLength);
878
887
  if (Array.isArray(e)) {
879
- let t = e.map(it), n = new Uint8Array(t.reduce((e, t) => e + t.byteLength, 0)), r = 0;
888
+ let t = e.map(at), n = new Uint8Array(t.reduce((e, t) => e + t.byteLength, 0)), r = 0;
880
889
  for (let e of t) n.set(e, r), r += e.byteLength;
881
890
  return n;
882
891
  }
@@ -886,28 +895,28 @@ var Xe = /* @__PURE__ */ n({
886
895
  if (t.length !== 4 || t.some((e) => Number.isNaN(e) || e < 0 || e > 255)) throw Error(`Invalid IPv4 address: ${e}`);
887
896
  return new Uint8Array(t);
888
897
  }, R = (e) => {
889
- let t = new p(e).getBitsBase16(0, 128).match(/.{2}/g);
898
+ let t = new m(e).getBitsBase16(0, 128).match(/.{2}/g);
890
899
  if (!t || t.length !== 16) throw Error(`Invalid IPv6 address: ${e}`);
891
900
  return new Uint8Array(t.map((e) => parseInt(e, 16)));
892
- }, at = (e, t) => {
893
- let n = new nt(typeof e == "string" ? { type: e } : e);
901
+ }, ot = (e, t) => {
902
+ let n = new rt(typeof e == "string" ? { type: e } : e);
894
903
  return t && n.on("message", t), n;
895
- }, ot = /* @__PURE__ */ n({
904
+ }, st = /* @__PURE__ */ n({
896
905
  Agent: () => Y,
897
906
  ClientRequest: () => q,
898
907
  HTTPParser: () => U,
899
908
  IncomingMessage: () => W,
900
- METHODS: () => ct,
909
+ METHODS: () => lt,
901
910
  STATUS_CODES: () => z,
902
911
  Server: () => J,
903
912
  ServerResponse: () => K,
904
- _default: () => yt,
905
- createServer: () => vt,
906
- default: () => yt,
907
- get: () => _t,
908
- globalAgent: () => gt,
913
+ _default: () => bt,
914
+ createServer: () => yt,
915
+ default: () => bt,
916
+ get: () => vt,
917
+ globalAgent: () => _t,
909
918
  request: () => X
910
- }), st = new TextDecoder("latin1"), ct = /* @__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("."), z = {
919
+ }), ct = new TextDecoder("latin1"), lt = /* @__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("."), z = {
911
920
  100: "Continue",
912
921
  101: "Switching Protocols",
913
922
  102: "Processing",
@@ -971,7 +980,7 @@ var Xe = /* @__PURE__ */ n({
971
980
  509: "Bandwidth Limit Exceeded",
972
981
  510: "Not Extended",
973
982
  511: "Network Authentication Required"
974
- }, lt = new Set([
983
+ }, ut = new Set([
975
984
  "content-type",
976
985
  "content-length",
977
986
  "user-agent",
@@ -990,15 +999,15 @@ var Xe = /* @__PURE__ */ n({
990
999
  "server",
991
1000
  "age",
992
1001
  "expires"
993
- ]), B = 13, V = 10, ut = /^[\^_`a-zA-Z\-0-9!#$%&'*+.|~]+$/, H = (e, t) => (e.code = t, e), dt = (e, t) => {
1002
+ ]), B = 13, V = 10, dt = /^[\^_`a-zA-Z\-0-9!#$%&'*+.|~]+$/, H = (e, t) => (e.code = t, e), ft = (e, t) => {
994
1003
  if (e.length === 0) return t;
995
1004
  if (t.length === 0) return e;
996
1005
  let n = new Uint8Array(e.length + t.length);
997
1006
  return n.set(e, 0), n.set(t, e.length), n;
998
- }, ft = (e, t) => {
1007
+ }, pt = (e, t) => {
999
1008
  for (let n = t; n + 1 < e.length; n++) if (e[n] === B && e[n + 1] === V) return n;
1000
1009
  return -1;
1001
- }, pt = (e) => {
1010
+ }, mt = (e) => {
1002
1011
  for (let t = 0; t + 3 < e.length; t++) if (e[t] === B && e[t + 1] === V && e[t + 2] === B && e[t + 3] === V) return t;
1003
1012
  return -1;
1004
1013
  }, U = class {
@@ -1012,10 +1021,10 @@ var Xe = /* @__PURE__ */ n({
1012
1021
  this.mode = e, this.handlers = t;
1013
1022
  }
1014
1023
  execute(e) {
1015
- this.buf = dt(this.buf, e);
1024
+ this.buf = ft(this.buf, e);
1016
1025
  let t = !0;
1017
1026
  for (; t;) if (t = !1, this.state === "HEAD") {
1018
- let e = pt(this.buf);
1027
+ let e = mt(this.buf);
1019
1028
  if (e === -1) return;
1020
1029
  let n = this.buf.subarray(0, e);
1021
1030
  this.buf = this.buf.subarray(e + 4);
@@ -1030,7 +1039,7 @@ var Xe = /* @__PURE__ */ n({
1030
1039
  this.state = "HEAD", this.framing = "none", this.bodyRemaining = 0, this.chunkState = "size", this.skipBody = !1;
1031
1040
  }
1032
1041
  parseHead(e) {
1033
- let t = st.decode(e).split("\r\n"), n = t.shift() ?? "", r = [];
1042
+ let t = ct.decode(e).split("\r\n"), n = t.shift() ?? "", r = [];
1034
1043
  for (let e of t) (e.startsWith(" ") || e.startsWith(" ")) && r.length > 0 ? r[r.length - 1] += " " + e.trim() : r.push(e);
1035
1044
  let i = [], a = {};
1036
1045
  for (let e of r) {
@@ -1068,7 +1077,7 @@ var Xe = /* @__PURE__ */ n({
1068
1077
  return;
1069
1078
  }
1070
1079
  let i = e[r];
1071
- i === void 0 ? e[r] = n : lt.has(r) || (e[r] = `${i}, ${n}`);
1080
+ i === void 0 ? e[r] = n : ut.has(r) || (e[r] = `${i}, ${n}`);
1072
1081
  }
1073
1082
  setupBody(e) {
1074
1083
  if (this.skipBody) {
@@ -1101,9 +1110,9 @@ var Xe = /* @__PURE__ */ n({
1101
1110
  }
1102
1111
  consumeChunked() {
1103
1112
  for (;;) if (this.chunkState === "size") {
1104
- let e = ft(this.buf, 0);
1113
+ let e = pt(this.buf, 0);
1105
1114
  if (e === -1) return !1;
1106
- let t = st.decode(this.buf.subarray(0, e)), n = parseInt(t.split(";")[0].trim(), 16);
1115
+ let t = ct.decode(this.buf.subarray(0, e)), n = parseInt(t.split(";")[0].trim(), 16);
1107
1116
  if (this.buf = this.buf.subarray(e + 2), Number.isNaN(n)) return !0;
1108
1117
  n === 0 ? this.chunkState = "trailer" : (this.bodyRemaining = n, this.chunkState = "data");
1109
1118
  } else if (this.chunkState === "data") {
@@ -1114,13 +1123,13 @@ var Xe = /* @__PURE__ */ n({
1114
1123
  if (this.buf.length < 2) return !1;
1115
1124
  this.buf = this.buf.subarray(2), this.chunkState = "size";
1116
1125
  } else {
1117
- let e = ft(this.buf, 0);
1126
+ let e = pt(this.buf, 0);
1118
1127
  if (e === -1) return !1;
1119
1128
  let t = e === 0;
1120
1129
  if (this.buf = this.buf.subarray(e + 2), t) return !0;
1121
1130
  }
1122
1131
  }
1123
- }, mt = (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)), W = class extends d.Readable {
1132
+ }, ht = (e, t) => h.isBuffer(e) ? e : typeof e == "string" ? h.from(e, t ?? "utf8") : e instanceof Uint8Array ? h.from(e) : e instanceof ArrayBuffer ? h.from(new Uint8Array(e)) : h.from(String(e)), W = class extends f.Readable {
1124
1133
  httpVersion = "1.1";
1125
1134
  httpVersionMajor = 1;
1126
1135
  httpVersionMinor = 1;
@@ -1147,7 +1156,7 @@ var Xe = /* @__PURE__ */ n({
1147
1156
  setTimeout(e, t) {
1148
1157
  return this.socket.setTimeout(e, t), this;
1149
1158
  }
1150
- }, G = class extends d.Writable {
1159
+ }, G = class extends f.Writable {
1151
1160
  _headerStore = /* @__PURE__ */ new Map();
1152
1161
  headersSent = !1;
1153
1162
  chunkedEncoding = !1;
@@ -1155,7 +1164,7 @@ var Xe = /* @__PURE__ */ n({
1155
1164
  _bodyWritten = !1;
1156
1165
  setHeader(e, t) {
1157
1166
  if (this.headersSent) throw H(/* @__PURE__ */ Error("Cannot set headers after they are sent to the client"), "ERR_HTTP_HEADERS_SENT");
1158
- if (typeof e != "string" || !ut.test(e)) throw H(/* @__PURE__ */ TypeError(`Header name must be a valid HTTP token [${JSON.stringify(String(e))}]`), "ERR_INVALID_HTTP_TOKEN");
1167
+ if (typeof e != "string" || !dt.test(e)) throw H(/* @__PURE__ */ TypeError(`Header name must be a valid HTTP token [${JSON.stringify(String(e))}]`), "ERR_INVALID_HTTP_TOKEN");
1159
1168
  if (t === void 0) throw H(/* @__PURE__ */ TypeError(`Invalid value "undefined" for header "${e}"`), "ERR_HTTP_INVALID_HEADER_VALUE");
1160
1169
  return this._headerStore.set(e.toLowerCase(), [e, Array.isArray(t) ? [...t] : t]), this;
1161
1170
  }
@@ -1196,25 +1205,25 @@ var Xe = /* @__PURE__ */ n({
1196
1205
  return this._bodyWritten = !0, super.write(e, t, n);
1197
1206
  }
1198
1207
  _write(e, t, n) {
1199
- let r = mt(e), i = [];
1200
- 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) {
1208
+ let r = ht(e), i = [];
1209
+ if (this.headersSent ||= (this._implicitHeader(), i.push(h.from(this._headBlock, "latin1")), !0), this.chunkedEncoding ? r.length > 0 && (i.push(h.from(`${r.length.toString(16)}\r\n`, "latin1")), i.push(r), i.push(h.from("\r\n", "latin1"))) : i.push(r), i.length === 0) {
1201
1210
  n();
1202
1211
  return;
1203
1212
  }
1204
- this._writeToSocket(m.concat(i), n);
1213
+ this._writeToSocket(h.concat(i), n);
1205
1214
  }
1206
1215
  _final(e) {
1207
1216
  let t = [];
1208
- 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) {
1217
+ if (this.headersSent ||= (!this.chunkedEncoding && !this.hasHeader("content-length") && this.setHeader("Content-Length", 0), this._implicitHeader(), t.push(h.from(this._headBlock, "latin1")), !0), this.chunkedEncoding && t.push(h.from("0\r\n\r\n", "latin1")), this.finished = !0, t.length === 0) {
1209
1218
  e();
1210
1219
  return;
1211
1220
  }
1212
- this._writeToSocket(m.concat(t), e);
1221
+ this._writeToSocket(h.concat(t), e);
1213
1222
  }
1214
1223
  end(e, t, n) {
1215
1224
  if (e != null && typeof e != "function" && !this._bodyWritten && !this.headersSent && !this.chunkedEncoding && !this.hasHeader("content-length")) {
1216
1225
  let n = typeof t == "string" ? t : void 0;
1217
- this.setHeader("Content-Length", mt(e, n).length);
1226
+ this.setHeader("Content-Length", ht(e, n).length);
1218
1227
  }
1219
1228
  return super.end(e, t, n);
1220
1229
  }
@@ -1258,12 +1267,12 @@ var Xe = /* @__PURE__ */ n({
1258
1267
  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}`);
1259
1268
  }
1260
1269
  writeContinue() {
1261
- this._writeToSocket(m.from("HTTP/1.1 100 Continue\r\n\r\n", "latin1"), () => {});
1270
+ this._writeToSocket(h.from("HTTP/1.1 100 Continue\r\n\r\n", "latin1"), () => {});
1262
1271
  }
1263
1272
  setTimeout(e, t) {
1264
1273
  return this.socket?.setTimeout(e, t), this;
1265
1274
  }
1266
- }, ht = (...e) => {
1275
+ }, gt = (...e) => {
1267
1276
  let t = {}, n = {}, r, i = [...e], a = i.shift();
1268
1277
  if (typeof a == "string" || a instanceof URL) {
1269
1278
  let e = typeof a == "string" ? new URL(a) : a;
@@ -1307,7 +1316,7 @@ var Xe = /* @__PURE__ */ n({
1307
1316
  let e = this.protocol === "https:" && r === 443 || this.protocol !== "https:" && r === 80;
1308
1317
  this.setHeader("Host", e ? n : `${n}:${r}`);
1309
1318
  }
1310
- e.auth && !this.hasHeader("authorization") && this.setHeader("Authorization", `Basic ${m.from(e.auth).toString("base64")}`), this.socket = new F(), this.emit("socket", this.socket), this.socket.on("error", (e) => {
1319
+ e.auth && !this.hasHeader("authorization") && this.setHeader("Authorization", `Basic ${h.from(e.auth).toString("base64")}`), this.socket = new F(), this.emit("socket", this.socket), this.socket.on("error", (e) => {
1311
1320
  this._aborted || this.emit("error", e);
1312
1321
  }), this._attachResponseParser(), this.socket.connect({
1313
1322
  host: n,
@@ -1328,7 +1337,7 @@ var Xe = /* @__PURE__ */ n({
1328
1337
  e._applyHead(n), this.method === "HEAD" && (t.skipBody = !0), this.res = e, this.emit("response", e);
1329
1338
  },
1330
1339
  onBody: (t) => {
1331
- e.push(m.from(t));
1340
+ e.push(h.from(t));
1332
1341
  },
1333
1342
  onComplete: () => {
1334
1343
  e.complete = !0, e.push(null);
@@ -1382,7 +1391,7 @@ var Xe = /* @__PURE__ */ n({
1382
1391
  }), this.emit("request", t, i);
1383
1392
  },
1384
1393
  onBody: (e) => {
1385
- t?.push(m.from(e));
1394
+ t?.push(h.from(e));
1386
1395
  },
1387
1396
  onComplete: () => {
1388
1397
  t && (t.complete = !0, t.push(null)), t = null;
@@ -1404,115 +1413,116 @@ var Xe = /* @__PURE__ */ n({
1404
1413
  return `${e.host ?? "localhost"}:${e.port ?? ""}:${e.localAddress ?? ""}`;
1405
1414
  }
1406
1415
  destroy() {}
1407
- }, gt = new Y(), X = (...e) => {
1408
- let { options: t, callback: n } = ht(...e);
1416
+ }, _t = new Y(), X = (...e) => {
1417
+ let { options: t, callback: n } = gt(...e);
1409
1418
  return new q(t, n);
1410
- }, _t = (...e) => {
1419
+ }, vt = (...e) => {
1411
1420
  let t = X(...e);
1412
1421
  return t.end(), t;
1413
- }, vt = (e, t) => new J(e, t), yt = {
1414
- METHODS: ct,
1422
+ }, yt = (e, t) => new J(e, t), bt = {
1423
+ METHODS: lt,
1415
1424
  STATUS_CODES: z,
1416
1425
  Agent: Y,
1417
- globalAgent: gt,
1426
+ globalAgent: _t,
1418
1427
  Server: J,
1419
1428
  ServerResponse: K,
1420
1429
  IncomingMessage: W,
1421
1430
  ClientRequest: q,
1422
1431
  OutgoingMessage: G,
1423
- createServer: vt,
1432
+ createServer: yt,
1424
1433
  request: X,
1425
- get: _t
1426
- }, bt = /* @__PURE__ */ n({
1427
- available: () => xt,
1428
- dgram: () => tt,
1429
- dns: () => Ue,
1430
- fetch: () => Ve,
1431
- http: () => ot,
1432
- net: () => Xe,
1433
- quota: () => He
1434
- }), xt = () => Re, Z = async (e) => {
1434
+ get: vt
1435
+ }, xt = /* @__PURE__ */ n({
1436
+ available: () => St,
1437
+ dgram: () => nt,
1438
+ dns: () => We,
1439
+ fetch: () => He,
1440
+ http: () => st,
1441
+ net: () => Ze,
1442
+ quota: () => Ue
1443
+ }), St = () => ze, Z = async (e) => {
1435
1444
  if (typeof window > "u") return !1;
1436
- if (g()) return !0;
1445
+ if (_()) return !0;
1437
1446
  let t = await M, n = null, r = new Promise((e) => {
1438
1447
  n = () => {
1439
- g() && e(!0);
1440
- }, h.addEventListener("statuschange", n);
1448
+ _() && e(!0);
1449
+ }, g.addEventListener("statuschange", n);
1441
1450
  }), i = t.installPrompt.show(e).then(() => !1), a = await Promise.race([r, i]);
1442
- return n && h.removeEventListener("statuschange", n), await t.installPrompt.hide().catch(() => {}), a;
1451
+ return n && g.removeEventListener("statuschange", n), await t.installPrompt.hide().catch(() => {}), a;
1443
1452
  }, Q = null;
1444
- v(() => (Q ||= Z().then(() => void 0).finally(() => {
1453
+ y(() => (Q ||= Z().then(() => void 0).finally(() => {
1445
1454
  Q = null;
1446
1455
  }), Q));
1447
1456
  //#endregion
1448
1457
  //#region src/lib/desktop.ts
1449
- var St = /* @__PURE__ */ n({
1450
- available: () => Ct,
1451
- dgram: () => Dt,
1452
- dns: () => Tt,
1453
- fetch: () => wt,
1454
- fs: () => Ot,
1455
- net: () => Et
1456
- }), Ct = () => !1, $ = (e) => (...t) => {
1458
+ var Ct = /* @__PURE__ */ n({
1459
+ available: () => wt,
1460
+ dgram: () => Ot,
1461
+ dns: () => Et,
1462
+ fetch: () => Tt,
1463
+ fs: () => kt,
1464
+ net: () => Dt
1465
+ }), wt = () => !1, $ = (e) => (...t) => {
1457
1466
  throw Error(`The FKN desktop app is not connected, desktop.${e} is unavailable`);
1458
- }, wt = $("fetch"), Tt = { lookup: $("dns.lookup") }, Et = {
1467
+ }, Tt = $("fetch"), Et = { lookup: $("dns.lookup") }, Dt = {
1459
1468
  connect: $("net.connect"),
1460
1469
  createConnection: $("net.createConnection"),
1461
1470
  createServer: $("net.createServer")
1462
- }, Dt = { createSocket: $("dgram.createSocket") }, Ot = {
1471
+ }, Ot = { createSocket: $("dgram.createSocket") }, kt = {
1463
1472
  isLocalDirectorySupported: () => !1,
1464
1473
  pickLocalDirectory: $("fs.pickLocalDirectory"),
1465
1474
  queryDirectoryPermission: $("fs.queryDirectoryPermission"),
1466
1475
  ensureDirectoryPermission: $("fs.ensureDirectoryPermission")
1467
- }, kt = () => typeof document < "u" && g(), At = async (e, t) => {
1468
- if (Be(e), t?.credentials === "include") {
1476
+ }, At = () => typeof document < "u" && _(), jt = async (e, t) => {
1477
+ if (Ve(e), t?.credentials === "include") {
1469
1478
  if (typeof document > "u") throw Error("fetch with credentials needs the FKN extension, which only exists in window realms");
1470
- return C(e, t);
1479
+ return he(e, t);
1471
1480
  }
1472
- return kt() ? C(e, {
1481
+ return At() ? he(e, {
1473
1482
  ...t,
1474
1483
  credentials: "omit"
1475
- }) : Ct() ? wt(e, t) : Ve(e, t);
1476
- }, jt = /* @__PURE__ */ n({
1484
+ }) : wt() ? Tt(e, t) : He(e, t);
1485
+ }, Mt = /* @__PURE__ */ n({
1477
1486
  ATTACH_FRAME_EVENT_KEY: () => w,
1478
1487
  assertAttachableFrameUrl: () => E,
1479
- assertFetchableUrl: () => S,
1480
- attachFrame: () => Ce,
1488
+ assertFetchableUrl: () => C,
1489
+ attachFrame: () => we,
1481
1490
  attachFramePermission: () => xe,
1482
- available: () => kt,
1491
+ available: () => At,
1483
1492
  box: () => l,
1484
1493
  cookies: () => _e,
1485
1494
  createVideoElementHandle: () => e,
1486
- events: () => h,
1487
- extension: () => h,
1488
- fetch: () => C,
1489
- fetchCredentialedPermission: () => le,
1490
- fetchLocalPermission: () => ue,
1491
- fetchPermission: () => ce,
1495
+ evaluatePermission: () => Ce,
1496
+ events: () => g,
1497
+ extension: () => g,
1498
+ fetch: () => he,
1499
+ fetchCredentialedPermission: () => ce,
1500
+ fetchLocalPermission: () => le,
1501
+ fetchPermission: () => se,
1492
1502
  gotoPermission: () => Se,
1493
1503
  handleRevivableModules: () => i,
1494
- isBlockedFetchUrl: () => x,
1504
+ isBlockedFetchUrl: () => S,
1495
1505
  isBlockedFrameUrl: () => T,
1496
- isExtensionExposed: () => g,
1497
- isLocalNetworkUrl: () => fe,
1506
+ isExtensionExposed: () => _,
1507
+ isLocalNetworkUrl: () => de,
1498
1508
  isType: () => t,
1499
1509
  modifyRequestHeadersPermission: () => ve,
1500
- permissions: () => we,
1510
+ permissions: () => Te,
1501
1511
  promptInstall: () => Z,
1502
1512
  readCookiePermission: () => ge,
1503
1513
  removeRequestHeaderRule: () => be,
1504
1514
  revive: () => o,
1505
- setMissingExtensionHandler: () => v,
1515
+ setMissingExtensionHandler: () => y,
1506
1516
  setRequestHeaderRule: () => ye,
1507
1517
  type: () => a,
1508
- waitForExtensionExposure: () => y
1509
- }), Mt = /* @__PURE__ */ n({
1510
- ensureDirectoryPermission: () => It,
1511
- isLocalDirectorySupported: () => Nt,
1512
- pickLocalDirectory: () => Pt,
1513
- queryDirectoryPermission: () => Ft
1514
- }), Nt = () => typeof window < "u" && "showDirectoryPicker" in window, Pt = async (e = {}) => {
1515
- if (!Nt()) return;
1518
+ waitForExtensionExposure: () => b
1519
+ }), Nt = /* @__PURE__ */ n({
1520
+ ensureDirectoryPermission: () => Lt,
1521
+ isLocalDirectorySupported: () => Pt,
1522
+ pickLocalDirectory: () => Ft,
1523
+ queryDirectoryPermission: () => It
1524
+ }), Pt = () => typeof window < "u" && "showDirectoryPicker" in window, Ft = async (e = {}) => {
1525
+ if (!Pt()) return;
1516
1526
  let t = window.showDirectoryPicker;
1517
1527
  return t({
1518
1528
  mode: "readwrite",
@@ -1520,33 +1530,33 @@ var St = /* @__PURE__ */ n({
1520
1530
  }).catch((e) => {
1521
1531
  if (e?.name !== "AbortError") throw e;
1522
1532
  });
1523
- }, Ft = async (e, t = "readwrite") => {
1533
+ }, It = async (e, t = "readwrite") => {
1524
1534
  let { queryPermission: n } = e;
1525
1535
  return await n?.call(e, { mode: t }) ?? "granted";
1526
- }, It = async (e, t = "readwrite") => {
1527
- if (await Ft(e, t) === "granted") return !0;
1536
+ }, Lt = async (e, t = "readwrite") => {
1537
+ if (await It(e, t) === "granted") return !0;
1528
1538
  let { requestPermission: n } = e;
1529
1539
  return await n?.call(e, { mode: t }) === "granted";
1530
- }, Lt = "https://fkn.app", Rt = (e, t) => {
1540
+ }, Rt = "https://fkn.app", zt = (e, t) => {
1531
1541
  if (typeof window > "u") throw Error("FKN @fkn/lib: relayWorker must be called from the main thread");
1532
1542
  if (!A?.contentWindow) throw Error("FKN @fkn/lib: relayWorker called before the FKN iframe was injected");
1533
- ne({
1543
+ ee({
1534
1544
  receive: window,
1535
1545
  emit: A.contentWindow
1536
1546
  }, e, {
1537
1547
  key: "fkn-api",
1538
- originA: t?.originA ?? Lt,
1548
+ originA: t?.originA ?? Rt,
1539
1549
  originB: t?.originB ?? "*",
1540
1550
  unregisterSignal: t?.unregisterSignal
1541
1551
  });
1542
- }, zt = async () => typeof window > "u" ? !1 : (await M).connect.prompt(location.origin).catch(() => !1), Bt = /* @__PURE__ */ n({
1543
- info: () => Ut,
1544
- login: () => Vt,
1545
- logout: () => Ht,
1546
- onChange: () => Wt
1547
- }), Vt = async () => typeof window > "u" ? !1 : (await M).account.login(location.origin).catch(() => !1), Ht = async () => {
1552
+ }, Bt = async () => typeof window > "u" ? !1 : (await M).connect.prompt(location.origin).catch(() => !1), Vt = /* @__PURE__ */ n({
1553
+ info: () => Wt,
1554
+ login: () => Ht,
1555
+ logout: () => Ut,
1556
+ onChange: () => Gt
1557
+ }), Ht = async () => typeof window > "u" ? !1 : (await M).account.login(location.origin).catch(() => !1), Ut = async () => {
1548
1558
  typeof window > "u" || await (await M).account.logout().catch(() => {});
1549
- }, Ut = async () => {
1559
+ }, Wt = async () => {
1550
1560
  if (typeof window > "u") return null;
1551
1561
  let e = await M.then((e) => e.account.info()).catch(() => null);
1552
1562
  return e ? {
@@ -1555,12 +1565,24 @@ var St = /* @__PURE__ */ n({
1555
1565
  premium: e.premium,
1556
1566
  premiumUntil: e.premiumUntil ? Date.parse(e.premiumUntil) : null
1557
1567
  } : null;
1558
- }, Wt = async (e) => {
1568
+ }, Gt = async (e) => {
1559
1569
  if (typeof window > "u") return () => {};
1560
1570
  let t = await M.catch(() => null);
1561
1571
  if (!t) return () => {};
1562
1572
  let n = await t.account.onChange(e).catch(() => null);
1563
1573
  return typeof n == "function" ? n : () => {};
1564
- };
1574
+ }, Kt = "https://fkn.app", qt = (e = location.origin) => `${Kt}/connect-button?origin=${encodeURIComponent(e)}`, Jt = ({ className: e, style: t } = {}) => ne("iframe", {
1575
+ src: qt(),
1576
+ title: "Connect your FKN account",
1577
+ className: e,
1578
+ style: {
1579
+ border: "none",
1580
+ width: 150,
1581
+ height: 40,
1582
+ background: "transparent",
1583
+ colorScheme: "normal",
1584
+ ...t
1585
+ }
1586
+ });
1565
1587
  //#endregion
1566
- export { w as ATTACH_FRAME_EVENT_KEY, Bt as account, E as assertAttachableFrameUrl, S as assertFetchableUrl, Ce as attachFrame, xe as attachFramePermission, l as box, bt as cloud, zt as connect, u as connectButtonUrl, _e as cookies, e as createVideoElementHandle, St as desktop, tt as dgram, Ue as dns, jt as extension, At as fetch, le as fetchCredentialedPermission, ue as fetchLocalPermission, ce as fetchPermission, Mt as fs, Se as gotoPermission, i as handleRevivableModules, ot as http, x as isBlockedFetchUrl, T as isBlockedFrameUrl, g as isExtensionExposed, fe as isLocalNetworkUrl, t as isType, ve as modifyRequestHeadersPermission, Xe as net, we as permissions, Z as promptInstall, ge as readCookiePermission, Rt as relayWorker, be as removeRequestHeaderRule, o as revive, v as setMissingExtensionHandler, ye as setRequestHeaderRule, a as type, y as waitForExtensionExposure };
1588
+ export { w as ATTACH_FRAME_EVENT_KEY, Jt as ConnectButton, Vt as account, E as assertAttachableFrameUrl, C as assertFetchableUrl, we as attachFrame, xe as attachFramePermission, l as box, xt as cloud, Bt as connect, qt as connectButtonUrl, _e as cookies, e as createVideoElementHandle, Ct as desktop, nt as dgram, We as dns, Ce as evaluatePermission, Mt as extension, jt as fetch, ce as fetchCredentialedPermission, le as fetchLocalPermission, se as fetchPermission, Nt as fs, Se as gotoPermission, i as handleRevivableModules, st as http, S as isBlockedFetchUrl, T as isBlockedFrameUrl, _ as isExtensionExposed, de as isLocalNetworkUrl, t as isType, ve as modifyRequestHeadersPermission, Ze as net, Te as permissions, Z as promptInstall, ge as readCookiePermission, zt as relayWorker, be as removeRequestHeaderRule, o as revive, y as setMissingExtensionHandler, ye as setRequestHeaderRule, a as type, b as waitForExtensionExposure };