@fkn/lib 0.4.7 → 0.4.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/{background-DLyTYBpc.cjs → background-BqRFQggD.cjs} +1 -1
- package/{background-CaMv-fCT.js → background-CTsVv_a0.js} +52 -27
- package/favicon.svg +5 -0
- package/index.cjs +6 -6
- package/index.d.ts +451 -258
- package/index.js +631 -299
- package/{locator-DpDoiZSP.cjs → locator-Cjl21Nkt.cjs} +1 -1
- package/{locator-CzKO_aEl.js → locator-Q5m8i40Z.js} +1 -1
- package/package.json +2 -7
- package/connect-button-Ng6Rf4-Y.cjs +0 -1
- package/connect-button-yKMuFxR9.js +0 -4
- package/react.cjs +0 -1
- package/react.d.ts +0 -10
- package/react.js +0 -18
package/index.js
CHANGED
|
@@ -1,26 +1,26 @@
|
|
|
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-
|
|
2
|
-
import {
|
|
3
|
-
import { createTypedEventTarget as ee, expose as te, relay as ne } from "osra";
|
|
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 ee, relay as te } from "osra";
|
|
4
3
|
import { Stream as d } from "stream";
|
|
5
|
-
import { EventEmitter as
|
|
4
|
+
import { EventEmitter as ne } from "events";
|
|
6
5
|
import { Address4 as f, Address6 as p } from "ip-address";
|
|
7
6
|
import { Buffer as m } from "buffer";
|
|
7
|
+
import { createElement as re } 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 =
|
|
10
|
-
typeof document < "u" && document.addEventListener(ie, (
|
|
11
|
-
h.dispatchEvent(new CustomEvent("statuschange", { detail: { enabled:
|
|
9
|
+
var ie = "FKN_WEB_EXTENSION_MAIN_WORLD_CONTENT_SCRIPT_ENABLED_EVENT_KEY", ae = "fknExtension", h = u();
|
|
10
|
+
typeof document < "u" && document.addEventListener(ie, () => {
|
|
11
|
+
h.dispatchEvent(new CustomEvent("statuschange", { detail: { enabled: g() } }));
|
|
12
12
|
});
|
|
13
|
-
var g = () => typeof document > "u" ? !1 : document.documentElement.dataset[ae] === "true",
|
|
14
|
-
|
|
15
|
-
},
|
|
13
|
+
var g = () => typeof document > "u" ? !1 : document.documentElement.dataset[ae] === "true", oe = null, se = (e) => {
|
|
14
|
+
oe = e;
|
|
15
|
+
}, ce = 150, _ = (e = 1e3) => new Promise((t, n) => {
|
|
16
16
|
if (g()) 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 (
|
|
20
|
+
if (oe && (await oe().catch(() => {}), g())) 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(),
|
|
23
|
+
clearTimeout(r), r = setTimeout(() => g() ? i(t) : a(), ce);
|
|
24
24
|
}, s = new MutationObserver(() => {
|
|
25
25
|
g() && i(t);
|
|
26
26
|
}), c = () => {
|
|
@@ -31,39 +31,39 @@ var g = () => typeof document > "u" ? !1 : document.documentElement.dataset[ae]
|
|
|
31
31
|
attributeFilter: ["data-fkn-extension"]
|
|
32
32
|
}), document.addEventListener("readystatechange", c), document.readyState === "complete") return o();
|
|
33
33
|
g() && i(t);
|
|
34
|
-
}),
|
|
35
|
-
await
|
|
34
|
+
}), le, v = new Proxy({}, { get: (e, t) => async (...e) => {
|
|
35
|
+
await _(), le ??= ee({}, {
|
|
36
36
|
transport: window,
|
|
37
37
|
revivableModules: i
|
|
38
38
|
});
|
|
39
|
-
let n = (await
|
|
39
|
+
let n = (await le)[t];
|
|
40
40
|
return n(...e);
|
|
41
|
-
} }),
|
|
41
|
+
} }), ue = {
|
|
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
|
-
},
|
|
47
|
+
}, de = {
|
|
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
|
-
},
|
|
54
|
+
}, fe = {
|
|
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
|
-
},
|
|
61
|
+
}, pe = (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
|
-
},
|
|
66
|
+
}, me = (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:") :
|
|
75
|
-
},
|
|
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:") : pe(n);
|
|
75
|
+
}, he = ["fkn.app", "fkn.dev"], ge = (e) => {
|
|
76
76
|
let t;
|
|
77
77
|
try {
|
|
78
78
|
t = new URL(e);
|
|
@@ -81,46 +81,46 @@ 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
|
|
85
|
-
},
|
|
86
|
-
if (
|
|
87
|
-
},
|
|
84
|
+
return he.some((e) => n === e || n.endsWith(`.${e}`));
|
|
85
|
+
}, _e = (e) => {
|
|
86
|
+
if (ge(e)) throw Error("fetch: refusing to target the extension's own pages or FKN platform domains");
|
|
87
|
+
}, ve = ["origin", "referer"], ye = (e) => {
|
|
88
88
|
if (!e?.headers) return;
|
|
89
|
-
let t = new Headers(e.headers), n =
|
|
89
|
+
let t = new Headers(e.headers), n = ve.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
|
-
},
|
|
94
|
+
}, be = async (e, t) => {
|
|
95
95
|
let n = new Request(e, t);
|
|
96
|
-
|
|
96
|
+
_e(n.url);
|
|
97
97
|
let r = n.body ? await n.arrayBuffer() : null;
|
|
98
|
-
return
|
|
98
|
+
return v.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:
|
|
105
|
+
unsafeHeaders: ye(t),
|
|
106
106
|
reason: t?.reason,
|
|
107
107
|
signal: t?.signal ?? void 0
|
|
108
108
|
});
|
|
109
|
-
},
|
|
109
|
+
}, xe = {
|
|
110
110
|
scope: "network.readCookie",
|
|
111
111
|
category: "network",
|
|
112
112
|
severity: 3,
|
|
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
|
-
},
|
|
116
|
+
}, Se = { get: (e) => v.getCookie(e) }, Ce = {
|
|
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
|
-
},
|
|
123
|
+
}, we = (e) => v.setRequestHeaderRule(e), Te = (e) => v.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);
|
|
@@ -128,7 +128,7 @@ var g = () => typeof document > "u" ? !1 : document.documentElement.dataset[ae]
|
|
|
128
128
|
})();
|
|
129
129
|
//#endregion
|
|
130
130
|
//#region node_modules/@mfkn/web-extension/lib/lib/frame.js
|
|
131
|
-
var
|
|
131
|
+
var Ee = "FKN_WEB_EXTENSION_ATTACH_FRAME_EVENT_KEY", De = (e) => {
|
|
132
132
|
if (!e || e === "about:blank") return !1;
|
|
133
133
|
let t;
|
|
134
134
|
try {
|
|
@@ -140,52 +140,61 @@ var w = "FKN_WEB_EXTENSION_ATTACH_FRAME_EVENT_KEY", T = (e) => {
|
|
|
140
140
|
if (t.protocol === "about:") return !1;
|
|
141
141
|
let n = t.hostname;
|
|
142
142
|
return n === "fkn.app" || n.endsWith(".fkn.app");
|
|
143
|
-
},
|
|
144
|
-
if (
|
|
145
|
-
},
|
|
143
|
+
}, y = (e) => {
|
|
144
|
+
if (De(e)) throw Error("attachFrame: refusing to target the extension's own pages or fkn.app");
|
|
145
|
+
}, Oe = {
|
|
146
146
|
scope: "embed.iframe",
|
|
147
147
|
category: "embed",
|
|
148
148
|
severity: 0,
|
|
149
149
|
title: "Load another website inside this app",
|
|
150
150
|
description: "Lets the app embed external pages directly inside its own view."
|
|
151
|
-
},
|
|
151
|
+
}, ke = {
|
|
152
152
|
scope: "embed.open",
|
|
153
153
|
category: "embed",
|
|
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
|
-
},
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
157
|
+
}, Ae = {
|
|
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
|
+
}, je = async ({ iframe: e, domains: t = [], syncCookies: n = !0, lockdown: r = !1 }) => {
|
|
164
|
+
let i = crypto.randomUUID();
|
|
165
|
+
if (y(e.src), await _(), !e.isConnected) throw Error("attachFrame: the iframe must be connected to the document before attaching");
|
|
166
|
+
e.dispatchEvent(new CustomEvent(Ee, { detail: i }));
|
|
167
|
+
let { executeLocator: a, ensureLocatorPermission: o, goto: c, evaluate: l } = await v.attachFrame({
|
|
168
|
+
marker: i,
|
|
169
|
+
domains: t,
|
|
170
|
+
syncCookies: n,
|
|
171
|
+
lockdown: r
|
|
172
|
+
}), u = s(a, o), ee = (e, t = {}) => (y(e), c({
|
|
165
173
|
url: e,
|
|
166
174
|
...t
|
|
167
|
-
})), l = () => e.src;
|
|
175
|
+
})), te = ((e, t) => l(e, t)), d = () => e.src;
|
|
168
176
|
return {
|
|
169
|
-
...
|
|
170
|
-
goto:
|
|
171
|
-
|
|
177
|
+
...u,
|
|
178
|
+
goto: ee,
|
|
179
|
+
evaluate: te,
|
|
180
|
+
url: d
|
|
172
181
|
};
|
|
173
|
-
},
|
|
182
|
+
}, Me = { request: (e) => v.requestPermissions(e.map((e) => ({
|
|
174
183
|
key: e.key,
|
|
175
184
|
scope: e.scope ?? "",
|
|
176
185
|
reason: e.reason
|
|
177
|
-
}))) },
|
|
186
|
+
}))) }, Ne = 32, Pe = typeof CSS < "u" && CSS.supports("clip-path", "path('M0 0H1V1H0Z')"), Fe = (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
|
-
},
|
|
181
|
-
if (!
|
|
189
|
+
}, Ie = ({ x: e, y: t, width: n, height: r }) => `M${e} ${t}h${n}v${r}h${-n}Z`, Le = (e, { modal: t, rects: n }) => {
|
|
190
|
+
if (!Pe) {
|
|
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(
|
|
195
|
+
let r = t ? "none" : n.length === 0 ? "inset(100%)" : `path('${n.map(Ie).join("")}')`, i = r === "none" || CSS.supports("clip-path", r) ? r : "inset(100%)";
|
|
187
196
|
e.style.setProperty("clip-path", i, "important");
|
|
188
|
-
},
|
|
197
|
+
}, Re = (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
|
-
},
|
|
213
|
+
}, ze = (e) => {
|
|
205
214
|
if (typeof e != "object" || !e) return null;
|
|
206
|
-
let t = e, n = (Array.isArray(t.rects) ? t.rects.slice(0,
|
|
215
|
+
let t = e, n = (Array.isArray(t.rects) ? t.rects.slice(0, Ne) : []).map(Re).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
|
-
},
|
|
212
|
-
|
|
220
|
+
}, b = null, Be = () => b !== null, Ve = (e) => {
|
|
221
|
+
Fe(e), Le(e, {
|
|
213
222
|
modal: !1,
|
|
214
223
|
rects: []
|
|
215
|
-
}),
|
|
216
|
-
},
|
|
217
|
-
if (!
|
|
218
|
-
let t =
|
|
219
|
-
t &&
|
|
220
|
-
},
|
|
221
|
-
!
|
|
222
|
-
var
|
|
223
|
-
|
|
224
|
-
var
|
|
225
|
-
if (typeof window < "u") return
|
|
224
|
+
}), b = e;
|
|
225
|
+
}, He = (e) => {
|
|
226
|
+
if (!b) return;
|
|
227
|
+
let t = ze(e);
|
|
228
|
+
t && Le(b, t);
|
|
229
|
+
}, Ue = "https://fkn.app", x = typeof globalThis < "u" && globalThis.document ? globalThis.document : void 0, We = x?.querySelector(`iframe[src="${Ue}/api"]`) ?? null, S = x?.createElement("iframe") ?? null;
|
|
230
|
+
!We && S && x && (S.src = `${Ue}/api`, x.body.appendChild(S));
|
|
231
|
+
var C = We ?? S, Ge = C?.contentWindow ?? null;
|
|
232
|
+
C && x && Ve(C);
|
|
233
|
+
var Ke = (() => {
|
|
234
|
+
if (typeof window < "u") return Ge ? {
|
|
226
235
|
receive: window,
|
|
227
|
-
emit:
|
|
236
|
+
emit: Ge
|
|
228
237
|
} : void 0;
|
|
229
238
|
if (typeof self < "u") return {
|
|
230
239
|
receive: self,
|
|
231
240
|
emit: self
|
|
232
241
|
};
|
|
233
|
-
})(),
|
|
242
|
+
})(), qe = Ke !== void 0, w = Ke ? ee({}, {
|
|
234
243
|
key: "fkn-api",
|
|
235
|
-
transport:
|
|
244
|
+
transport: Ke
|
|
236
245
|
}) : new Promise(() => {});
|
|
237
|
-
|
|
238
|
-
|
|
246
|
+
w.then((e) => {
|
|
247
|
+
Be() && e.overlay.setHost(He);
|
|
239
248
|
}, () => {});
|
|
240
249
|
//#endregion
|
|
241
250
|
//#region src/lib/fkn-target.ts
|
|
242
|
-
var
|
|
251
|
+
var Je = ["fkn.app", "fkn.dev"], Ye = (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,9 +256,9 @@ var ze = ["fkn.app", "fkn.dev"], Be = (e) => {
|
|
|
247
256
|
return;
|
|
248
257
|
}
|
|
249
258
|
let r = n.hostname;
|
|
250
|
-
if (
|
|
251
|
-
},
|
|
252
|
-
let e = await
|
|
259
|
+
if (Je.some((e) => r === e || r.endsWith(`.${e}`))) throw Error(`fetch refuses FKN platform domains (${r})`);
|
|
260
|
+
}, Xe = (e, t) => (Ye(e), w.then((n) => n.cloud.fetch(e, t))), Ze = async () => {
|
|
261
|
+
let e = await w.then((e) => e.cloud.quota());
|
|
253
262
|
return {
|
|
254
263
|
premium: e.premium,
|
|
255
264
|
overQuota: e.overQuota,
|
|
@@ -260,9 +269,16 @@ var ze = ["fkn.app", "fkn.dev"], Be = (e) => {
|
|
|
260
269
|
bytesPerSecond: e.bytesPerSecond,
|
|
261
270
|
bitsPerSecond: e.bytesPerSecond * 8
|
|
262
271
|
};
|
|
263
|
-
},
|
|
272
|
+
}, Qe = /* @__PURE__ */ n({ lookup: () => $e }), $e = (e, t) => w.then((n) => n.cloud.dns.lookup(e, t)), et = /* @__PURE__ */ n({
|
|
273
|
+
available: () => tt,
|
|
274
|
+
list: () => nt,
|
|
275
|
+
quota: () => rt,
|
|
276
|
+
readFile: () => T,
|
|
277
|
+
remove: () => at,
|
|
278
|
+
writeFile: () => it
|
|
279
|
+
}), tt = () => w.then((e) => e.cloud.fs.available()).catch(() => !1), nt = () => w.then((e) => e.cloud.fs.list()), rt = () => w.then((e) => e.cloud.fs.quota()), T = async (e) => await (await w).cloud.fs.readFile(e), it = (e, t, n) => w.then((r) => r.cloud.fs.writeFile(e, t, n?.contentType ?? null)).then(() => void 0), at = (e) => w.then((t) => t.cloud.fs.remove(e)).then(() => void 0), ot = new TextEncoder();
|
|
264
280
|
new TextDecoder();
|
|
265
|
-
var
|
|
281
|
+
var st = (e) => f.isValid(e), ct = (e) => p.isValid(e), lt = (e) => st(e) ? 4 : ct(e) ? 6 : 0, ut = (...e) => {
|
|
266
282
|
if (typeof e[0] == "string") throw Error("FKN WebVPN does not support IPC connections");
|
|
267
283
|
let t = typeof e.at(-1) == "function" ? e.at(-1) : void 0;
|
|
268
284
|
return e[0] && typeof e[0] == "object" ? {
|
|
@@ -273,7 +289,7 @@ var N = (e) => f.isValid(e), P = (e) => p.isValid(e), Ke = (e) => N(e) ? 4 : P(e
|
|
|
273
289
|
host: typeof e[1] == "string" ? e[1] : void 0,
|
|
274
290
|
callback: t
|
|
275
291
|
};
|
|
276
|
-
},
|
|
292
|
+
}, dt = (...e) => {
|
|
277
293
|
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
294
|
return typeof e[0] == "object" ? {
|
|
279
295
|
...e[0],
|
|
@@ -285,7 +301,7 @@ var N = (e) => f.isValid(e), P = (e) => p.isValid(e), Ke = (e) => N(e) ? 4 : P(e
|
|
|
285
301
|
port: n,
|
|
286
302
|
callback: t
|
|
287
303
|
};
|
|
288
|
-
},
|
|
304
|
+
}, ft = (...e) => {
|
|
289
305
|
let t = typeof e.at(-1) == "function" ? e.at(-1) : void 0, n = e[0];
|
|
290
306
|
if (typeof e[2] == "number") return {
|
|
291
307
|
message: n,
|
|
@@ -310,18 +326,18 @@ var N = (e) => f.isValid(e), P = (e) => p.isValid(e), Ke = (e) => N(e) ? 4 : P(e
|
|
|
310
326
|
new TextEncoder(), new TextDecoder();
|
|
311
327
|
//#endregion
|
|
312
328
|
//#region src/lib/webvpn/net.ts
|
|
313
|
-
var
|
|
314
|
-
Server: () =>
|
|
315
|
-
Socket: () =>
|
|
316
|
-
_default: () =>
|
|
317
|
-
connect: () =>
|
|
318
|
-
createConnection: () =>
|
|
319
|
-
createServer: () =>
|
|
320
|
-
default: () =>
|
|
321
|
-
isIP: () =>
|
|
322
|
-
isIPv4: () =>
|
|
323
|
-
isIPv6: () =>
|
|
324
|
-
}),
|
|
329
|
+
var pt = /* @__PURE__ */ n({
|
|
330
|
+
Server: () => D,
|
|
331
|
+
Socket: () => E,
|
|
332
|
+
_default: () => _t,
|
|
333
|
+
connect: () => mt,
|
|
334
|
+
createConnection: () => ht,
|
|
335
|
+
createServer: () => gt,
|
|
336
|
+
default: () => _t,
|
|
337
|
+
isIP: () => lt,
|
|
338
|
+
isIPv4: () => st,
|
|
339
|
+
isIPv6: () => ct
|
|
340
|
+
}), E = class extends d.Duplex {
|
|
325
341
|
_localAddress;
|
|
326
342
|
_remoteAddress;
|
|
327
343
|
_webVPNTcpSocketPromise;
|
|
@@ -381,7 +397,7 @@ var Xe = /* @__PURE__ */ n({
|
|
|
381
397
|
}).catch(n);
|
|
382
398
|
}
|
|
383
399
|
connect(...e) {
|
|
384
|
-
let t =
|
|
400
|
+
let t = ut(...e), n = this.__webvpn_tcp_socket_init__(w.then((e) => e.cloud.webvpn.tcpSocket({
|
|
385
401
|
remoteAddress: t.host ?? "localhost",
|
|
386
402
|
remotePort: t.port
|
|
387
403
|
})));
|
|
@@ -508,7 +524,7 @@ var Xe = /* @__PURE__ */ n({
|
|
|
508
524
|
return this._remoteAddress.family;
|
|
509
525
|
}
|
|
510
526
|
timeout;
|
|
511
|
-
},
|
|
527
|
+
}, D = class extends ne {
|
|
512
528
|
_localAddress;
|
|
513
529
|
_webVPNTcpSocketListenerPromise;
|
|
514
530
|
constructor(e, t) {
|
|
@@ -526,10 +542,10 @@ var Xe = /* @__PURE__ */ n({
|
|
|
526
542
|
}), this._webVPNTcpSocketListenerPromise;
|
|
527
543
|
}
|
|
528
544
|
listen(...e) {
|
|
529
|
-
let t =
|
|
530
|
-
let t = new
|
|
545
|
+
let t = ut(...e), n = (e) => {
|
|
546
|
+
let t = new E({ connection: Promise.resolve(e) });
|
|
531
547
|
this.emit("connection", t);
|
|
532
|
-
}, r = (e) =>
|
|
548
|
+
}, r = (e) => w.then((r) => r.cloud.webvpn.tcpSocketListener({
|
|
533
549
|
localAddress: e,
|
|
534
550
|
localPort: t.port,
|
|
535
551
|
onConnection: n
|
|
@@ -563,23 +579,23 @@ var Xe = /* @__PURE__ */ n({
|
|
|
563
579
|
connections;
|
|
564
580
|
listening;
|
|
565
581
|
async [Symbol.asyncDispose]() {}
|
|
566
|
-
},
|
|
582
|
+
}, mt = (e, t) => new E().connect(e, t), ht = (e, t) => new E().connect(e, t), gt = (e, t) => {
|
|
567
583
|
typeof e == "function" && (t = e, e = void 0);
|
|
568
|
-
let n = new
|
|
584
|
+
let n = new D(e);
|
|
569
585
|
return t && n.on("connection", t), n;
|
|
570
|
-
},
|
|
571
|
-
Socket:
|
|
572
|
-
Server:
|
|
573
|
-
connect:
|
|
574
|
-
createConnection:
|
|
575
|
-
createServer:
|
|
576
|
-
isIP:
|
|
577
|
-
isIPv4:
|
|
578
|
-
isIPv6:
|
|
579
|
-
},
|
|
580
|
-
Socket: () =>
|
|
581
|
-
createSocket: () =>
|
|
582
|
-
}),
|
|
586
|
+
}, _t = {
|
|
587
|
+
Socket: E,
|
|
588
|
+
Server: D,
|
|
589
|
+
connect: mt,
|
|
590
|
+
createConnection: ht,
|
|
591
|
+
createServer: gt,
|
|
592
|
+
isIP: lt,
|
|
593
|
+
isIPv4: st,
|
|
594
|
+
isIPv6: ct
|
|
595
|
+
}, vt = /* @__PURE__ */ n({
|
|
596
|
+
Socket: () => yt,
|
|
597
|
+
createSocket: () => Ct
|
|
598
|
+
}), yt = class extends ne {
|
|
583
599
|
_type;
|
|
584
600
|
_localAddress;
|
|
585
601
|
_remoteAddress;
|
|
@@ -649,10 +665,10 @@ var Xe = /* @__PURE__ */ n({
|
|
|
649
665
|
}
|
|
650
666
|
}
|
|
651
667
|
_peerTail(e, t) {
|
|
652
|
-
if (e === void 0 || t === void 0) return
|
|
668
|
+
if (e === void 0 || t === void 0) return bt;
|
|
653
669
|
let n = `${e}|${t}`, r = this._peerTailCache.get(n);
|
|
654
670
|
if (r) return r;
|
|
655
|
-
let i = f.isValid(e) ?
|
|
671
|
+
let i = f.isValid(e) ? O(e) : St(e), a = new Uint8Array(1 + i.byteLength + 2);
|
|
656
672
|
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
673
|
}
|
|
658
674
|
_portSend(e, t, n) {
|
|
@@ -668,7 +684,7 @@ var Xe = /* @__PURE__ */ n({
|
|
|
668
684
|
}
|
|
669
685
|
addMembership(e, t) {
|
|
670
686
|
if (f.isValid(e)) {
|
|
671
|
-
let n =
|
|
687
|
+
let n = O(e), r = t && f.isValid(t) ? O(t) : new Uint8Array([
|
|
672
688
|
0,
|
|
673
689
|
0,
|
|
674
690
|
0,
|
|
@@ -680,7 +696,7 @@ var Xe = /* @__PURE__ */ n({
|
|
|
680
696
|
interface: r
|
|
681
697
|
});
|
|
682
698
|
} else if (p.isValid(e)) {
|
|
683
|
-
let t =
|
|
699
|
+
let t = St(e);
|
|
684
700
|
this._setUdpOption({
|
|
685
701
|
type: 7,
|
|
686
702
|
group: t,
|
|
@@ -693,8 +709,8 @@ var Xe = /* @__PURE__ */ n({
|
|
|
693
709
|
return this._localAddress;
|
|
694
710
|
}
|
|
695
711
|
bind(...e) {
|
|
696
|
-
let t =
|
|
697
|
-
return this._webVPNUdpSocketPromise =
|
|
712
|
+
let t = dt(...e), n = this._type === "udp6" ? "::" : "0.0.0.0";
|
|
713
|
+
return this._webVPNUdpSocketPromise = w.then((e) => e.cloud.webvpn.udpSocket({
|
|
698
714
|
type: this._type,
|
|
699
715
|
address: t.address ?? n,
|
|
700
716
|
port: t.port,
|
|
@@ -760,7 +776,7 @@ var Xe = /* @__PURE__ */ n({
|
|
|
760
776
|
}
|
|
761
777
|
dropMembership(e, t) {
|
|
762
778
|
if (f.isValid(e)) {
|
|
763
|
-
let n =
|
|
779
|
+
let n = O(e), r = t && f.isValid(t) ? O(t) : new Uint8Array([
|
|
764
780
|
0,
|
|
765
781
|
0,
|
|
766
782
|
0,
|
|
@@ -772,7 +788,7 @@ var Xe = /* @__PURE__ */ n({
|
|
|
772
788
|
interface: r
|
|
773
789
|
});
|
|
774
790
|
} else if (p.isValid(e)) {
|
|
775
|
-
let t =
|
|
791
|
+
let t = St(e);
|
|
776
792
|
this._setUdpOption({
|
|
777
793
|
type: 8,
|
|
778
794
|
group: t,
|
|
@@ -805,11 +821,11 @@ var Xe = /* @__PURE__ */ n({
|
|
|
805
821
|
}
|
|
806
822
|
send(...e) {
|
|
807
823
|
this._webVPNUdpSocketPromise || this.bind();
|
|
808
|
-
let t =
|
|
824
|
+
let t = ft(...e), n = this._type === "udp6" ? "::1" : "127.0.0.1";
|
|
809
825
|
if (!this._webVPNUdpSocketPromise) throw Error("Socket not bound");
|
|
810
826
|
this._webVPNUdpSocketPromise.then((e) => {
|
|
811
827
|
if (!e) throw Error("Socket not bound");
|
|
812
|
-
let r =
|
|
828
|
+
let r = xt(t.message), i = t.callback, a = t.address ?? n, o = this._remoteAddress !== void 0 && t.address === void 0;
|
|
813
829
|
if (this._dataPort && (o || f.isValid(a) || p.isValid(a))) {
|
|
814
830
|
this._portSend(r, o ? void 0 : a, o ? void 0 : t.port), i?.call(this, null, r.byteLength);
|
|
815
831
|
return;
|
|
@@ -871,43 +887,43 @@ var Xe = /* @__PURE__ */ n({
|
|
|
871
887
|
this.close(e);
|
|
872
888
|
});
|
|
873
889
|
}
|
|
874
|
-
},
|
|
875
|
-
if (typeof e == "string") return
|
|
890
|
+
}, bt = new Uint8Array([2]), xt = (e) => {
|
|
891
|
+
if (typeof e == "string") return ot.encode(e);
|
|
876
892
|
if (e instanceof Uint8Array) return e;
|
|
877
893
|
if (ArrayBuffer.isView(e)) return new Uint8Array(e.buffer, e.byteOffset, e.byteLength);
|
|
878
894
|
if (Array.isArray(e)) {
|
|
879
|
-
let t = e.map(
|
|
895
|
+
let t = e.map(xt), n = new Uint8Array(t.reduce((e, t) => e + t.byteLength, 0)), r = 0;
|
|
880
896
|
for (let e of t) n.set(e, r), r += e.byteLength;
|
|
881
897
|
return n;
|
|
882
898
|
}
|
|
883
899
|
return new Uint8Array(e);
|
|
884
|
-
},
|
|
900
|
+
}, O = (e) => {
|
|
885
901
|
let t = e.split(".").map((e) => parseInt(e, 10));
|
|
886
902
|
if (t.length !== 4 || t.some((e) => Number.isNaN(e) || e < 0 || e > 255)) throw Error(`Invalid IPv4 address: ${e}`);
|
|
887
903
|
return new Uint8Array(t);
|
|
888
|
-
},
|
|
904
|
+
}, St = (e) => {
|
|
889
905
|
let t = new p(e).getBitsBase16(0, 128).match(/.{2}/g);
|
|
890
906
|
if (!t || t.length !== 16) throw Error(`Invalid IPv6 address: ${e}`);
|
|
891
907
|
return new Uint8Array(t.map((e) => parseInt(e, 16)));
|
|
892
|
-
},
|
|
893
|
-
let n = new
|
|
908
|
+
}, Ct = (e, t) => {
|
|
909
|
+
let n = new yt(typeof e == "string" ? { type: e } : e);
|
|
894
910
|
return t && n.on("message", t), n;
|
|
895
|
-
},
|
|
896
|
-
Agent: () =>
|
|
897
|
-
ClientRequest: () =>
|
|
898
|
-
HTTPParser: () =>
|
|
899
|
-
IncomingMessage: () =>
|
|
900
|
-
METHODS: () =>
|
|
901
|
-
STATUS_CODES: () =>
|
|
902
|
-
Server: () =>
|
|
903
|
-
ServerResponse: () =>
|
|
904
|
-
_default: () =>
|
|
905
|
-
createServer: () =>
|
|
906
|
-
default: () =>
|
|
907
|
-
get: () =>
|
|
908
|
-
globalAgent: () =>
|
|
909
|
-
request: () =>
|
|
910
|
-
}),
|
|
911
|
+
}, wt = /* @__PURE__ */ n({
|
|
912
|
+
Agent: () => Vt,
|
|
913
|
+
ClientRequest: () => zt,
|
|
914
|
+
HTTPParser: () => A,
|
|
915
|
+
IncomingMessage: () => j,
|
|
916
|
+
METHODS: () => Et,
|
|
917
|
+
STATUS_CODES: () => Dt,
|
|
918
|
+
Server: () => Bt,
|
|
919
|
+
ServerResponse: () => Lt,
|
|
920
|
+
_default: () => Kt,
|
|
921
|
+
createServer: () => Gt,
|
|
922
|
+
default: () => Kt,
|
|
923
|
+
get: () => Wt,
|
|
924
|
+
globalAgent: () => Ht,
|
|
925
|
+
request: () => Ut
|
|
926
|
+
}), Tt = new TextDecoder("latin1"), Et = /* @__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("."), Dt = {
|
|
911
927
|
100: "Continue",
|
|
912
928
|
101: "Switching Protocols",
|
|
913
929
|
102: "Processing",
|
|
@@ -971,7 +987,7 @@ var Xe = /* @__PURE__ */ n({
|
|
|
971
987
|
509: "Bandwidth Limit Exceeded",
|
|
972
988
|
510: "Not Extended",
|
|
973
989
|
511: "Network Authentication Required"
|
|
974
|
-
},
|
|
990
|
+
}, Ot = new Set([
|
|
975
991
|
"content-type",
|
|
976
992
|
"content-length",
|
|
977
993
|
"user-agent",
|
|
@@ -990,18 +1006,18 @@ var Xe = /* @__PURE__ */ n({
|
|
|
990
1006
|
"server",
|
|
991
1007
|
"age",
|
|
992
1008
|
"expires"
|
|
993
|
-
]),
|
|
1009
|
+
]), kt = 13, At = 10, jt = /^[\^_`a-zA-Z\-0-9!#$%&'*+.|~]+$/, k = (e, t) => (e.code = t, e), Mt = (e, t) => {
|
|
994
1010
|
if (e.length === 0) return t;
|
|
995
1011
|
if (t.length === 0) return e;
|
|
996
1012
|
let n = new Uint8Array(e.length + t.length);
|
|
997
1013
|
return n.set(e, 0), n.set(t, e.length), n;
|
|
998
|
-
},
|
|
999
|
-
for (let n = t; n + 1 < e.length; n++) if (e[n] ===
|
|
1014
|
+
}, Nt = (e, t) => {
|
|
1015
|
+
for (let n = t; n + 1 < e.length; n++) if (e[n] === kt && e[n + 1] === At) return n;
|
|
1000
1016
|
return -1;
|
|
1001
|
-
},
|
|
1002
|
-
for (let t = 0; t + 3 < e.length; t++) if (e[t] ===
|
|
1017
|
+
}, Pt = (e) => {
|
|
1018
|
+
for (let t = 0; t + 3 < e.length; t++) if (e[t] === kt && e[t + 1] === At && e[t + 2] === kt && e[t + 3] === At) return t;
|
|
1003
1019
|
return -1;
|
|
1004
|
-
},
|
|
1020
|
+
}, A = class {
|
|
1005
1021
|
buf = new Uint8Array();
|
|
1006
1022
|
state = "HEAD";
|
|
1007
1023
|
framing = "none";
|
|
@@ -1012,10 +1028,10 @@ var Xe = /* @__PURE__ */ n({
|
|
|
1012
1028
|
this.mode = e, this.handlers = t;
|
|
1013
1029
|
}
|
|
1014
1030
|
execute(e) {
|
|
1015
|
-
this.buf =
|
|
1031
|
+
this.buf = Mt(this.buf, e);
|
|
1016
1032
|
let t = !0;
|
|
1017
1033
|
for (; t;) if (t = !1, this.state === "HEAD") {
|
|
1018
|
-
let e =
|
|
1034
|
+
let e = Pt(this.buf);
|
|
1019
1035
|
if (e === -1) return;
|
|
1020
1036
|
let n = this.buf.subarray(0, e);
|
|
1021
1037
|
this.buf = this.buf.subarray(e + 4);
|
|
@@ -1030,7 +1046,7 @@ var Xe = /* @__PURE__ */ n({
|
|
|
1030
1046
|
this.state = "HEAD", this.framing = "none", this.bodyRemaining = 0, this.chunkState = "size", this.skipBody = !1;
|
|
1031
1047
|
}
|
|
1032
1048
|
parseHead(e) {
|
|
1033
|
-
let t =
|
|
1049
|
+
let t = Tt.decode(e).split("\r\n"), n = t.shift() ?? "", r = [];
|
|
1034
1050
|
for (let e of t) (e.startsWith(" ") || e.startsWith(" ")) && r.length > 0 ? r[r.length - 1] += " " + e.trim() : r.push(e);
|
|
1035
1051
|
let i = [], a = {};
|
|
1036
1052
|
for (let e of r) {
|
|
@@ -1068,7 +1084,7 @@ var Xe = /* @__PURE__ */ n({
|
|
|
1068
1084
|
return;
|
|
1069
1085
|
}
|
|
1070
1086
|
let i = e[r];
|
|
1071
|
-
i === void 0 ? e[r] = n :
|
|
1087
|
+
i === void 0 ? e[r] = n : Ot.has(r) || (e[r] = `${i}, ${n}`);
|
|
1072
1088
|
}
|
|
1073
1089
|
setupBody(e) {
|
|
1074
1090
|
if (this.skipBody) {
|
|
@@ -1101,9 +1117,9 @@ var Xe = /* @__PURE__ */ n({
|
|
|
1101
1117
|
}
|
|
1102
1118
|
consumeChunked() {
|
|
1103
1119
|
for (;;) if (this.chunkState === "size") {
|
|
1104
|
-
let e =
|
|
1120
|
+
let e = Nt(this.buf, 0);
|
|
1105
1121
|
if (e === -1) return !1;
|
|
1106
|
-
let t =
|
|
1122
|
+
let t = Tt.decode(this.buf.subarray(0, e)), n = parseInt(t.split(";")[0].trim(), 16);
|
|
1107
1123
|
if (this.buf = this.buf.subarray(e + 2), Number.isNaN(n)) return !0;
|
|
1108
1124
|
n === 0 ? this.chunkState = "trailer" : (this.bodyRemaining = n, this.chunkState = "data");
|
|
1109
1125
|
} else if (this.chunkState === "data") {
|
|
@@ -1114,13 +1130,13 @@ var Xe = /* @__PURE__ */ n({
|
|
|
1114
1130
|
if (this.buf.length < 2) return !1;
|
|
1115
1131
|
this.buf = this.buf.subarray(2), this.chunkState = "size";
|
|
1116
1132
|
} else {
|
|
1117
|
-
let e =
|
|
1133
|
+
let e = Nt(this.buf, 0);
|
|
1118
1134
|
if (e === -1) return !1;
|
|
1119
1135
|
let t = e === 0;
|
|
1120
1136
|
if (this.buf = this.buf.subarray(e + 2), t) return !0;
|
|
1121
1137
|
}
|
|
1122
1138
|
}
|
|
1123
|
-
},
|
|
1139
|
+
}, Ft = (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)), j = class extends d.Readable {
|
|
1124
1140
|
httpVersion = "1.1";
|
|
1125
1141
|
httpVersionMajor = 1;
|
|
1126
1142
|
httpVersionMinor = 1;
|
|
@@ -1147,16 +1163,16 @@ var Xe = /* @__PURE__ */ n({
|
|
|
1147
1163
|
setTimeout(e, t) {
|
|
1148
1164
|
return this.socket.setTimeout(e, t), this;
|
|
1149
1165
|
}
|
|
1150
|
-
},
|
|
1166
|
+
}, It = class extends d.Writable {
|
|
1151
1167
|
_headerStore = /* @__PURE__ */ new Map();
|
|
1152
1168
|
headersSent = !1;
|
|
1153
1169
|
chunkedEncoding = !1;
|
|
1154
1170
|
finished = !1;
|
|
1155
1171
|
_bodyWritten = !1;
|
|
1156
1172
|
setHeader(e, t) {
|
|
1157
|
-
if (this.headersSent) throw
|
|
1158
|
-
if (typeof e != "string" || !
|
|
1159
|
-
if (t === void 0) throw
|
|
1173
|
+
if (this.headersSent) throw k(/* @__PURE__ */ Error("Cannot set headers after they are sent to the client"), "ERR_HTTP_HEADERS_SENT");
|
|
1174
|
+
if (typeof e != "string" || !jt.test(e)) throw k(/* @__PURE__ */ TypeError(`Header name must be a valid HTTP token [${JSON.stringify(String(e))}]`), "ERR_INVALID_HTTP_TOKEN");
|
|
1175
|
+
if (t === void 0) throw k(/* @__PURE__ */ TypeError(`Invalid value "undefined" for header "${e}"`), "ERR_HTTP_INVALID_HEADER_VALUE");
|
|
1160
1176
|
return this._headerStore.set(e.toLowerCase(), [e, Array.isArray(t) ? [...t] : t]), this;
|
|
1161
1177
|
}
|
|
1162
1178
|
getHeader(e) {
|
|
@@ -1196,7 +1212,7 @@ var Xe = /* @__PURE__ */ n({
|
|
|
1196
1212
|
return this._bodyWritten = !0, super.write(e, t, n);
|
|
1197
1213
|
}
|
|
1198
1214
|
_write(e, t, n) {
|
|
1199
|
-
let r =
|
|
1215
|
+
let r = Ft(e), i = [];
|
|
1200
1216
|
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) {
|
|
1201
1217
|
n();
|
|
1202
1218
|
return;
|
|
@@ -1214,12 +1230,12 @@ var Xe = /* @__PURE__ */ n({
|
|
|
1214
1230
|
end(e, t, n) {
|
|
1215
1231
|
if (e != null && typeof e != "function" && !this._bodyWritten && !this.headersSent && !this.chunkedEncoding && !this.hasHeader("content-length")) {
|
|
1216
1232
|
let n = typeof t == "string" ? t : void 0;
|
|
1217
|
-
this.setHeader("Content-Length",
|
|
1233
|
+
this.setHeader("Content-Length", Ft(e, n).length);
|
|
1218
1234
|
}
|
|
1219
1235
|
return super.end(e, t, n);
|
|
1220
1236
|
}
|
|
1221
1237
|
_headBlock;
|
|
1222
|
-
},
|
|
1238
|
+
}, Lt = class extends It {
|
|
1223
1239
|
statusCode = 200;
|
|
1224
1240
|
statusMessage;
|
|
1225
1241
|
_writeHeadCalled = !1;
|
|
@@ -1236,7 +1252,7 @@ var Xe = /* @__PURE__ */ n({
|
|
|
1236
1252
|
return !(e >= 100 && e < 200 || e === 204 || e === 304);
|
|
1237
1253
|
}
|
|
1238
1254
|
writeHead(e, t, n) {
|
|
1239
|
-
if (this._writeHeadCalled || this.headersSent) throw
|
|
1255
|
+
if (this._writeHeadCalled || this.headersSent) throw k(/* @__PURE__ */ Error("Cannot render headers after they are sent to the client"), "ERR_HTTP_HEADERS_SENT");
|
|
1240
1256
|
this._writeHeadCalled = !0, this.statusCode = e;
|
|
1241
1257
|
let r = n;
|
|
1242
1258
|
if (typeof t == "string" ? this.statusMessage = t : t != null && (r = t), Array.isArray(r)) {
|
|
@@ -1254,7 +1270,7 @@ var Xe = /* @__PURE__ */ n({
|
|
|
1254
1270
|
}
|
|
1255
1271
|
}
|
|
1256
1272
|
_implicitHeader() {
|
|
1257
|
-
let e = this.statusMessage ??
|
|
1273
|
+
let e = this.statusMessage ?? Dt[this.statusCode] ?? "unknown";
|
|
1258
1274
|
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
1275
|
}
|
|
1260
1276
|
writeContinue() {
|
|
@@ -1263,7 +1279,7 @@ var Xe = /* @__PURE__ */ n({
|
|
|
1263
1279
|
setTimeout(e, t) {
|
|
1264
1280
|
return this.socket?.setTimeout(e, t), this;
|
|
1265
1281
|
}
|
|
1266
|
-
},
|
|
1282
|
+
}, Rt = (...e) => {
|
|
1267
1283
|
let t = {}, n = {}, r, i = [...e], a = i.shift();
|
|
1268
1284
|
if (typeof a == "string" || a instanceof URL) {
|
|
1269
1285
|
let e = typeof a == "string" ? new URL(a) : a;
|
|
@@ -1285,7 +1301,7 @@ var Xe = /* @__PURE__ */ n({
|
|
|
1285
1301
|
},
|
|
1286
1302
|
callback: r
|
|
1287
1303
|
};
|
|
1288
|
-
},
|
|
1304
|
+
}, zt = class extends It {
|
|
1289
1305
|
method;
|
|
1290
1306
|
path;
|
|
1291
1307
|
host;
|
|
@@ -1307,7 +1323,7 @@ var Xe = /* @__PURE__ */ n({
|
|
|
1307
1323
|
let e = this.protocol === "https:" && r === 443 || this.protocol !== "https:" && r === 80;
|
|
1308
1324
|
this.setHeader("Host", e ? n : `${n}:${r}`);
|
|
1309
1325
|
}
|
|
1310
|
-
e.auth && !this.hasHeader("authorization") && this.setHeader("Authorization", `Basic ${m.from(e.auth).toString("base64")}`), this.socket = new
|
|
1326
|
+
e.auth && !this.hasHeader("authorization") && this.setHeader("Authorization", `Basic ${m.from(e.auth).toString("base64")}`), this.socket = new E(), this.emit("socket", this.socket), this.socket.on("error", (e) => {
|
|
1311
1327
|
this._aborted || this.emit("error", e);
|
|
1312
1328
|
}), this._attachResponseParser(), this.socket.connect({
|
|
1313
1329
|
host: n,
|
|
@@ -1323,7 +1339,7 @@ var Xe = /* @__PURE__ */ n({
|
|
|
1323
1339
|
this._headBlock = this._storeHeader(`${this.method} ${this.path} HTTP/1.1`);
|
|
1324
1340
|
}
|
|
1325
1341
|
_attachResponseParser() {
|
|
1326
|
-
let e = new
|
|
1342
|
+
let e = new j(this.socket), t = new A("response", {
|
|
1327
1343
|
onHeaders: (n) => {
|
|
1328
1344
|
e._applyHead(n), this.method === "HEAD" && (t.skipBody = !0), this.res = e, this.emit("response", e);
|
|
1329
1345
|
},
|
|
@@ -1367,16 +1383,16 @@ var Xe = /* @__PURE__ */ n({
|
|
|
1367
1383
|
setSocketKeepAlive(e, t) {
|
|
1368
1384
|
this.socket.setKeepAlive(e, t);
|
|
1369
1385
|
}
|
|
1370
|
-
},
|
|
1386
|
+
}, Bt = new Proxy(class extends D {
|
|
1371
1387
|
constructor(e, t) {
|
|
1372
1388
|
let n = {}, r = t;
|
|
1373
1389
|
typeof e == "function" ? r = e : e && (n = e), super(n), r && this.on("request", r), this.on("connection", (e) => this._handleConnection(e));
|
|
1374
1390
|
}
|
|
1375
1391
|
_handleConnection(e) {
|
|
1376
|
-
let t = null, n = new
|
|
1392
|
+
let t = null, n = new A("request", {
|
|
1377
1393
|
onHeaders: (r) => {
|
|
1378
|
-
t = new
|
|
1379
|
-
let i = new
|
|
1394
|
+
t = new j(e), t._applyHead(r), r.method === "HEAD" && (n.skipBody = !0);
|
|
1395
|
+
let i = new Lt(t), a = String(r.headers.connection ?? "").toLowerCase();
|
|
1380
1396
|
i._keepAlive = r.httpVersionMinor >= 1 ? a !== "close" : a === "keep-alive", i.on("finish", () => {
|
|
1381
1397
|
i._keepAlive || e.end();
|
|
1382
1398
|
}), this.emit("request", t, i);
|
|
@@ -1392,7 +1408,7 @@ var Xe = /* @__PURE__ */ n({
|
|
|
1392
1408
|
n.finish(), t && t.push(null);
|
|
1393
1409
|
}), e.on("error", (t) => this.emit("clientError", t, e));
|
|
1394
1410
|
}
|
|
1395
|
-
}, { apply: (e, t, n) => new e(...n) }),
|
|
1411
|
+
}, { apply: (e, t, n) => new e(...n) }), Vt = class {
|
|
1396
1412
|
maxSockets;
|
|
1397
1413
|
maxFreeSockets;
|
|
1398
1414
|
keepAlive;
|
|
@@ -1404,163 +1420,479 @@ var Xe = /* @__PURE__ */ n({
|
|
|
1404
1420
|
return `${e.host ?? "localhost"}:${e.port ?? ""}:${e.localAddress ?? ""}`;
|
|
1405
1421
|
}
|
|
1406
1422
|
destroy() {}
|
|
1407
|
-
},
|
|
1408
|
-
let { options: t, callback: n } =
|
|
1409
|
-
return new
|
|
1410
|
-
},
|
|
1411
|
-
let t =
|
|
1423
|
+
}, Ht = new Vt(), Ut = (...e) => {
|
|
1424
|
+
let { options: t, callback: n } = Rt(...e);
|
|
1425
|
+
return new zt(t, n);
|
|
1426
|
+
}, Wt = (...e) => {
|
|
1427
|
+
let t = Ut(...e);
|
|
1412
1428
|
return t.end(), t;
|
|
1413
|
-
},
|
|
1414
|
-
METHODS:
|
|
1415
|
-
STATUS_CODES:
|
|
1416
|
-
Agent:
|
|
1417
|
-
globalAgent:
|
|
1418
|
-
Server:
|
|
1419
|
-
ServerResponse:
|
|
1420
|
-
IncomingMessage:
|
|
1421
|
-
ClientRequest:
|
|
1422
|
-
OutgoingMessage:
|
|
1423
|
-
createServer:
|
|
1424
|
-
request:
|
|
1425
|
-
get:
|
|
1426
|
-
},
|
|
1427
|
-
available: () =>
|
|
1428
|
-
dgram: () =>
|
|
1429
|
-
dns: () =>
|
|
1430
|
-
fetch: () =>
|
|
1431
|
-
|
|
1432
|
-
|
|
1433
|
-
|
|
1434
|
-
|
|
1429
|
+
}, Gt = (e, t) => new Bt(e, t), Kt = {
|
|
1430
|
+
METHODS: Et,
|
|
1431
|
+
STATUS_CODES: Dt,
|
|
1432
|
+
Agent: Vt,
|
|
1433
|
+
globalAgent: Ht,
|
|
1434
|
+
Server: Bt,
|
|
1435
|
+
ServerResponse: Lt,
|
|
1436
|
+
IncomingMessage: j,
|
|
1437
|
+
ClientRequest: zt,
|
|
1438
|
+
OutgoingMessage: It,
|
|
1439
|
+
createServer: Gt,
|
|
1440
|
+
request: Ut,
|
|
1441
|
+
get: Wt
|
|
1442
|
+
}, qt = /* @__PURE__ */ n({
|
|
1443
|
+
available: () => Jt,
|
|
1444
|
+
dgram: () => vt,
|
|
1445
|
+
dns: () => Qe,
|
|
1446
|
+
fetch: () => Xe,
|
|
1447
|
+
fs: () => et,
|
|
1448
|
+
http: () => wt,
|
|
1449
|
+
net: () => pt,
|
|
1450
|
+
quota: () => Ze
|
|
1451
|
+
}), Jt = () => qe, Yt = async (e) => {
|
|
1435
1452
|
if (typeof window > "u") return !1;
|
|
1436
1453
|
if (g()) return !0;
|
|
1437
|
-
let t = await
|
|
1454
|
+
let t = await w, n = null, r = new Promise((e) => {
|
|
1438
1455
|
n = () => {
|
|
1439
1456
|
g() && e(!0);
|
|
1440
1457
|
}, h.addEventListener("statuschange", n);
|
|
1441
1458
|
}), i = t.installPrompt.show(e).then(() => !1), a = await Promise.race([r, i]);
|
|
1442
1459
|
return n && h.removeEventListener("statuschange", n), await t.installPrompt.hide().catch(() => {}), a;
|
|
1443
|
-
},
|
|
1444
|
-
|
|
1445
|
-
|
|
1446
|
-
}),
|
|
1460
|
+
}, Xt = null;
|
|
1461
|
+
se(() => (Xt ||= Yt().then(() => void 0).finally(() => {
|
|
1462
|
+
Xt = null;
|
|
1463
|
+
}), Xt));
|
|
1447
1464
|
//#endregion
|
|
1448
1465
|
//#region src/lib/desktop.ts
|
|
1449
|
-
var
|
|
1450
|
-
available: () =>
|
|
1451
|
-
dgram: () =>
|
|
1452
|
-
dns: () =>
|
|
1453
|
-
fetch: () =>
|
|
1454
|
-
fs: () =>
|
|
1455
|
-
net: () =>
|
|
1456
|
-
}),
|
|
1466
|
+
var Zt = /* @__PURE__ */ n({
|
|
1467
|
+
available: () => Qt,
|
|
1468
|
+
dgram: () => nn,
|
|
1469
|
+
dns: () => en,
|
|
1470
|
+
fetch: () => $t,
|
|
1471
|
+
fs: () => rn,
|
|
1472
|
+
net: () => tn
|
|
1473
|
+
}), Qt = () => !1, M = (e) => (...t) => {
|
|
1457
1474
|
throw Error(`The FKN desktop app is not connected, desktop.${e} is unavailable`);
|
|
1458
|
-
},
|
|
1459
|
-
connect:
|
|
1460
|
-
createConnection:
|
|
1461
|
-
createServer:
|
|
1462
|
-
},
|
|
1463
|
-
|
|
1464
|
-
|
|
1465
|
-
|
|
1466
|
-
|
|
1467
|
-
|
|
1468
|
-
|
|
1475
|
+
}, $t = M("fetch"), en = { lookup: M("dns.lookup") }, tn = {
|
|
1476
|
+
connect: M("net.connect"),
|
|
1477
|
+
createConnection: M("net.createConnection"),
|
|
1478
|
+
createServer: M("net.createServer")
|
|
1479
|
+
}, nn = { createSocket: M("dgram.createSocket") }, rn = {
|
|
1480
|
+
available: async () => !1,
|
|
1481
|
+
list: M("fs.list"),
|
|
1482
|
+
readFile: M("fs.readFile"),
|
|
1483
|
+
writeFile: M("fs.writeFile"),
|
|
1484
|
+
remove: M("fs.remove")
|
|
1485
|
+
}, an = () => typeof document < "u" && g(), on = async (e, t) => {
|
|
1486
|
+
if (Ye(e), t?.credentials === "include") {
|
|
1469
1487
|
if (typeof document > "u") throw Error("fetch with credentials needs the FKN extension, which only exists in window realms");
|
|
1470
|
-
return
|
|
1488
|
+
return be(e, t);
|
|
1471
1489
|
}
|
|
1472
|
-
return
|
|
1490
|
+
return an() ? be(e, {
|
|
1473
1491
|
...t,
|
|
1474
1492
|
credentials: "omit"
|
|
1475
|
-
}) :
|
|
1476
|
-
},
|
|
1477
|
-
ATTACH_FRAME_EVENT_KEY: () =>
|
|
1478
|
-
assertAttachableFrameUrl: () =>
|
|
1479
|
-
assertFetchableUrl: () =>
|
|
1480
|
-
attachFrame: () =>
|
|
1481
|
-
attachFramePermission: () =>
|
|
1482
|
-
available: () =>
|
|
1493
|
+
}) : Qt() ? $t(e, t) : Xe(e, t);
|
|
1494
|
+
}, sn = /* @__PURE__ */ n({
|
|
1495
|
+
ATTACH_FRAME_EVENT_KEY: () => Ee,
|
|
1496
|
+
assertAttachableFrameUrl: () => y,
|
|
1497
|
+
assertFetchableUrl: () => _e,
|
|
1498
|
+
attachFrame: () => je,
|
|
1499
|
+
attachFramePermission: () => Oe,
|
|
1500
|
+
available: () => an,
|
|
1483
1501
|
box: () => l,
|
|
1484
|
-
cookies: () =>
|
|
1502
|
+
cookies: () => Se,
|
|
1485
1503
|
createVideoElementHandle: () => e,
|
|
1504
|
+
evaluatePermission: () => Ae,
|
|
1486
1505
|
events: () => h,
|
|
1487
1506
|
extension: () => h,
|
|
1488
|
-
fetch: () =>
|
|
1489
|
-
fetchCredentialedPermission: () =>
|
|
1490
|
-
fetchLocalPermission: () =>
|
|
1491
|
-
fetchPermission: () =>
|
|
1492
|
-
gotoPermission: () =>
|
|
1507
|
+
fetch: () => be,
|
|
1508
|
+
fetchCredentialedPermission: () => de,
|
|
1509
|
+
fetchLocalPermission: () => fe,
|
|
1510
|
+
fetchPermission: () => ue,
|
|
1511
|
+
gotoPermission: () => ke,
|
|
1493
1512
|
handleRevivableModules: () => i,
|
|
1494
|
-
isBlockedFetchUrl: () =>
|
|
1495
|
-
isBlockedFrameUrl: () =>
|
|
1513
|
+
isBlockedFetchUrl: () => ge,
|
|
1514
|
+
isBlockedFrameUrl: () => De,
|
|
1496
1515
|
isExtensionExposed: () => g,
|
|
1497
|
-
isLocalNetworkUrl: () =>
|
|
1516
|
+
isLocalNetworkUrl: () => me,
|
|
1498
1517
|
isType: () => t,
|
|
1499
|
-
modifyRequestHeadersPermission: () =>
|
|
1500
|
-
permissions: () =>
|
|
1501
|
-
promptInstall: () =>
|
|
1502
|
-
readCookiePermission: () =>
|
|
1503
|
-
removeRequestHeaderRule: () =>
|
|
1518
|
+
modifyRequestHeadersPermission: () => Ce,
|
|
1519
|
+
permissions: () => Me,
|
|
1520
|
+
promptInstall: () => Yt,
|
|
1521
|
+
readCookiePermission: () => xe,
|
|
1522
|
+
removeRequestHeaderRule: () => Te,
|
|
1504
1523
|
revive: () => o,
|
|
1505
|
-
setMissingExtensionHandler: () =>
|
|
1506
|
-
setRequestHeaderRule: () =>
|
|
1524
|
+
setMissingExtensionHandler: () => se,
|
|
1525
|
+
setRequestHeaderRule: () => we,
|
|
1507
1526
|
type: () => a,
|
|
1508
|
-
waitForExtensionExposure: () =>
|
|
1509
|
-
}),
|
|
1510
|
-
|
|
1511
|
-
|
|
1512
|
-
|
|
1513
|
-
|
|
1514
|
-
|
|
1515
|
-
|
|
1516
|
-
let t =
|
|
1517
|
-
|
|
1518
|
-
|
|
1519
|
-
|
|
1520
|
-
|
|
1521
|
-
|
|
1527
|
+
waitForExtensionExposure: () => _
|
|
1528
|
+
}), cn = /* @__PURE__ */ n({
|
|
1529
|
+
available: () => fn,
|
|
1530
|
+
list: () => hn,
|
|
1531
|
+
readFile: () => pn,
|
|
1532
|
+
remove: () => mn,
|
|
1533
|
+
writeFile: () => N
|
|
1534
|
+
}), ln = () => navigator.storage.getDirectory(), un = (e) => {
|
|
1535
|
+
let t = e.split("/").filter((e) => e && e !== ".");
|
|
1536
|
+
if (t.some((e) => e === "..") || !t.length) throw Error("opfs: invalid path");
|
|
1537
|
+
return t;
|
|
1538
|
+
}, dn = async (e, t) => {
|
|
1539
|
+
let n = await ln();
|
|
1540
|
+
for (let r of e) n = await n.getDirectoryHandle(r, { create: t });
|
|
1541
|
+
return n;
|
|
1542
|
+
}, fn = async () => {
|
|
1543
|
+
try {
|
|
1544
|
+
return typeof navigator < "u" && !!navigator.storage?.getDirectory && !!await ln();
|
|
1545
|
+
} catch {
|
|
1546
|
+
return !1;
|
|
1547
|
+
}
|
|
1548
|
+
}, N = async (e, t, n) => {
|
|
1549
|
+
let r = un(e), i = r.pop(), a = await (await (await dn(r, !0)).getFileHandle(i, { create: !0 })).createWritable({ keepExistingData: !1 });
|
|
1550
|
+
try {
|
|
1551
|
+
let e = t instanceof Blob ? t : new Blob([t], n?.contentType ? { type: n.contentType } : void 0);
|
|
1552
|
+
await a.write(e);
|
|
1553
|
+
} finally {
|
|
1554
|
+
await a.close();
|
|
1555
|
+
}
|
|
1556
|
+
}, pn = async (e) => {
|
|
1557
|
+
let t = un(e), n = t.pop();
|
|
1558
|
+
return (await (await dn(t, !1)).getFileHandle(n)).getFile();
|
|
1559
|
+
}, mn = async (e) => {
|
|
1560
|
+
let t = un(e), n = t.pop();
|
|
1561
|
+
await (await dn(t, !1)).removeEntry(n, { recursive: !0 });
|
|
1562
|
+
}, hn = async () => {
|
|
1563
|
+
let e = [], t = async (n, r) => {
|
|
1564
|
+
for await (let [i, a] of n.entries()) {
|
|
1565
|
+
let n = r ? `${r}/${i}` : i;
|
|
1566
|
+
if (a.kind === "file") {
|
|
1567
|
+
let t = await a.getFile();
|
|
1568
|
+
e.push({
|
|
1569
|
+
path: n,
|
|
1570
|
+
size: t.size,
|
|
1571
|
+
contentType: t.type || null,
|
|
1572
|
+
updatedAt: new Date(t.lastModified).toISOString()
|
|
1573
|
+
});
|
|
1574
|
+
} else await t(a, n);
|
|
1575
|
+
}
|
|
1576
|
+
};
|
|
1577
|
+
return await t(await ln(), ""), e;
|
|
1578
|
+
}, gn = /* @__PURE__ */ n({
|
|
1579
|
+
available: () => vn,
|
|
1580
|
+
list: () => yn,
|
|
1581
|
+
pull: () => Cn,
|
|
1582
|
+
readFile: () => bn,
|
|
1583
|
+
remove: () => Sn,
|
|
1584
|
+
writeFile: () => xn
|
|
1585
|
+
}), _n, P = async () => await (_n ??= fn().catch(() => !1)) ? !0 : (_n = void 0, !1), F = () => tt().catch(() => !1), vn = async () => await P() || await F(), yn = async () => {
|
|
1586
|
+
let [e, t] = await Promise.all([P().then((e) => e ? hn() : []).catch(() => []), F().then((e) => e ? nt() : []).catch(() => [])]), n = /* @__PURE__ */ new Map(), r = (e) => {
|
|
1587
|
+
let t = Date.parse(e.updatedAt ?? "");
|
|
1588
|
+
return Number.isFinite(t) ? t : 0;
|
|
1589
|
+
}, i = (e) => {
|
|
1590
|
+
let t = n.get(e.path);
|
|
1591
|
+
(!t || r(e) >= r(t)) && n.set(e.path, e);
|
|
1592
|
+
};
|
|
1593
|
+
for (let t of e) i(t);
|
|
1594
|
+
for (let e of t) i(e);
|
|
1595
|
+
return [...n.values()];
|
|
1596
|
+
}, bn = async (e) => {
|
|
1597
|
+
if (await P()) try {
|
|
1598
|
+
return await pn(e);
|
|
1599
|
+
} catch (e) {
|
|
1600
|
+
if (e?.name !== "NotFoundError") throw e;
|
|
1601
|
+
}
|
|
1602
|
+
let t = await T(e);
|
|
1603
|
+
return await P() && N(e, t).catch(() => {}), t;
|
|
1604
|
+
}, xn = async (e, t, n) => {
|
|
1605
|
+
let r = t instanceof Blob ? t : new Blob([t], n?.contentType ? { type: n.contentType } : void 0);
|
|
1606
|
+
if (await P()) {
|
|
1607
|
+
await N(e, r, n), await F() && it(e, r, n).catch((e) => console.warn("fs: cloud replicate failed", e));
|
|
1608
|
+
return;
|
|
1609
|
+
}
|
|
1610
|
+
if (await F()) return it(e, r, n);
|
|
1611
|
+
throw Error("fs: no storage backend available");
|
|
1612
|
+
}, Sn = async (e) => {
|
|
1613
|
+
let t = [];
|
|
1614
|
+
if (await P() && t.push(mn(e).catch(() => {})), await F() && t.push(at(e).catch(() => {})), !t.length) throw Error("fs: no storage backend available");
|
|
1615
|
+
await Promise.all(t);
|
|
1616
|
+
}, Cn = async (e) => {
|
|
1617
|
+
let t = await T(e);
|
|
1618
|
+
return await P() && await N(e, t), t;
|
|
1619
|
+
}, I = new Map([["", {
|
|
1620
|
+
kind: "dir",
|
|
1621
|
+
mtimeMs: 0
|
|
1622
|
+
}]]), L = /* @__PURE__ */ new Set(), R = /* @__PURE__ */ new Set(), wn = () => Date.now(), z = (e, t, n) => {
|
|
1623
|
+
let r = /* @__PURE__ */ Error(`${e}: ${{
|
|
1624
|
+
ENOENT: "no such file or directory",
|
|
1625
|
+
EEXIST: "file already exists",
|
|
1626
|
+
ENOTDIR: "not a directory",
|
|
1627
|
+
EISDIR: "illegal operation on a directory",
|
|
1628
|
+
ENOTEMPTY: "directory not empty"
|
|
1629
|
+
}[e] ?? e}, ${n} '${t}'`);
|
|
1630
|
+
return r.code = e, r.path = t, r.syscall = n, r;
|
|
1631
|
+
}, B = (e) => {
|
|
1632
|
+
let t = [];
|
|
1633
|
+
for (let n of e.split("/")) if (!(!n || n === ".")) {
|
|
1634
|
+
if (n === "..") {
|
|
1635
|
+
t.pop();
|
|
1636
|
+
continue;
|
|
1637
|
+
}
|
|
1638
|
+
t.push(n);
|
|
1639
|
+
}
|
|
1640
|
+
return t.join("/");
|
|
1641
|
+
}, V = (e) => e.split("/").slice(0, -1).join("/"), H = (e) => {
|
|
1642
|
+
if (!e) return;
|
|
1643
|
+
let t = e.split("/"), n = "";
|
|
1644
|
+
for (let e of t) {
|
|
1645
|
+
n = n ? `${n}/${e}` : e;
|
|
1646
|
+
let t = I.get(n);
|
|
1647
|
+
if (!t) I.set(n, {
|
|
1648
|
+
kind: "dir",
|
|
1649
|
+
mtimeMs: wn()
|
|
1650
|
+
});
|
|
1651
|
+
else if (t.kind === "file") throw z("ENOTDIR", n, "mkdir");
|
|
1652
|
+
}
|
|
1653
|
+
}, Tn, U = () => Tn ??= (async () => {
|
|
1654
|
+
let e = await yn().catch(() => []);
|
|
1655
|
+
for (let t of e) try {
|
|
1656
|
+
let e = B(t.path);
|
|
1657
|
+
if (L.has(e)) continue;
|
|
1658
|
+
let n = await (await bn(t.path)).arrayBuffer();
|
|
1659
|
+
H(V(e));
|
|
1660
|
+
let r = Date.parse(t.updatedAt ?? "");
|
|
1661
|
+
I.set(e, {
|
|
1662
|
+
kind: "file",
|
|
1663
|
+
data: new Uint8Array(n),
|
|
1664
|
+
mtimeMs: Number.isFinite(r) ? r : wn()
|
|
1665
|
+
});
|
|
1666
|
+
} catch {}
|
|
1667
|
+
})(), En = async () => {
|
|
1668
|
+
Tn = void 0, await U();
|
|
1669
|
+
}, W = async () => {
|
|
1670
|
+
let e = [...L].map(async (e) => {
|
|
1671
|
+
let t = I.get(e);
|
|
1672
|
+
if (t?.kind !== "file") {
|
|
1673
|
+
L.delete(e);
|
|
1674
|
+
return;
|
|
1675
|
+
}
|
|
1676
|
+
let n = t.data;
|
|
1677
|
+
try {
|
|
1678
|
+
await xn(e, n), I.get(e)?.kind === "file" && I.get(e).data === n && L.delete(e);
|
|
1679
|
+
} catch {}
|
|
1680
|
+
}), t = [...R].map(async (e) => {
|
|
1681
|
+
try {
|
|
1682
|
+
await Sn(e), R.delete(e);
|
|
1683
|
+
} catch {}
|
|
1684
|
+
});
|
|
1685
|
+
await Promise.all([...e, ...t]);
|
|
1686
|
+
}, Dn, On = () => {
|
|
1687
|
+
Dn ||= setTimeout(() => {
|
|
1688
|
+
Dn = void 0, W().catch(() => {});
|
|
1689
|
+
}, 250);
|
|
1690
|
+
};
|
|
1691
|
+
typeof addEventListener < "u" && (addEventListener("pagehide", () => {
|
|
1692
|
+
W().catch(() => {});
|
|
1693
|
+
}), addEventListener("visibilitychange", () => {
|
|
1694
|
+
typeof document < "u" && document.visibilityState === "hidden" && W().catch(() => {});
|
|
1695
|
+
}));
|
|
1696
|
+
var kn = (e, t) => ({
|
|
1697
|
+
size: t.kind === "file" ? t.data.byteLength : 0,
|
|
1698
|
+
mtimeMs: t.mtimeMs,
|
|
1699
|
+
mtime: new Date(t.mtimeMs),
|
|
1700
|
+
atimeMs: t.mtimeMs,
|
|
1701
|
+
ctimeMs: t.mtimeMs,
|
|
1702
|
+
mode: t.kind === "file" ? 420 : 493,
|
|
1703
|
+
isFile: () => t.kind === "file",
|
|
1704
|
+
isDirectory: () => t.kind === "dir",
|
|
1705
|
+
isSymbolicLink: () => !1
|
|
1706
|
+
}), An = (e) => I.has(B(e)), G = (e) => {
|
|
1707
|
+
let t = B(e), n = I.get(t);
|
|
1708
|
+
if (!n) throw z("ENOENT", e, "stat");
|
|
1709
|
+
return kn(t, n);
|
|
1710
|
+
}, jn = (e) => {
|
|
1711
|
+
let t = I.get(B(e));
|
|
1712
|
+
if (!t) throw z("ENOENT", e, "open");
|
|
1713
|
+
if (t.kind === "dir") throw z("EISDIR", e, "read");
|
|
1714
|
+
return t.data;
|
|
1715
|
+
}, K = (e, t, n) => {
|
|
1716
|
+
let r = B(e);
|
|
1717
|
+
if (!r) throw z("EISDIR", e, "open");
|
|
1718
|
+
let i = I.get(r);
|
|
1719
|
+
if (i?.kind === "dir") throw z("EISDIR", e, "open");
|
|
1720
|
+
H(V(r));
|
|
1721
|
+
let a = n && i?.kind === "file" ? Mn(i.data, t) : t;
|
|
1722
|
+
I.set(r, {
|
|
1723
|
+
kind: "file",
|
|
1724
|
+
data: a,
|
|
1725
|
+
mtimeMs: wn()
|
|
1726
|
+
}), L.add(r), R.delete(r), On();
|
|
1727
|
+
}, Mn = (e, t) => {
|
|
1728
|
+
let n = new Uint8Array(e.byteLength + t.byteLength);
|
|
1729
|
+
return n.set(e, 0), n.set(t, e.byteLength), n;
|
|
1730
|
+
}, Nn = (e, t) => {
|
|
1731
|
+
let n = B(e);
|
|
1732
|
+
if (n) {
|
|
1733
|
+
if (I.has(n)) {
|
|
1734
|
+
if (t) return;
|
|
1735
|
+
throw z("EEXIST", e, "mkdir");
|
|
1736
|
+
}
|
|
1737
|
+
if (!t && !I.has(V(n))) throw z("ENOENT", e, "mkdir");
|
|
1738
|
+
H(n);
|
|
1739
|
+
}
|
|
1740
|
+
}, Pn = (e) => {
|
|
1741
|
+
let t = B(e), n = I.get(t);
|
|
1742
|
+
if (!n) throw z("ENOENT", e, "scandir");
|
|
1743
|
+
if (n.kind === "file") throw z("ENOTDIR", e, "scandir");
|
|
1744
|
+
let r = t ? `${t}/` : "", i = /* @__PURE__ */ new Set();
|
|
1745
|
+
for (let e of I.keys()) {
|
|
1746
|
+
if (!e || !e.startsWith(r)) continue;
|
|
1747
|
+
let t = e.slice(r.length);
|
|
1748
|
+
if (!t || t.includes("/")) {
|
|
1749
|
+
t.includes("/") && i.add(t.split("/")[0]);
|
|
1750
|
+
continue;
|
|
1751
|
+
}
|
|
1752
|
+
i.add(t);
|
|
1753
|
+
}
|
|
1754
|
+
return [...i];
|
|
1755
|
+
}, q = (e, t) => {
|
|
1756
|
+
let n = B(e);
|
|
1757
|
+
if (!I.get(n)) {
|
|
1758
|
+
if (t) return;
|
|
1759
|
+
throw z("ENOENT", e, "unlink");
|
|
1760
|
+
}
|
|
1761
|
+
let r = `${n}/`, i = [...I.keys()].filter((e) => e.startsWith(r));
|
|
1762
|
+
if (i.length && !t) throw z("ENOTEMPTY", e, "rmdir");
|
|
1763
|
+
for (let e of [n, ...i]) {
|
|
1764
|
+
let t = I.get(e);
|
|
1765
|
+
I.delete(e), t?.kind === "file" && (L.delete(e), R.add(e));
|
|
1766
|
+
}
|
|
1767
|
+
On();
|
|
1768
|
+
}, Fn = (e, t) => {
|
|
1769
|
+
let n = B(e), r = B(t);
|
|
1770
|
+
if (!n) throw z("EBUSY", e, "rename");
|
|
1771
|
+
if (r === n || r.startsWith(`${n}/`)) throw z("EINVAL", e, "rename");
|
|
1772
|
+
let i = I.get(n);
|
|
1773
|
+
if (!i) throw z("ENOENT", e, "rename");
|
|
1774
|
+
let a = I.get(r);
|
|
1775
|
+
if (a) {
|
|
1776
|
+
if (a.kind !== i.kind) throw z(i.kind === "dir" ? "ENOTDIR" : "EISDIR", t, "rename");
|
|
1777
|
+
q(r, !0);
|
|
1778
|
+
}
|
|
1779
|
+
H(V(r));
|
|
1780
|
+
let o = `${n}/`, s = [n, ...[...I.keys()].filter((e) => e.startsWith(o))];
|
|
1781
|
+
for (let e of s) {
|
|
1782
|
+
let t = r + e.slice(n.length), i = I.get(e);
|
|
1783
|
+
I.set(t, i), I.delete(e), i.kind === "file" && (L.add(t), R.delete(t), L.delete(e), R.add(e));
|
|
1784
|
+
}
|
|
1785
|
+
On();
|
|
1786
|
+
}, In = /* @__PURE__ */ n({
|
|
1787
|
+
appendFile: () => er,
|
|
1788
|
+
appendFileSync: () => Hn,
|
|
1789
|
+
exists: () => sr,
|
|
1790
|
+
existsSync: () => Un,
|
|
1791
|
+
flush: () => W,
|
|
1792
|
+
lstatSync: () => Gn,
|
|
1793
|
+
mkdir: () => rr,
|
|
1794
|
+
mkdirSync: () => qn,
|
|
1795
|
+
mount: () => U,
|
|
1796
|
+
promises: () => cr,
|
|
1797
|
+
readFile: () => Qn,
|
|
1798
|
+
readFileSync: () => Bn,
|
|
1799
|
+
readdir: () => nr,
|
|
1800
|
+
readdirSync: () => Kn,
|
|
1801
|
+
remount: () => En,
|
|
1802
|
+
rename: () => or,
|
|
1803
|
+
renameSync: () => Zn,
|
|
1804
|
+
rm: () => ir,
|
|
1805
|
+
rmSync: () => Jn,
|
|
1806
|
+
rmdirSync: () => Yn,
|
|
1807
|
+
stat: () => tr,
|
|
1808
|
+
statSync: () => Wn,
|
|
1809
|
+
unlink: () => ar,
|
|
1810
|
+
unlinkSync: () => Xn,
|
|
1811
|
+
writeFile: () => $n,
|
|
1812
|
+
writeFileSync: () => Vn
|
|
1813
|
+
}), J = (e) => typeof e == "string" ? e : e instanceof URL ? decodeURIComponent(e.pathname) : e.toString(), Ln = (e) => typeof e == "string" ? e : e?.encoding ?? void 0, Rn = (e) => typeof e == "object" && !!e?.recursive, zn = (e, t) => {
|
|
1814
|
+
let n = Ln(t);
|
|
1815
|
+
return n ? m.from(e).toString(n) : m.from(e);
|
|
1816
|
+
}, Y = (e, t) => {
|
|
1817
|
+
if (typeof e == "string") return new Uint8Array(m.from(e, Ln(t) ?? "utf8"));
|
|
1818
|
+
if (e instanceof Uint8Array) return e.slice();
|
|
1819
|
+
if (e instanceof ArrayBuffer) return new Uint8Array(e).slice();
|
|
1820
|
+
if (ArrayBuffer.isView(e)) return new Uint8Array(e.buffer, e.byteOffset, e.byteLength).slice();
|
|
1821
|
+
throw TypeError("The \"data\" argument must be of type string, Buffer, TypedArray, or DataView");
|
|
1822
|
+
}, Bn = (e, t) => zn(jn(J(e)), t), Vn = (e, t, n) => K(J(e), Y(t, n), !1), Hn = (e, t, n) => K(J(e), Y(t, n), !0), Un = (e) => An(J(e)), Wn = (e) => G(J(e)), Gn = Wn, Kn = (e) => Pn(J(e)), qn = (e, t) => Nn(J(e), Rn(t)), Jn = (e, t) => q(J(e), !!t?.recursive), Yn = (e, t) => q(J(e), !!t?.recursive), Xn = (e) => q(J(e), !1), Zn = (e, t) => Fn(J(e), J(t)), X = (e, t) => {
|
|
1823
|
+
U().finally(() => {
|
|
1824
|
+
let n;
|
|
1825
|
+
try {
|
|
1826
|
+
n = e();
|
|
1827
|
+
} catch (e) {
|
|
1828
|
+
t(e);
|
|
1829
|
+
return;
|
|
1830
|
+
}
|
|
1831
|
+
t(null, n);
|
|
1522
1832
|
});
|
|
1523
|
-
},
|
|
1524
|
-
|
|
1525
|
-
|
|
1526
|
-
|
|
1527
|
-
|
|
1528
|
-
|
|
1529
|
-
|
|
1530
|
-
|
|
1833
|
+
}, Z = (e, t) => typeof e == "function" ? e : t, Q = (e) => typeof e == "function" ? void 0 : e, Qn = (e, t, n) => X(() => zn(jn(J(e)), Q(t)), Z(t, n)), $n = (e, t, n, r) => X(() => K(J(e), Y(t, Q(n)), !1), Z(n, r)), er = (e, t, n, r) => X(() => K(J(e), Y(t, Q(n)), !0), Z(n, r)), tr = (e, t) => X(() => G(J(e)), t), nr = (e, t, n) => X(() => Pn(J(e)), Z(t, n)), rr = (e, t, n) => X(() => Nn(J(e), Rn(Q(t))), Z(t, n)), ir = (e, t, n) => X(() => q(J(e), !!Q(t)?.recursive), Z(t, n)), ar = (e, t) => X(() => q(J(e), !1), t), or = (e, t, n) => X(() => Fn(J(e), J(t)), n), sr = (e, t) => {
|
|
1834
|
+
U().finally(() => t(An(J(e))));
|
|
1835
|
+
}, $ = (e) => U().then(() => e()), cr = {
|
|
1836
|
+
readFile: (e, t) => $(() => zn(jn(J(e)), t)),
|
|
1837
|
+
writeFile: (e, t, n) => $(() => K(J(e), Y(t, n), !1)),
|
|
1838
|
+
appendFile: (e, t, n) => $(() => K(J(e), Y(t, n), !0)),
|
|
1839
|
+
stat: (e) => $(() => G(J(e))),
|
|
1840
|
+
lstat: (e) => $(() => G(J(e))),
|
|
1841
|
+
readdir: (e) => $(() => Pn(J(e))),
|
|
1842
|
+
mkdir: (e, t) => $(() => Nn(J(e), Rn(t))),
|
|
1843
|
+
rm: (e, t) => $(() => q(J(e), !!t?.recursive)),
|
|
1844
|
+
rmdir: (e, t) => $(() => q(J(e), !!t?.recursive)),
|
|
1845
|
+
unlink: (e) => $(() => q(J(e), !1)),
|
|
1846
|
+
rename: (e, t) => $(() => Fn(J(e), J(t))),
|
|
1847
|
+
access: (e) => $(() => {
|
|
1848
|
+
if (!An(J(e))) throw z("ENOENT", J(e), "access");
|
|
1849
|
+
})
|
|
1850
|
+
}, lr = "https://fkn.app", ur = (e, t) => {
|
|
1531
1851
|
if (typeof window > "u") throw Error("FKN @fkn/lib: relayWorker must be called from the main thread");
|
|
1532
|
-
if (!
|
|
1533
|
-
|
|
1852
|
+
if (!C?.contentWindow) throw Error("FKN @fkn/lib: relayWorker called before the FKN iframe was injected");
|
|
1853
|
+
te({
|
|
1534
1854
|
receive: window,
|
|
1535
|
-
emit:
|
|
1855
|
+
emit: C.contentWindow
|
|
1536
1856
|
}, e, {
|
|
1537
1857
|
key: "fkn-api",
|
|
1538
|
-
originA: t?.originA ??
|
|
1858
|
+
originA: t?.originA ?? lr,
|
|
1539
1859
|
originB: t?.originB ?? "*",
|
|
1540
1860
|
unregisterSignal: t?.unregisterSignal
|
|
1541
1861
|
});
|
|
1542
|
-
},
|
|
1543
|
-
info: () =>
|
|
1544
|
-
login: () =>
|
|
1545
|
-
logout: () =>
|
|
1546
|
-
onChange: () =>
|
|
1547
|
-
}),
|
|
1548
|
-
typeof window > "u" || await (await
|
|
1549
|
-
},
|
|
1862
|
+
}, dr = async () => typeof window > "u" ? !1 : (await w).connect.prompt(location.origin).catch(() => !1), fr = /* @__PURE__ */ n({
|
|
1863
|
+
info: () => hr,
|
|
1864
|
+
login: () => pr,
|
|
1865
|
+
logout: () => mr,
|
|
1866
|
+
onChange: () => gr
|
|
1867
|
+
}), pr = async () => typeof window > "u" ? !1 : (await w).account.login(location.origin).catch(() => !1), mr = async () => {
|
|
1868
|
+
typeof window > "u" || await (await w).account.logout().catch(() => {});
|
|
1869
|
+
}, hr = async () => {
|
|
1550
1870
|
if (typeof window > "u") return null;
|
|
1551
|
-
let e = await
|
|
1871
|
+
let e = await w.then((e) => e.account.info()).catch(() => null);
|
|
1552
1872
|
return e ? {
|
|
1553
1873
|
name: e.name,
|
|
1554
1874
|
image: e.image,
|
|
1555
1875
|
premium: e.premium,
|
|
1556
1876
|
premiumUntil: e.premiumUntil ? Date.parse(e.premiumUntil) : null
|
|
1557
1877
|
} : null;
|
|
1558
|
-
},
|
|
1878
|
+
}, gr = async (e) => {
|
|
1559
1879
|
if (typeof window > "u") return () => {};
|
|
1560
|
-
let t = await
|
|
1880
|
+
let t = await w.catch(() => null);
|
|
1561
1881
|
if (!t) return () => {};
|
|
1562
1882
|
let n = await t.account.onChange(e).catch(() => null);
|
|
1563
1883
|
return typeof n == "function" ? n : () => {};
|
|
1564
|
-
}
|
|
1884
|
+
}, _r = "https://fkn.app", vr = (e = location.origin) => `${_r}/connect-button?origin=${encodeURIComponent(e)}`, yr = ({ className: e, style: t } = {}) => re("iframe", {
|
|
1885
|
+
src: vr(),
|
|
1886
|
+
title: "Connect your FKN account",
|
|
1887
|
+
className: e,
|
|
1888
|
+
style: {
|
|
1889
|
+
border: "none",
|
|
1890
|
+
width: 150,
|
|
1891
|
+
height: 40,
|
|
1892
|
+
background: "transparent",
|
|
1893
|
+
colorScheme: "normal",
|
|
1894
|
+
...t
|
|
1895
|
+
}
|
|
1896
|
+
});
|
|
1565
1897
|
//#endregion
|
|
1566
|
-
export {
|
|
1898
|
+
export { Ee as ATTACH_FRAME_EVENT_KEY, yr as ConnectButton, fr as account, y as assertAttachableFrameUrl, _e as assertFetchableUrl, je as attachFrame, Oe as attachFramePermission, l as box, qt as cloud, dr as connect, vr as connectButtonUrl, Se as cookies, e as createVideoElementHandle, Zt as desktop, vt as dgram, Qe as dns, Ae as evaluatePermission, sn as extension, on as fetch, de as fetchCredentialedPermission, fe as fetchLocalPermission, ue as fetchPermission, gn as fs, ke as gotoPermission, i as handleRevivableModules, wt as http, ge as isBlockedFetchUrl, De as isBlockedFrameUrl, g as isExtensionExposed, me as isLocalNetworkUrl, t as isType, Ce as modifyRequestHeadersPermission, pt as net, In as nodeFs, cn as opfs, Me as permissions, Yt as promptInstall, xe as readCookiePermission, ur as relayWorker, Te as removeRequestHeaderRule, o as revive, se as setMissingExtensionHandler, we as setRequestHeaderRule, a as type, _ as waitForExtensionExposure };
|