@fkn/lib 0.4.8 → 0.5.0
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/account.cjs +1 -0
- package/account.d.ts +17 -0
- package/account.js +28 -0
- package/api-ByfayMm1.js +67 -0
- package/api-CDb2pv7C.cjs +1 -0
- package/background-Dk_vaVP1.cjs +1 -0
- package/{background-CTsVv_a0.js → background-TtzKw6g0.js} +5 -4
- package/chunk-B6C_zzib.cjs +1 -0
- package/chunk-CPXzm0be.js +11 -0
- package/cloud/dgram.cjs +1 -0
- package/cloud/dgram.d.ts +537 -0
- package/cloud/dgram.js +4 -0
- package/cloud/dns.cjs +1 -0
- package/cloud/dns.d.ts +12 -0
- package/cloud/dns.js +3 -0
- package/cloud/fs/promises.cjs +1 -0
- package/cloud/fs/promises.d.ts +45 -0
- package/cloud/fs/promises.js +8 -0
- package/cloud/fs.cjs +1 -0
- package/cloud/fs.d.ts +75 -0
- package/cloud/fs.js +20 -0
- package/cloud/http.cjs +1 -0
- package/cloud/http.d.ts +767 -0
- package/cloud/http.js +5 -0
- package/cloud/net.cjs +1 -0
- package/cloud/net.d.ts +606 -0
- package/cloud/net.js +4 -0
- package/cloud-BVnscun4.js +33 -0
- package/cloud-DTL2B5pW.cjs +1 -0
- package/cloud.cjs +1 -0
- package/cloud.d.ts +1048 -0
- package/cloud.js +12 -0
- package/desktop.cjs +1 -0
- package/desktop.d.ts +49 -0
- package/desktop.js +51 -0
- package/dgram-5YUb70O2.js +326 -0
- package/dgram-Cdi6Y7zJ.cjs +1 -0
- package/dgram.cjs +1 -0
- package/dgram.d.ts +537 -0
- package/dgram.js +4 -0
- package/dns.cjs +1 -0
- package/dns.d.ts +12 -0
- package/dns.js +6 -0
- package/extension-9Uv_0HdS.cjs +1 -0
- package/extension-Dgz0UTy0.js +245 -0
- package/extension.cjs +1 -0
- package/extension.d.ts +853 -0
- package/extension.js +5 -0
- package/fs/promises.cjs +1 -0
- package/fs/promises.d.ts +46 -0
- package/fs/promises.js +8 -0
- package/fs-B7JumDCn.js +78 -0
- package/fs-DrwvwtqC.cjs +1 -0
- package/fs.cjs +1 -0
- package/fs.d.ts +84 -0
- package/fs.js +5 -0
- package/http.cjs +9 -0
- package/http.d.ts +767 -0
- package/http.js +541 -0
- package/index.cjs +1 -9
- package/index.d.ts +495 -268
- package/index.js +27 -1569
- package/locator-Cf7M3QKN.cjs +53 -0
- package/{locator-Q5m8i40Z.js → locator-DxAsGV_o.js} +331 -337
- package/net-Bl6_W3bd.js +275 -0
- package/net-C5kWnI4C.cjs +1 -0
- package/net.cjs +1 -0
- package/net.d.ts +606 -0
- package/net.js +4 -0
- package/node-fs-Bd_UUx1m.js +361 -0
- package/node-fs-lrlD_zqB.cjs +1 -0
- package/opfs/promises.cjs +1 -0
- package/opfs/promises.d.ts +46 -0
- package/opfs/promises.js +6 -0
- package/opfs-BfcYLPGb.js +55 -0
- package/opfs-Dsi4FkJU.cjs +1 -0
- package/opfs.cjs +1 -0
- package/opfs.d.ts +83 -0
- package/opfs.js +35 -0
- package/package.json +91 -1
- package/proxy-A9UvWUaF.cjs +1 -0
- package/proxy-wiZN4eTR.js +14 -0
- package/storage-BadvHtv0.cjs +1 -0
- package/storage-z0q3iena.js +13 -0
- package/utils-BsNRWMfl.cjs +1 -0
- package/utils-CNydj3OT.js +52 -0
- package/background-BqRFQggD.cjs +0 -1
- package/locator-Cjl21Nkt.cjs +0 -53
package/index.js
CHANGED
|
@@ -1,1578 +1,36 @@
|
|
|
1
|
-
import { d as e, f as t,
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
}
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
n(/* @__PURE__ */ Error("The FKN WebExtension is not installed, enabled or not exposed on this page."));
|
|
22
|
-
}), o = () => {
|
|
23
|
-
clearTimeout(r), r = setTimeout(() => _() ? i(t) : a(), ae);
|
|
24
|
-
}, s = new MutationObserver(() => {
|
|
25
|
-
_() && i(t);
|
|
26
|
-
}), c = () => {
|
|
27
|
-
document.readyState === "complete" && !_() && o();
|
|
28
|
-
};
|
|
29
|
-
if (r = setTimeout(a, e), s.observe(document.documentElement, {
|
|
30
|
-
attributes: !0,
|
|
31
|
-
attributeFilter: ["data-fkn-extension"]
|
|
32
|
-
}), document.addEventListener("readystatechange", c), document.readyState === "complete") return o();
|
|
33
|
-
_() && i(t);
|
|
34
|
-
}), oe, x = new Proxy({}, { get: (e, t) => async (...e) => {
|
|
35
|
-
await b(), oe ??= d({}, {
|
|
36
|
-
transport: window,
|
|
37
|
-
revivableModules: i
|
|
38
|
-
});
|
|
39
|
-
let n = (await oe)[t];
|
|
40
|
-
return n(...e);
|
|
41
|
-
} }), se = {
|
|
42
|
-
scope: "network.fetch",
|
|
43
|
-
category: "network",
|
|
44
|
-
severity: 0,
|
|
45
|
-
title: "Fetch data from other sites",
|
|
46
|
-
description: "Lets the app download public data from other websites directly, past the usual cross-origin limits."
|
|
47
|
-
}, ce = {
|
|
48
|
-
scope: "network.fetchCredentialed",
|
|
49
|
-
category: "network",
|
|
50
|
-
severity: 3,
|
|
51
|
-
unsafe: !0,
|
|
52
|
-
title: "Fetch from other sites, signed in as you",
|
|
53
|
-
description: "Lets the app fetch other sites using your logged-in session cookies, so it can read data only you should see."
|
|
54
|
-
}, le = {
|
|
55
|
-
scope: "network.fetchLocal",
|
|
56
|
-
category: "network",
|
|
57
|
-
severity: 3,
|
|
58
|
-
unsafe: !0,
|
|
59
|
-
title: "Access devices on your local network",
|
|
60
|
-
description: "Lets the app reach devices and services on your home or work network, which websites normally cannot touch."
|
|
61
|
-
}, ue = (e) => {
|
|
62
|
-
let t = e.match(/^(\d+)\.(\d+)\.\d+\.\d+$/);
|
|
63
|
-
if (!t) return !1;
|
|
64
|
-
let [n, r] = [Number(t[1]), Number(t[2])];
|
|
65
|
-
return n === 10 || n === 127 || n === 0 || n === 169 && r === 254 || n === 172 && r >= 16 && r <= 31 || n === 192 && r === 168;
|
|
66
|
-
}, de = (e) => {
|
|
67
|
-
let t;
|
|
68
|
-
try {
|
|
69
|
-
t = new URL(e);
|
|
70
|
-
} catch {
|
|
71
|
-
return !1;
|
|
72
|
-
}
|
|
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:") : ue(n);
|
|
75
|
-
}, fe = ["fkn.app", "fkn.dev"], S = (e) => {
|
|
76
|
-
let t;
|
|
77
|
-
try {
|
|
78
|
-
t = new URL(e);
|
|
79
|
-
} catch {
|
|
80
|
-
return !1;
|
|
81
|
-
}
|
|
82
|
-
if (t.protocol === "chrome-extension:" || t.protocol === "moz-extension:") return !0;
|
|
83
|
-
let n = t.hostname;
|
|
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
|
-
if (!e?.headers) return;
|
|
89
|
-
let t = new Headers(e.headers), n = pe.map((e) => {
|
|
90
|
-
let n = t.get(e);
|
|
91
|
-
return n === null ? void 0 : [e, n];
|
|
92
|
-
}).filter((e) => e !== void 0);
|
|
93
|
-
return n.length ? n : void 0;
|
|
94
|
-
}, he = async (e, t) => {
|
|
95
|
-
let n = new Request(e, t);
|
|
96
|
-
C(n.url);
|
|
97
|
-
let r = n.body ? await n.arrayBuffer() : null;
|
|
98
|
-
return x.proxyFetch({
|
|
99
|
-
url: n.url,
|
|
100
|
-
method: n.method,
|
|
101
|
-
headers: [...n.headers],
|
|
102
|
-
body: r,
|
|
103
|
-
credentials: t?.credentials === "include" ? "include" : "omit",
|
|
104
|
-
redirect: n.redirect,
|
|
105
|
-
unsafeHeaders: me(t),
|
|
106
|
-
reason: t?.reason,
|
|
107
|
-
signal: t?.signal ?? void 0
|
|
108
|
-
});
|
|
109
|
-
}, ge = {
|
|
110
|
-
scope: "network.readCookie",
|
|
111
|
-
category: "network",
|
|
112
|
-
severity: 3,
|
|
113
|
-
unsafe: !0,
|
|
114
|
-
title: "Read a site’s cookie",
|
|
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) => x.getCookie(e) }, ve = {
|
|
117
|
-
scope: "network.modifyRequestHeaders",
|
|
118
|
-
category: "network",
|
|
119
|
-
severity: 2,
|
|
120
|
-
unsafe: !0,
|
|
121
|
-
title: "Rewrite request headers to other sites",
|
|
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) => x.setRequestHeaderRule(e), be = (e) => x.removeRequestHeaderRule({ ruleId: e });
|
|
124
|
-
(() => {
|
|
125
|
-
let e = {}, t = [...c.selectorModules, ...r.selectorModules];
|
|
126
|
-
for (let n of t) n.render && !(n.type in e) && (e[n.type] = n.render);
|
|
127
|
-
return e;
|
|
128
|
-
})();
|
|
129
|
-
//#endregion
|
|
130
|
-
//#region node_modules/@mfkn/web-extension/lib/lib/frame.js
|
|
131
|
-
var w = "FKN_WEB_EXTENSION_ATTACH_FRAME_EVENT_KEY", T = (e) => {
|
|
132
|
-
if (!e || e === "about:blank") return !1;
|
|
133
|
-
let t;
|
|
134
|
-
try {
|
|
135
|
-
t = new URL(e, location.href);
|
|
136
|
-
} catch {
|
|
137
|
-
return !1;
|
|
138
|
-
}
|
|
139
|
-
if (t.protocol === "chrome-extension:" || t.protocol === "moz-extension:") return !0;
|
|
140
|
-
if (t.protocol === "about:") return !1;
|
|
141
|
-
let n = t.hostname;
|
|
142
|
-
return n === "fkn.app" || n.endsWith(".fkn.app");
|
|
143
|
-
}, E = (e) => {
|
|
144
|
-
if (T(e)) throw Error("attachFrame: refusing to target the extension's own pages or fkn.app");
|
|
145
|
-
}, xe = {
|
|
146
|
-
scope: "embed.iframe",
|
|
147
|
-
category: "embed",
|
|
148
|
-
severity: 0,
|
|
149
|
-
title: "Load another website inside this app",
|
|
150
|
-
description: "Lets the app embed external pages directly inside its own view."
|
|
151
|
-
}, Se = {
|
|
152
|
-
scope: "embed.open",
|
|
153
|
-
category: "embed",
|
|
154
|
-
severity: 0,
|
|
155
|
-
title: "Open a website inside this app",
|
|
156
|
-
description: "Lets the app navigate to another site without leaving its window."
|
|
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({
|
|
173
|
-
url: e,
|
|
174
|
-
...t
|
|
175
|
-
})), ee = ((e, t) => l(e, t)), f = () => e.src;
|
|
176
|
-
return {
|
|
177
|
-
...u,
|
|
178
|
-
goto: d,
|
|
179
|
-
evaluate: ee,
|
|
180
|
-
url: f
|
|
181
|
-
};
|
|
182
|
-
}, Te = { request: (e) => x.requestPermissions(e.map((e) => ({
|
|
183
|
-
key: e.key,
|
|
184
|
-
scope: e.scope ?? "",
|
|
185
|
-
reason: e.reason
|
|
186
|
-
}))) }, Ee = 32, De = typeof CSS < "u" && CSS.supports("clip-path", "path('M0 0H1V1H0Z')"), Oe = (e) => {
|
|
187
|
-
let t = e.style;
|
|
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");
|
|
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) {
|
|
191
|
-
let r = t || n.length > 0;
|
|
192
|
-
e.style.setProperty("pointer-events", r ? "auto" : "none", "important"), e.style.setProperty("visibility", r ? "visible" : "hidden", "important");
|
|
193
|
-
return;
|
|
194
|
-
}
|
|
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%)";
|
|
196
|
-
e.style.setProperty("clip-path", i, "important");
|
|
197
|
-
}, je = (e) => {
|
|
198
|
-
if (typeof e != "object" || !e) return null;
|
|
199
|
-
let { x: t, y: n, width: r, height: i } = e;
|
|
200
|
-
if (![
|
|
201
|
-
t,
|
|
202
|
-
n,
|
|
203
|
-
r,
|
|
204
|
-
i
|
|
205
|
-
].every((e) => typeof e == "number" && Number.isFinite(e))) return null;
|
|
206
|
-
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)), u = Math.max(c, Math.min(Math.round(n + i), o));
|
|
207
|
-
return {
|
|
208
|
-
x: s,
|
|
209
|
-
y: c,
|
|
210
|
-
width: l - s,
|
|
211
|
-
height: u - c
|
|
212
|
-
};
|
|
213
|
-
}, Me = (e) => {
|
|
214
|
-
if (typeof e != "object" || !e) return null;
|
|
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);
|
|
216
|
-
return {
|
|
217
|
-
modal: t.modal === !0,
|
|
218
|
-
rects: n
|
|
219
|
-
};
|
|
220
|
-
}, D = null, Ne = () => D !== null, Pe = (e) => {
|
|
221
|
-
Oe(e), Ae(e, {
|
|
222
|
-
modal: !1,
|
|
223
|
-
rects: []
|
|
224
|
-
}), D = e;
|
|
225
|
-
}, Fe = (e) => {
|
|
226
|
-
if (!D) return;
|
|
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);
|
|
233
|
-
var j = (() => {
|
|
234
|
-
if (typeof window < "u") return Re ? {
|
|
235
|
-
receive: window,
|
|
236
|
-
emit: Re
|
|
237
|
-
} : void 0;
|
|
238
|
-
if (typeof self < "u") return {
|
|
239
|
-
receive: self,
|
|
240
|
-
emit: self
|
|
241
|
-
};
|
|
242
|
-
})(), ze = j !== void 0, M = j ? d({}, {
|
|
243
|
-
key: "fkn-api",
|
|
244
|
-
transport: j
|
|
245
|
-
}) : new Promise(() => {});
|
|
246
|
-
M.then((e) => {
|
|
247
|
-
Ne() && e.overlay.setHost(Fe);
|
|
248
|
-
}, () => {});
|
|
249
|
-
//#endregion
|
|
250
|
-
//#region src/lib/fkn-target.ts
|
|
251
|
-
var Be = ["fkn.app", "fkn.dev"], Ve = (e) => {
|
|
252
|
-
let t = typeof e == "string" ? e : e instanceof URL ? e.href : e.url, n;
|
|
253
|
-
try {
|
|
254
|
-
n = new URL(t);
|
|
255
|
-
} catch {
|
|
256
|
-
return;
|
|
257
|
-
}
|
|
258
|
-
let r = n.hostname;
|
|
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 () => {
|
|
261
|
-
let e = await M.then((e) => e.cloud.quota());
|
|
262
|
-
return {
|
|
263
|
-
premium: e.premium,
|
|
264
|
-
overQuota: e.overQuota,
|
|
265
|
-
throttled: e.overQuota && !e.premium,
|
|
266
|
-
usedBytes: e.usedBytes,
|
|
267
|
-
limitBytes: e.limitBytes,
|
|
268
|
-
remainingBytes: e.remaining,
|
|
269
|
-
bytesPerSecond: e.bytesPerSecond,
|
|
270
|
-
bitsPerSecond: e.bytesPerSecond * 8
|
|
271
|
-
};
|
|
272
|
-
}, We = /* @__PURE__ */ n({ lookup: () => Ge }), Ge = (e, t) => M.then((n) => n.cloud.dns.lookup(e, t)), Ke = new TextEncoder();
|
|
273
|
-
new TextDecoder();
|
|
274
|
-
var N = (e) => p.isValid(e), P = (e) => m.isValid(e), qe = (e) => N(e) ? 4 : P(e) ? 6 : 0, Je = (...e) => {
|
|
275
|
-
if (typeof e[0] == "string") throw Error("FKN WebVPN does not support IPC connections");
|
|
276
|
-
let t = typeof e.at(-1) == "function" ? e.at(-1) : void 0;
|
|
277
|
-
return e[0] && typeof e[0] == "object" ? {
|
|
278
|
-
...e[0],
|
|
279
|
-
callback: t
|
|
280
|
-
} : {
|
|
281
|
-
port: e[0] ?? 0,
|
|
282
|
-
host: typeof e[1] == "string" ? e[1] : void 0,
|
|
283
|
-
callback: t
|
|
284
|
-
};
|
|
285
|
-
}, Ye = (...e) => {
|
|
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;
|
|
287
|
-
return typeof e[0] == "object" ? {
|
|
288
|
-
...e[0],
|
|
289
|
-
address: e[0].address ?? r,
|
|
290
|
-
port: e[0].port ?? n,
|
|
291
|
-
callback: t
|
|
292
|
-
} : {
|
|
293
|
-
address: r,
|
|
294
|
-
port: n,
|
|
295
|
-
callback: t
|
|
296
|
-
};
|
|
297
|
-
}, Xe = (...e) => {
|
|
298
|
-
let t = typeof e.at(-1) == "function" ? e.at(-1) : void 0, n = e[0];
|
|
299
|
-
if (typeof e[2] == "number") return {
|
|
300
|
-
message: n,
|
|
301
|
-
offset: e[1],
|
|
302
|
-
length: e[2],
|
|
303
|
-
port: typeof e[3] == "number" ? e[3] : 0,
|
|
304
|
-
address: typeof e[4] == "string" ? e[4] : void 0,
|
|
305
|
-
callback: t
|
|
306
|
-
};
|
|
307
|
-
{
|
|
308
|
-
let r = typeof e[1] == "number" ? e[1] : 0, i = typeof e[2] == "string" ? e[2] : void 0;
|
|
309
|
-
return {
|
|
310
|
-
message: n,
|
|
311
|
-
offset: 0,
|
|
312
|
-
length: n.length,
|
|
313
|
-
port: r,
|
|
314
|
-
address: i,
|
|
315
|
-
callback: t
|
|
316
|
-
};
|
|
317
|
-
}
|
|
318
|
-
};
|
|
319
|
-
new TextEncoder(), new TextDecoder();
|
|
320
|
-
//#endregion
|
|
321
|
-
//#region src/lib/webvpn/net.ts
|
|
322
|
-
var Ze = /* @__PURE__ */ n({
|
|
323
|
-
Server: () => I,
|
|
324
|
-
Socket: () => F,
|
|
325
|
-
_default: () => tt,
|
|
326
|
-
connect: () => Qe,
|
|
327
|
-
createConnection: () => $e,
|
|
328
|
-
createServer: () => et,
|
|
329
|
-
default: () => tt,
|
|
330
|
-
isIP: () => qe,
|
|
331
|
-
isIPv4: () => N,
|
|
332
|
-
isIPv6: () => P
|
|
333
|
-
}), F = class extends f.Duplex {
|
|
334
|
-
_localAddress;
|
|
335
|
-
_remoteAddress;
|
|
336
|
-
_webVPNTcpSocketPromise;
|
|
337
|
-
constructor(e) {
|
|
338
|
-
if (e?.fd !== void 0) throw Error("FKN WebVPN does not support file descriptors");
|
|
339
|
-
super(e), e?.connection && this.__webvpn_tcp_socket_init__(e.connection);
|
|
340
|
-
}
|
|
341
|
-
__webvpn_tcp_socket_init__(e) {
|
|
342
|
-
if (this._webVPNTcpSocketPromise = e.then((e) => {
|
|
343
|
-
let t = e.dataReadableStream.getReader(), n = e.dataWritableStream.getWriter();
|
|
344
|
-
return this._localAddress = {
|
|
345
|
-
address: e.localAddress,
|
|
346
|
-
family: e.localFamily,
|
|
347
|
-
port: e.localPort
|
|
348
|
-
}, this._remoteAddress = {
|
|
349
|
-
address: e.remoteAddress,
|
|
350
|
-
family: e.remoteFamily,
|
|
351
|
-
port: e.remotePort
|
|
352
|
-
}, {
|
|
353
|
-
...e,
|
|
354
|
-
reader: t,
|
|
355
|
-
writer: n
|
|
356
|
-
};
|
|
357
|
-
}).catch((e) => {
|
|
358
|
-
this.emit("error", e);
|
|
359
|
-
}), !this._webVPNTcpSocketPromise) throw Error("Socket not connected");
|
|
360
|
-
return this._webVPNTcpSocketPromise.then((e) => {
|
|
361
|
-
e && this.emit("connect");
|
|
362
|
-
}), this._webVPNTcpSocketPromise;
|
|
363
|
-
}
|
|
364
|
-
_read(e) {
|
|
365
|
-
if (!this._webVPNTcpSocketPromise) throw Error("Socket not connected");
|
|
366
|
-
this._webVPNTcpSocketPromise.then((e) => {
|
|
367
|
-
if (!e) {
|
|
368
|
-
this.push(null);
|
|
369
|
-
return;
|
|
370
|
-
}
|
|
371
|
-
e.reader.read().then(({ value: e, done: t }) => {
|
|
372
|
-
if (t) {
|
|
373
|
-
this.push(null);
|
|
374
|
-
return;
|
|
375
|
-
}
|
|
376
|
-
this._restartTimeoutTimer(), this.push(e);
|
|
377
|
-
}).catch((e) => {
|
|
378
|
-
this.destroy(e);
|
|
379
|
-
});
|
|
380
|
-
});
|
|
381
|
-
}
|
|
382
|
-
_write(e, t, n) {
|
|
383
|
-
if (!this._webVPNTcpSocketPromise) {
|
|
384
|
-
n(/* @__PURE__ */ Error("Socket not connected"));
|
|
385
|
-
return;
|
|
386
|
-
}
|
|
387
|
-
this._webVPNTcpSocketPromise.then(async (t) => {
|
|
388
|
-
if (!t) throw Error("Socket not connected");
|
|
389
|
-
await t.writer.ready, await t.writer.write(e), this._restartTimeoutTimer(), n();
|
|
390
|
-
}).catch(n);
|
|
391
|
-
}
|
|
392
|
-
connect(...e) {
|
|
393
|
-
let t = Je(...e), n = this.__webvpn_tcp_socket_init__(M.then((e) => e.cloud.webvpn.tcpSocket({
|
|
394
|
-
remoteAddress: t.host ?? "localhost",
|
|
395
|
-
remotePort: t.port
|
|
396
|
-
})));
|
|
397
|
-
return t.callback && n.then((e) => {
|
|
398
|
-
e && t.callback.call(this);
|
|
399
|
-
}), this;
|
|
400
|
-
}
|
|
401
|
-
_end(...e) {
|
|
402
|
-
return this._webVPNTcpSocketPromise ? (e.length !== 0 && this.write(e[0], e[1], e[2]), this._webVPNTcpSocketPromise.then(async (e) => {
|
|
403
|
-
e && await e.end();
|
|
404
|
-
}), this) : this;
|
|
405
|
-
}
|
|
406
|
-
_destroy(e) {
|
|
407
|
-
return this._timeoutTimer && clearTimeout(this._timeoutTimer), this._webVPNTcpSocketPromise && this._webVPNTcpSocketPromise.then(async (e) => {
|
|
408
|
-
e && await e.destroy();
|
|
409
|
-
}), this;
|
|
410
|
-
}
|
|
411
|
-
destroySoon() {
|
|
412
|
-
this._webVPNTcpSocketPromise && this._webVPNTcpSocketPromise.then(async (e) => {
|
|
413
|
-
e && await e.destroySoon();
|
|
414
|
-
});
|
|
415
|
-
}
|
|
416
|
-
resetAndDestroy() {
|
|
417
|
-
return this._webVPNTcpSocketPromise && this._webVPNTcpSocketPromise.then(async (e) => {
|
|
418
|
-
e && await e.resetAndDestroy();
|
|
419
|
-
}), this;
|
|
420
|
-
}
|
|
421
|
-
_timeoutMs;
|
|
422
|
-
_timeoutTimer;
|
|
423
|
-
_restartTimeoutTimer() {
|
|
424
|
-
this._timeoutTimer && clearTimeout(this._timeoutTimer), this._timeoutMs && (this._timeoutTimer = setTimeout(() => this.emit("timeout"), this._timeoutMs));
|
|
425
|
-
}
|
|
426
|
-
setTimeout(e, t) {
|
|
427
|
-
return t && this.on("timeout", t), this._timeoutMs = e, this._restartTimeoutTimer(), this;
|
|
428
|
-
}
|
|
429
|
-
setNoDelay(e) {
|
|
430
|
-
let t = e ?? !0;
|
|
431
|
-
return this._setTcpOption({
|
|
432
|
-
type: 0,
|
|
433
|
-
value: t
|
|
434
|
-
}), this;
|
|
435
|
-
}
|
|
436
|
-
setKeepAlive(e, t) {
|
|
437
|
-
let n = e ?? !1, r = t !== void 0 && t > 0 ? Math.max(1, Math.round(t / 1e3)) : 0;
|
|
438
|
-
return this._setTcpOption({
|
|
439
|
-
type: 2,
|
|
440
|
-
enabled: n,
|
|
441
|
-
initialDelaySeconds: r
|
|
442
|
-
}), this;
|
|
443
|
-
}
|
|
444
|
-
setSendBufferSize(e) {
|
|
445
|
-
return this._setTcpOption({
|
|
446
|
-
type: 3,
|
|
447
|
-
value: e
|
|
448
|
-
}), this;
|
|
449
|
-
}
|
|
450
|
-
setRecvBufferSize(e) {
|
|
451
|
-
return this._setTcpOption({
|
|
452
|
-
type: 4,
|
|
453
|
-
value: e
|
|
454
|
-
}), this;
|
|
455
|
-
}
|
|
456
|
-
_typeOfService;
|
|
457
|
-
getTypeOfService() {
|
|
458
|
-
return this._typeOfService ?? 0;
|
|
459
|
-
}
|
|
460
|
-
setTypeOfService(e) {
|
|
461
|
-
return this._typeOfService = e, this;
|
|
462
|
-
}
|
|
463
|
-
_setTcpOption(e) {
|
|
464
|
-
if (!this._webVPNTcpSocketPromise) {
|
|
465
|
-
this.emit("error", /* @__PURE__ */ Error("Cannot set socket option before connect"));
|
|
466
|
-
return;
|
|
467
|
-
}
|
|
468
|
-
this._webVPNTcpSocketPromise.then(async (t) => {
|
|
469
|
-
if (t) try {
|
|
470
|
-
await t.setOption(e);
|
|
471
|
-
} catch (e) {
|
|
472
|
-
this.emit("error", e);
|
|
473
|
-
}
|
|
474
|
-
});
|
|
475
|
-
}
|
|
476
|
-
write(e, t, ...n) {
|
|
477
|
-
return super.write(e, t, ...n);
|
|
478
|
-
}
|
|
479
|
-
address() {
|
|
480
|
-
return this._localAddress ?? {};
|
|
481
|
-
}
|
|
482
|
-
unref() {
|
|
483
|
-
return this;
|
|
484
|
-
}
|
|
485
|
-
ref() {
|
|
486
|
-
return this;
|
|
487
|
-
}
|
|
488
|
-
autoSelectFamilyAttemptedAddresses;
|
|
489
|
-
bufferSize;
|
|
490
|
-
bytesRead;
|
|
491
|
-
bytesWritten;
|
|
492
|
-
connecting;
|
|
493
|
-
pending;
|
|
494
|
-
get localAddress() {
|
|
495
|
-
if (!this._localAddress) throw Error("Socket is not connected");
|
|
496
|
-
return this._localAddress.address;
|
|
497
|
-
}
|
|
498
|
-
get localPort() {
|
|
499
|
-
if (!this._localAddress) throw Error("Socket is not connected");
|
|
500
|
-
return this._localAddress.port;
|
|
501
|
-
}
|
|
502
|
-
get localFamily() {
|
|
503
|
-
if (!this._localAddress) throw Error("Socket is not connected");
|
|
504
|
-
return this._localAddress.family;
|
|
505
|
-
}
|
|
506
|
-
readyState;
|
|
507
|
-
get remoteAddress() {
|
|
508
|
-
if (!this._remoteAddress) throw Error("Socket is not connected");
|
|
509
|
-
return this._remoteAddress.address;
|
|
510
|
-
}
|
|
511
|
-
get remotePort() {
|
|
512
|
-
if (!this._remoteAddress) throw Error("Socket is not connected");
|
|
513
|
-
return this._remoteAddress.port;
|
|
514
|
-
}
|
|
515
|
-
get remoteFamily() {
|
|
516
|
-
if (!this._remoteAddress) throw Error("Socket is not connected");
|
|
517
|
-
return this._remoteAddress.family;
|
|
518
|
-
}
|
|
519
|
-
timeout;
|
|
520
|
-
}, I = class extends te {
|
|
521
|
-
_localAddress;
|
|
522
|
-
_webVPNTcpSocketListenerPromise;
|
|
523
|
-
constructor(e, t) {
|
|
524
|
-
super(e), t && this.on("connection", t), e?.connection && this.__webvpn_tcp_socket_listener_init__(e.connection);
|
|
525
|
-
}
|
|
526
|
-
__webvpn_tcp_socket_listener_init__(e) {
|
|
527
|
-
return this._webVPNTcpSocketListenerPromise = e.then((e) => (this._localAddress = {
|
|
528
|
-
address: e.localAddress,
|
|
529
|
-
family: e.localFamily,
|
|
530
|
-
port: e.localPort
|
|
531
|
-
}, e)).catch((e) => {
|
|
532
|
-
this.emit("error", e);
|
|
533
|
-
}), this._webVPNTcpSocketListenerPromise.then((e) => {
|
|
534
|
-
e && this.emit("listening");
|
|
535
|
-
}), this._webVPNTcpSocketListenerPromise;
|
|
536
|
-
}
|
|
537
|
-
listen(...e) {
|
|
538
|
-
let t = Je(...e), n = (e) => {
|
|
539
|
-
let t = new F({ connection: Promise.resolve(e) });
|
|
540
|
-
this.emit("connection", t);
|
|
541
|
-
}, r = (e) => M.then((r) => r.cloud.webvpn.tcpSocketListener({
|
|
542
|
-
localAddress: e,
|
|
543
|
-
localPort: t.port,
|
|
544
|
-
onConnection: n
|
|
545
|
-
})), i = t.host ? r(t.host) : r("::").catch(() => r("0.0.0.0")), a = this.__webvpn_tcp_socket_listener_init__(i);
|
|
546
|
-
return t.callback && a.then((e) => {
|
|
547
|
-
e && t.callback.call(this);
|
|
548
|
-
}), this;
|
|
549
|
-
}
|
|
550
|
-
close(e) {
|
|
551
|
-
return this._webVPNTcpSocketListenerPromise && this._webVPNTcpSocketListenerPromise.then(async (t) => {
|
|
552
|
-
if (t) try {
|
|
553
|
-
await t.close(), this._localAddress = void 0, this.emit("close"), e && e();
|
|
554
|
-
} catch (t) {
|
|
555
|
-
this._localAddress = void 0, this.emit("close"), e && e(t);
|
|
556
|
-
}
|
|
557
|
-
}), this;
|
|
558
|
-
}
|
|
559
|
-
address() {
|
|
560
|
-
return this._localAddress ?? null;
|
|
561
|
-
}
|
|
562
|
-
getConnections(e) {
|
|
563
|
-
throw Error("Method not implemented.");
|
|
564
|
-
}
|
|
565
|
-
ref() {
|
|
566
|
-
return this;
|
|
567
|
-
}
|
|
568
|
-
unref() {
|
|
569
|
-
return this;
|
|
570
|
-
}
|
|
571
|
-
maxConnections;
|
|
572
|
-
connections;
|
|
573
|
-
listening;
|
|
574
|
-
async [Symbol.asyncDispose]() {}
|
|
575
|
-
}, Qe = (e, t) => new F().connect(e, t), $e = (e, t) => new F().connect(e, t), et = (e, t) => {
|
|
576
|
-
typeof e == "function" && (t = e, e = void 0);
|
|
577
|
-
let n = new I(e);
|
|
578
|
-
return t && n.on("connection", t), n;
|
|
579
|
-
}, tt = {
|
|
580
|
-
Socket: F,
|
|
581
|
-
Server: I,
|
|
582
|
-
connect: Qe,
|
|
583
|
-
createConnection: $e,
|
|
584
|
-
createServer: et,
|
|
585
|
-
isIP: qe,
|
|
586
|
-
isIPv4: N,
|
|
587
|
-
isIPv6: P
|
|
588
|
-
}, nt = /* @__PURE__ */ n({
|
|
589
|
-
Socket: () => rt,
|
|
590
|
-
createSocket: () => ot
|
|
591
|
-
}), rt = class extends te {
|
|
592
|
-
_type;
|
|
593
|
-
_localAddress;
|
|
594
|
-
_remoteAddress;
|
|
595
|
-
_webVPNUdpSocketPromise;
|
|
596
|
-
_dataPort;
|
|
597
|
-
_socketId;
|
|
598
|
-
_sendQueue = [];
|
|
599
|
-
_sendQueueBytes = 0;
|
|
600
|
-
_sendFlushScheduled = !1;
|
|
601
|
-
_peerTailCache = /* @__PURE__ */ new Map();
|
|
602
|
-
constructor(e) {
|
|
603
|
-
if (super(e), !e) throw Error("Missing options");
|
|
604
|
-
this._type = e.type;
|
|
605
|
-
}
|
|
606
|
-
_lastRecvBufferSize = 0;
|
|
607
|
-
_lastSendBufferSize = 0;
|
|
608
|
-
_lastTtl = 64;
|
|
609
|
-
_lastMulticastTtl = 1;
|
|
610
|
-
_lastMulticastLoopback = !0;
|
|
611
|
-
_setUdpOption(e) {
|
|
612
|
-
if (!this._webVPNUdpSocketPromise) {
|
|
613
|
-
this.emit("error", /* @__PURE__ */ Error("Cannot set socket option before bind"));
|
|
614
|
-
return;
|
|
615
|
-
}
|
|
616
|
-
this._webVPNUdpSocketPromise.then(async (t) => {
|
|
617
|
-
if (t) try {
|
|
618
|
-
await t.setOption(e);
|
|
619
|
-
} catch (e) {
|
|
620
|
-
this.emit("error", e);
|
|
621
|
-
}
|
|
622
|
-
});
|
|
623
|
-
}
|
|
624
|
-
_onDataPortBatch(e) {
|
|
625
|
-
let t = new DataView(e), n = 0;
|
|
626
|
-
for (; n + 4 <= e.byteLength;) {
|
|
627
|
-
let r = t.getUint32(n);
|
|
628
|
-
n += 4;
|
|
629
|
-
let i = n + r;
|
|
630
|
-
if (i > e.byteLength) break;
|
|
631
|
-
let a = n + 4, o = t.getUint8(a);
|
|
632
|
-
a += 1;
|
|
633
|
-
let s, c, l;
|
|
634
|
-
if (o === 2) {
|
|
635
|
-
if (!this._remoteAddress) {
|
|
636
|
-
n = i;
|
|
637
|
-
continue;
|
|
638
|
-
}
|
|
639
|
-
s = this._remoteAddress.address, c = this._remoteAddress.family, l = this._remoteAddress.port;
|
|
640
|
-
} else {
|
|
641
|
-
let n = new Uint8Array(e, a, o === 0 ? 4 : 16);
|
|
642
|
-
if (o === 0) c = "IPv4", s = `${n[0]}.${n[1]}.${n[2]}.${n[3]}`;
|
|
643
|
-
else {
|
|
644
|
-
c = "IPv6";
|
|
645
|
-
let e = [];
|
|
646
|
-
for (let t = 0; t < 16; t += 2) e.push(((n[t] << 8 | n[t + 1]) >>> 0).toString(16));
|
|
647
|
-
s = e.join(":");
|
|
648
|
-
}
|
|
649
|
-
a += n.byteLength, l = t.getUint16(a), a += 2;
|
|
650
|
-
}
|
|
651
|
-
let u = t.getUint32(a);
|
|
652
|
-
a += 4, this.emit("message", h.from(e.slice(a, a + u)), {
|
|
653
|
-
address: s,
|
|
654
|
-
family: c,
|
|
655
|
-
port: l,
|
|
656
|
-
size: u
|
|
657
|
-
}), n = i;
|
|
658
|
-
}
|
|
659
|
-
}
|
|
660
|
-
_peerTail(e, t) {
|
|
661
|
-
if (e === void 0 || t === void 0) return it;
|
|
662
|
-
let n = `${e}|${t}`, r = this._peerTailCache.get(n);
|
|
663
|
-
if (r) return r;
|
|
664
|
-
let i = p.isValid(e) ? L(e) : R(e), a = new Uint8Array(1 + i.byteLength + 2);
|
|
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;
|
|
666
|
-
}
|
|
667
|
-
_portSend(e, t, n) {
|
|
668
|
-
let r = this._peerTail(t, n), i = new Uint8Array(8 + r.byteLength + 4 + e.byteLength), a = new DataView(i.buffer);
|
|
669
|
-
a.setUint32(0, i.byteLength - 4), a.setUint32(4, this._socketId), i.set(r, 8), a.setUint32(8 + r.byteLength, e.byteLength), i.set(e, 12 + r.byteLength), this._sendQueue.push(i), this._sendQueueBytes += i.byteLength, !this._sendFlushScheduled && (this._sendFlushScheduled = !0, queueMicrotask(() => {
|
|
670
|
-
this._sendFlushScheduled = !1;
|
|
671
|
-
let e = this._sendQueue, t = this._sendQueueBytes;
|
|
672
|
-
if (this._sendQueue = [], this._sendQueueBytes = 0, !e.length || !this._dataPort) return;
|
|
673
|
-
let n = new Uint8Array(t), r = 0;
|
|
674
|
-
for (let t of e) n.set(t, r), r += t.byteLength;
|
|
675
|
-
this._dataPort.postMessage(n.buffer, [n.buffer]);
|
|
676
|
-
}));
|
|
677
|
-
}
|
|
678
|
-
addMembership(e, t) {
|
|
679
|
-
if (p.isValid(e)) {
|
|
680
|
-
let n = L(e), r = t && p.isValid(t) ? L(t) : new Uint8Array([
|
|
681
|
-
0,
|
|
682
|
-
0,
|
|
683
|
-
0,
|
|
684
|
-
0
|
|
685
|
-
]);
|
|
686
|
-
this._setUdpOption({
|
|
687
|
-
type: 5,
|
|
688
|
-
group: n,
|
|
689
|
-
interface: r
|
|
690
|
-
});
|
|
691
|
-
} else if (m.isValid(e)) {
|
|
692
|
-
let t = R(e);
|
|
693
|
-
this._setUdpOption({
|
|
694
|
-
type: 7,
|
|
695
|
-
group: t,
|
|
696
|
-
ifIndex: 0
|
|
697
|
-
});
|
|
698
|
-
} else this.emit("error", /* @__PURE__ */ Error(`Invalid multicast address: ${e}`));
|
|
699
|
-
}
|
|
700
|
-
address() {
|
|
701
|
-
if (!this._localAddress) throw Error("EBADF");
|
|
702
|
-
return this._localAddress;
|
|
703
|
-
}
|
|
704
|
-
bind(...e) {
|
|
705
|
-
let t = Ye(...e), n = this._type === "udp6" ? "::" : "0.0.0.0";
|
|
706
|
-
return this._webVPNUdpSocketPromise = M.then((e) => e.cloud.webvpn.udpSocket({
|
|
707
|
-
type: this._type,
|
|
708
|
-
address: t.address ?? n,
|
|
709
|
-
port: t.port,
|
|
710
|
-
dataPort: !0
|
|
711
|
-
})).then((e) => {
|
|
712
|
-
if (e.dataPort) this._socketId = e.socketId, this._dataPort = e.dataPort, this._dataPort.onmessage = (e) => this._onDataPortBatch(e.data);
|
|
713
|
-
else {
|
|
714
|
-
let t = e.dataReadableStream.getReader(), n = async () => {
|
|
715
|
-
let { value: e, done: r } = await t.read();
|
|
716
|
-
r || (this.emit("message", h.from(e.data), {
|
|
717
|
-
address: e.address,
|
|
718
|
-
family: e.family,
|
|
719
|
-
port: e.port,
|
|
720
|
-
size: e.size
|
|
721
|
-
}), n());
|
|
722
|
-
};
|
|
723
|
-
n();
|
|
724
|
-
}
|
|
725
|
-
return this._localAddress = {
|
|
726
|
-
address: e.localAddress,
|
|
727
|
-
family: e.localFamily,
|
|
728
|
-
port: e.localPort
|
|
729
|
-
}, e;
|
|
730
|
-
}).catch((e) => {
|
|
731
|
-
this.emit("error", e);
|
|
732
|
-
}), this._webVPNUdpSocketPromise.then((e) => {
|
|
733
|
-
e && this.emit("listening");
|
|
734
|
-
}), t.callback && this._webVPNUdpSocketPromise.then((e) => {
|
|
735
|
-
e && t.callback.call(this);
|
|
736
|
-
}), this;
|
|
737
|
-
}
|
|
738
|
-
close(e) {
|
|
739
|
-
if (!this._webVPNUdpSocketPromise) throw Error("Socket not bound");
|
|
740
|
-
return this._webVPNUdpSocketPromise.then(async (t) => {
|
|
741
|
-
if (!t) throw Error("Socket not bound");
|
|
742
|
-
this._dataPort?.close(), this._dataPort = void 0, await t.close(), e && e(), this.emit("close");
|
|
743
|
-
}), this;
|
|
744
|
-
}
|
|
745
|
-
connect(...e) {
|
|
746
|
-
if (!this._webVPNUdpSocketPromise) throw Error("Socket not bound");
|
|
747
|
-
this._webVPNUdpSocketPromise.then(async (t) => {
|
|
748
|
-
if (!t) throw Error("Socket not bound");
|
|
749
|
-
let n = e[0], r = this._type === "udp6" ? "::1" : "127.0.0.1", i = typeof e[1] == "string" ? e[1] : r, a = typeof e.at(-1) == "function" ? e.at(-1) : void 0;
|
|
750
|
-
await t.connect({
|
|
751
|
-
remotePort: n,
|
|
752
|
-
remoteAddress: i
|
|
753
|
-
}), this._remoteAddress = {
|
|
754
|
-
address: i,
|
|
755
|
-
family: this._type === "udp6" ? "IPv6" : "IPv4",
|
|
756
|
-
port: n
|
|
757
|
-
}, a && a();
|
|
758
|
-
});
|
|
759
|
-
}
|
|
760
|
-
disconnect() {
|
|
761
|
-
if (!this._webVPNUdpSocketPromise) throw Error("Socket not bound");
|
|
762
|
-
this._webVPNUdpSocketPromise.then(async (e) => {
|
|
763
|
-
if (!e) throw Error("Socket not bound");
|
|
764
|
-
await e.connect({
|
|
765
|
-
remotePort: 0,
|
|
766
|
-
remoteAddress: this._type === "udp4" ? "0.0.0.0" : "::"
|
|
767
|
-
});
|
|
768
|
-
});
|
|
769
|
-
}
|
|
770
|
-
dropMembership(e, t) {
|
|
771
|
-
if (p.isValid(e)) {
|
|
772
|
-
let n = L(e), r = t && p.isValid(t) ? L(t) : new Uint8Array([
|
|
773
|
-
0,
|
|
774
|
-
0,
|
|
775
|
-
0,
|
|
776
|
-
0
|
|
777
|
-
]);
|
|
778
|
-
this._setUdpOption({
|
|
779
|
-
type: 6,
|
|
780
|
-
group: n,
|
|
781
|
-
interface: r
|
|
782
|
-
});
|
|
783
|
-
} else if (m.isValid(e)) {
|
|
784
|
-
let t = R(e);
|
|
785
|
-
this._setUdpOption({
|
|
786
|
-
type: 8,
|
|
787
|
-
group: t,
|
|
788
|
-
ifIndex: 0
|
|
789
|
-
});
|
|
790
|
-
} else this.emit("error", /* @__PURE__ */ Error(`Invalid multicast address: ${e}`));
|
|
791
|
-
}
|
|
792
|
-
getRecvBufferSize() {
|
|
793
|
-
return this._lastRecvBufferSize;
|
|
794
|
-
}
|
|
795
|
-
getSendBufferSize() {
|
|
796
|
-
return this._lastSendBufferSize;
|
|
797
|
-
}
|
|
798
|
-
getSendQueueSize() {
|
|
799
|
-
return 0;
|
|
800
|
-
}
|
|
801
|
-
getSendQueueCount() {
|
|
802
|
-
return 0;
|
|
803
|
-
}
|
|
804
|
-
ref() {
|
|
805
|
-
return this;
|
|
806
|
-
}
|
|
807
|
-
remoteAddress() {
|
|
808
|
-
if (!this._remoteAddress) throw Error("ERR_SOCKET_DGRAM_NOT_CONNECTED");
|
|
809
|
-
return {
|
|
810
|
-
address: this._remoteAddress.address,
|
|
811
|
-
family: this._remoteAddress.family,
|
|
812
|
-
port: this._remoteAddress.port
|
|
813
|
-
};
|
|
814
|
-
}
|
|
815
|
-
send(...e) {
|
|
816
|
-
this._webVPNUdpSocketPromise || this.bind();
|
|
817
|
-
let t = Xe(...e), n = this._type === "udp6" ? "::1" : "127.0.0.1";
|
|
818
|
-
if (!this._webVPNUdpSocketPromise) throw Error("Socket not bound");
|
|
819
|
-
this._webVPNUdpSocketPromise.then((e) => {
|
|
820
|
-
if (!e) throw Error("Socket not bound");
|
|
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))) {
|
|
823
|
-
this._portSend(r, o ? void 0 : a, o ? void 0 : t.port), i?.call(this, null, r.byteLength);
|
|
824
|
-
return;
|
|
825
|
-
}
|
|
826
|
-
e.send({
|
|
827
|
-
...t,
|
|
828
|
-
address: a,
|
|
829
|
-
message: r.byteOffset === 0 && r.byteLength === r.buffer.byteLength ? r.buffer : r.buffer.slice(r.byteOffset, r.byteOffset + r.byteLength)
|
|
830
|
-
}).then(() => i?.call(this, null, r.byteLength), (e) => i ? i.call(this, e, 0) : this.emit("error", e));
|
|
831
|
-
});
|
|
832
|
-
}
|
|
833
|
-
setBroadcast(e) {
|
|
834
|
-
this._setUdpOption({
|
|
835
|
-
type: 0,
|
|
836
|
-
value: e
|
|
837
|
-
});
|
|
838
|
-
}
|
|
839
|
-
setMulticastInterface(e) {}
|
|
840
|
-
setMulticastLoopback(e) {
|
|
841
|
-
return this._setUdpOption({
|
|
842
|
-
type: 3,
|
|
843
|
-
value: e
|
|
844
|
-
}), this._setUdpOption({
|
|
845
|
-
type: 4,
|
|
846
|
-
value: e
|
|
847
|
-
}), this._lastMulticastLoopback = e, e;
|
|
848
|
-
}
|
|
849
|
-
setMulticastTTL(e) {
|
|
850
|
-
return this._setUdpOption({
|
|
851
|
-
type: 2,
|
|
852
|
-
value: e
|
|
853
|
-
}), this._lastMulticastTtl = e, e;
|
|
854
|
-
}
|
|
855
|
-
setRecvBufferSize(e) {
|
|
856
|
-
this._setUdpOption({
|
|
857
|
-
type: 10,
|
|
858
|
-
value: e
|
|
859
|
-
}), this._lastRecvBufferSize = e;
|
|
860
|
-
}
|
|
861
|
-
setSendBufferSize(e) {
|
|
862
|
-
this._setUdpOption({
|
|
863
|
-
type: 9,
|
|
864
|
-
value: e
|
|
865
|
-
}), this._lastSendBufferSize = e;
|
|
866
|
-
}
|
|
867
|
-
setTTL(e) {
|
|
868
|
-
return this._setUdpOption({
|
|
869
|
-
type: 1,
|
|
870
|
-
value: e
|
|
871
|
-
}), this._lastTtl = e, e;
|
|
872
|
-
}
|
|
873
|
-
unref() {
|
|
874
|
-
return this;
|
|
875
|
-
}
|
|
876
|
-
addSourceSpecificMembership(e, t, n) {}
|
|
877
|
-
dropSourceSpecificMembership(e, t, n) {}
|
|
878
|
-
async [Symbol.asyncDispose]() {
|
|
879
|
-
await new Promise((e) => {
|
|
880
|
-
this.close(e);
|
|
881
|
-
});
|
|
882
|
-
}
|
|
883
|
-
}, it = new Uint8Array([2]), at = (e) => {
|
|
884
|
-
if (typeof e == "string") return Ke.encode(e);
|
|
885
|
-
if (e instanceof Uint8Array) return e;
|
|
886
|
-
if (ArrayBuffer.isView(e)) return new Uint8Array(e.buffer, e.byteOffset, e.byteLength);
|
|
887
|
-
if (Array.isArray(e)) {
|
|
888
|
-
let t = e.map(at), n = new Uint8Array(t.reduce((e, t) => e + t.byteLength, 0)), r = 0;
|
|
889
|
-
for (let e of t) n.set(e, r), r += e.byteLength;
|
|
890
|
-
return n;
|
|
891
|
-
}
|
|
892
|
-
return new Uint8Array(e);
|
|
893
|
-
}, L = (e) => {
|
|
894
|
-
let t = e.split(".").map((e) => parseInt(e, 10));
|
|
895
|
-
if (t.length !== 4 || t.some((e) => Number.isNaN(e) || e < 0 || e > 255)) throw Error(`Invalid IPv4 address: ${e}`);
|
|
896
|
-
return new Uint8Array(t);
|
|
897
|
-
}, R = (e) => {
|
|
898
|
-
let t = new m(e).getBitsBase16(0, 128).match(/.{2}/g);
|
|
899
|
-
if (!t || t.length !== 16) throw Error(`Invalid IPv6 address: ${e}`);
|
|
900
|
-
return new Uint8Array(t.map((e) => parseInt(e, 16)));
|
|
901
|
-
}, ot = (e, t) => {
|
|
902
|
-
let n = new rt(typeof e == "string" ? { type: e } : e);
|
|
903
|
-
return t && n.on("message", t), n;
|
|
904
|
-
}, st = /* @__PURE__ */ n({
|
|
905
|
-
Agent: () => Y,
|
|
906
|
-
ClientRequest: () => q,
|
|
907
|
-
HTTPParser: () => U,
|
|
908
|
-
IncomingMessage: () => W,
|
|
909
|
-
METHODS: () => lt,
|
|
910
|
-
STATUS_CODES: () => z,
|
|
911
|
-
Server: () => J,
|
|
912
|
-
ServerResponse: () => K,
|
|
913
|
-
_default: () => bt,
|
|
914
|
-
createServer: () => yt,
|
|
915
|
-
default: () => bt,
|
|
916
|
-
get: () => vt,
|
|
917
|
-
globalAgent: () => _t,
|
|
918
|
-
request: () => X
|
|
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 = {
|
|
920
|
-
100: "Continue",
|
|
921
|
-
101: "Switching Protocols",
|
|
922
|
-
102: "Processing",
|
|
923
|
-
103: "Early Hints",
|
|
924
|
-
200: "OK",
|
|
925
|
-
201: "Created",
|
|
926
|
-
202: "Accepted",
|
|
927
|
-
203: "Non-Authoritative Information",
|
|
928
|
-
204: "No Content",
|
|
929
|
-
205: "Reset Content",
|
|
930
|
-
206: "Partial Content",
|
|
931
|
-
207: "Multi-Status",
|
|
932
|
-
208: "Already Reported",
|
|
933
|
-
226: "IM Used",
|
|
934
|
-
300: "Multiple Choices",
|
|
935
|
-
301: "Moved Permanently",
|
|
936
|
-
302: "Found",
|
|
937
|
-
303: "See Other",
|
|
938
|
-
304: "Not Modified",
|
|
939
|
-
305: "Use Proxy",
|
|
940
|
-
307: "Temporary Redirect",
|
|
941
|
-
308: "Permanent Redirect",
|
|
942
|
-
400: "Bad Request",
|
|
943
|
-
401: "Unauthorized",
|
|
944
|
-
402: "Payment Required",
|
|
945
|
-
403: "Forbidden",
|
|
946
|
-
404: "Not Found",
|
|
947
|
-
405: "Method Not Allowed",
|
|
948
|
-
406: "Not Acceptable",
|
|
949
|
-
407: "Proxy Authentication Required",
|
|
950
|
-
408: "Request Timeout",
|
|
951
|
-
409: "Conflict",
|
|
952
|
-
410: "Gone",
|
|
953
|
-
411: "Length Required",
|
|
954
|
-
412: "Precondition Failed",
|
|
955
|
-
413: "Payload Too Large",
|
|
956
|
-
414: "URI Too Long",
|
|
957
|
-
415: "Unsupported Media Type",
|
|
958
|
-
416: "Range Not Satisfiable",
|
|
959
|
-
417: "Expectation Failed",
|
|
960
|
-
418: "I'm a Teapot",
|
|
961
|
-
421: "Misdirected Request",
|
|
962
|
-
422: "Unprocessable Entity",
|
|
963
|
-
423: "Locked",
|
|
964
|
-
424: "Failed Dependency",
|
|
965
|
-
425: "Too Early",
|
|
966
|
-
426: "Upgrade Required",
|
|
967
|
-
428: "Precondition Required",
|
|
968
|
-
429: "Too Many Requests",
|
|
969
|
-
431: "Request Header Fields Too Large",
|
|
970
|
-
451: "Unavailable For Legal Reasons",
|
|
971
|
-
500: "Internal Server Error",
|
|
972
|
-
501: "Not Implemented",
|
|
973
|
-
502: "Bad Gateway",
|
|
974
|
-
503: "Service Unavailable",
|
|
975
|
-
504: "Gateway Timeout",
|
|
976
|
-
505: "HTTP Version Not Supported",
|
|
977
|
-
506: "Variant Also Negotiates",
|
|
978
|
-
507: "Insufficient Storage",
|
|
979
|
-
508: "Loop Detected",
|
|
980
|
-
509: "Bandwidth Limit Exceeded",
|
|
981
|
-
510: "Not Extended",
|
|
982
|
-
511: "Network Authentication Required"
|
|
983
|
-
}, ut = new Set([
|
|
984
|
-
"content-type",
|
|
985
|
-
"content-length",
|
|
986
|
-
"user-agent",
|
|
987
|
-
"referer",
|
|
988
|
-
"host",
|
|
989
|
-
"authorization",
|
|
990
|
-
"proxy-authorization",
|
|
991
|
-
"if-modified-since",
|
|
992
|
-
"if-unmodified-since",
|
|
993
|
-
"from",
|
|
994
|
-
"location",
|
|
995
|
-
"max-forwards",
|
|
996
|
-
"retry-after",
|
|
997
|
-
"etag",
|
|
998
|
-
"last-modified",
|
|
999
|
-
"server",
|
|
1000
|
-
"age",
|
|
1001
|
-
"expires"
|
|
1002
|
-
]), B = 13, V = 10, dt = /^[\^_`a-zA-Z\-0-9!#$%&'*+.|~]+$/, H = (e, t) => (e.code = t, e), ft = (e, t) => {
|
|
1003
|
-
if (e.length === 0) return t;
|
|
1004
|
-
if (t.length === 0) return e;
|
|
1005
|
-
let n = new Uint8Array(e.length + t.length);
|
|
1006
|
-
return n.set(e, 0), n.set(t, e.length), n;
|
|
1007
|
-
}, pt = (e, t) => {
|
|
1008
|
-
for (let n = t; n + 1 < e.length; n++) if (e[n] === B && e[n + 1] === V) return n;
|
|
1009
|
-
return -1;
|
|
1010
|
-
}, mt = (e) => {
|
|
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;
|
|
1012
|
-
return -1;
|
|
1013
|
-
}, U = class {
|
|
1014
|
-
buf = new Uint8Array();
|
|
1015
|
-
state = "HEAD";
|
|
1016
|
-
framing = "none";
|
|
1017
|
-
bodyRemaining = 0;
|
|
1018
|
-
chunkState = "size";
|
|
1019
|
-
skipBody = !1;
|
|
1020
|
-
constructor(e, t) {
|
|
1021
|
-
this.mode = e, this.handlers = t;
|
|
1022
|
-
}
|
|
1023
|
-
execute(e) {
|
|
1024
|
-
this.buf = ft(this.buf, e);
|
|
1025
|
-
let t = !0;
|
|
1026
|
-
for (; t;) if (t = !1, this.state === "HEAD") {
|
|
1027
|
-
let e = mt(this.buf);
|
|
1028
|
-
if (e === -1) return;
|
|
1029
|
-
let n = this.buf.subarray(0, e);
|
|
1030
|
-
this.buf = this.buf.subarray(e + 4);
|
|
1031
|
-
let r = this.parseHead(n);
|
|
1032
|
-
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);
|
|
1033
|
-
} else this.consumeBody() && (this.handlers.onComplete(), this.reset(), t = this.buf.length > 0);
|
|
1034
|
-
}
|
|
1035
|
-
finish() {
|
|
1036
|
-
this.state === "BODY" && this.framing === "eof" && (this.handlers.onComplete(), this.reset());
|
|
1037
|
-
}
|
|
1038
|
-
reset() {
|
|
1039
|
-
this.state = "HEAD", this.framing = "none", this.bodyRemaining = 0, this.chunkState = "size", this.skipBody = !1;
|
|
1040
|
-
}
|
|
1041
|
-
parseHead(e) {
|
|
1042
|
-
let t = ct.decode(e).split("\r\n"), n = t.shift() ?? "", r = [];
|
|
1043
|
-
for (let e of t) (e.startsWith(" ") || e.startsWith(" ")) && r.length > 0 ? r[r.length - 1] += " " + e.trim() : r.push(e);
|
|
1044
|
-
let i = [], a = {};
|
|
1045
|
-
for (let e of r) {
|
|
1046
|
-
if (!e) continue;
|
|
1047
|
-
let t = e.indexOf(":");
|
|
1048
|
-
if (t === -1) continue;
|
|
1049
|
-
let n = e.slice(0, t).trim(), r = e.slice(t + 1).trim();
|
|
1050
|
-
i.push(n, r), this.addHeader(a, n, r);
|
|
1051
|
-
}
|
|
1052
|
-
let o = {
|
|
1053
|
-
httpVersionMajor: 1,
|
|
1054
|
-
httpVersionMinor: 1,
|
|
1055
|
-
httpVersion: "1.1",
|
|
1056
|
-
headers: a,
|
|
1057
|
-
rawHeaders: i
|
|
1058
|
-
};
|
|
1059
|
-
if (this.mode === "request") {
|
|
1060
|
-
let [e, t, r] = n.split(" ");
|
|
1061
|
-
o.method = (e ?? "GET").toUpperCase(), o.url = t ?? "/", this.applyVersion(o, r);
|
|
1062
|
-
} else {
|
|
1063
|
-
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);
|
|
1064
|
-
o.statusCode = parseInt(a, 10) || 0, o.statusMessage = i === -1 ? "" : r.slice(i + 1), this.applyVersion(o, t);
|
|
1065
|
-
}
|
|
1066
|
-
return o;
|
|
1067
|
-
}
|
|
1068
|
-
applyVersion(e, t) {
|
|
1069
|
-
let n = /HTTP\/(\d)\.(\d)/i.exec(t ?? "");
|
|
1070
|
-
n && (e.httpVersionMajor = parseInt(n[1], 10), e.httpVersionMinor = parseInt(n[2], 10), e.httpVersion = `${e.httpVersionMajor}.${e.httpVersionMinor}`);
|
|
1071
|
-
}
|
|
1072
|
-
addHeader(e, t, n) {
|
|
1073
|
-
let r = t.toLowerCase();
|
|
1074
|
-
if (r === "set-cookie") {
|
|
1075
|
-
let t = e["set-cookie"];
|
|
1076
|
-
Array.isArray(t) ? t.push(n) : e["set-cookie"] = [n];
|
|
1077
|
-
return;
|
|
1078
|
-
}
|
|
1079
|
-
let i = e[r];
|
|
1080
|
-
i === void 0 ? e[r] = n : ut.has(r) || (e[r] = `${i}, ${n}`);
|
|
1081
|
-
}
|
|
1082
|
-
setupBody(e) {
|
|
1083
|
-
if (this.skipBody) {
|
|
1084
|
-
this.framing = "none";
|
|
1085
|
-
return;
|
|
1086
|
-
}
|
|
1087
|
-
let t = e.headers["transfer-encoding"];
|
|
1088
|
-
if (typeof t == "string" && t.toLowerCase().includes("chunked")) {
|
|
1089
|
-
this.framing = "chunked", this.chunkState = "size";
|
|
1090
|
-
return;
|
|
1091
|
-
}
|
|
1092
|
-
let n = e.headers["content-length"];
|
|
1093
|
-
if (typeof n == "string" && n !== "") {
|
|
1094
|
-
let e = parseInt(n, 10);
|
|
1095
|
-
e > 0 ? (this.framing = "length", this.bodyRemaining = e) : this.framing = "none";
|
|
1096
|
-
return;
|
|
1097
|
-
}
|
|
1098
|
-
if (this.mode === "response") {
|
|
1099
|
-
let t = e.statusCode ?? 0;
|
|
1100
|
-
t >= 100 && t < 200 || t === 204 || t === 304 ? this.framing = "none" : this.framing = "eof";
|
|
1101
|
-
} else this.framing = "none";
|
|
1102
|
-
}
|
|
1103
|
-
consumeBody() {
|
|
1104
|
-
if (this.framing === "length") {
|
|
1105
|
-
if (this.buf.length === 0) return !1;
|
|
1106
|
-
let e = Math.min(this.bodyRemaining, this.buf.length);
|
|
1107
|
-
return this.handlers.onBody(this.buf.subarray(0, e)), this.buf = this.buf.subarray(e), this.bodyRemaining -= e, this.bodyRemaining === 0;
|
|
1108
|
-
}
|
|
1109
|
-
return this.framing === "eof" ? (this.buf.length > 0 && (this.handlers.onBody(this.buf), this.buf = new Uint8Array()), !1) : this.framing === "chunked" ? this.consumeChunked() : !0;
|
|
1110
|
-
}
|
|
1111
|
-
consumeChunked() {
|
|
1112
|
-
for (;;) if (this.chunkState === "size") {
|
|
1113
|
-
let e = pt(this.buf, 0);
|
|
1114
|
-
if (e === -1) return !1;
|
|
1115
|
-
let t = ct.decode(this.buf.subarray(0, e)), n = parseInt(t.split(";")[0].trim(), 16);
|
|
1116
|
-
if (this.buf = this.buf.subarray(e + 2), Number.isNaN(n)) return !0;
|
|
1117
|
-
n === 0 ? this.chunkState = "trailer" : (this.bodyRemaining = n, this.chunkState = "data");
|
|
1118
|
-
} else if (this.chunkState === "data") {
|
|
1119
|
-
if (this.buf.length === 0) return !1;
|
|
1120
|
-
let e = Math.min(this.bodyRemaining, this.buf.length);
|
|
1121
|
-
this.handlers.onBody(this.buf.subarray(0, e)), this.buf = this.buf.subarray(e), this.bodyRemaining -= e, this.bodyRemaining === 0 && (this.chunkState = "dataCRLF");
|
|
1122
|
-
} else if (this.chunkState === "dataCRLF") {
|
|
1123
|
-
if (this.buf.length < 2) return !1;
|
|
1124
|
-
this.buf = this.buf.subarray(2), this.chunkState = "size";
|
|
1125
|
-
} else {
|
|
1126
|
-
let e = pt(this.buf, 0);
|
|
1127
|
-
if (e === -1) return !1;
|
|
1128
|
-
let t = e === 0;
|
|
1129
|
-
if (this.buf = this.buf.subarray(e + 2), t) return !0;
|
|
1130
|
-
}
|
|
1131
|
-
}
|
|
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 {
|
|
1133
|
-
httpVersion = "1.1";
|
|
1134
|
-
httpVersionMajor = 1;
|
|
1135
|
-
httpVersionMinor = 1;
|
|
1136
|
-
headers = {};
|
|
1137
|
-
rawHeaders = [];
|
|
1138
|
-
trailers = {};
|
|
1139
|
-
rawTrailers = [];
|
|
1140
|
-
method;
|
|
1141
|
-
url;
|
|
1142
|
-
statusCode;
|
|
1143
|
-
statusMessage;
|
|
1144
|
-
complete = !1;
|
|
1145
|
-
socket;
|
|
1146
|
-
constructor(e) {
|
|
1147
|
-
super(), this.socket = e;
|
|
1148
|
-
}
|
|
1149
|
-
get connection() {
|
|
1150
|
-
return this.socket;
|
|
1151
|
-
}
|
|
1152
|
-
_applyHead(e) {
|
|
1153
|
-
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;
|
|
1154
|
-
}
|
|
1155
|
-
_read() {}
|
|
1156
|
-
setTimeout(e, t) {
|
|
1157
|
-
return this.socket.setTimeout(e, t), this;
|
|
1158
|
-
}
|
|
1159
|
-
}, G = class extends f.Writable {
|
|
1160
|
-
_headerStore = /* @__PURE__ */ new Map();
|
|
1161
|
-
headersSent = !1;
|
|
1162
|
-
chunkedEncoding = !1;
|
|
1163
|
-
finished = !1;
|
|
1164
|
-
_bodyWritten = !1;
|
|
1165
|
-
setHeader(e, t) {
|
|
1166
|
-
if (this.headersSent) throw H(/* @__PURE__ */ Error("Cannot set headers after they are sent to the client"), "ERR_HTTP_HEADERS_SENT");
|
|
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");
|
|
1168
|
-
if (t === void 0) throw H(/* @__PURE__ */ TypeError(`Invalid value "undefined" for header "${e}"`), "ERR_HTTP_INVALID_HEADER_VALUE");
|
|
1169
|
-
return this._headerStore.set(e.toLowerCase(), [e, Array.isArray(t) ? [...t] : t]), this;
|
|
1170
|
-
}
|
|
1171
|
-
getHeader(e) {
|
|
1172
|
-
return this._headerStore.get(e.toLowerCase())?.[1];
|
|
1173
|
-
}
|
|
1174
|
-
getHeaderNames() {
|
|
1175
|
-
return [...this._headerStore.values()].map(([e]) => e);
|
|
1176
|
-
}
|
|
1177
|
-
getHeaders() {
|
|
1178
|
-
let e = {};
|
|
1179
|
-
for (let [t, n] of this._headerStore.values()) e[t] = n;
|
|
1180
|
-
return e;
|
|
1181
|
-
}
|
|
1182
|
-
hasHeader(e) {
|
|
1183
|
-
return this._headerStore.has(e.toLowerCase());
|
|
1184
|
-
}
|
|
1185
|
-
removeHeader(e) {
|
|
1186
|
-
if (this.headersSent) throw Error("Cannot remove headers after they are sent to the client");
|
|
1187
|
-
this._headerStore.delete(e.toLowerCase());
|
|
1188
|
-
}
|
|
1189
|
-
_storeHeader(e) {
|
|
1190
|
-
let t = this.hasHeader("content-length"), n = this.getHeader("transfer-encoding");
|
|
1191
|
-
typeof n == "string" && n.toLowerCase().includes("chunked") ? this.chunkedEncoding = !0 : !t && this._shouldSendBody() && (this.chunkedEncoding = !0, this.setHeader("Transfer-Encoding", "chunked"));
|
|
1192
|
-
let r = e + "\r\n";
|
|
1193
|
-
for (let [e, t] of this._headerStore.values()) if (Array.isArray(t)) for (let n of t) r += `${e}: ${n}\r\n`;
|
|
1194
|
-
else r += `${e}: ${t}\r\n`;
|
|
1195
|
-
return r += "\r\n", r;
|
|
1196
|
-
}
|
|
1197
|
-
_writeToSocket(e, t) {
|
|
1198
|
-
if (!this.socket) {
|
|
1199
|
-
t(/* @__PURE__ */ Error("Socket is not available"));
|
|
1200
|
-
return;
|
|
1201
|
-
}
|
|
1202
|
-
this.socket.write(e, t);
|
|
1203
|
-
}
|
|
1204
|
-
write(e, t, n) {
|
|
1205
|
-
return this._bodyWritten = !0, super.write(e, t, n);
|
|
1206
|
-
}
|
|
1207
|
-
_write(e, t, n) {
|
|
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) {
|
|
1210
|
-
n();
|
|
1211
|
-
return;
|
|
1212
|
-
}
|
|
1213
|
-
this._writeToSocket(h.concat(i), n);
|
|
1214
|
-
}
|
|
1215
|
-
_final(e) {
|
|
1216
|
-
let t = [];
|
|
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) {
|
|
1218
|
-
e();
|
|
1219
|
-
return;
|
|
1220
|
-
}
|
|
1221
|
-
this._writeToSocket(h.concat(t), e);
|
|
1222
|
-
}
|
|
1223
|
-
end(e, t, n) {
|
|
1224
|
-
if (e != null && typeof e != "function" && !this._bodyWritten && !this.headersSent && !this.chunkedEncoding && !this.hasHeader("content-length")) {
|
|
1225
|
-
let n = typeof t == "string" ? t : void 0;
|
|
1226
|
-
this.setHeader("Content-Length", ht(e, n).length);
|
|
1227
|
-
}
|
|
1228
|
-
return super.end(e, t, n);
|
|
1229
|
-
}
|
|
1230
|
-
_headBlock;
|
|
1231
|
-
}, K = class extends G {
|
|
1232
|
-
statusCode = 200;
|
|
1233
|
-
statusMessage;
|
|
1234
|
-
_writeHeadCalled = !1;
|
|
1235
|
-
sendDate = !0;
|
|
1236
|
-
req;
|
|
1237
|
-
socket;
|
|
1238
|
-
_keepAlive = !0;
|
|
1239
|
-
constructor(e) {
|
|
1240
|
-
super(), this.req = e, this.socket = e.socket;
|
|
1241
|
-
}
|
|
1242
|
-
_shouldSendBody() {
|
|
1243
|
-
if (this.req.method === "HEAD") return !1;
|
|
1244
|
-
let e = this.statusCode;
|
|
1245
|
-
return !(e >= 100 && e < 200 || e === 204 || e === 304);
|
|
1246
|
-
}
|
|
1247
|
-
writeHead(e, t, n) {
|
|
1248
|
-
if (this._writeHeadCalled || this.headersSent) throw H(/* @__PURE__ */ Error("Cannot render headers after they are sent to the client"), "ERR_HTTP_HEADERS_SENT");
|
|
1249
|
-
this._writeHeadCalled = !0, this.statusCode = e;
|
|
1250
|
-
let r = n;
|
|
1251
|
-
if (typeof t == "string" ? this.statusMessage = t : t != null && (r = t), Array.isArray(r)) {
|
|
1252
|
-
let e = Array.isArray(r[0]) ? r : Array.from({ length: Math.floor(r.length / 2) }, (e, t) => [r[t * 2], r[t * 2 + 1]]);
|
|
1253
|
-
for (let [t, n] of e) n !== void 0 && this._appendHeader(t, n);
|
|
1254
|
-
} else if (r) for (let [e, t] of Object.entries(r)) t !== void 0 && this.setHeader(e, t);
|
|
1255
|
-
return this;
|
|
1256
|
-
}
|
|
1257
|
-
_appendHeader(e, t) {
|
|
1258
|
-
let n = this.getHeader(e);
|
|
1259
|
-
if (n === void 0) this.setHeader(e, t);
|
|
1260
|
-
else {
|
|
1261
|
-
let r = [...Array.isArray(n) ? n : [n], ...Array.isArray(t) ? t : [t]].map(String);
|
|
1262
|
-
this.setHeader(e, r);
|
|
1263
|
-
}
|
|
1264
|
-
}
|
|
1265
|
-
_implicitHeader() {
|
|
1266
|
-
let e = this.statusMessage ?? z[this.statusCode] ?? "unknown";
|
|
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}`);
|
|
1268
|
-
}
|
|
1269
|
-
writeContinue() {
|
|
1270
|
-
this._writeToSocket(h.from("HTTP/1.1 100 Continue\r\n\r\n", "latin1"), () => {});
|
|
1271
|
-
}
|
|
1272
|
-
setTimeout(e, t) {
|
|
1273
|
-
return this.socket?.setTimeout(e, t), this;
|
|
1274
|
-
}
|
|
1275
|
-
}, gt = (...e) => {
|
|
1276
|
-
let t = {}, n = {}, r, i = [...e], a = i.shift();
|
|
1277
|
-
if (typeof a == "string" || a instanceof URL) {
|
|
1278
|
-
let e = typeof a == "string" ? new URL(a) : a;
|
|
1279
|
-
t = {
|
|
1280
|
-
protocol: e.protocol,
|
|
1281
|
-
hostname: e.hostname,
|
|
1282
|
-
host: e.hostname,
|
|
1283
|
-
port: e.port,
|
|
1284
|
-
path: `${e.pathname}${e.search}`,
|
|
1285
|
-
auth: e.username ? `${e.username}:${e.password}` : void 0
|
|
1286
|
-
};
|
|
1287
|
-
let o = i.shift();
|
|
1288
|
-
typeof o == "function" ? r = o : o && typeof o == "object" && (n = o, r = i.shift());
|
|
1289
|
-
} else a && typeof a == "object" && (n = a, r = i.shift());
|
|
1290
|
-
return {
|
|
1291
|
-
options: {
|
|
1292
|
-
...t,
|
|
1293
|
-
...n
|
|
1294
|
-
},
|
|
1295
|
-
callback: r
|
|
1296
|
-
};
|
|
1297
|
-
}, q = class extends G {
|
|
1298
|
-
method;
|
|
1299
|
-
path;
|
|
1300
|
-
host;
|
|
1301
|
-
protocol;
|
|
1302
|
-
socket;
|
|
1303
|
-
get connection() {
|
|
1304
|
-
return this.socket;
|
|
1305
|
-
}
|
|
1306
|
-
res = null;
|
|
1307
|
-
aborted = !1;
|
|
1308
|
-
_aborted = !1;
|
|
1309
|
-
constructor(e, t) {
|
|
1310
|
-
super(), this.method = (e.method ?? "GET").toUpperCase(), this.path = e.path ?? "/", this.protocol = e.protocol ?? "http:";
|
|
1311
|
-
let n = e.hostname ?? e.host ?? "localhost";
|
|
1312
|
-
this.host = n;
|
|
1313
|
-
let r = Number(e.port ?? (this.protocol === "https:" ? 443 : 80));
|
|
1314
|
-
if (t && this.once("response", t), e.headers) for (let [t, n] of Object.entries(e.headers)) n !== void 0 && this.setHeader(t, n);
|
|
1315
|
-
if (!this.hasHeader("host")) {
|
|
1316
|
-
let e = this.protocol === "https:" && r === 443 || this.protocol !== "https:" && r === 80;
|
|
1317
|
-
this.setHeader("Host", e ? n : `${n}:${r}`);
|
|
1318
|
-
}
|
|
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) => {
|
|
1320
|
-
this._aborted || this.emit("error", e);
|
|
1321
|
-
}), this._attachResponseParser(), this.socket.connect({
|
|
1322
|
-
host: n,
|
|
1323
|
-
port: r
|
|
1324
|
-
}, () => {
|
|
1325
|
-
this.emit("connect");
|
|
1326
|
-
});
|
|
1327
|
-
}
|
|
1328
|
-
_shouldSendBody() {
|
|
1329
|
-
return this.method !== "GET" && this.method !== "HEAD" && this.method !== "DELETE";
|
|
1330
|
-
}
|
|
1331
|
-
_implicitHeader() {
|
|
1332
|
-
this._headBlock = this._storeHeader(`${this.method} ${this.path} HTTP/1.1`);
|
|
1333
|
-
}
|
|
1334
|
-
_attachResponseParser() {
|
|
1335
|
-
let e = new W(this.socket), t = new U("response", {
|
|
1336
|
-
onHeaders: (n) => {
|
|
1337
|
-
e._applyHead(n), this.method === "HEAD" && (t.skipBody = !0), this.res = e, this.emit("response", e);
|
|
1338
|
-
},
|
|
1339
|
-
onBody: (t) => {
|
|
1340
|
-
e.push(h.from(t));
|
|
1341
|
-
},
|
|
1342
|
-
onComplete: () => {
|
|
1343
|
-
e.complete = !0, e.push(null);
|
|
1344
|
-
}
|
|
1345
|
-
});
|
|
1346
|
-
this.socket.on("data", (e) => {
|
|
1347
|
-
this._aborted || t.execute(e);
|
|
1348
|
-
}), this.socket.on("end", () => {
|
|
1349
|
-
t.finish();
|
|
1350
|
-
}), this.socket.on("close", () => {
|
|
1351
|
-
this.emit("close");
|
|
1352
|
-
});
|
|
1353
|
-
}
|
|
1354
|
-
abort() {
|
|
1355
|
-
this._aborted || (this._aborted = !0, this.aborted = !0, this.emit("abort"), this.socket.destroy());
|
|
1356
|
-
}
|
|
1357
|
-
destroy(e) {
|
|
1358
|
-
return this._aborted ? this : (this._aborted = !0, this.socket.destroy(e), super.destroy(e), this);
|
|
1359
|
-
}
|
|
1360
|
-
end(e, t, n) {
|
|
1361
|
-
return this._aborted ? this : super.end(e, t, n);
|
|
1362
|
-
}
|
|
1363
|
-
_writeToSocket(e, t) {
|
|
1364
|
-
if (this._aborted) {
|
|
1365
|
-
t();
|
|
1366
|
-
return;
|
|
1367
|
-
}
|
|
1368
|
-
super._writeToSocket(e, t);
|
|
1369
|
-
}
|
|
1370
|
-
setTimeout(e, t) {
|
|
1371
|
-
return this.socket.setTimeout(e, t), this;
|
|
1372
|
-
}
|
|
1373
|
-
setNoDelay(e) {
|
|
1374
|
-
this.socket.setNoDelay(e);
|
|
1375
|
-
}
|
|
1376
|
-
setSocketKeepAlive(e, t) {
|
|
1377
|
-
this.socket.setKeepAlive(e, t);
|
|
1378
|
-
}
|
|
1379
|
-
}, J = new Proxy(class extends I {
|
|
1380
|
-
constructor(e, t) {
|
|
1381
|
-
let n = {}, r = t;
|
|
1382
|
-
typeof e == "function" ? r = e : e && (n = e), super(n), r && this.on("request", r), this.on("connection", (e) => this._handleConnection(e));
|
|
1383
|
-
}
|
|
1384
|
-
_handleConnection(e) {
|
|
1385
|
-
let t = null, n = new U("request", {
|
|
1386
|
-
onHeaders: (r) => {
|
|
1387
|
-
t = new W(e), t._applyHead(r), r.method === "HEAD" && (n.skipBody = !0);
|
|
1388
|
-
let i = new K(t), a = String(r.headers.connection ?? "").toLowerCase();
|
|
1389
|
-
i._keepAlive = r.httpVersionMinor >= 1 ? a !== "close" : a === "keep-alive", i.on("finish", () => {
|
|
1390
|
-
i._keepAlive || e.end();
|
|
1391
|
-
}), this.emit("request", t, i);
|
|
1392
|
-
},
|
|
1393
|
-
onBody: (e) => {
|
|
1394
|
-
t?.push(h.from(e));
|
|
1395
|
-
},
|
|
1396
|
-
onComplete: () => {
|
|
1397
|
-
t && (t.complete = !0, t.push(null)), t = null;
|
|
1398
|
-
}
|
|
1399
|
-
});
|
|
1400
|
-
e.on("data", (e) => n.execute(e)), e.on("end", () => {
|
|
1401
|
-
n.finish(), t && t.push(null);
|
|
1402
|
-
}), e.on("error", (t) => this.emit("clientError", t, e));
|
|
1403
|
-
}
|
|
1404
|
-
}, { apply: (e, t, n) => new e(...n) }), Y = class {
|
|
1405
|
-
maxSockets;
|
|
1406
|
-
maxFreeSockets;
|
|
1407
|
-
keepAlive;
|
|
1408
|
-
options;
|
|
1409
|
-
constructor(e = {}) {
|
|
1410
|
-
this.options = e, this.keepAlive = !!e.keepAlive, this.maxSockets = e.maxSockets ?? Infinity, this.maxFreeSockets = e.maxFreeSockets ?? 256;
|
|
1411
|
-
}
|
|
1412
|
-
getName(e = {}) {
|
|
1413
|
-
return `${e.host ?? "localhost"}:${e.port ?? ""}:${e.localAddress ?? ""}`;
|
|
1414
|
-
}
|
|
1415
|
-
destroy() {}
|
|
1416
|
-
}, _t = new Y(), X = (...e) => {
|
|
1417
|
-
let { options: t, callback: n } = gt(...e);
|
|
1418
|
-
return new q(t, n);
|
|
1419
|
-
}, vt = (...e) => {
|
|
1420
|
-
let t = X(...e);
|
|
1421
|
-
return t.end(), t;
|
|
1422
|
-
}, yt = (e, t) => new J(e, t), bt = {
|
|
1423
|
-
METHODS: lt,
|
|
1424
|
-
STATUS_CODES: z,
|
|
1425
|
-
Agent: Y,
|
|
1426
|
-
globalAgent: _t,
|
|
1427
|
-
Server: J,
|
|
1428
|
-
ServerResponse: K,
|
|
1429
|
-
IncomingMessage: W,
|
|
1430
|
-
ClientRequest: q,
|
|
1431
|
-
OutgoingMessage: G,
|
|
1432
|
-
createServer: yt,
|
|
1433
|
-
request: X,
|
|
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) => {
|
|
1444
|
-
if (typeof window > "u") return !1;
|
|
1445
|
-
if (_()) return !0;
|
|
1446
|
-
let t = await M, n = null, r = new Promise((e) => {
|
|
1447
|
-
n = () => {
|
|
1448
|
-
_() && e(!0);
|
|
1449
|
-
}, g.addEventListener("statuschange", n);
|
|
1450
|
-
}), i = t.installPrompt.show(e).then(() => !1), a = await Promise.race([r, i]);
|
|
1451
|
-
return n && g.removeEventListener("statuschange", n), await t.installPrompt.hide().catch(() => {}), a;
|
|
1452
|
-
}, Q = null;
|
|
1453
|
-
y(() => (Q ||= Z().then(() => void 0).finally(() => {
|
|
1454
|
-
Q = null;
|
|
1455
|
-
}), Q));
|
|
1456
|
-
//#endregion
|
|
1457
|
-
//#region src/lib/desktop.ts
|
|
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) => {
|
|
1466
|
-
throw Error(`The FKN desktop app is not connected, desktop.${e} is unavailable`);
|
|
1467
|
-
}, Tt = $("fetch"), Et = { lookup: $("dns.lookup") }, Dt = {
|
|
1468
|
-
connect: $("net.connect"),
|
|
1469
|
-
createConnection: $("net.createConnection"),
|
|
1470
|
-
createServer: $("net.createServer")
|
|
1471
|
-
}, Ot = { createSocket: $("dgram.createSocket") }, kt = {
|
|
1472
|
-
isLocalDirectorySupported: () => !1,
|
|
1473
|
-
pickLocalDirectory: $("fs.pickLocalDirectory"),
|
|
1474
|
-
queryDirectoryPermission: $("fs.queryDirectoryPermission"),
|
|
1475
|
-
ensureDirectoryPermission: $("fs.ensureDirectoryPermission")
|
|
1476
|
-
}, At = () => typeof document < "u" && _(), jt = async (e, t) => {
|
|
1477
|
-
if (Ve(e), t?.credentials === "include") {
|
|
1478
|
-
if (typeof document > "u") throw Error("fetch with credentials needs the FKN extension, which only exists in window realms");
|
|
1479
|
-
return he(e, t);
|
|
1480
|
-
}
|
|
1481
|
-
return At() ? he(e, {
|
|
1482
|
-
...t,
|
|
1483
|
-
credentials: "omit"
|
|
1484
|
-
}) : wt() ? Tt(e, t) : He(e, t);
|
|
1485
|
-
}, Mt = /* @__PURE__ */ n({
|
|
1486
|
-
ATTACH_FRAME_EVENT_KEY: () => w,
|
|
1487
|
-
assertAttachableFrameUrl: () => E,
|
|
1488
|
-
assertFetchableUrl: () => C,
|
|
1489
|
-
attachFrame: () => we,
|
|
1490
|
-
attachFramePermission: () => xe,
|
|
1491
|
-
available: () => At,
|
|
1492
|
-
box: () => l,
|
|
1493
|
-
cookies: () => _e,
|
|
1494
|
-
createVideoElementHandle: () => e,
|
|
1495
|
-
evaluatePermission: () => Ce,
|
|
1496
|
-
events: () => g,
|
|
1497
|
-
extension: () => g,
|
|
1498
|
-
fetch: () => he,
|
|
1499
|
-
fetchCredentialedPermission: () => ce,
|
|
1500
|
-
fetchLocalPermission: () => le,
|
|
1501
|
-
fetchPermission: () => se,
|
|
1502
|
-
gotoPermission: () => Se,
|
|
1503
|
-
handleRevivableModules: () => i,
|
|
1504
|
-
isBlockedFetchUrl: () => S,
|
|
1505
|
-
isBlockedFrameUrl: () => T,
|
|
1506
|
-
isExtensionExposed: () => _,
|
|
1507
|
-
isLocalNetworkUrl: () => de,
|
|
1508
|
-
isType: () => t,
|
|
1509
|
-
modifyRequestHeadersPermission: () => ve,
|
|
1510
|
-
permissions: () => Te,
|
|
1511
|
-
promptInstall: () => Z,
|
|
1512
|
-
readCookiePermission: () => ge,
|
|
1513
|
-
removeRequestHeaderRule: () => be,
|
|
1514
|
-
revive: () => o,
|
|
1515
|
-
setMissingExtensionHandler: () => y,
|
|
1516
|
-
setRequestHeaderRule: () => ye,
|
|
1517
|
-
type: () => a,
|
|
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;
|
|
1526
|
-
let t = window.showDirectoryPicker;
|
|
1527
|
-
return t({
|
|
1528
|
-
mode: "readwrite",
|
|
1529
|
-
...e
|
|
1530
|
-
}).catch((e) => {
|
|
1531
|
-
if (e?.name !== "AbortError") throw e;
|
|
1532
|
-
});
|
|
1533
|
-
}, It = async (e, t = "readwrite") => {
|
|
1534
|
-
let { queryPermission: n } = e;
|
|
1535
|
-
return await n?.call(e, { mode: t }) ?? "granted";
|
|
1536
|
-
}, Lt = async (e, t = "readwrite") => {
|
|
1537
|
-
if (await It(e, t) === "granted") return !0;
|
|
1538
|
-
let { requestPermission: n } = e;
|
|
1539
|
-
return await n?.call(e, { mode: t }) === "granted";
|
|
1540
|
-
}, Rt = "https://fkn.app", zt = (e, t) => {
|
|
1
|
+
import { d as e, f as t, l as n, m as r, p as i, u as a } from "./locator-DxAsGV_o.js";
|
|
2
|
+
import { C as o, D as s, E as c, O as l, S as u, _ as d, a as f, b as p, c as m, d as h, f as g, g as _, h as v, i as y, l as b, m as x, n as S, o as C, p as w, s as T, t as E, u as D, v as O, w as k, x as A } from "./extension-Dgz0UTy0.js";
|
|
3
|
+
import { r as j, t as M } from "./api-ByfayMm1.js";
|
|
4
|
+
import "./proxy-wiZN4eTR.js";
|
|
5
|
+
import { n as N } from "./cloud-BVnscun4.js";
|
|
6
|
+
import { t as P } from "./dns.js";
|
|
7
|
+
import "./node-fs-Bd_UUx1m.js";
|
|
8
|
+
import "./storage-z0q3iena.js";
|
|
9
|
+
import "./utils-CNydj3OT.js";
|
|
10
|
+
import { s as F } from "./net-Bl6_W3bd.js";
|
|
11
|
+
import { r as I } from "./dgram-5YUb70O2.js";
|
|
12
|
+
import { t as L } from "./http.js";
|
|
13
|
+
import { t as R } from "./desktop.js";
|
|
14
|
+
import { s as z } from "./fs-B7JumDCn.js";
|
|
15
|
+
import { t as B } from "./opfs.js";
|
|
16
|
+
import { t as V } from "./account.js";
|
|
17
|
+
import { relay as H } from "osra";
|
|
18
|
+
import { createElement as U } from "react";
|
|
19
|
+
//#region src/lib/relay.ts
|
|
20
|
+
var W = "https://fkn.app", G = (e, t) => {
|
|
1541
21
|
if (typeof window > "u") throw Error("FKN @fkn/lib: relayWorker must be called from the main thread");
|
|
1542
|
-
if (!
|
|
1543
|
-
|
|
22
|
+
if (!j?.contentWindow) throw Error("FKN @fkn/lib: relayWorker called before the FKN iframe was injected");
|
|
23
|
+
H({
|
|
1544
24
|
receive: window,
|
|
1545
|
-
emit:
|
|
25
|
+
emit: j.contentWindow
|
|
1546
26
|
}, e, {
|
|
1547
27
|
key: "fkn-api",
|
|
1548
|
-
originA: t?.originA ??
|
|
28
|
+
originA: t?.originA ?? W,
|
|
1549
29
|
originB: t?.originB ?? "*",
|
|
1550
30
|
unregisterSignal: t?.unregisterSignal
|
|
1551
31
|
});
|
|
1552
|
-
},
|
|
1553
|
-
|
|
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 () => {
|
|
1558
|
-
typeof window > "u" || await (await M).account.logout().catch(() => {});
|
|
1559
|
-
}, Wt = async () => {
|
|
1560
|
-
if (typeof window > "u") return null;
|
|
1561
|
-
let e = await M.then((e) => e.account.info()).catch(() => null);
|
|
1562
|
-
return e ? {
|
|
1563
|
-
name: e.name,
|
|
1564
|
-
image: e.image,
|
|
1565
|
-
premium: e.premium,
|
|
1566
|
-
premiumUntil: e.premiumUntil ? Date.parse(e.premiumUntil) : null
|
|
1567
|
-
} : null;
|
|
1568
|
-
}, Gt = async (e) => {
|
|
1569
|
-
if (typeof window > "u") return () => {};
|
|
1570
|
-
let t = await M.catch(() => null);
|
|
1571
|
-
if (!t) return () => {};
|
|
1572
|
-
let n = await t.account.onChange(e).catch(() => null);
|
|
1573
|
-
return typeof n == "function" ? n : () => {};
|
|
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(),
|
|
32
|
+
}, K = async () => typeof window > "u" ? !1 : (await M).connect.prompt(location.origin).catch(() => !1), q = "https://fkn.app", J = (e = location.origin) => `${q}/connect-button?origin=${encodeURIComponent(e)}`, Y = ({ className: e, style: t } = {}) => U("iframe", {
|
|
33
|
+
src: J(),
|
|
1576
34
|
title: "Connect your FKN account",
|
|
1577
35
|
className: e,
|
|
1578
36
|
style: {
|
|
@@ -1585,4 +43,4 @@ var Ct = /* @__PURE__ */ n({
|
|
|
1585
43
|
}
|
|
1586
44
|
});
|
|
1587
45
|
//#endregion
|
|
1588
|
-
export {
|
|
46
|
+
export { C as ATTACH_FRAME_EVENT_KEY, Y as ConnectButton, V as account, T as assertAttachableFrameUrl, O as assertFetchableUrl, m as attachFrame, b as attachFramePermission, a as box, N as cloud, K as connect, J as connectButtonUrl, _ as cookies, e as createVideoElementHandle, R as desktop, I as dgram, P as dns, D as evaluatePermission, E as extension, S as fetch, p as fetchCredentialedPermission, A as fetchLocalPermission, u as fetchPermission, z as fs, h as gotoPermission, n as handleRevivableModules, L as http, o as isBlockedFetchUrl, g as isBlockedFrameUrl, c as isExtensionExposed, k as isLocalNetworkUrl, t as isType, w as modifyRequestHeadersPermission, F as net, B as opfs, f as permissions, y as promptInstall, d as readCookiePermission, G as relayWorker, x as removeRequestHeaderRule, i as revive, s as setMissingExtensionHandler, v as setRequestHeaderRule, r as type, l as waitForExtensionExposure };
|