@fkn/lib 0.3.7 → 0.3.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/_redirects +5 -0
- package/{background-Y_zGUlba.cjs → background-DWzRqH12.cjs} +1 -1
- package/{background-DkW0j6iK.js → background-_3_Cnyol.js} +160 -47
- package/index.cjs +11 -1
- package/index.d.ts +698 -76
- package/index.js +2310 -121
- package/{locator-DpMUq6q3.js → locator-1wWrCOyE.js} +588 -499
- package/locator-DHsqhrFb.cjs +31 -0
- package/logo.png +0 -0
- package/logo.svg +7 -0
- package/package.json +4 -2
- package/locator-CcAGamNm.cjs +0 -31
package/index.js
CHANGED
|
@@ -1,38 +1,1725 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { createTypedEventTarget as u, expose as d } from "osra";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
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-1wWrCOyE.js";
|
|
2
|
+
import { createTypedEventTarget as u, expose as d, relay as f } from "osra";
|
|
3
|
+
import { Component as p, Fragment as m, createElement as h, options as g, toChildArray as _ } from "preact";
|
|
4
|
+
import { BlindRSA as v } from "@cloudflare/blindrsa-ts";
|
|
5
|
+
import { Stream as y } from "stream";
|
|
6
|
+
import { EventEmitter as b } from "events";
|
|
7
|
+
import { Address4 as x, Address6 as S } from "ip-address";
|
|
8
|
+
import { Buffer as C } from "buffer";
|
|
7
9
|
//#region src/lib/dom.ts
|
|
8
|
-
var
|
|
9
|
-
!
|
|
10
|
-
var
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
10
|
+
var ee = "https://fkn.app", te = typeof globalThis < "u" && globalThis.document ? globalThis.document : void 0, ne = te?.querySelector(`iframe[src="${ee}/api"]`) ?? null, w = te?.createElement("iframe") ?? null;
|
|
11
|
+
!ne && w && te && (w.src = `${ee}/api`, w.style.display = "none", te.body.appendChild(w));
|
|
12
|
+
var T = ne ?? w, re = T?.contentWindow ?? null, ie = T?.style.cssText ?? "", ae = (e) => {
|
|
13
|
+
T && Object.assign(T.style, e);
|
|
14
|
+
}, oe = () => {
|
|
15
|
+
T && (T.style.cssText = ie);
|
|
16
|
+
}, se = typeof window < "u" && T ? {
|
|
17
|
+
changeIframeStyle: ae,
|
|
18
|
+
resetIframeStyle: oe
|
|
19
|
+
} : {}, ce = () => {
|
|
20
|
+
if (typeof window < "u") return re ? {
|
|
21
|
+
receive: window,
|
|
22
|
+
emit: re
|
|
23
|
+
} : void 0;
|
|
24
|
+
if (typeof self < "u") return {
|
|
25
|
+
receive: self,
|
|
26
|
+
emit: self
|
|
27
|
+
};
|
|
28
|
+
}, le = (e) => new Promise((t, n) => {
|
|
29
|
+
let r = ce();
|
|
30
|
+
if (!r) return;
|
|
31
|
+
let i = new AbortController(), a = setTimeout(() => {
|
|
32
|
+
i.abort(), n(/* @__PURE__ */ Error("Timeout waiting for api to be exposed"));
|
|
17
33
|
}, e);
|
|
18
|
-
d(
|
|
34
|
+
d(se, {
|
|
19
35
|
key: "fkn-api",
|
|
20
|
-
unregisterSignal:
|
|
21
|
-
transport:
|
|
22
|
-
receive: window,
|
|
23
|
-
emit: x
|
|
24
|
-
}
|
|
36
|
+
unregisterSignal: i.signal,
|
|
37
|
+
transport: r
|
|
25
38
|
}).then((e) => {
|
|
26
|
-
clearTimeout(
|
|
39
|
+
clearTimeout(a), t(e);
|
|
27
40
|
}).catch((e) => {
|
|
28
|
-
clearTimeout(
|
|
41
|
+
clearTimeout(a), n(e);
|
|
29
42
|
});
|
|
30
|
-
}),
|
|
31
|
-
if (t.message === "Timeout waiting for api to be exposed") return
|
|
43
|
+
}), ue = (e = 50) => le(e).then((e) => e).catch((t) => {
|
|
44
|
+
if (t.message === "Timeout waiting for api to be exposed") return ue(Math.min(e * 2, 500));
|
|
32
45
|
throw t;
|
|
33
|
-
}),
|
|
46
|
+
}), E = ue(), de = (e, t) => E.then((n) => n.proxyFetch(e, t)), fe = "https://fkn.app", pe = (e, t) => {
|
|
47
|
+
if (typeof window > "u") throw Error("FKN @fkn/lib: relayWorker must be called from the main thread");
|
|
48
|
+
if (!T?.contentWindow) throw Error("FKN @fkn/lib: relayWorker called before the FKN iframe was injected");
|
|
49
|
+
f({
|
|
50
|
+
receive: window,
|
|
51
|
+
emit: T.contentWindow
|
|
52
|
+
}, e, {
|
|
53
|
+
key: "fkn-api",
|
|
54
|
+
originA: t?.originA ?? fe,
|
|
55
|
+
originB: t?.originB ?? "*",
|
|
56
|
+
unregisterSignal: t?.unregisterSignal
|
|
57
|
+
});
|
|
58
|
+
}, me = "FKN_WEB_EXTENSION_MAIN_WORLD_CONTENT_SCRIPT_ENABLED_EVENT_KEY", he = "fknExtension", D = u();
|
|
59
|
+
typeof document < "u" && document.addEventListener(me, (e) => {
|
|
60
|
+
D.dispatchEvent(new CustomEvent("statuschange", { detail: { enabled: e.detail.enabled } }));
|
|
61
|
+
});
|
|
62
|
+
var O = () => document.documentElement.dataset[he] === "true", ge = null, _e = (e) => {
|
|
63
|
+
ge = e;
|
|
64
|
+
}, ve = (e = 1e3) => new Promise((t, n) => {
|
|
65
|
+
if (O()) return t();
|
|
66
|
+
let r = (e) => {
|
|
67
|
+
clearTimeout(s), a.disconnect(), document.removeEventListener("readystatechange", o), e();
|
|
68
|
+
}, i = () => r(async () => {
|
|
69
|
+
if (ge && (await ge().catch(() => {}), O())) return t();
|
|
70
|
+
n(/* @__PURE__ */ Error("The FKN WebExtension is not installed, enabled or not exposed on this page."));
|
|
71
|
+
}), a = new MutationObserver(() => {
|
|
72
|
+
O() && r(t);
|
|
73
|
+
}), o = () => {
|
|
74
|
+
document.readyState === "complete" && !O() && i();
|
|
75
|
+
}, s = setTimeout(i, e);
|
|
76
|
+
if (document.readyState === "complete") return i();
|
|
77
|
+
a.observe(document.documentElement, {
|
|
78
|
+
attributes: !0,
|
|
79
|
+
attributeFilter: ["data-fkn-extension"]
|
|
80
|
+
}), document.addEventListener("readystatechange", o), O() && r(t);
|
|
81
|
+
}), ye, k = new Proxy({}, { get: (e, t) => async (...e) => {
|
|
82
|
+
await ve(), ye ??= d({}, {
|
|
83
|
+
transport: window,
|
|
84
|
+
revivableModules: i
|
|
85
|
+
});
|
|
86
|
+
let n = (await ye)[t];
|
|
87
|
+
return n(...e);
|
|
88
|
+
} }), be = {
|
|
89
|
+
scope: "network.fetch",
|
|
90
|
+
category: "network",
|
|
91
|
+
severity: 0,
|
|
92
|
+
title: "Fetch data from other sites",
|
|
93
|
+
description: "Lets the app download public data from other websites directly, past the usual cross-origin limits."
|
|
94
|
+
}, xe = {
|
|
95
|
+
scope: "network.fetchCredentialed",
|
|
96
|
+
category: "network",
|
|
97
|
+
severity: 3,
|
|
98
|
+
unsafe: !0,
|
|
99
|
+
title: "Fetch from other sites — signed in as you",
|
|
100
|
+
description: "Lets the app fetch other sites using your logged-in session cookies, so it can read data only you should see."
|
|
101
|
+
}, Se = ["origin", "referer"], Ce = (e) => {
|
|
102
|
+
if (!e?.headers) return;
|
|
103
|
+
let t = new Headers(e.headers), n = Se.map((e) => {
|
|
104
|
+
let n = t.get(e);
|
|
105
|
+
return n === null ? void 0 : [e, n];
|
|
106
|
+
}).filter((e) => e !== void 0);
|
|
107
|
+
return n.length ? n : void 0;
|
|
108
|
+
}, we = async (e, t) => {
|
|
109
|
+
let n = new Request(e, t), r = n.body ? await n.arrayBuffer() : null;
|
|
110
|
+
return k.proxyFetch({
|
|
111
|
+
url: n.url,
|
|
112
|
+
method: n.method,
|
|
113
|
+
headers: [...n.headers],
|
|
114
|
+
body: r,
|
|
115
|
+
credentials: t?.credentials === "include" ? "include" : "omit",
|
|
116
|
+
redirect: n.redirect,
|
|
117
|
+
unsafeHeaders: Ce(t),
|
|
118
|
+
reason: t?.reason,
|
|
119
|
+
signal: t?.signal ?? void 0
|
|
120
|
+
});
|
|
121
|
+
}, Te = {
|
|
122
|
+
scope: "network.readCookie",
|
|
123
|
+
category: "network",
|
|
124
|
+
severity: 3,
|
|
125
|
+
unsafe: !0,
|
|
126
|
+
title: "Read a site’s cookie",
|
|
127
|
+
description: "Lets the app read a named cookie from another site, which can include the login token only that site should see."
|
|
128
|
+
}, Ee = { get: (e) => k.getCookie(e) }, De = {
|
|
129
|
+
scope: "network.modifyRequestHeaders",
|
|
130
|
+
category: "network",
|
|
131
|
+
severity: 2,
|
|
132
|
+
unsafe: !0,
|
|
133
|
+
title: "Rewrite request headers to other sites",
|
|
134
|
+
description: "Lets the app set or remove headers (like Origin and Referer) on this page’s own requests to the listed sites."
|
|
135
|
+
}, Oe = (e) => k.setRequestHeaderRule(e), ke = (e) => k.removeRequestHeaderRule({ ruleId: e });
|
|
136
|
+
(() => {
|
|
137
|
+
let e = {}, t = [...c.selectorModules, ...r.selectorModules];
|
|
138
|
+
for (let n of t) n.render && !(n.type in e) && (e[n.type] = n.render);
|
|
139
|
+
return e;
|
|
140
|
+
})();
|
|
141
|
+
//#endregion
|
|
142
|
+
//#region ../web-extension/lib/lib/frame.js
|
|
143
|
+
var Ae = "FKN_WEB_EXTENSION_ATTACH_FRAME_EVENT_KEY", je = {
|
|
144
|
+
scope: "embed.iframe",
|
|
145
|
+
category: "embed",
|
|
146
|
+
severity: 0,
|
|
147
|
+
title: "Load another website inside this app",
|
|
148
|
+
description: "Lets the app embed external pages directly inside its own view."
|
|
149
|
+
}, Me = {
|
|
150
|
+
scope: "embed.open",
|
|
151
|
+
category: "embed",
|
|
152
|
+
severity: 0,
|
|
153
|
+
title: "Open a website inside this app",
|
|
154
|
+
description: "Lets the app navigate to another site without leaving its window."
|
|
155
|
+
}, Ne = async ({ iframe: e, domains: t = [] }) => {
|
|
156
|
+
let n = crypto.randomUUID();
|
|
157
|
+
if (await ve(), !e.isConnected) throw Error("attachFrame: the iframe must be connected to the document before attaching");
|
|
158
|
+
e.dispatchEvent(new CustomEvent(Ae, { detail: n }));
|
|
159
|
+
let { executeLocator: r, ensureLocatorPermission: i, goto: a } = await k.attachFrame({
|
|
160
|
+
marker: n,
|
|
161
|
+
domains: t
|
|
162
|
+
}), o = s(r, i), c = (e, t = {}) => a({
|
|
163
|
+
url: e,
|
|
164
|
+
...t
|
|
165
|
+
}), l = () => e.src;
|
|
166
|
+
return {
|
|
167
|
+
...o,
|
|
168
|
+
goto: c,
|
|
169
|
+
url: l
|
|
170
|
+
};
|
|
171
|
+
}, Pe = { request: (e) => k.requestPermissions(e.map((e) => ({
|
|
172
|
+
key: e.key,
|
|
173
|
+
scope: e.scope ?? "",
|
|
174
|
+
reason: e.reason
|
|
175
|
+
}))) }, Fe = async (e) => {
|
|
176
|
+
if (typeof window > "u") return !1;
|
|
177
|
+
if (O()) return !0;
|
|
178
|
+
let t = await E, n = null, r = new Promise((e) => {
|
|
179
|
+
n = () => {
|
|
180
|
+
O() && e(!0);
|
|
181
|
+
}, D.addEventListener("statuschange", n);
|
|
182
|
+
}), i = t.showInstallPrompt(e).then(() => !1), a = await Promise.race([r, i]);
|
|
183
|
+
return n && D.removeEventListener("statuschange", n), await t.hideInstallPrompt().catch(() => {}), a;
|
|
184
|
+
}, Ie = null;
|
|
185
|
+
_e(() => (Ie ||= Fe().then(() => void 0).finally(() => {
|
|
186
|
+
Ie = null;
|
|
187
|
+
}), Ie));
|
|
188
|
+
//#endregion
|
|
189
|
+
//#region node_modules/preact/hooks/dist/hooks.module.js
|
|
190
|
+
var A, Le, Re, ze = [], j = g, Be = j.__b, Ve = j.__r, He = j.diffed, Ue = j.__c, We = j.unmount, Ge = j.__;
|
|
191
|
+
function Ke() {
|
|
192
|
+
for (var e; e = ze.shift();) if (e.__P && e.__H) try {
|
|
193
|
+
e.__H.__h.forEach(M), e.__H.__h.forEach(Ye), e.__H.__h = [];
|
|
194
|
+
} catch (t) {
|
|
195
|
+
e.__H.__h = [], j.__e(t, e.__v);
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
j.__b = function(e) {
|
|
199
|
+
A = null, Be && Be(e);
|
|
200
|
+
}, j.__ = function(e, t) {
|
|
201
|
+
e && t.__k && t.__k.__m && (e.__m = t.__k.__m), Ge && Ge(e, t);
|
|
202
|
+
}, j.__r = function(e) {
|
|
203
|
+
Ve && Ve(e);
|
|
204
|
+
var t = (A = e.__c).__H;
|
|
205
|
+
t && (Le === A ? (t.__h = [], A.__h = [], t.__.forEach(function(e) {
|
|
206
|
+
e.__N && (e.__ = e.__N), e.u = e.__N = void 0;
|
|
207
|
+
})) : (t.__h.forEach(M), t.__h.forEach(Ye), t.__h = [])), Le = A;
|
|
208
|
+
}, j.diffed = function(e) {
|
|
209
|
+
He && He(e);
|
|
210
|
+
var t = e.__c;
|
|
211
|
+
t && t.__H && (t.__H.__h.length && (ze.push(t) !== 1 && Re === j.requestAnimationFrame || ((Re = j.requestAnimationFrame) || Je)(Ke)), t.__H.__.forEach(function(e) {
|
|
212
|
+
e.u && (e.__H = e.u), e.u = void 0;
|
|
213
|
+
})), Le = A = null;
|
|
214
|
+
}, j.__c = function(e, t) {
|
|
215
|
+
t.some(function(e) {
|
|
216
|
+
try {
|
|
217
|
+
e.__h.forEach(M), e.__h = e.__h.filter(function(e) {
|
|
218
|
+
return !e.__ || Ye(e);
|
|
219
|
+
});
|
|
220
|
+
} catch (n) {
|
|
221
|
+
t.some(function(e) {
|
|
222
|
+
e.__h &&= [];
|
|
223
|
+
}), t = [], j.__e(n, e.__v);
|
|
224
|
+
}
|
|
225
|
+
}), Ue && Ue(e, t);
|
|
226
|
+
}, j.unmount = function(e) {
|
|
227
|
+
We && We(e);
|
|
228
|
+
var t, n = e.__c;
|
|
229
|
+
n && n.__H && (n.__H.__.forEach(function(e) {
|
|
230
|
+
try {
|
|
231
|
+
M(e);
|
|
232
|
+
} catch (e) {
|
|
233
|
+
t = e;
|
|
234
|
+
}
|
|
235
|
+
}), n.__H = void 0, t && j.__e(t, n.__v));
|
|
236
|
+
};
|
|
237
|
+
var qe = typeof requestAnimationFrame == "function";
|
|
238
|
+
function Je(e) {
|
|
239
|
+
var t, n = function() {
|
|
240
|
+
clearTimeout(r), qe && cancelAnimationFrame(t), setTimeout(e);
|
|
241
|
+
}, r = setTimeout(n, 35);
|
|
242
|
+
qe && (t = requestAnimationFrame(n));
|
|
243
|
+
}
|
|
244
|
+
function M(e) {
|
|
245
|
+
var t = A, n = e.__c;
|
|
246
|
+
typeof n == "function" && (e.__c = void 0, n()), A = t;
|
|
247
|
+
}
|
|
248
|
+
function Ye(e) {
|
|
249
|
+
var t = A;
|
|
250
|
+
e.__c = e.__(), A = t;
|
|
251
|
+
}
|
|
252
|
+
//#endregion
|
|
253
|
+
//#region node_modules/preact/compat/dist/compat.module.js
|
|
254
|
+
function Xe(e, t) {
|
|
255
|
+
for (var n in t) e[n] = t[n];
|
|
256
|
+
return e;
|
|
257
|
+
}
|
|
258
|
+
function Ze(e, t) {
|
|
259
|
+
for (var n in e) if (n !== "__source" && !(n in t)) return !0;
|
|
260
|
+
for (var r in t) if (r !== "__source" && e[r] !== t[r]) return !0;
|
|
261
|
+
return !1;
|
|
262
|
+
}
|
|
263
|
+
function Qe(e, t) {
|
|
264
|
+
this.props = e, this.context = t;
|
|
265
|
+
}
|
|
266
|
+
(Qe.prototype = new p()).isPureReactComponent = !0, Qe.prototype.shouldComponentUpdate = function(e, t) {
|
|
267
|
+
return Ze(this.props, e) || Ze(this.state, t);
|
|
268
|
+
};
|
|
269
|
+
var $e = g.__b;
|
|
270
|
+
g.__b = function(e) {
|
|
271
|
+
e.type && e.type.__f && e.ref && (e.props.ref = e.ref, e.ref = null), $e && $e(e);
|
|
272
|
+
}, typeof Symbol < "u" && Symbol.for;
|
|
273
|
+
var et = g.__e;
|
|
274
|
+
g.__e = function(e, t, n, r) {
|
|
275
|
+
if (e.then) {
|
|
276
|
+
for (var i, a = t; a = a.__;) if ((i = a.__c) && i.__c) return t.__e ?? (t.__e = n.__e, t.__k = n.__k), i.__c(e, t);
|
|
277
|
+
}
|
|
278
|
+
et(e, t, n, r);
|
|
279
|
+
};
|
|
280
|
+
var tt = g.unmount;
|
|
281
|
+
function nt(e, t, n) {
|
|
282
|
+
return e && (e.__c && e.__c.__H && (e.__c.__H.__.forEach(function(e) {
|
|
283
|
+
typeof e.__c == "function" && e.__c();
|
|
284
|
+
}), e.__c.__H = null), (e = Xe({}, e)).__c != null && (e.__c.__P === n && (e.__c.__P = t), e.__c.__e = !0, e.__c = null), e.__k = e.__k && e.__k.map(function(e) {
|
|
285
|
+
return nt(e, t, n);
|
|
286
|
+
})), e;
|
|
287
|
+
}
|
|
288
|
+
function rt(e, t, n) {
|
|
289
|
+
return e && n && (e.__v = null, e.__k = e.__k && e.__k.map(function(e) {
|
|
290
|
+
return rt(e, t, n);
|
|
291
|
+
}), e.__c && e.__c.__P === t && (e.__e && n.appendChild(e.__e), e.__c.__e = !0, e.__c.__P = n)), e;
|
|
292
|
+
}
|
|
293
|
+
function it() {
|
|
294
|
+
this.__u = 0, this.o = null, this.__b = null;
|
|
295
|
+
}
|
|
296
|
+
function at(e) {
|
|
297
|
+
if (!e.__) return null;
|
|
298
|
+
var t = e.__.__c;
|
|
299
|
+
return t && t.__a && t.__a(e);
|
|
300
|
+
}
|
|
301
|
+
function N() {
|
|
302
|
+
this.i = null, this.l = null;
|
|
303
|
+
}
|
|
304
|
+
g.unmount = function(e) {
|
|
305
|
+
var t = e.__c;
|
|
306
|
+
t && (t.__z = !0), t && t.__R && t.__R(), t && 32 & e.__u && (e.type = null), tt && tt(e);
|
|
307
|
+
}, (it.prototype = new p()).__c = function(e, t) {
|
|
308
|
+
var n = t.__c, r = this;
|
|
309
|
+
r.o ??= [], r.o.push(n);
|
|
310
|
+
var i = at(r.__v), a = !1, o = function() {
|
|
311
|
+
a || r.__z || (a = !0, n.__R = null, i ? i(c) : c());
|
|
312
|
+
};
|
|
313
|
+
n.__R = o;
|
|
314
|
+
var s = n.__P;
|
|
315
|
+
n.__P = null;
|
|
316
|
+
var c = function() {
|
|
317
|
+
if (!--r.__u) {
|
|
318
|
+
if (r.state.__a) {
|
|
319
|
+
var e = r.state.__a;
|
|
320
|
+
r.__v.__k[0] = rt(e, e.__c.__P, e.__c.__O);
|
|
321
|
+
}
|
|
322
|
+
var t;
|
|
323
|
+
for (r.setState({ __a: r.__b = null }); t = r.o.pop();) t.__P = s, t.forceUpdate();
|
|
324
|
+
}
|
|
325
|
+
};
|
|
326
|
+
r.__u++ || 32 & t.__u || r.setState({ __a: r.__b = r.__v.__k[0] }), e.then(o, o);
|
|
327
|
+
}, it.prototype.componentWillUnmount = function() {
|
|
328
|
+
this.o = [];
|
|
329
|
+
}, it.prototype.render = function(e, t) {
|
|
330
|
+
if (this.__b) {
|
|
331
|
+
if (this.__v.__k) {
|
|
332
|
+
var n = document.createElement("div"), r = this.__v.__k[0].__c;
|
|
333
|
+
this.__v.__k[0] = nt(this.__b, n, r.__O = r.__P);
|
|
334
|
+
}
|
|
335
|
+
this.__b = null;
|
|
336
|
+
}
|
|
337
|
+
var i = t.__a && h(m, null, e.fallback);
|
|
338
|
+
return i && (i.__u &= -33), [h(m, null, t.__a ? null : e.children), i];
|
|
339
|
+
};
|
|
340
|
+
var ot = function(e, t, n) {
|
|
341
|
+
if (++n[1] === n[0] && e.l.delete(t), e.props.revealOrder && (e.props.revealOrder[0] !== "t" || !e.l.size)) for (n = e.i; n;) {
|
|
342
|
+
for (; n.length > 3;) n.pop()();
|
|
343
|
+
if (n[1] < n[0]) break;
|
|
344
|
+
e.i = n = n[2];
|
|
345
|
+
}
|
|
346
|
+
};
|
|
347
|
+
(N.prototype = new p()).__a = function(e) {
|
|
348
|
+
var t = this, n = at(t.__v), r = t.l.get(e);
|
|
349
|
+
return r[0]++, function(i) {
|
|
350
|
+
var a = function() {
|
|
351
|
+
t.props.revealOrder ? (r.push(i), ot(t, e, r)) : i();
|
|
352
|
+
};
|
|
353
|
+
n ? n(a) : a();
|
|
354
|
+
};
|
|
355
|
+
}, N.prototype.render = function(e) {
|
|
356
|
+
this.i = null, this.l = /* @__PURE__ */ new Map();
|
|
357
|
+
var t = _(e.children);
|
|
358
|
+
e.revealOrder && e.revealOrder[0] === "b" && t.reverse();
|
|
359
|
+
for (var n = t.length; n--;) this.l.set(t[n], this.i = [
|
|
360
|
+
1,
|
|
361
|
+
0,
|
|
362
|
+
this.i
|
|
363
|
+
]);
|
|
364
|
+
return e.children;
|
|
365
|
+
}, N.prototype.componentDidUpdate = N.prototype.componentDidMount = function() {
|
|
366
|
+
var e = this;
|
|
367
|
+
this.l.forEach(function(t, n) {
|
|
368
|
+
ot(e, n, t);
|
|
369
|
+
});
|
|
370
|
+
};
|
|
371
|
+
var st = typeof Symbol < "u" && Symbol.for && Symbol.for("react.element") || 60103, ct = /^(?:accent|alignment|arabic|baseline|cap|clip(?!PathU)|color|dominant|fill|flood|font|glyph(?!R)|horiz|image(!S)|letter|lighting|marker(?!H|W|U)|overline|paint|pointer|shape|stop|strikethrough|stroke|text(?!L)|transform|underline|unicode|units|v|vector|vert|word|writing|x(?!C))[A-Z]/, lt = /^on(Ani|Tra|Tou|BeforeInp|Compo)/, ut = /[A-Z0-9]/g, dt = typeof document < "u", ft = function(e) {
|
|
372
|
+
return (typeof Symbol < "u" && typeof Symbol() == "symbol" ? /fil|che|rad/ : /fil|che|ra/).test(e);
|
|
373
|
+
};
|
|
374
|
+
p.prototype.isReactComponent = {}, [
|
|
375
|
+
"componentWillMount",
|
|
376
|
+
"componentWillReceiveProps",
|
|
377
|
+
"componentWillUpdate"
|
|
378
|
+
].forEach(function(e) {
|
|
379
|
+
Object.defineProperty(p.prototype, e, {
|
|
380
|
+
configurable: !0,
|
|
381
|
+
get: function() {
|
|
382
|
+
return this["UNSAFE_" + e];
|
|
383
|
+
},
|
|
384
|
+
set: function(t) {
|
|
385
|
+
Object.defineProperty(this, e, {
|
|
386
|
+
configurable: !0,
|
|
387
|
+
writable: !0,
|
|
388
|
+
value: t
|
|
389
|
+
});
|
|
390
|
+
}
|
|
391
|
+
});
|
|
392
|
+
});
|
|
393
|
+
var pt = g.event;
|
|
394
|
+
function mt() {}
|
|
395
|
+
function ht() {
|
|
396
|
+
return this.cancelBubble;
|
|
397
|
+
}
|
|
398
|
+
function gt() {
|
|
399
|
+
return this.defaultPrevented;
|
|
400
|
+
}
|
|
401
|
+
g.event = function(e) {
|
|
402
|
+
return pt && (e = pt(e)), e.persist = mt, e.isPropagationStopped = ht, e.isDefaultPrevented = gt, e.nativeEvent = e;
|
|
403
|
+
};
|
|
404
|
+
var _t = {
|
|
405
|
+
enumerable: !1,
|
|
406
|
+
configurable: !0,
|
|
407
|
+
get: function() {
|
|
408
|
+
return this.class;
|
|
409
|
+
}
|
|
410
|
+
}, vt = g.vnode;
|
|
411
|
+
g.vnode = function(e) {
|
|
412
|
+
typeof e.type == "string" && function(e) {
|
|
413
|
+
var t = e.props, n = e.type, r = {}, i = n.indexOf("-") === -1;
|
|
414
|
+
for (var a in t) {
|
|
415
|
+
var o = t[a];
|
|
416
|
+
if (!(a === "value" && "defaultValue" in t && o == null || dt && a === "children" && n === "noscript" || a === "class" || a === "className")) {
|
|
417
|
+
var s = a.toLowerCase();
|
|
418
|
+
a === "defaultValue" && "value" in t && t.value == null ? a = "value" : a === "download" && !0 === o ? o = "" : s === "translate" && o === "no" ? o = !1 : s[0] === "o" && s[1] === "n" ? s === "ondoubleclick" ? a = "ondblclick" : s !== "onchange" || n !== "input" && n !== "textarea" || ft(t.type) ? s === "onfocus" ? a = "onfocusin" : s === "onblur" ? a = "onfocusout" : lt.test(a) && (a = s) : s = a = "oninput" : i && ct.test(a) ? a = a.replace(ut, "-$&").toLowerCase() : o === null && (o = void 0), s === "oninput" && r[a = s] && (a = "oninputCapture"), r[a] = o;
|
|
419
|
+
}
|
|
420
|
+
}
|
|
421
|
+
n == "select" && r.multiple && Array.isArray(r.value) && (r.value = _(t.children).forEach(function(e) {
|
|
422
|
+
e.props.selected = r.value.indexOf(e.props.value) != -1;
|
|
423
|
+
})), n == "select" && r.defaultValue != null && (r.value = _(t.children).forEach(function(e) {
|
|
424
|
+
e.props.selected = r.multiple ? r.defaultValue.indexOf(e.props.value) != -1 : r.defaultValue == e.props.value;
|
|
425
|
+
})), t.class && !t.className ? (r.class = t.class, Object.defineProperty(r, "className", _t)) : (t.className && !t.class || t.class && t.className) && (r.class = r.className = t.className), e.props = r;
|
|
426
|
+
}(e), e.$$typeof = st, vt && vt(e);
|
|
427
|
+
};
|
|
428
|
+
var yt = g.__r;
|
|
429
|
+
g.__r = function(e) {
|
|
430
|
+
yt && yt(e), e.__c;
|
|
431
|
+
};
|
|
432
|
+
var bt = g.diffed;
|
|
433
|
+
g.diffed = function(e) {
|
|
434
|
+
bt && bt(e);
|
|
435
|
+
var t = e.props, n = e.__e;
|
|
436
|
+
n != null && e.type === "textarea" && "value" in t && t.value !== n.value && (n.value = t.value == null ? "" : t.value);
|
|
437
|
+
};
|
|
438
|
+
//#endregion
|
|
439
|
+
//#region node_modules/better-auth/dist/client/broadcast-channel.mjs
|
|
440
|
+
var xt = Symbol.for("better-auth:broadcast-channel"), St = () => Math.floor(Date.now() / 1e3), Ct = class {
|
|
441
|
+
listeners = /* @__PURE__ */ new Set();
|
|
442
|
+
name;
|
|
443
|
+
constructor(e = "better-auth.message") {
|
|
444
|
+
this.name = e;
|
|
445
|
+
}
|
|
446
|
+
subscribe(e) {
|
|
447
|
+
return this.listeners.add(e), () => {
|
|
448
|
+
this.listeners.delete(e);
|
|
449
|
+
};
|
|
450
|
+
}
|
|
451
|
+
post(e) {
|
|
452
|
+
if (!(typeof window > "u")) try {
|
|
453
|
+
localStorage.setItem(this.name, JSON.stringify({
|
|
454
|
+
...e,
|
|
455
|
+
timestamp: St()
|
|
456
|
+
}));
|
|
457
|
+
} catch {}
|
|
458
|
+
}
|
|
459
|
+
setup() {
|
|
460
|
+
if (typeof window > "u" || window.addEventListener === void 0) return () => {};
|
|
461
|
+
let e = (e) => {
|
|
462
|
+
if (e.key !== this.name) return;
|
|
463
|
+
let t = JSON.parse(e.newValue ?? "{}");
|
|
464
|
+
t?.event !== "session" || !t?.data || this.listeners.forEach((e) => e(t));
|
|
465
|
+
};
|
|
466
|
+
return window.addEventListener("storage", e), () => {
|
|
467
|
+
window.removeEventListener("storage", e);
|
|
468
|
+
};
|
|
469
|
+
}
|
|
470
|
+
};
|
|
471
|
+
function wt(e = "better-auth.message") {
|
|
472
|
+
return globalThis[xt] || (globalThis[xt] = new Ct(e)), globalThis[xt];
|
|
473
|
+
}
|
|
474
|
+
//#endregion
|
|
475
|
+
//#region node_modules/better-auth/dist/client/focus-manager.mjs
|
|
476
|
+
var Tt = Symbol.for("better-auth:focus-manager"), Et = class {
|
|
477
|
+
listeners = /* @__PURE__ */ new Set();
|
|
478
|
+
subscribe(e) {
|
|
479
|
+
return this.listeners.add(e), () => {
|
|
480
|
+
this.listeners.delete(e);
|
|
481
|
+
};
|
|
482
|
+
}
|
|
483
|
+
setFocused(e) {
|
|
484
|
+
this.listeners.forEach((t) => t(e));
|
|
485
|
+
}
|
|
486
|
+
setup() {
|
|
487
|
+
if (typeof window > "u" || typeof document > "u" || window.addEventListener === void 0) return () => {};
|
|
488
|
+
let e = () => {
|
|
489
|
+
document.visibilityState === "visible" && this.setFocused(!0);
|
|
490
|
+
};
|
|
491
|
+
return document.addEventListener("visibilitychange", e, !1), () => {
|
|
492
|
+
document.removeEventListener("visibilitychange", e, !1);
|
|
493
|
+
};
|
|
494
|
+
}
|
|
495
|
+
};
|
|
496
|
+
function Dt() {
|
|
497
|
+
return globalThis[Tt] || (globalThis[Tt] = new Et()), globalThis[Tt];
|
|
498
|
+
}
|
|
499
|
+
//#endregion
|
|
500
|
+
//#region node_modules/better-auth/dist/client/online-manager.mjs
|
|
501
|
+
var Ot = Symbol.for("better-auth:online-manager"), kt = class {
|
|
502
|
+
listeners = /* @__PURE__ */ new Set();
|
|
503
|
+
isOnline = typeof navigator < "u" ? navigator.onLine : !0;
|
|
504
|
+
subscribe(e) {
|
|
505
|
+
return this.listeners.add(e), () => {
|
|
506
|
+
this.listeners.delete(e);
|
|
507
|
+
};
|
|
508
|
+
}
|
|
509
|
+
setOnline(e) {
|
|
510
|
+
this.isOnline = e, this.listeners.forEach((t) => t(e));
|
|
511
|
+
}
|
|
512
|
+
setup() {
|
|
513
|
+
if (typeof window > "u" || window.addEventListener === void 0) return () => {};
|
|
514
|
+
let e = () => this.setOnline(!0), t = () => this.setOnline(!1);
|
|
515
|
+
return window.addEventListener("online", e, !1), window.addEventListener("offline", t, !1), () => {
|
|
516
|
+
window.removeEventListener("online", e, !1), window.removeEventListener("offline", t, !1);
|
|
517
|
+
};
|
|
518
|
+
}
|
|
519
|
+
};
|
|
520
|
+
function At() {
|
|
521
|
+
return globalThis[Ot] || (globalThis[Ot] = new kt()), globalThis[Ot];
|
|
522
|
+
}
|
|
523
|
+
//#endregion
|
|
524
|
+
//#region node_modules/better-auth/dist/client/parser.mjs
|
|
525
|
+
var jt = {
|
|
526
|
+
proto: /"(?:_|\\u0{2}5[Ff]){2}(?:p|\\u0{2}70)(?:r|\\u0{2}72)(?:o|\\u0{2}6[Ff])(?:t|\\u0{2}74)(?:o|\\u0{2}6[Ff])(?:_|\\u0{2}5[Ff]){2}"\s*:/,
|
|
527
|
+
constructor: /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/,
|
|
528
|
+
protoShort: /"__proto__"\s*:/,
|
|
529
|
+
constructorShort: /"constructor"\s*:/
|
|
530
|
+
}, Mt = /^\s*["[{]|^\s*-?\d{1,16}(\.\d{1,17})?([Ee][+-]?\d+)?\s*$/, Nt = {
|
|
531
|
+
true: !0,
|
|
532
|
+
false: !1,
|
|
533
|
+
null: null,
|
|
534
|
+
undefined: void 0,
|
|
535
|
+
nan: NaN,
|
|
536
|
+
infinity: Infinity,
|
|
537
|
+
"-infinity": -Infinity
|
|
538
|
+
}, Pt = /^(\d{4})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,7}))?(?:Z|([+-])(\d{2}):(\d{2}))$/;
|
|
539
|
+
function Ft(e) {
|
|
540
|
+
return e instanceof Date && !isNaN(e.getTime());
|
|
541
|
+
}
|
|
542
|
+
function It(e) {
|
|
543
|
+
let t = Pt.exec(e);
|
|
544
|
+
if (!t) return null;
|
|
545
|
+
let [, n, r, i, a, o, s, c, l, u, d] = t, f = new Date(Date.UTC(parseInt(n, 10), parseInt(r, 10) - 1, parseInt(i, 10), parseInt(a, 10), parseInt(o, 10), parseInt(s, 10), c ? parseInt(c.padEnd(3, "0"), 10) : 0));
|
|
546
|
+
if (l) {
|
|
547
|
+
let e = (parseInt(u, 10) * 60 + parseInt(d, 10)) * (l === "+" ? -1 : 1);
|
|
548
|
+
f.setUTCMinutes(f.getUTCMinutes() + e);
|
|
549
|
+
}
|
|
550
|
+
return Ft(f) ? f : null;
|
|
551
|
+
}
|
|
552
|
+
function Lt(e, t = {}) {
|
|
553
|
+
let { strict: n = !1, warnings: r = !1, reviver: i, parseDates: a = !0 } = t;
|
|
554
|
+
if (typeof e != "string") return e;
|
|
555
|
+
let o = e.trim(), s = o.toLowerCase();
|
|
556
|
+
if (s.length <= 9 && s in Nt) return Nt[s];
|
|
557
|
+
if (!Mt.test(o)) {
|
|
558
|
+
if (n) throw SyntaxError("[better-json] Invalid JSON");
|
|
559
|
+
return e;
|
|
560
|
+
}
|
|
561
|
+
if (Object.entries(jt).some(([e, t]) => {
|
|
562
|
+
let n = t.test(o);
|
|
563
|
+
return n && r && console.warn(`[better-json] Detected potential prototype pollution attempt using ${e} pattern`), n;
|
|
564
|
+
}) && n) throw Error("[better-json] Potential prototype pollution attempt detected");
|
|
565
|
+
try {
|
|
566
|
+
return JSON.parse(o, (e, t) => {
|
|
567
|
+
if (e === "__proto__" || e === "constructor" && t && typeof t == "object" && "prototype" in t) {
|
|
568
|
+
r && console.warn(`[better-json] Dropping "${e}" key to prevent prototype pollution`);
|
|
569
|
+
return;
|
|
570
|
+
}
|
|
571
|
+
if (a && typeof t == "string") {
|
|
572
|
+
let e = It(t);
|
|
573
|
+
if (e) return e;
|
|
574
|
+
}
|
|
575
|
+
return i ? i(e, t) : t;
|
|
576
|
+
});
|
|
577
|
+
} catch (t) {
|
|
578
|
+
if (n) throw t;
|
|
579
|
+
return e;
|
|
580
|
+
}
|
|
581
|
+
}
|
|
582
|
+
function Rt(e, t = { strict: !0 }) {
|
|
583
|
+
return Lt(e, t);
|
|
584
|
+
}
|
|
585
|
+
//#endregion
|
|
586
|
+
//#region node_modules/nanostores/atom/index.js
|
|
587
|
+
var P = [], F = 0, I = 4, zt = globalThis.nanostoresGlobal ||= { epoch: 0 }, Bt = /* @__NO_SIDE_EFFECTS__ */ (e) => {
|
|
588
|
+
let t = [], n = {
|
|
589
|
+
get() {
|
|
590
|
+
return n.lc || n.listen(() => {})(), n.value;
|
|
591
|
+
},
|
|
592
|
+
init: e,
|
|
593
|
+
lc: 0,
|
|
594
|
+
listen(e) {
|
|
595
|
+
return n.lc = t.push(e), () => {
|
|
596
|
+
for (let t = F + I; t < P.length;) P[t] === e ? P.splice(t, I) : t += I;
|
|
597
|
+
let r = t.indexOf(e);
|
|
598
|
+
~r && (t.splice(r, 1), --n.lc || n.off());
|
|
599
|
+
};
|
|
600
|
+
},
|
|
601
|
+
notify(e, r) {
|
|
602
|
+
zt.epoch++;
|
|
603
|
+
let i = !P.length;
|
|
604
|
+
for (let i of t) P.push(i, n.value, e, r);
|
|
605
|
+
if (i) {
|
|
606
|
+
for (F = 0; F < P.length; F += I) P[F](P[F + 1], P[F + 2], P[F + 3]);
|
|
607
|
+
P.length = 0;
|
|
608
|
+
}
|
|
609
|
+
},
|
|
610
|
+
off() {},
|
|
611
|
+
set(e) {
|
|
612
|
+
let t = n.value;
|
|
613
|
+
t !== e && (n.value = e, n.notify(t));
|
|
614
|
+
},
|
|
615
|
+
subscribe(e) {
|
|
616
|
+
let t = n.listen(e);
|
|
617
|
+
return e(n.value), t;
|
|
618
|
+
},
|
|
619
|
+
value: e
|
|
620
|
+
};
|
|
621
|
+
return n;
|
|
622
|
+
}, Vt = 5, L = 6, R = 10, Ht = (e, t, n, r) => (e.events = e.events || {}, e.events[n + R] || (e.events[n + R] = r((t) => {
|
|
623
|
+
e.events[n].reduceRight((e, t) => (t(e), e), {
|
|
624
|
+
shared: {},
|
|
625
|
+
...t
|
|
626
|
+
});
|
|
627
|
+
})), e.events[n] = e.events[n] || [], e.events[n].push(t), () => {
|
|
628
|
+
let r = e.events[n], i = r.indexOf(t);
|
|
629
|
+
r.splice(i, 1), r.length || (delete e.events[n], e.events[n + R](), delete e.events[n + R]);
|
|
630
|
+
}), Ut = 1e3, Wt = (e, t) => Ht(e, (n) => {
|
|
631
|
+
let r = t(n);
|
|
632
|
+
r && e.events[L].push(r);
|
|
633
|
+
}, Vt, (t) => {
|
|
634
|
+
let n = e.listen;
|
|
635
|
+
e.listen = (...r) => (!e.lc && !e.active && (e.active = !0, t()), n(...r));
|
|
636
|
+
let r = e.off;
|
|
637
|
+
return e.events[L] = [], e.off = () => {
|
|
638
|
+
r(), setTimeout(() => {
|
|
639
|
+
if (e.active && !e.lc) {
|
|
640
|
+
e.active = !1;
|
|
641
|
+
for (let t of e.events[L]) t();
|
|
642
|
+
e.events[L] = [];
|
|
643
|
+
}
|
|
644
|
+
}, Ut);
|
|
645
|
+
}, () => {
|
|
646
|
+
e.listen = n, e.off = r;
|
|
647
|
+
};
|
|
648
|
+
}), Gt = () => typeof window > "u", Kt = (e, t, n, r) => {
|
|
649
|
+
let i = /* @__PURE__ */ Bt({
|
|
650
|
+
data: null,
|
|
651
|
+
error: null,
|
|
652
|
+
isPending: !0,
|
|
653
|
+
isRefetching: !1,
|
|
654
|
+
refetch: (e) => a(e)
|
|
655
|
+
}), a = async (e) => new Promise((a) => {
|
|
656
|
+
let o = typeof r == "function" ? r({
|
|
657
|
+
data: i.get().data,
|
|
658
|
+
error: i.get().error,
|
|
659
|
+
isPending: i.get().isPending
|
|
660
|
+
}) : r;
|
|
661
|
+
n(t, {
|
|
662
|
+
...o,
|
|
663
|
+
query: {
|
|
664
|
+
...o?.query,
|
|
665
|
+
...e?.query
|
|
666
|
+
},
|
|
667
|
+
async onSuccess(e) {
|
|
668
|
+
i.set({
|
|
669
|
+
data: e.data,
|
|
670
|
+
error: null,
|
|
671
|
+
isPending: !1,
|
|
672
|
+
isRefetching: !1,
|
|
673
|
+
refetch: i.value.refetch
|
|
674
|
+
}), await o?.onSuccess?.(e);
|
|
675
|
+
},
|
|
676
|
+
async onError(e) {
|
|
677
|
+
let { request: t } = e, n = typeof t.retry == "number" ? t.retry : t.retry?.attempts, r = t.retryAttempt || 0;
|
|
678
|
+
if (n && r < n) return;
|
|
679
|
+
let a = e.error.status === 401;
|
|
680
|
+
i.set({
|
|
681
|
+
error: e.error,
|
|
682
|
+
data: a ? null : i.get().data,
|
|
683
|
+
isPending: !1,
|
|
684
|
+
isRefetching: !1,
|
|
685
|
+
refetch: i.value.refetch
|
|
686
|
+
}), await o?.onError?.(e);
|
|
687
|
+
},
|
|
688
|
+
async onRequest(e) {
|
|
689
|
+
let t = i.get();
|
|
690
|
+
i.set({
|
|
691
|
+
isPending: t.data === null,
|
|
692
|
+
data: t.data,
|
|
693
|
+
error: null,
|
|
694
|
+
isRefetching: !0,
|
|
695
|
+
refetch: i.value.refetch
|
|
696
|
+
}), await o?.onRequest?.(e);
|
|
697
|
+
}
|
|
698
|
+
}).catch((e) => {
|
|
699
|
+
i.set({
|
|
700
|
+
error: e,
|
|
701
|
+
data: i.get().data,
|
|
702
|
+
isPending: !1,
|
|
703
|
+
isRefetching: !1,
|
|
704
|
+
refetch: i.value.refetch
|
|
705
|
+
});
|
|
706
|
+
}).finally(() => {
|
|
707
|
+
a(void 0);
|
|
708
|
+
});
|
|
709
|
+
});
|
|
710
|
+
e = Array.isArray(e) ? e : [e];
|
|
711
|
+
let o = !1;
|
|
712
|
+
for (let t of e) t.subscribe(async () => {
|
|
713
|
+
Gt() || (o ? await a() : Wt(i, () => {
|
|
714
|
+
let e = setTimeout(async () => {
|
|
715
|
+
o || (o = !0, await a());
|
|
716
|
+
}, 0);
|
|
717
|
+
return () => {
|
|
718
|
+
i.off(), t.off(), clearTimeout(e);
|
|
719
|
+
};
|
|
720
|
+
}));
|
|
721
|
+
});
|
|
722
|
+
return i;
|
|
723
|
+
}, z = () => Math.floor(Date.now() / 1e3);
|
|
724
|
+
function qt(e) {
|
|
725
|
+
return typeof e == "object" && e && "data" in e && "error" in e ? e : {
|
|
726
|
+
data: e,
|
|
727
|
+
error: null
|
|
728
|
+
};
|
|
729
|
+
}
|
|
730
|
+
var Jt = 5;
|
|
731
|
+
function Yt(e) {
|
|
732
|
+
let { sessionAtom: t, sessionSignal: n, $fetch: r, options: i = {} } = e, a = i.sessionOptions?.refetchInterval ?? 0, o = i.sessionOptions?.refetchOnWindowFocus ?? !0, s = i.sessionOptions?.refetchWhenOffline ?? !1, c = {
|
|
733
|
+
lastSync: 0,
|
|
734
|
+
lastSessionRequest: 0,
|
|
735
|
+
cachedSession: void 0
|
|
736
|
+
}, l = () => s || At().isOnline, u = (e) => {
|
|
737
|
+
if (!l()) return;
|
|
738
|
+
if (e?.event === "storage") {
|
|
739
|
+
c.lastSync = z(), n.set(!n.get());
|
|
740
|
+
return;
|
|
741
|
+
}
|
|
742
|
+
let i = t.get(), a = () => {
|
|
743
|
+
c.lastSessionRequest = z(), r("/get-session").then(async (e) => {
|
|
744
|
+
let { data: a, error: o } = qt(e);
|
|
745
|
+
if (a?.needsRefresh) try {
|
|
746
|
+
let e = await r("/get-session", { method: "POST" });
|
|
747
|
+
({data: a, error: o} = qt(e));
|
|
748
|
+
} catch {}
|
|
749
|
+
let s = a?.session && a?.user ? a : null;
|
|
750
|
+
t.set({
|
|
751
|
+
...i,
|
|
752
|
+
data: s,
|
|
753
|
+
error: o
|
|
754
|
+
}), c.lastSync = z(), n.set(!n.get());
|
|
755
|
+
}).catch(() => {});
|
|
756
|
+
};
|
|
757
|
+
if (e?.event === "poll") {
|
|
758
|
+
a();
|
|
759
|
+
return;
|
|
760
|
+
}
|
|
761
|
+
if (e?.event === "visibilitychange") {
|
|
762
|
+
if (z() - c.lastSessionRequest < Jt) return;
|
|
763
|
+
c.lastSessionRequest = z();
|
|
764
|
+
}
|
|
765
|
+
if (e?.event === "visibilitychange") {
|
|
766
|
+
a();
|
|
767
|
+
return;
|
|
768
|
+
}
|
|
769
|
+
(i?.data === null || i?.data === void 0) && (c.lastSync = z(), n.set(!n.get()));
|
|
770
|
+
}, d = (e) => {
|
|
771
|
+
wt().post({
|
|
772
|
+
event: "session",
|
|
773
|
+
data: { trigger: e },
|
|
774
|
+
clientId: Math.random().toString(36).substring(7)
|
|
775
|
+
});
|
|
776
|
+
}, f = () => {
|
|
777
|
+
a && a > 0 && (c.pollInterval = setInterval(() => {
|
|
778
|
+
t.get()?.data && u({ event: "poll" });
|
|
779
|
+
}, a * 1e3));
|
|
780
|
+
}, p = () => {
|
|
781
|
+
c.unsubscribeBroadcast = wt().subscribe(() => {
|
|
782
|
+
u({ event: "storage" });
|
|
783
|
+
});
|
|
784
|
+
}, m = () => {
|
|
785
|
+
o && (c.unsubscribeFocus = Dt().subscribe(() => {
|
|
786
|
+
u({ event: "visibilitychange" });
|
|
787
|
+
}));
|
|
788
|
+
}, h = () => {
|
|
789
|
+
c.unsubscribeOnline = At().subscribe((e) => {
|
|
790
|
+
e && u({ event: "visibilitychange" });
|
|
791
|
+
});
|
|
792
|
+
};
|
|
793
|
+
return {
|
|
794
|
+
init: () => {
|
|
795
|
+
f(), p(), m(), h(), wt().setup(), Dt().setup(), At().setup();
|
|
796
|
+
},
|
|
797
|
+
cleanup: () => {
|
|
798
|
+
c.pollInterval &&= (clearInterval(c.pollInterval), void 0), c.unsubscribeBroadcast &&= (c.unsubscribeBroadcast(), void 0), c.unsubscribeFocus &&= (c.unsubscribeFocus(), void 0), c.unsubscribeOnline &&= (c.unsubscribeOnline(), void 0), c.lastSync = 0, c.lastSessionRequest = 0, c.cachedSession = void 0;
|
|
799
|
+
},
|
|
800
|
+
triggerRefetch: u,
|
|
801
|
+
broadcastSessionUpdate: d
|
|
802
|
+
};
|
|
803
|
+
}
|
|
804
|
+
//#endregion
|
|
805
|
+
//#region node_modules/@better-auth/core/dist/env/env-impl.mjs
|
|
806
|
+
var B = Object.create(null), V = (e) => globalThis.process?.env || globalThis.Deno?.env.toObject() || globalThis.__env__ || (e ? B : globalThis), H = new Proxy(B, {
|
|
807
|
+
get(e, t) {
|
|
808
|
+
return V()[t] ?? B[t];
|
|
809
|
+
},
|
|
810
|
+
has(e, t) {
|
|
811
|
+
return t in V() || t in B;
|
|
812
|
+
},
|
|
813
|
+
set(e, t, n) {
|
|
814
|
+
let r = V(!0);
|
|
815
|
+
return r[t] = n, !0;
|
|
816
|
+
},
|
|
817
|
+
deleteProperty(e, t) {
|
|
818
|
+
if (!t) return !1;
|
|
819
|
+
let n = V(!0);
|
|
820
|
+
return delete n[t], !0;
|
|
821
|
+
},
|
|
822
|
+
ownKeys() {
|
|
823
|
+
let e = V(!0);
|
|
824
|
+
return Object.keys(e);
|
|
825
|
+
}
|
|
826
|
+
});
|
|
827
|
+
typeof process < "u" && process.env;
|
|
828
|
+
function U(e, t) {
|
|
829
|
+
return typeof process < "u" && process.env ? process.env[e] ?? t : typeof Deno < "u" ? Deno.env.get(e) ?? t : typeof Bun < "u" ? Bun.env[e] ?? t : t;
|
|
830
|
+
}
|
|
831
|
+
Object.freeze({
|
|
832
|
+
get BETTER_AUTH_SECRET() {
|
|
833
|
+
return U("BETTER_AUTH_SECRET");
|
|
834
|
+
},
|
|
835
|
+
get AUTH_SECRET() {
|
|
836
|
+
return U("AUTH_SECRET");
|
|
837
|
+
},
|
|
838
|
+
get BETTER_AUTH_TELEMETRY() {
|
|
839
|
+
return U("BETTER_AUTH_TELEMETRY");
|
|
840
|
+
},
|
|
841
|
+
get BETTER_AUTH_TELEMETRY_ID() {
|
|
842
|
+
return U("BETTER_AUTH_TELEMETRY_ID");
|
|
843
|
+
},
|
|
844
|
+
get NODE_ENV() {
|
|
845
|
+
return U("NODE_ENV", "development");
|
|
846
|
+
},
|
|
847
|
+
get PACKAGE_VERSION() {
|
|
848
|
+
return U("PACKAGE_VERSION", "0.0.0");
|
|
849
|
+
},
|
|
850
|
+
get BETTER_AUTH_TELEMETRY_ENDPOINT() {
|
|
851
|
+
return U("BETTER_AUTH_TELEMETRY_ENDPOINT", "");
|
|
852
|
+
}
|
|
853
|
+
});
|
|
854
|
+
//#endregion
|
|
855
|
+
//#region node_modules/better-call/dist/error.mjs
|
|
856
|
+
function Xt() {
|
|
857
|
+
let e = Object.getOwnPropertyDescriptor(Error, "stackTraceLimit");
|
|
858
|
+
return e === void 0 ? Object.isExtensible(Error) : Object.prototype.hasOwnProperty.call(e, "writable") ? e.writable : e.set !== void 0;
|
|
859
|
+
}
|
|
860
|
+
function Zt(e) {
|
|
861
|
+
let t = e.split("\n at ");
|
|
862
|
+
return t.length <= 1 ? e : (t.splice(1, 1), t.join("\n at "));
|
|
863
|
+
}
|
|
864
|
+
function Qt(e, t) {
|
|
865
|
+
class n extends e {
|
|
866
|
+
#e;
|
|
867
|
+
constructor(...e) {
|
|
868
|
+
if (Xt()) {
|
|
869
|
+
let t = Error.stackTraceLimit;
|
|
870
|
+
Error.stackTraceLimit = 0, super(...e), Error.stackTraceLimit = t;
|
|
871
|
+
} else super(...e);
|
|
872
|
+
let t = (/* @__PURE__ */ Error()).stack;
|
|
873
|
+
t && (this.#e = Zt(t.replace(/^Error/, this.name)));
|
|
874
|
+
}
|
|
875
|
+
get errorStack() {
|
|
876
|
+
return this.#e;
|
|
877
|
+
}
|
|
878
|
+
}
|
|
879
|
+
return Object.defineProperty(n.prototype, "constructor", {
|
|
880
|
+
get() {
|
|
881
|
+
return t;
|
|
882
|
+
},
|
|
883
|
+
enumerable: !1,
|
|
884
|
+
configurable: !0
|
|
885
|
+
}), n;
|
|
886
|
+
}
|
|
887
|
+
var $t = {
|
|
888
|
+
OK: 200,
|
|
889
|
+
CREATED: 201,
|
|
890
|
+
ACCEPTED: 202,
|
|
891
|
+
NO_CONTENT: 204,
|
|
892
|
+
MULTIPLE_CHOICES: 300,
|
|
893
|
+
MOVED_PERMANENTLY: 301,
|
|
894
|
+
FOUND: 302,
|
|
895
|
+
SEE_OTHER: 303,
|
|
896
|
+
NOT_MODIFIED: 304,
|
|
897
|
+
TEMPORARY_REDIRECT: 307,
|
|
898
|
+
BAD_REQUEST: 400,
|
|
899
|
+
UNAUTHORIZED: 401,
|
|
900
|
+
PAYMENT_REQUIRED: 402,
|
|
901
|
+
FORBIDDEN: 403,
|
|
902
|
+
NOT_FOUND: 404,
|
|
903
|
+
METHOD_NOT_ALLOWED: 405,
|
|
904
|
+
NOT_ACCEPTABLE: 406,
|
|
905
|
+
PROXY_AUTHENTICATION_REQUIRED: 407,
|
|
906
|
+
REQUEST_TIMEOUT: 408,
|
|
907
|
+
CONFLICT: 409,
|
|
908
|
+
GONE: 410,
|
|
909
|
+
LENGTH_REQUIRED: 411,
|
|
910
|
+
PRECONDITION_FAILED: 412,
|
|
911
|
+
PAYLOAD_TOO_LARGE: 413,
|
|
912
|
+
URI_TOO_LONG: 414,
|
|
913
|
+
UNSUPPORTED_MEDIA_TYPE: 415,
|
|
914
|
+
RANGE_NOT_SATISFIABLE: 416,
|
|
915
|
+
EXPECTATION_FAILED: 417,
|
|
916
|
+
"I'M_A_TEAPOT": 418,
|
|
917
|
+
MISDIRECTED_REQUEST: 421,
|
|
918
|
+
UNPROCESSABLE_ENTITY: 422,
|
|
919
|
+
LOCKED: 423,
|
|
920
|
+
FAILED_DEPENDENCY: 424,
|
|
921
|
+
TOO_EARLY: 425,
|
|
922
|
+
UPGRADE_REQUIRED: 426,
|
|
923
|
+
PRECONDITION_REQUIRED: 428,
|
|
924
|
+
TOO_MANY_REQUESTS: 429,
|
|
925
|
+
REQUEST_HEADER_FIELDS_TOO_LARGE: 431,
|
|
926
|
+
UNAVAILABLE_FOR_LEGAL_REASONS: 451,
|
|
927
|
+
INTERNAL_SERVER_ERROR: 500,
|
|
928
|
+
NOT_IMPLEMENTED: 501,
|
|
929
|
+
BAD_GATEWAY: 502,
|
|
930
|
+
SERVICE_UNAVAILABLE: 503,
|
|
931
|
+
GATEWAY_TIMEOUT: 504,
|
|
932
|
+
HTTP_VERSION_NOT_SUPPORTED: 505,
|
|
933
|
+
VARIANT_ALSO_NEGOTIATES: 506,
|
|
934
|
+
INSUFFICIENT_STORAGE: 507,
|
|
935
|
+
LOOP_DETECTED: 508,
|
|
936
|
+
NOT_EXTENDED: 510,
|
|
937
|
+
NETWORK_AUTHENTICATION_REQUIRED: 511
|
|
938
|
+
};
|
|
939
|
+
Qt(class extends Error {
|
|
940
|
+
constructor(e = "INTERNAL_SERVER_ERROR", t = void 0, n = {}, r = typeof e == "number" ? e : $t[e]) {
|
|
941
|
+
super(t?.message, t?.cause ? { cause: t.cause } : void 0), this.status = e, this.body = t, this.headers = n, this.statusCode = r, this.name = "APIError", this.status = e, this.headers = n, this.statusCode = r, this.body = t;
|
|
942
|
+
}
|
|
943
|
+
}, Error);
|
|
944
|
+
//#endregion
|
|
945
|
+
//#region node_modules/@better-auth/core/dist/error/index.mjs
|
|
946
|
+
var W = class extends Error {
|
|
947
|
+
constructor(e, t) {
|
|
948
|
+
super(e, t), this.name = "BetterAuthError", this.message = e, this.stack = "";
|
|
949
|
+
}
|
|
950
|
+
}, en = 47;
|
|
951
|
+
function tn(e) {
|
|
952
|
+
let t = e.length;
|
|
953
|
+
for (; t > 0 && e.charCodeAt(t - 1) === en;) t--;
|
|
954
|
+
return t === e.length ? e : e.slice(0, t);
|
|
955
|
+
}
|
|
956
|
+
function nn(e) {
|
|
957
|
+
try {
|
|
958
|
+
return (tn(new URL(e).pathname) || "/") !== "/";
|
|
959
|
+
} catch {
|
|
960
|
+
throw new W(`Invalid base URL: ${e}. Please provide a valid base URL.`);
|
|
961
|
+
}
|
|
962
|
+
}
|
|
963
|
+
function rn(e) {
|
|
964
|
+
try {
|
|
965
|
+
let t = new URL(e);
|
|
966
|
+
if (t.protocol !== "http:" && t.protocol !== "https:") throw new W(`Invalid base URL: ${e}. URL must include 'http://' or 'https://'`);
|
|
967
|
+
} catch (t) {
|
|
968
|
+
throw t instanceof W ? t : new W(`Invalid base URL: ${e}. Please provide a valid base URL.`, { cause: t });
|
|
969
|
+
}
|
|
970
|
+
}
|
|
971
|
+
function G(e, t = "/api/auth") {
|
|
972
|
+
if (rn(e), nn(e)) return e;
|
|
973
|
+
let n = tn(e);
|
|
974
|
+
return !t || t === "/" ? n : (t = t.startsWith("/") ? t : `/${t}`, `${n}${t}`);
|
|
975
|
+
}
|
|
976
|
+
function an(e, t) {
|
|
977
|
+
return !e || e.trim() === "" ? !1 : t === "proto" ? e === "http" || e === "https" : t === "host" ? [
|
|
978
|
+
/\.\./,
|
|
979
|
+
/\0/,
|
|
980
|
+
/[\s]/,
|
|
981
|
+
/^[.]/,
|
|
982
|
+
/[<>'"]/,
|
|
983
|
+
/javascript:/i,
|
|
984
|
+
/file:/i,
|
|
985
|
+
/data:/i
|
|
986
|
+
].some((t) => t.test(e)) ? !1 : /^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*(:[0-9]{1,5})?$/.test(e) || /^(\d{1,3}\.){3}\d{1,3}(:[0-9]{1,5})?$/.test(e) || /^\[[0-9a-fA-F:]+\](:[0-9]{1,5})?$/.test(e) || /^localhost(:[0-9]{1,5})?$/i.test(e) : !1;
|
|
987
|
+
}
|
|
988
|
+
function on(e, t, n, r, i) {
|
|
989
|
+
if (e) return G(e, t);
|
|
990
|
+
if (r !== !1) {
|
|
991
|
+
let e = H.BETTER_AUTH_URL || H.NEXT_PUBLIC_BETTER_AUTH_URL || H.PUBLIC_BETTER_AUTH_URL || H.NUXT_PUBLIC_BETTER_AUTH_URL || H.NUXT_PUBLIC_AUTH_URL || (H.BASE_URL === "/" ? void 0 : H.BASE_URL);
|
|
992
|
+
if (e) return G(e, t);
|
|
993
|
+
}
|
|
994
|
+
let a = n?.headers.get("x-forwarded-host"), o = n?.headers.get("x-forwarded-proto");
|
|
995
|
+
if (a && o && i && an(o, "proto") && an(a, "host")) try {
|
|
996
|
+
return G(`${o}://${a}`, t);
|
|
997
|
+
} catch {}
|
|
998
|
+
if (n) {
|
|
999
|
+
let e = sn(n.url);
|
|
1000
|
+
if (!e) throw new W("Could not get origin from request. Please provide a valid base URL.");
|
|
1001
|
+
return G(e, t);
|
|
1002
|
+
}
|
|
1003
|
+
if (typeof window < "u" && window.location) return G(window.location.origin, t);
|
|
1004
|
+
}
|
|
1005
|
+
function sn(e) {
|
|
1006
|
+
try {
|
|
1007
|
+
let t = new URL(e);
|
|
1008
|
+
return t.origin === "null" ? null : t.origin;
|
|
1009
|
+
} catch {
|
|
1010
|
+
return null;
|
|
1011
|
+
}
|
|
1012
|
+
}
|
|
1013
|
+
//#endregion
|
|
1014
|
+
//#region node_modules/@better-auth/core/dist/utils/url.mjs
|
|
1015
|
+
var cn = [
|
|
1016
|
+
"javascript:",
|
|
1017
|
+
"data:",
|
|
1018
|
+
"vbscript:"
|
|
1019
|
+
];
|
|
1020
|
+
function ln(e) {
|
|
1021
|
+
let t;
|
|
1022
|
+
try {
|
|
1023
|
+
t = new URL(e);
|
|
1024
|
+
} catch {
|
|
1025
|
+
return !0;
|
|
1026
|
+
}
|
|
1027
|
+
return !cn.includes(t.protocol);
|
|
1028
|
+
}
|
|
1029
|
+
//#endregion
|
|
1030
|
+
//#region node_modules/better-auth/dist/client/fetch-plugins.mjs
|
|
1031
|
+
var un = {
|
|
1032
|
+
id: "redirect",
|
|
1033
|
+
name: "Redirect",
|
|
1034
|
+
hooks: { onSuccess(e) {
|
|
1035
|
+
if (e.data?.url && e.data?.redirect && ln(e.data.url) && typeof window < "u" && window.location && window.location) try {
|
|
1036
|
+
window.location.href = e.data.url;
|
|
1037
|
+
} catch {}
|
|
1038
|
+
} }
|
|
1039
|
+
};
|
|
1040
|
+
//#endregion
|
|
1041
|
+
//#region node_modules/better-auth/dist/client/session-atom.mjs
|
|
1042
|
+
function dn(e, t) {
|
|
1043
|
+
let n = /* @__PURE__ */ Bt(!1), r = Kt(n, "/get-session", e, { method: "GET" }), i = () => {};
|
|
1044
|
+
return Wt(r, () => {
|
|
1045
|
+
let a = Yt({
|
|
1046
|
+
sessionAtom: r,
|
|
1047
|
+
sessionSignal: n,
|
|
1048
|
+
$fetch: e,
|
|
1049
|
+
options: t
|
|
1050
|
+
});
|
|
1051
|
+
return a.init(), i = a.broadcastSessionUpdate, () => {
|
|
1052
|
+
a.cleanup();
|
|
1053
|
+
};
|
|
1054
|
+
}), {
|
|
1055
|
+
session: r,
|
|
1056
|
+
$sessionSignal: n,
|
|
1057
|
+
broadcastSessionUpdate: (e) => i(e)
|
|
1058
|
+
};
|
|
1059
|
+
}
|
|
1060
|
+
//#endregion
|
|
1061
|
+
//#region node_modules/defu/dist/defu.mjs
|
|
1062
|
+
function fn(e) {
|
|
1063
|
+
if (typeof e != "object" || !e) return !1;
|
|
1064
|
+
let t = Object.getPrototypeOf(e);
|
|
1065
|
+
return t !== null && t !== Object.prototype && Object.getPrototypeOf(t) !== null || Symbol.iterator in e ? !1 : Symbol.toStringTag in e ? Object.prototype.toString.call(e) === "[object Module]" : !0;
|
|
1066
|
+
}
|
|
1067
|
+
function pn(e, t, n = ".", r) {
|
|
1068
|
+
if (!fn(t)) return pn(e, {}, n, r);
|
|
1069
|
+
let i = { ...t };
|
|
1070
|
+
for (let t of Object.keys(e)) {
|
|
1071
|
+
if (t === "__proto__" || t === "constructor") continue;
|
|
1072
|
+
let a = e[t];
|
|
1073
|
+
a != null && (r && r(i, t, a, n) || (Array.isArray(a) && Array.isArray(i[t]) ? i[t] = [...a, ...i[t]] : fn(a) && fn(i[t]) ? i[t] = pn(a, i[t], (n ? `${n}.` : "") + t.toString(), r) : i[t] = a));
|
|
1074
|
+
}
|
|
1075
|
+
return i;
|
|
1076
|
+
}
|
|
1077
|
+
function mn(e) {
|
|
1078
|
+
return (...t) => t.reduce((t, n) => pn(t, n, "", e), {});
|
|
1079
|
+
}
|
|
1080
|
+
var hn = mn(), gn = Object.defineProperty, _n = Object.defineProperties, vn = Object.getOwnPropertyDescriptors, yn = Object.getOwnPropertySymbols, bn = Object.prototype.hasOwnProperty, xn = Object.prototype.propertyIsEnumerable, Sn = (e, t, n) => t in e ? gn(e, t, {
|
|
1081
|
+
enumerable: !0,
|
|
1082
|
+
configurable: !0,
|
|
1083
|
+
writable: !0,
|
|
1084
|
+
value: n
|
|
1085
|
+
}) : e[t] = n, K = (e, t) => {
|
|
1086
|
+
for (var n in t ||= {}) bn.call(t, n) && Sn(e, n, t[n]);
|
|
1087
|
+
if (yn) for (var n of yn(t)) xn.call(t, n) && Sn(e, n, t[n]);
|
|
1088
|
+
return e;
|
|
1089
|
+
}, q = (e, t) => _n(e, vn(t)), Cn = class extends Error {
|
|
1090
|
+
constructor(e, t, n) {
|
|
1091
|
+
super(t || e.toString(), { cause: n }), this.status = e, this.statusText = t, this.error = n, Error.captureStackTrace(this, this.constructor);
|
|
1092
|
+
}
|
|
1093
|
+
}, wn = async (e, t) => {
|
|
1094
|
+
let n = t || {}, r = {
|
|
1095
|
+
onRequest: [t?.onRequest],
|
|
1096
|
+
onResponse: [t?.onResponse],
|
|
1097
|
+
onSuccess: [t?.onSuccess],
|
|
1098
|
+
onError: [t?.onError],
|
|
1099
|
+
onRetry: [t?.onRetry]
|
|
1100
|
+
};
|
|
1101
|
+
if (!t || !t?.plugins) return {
|
|
1102
|
+
url: e,
|
|
1103
|
+
options: n,
|
|
1104
|
+
hooks: r
|
|
1105
|
+
};
|
|
1106
|
+
for (let i of t?.plugins || []) {
|
|
1107
|
+
if (i.init) {
|
|
1108
|
+
let r = await i.init?.call(i, e.toString(), t);
|
|
1109
|
+
n = r.options || n, e = r.url;
|
|
1110
|
+
}
|
|
1111
|
+
r.onRequest.push(i.hooks?.onRequest), r.onResponse.push(i.hooks?.onResponse), r.onSuccess.push(i.hooks?.onSuccess), r.onError.push(i.hooks?.onError), r.onRetry.push(i.hooks?.onRetry);
|
|
1112
|
+
}
|
|
1113
|
+
return {
|
|
1114
|
+
url: e,
|
|
1115
|
+
options: n,
|
|
1116
|
+
hooks: r
|
|
1117
|
+
};
|
|
1118
|
+
}, Tn = class {
|
|
1119
|
+
constructor(e) {
|
|
1120
|
+
this.options = e;
|
|
1121
|
+
}
|
|
1122
|
+
shouldAttemptRetry(e, t) {
|
|
1123
|
+
return this.options.shouldRetry ? Promise.resolve(e < this.options.attempts && this.options.shouldRetry(t)) : Promise.resolve(e < this.options.attempts);
|
|
1124
|
+
}
|
|
1125
|
+
getDelay() {
|
|
1126
|
+
return this.options.delay;
|
|
1127
|
+
}
|
|
1128
|
+
}, En = class {
|
|
1129
|
+
constructor(e) {
|
|
1130
|
+
this.options = e;
|
|
1131
|
+
}
|
|
1132
|
+
shouldAttemptRetry(e, t) {
|
|
1133
|
+
return this.options.shouldRetry ? Promise.resolve(e < this.options.attempts && this.options.shouldRetry(t)) : Promise.resolve(e < this.options.attempts);
|
|
1134
|
+
}
|
|
1135
|
+
getDelay(e) {
|
|
1136
|
+
return Math.min(this.options.maxDelay, this.options.baseDelay * 2 ** e);
|
|
1137
|
+
}
|
|
1138
|
+
};
|
|
1139
|
+
function Dn(e) {
|
|
1140
|
+
if (typeof e == "number") return new Tn({
|
|
1141
|
+
type: "linear",
|
|
1142
|
+
attempts: e,
|
|
1143
|
+
delay: 1e3
|
|
1144
|
+
});
|
|
1145
|
+
switch (e.type) {
|
|
1146
|
+
case "linear": return new Tn(e);
|
|
1147
|
+
case "exponential": return new En(e);
|
|
1148
|
+
default: throw Error("Invalid retry strategy");
|
|
1149
|
+
}
|
|
1150
|
+
}
|
|
1151
|
+
var On = async (e) => {
|
|
1152
|
+
let t = {}, n = async (e) => typeof e == "function" ? await e() : e;
|
|
1153
|
+
if (e?.auth) {
|
|
1154
|
+
if (e.auth.type === "Bearer") {
|
|
1155
|
+
let r = await n(e.auth.token);
|
|
1156
|
+
if (!r) return t;
|
|
1157
|
+
t.authorization = `Bearer ${r}`;
|
|
1158
|
+
} else if (e.auth.type === "Basic") {
|
|
1159
|
+
let [r, i] = await Promise.all([n(e.auth.username), n(e.auth.password)]);
|
|
1160
|
+
if (!r || !i) return t;
|
|
1161
|
+
t.authorization = `Basic ${btoa(`${r}:${i}`)}`;
|
|
1162
|
+
} else if (e.auth.type === "Custom") {
|
|
1163
|
+
let [r, i] = await Promise.all([n(e.auth.prefix), n(e.auth.value)]);
|
|
1164
|
+
if (!i) return t;
|
|
1165
|
+
t.authorization = `${r ?? ""} ${i}`;
|
|
1166
|
+
}
|
|
1167
|
+
}
|
|
1168
|
+
return t;
|
|
1169
|
+
}, kn = /^application\/(?:[\w!#$%&*.^`~-]*\+)?json(;.+)?$/i;
|
|
1170
|
+
function An(e) {
|
|
1171
|
+
let t = e.headers.get("content-type"), n = /* @__PURE__ */ new Set([
|
|
1172
|
+
"image/svg",
|
|
1173
|
+
"application/xml",
|
|
1174
|
+
"application/xhtml",
|
|
1175
|
+
"application/html"
|
|
1176
|
+
]);
|
|
1177
|
+
if (!t) return "json";
|
|
1178
|
+
let r = t.split(";").shift() || "";
|
|
1179
|
+
return kn.test(r) ? "json" : n.has(r) || r.startsWith("text/") ? "text" : "blob";
|
|
1180
|
+
}
|
|
1181
|
+
function jn(e) {
|
|
1182
|
+
try {
|
|
1183
|
+
return JSON.parse(e), !0;
|
|
1184
|
+
} catch {
|
|
1185
|
+
return !1;
|
|
1186
|
+
}
|
|
1187
|
+
}
|
|
1188
|
+
function Mn(e) {
|
|
1189
|
+
if (e === void 0) return !1;
|
|
1190
|
+
let t = typeof e;
|
|
1191
|
+
return t === "string" || t === "number" || t === "boolean" || t === null ? !0 : t === "object" ? Array.isArray(e) ? !0 : e.buffer ? !1 : e.constructor && e.constructor.name === "Object" || typeof e.toJSON == "function" : !1;
|
|
1192
|
+
}
|
|
1193
|
+
function Nn(e) {
|
|
1194
|
+
try {
|
|
1195
|
+
return JSON.parse(e);
|
|
1196
|
+
} catch {
|
|
1197
|
+
return e;
|
|
1198
|
+
}
|
|
1199
|
+
}
|
|
1200
|
+
function Pn(e) {
|
|
1201
|
+
return typeof e == "function";
|
|
1202
|
+
}
|
|
1203
|
+
function Fn(e) {
|
|
1204
|
+
if (e?.customFetchImpl) return e.customFetchImpl;
|
|
1205
|
+
if (typeof globalThis < "u" && Pn(globalThis.fetch)) return globalThis.fetch;
|
|
1206
|
+
if (typeof window < "u" && Pn(window.fetch)) return window.fetch;
|
|
1207
|
+
throw Error("No fetch implementation found");
|
|
1208
|
+
}
|
|
1209
|
+
async function In(e) {
|
|
1210
|
+
let t = new Headers(e?.headers), n = await On(e);
|
|
1211
|
+
for (let [e, r] of Object.entries(n || {})) t.set(e, r);
|
|
1212
|
+
if (!t.has("content-type")) {
|
|
1213
|
+
let n = Ln(e?.body);
|
|
1214
|
+
n && t.set("content-type", n);
|
|
1215
|
+
}
|
|
1216
|
+
return t;
|
|
1217
|
+
}
|
|
1218
|
+
function Ln(e) {
|
|
1219
|
+
return Mn(e) ? "application/json" : null;
|
|
1220
|
+
}
|
|
1221
|
+
function Rn(e) {
|
|
1222
|
+
if (!e?.body) return null;
|
|
1223
|
+
let t = new Headers(e?.headers);
|
|
1224
|
+
if (Mn(e.body) && !t.has("content-type")) {
|
|
1225
|
+
for (let [t, n] of Object.entries(e?.body)) n instanceof Date && (e.body[t] = n.toISOString());
|
|
1226
|
+
return JSON.stringify(e.body);
|
|
1227
|
+
}
|
|
1228
|
+
return t.has("content-type") && t.get("content-type") === "application/x-www-form-urlencoded" && Mn(e.body) ? new URLSearchParams(e.body).toString() : e.body;
|
|
1229
|
+
}
|
|
1230
|
+
function zn(e, t) {
|
|
1231
|
+
if (t?.method) return t.method.toUpperCase();
|
|
1232
|
+
if (e.startsWith("@")) {
|
|
1233
|
+
let n = e.split("@")[1]?.split("/")[0];
|
|
1234
|
+
return Hn.includes(n) ? n.toUpperCase() : t?.body ? "POST" : "GET";
|
|
1235
|
+
}
|
|
1236
|
+
return t?.body ? "POST" : "GET";
|
|
1237
|
+
}
|
|
1238
|
+
function Bn(e, t) {
|
|
1239
|
+
let n;
|
|
1240
|
+
return !e?.signal && e?.timeout && (n = setTimeout(() => t?.abort(), e?.timeout)), {
|
|
1241
|
+
abortTimeout: n,
|
|
1242
|
+
clearTimeout: () => {
|
|
1243
|
+
n && clearTimeout(n);
|
|
1244
|
+
}
|
|
1245
|
+
};
|
|
1246
|
+
}
|
|
1247
|
+
var Vn = class e extends Error {
|
|
1248
|
+
constructor(t, n) {
|
|
1249
|
+
super(n || JSON.stringify(t, null, 2)), this.issues = t, Object.setPrototypeOf(this, e.prototype);
|
|
1250
|
+
}
|
|
1251
|
+
};
|
|
1252
|
+
async function J(e, t) {
|
|
1253
|
+
let n = await e["~standard"].validate(t);
|
|
1254
|
+
if (n.issues) throw new Vn(n.issues);
|
|
1255
|
+
return n.value;
|
|
1256
|
+
}
|
|
1257
|
+
var Hn = [
|
|
1258
|
+
"get",
|
|
1259
|
+
"post",
|
|
1260
|
+
"put",
|
|
1261
|
+
"patch",
|
|
1262
|
+
"delete"
|
|
1263
|
+
], Un = (e) => ({
|
|
1264
|
+
id: "apply-schema",
|
|
1265
|
+
name: "Apply Schema",
|
|
1266
|
+
version: "1.0.0",
|
|
1267
|
+
async init(t, n) {
|
|
1268
|
+
let r = e.plugins?.find((e) => e.schema?.config ? t.startsWith(e.schema.config.baseURL || "") || t.startsWith(e.schema.config.prefix || "") : !1)?.schema || e.schema;
|
|
1269
|
+
if (r) {
|
|
1270
|
+
let e = t;
|
|
1271
|
+
r.config?.prefix && e.startsWith(r.config.prefix) && (e = e.replace(r.config.prefix, ""), r.config.baseURL && (t = t.replace(r.config.prefix, r.config.baseURL))), r.config?.baseURL && e.startsWith(r.config.baseURL) && (e = e.replace(r.config.baseURL, ""));
|
|
1272
|
+
let i = r.schema[e];
|
|
1273
|
+
if (i) {
|
|
1274
|
+
let e = q(K({}, n), {
|
|
1275
|
+
method: i.method,
|
|
1276
|
+
output: i.output
|
|
1277
|
+
});
|
|
1278
|
+
return n?.disableValidation || (e = q(K({}, e), {
|
|
1279
|
+
body: i.input ? await J(i.input, n?.body) : n?.body,
|
|
1280
|
+
params: i.params ? await J(i.params, n?.params) : n?.params,
|
|
1281
|
+
query: i.query ? await J(i.query, n?.query) : n?.query
|
|
1282
|
+
})), {
|
|
1283
|
+
url: t,
|
|
1284
|
+
options: e
|
|
1285
|
+
};
|
|
1286
|
+
}
|
|
1287
|
+
}
|
|
1288
|
+
return {
|
|
1289
|
+
url: t,
|
|
1290
|
+
options: n
|
|
1291
|
+
};
|
|
1292
|
+
}
|
|
1293
|
+
}), Wn = (e) => {
|
|
1294
|
+
async function t(t, n) {
|
|
1295
|
+
let r = q(K(K({}, e), n), { plugins: [
|
|
1296
|
+
...e?.plugins || [],
|
|
1297
|
+
Un(e || {}),
|
|
1298
|
+
...n?.plugins || []
|
|
1299
|
+
] });
|
|
1300
|
+
if (e?.catchAllError) try {
|
|
1301
|
+
return await Kn(t, r);
|
|
1302
|
+
} catch (e) {
|
|
1303
|
+
return {
|
|
1304
|
+
data: null,
|
|
1305
|
+
error: {
|
|
1306
|
+
status: 500,
|
|
1307
|
+
statusText: "Fetch Error",
|
|
1308
|
+
message: "Fetch related error. Captured by catchAllError option. See error property for more details.",
|
|
1309
|
+
error: e
|
|
1310
|
+
}
|
|
1311
|
+
};
|
|
1312
|
+
}
|
|
1313
|
+
return await Kn(t, r);
|
|
1314
|
+
}
|
|
1315
|
+
return t;
|
|
1316
|
+
};
|
|
1317
|
+
function Gn(e, t) {
|
|
1318
|
+
let { baseURL: n, params: r, query: i } = t || {
|
|
1319
|
+
query: {},
|
|
1320
|
+
params: {},
|
|
1321
|
+
baseURL: ""
|
|
1322
|
+
}, a = e.startsWith("http") ? e.split("/").slice(0, 3).join("/") : n || "";
|
|
1323
|
+
if (e.startsWith("@")) {
|
|
1324
|
+
let t = e.toString().split("@")[1].split("/")[0];
|
|
1325
|
+
Hn.includes(t) && (e = e.replace(`@${t}/`, "/"));
|
|
1326
|
+
}
|
|
1327
|
+
a.endsWith("/") || (a += "/");
|
|
1328
|
+
let [o, s] = e.replace(a, "").split("?"), c = new URLSearchParams(s);
|
|
1329
|
+
for (let [e, t] of Object.entries(i || {})) {
|
|
1330
|
+
if (t == null) continue;
|
|
1331
|
+
let n;
|
|
1332
|
+
if (typeof t == "string") n = t;
|
|
1333
|
+
else if (Array.isArray(t)) {
|
|
1334
|
+
for (let n of t) c.append(e, n);
|
|
1335
|
+
continue;
|
|
1336
|
+
} else n = JSON.stringify(t);
|
|
1337
|
+
c.set(e, n);
|
|
1338
|
+
}
|
|
1339
|
+
if (r) if (Array.isArray(r)) {
|
|
1340
|
+
let e = o.split("/").filter((e) => e.startsWith(":"));
|
|
1341
|
+
for (let [t, n] of e.entries()) {
|
|
1342
|
+
let e = r[t];
|
|
1343
|
+
o = o.replace(n, e);
|
|
1344
|
+
}
|
|
1345
|
+
} else for (let [e, t] of Object.entries(r)) o = o.replace(`:${e}`, String(t));
|
|
1346
|
+
o = o.split("/").map(encodeURIComponent).join("/"), o.startsWith("/") && (o = o.slice(1));
|
|
1347
|
+
let l = c.toString();
|
|
1348
|
+
return l = l.length > 0 ? `?${l}`.replace(/\+/g, "%20") : "", a.startsWith("http") ? new URL(`${o}${l}`, a) : `${a}${o}${l}`;
|
|
1349
|
+
}
|
|
1350
|
+
var Kn = async (e, t) => {
|
|
1351
|
+
let { hooks: n, url: r, options: i } = await wn(e, t), a = Fn(i), o = new AbortController(), s = i.signal ?? o.signal, c = Gn(r, i), l = Rn(i), u = await In(i), d = zn(r, i), f = q(K({}, i), {
|
|
1352
|
+
url: c,
|
|
1353
|
+
headers: u,
|
|
1354
|
+
body: l,
|
|
1355
|
+
method: d,
|
|
1356
|
+
signal: s
|
|
1357
|
+
});
|
|
1358
|
+
for (let e of n.onRequest) if (e) {
|
|
1359
|
+
let t = await e(f);
|
|
1360
|
+
typeof t == "object" && t && (f = t);
|
|
1361
|
+
}
|
|
1362
|
+
("pipeTo" in f && typeof f.pipeTo == "function" || typeof t?.body?.pipe == "function") && ("duplex" in f || (f.duplex = "half"));
|
|
1363
|
+
let { clearTimeout: p } = Bn(i, o), m = await a(f.url, f);
|
|
1364
|
+
p();
|
|
1365
|
+
let h = {
|
|
1366
|
+
response: m,
|
|
1367
|
+
request: f
|
|
1368
|
+
};
|
|
1369
|
+
for (let e of n.onResponse) if (e) {
|
|
1370
|
+
let n = await e(q(K({}, h), { response: t?.hookOptions?.cloneResponse ? m.clone() : m }));
|
|
1371
|
+
n instanceof Response ? m = n : typeof n == "object" && n && (m = n.response);
|
|
1372
|
+
}
|
|
1373
|
+
if (m.ok) {
|
|
1374
|
+
if (f.method === "HEAD") return {
|
|
1375
|
+
data: "",
|
|
1376
|
+
error: null
|
|
1377
|
+
};
|
|
1378
|
+
let e = An(m), r = {
|
|
1379
|
+
data: null,
|
|
1380
|
+
response: m,
|
|
1381
|
+
request: f
|
|
1382
|
+
};
|
|
1383
|
+
if (e === "json" || e === "text") {
|
|
1384
|
+
let e = await m.text();
|
|
1385
|
+
r.data = await (f.jsonParser ?? Nn)(e);
|
|
1386
|
+
} else r.data = await m[e]();
|
|
1387
|
+
f?.output && f.output && !f.disableValidation && (r.data = await J(f.output, r.data));
|
|
1388
|
+
for (let e of n.onSuccess) e && await e(q(K({}, r), { response: t?.hookOptions?.cloneResponse ? m.clone() : m }));
|
|
1389
|
+
return t?.throw ? r.data : {
|
|
1390
|
+
data: r.data,
|
|
1391
|
+
error: null
|
|
1392
|
+
};
|
|
1393
|
+
}
|
|
1394
|
+
let g = t?.jsonParser ?? Nn, _ = await m.text(), v = jn(_), y = v ? await g(_) : null, b = {
|
|
1395
|
+
response: m,
|
|
1396
|
+
responseText: _,
|
|
1397
|
+
request: f,
|
|
1398
|
+
error: q(K({}, y), {
|
|
1399
|
+
status: m.status,
|
|
1400
|
+
statusText: m.statusText
|
|
1401
|
+
})
|
|
1402
|
+
};
|
|
1403
|
+
for (let e of n.onError) e && await e(q(K({}, b), { response: t?.hookOptions?.cloneResponse ? m.clone() : m }));
|
|
1404
|
+
if (t?.retry) {
|
|
1405
|
+
let r = Dn(t.retry), i = t.retryAttempt ?? 0;
|
|
1406
|
+
if (await r.shouldAttemptRetry(i, m)) {
|
|
1407
|
+
for (let e of n.onRetry) e && await e(h);
|
|
1408
|
+
let a = r.getDelay(i);
|
|
1409
|
+
return await new Promise((e) => setTimeout(e, a)), await Kn(e, q(K({}, t), { retryAttempt: i + 1 }));
|
|
1410
|
+
}
|
|
1411
|
+
}
|
|
1412
|
+
if (t?.throw) throw new Cn(m.status, m.statusText, v ? y : _);
|
|
1413
|
+
return {
|
|
1414
|
+
data: null,
|
|
1415
|
+
error: q(K({}, y), {
|
|
1416
|
+
status: m.status,
|
|
1417
|
+
statusText: m.statusText
|
|
1418
|
+
})
|
|
1419
|
+
};
|
|
1420
|
+
}, qn = (e) => {
|
|
1421
|
+
if (typeof process > "u") return;
|
|
1422
|
+
let t = e ?? "/api/auth";
|
|
1423
|
+
if (process.env.NEXT_PUBLIC_AUTH_URL) return process.env.NEXT_PUBLIC_AUTH_URL;
|
|
1424
|
+
if (typeof window > "u") {
|
|
1425
|
+
if (process.env.NEXTAUTH_URL) try {
|
|
1426
|
+
return process.env.NEXTAUTH_URL;
|
|
1427
|
+
} catch {}
|
|
1428
|
+
if (process.env.VERCEL_URL) try {
|
|
1429
|
+
let e = process.env.VERCEL_URL.startsWith("http") ? "" : "https://";
|
|
1430
|
+
return `${new URL(`${e}${process.env.VERCEL_URL}`).origin}${t}`;
|
|
1431
|
+
} catch {}
|
|
1432
|
+
}
|
|
1433
|
+
}, Jn = (e, t) => {
|
|
1434
|
+
let n = "credentials" in Request.prototype, r = on(e?.baseURL, e?.basePath, void 0, t) ?? qn(e?.basePath) ?? "/api/auth", i = e?.plugins?.flatMap((e) => e.fetchPlugins).filter((e) => e !== void 0) || [], a = {
|
|
1435
|
+
id: "lifecycle-hooks",
|
|
1436
|
+
name: "lifecycle-hooks",
|
|
1437
|
+
hooks: {
|
|
1438
|
+
onSuccess: e?.fetchOptions?.onSuccess,
|
|
1439
|
+
onError: e?.fetchOptions?.onError,
|
|
1440
|
+
onRequest: e?.fetchOptions?.onRequest,
|
|
1441
|
+
onResponse: e?.fetchOptions?.onResponse
|
|
1442
|
+
}
|
|
1443
|
+
}, { onSuccess: o, onError: s, onRequest: c, onResponse: l, ...u } = e?.fetchOptions || {}, d = Wn({
|
|
1444
|
+
baseURL: r,
|
|
1445
|
+
...n ? { credentials: "include" } : {},
|
|
1446
|
+
method: "GET",
|
|
1447
|
+
jsonParser(e) {
|
|
1448
|
+
return e ? Rt(e, { strict: !1 }) : null;
|
|
1449
|
+
},
|
|
1450
|
+
customFetchImpl: fetch,
|
|
1451
|
+
...u,
|
|
1452
|
+
plugins: [
|
|
1453
|
+
a,
|
|
1454
|
+
...u.plugins || [],
|
|
1455
|
+
...e?.disableDefaultFetchPlugins ? [] : [un],
|
|
1456
|
+
...i
|
|
1457
|
+
]
|
|
1458
|
+
}), { $sessionSignal: f, session: p, broadcastSessionUpdate: m } = dn(d, e), h = e?.plugins || [], g = {}, _ = {
|
|
1459
|
+
$sessionSignal: f,
|
|
1460
|
+
session: p
|
|
1461
|
+
}, v = {
|
|
1462
|
+
"/sign-out": "POST",
|
|
1463
|
+
"/revoke-sessions": "POST",
|
|
1464
|
+
"/revoke-other-sessions": "POST",
|
|
1465
|
+
"/delete-user": "POST"
|
|
1466
|
+
}, y = [{
|
|
1467
|
+
signal: "$sessionSignal",
|
|
1468
|
+
matcher(e) {
|
|
1469
|
+
return e === "/sign-out" || e === "/update-user" || e === "/update-session" || e === "/sign-up/email" || e === "/sign-in/email" || e === "/delete-user" || e === "/verify-email" || e === "/revoke-sessions" || e === "/revoke-session" || e === "/revoke-other-sessions" || e === "/change-email" || e === "/change-password";
|
|
1470
|
+
},
|
|
1471
|
+
callback(e) {
|
|
1472
|
+
e === "/sign-out" ? m("signout") : (e === "/update-user" || e === "/update-session") && m("updateUser");
|
|
1473
|
+
}
|
|
1474
|
+
}];
|
|
1475
|
+
for (let e of h) e.getAtoms && Object.assign(_, e.getAtoms?.(d)), e.pathMethods && Object.assign(v, e.pathMethods), e.atomListeners && y.push(...e.atomListeners);
|
|
1476
|
+
let b = {
|
|
1477
|
+
notify: (e) => {
|
|
1478
|
+
_[e].set(!_[e].get());
|
|
1479
|
+
},
|
|
1480
|
+
listen: (e, t) => {
|
|
1481
|
+
_[e].subscribe(t);
|
|
1482
|
+
},
|
|
1483
|
+
atoms: _
|
|
1484
|
+
};
|
|
1485
|
+
for (let t of h) t.getActions && (g = hn(t.getActions?.(d, b, e) ?? {}, g));
|
|
1486
|
+
return {
|
|
1487
|
+
get baseURL() {
|
|
1488
|
+
return r;
|
|
1489
|
+
},
|
|
1490
|
+
pluginsActions: g,
|
|
1491
|
+
pluginsAtoms: _,
|
|
1492
|
+
pluginPathMethods: v,
|
|
1493
|
+
atomListeners: y,
|
|
1494
|
+
$fetch: d,
|
|
1495
|
+
$store: b
|
|
1496
|
+
};
|
|
1497
|
+
};
|
|
1498
|
+
//#endregion
|
|
1499
|
+
//#region node_modules/better-auth/dist/utils/is-atom.mjs
|
|
1500
|
+
function Yn(e) {
|
|
1501
|
+
return typeof e == "object" && !!e && "get" in e && typeof e.get == "function" && "lc" in e && typeof e.lc == "number";
|
|
1502
|
+
}
|
|
1503
|
+
//#endregion
|
|
1504
|
+
//#region node_modules/@better-auth/core/dist/utils/string.mjs
|
|
1505
|
+
function Xn(e) {
|
|
1506
|
+
return e.charAt(0).toUpperCase() + e.slice(1);
|
|
1507
|
+
}
|
|
1508
|
+
var Zn = /[\p{Ll}\d]+|\p{Lu}+(?!\p{Ll})|\p{Lu}[\p{Ll}\d]+|\p{Lo}+/gu, Qn = /['\u2019]/g;
|
|
1509
|
+
function $n(e) {
|
|
1510
|
+
return e.replace(Qn, "").match(Zn) ?? [];
|
|
1511
|
+
}
|
|
1512
|
+
function er(e) {
|
|
1513
|
+
return $n(e).map((e) => e.toLowerCase()).join("-");
|
|
1514
|
+
}
|
|
1515
|
+
//#endregion
|
|
1516
|
+
//#region node_modules/better-auth/dist/client/proxy.mjs
|
|
1517
|
+
function tr(e, t, n) {
|
|
1518
|
+
let r = t[e], { fetchOptions: i, query: a, ...o } = n || {};
|
|
1519
|
+
return r || (i?.method ? i.method : o && Object.keys(o).length > 0 ? "POST" : "GET");
|
|
1520
|
+
}
|
|
1521
|
+
function nr(e, t, n, r, i) {
|
|
1522
|
+
function a(o = []) {
|
|
1523
|
+
return new Proxy(function() {}, {
|
|
1524
|
+
get(t, n) {
|
|
1525
|
+
if (typeof n != "string" || n === "then" || n === "catch" || n === "finally") return;
|
|
1526
|
+
let r = [...o, n], i = e;
|
|
1527
|
+
for (let e of r) if (i && typeof i == "object" && e in i) i = i[e];
|
|
1528
|
+
else {
|
|
1529
|
+
i = void 0;
|
|
1530
|
+
break;
|
|
1531
|
+
}
|
|
1532
|
+
return typeof i == "function" || Yn(i) ? i : a(r);
|
|
1533
|
+
},
|
|
1534
|
+
apply: async (e, a, s) => {
|
|
1535
|
+
let c = "/" + o.map(er).join("/"), l = s[0] || {}, u = s[1] || {}, { query: d, fetchOptions: f, ...p } = l, m = {
|
|
1536
|
+
...u,
|
|
1537
|
+
...f
|
|
1538
|
+
}, h = tr(c, n, l);
|
|
1539
|
+
return await t(c, {
|
|
1540
|
+
...m,
|
|
1541
|
+
body: h === "GET" ? void 0 : {
|
|
1542
|
+
...p,
|
|
1543
|
+
...m?.body || {}
|
|
1544
|
+
},
|
|
1545
|
+
query: d || m?.query,
|
|
1546
|
+
method: h,
|
|
1547
|
+
async onSuccess(e) {
|
|
1548
|
+
if (await m?.onSuccess?.(e), !i || m.disableSignal) return;
|
|
1549
|
+
let t = i.filter((e) => e.matcher(c));
|
|
1550
|
+
if (!t.length) return;
|
|
1551
|
+
let n = /* @__PURE__ */ new Set();
|
|
1552
|
+
for (let e of t) {
|
|
1553
|
+
let t = r[e.signal];
|
|
1554
|
+
if (!t) return;
|
|
1555
|
+
if (n.has(e.signal)) continue;
|
|
1556
|
+
n.add(e.signal);
|
|
1557
|
+
let i = t.get();
|
|
1558
|
+
setTimeout(() => {
|
|
1559
|
+
t.set(!i);
|
|
1560
|
+
}, 10), e.callback?.(c);
|
|
1561
|
+
}
|
|
1562
|
+
}
|
|
1563
|
+
});
|
|
1564
|
+
}
|
|
1565
|
+
});
|
|
1566
|
+
}
|
|
1567
|
+
return a();
|
|
1568
|
+
}
|
|
1569
|
+
//#endregion
|
|
1570
|
+
//#region node_modules/better-auth/dist/client/vanilla.mjs
|
|
1571
|
+
function rr(e) {
|
|
1572
|
+
let { pluginPathMethods: t, pluginsActions: n, pluginsAtoms: r, $fetch: i, atomListeners: a, $store: o } = Jn(e), s = {};
|
|
1573
|
+
for (let [e, t] of Object.entries(r)) s[`use${Xn(e)}`] = t;
|
|
1574
|
+
return nr({
|
|
1575
|
+
...n,
|
|
1576
|
+
...s,
|
|
1577
|
+
$fetch: i,
|
|
1578
|
+
$store: o
|
|
1579
|
+
}, i, t, r, a);
|
|
1580
|
+
}
|
|
1581
|
+
//#endregion
|
|
1582
|
+
//#region src/lib/auth-client.ts
|
|
1583
|
+
var ir = "https://api.fkn.app", ar = ir, { signIn: or, signUp: sr, signOut: cr } = rr({ baseURL: ir }), lr = (e) => {
|
|
1584
|
+
let t = "";
|
|
1585
|
+
for (let n of e) t += String.fromCharCode(n);
|
|
1586
|
+
return btoa(t).replace(/\+/g, "-").replace(/\//g, "_").replace(/=+$/, "");
|
|
1587
|
+
}, ur = (e) => {
|
|
1588
|
+
let t = e.replace(/-/g, "+").replace(/_/g, "/"), n = atob(t), r = new Uint8Array(n.length);
|
|
1589
|
+
for (let e = 0; e < n.length; e++) r[e] = n.charCodeAt(e);
|
|
1590
|
+
return r;
|
|
1591
|
+
}, dr = "fkn-e2e", fr = "keys", pr = "dek", mr = () => new Promise((e, t) => {
|
|
1592
|
+
let n = indexedDB.open(dr, 1);
|
|
1593
|
+
n.onupgradeneeded = () => {
|
|
1594
|
+
n.result.createObjectStore(fr);
|
|
1595
|
+
}, n.onsuccess = () => e(n.result), n.onerror = () => t(n.error);
|
|
1596
|
+
}), hr = async (e, t) => {
|
|
1597
|
+
let n = await mr();
|
|
1598
|
+
return new Promise((r, i) => {
|
|
1599
|
+
let a = n.transaction(fr, e), o = t(a.objectStore(fr));
|
|
1600
|
+
o.onsuccess = () => r(o.result), o.onerror = () => i(o.error), a.oncomplete = () => n.close();
|
|
1601
|
+
});
|
|
1602
|
+
}, gr = () => hr("readonly", (e) => e.get(pr)), _r = async (e, t) => {
|
|
1603
|
+
let n = await gr();
|
|
1604
|
+
if (!n) throw Error("no_dek");
|
|
1605
|
+
let r = crypto.getRandomValues(new Uint8Array(12)), i = {
|
|
1606
|
+
name: "AES-GCM",
|
|
1607
|
+
iv: r
|
|
1608
|
+
};
|
|
1609
|
+
t && (i.additionalData = t);
|
|
1610
|
+
let a = new Uint8Array(await crypto.subtle.encrypt(i, n, e)), o = new Uint8Array(r.length + a.length);
|
|
1611
|
+
return o.set(r), o.set(a, r.length), o;
|
|
1612
|
+
}, vr = async (e, t) => {
|
|
1613
|
+
let n = await gr();
|
|
1614
|
+
if (!n) throw Error("no_dek");
|
|
1615
|
+
let r = e.slice(0, 12), i = e.slice(12), a = {
|
|
1616
|
+
name: "AES-GCM",
|
|
1617
|
+
iv: r
|
|
1618
|
+
};
|
|
1619
|
+
return t && (a.additionalData = t), new Uint8Array(await crypto.subtle.decrypt(a, n, i));
|
|
1620
|
+
}, yr = `${ar}/api/v1/storage`, br = new TextEncoder(), xr = (e, t) => br.encode(`${e}\0${t}`), Y = async () => {
|
|
1621
|
+
if (!await gr()) throw Error("no_dek");
|
|
1622
|
+
}, X = (e, t) => fetch(`${yr}${e}`, {
|
|
1623
|
+
credentials: "include",
|
|
1624
|
+
...t
|
|
1625
|
+
}), Z = async (e) => {
|
|
1626
|
+
let t = await e.json().catch(() => null);
|
|
1627
|
+
if (!e.ok || !t) throw Error(t?.error ?? `storage_request_failed_${e.status}`);
|
|
1628
|
+
return t;
|
|
1629
|
+
}, Sr = {
|
|
1630
|
+
set: async (e, t, n) => {
|
|
1631
|
+
await Y();
|
|
1632
|
+
let r = await _r(n, xr(e, t));
|
|
1633
|
+
await Z(await X("/set", {
|
|
1634
|
+
method: "POST",
|
|
1635
|
+
headers: { "content-type": "application/json" },
|
|
1636
|
+
body: JSON.stringify({
|
|
1637
|
+
namespace: e,
|
|
1638
|
+
key: t,
|
|
1639
|
+
value: lr(r)
|
|
1640
|
+
})
|
|
1641
|
+
}));
|
|
1642
|
+
},
|
|
1643
|
+
get: async (e, t) => {
|
|
1644
|
+
await Y();
|
|
1645
|
+
let n = await X(`/get?namespace=${encodeURIComponent(e)}&key=${encodeURIComponent(t)}`, { method: "GET" });
|
|
1646
|
+
if (n.status === 404) return null;
|
|
1647
|
+
let { value: r } = await Z(n);
|
|
1648
|
+
return vr(ur(r), xr(e, t));
|
|
1649
|
+
},
|
|
1650
|
+
list: async (e, t) => (await Y(), Z(await X("/list", {
|
|
1651
|
+
method: "POST",
|
|
1652
|
+
headers: { "content-type": "application/json" },
|
|
1653
|
+
body: JSON.stringify({
|
|
1654
|
+
namespace: e,
|
|
1655
|
+
limit: t?.limit,
|
|
1656
|
+
cursor: t?.cursor
|
|
1657
|
+
})
|
|
1658
|
+
}))),
|
|
1659
|
+
remove: async (e, t) => {
|
|
1660
|
+
await Y(), await Z(await X("/delete", {
|
|
1661
|
+
method: "DELETE",
|
|
1662
|
+
headers: { "content-type": "application/json" },
|
|
1663
|
+
body: JSON.stringify({
|
|
1664
|
+
namespace: e,
|
|
1665
|
+
key: t
|
|
1666
|
+
})
|
|
1667
|
+
}));
|
|
1668
|
+
}
|
|
1669
|
+
}, Cr = "fkn-premium", Q = "premium-tokens", wr = () => new Promise((e, t) => {
|
|
1670
|
+
let n = indexedDB.open(Cr, 1);
|
|
1671
|
+
n.onupgradeneeded = () => {
|
|
1672
|
+
n.result.createObjectStore(Q, { autoIncrement: !0 });
|
|
1673
|
+
}, n.onsuccess = () => e(n.result), n.onerror = () => t(n.error);
|
|
1674
|
+
}), Tr = async (e, t) => {
|
|
1675
|
+
let n = await wr();
|
|
1676
|
+
return new Promise((r, i) => {
|
|
1677
|
+
let a = n.transaction(Q, e), o = t(a.objectStore(Q));
|
|
1678
|
+
o.onsuccess = () => r(o.result), o.onerror = () => i(o.error), a.oncomplete = () => n.close();
|
|
1679
|
+
});
|
|
1680
|
+
}, Er = async (e) => {
|
|
1681
|
+
let t = await wr();
|
|
1682
|
+
await new Promise((n, r) => {
|
|
1683
|
+
let i = t.transaction(Q, "readwrite"), a = i.objectStore(Q);
|
|
1684
|
+
for (let t of e) a.add(t);
|
|
1685
|
+
i.oncomplete = () => {
|
|
1686
|
+
t.close(), n();
|
|
1687
|
+
}, i.onerror = () => r(i.error);
|
|
1688
|
+
});
|
|
1689
|
+
}, Dr = () => Tr("readonly", (e) => e.count()), Or = () => Tr("readwrite", (e) => e.clear()), kr = new v({
|
|
1690
|
+
name: "RSABSSA-SHA256-PSS-Deterministic",
|
|
1691
|
+
hash: "SHA-256",
|
|
1692
|
+
saltLength: 32,
|
|
1693
|
+
prepareType: 0,
|
|
1694
|
+
supportsRSARAW: !1
|
|
1695
|
+
}), Ar = 10, jr = 3, Mr = `${ar}/api/v1/tokens`, Nr = (e) => ur(e.replace("-----BEGIN PUBLIC KEY-----", "").replace("-----END PUBLIC KEY-----", "").replace(/\s+/g, "").replace(/\+/g, "-").replace(/\//g, "_")), Pr = async (e) => crypto.subtle.importKey("spki", Nr(e), {
|
|
1696
|
+
name: "RSA-PSS",
|
|
1697
|
+
hash: "SHA-256"
|
|
1698
|
+
}, !0, ["verify"]), Fr = async () => {
|
|
1699
|
+
let e = await fetch(`${Mr}/pubkey`, { credentials: "include" }), t = await e.json().catch(() => null);
|
|
1700
|
+
if (!e.ok || !t?.publicKey) throw Error(t?.error ?? `pubkey_failed_${e.status}`);
|
|
1701
|
+
return Pr(t.publicKey);
|
|
1702
|
+
}, Ir = async (e) => {
|
|
1703
|
+
let t = Array.from({ length: Ar }, () => ({ message: kr.prepare(crypto.getRandomValues(new Uint8Array(32))) })), n = await Promise.all(t.map(({ message: t }) => kr.blind(e, t))), r = await fetch(Mr, {
|
|
1704
|
+
method: "POST",
|
|
1705
|
+
credentials: "include",
|
|
1706
|
+
headers: { "content-type": "application/json" },
|
|
1707
|
+
body: JSON.stringify({ blinded: n.map(({ blindedMsg: e }) => lr(e)) })
|
|
1708
|
+
}), i = await r.json().catch(() => null);
|
|
1709
|
+
if (!r.ok || !i?.signatures) throw Error(i?.error ?? `issue_failed_${r.status}`);
|
|
1710
|
+
let a = i.signatures;
|
|
1711
|
+
return Promise.all(t.map(async ({ message: t }, r) => {
|
|
1712
|
+
let i = ur(a[r] ?? "");
|
|
1713
|
+
return {
|
|
1714
|
+
message: t,
|
|
1715
|
+
signature: await kr.finalize(e, t, i, n[r].inv)
|
|
1716
|
+
};
|
|
1717
|
+
}));
|
|
1718
|
+
}, Lr = async () => {
|
|
1719
|
+
await Dr() >= jr || await Er(await Ir(await Fr()));
|
|
1720
|
+
}, Rr = new TextEncoder();
|
|
34
1721
|
new TextDecoder();
|
|
35
|
-
var
|
|
1722
|
+
var zr = (e) => x.isValid(e), Br = (e) => S.isValid(e), Vr = (e) => zr(e) ? 4 : Br(e) ? 6 : 0, Hr = (...e) => {
|
|
36
1723
|
if (typeof e[0] == "string") throw Error("FKN WebVPN does not support IPC connections");
|
|
37
1724
|
let t = typeof e.at(-1) == "function" ? e.at(-1) : void 0;
|
|
38
1725
|
return e[0] && typeof e[0] == "object" ? {
|
|
@@ -43,7 +1730,7 @@ var D = (e) => m.isValid(e), O = (e) => h.isValid(e), k = (e) => D(e) ? 4 : O(e)
|
|
|
43
1730
|
host: typeof e[1] == "string" ? e[1] : void 0,
|
|
44
1731
|
callback: t
|
|
45
1732
|
};
|
|
46
|
-
},
|
|
1733
|
+
}, Ur = (...e) => {
|
|
47
1734
|
let t = typeof e.at(-1) == "function" ? e.at(-1) : void 0, n = e[0] ?? 0, r = typeof e[1] == "string" ? e[1] : void 0;
|
|
48
1735
|
return typeof e[0] == "object" ? {
|
|
49
1736
|
...e[0],
|
|
@@ -55,7 +1742,7 @@ var D = (e) => m.isValid(e), O = (e) => h.isValid(e), k = (e) => D(e) ? 4 : O(e)
|
|
|
55
1742
|
port: n,
|
|
56
1743
|
callback: t
|
|
57
1744
|
};
|
|
58
|
-
},
|
|
1745
|
+
}, Wr = (...e) => {
|
|
59
1746
|
let t = typeof e.at(-1) == "function" ? e.at(-1) : void 0, n = e[0];
|
|
60
1747
|
if (typeof e[2] == "number") return {
|
|
61
1748
|
message: n,
|
|
@@ -80,18 +1767,18 @@ var D = (e) => m.isValid(e), O = (e) => h.isValid(e), k = (e) => D(e) ? 4 : O(e)
|
|
|
80
1767
|
new TextEncoder(), new TextDecoder();
|
|
81
1768
|
//#endregion
|
|
82
1769
|
//#region src/lib/webvpn/net.ts
|
|
83
|
-
var
|
|
84
|
-
Server: () =>
|
|
85
|
-
Socket: () =>
|
|
86
|
-
_default: () =>
|
|
87
|
-
connect: () =>
|
|
88
|
-
createConnection: () =>
|
|
89
|
-
createServer: () =>
|
|
90
|
-
default: () =>
|
|
91
|
-
isIP: () =>
|
|
92
|
-
isIPv4: () =>
|
|
93
|
-
isIPv6: () =>
|
|
94
|
-
}),
|
|
1770
|
+
var Gr = /* @__PURE__ */ n({
|
|
1771
|
+
Server: () => Kr,
|
|
1772
|
+
Socket: () => $,
|
|
1773
|
+
_default: () => Xr,
|
|
1774
|
+
connect: () => qr,
|
|
1775
|
+
createConnection: () => Jr,
|
|
1776
|
+
createServer: () => Yr,
|
|
1777
|
+
default: () => Xr,
|
|
1778
|
+
isIP: () => Vr,
|
|
1779
|
+
isIPv4: () => zr,
|
|
1780
|
+
isIPv6: () => Br
|
|
1781
|
+
}), $ = class extends y.Duplex {
|
|
95
1782
|
_localAddress;
|
|
96
1783
|
_remoteAddress;
|
|
97
1784
|
_webVPNTcpSocketPromise;
|
|
@@ -125,7 +1812,10 @@ var N = /* @__PURE__ */ n({
|
|
|
125
1812
|
_read(e) {
|
|
126
1813
|
if (!this._webVPNTcpSocketPromise) throw Error("Socket not connected");
|
|
127
1814
|
this._webVPNTcpSocketPromise.then((e) => {
|
|
128
|
-
if (!e)
|
|
1815
|
+
if (!e) {
|
|
1816
|
+
this.push(null);
|
|
1817
|
+
return;
|
|
1818
|
+
}
|
|
129
1819
|
e.reader.read().then(({ value: e, done: t }) => {
|
|
130
1820
|
if (t) {
|
|
131
1821
|
this.push(null);
|
|
@@ -148,12 +1838,12 @@ var N = /* @__PURE__ */ n({
|
|
|
148
1838
|
}).catch(n);
|
|
149
1839
|
}
|
|
150
1840
|
connect(...e) {
|
|
151
|
-
let t =
|
|
1841
|
+
let t = Hr(...e), n = this.__webvpn_tcp_socket_init__(E.then((e) => e.webVpnTcpSocket({
|
|
152
1842
|
remoteAddress: t.host ?? "localhost",
|
|
153
1843
|
remotePort: t.port
|
|
154
1844
|
})));
|
|
155
1845
|
return t.callback && n.then((e) => {
|
|
156
|
-
e && t.callback();
|
|
1846
|
+
e && t.callback.call(this);
|
|
157
1847
|
}), this;
|
|
158
1848
|
}
|
|
159
1849
|
_end(...e) {
|
|
@@ -268,7 +1958,7 @@ var N = /* @__PURE__ */ n({
|
|
|
268
1958
|
return this._remoteAddress.family;
|
|
269
1959
|
}
|
|
270
1960
|
timeout;
|
|
271
|
-
},
|
|
1961
|
+
}, Kr = class extends b {
|
|
272
1962
|
_localAddress;
|
|
273
1963
|
_webVPNTcpSocketListenerPromise;
|
|
274
1964
|
constructor(e, t) {
|
|
@@ -286,16 +1976,16 @@ var N = /* @__PURE__ */ n({
|
|
|
286
1976
|
}), this._webVPNTcpSocketListenerPromise;
|
|
287
1977
|
}
|
|
288
1978
|
listen(...e) {
|
|
289
|
-
let t =
|
|
290
|
-
|
|
1979
|
+
let t = Hr(...e), n = (e) => {
|
|
1980
|
+
let t = new $({ connection: Promise.resolve(e) });
|
|
1981
|
+
this.emit("connection", t);
|
|
1982
|
+
}, r = (e) => E.then((r) => r.webVpnTcpSocketListener({
|
|
1983
|
+
localAddress: e,
|
|
291
1984
|
localPort: t.port,
|
|
292
|
-
onConnection:
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
})));
|
|
297
|
-
return t.callback && n.then((e) => {
|
|
298
|
-
e && t.callback();
|
|
1985
|
+
onConnection: n
|
|
1986
|
+
})), i = t.host ? r(t.host) : r("::").catch(() => r("0.0.0.0")), a = this.__webvpn_tcp_socket_listener_init__(i);
|
|
1987
|
+
return t.callback && a.then((e) => {
|
|
1988
|
+
e && t.callback.call(this);
|
|
299
1989
|
}), this;
|
|
300
1990
|
}
|
|
301
1991
|
close(e) {
|
|
@@ -314,31 +2004,32 @@ var N = /* @__PURE__ */ n({
|
|
|
314
2004
|
throw Error("Method not implemented.");
|
|
315
2005
|
}
|
|
316
2006
|
ref() {
|
|
317
|
-
|
|
2007
|
+
return this;
|
|
318
2008
|
}
|
|
319
2009
|
unref() {
|
|
320
|
-
|
|
2010
|
+
return this;
|
|
321
2011
|
}
|
|
322
2012
|
maxConnections;
|
|
323
2013
|
connections;
|
|
324
2014
|
listening;
|
|
325
2015
|
async [Symbol.asyncDispose]() {}
|
|
326
|
-
},
|
|
327
|
-
|
|
2016
|
+
}, qr = (e, t) => new $().connect(e, t), Jr = (e, t) => new $().connect(e, t), Yr = (e, t) => {
|
|
2017
|
+
typeof e == "function" && (t = e, e = void 0);
|
|
2018
|
+
let n = new Kr(e);
|
|
328
2019
|
return t && n.on("connection", t), n;
|
|
329
|
-
},
|
|
330
|
-
Socket:
|
|
331
|
-
Server:
|
|
332
|
-
connect:
|
|
333
|
-
createConnection:
|
|
334
|
-
createServer:
|
|
335
|
-
isIP:
|
|
336
|
-
isIPv4:
|
|
337
|
-
isIPv6:
|
|
338
|
-
},
|
|
339
|
-
Socket: () =>
|
|
340
|
-
createSocket: () =>
|
|
341
|
-
}),
|
|
2020
|
+
}, Xr = {
|
|
2021
|
+
Socket: $,
|
|
2022
|
+
Server: Kr,
|
|
2023
|
+
connect: qr,
|
|
2024
|
+
createConnection: Jr,
|
|
2025
|
+
createServer: Yr,
|
|
2026
|
+
isIP: Vr,
|
|
2027
|
+
isIPv4: zr,
|
|
2028
|
+
isIPv6: Br
|
|
2029
|
+
}, Zr = /* @__PURE__ */ n({
|
|
2030
|
+
Socket: () => Qr,
|
|
2031
|
+
createSocket: () => ti
|
|
2032
|
+
}), Qr = class extends b {
|
|
342
2033
|
_type;
|
|
343
2034
|
_localAddress;
|
|
344
2035
|
_remoteAddress;
|
|
@@ -366,8 +2057,8 @@ var N = /* @__PURE__ */ n({
|
|
|
366
2057
|
});
|
|
367
2058
|
}
|
|
368
2059
|
addMembership(e, t) {
|
|
369
|
-
if (
|
|
370
|
-
let n =
|
|
2060
|
+
if (x.isValid(e)) {
|
|
2061
|
+
let n = $r(e), r = t && x.isValid(t) ? $r(t) : new Uint8Array([
|
|
371
2062
|
0,
|
|
372
2063
|
0,
|
|
373
2064
|
0,
|
|
@@ -378,8 +2069,8 @@ var N = /* @__PURE__ */ n({
|
|
|
378
2069
|
group: n,
|
|
379
2070
|
interface: r
|
|
380
2071
|
});
|
|
381
|
-
} else if (
|
|
382
|
-
let t =
|
|
2072
|
+
} else if (S.isValid(e)) {
|
|
2073
|
+
let t = ei(e);
|
|
383
2074
|
this._setUdpOption({
|
|
384
2075
|
type: 7,
|
|
385
2076
|
group: t,
|
|
@@ -392,15 +2083,15 @@ var N = /* @__PURE__ */ n({
|
|
|
392
2083
|
return this._localAddress;
|
|
393
2084
|
}
|
|
394
2085
|
bind(...e) {
|
|
395
|
-
let t =
|
|
396
|
-
return this._webVPNUdpSocketPromise =
|
|
2086
|
+
let t = Ur(...e), n = this._type === "udp6" ? "::" : "0.0.0.0";
|
|
2087
|
+
return this._webVPNUdpSocketPromise = E.then((e) => e.webVpnUdpSocket({
|
|
397
2088
|
type: this._type,
|
|
398
2089
|
address: t.address ?? n,
|
|
399
2090
|
port: t.port
|
|
400
2091
|
})).then((e) => {
|
|
401
2092
|
let t = e.dataReadableStream.getReader(), n = async () => {
|
|
402
2093
|
let { value: e, done: r } = await t.read();
|
|
403
|
-
r || (this.emit("message",
|
|
2094
|
+
r || (this.emit("message", C.from(e.data), {
|
|
404
2095
|
address: e.address,
|
|
405
2096
|
family: e.family,
|
|
406
2097
|
port: e.port,
|
|
@@ -453,8 +2144,8 @@ var N = /* @__PURE__ */ n({
|
|
|
453
2144
|
});
|
|
454
2145
|
}
|
|
455
2146
|
dropMembership(e, t) {
|
|
456
|
-
if (
|
|
457
|
-
let n =
|
|
2147
|
+
if (x.isValid(e)) {
|
|
2148
|
+
let n = $r(e), r = t && x.isValid(t) ? $r(t) : new Uint8Array([
|
|
458
2149
|
0,
|
|
459
2150
|
0,
|
|
460
2151
|
0,
|
|
@@ -465,8 +2156,8 @@ var N = /* @__PURE__ */ n({
|
|
|
465
2156
|
group: n,
|
|
466
2157
|
interface: r
|
|
467
2158
|
});
|
|
468
|
-
} else if (
|
|
469
|
-
let t =
|
|
2159
|
+
} else if (S.isValid(e)) {
|
|
2160
|
+
let t = ei(e);
|
|
470
2161
|
this._setUdpOption({
|
|
471
2162
|
type: 8,
|
|
472
2163
|
group: t,
|
|
@@ -499,11 +2190,11 @@ var N = /* @__PURE__ */ n({
|
|
|
499
2190
|
}
|
|
500
2191
|
send(...e) {
|
|
501
2192
|
this._webVPNUdpSocketPromise || this.bind();
|
|
502
|
-
let t =
|
|
2193
|
+
let t = Wr(...e), n = this._type === "udp6" ? "::1" : "127.0.0.1";
|
|
503
2194
|
if (!this._webVPNUdpSocketPromise) throw Error("Socket not bound");
|
|
504
2195
|
this._webVPNUdpSocketPromise.then((e) => {
|
|
505
2196
|
if (!e) throw Error("Socket not bound");
|
|
506
|
-
let r = typeof t.message == "string" ?
|
|
2197
|
+
let r = typeof t.message == "string" ? Rr.encode(t.message) : t.message;
|
|
507
2198
|
e.send({
|
|
508
2199
|
...t,
|
|
509
2200
|
address: t.address ?? n,
|
|
@@ -561,50 +2252,548 @@ var N = /* @__PURE__ */ n({
|
|
|
561
2252
|
this.close(e);
|
|
562
2253
|
});
|
|
563
2254
|
}
|
|
564
|
-
},
|
|
2255
|
+
}, $r = (e) => {
|
|
565
2256
|
let t = e.split(".").map((e) => parseInt(e, 10));
|
|
566
2257
|
if (t.length !== 4 || t.some((e) => Number.isNaN(e) || e < 0 || e > 255)) throw Error(`Invalid IPv4 address: ${e}`);
|
|
567
2258
|
return new Uint8Array(t);
|
|
568
|
-
},
|
|
569
|
-
let t = new
|
|
2259
|
+
}, ei = (e) => {
|
|
2260
|
+
let t = new S(e).getBitsBase16(0, 128).match(/.{2}/g);
|
|
570
2261
|
if (!t || t.length !== 16) throw Error(`Invalid IPv6 address: ${e}`);
|
|
571
2262
|
return new Uint8Array(t.map((e) => parseInt(e, 16)));
|
|
572
|
-
},
|
|
573
|
-
let n = new
|
|
2263
|
+
}, ti = (e, t) => {
|
|
2264
|
+
let n = new Qr(typeof e == "string" ? { type: e } : e);
|
|
574
2265
|
return t && n.on("message", t), n;
|
|
575
|
-
}
|
|
576
|
-
(
|
|
577
|
-
|
|
578
|
-
|
|
579
|
-
|
|
580
|
-
|
|
581
|
-
|
|
582
|
-
|
|
583
|
-
|
|
584
|
-
|
|
585
|
-
|
|
586
|
-
|
|
587
|
-
|
|
588
|
-
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
|
|
592
|
-
|
|
593
|
-
|
|
594
|
-
|
|
595
|
-
|
|
596
|
-
|
|
597
|
-
|
|
598
|
-
|
|
599
|
-
|
|
600
|
-
|
|
601
|
-
|
|
602
|
-
|
|
2266
|
+
}, ni = /* @__PURE__ */ n({
|
|
2267
|
+
Agent: () => Si,
|
|
2268
|
+
ClientRequest: () => bi,
|
|
2269
|
+
HTTPParser: () => mi,
|
|
2270
|
+
IncomingMessage: () => gi,
|
|
2271
|
+
METHODS: () => ii,
|
|
2272
|
+
STATUS_CODES: () => ai,
|
|
2273
|
+
Server: () => xi,
|
|
2274
|
+
ServerResponse: () => vi,
|
|
2275
|
+
_default: () => Di,
|
|
2276
|
+
createServer: () => Ei,
|
|
2277
|
+
default: () => Di,
|
|
2278
|
+
get: () => Ti,
|
|
2279
|
+
globalAgent: () => Ci,
|
|
2280
|
+
request: () => wi
|
|
2281
|
+
}), ri = new TextDecoder("latin1"), ii = /* @__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("."), ai = {
|
|
2282
|
+
100: "Continue",
|
|
2283
|
+
101: "Switching Protocols",
|
|
2284
|
+
102: "Processing",
|
|
2285
|
+
103: "Early Hints",
|
|
2286
|
+
200: "OK",
|
|
2287
|
+
201: "Created",
|
|
2288
|
+
202: "Accepted",
|
|
2289
|
+
203: "Non-Authoritative Information",
|
|
2290
|
+
204: "No Content",
|
|
2291
|
+
205: "Reset Content",
|
|
2292
|
+
206: "Partial Content",
|
|
2293
|
+
207: "Multi-Status",
|
|
2294
|
+
208: "Already Reported",
|
|
2295
|
+
226: "IM Used",
|
|
2296
|
+
300: "Multiple Choices",
|
|
2297
|
+
301: "Moved Permanently",
|
|
2298
|
+
302: "Found",
|
|
2299
|
+
303: "See Other",
|
|
2300
|
+
304: "Not Modified",
|
|
2301
|
+
305: "Use Proxy",
|
|
2302
|
+
307: "Temporary Redirect",
|
|
2303
|
+
308: "Permanent Redirect",
|
|
2304
|
+
400: "Bad Request",
|
|
2305
|
+
401: "Unauthorized",
|
|
2306
|
+
402: "Payment Required",
|
|
2307
|
+
403: "Forbidden",
|
|
2308
|
+
404: "Not Found",
|
|
2309
|
+
405: "Method Not Allowed",
|
|
2310
|
+
406: "Not Acceptable",
|
|
2311
|
+
407: "Proxy Authentication Required",
|
|
2312
|
+
408: "Request Timeout",
|
|
2313
|
+
409: "Conflict",
|
|
2314
|
+
410: "Gone",
|
|
2315
|
+
411: "Length Required",
|
|
2316
|
+
412: "Precondition Failed",
|
|
2317
|
+
413: "Payload Too Large",
|
|
2318
|
+
414: "URI Too Long",
|
|
2319
|
+
415: "Unsupported Media Type",
|
|
2320
|
+
416: "Range Not Satisfiable",
|
|
2321
|
+
417: "Expectation Failed",
|
|
2322
|
+
418: "I'm a Teapot",
|
|
2323
|
+
421: "Misdirected Request",
|
|
2324
|
+
422: "Unprocessable Entity",
|
|
2325
|
+
423: "Locked",
|
|
2326
|
+
424: "Failed Dependency",
|
|
2327
|
+
425: "Too Early",
|
|
2328
|
+
426: "Upgrade Required",
|
|
2329
|
+
428: "Precondition Required",
|
|
2330
|
+
429: "Too Many Requests",
|
|
2331
|
+
431: "Request Header Fields Too Large",
|
|
2332
|
+
451: "Unavailable For Legal Reasons",
|
|
2333
|
+
500: "Internal Server Error",
|
|
2334
|
+
501: "Not Implemented",
|
|
2335
|
+
502: "Bad Gateway",
|
|
2336
|
+
503: "Service Unavailable",
|
|
2337
|
+
504: "Gateway Timeout",
|
|
2338
|
+
505: "HTTP Version Not Supported",
|
|
2339
|
+
506: "Variant Also Negotiates",
|
|
2340
|
+
507: "Insufficient Storage",
|
|
2341
|
+
508: "Loop Detected",
|
|
2342
|
+
509: "Bandwidth Limit Exceeded",
|
|
2343
|
+
510: "Not Extended",
|
|
2344
|
+
511: "Network Authentication Required"
|
|
2345
|
+
}, oi = new Set([
|
|
2346
|
+
"content-type",
|
|
2347
|
+
"content-length",
|
|
2348
|
+
"user-agent",
|
|
2349
|
+
"referer",
|
|
2350
|
+
"host",
|
|
2351
|
+
"authorization",
|
|
2352
|
+
"proxy-authorization",
|
|
2353
|
+
"if-modified-since",
|
|
2354
|
+
"if-unmodified-since",
|
|
2355
|
+
"from",
|
|
2356
|
+
"location",
|
|
2357
|
+
"max-forwards",
|
|
2358
|
+
"retry-after",
|
|
2359
|
+
"etag",
|
|
2360
|
+
"last-modified",
|
|
2361
|
+
"server",
|
|
2362
|
+
"age",
|
|
2363
|
+
"expires"
|
|
2364
|
+
]), si = 13, ci = 10, li = /^[\^_`a-zA-Z\-0-9!#$%&'*+.|~]+$/, ui = (e, t) => (e.code = t, e), di = (e, t) => {
|
|
2365
|
+
if (e.length === 0) return t;
|
|
2366
|
+
if (t.length === 0) return e;
|
|
2367
|
+
let n = new Uint8Array(e.length + t.length);
|
|
2368
|
+
return n.set(e, 0), n.set(t, e.length), n;
|
|
2369
|
+
}, fi = (e, t) => {
|
|
2370
|
+
for (let n = t; n + 1 < e.length; n++) if (e[n] === si && e[n + 1] === ci) return n;
|
|
2371
|
+
return -1;
|
|
2372
|
+
}, pi = (e) => {
|
|
2373
|
+
for (let t = 0; t + 3 < e.length; t++) if (e[t] === si && e[t + 1] === ci && e[t + 2] === si && e[t + 3] === ci) return t;
|
|
2374
|
+
return -1;
|
|
2375
|
+
}, mi = class {
|
|
2376
|
+
buf = new Uint8Array();
|
|
2377
|
+
state = "HEAD";
|
|
2378
|
+
framing = "none";
|
|
2379
|
+
bodyRemaining = 0;
|
|
2380
|
+
chunkState = "size";
|
|
2381
|
+
skipBody = !1;
|
|
2382
|
+
constructor(e, t) {
|
|
2383
|
+
this.mode = e, this.handlers = t;
|
|
2384
|
+
}
|
|
2385
|
+
execute(e) {
|
|
2386
|
+
this.buf = di(this.buf, e);
|
|
2387
|
+
let t = !0;
|
|
2388
|
+
for (; t;) if (t = !1, this.state === "HEAD") {
|
|
2389
|
+
let e = pi(this.buf);
|
|
2390
|
+
if (e === -1) return;
|
|
2391
|
+
let n = this.buf.subarray(0, e);
|
|
2392
|
+
this.buf = this.buf.subarray(e + 4);
|
|
2393
|
+
let r = this.parseHead(n);
|
|
2394
|
+
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);
|
|
2395
|
+
} else this.consumeBody() && (this.handlers.onComplete(), this.reset(), t = this.buf.length > 0);
|
|
2396
|
+
}
|
|
2397
|
+
finish() {
|
|
2398
|
+
this.state === "BODY" && this.framing === "eof" && (this.handlers.onComplete(), this.reset());
|
|
2399
|
+
}
|
|
2400
|
+
reset() {
|
|
2401
|
+
this.state = "HEAD", this.framing = "none", this.bodyRemaining = 0, this.chunkState = "size", this.skipBody = !1;
|
|
2402
|
+
}
|
|
2403
|
+
parseHead(e) {
|
|
2404
|
+
let t = ri.decode(e).split("\r\n"), n = t.shift() ?? "", r = [];
|
|
2405
|
+
for (let e of t) (e.startsWith(" ") || e.startsWith(" ")) && r.length > 0 ? r[r.length - 1] += " " + e.trim() : r.push(e);
|
|
2406
|
+
let i = [], a = {};
|
|
2407
|
+
for (let e of r) {
|
|
2408
|
+
if (!e) continue;
|
|
2409
|
+
let t = e.indexOf(":");
|
|
2410
|
+
if (t === -1) continue;
|
|
2411
|
+
let n = e.slice(0, t).trim(), r = e.slice(t + 1).trim();
|
|
2412
|
+
i.push(n, r), this.addHeader(a, n, r);
|
|
2413
|
+
}
|
|
2414
|
+
let o = {
|
|
2415
|
+
httpVersionMajor: 1,
|
|
2416
|
+
httpVersionMinor: 1,
|
|
2417
|
+
httpVersion: "1.1",
|
|
2418
|
+
headers: a,
|
|
2419
|
+
rawHeaders: i
|
|
2420
|
+
};
|
|
2421
|
+
if (this.mode === "request") {
|
|
2422
|
+
let [e, t, r] = n.split(" ");
|
|
2423
|
+
o.method = (e ?? "GET").toUpperCase(), o.url = t ?? "/", this.applyVersion(o, r);
|
|
2424
|
+
} else {
|
|
2425
|
+
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);
|
|
2426
|
+
o.statusCode = parseInt(a, 10) || 0, o.statusMessage = i === -1 ? "" : r.slice(i + 1), this.applyVersion(o, t);
|
|
2427
|
+
}
|
|
2428
|
+
return o;
|
|
2429
|
+
}
|
|
2430
|
+
applyVersion(e, t) {
|
|
2431
|
+
let n = /HTTP\/(\d)\.(\d)/i.exec(t ?? "");
|
|
2432
|
+
n && (e.httpVersionMajor = parseInt(n[1], 10), e.httpVersionMinor = parseInt(n[2], 10), e.httpVersion = `${e.httpVersionMajor}.${e.httpVersionMinor}`);
|
|
2433
|
+
}
|
|
2434
|
+
addHeader(e, t, n) {
|
|
2435
|
+
let r = t.toLowerCase();
|
|
2436
|
+
if (r === "set-cookie") {
|
|
2437
|
+
let t = e["set-cookie"];
|
|
2438
|
+
Array.isArray(t) ? t.push(n) : e["set-cookie"] = [n];
|
|
2439
|
+
return;
|
|
2440
|
+
}
|
|
2441
|
+
let i = e[r];
|
|
2442
|
+
i === void 0 ? e[r] = n : oi.has(r) || (e[r] = `${i}, ${n}`);
|
|
2443
|
+
}
|
|
2444
|
+
setupBody(e) {
|
|
2445
|
+
if (this.skipBody) {
|
|
2446
|
+
this.framing = "none";
|
|
2447
|
+
return;
|
|
2448
|
+
}
|
|
2449
|
+
let t = e.headers["transfer-encoding"];
|
|
2450
|
+
if (typeof t == "string" && t.toLowerCase().includes("chunked")) {
|
|
2451
|
+
this.framing = "chunked", this.chunkState = "size";
|
|
2452
|
+
return;
|
|
2453
|
+
}
|
|
2454
|
+
let n = e.headers["content-length"];
|
|
2455
|
+
if (typeof n == "string" && n !== "") {
|
|
2456
|
+
let e = parseInt(n, 10);
|
|
2457
|
+
e > 0 ? (this.framing = "length", this.bodyRemaining = e) : this.framing = "none";
|
|
2458
|
+
return;
|
|
2459
|
+
}
|
|
2460
|
+
if (this.mode === "response") {
|
|
2461
|
+
let t = e.statusCode ?? 0;
|
|
2462
|
+
t >= 100 && t < 200 || t === 204 || t === 304 ? this.framing = "none" : this.framing = "eof";
|
|
2463
|
+
} else this.framing = "none";
|
|
2464
|
+
}
|
|
2465
|
+
consumeBody() {
|
|
2466
|
+
if (this.framing === "length") {
|
|
2467
|
+
if (this.buf.length === 0) return !1;
|
|
2468
|
+
let e = Math.min(this.bodyRemaining, this.buf.length);
|
|
2469
|
+
return this.handlers.onBody(this.buf.subarray(0, e)), this.buf = this.buf.subarray(e), this.bodyRemaining -= e, this.bodyRemaining === 0;
|
|
2470
|
+
}
|
|
2471
|
+
return this.framing === "eof" ? (this.buf.length > 0 && (this.handlers.onBody(this.buf), this.buf = new Uint8Array()), !1) : this.framing === "chunked" ? this.consumeChunked() : !0;
|
|
2472
|
+
}
|
|
2473
|
+
consumeChunked() {
|
|
2474
|
+
for (;;) if (this.chunkState === "size") {
|
|
2475
|
+
let e = fi(this.buf, 0);
|
|
2476
|
+
if (e === -1) return !1;
|
|
2477
|
+
let t = ri.decode(this.buf.subarray(0, e)), n = parseInt(t.split(";")[0].trim(), 16);
|
|
2478
|
+
if (this.buf = this.buf.subarray(e + 2), Number.isNaN(n)) return !0;
|
|
2479
|
+
n === 0 ? this.chunkState = "trailer" : (this.bodyRemaining = n, this.chunkState = "data");
|
|
2480
|
+
} else if (this.chunkState === "data") {
|
|
2481
|
+
if (this.buf.length === 0) return !1;
|
|
2482
|
+
let e = Math.min(this.bodyRemaining, this.buf.length);
|
|
2483
|
+
this.handlers.onBody(this.buf.subarray(0, e)), this.buf = this.buf.subarray(e), this.bodyRemaining -= e, this.bodyRemaining === 0 && (this.chunkState = "dataCRLF");
|
|
2484
|
+
} else if (this.chunkState === "dataCRLF") {
|
|
2485
|
+
if (this.buf.length < 2) return !1;
|
|
2486
|
+
this.buf = this.buf.subarray(2), this.chunkState = "size";
|
|
2487
|
+
} else {
|
|
2488
|
+
let e = fi(this.buf, 0);
|
|
2489
|
+
if (e === -1) return !1;
|
|
2490
|
+
let t = e === 0;
|
|
2491
|
+
if (this.buf = this.buf.subarray(e + 2), t) return !0;
|
|
2492
|
+
}
|
|
2493
|
+
}
|
|
2494
|
+
}, hi = (e, t) => C.isBuffer(e) ? e : typeof e == "string" ? C.from(e, t ?? "utf8") : e instanceof Uint8Array ? C.from(e) : e instanceof ArrayBuffer ? C.from(new Uint8Array(e)) : C.from(String(e)), gi = class extends y.Readable {
|
|
2495
|
+
httpVersion = "1.1";
|
|
2496
|
+
httpVersionMajor = 1;
|
|
2497
|
+
httpVersionMinor = 1;
|
|
2498
|
+
headers = {};
|
|
2499
|
+
rawHeaders = [];
|
|
2500
|
+
trailers = {};
|
|
2501
|
+
rawTrailers = [];
|
|
2502
|
+
method;
|
|
2503
|
+
url;
|
|
2504
|
+
statusCode;
|
|
2505
|
+
statusMessage;
|
|
2506
|
+
complete = !1;
|
|
2507
|
+
socket;
|
|
2508
|
+
constructor(e) {
|
|
2509
|
+
super(), this.socket = e;
|
|
2510
|
+
}
|
|
2511
|
+
get connection() {
|
|
2512
|
+
return this.socket;
|
|
2513
|
+
}
|
|
2514
|
+
_applyHead(e) {
|
|
2515
|
+
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;
|
|
2516
|
+
}
|
|
2517
|
+
_read() {}
|
|
2518
|
+
setTimeout(e, t) {
|
|
2519
|
+
return this.socket.setTimeout(e, t), this;
|
|
2520
|
+
}
|
|
2521
|
+
}, _i = class extends y.Writable {
|
|
2522
|
+
_headerStore = /* @__PURE__ */ new Map();
|
|
2523
|
+
headersSent = !1;
|
|
2524
|
+
chunkedEncoding = !1;
|
|
2525
|
+
finished = !1;
|
|
2526
|
+
_bodyWritten = !1;
|
|
2527
|
+
setHeader(e, t) {
|
|
2528
|
+
if (this.headersSent) throw ui(/* @__PURE__ */ Error("Cannot set headers after they are sent to the client"), "ERR_HTTP_HEADERS_SENT");
|
|
2529
|
+
if (typeof e != "string" || !li.test(e)) throw ui(/* @__PURE__ */ TypeError(`Header name must be a valid HTTP token [${JSON.stringify(String(e))}]`), "ERR_INVALID_HTTP_TOKEN");
|
|
2530
|
+
if (t === void 0) throw ui(/* @__PURE__ */ TypeError(`Invalid value "undefined" for header "${e}"`), "ERR_HTTP_INVALID_HEADER_VALUE");
|
|
2531
|
+
return this._headerStore.set(e.toLowerCase(), [e, Array.isArray(t) ? [...t] : t]), this;
|
|
2532
|
+
}
|
|
2533
|
+
getHeader(e) {
|
|
2534
|
+
return this._headerStore.get(e.toLowerCase())?.[1];
|
|
2535
|
+
}
|
|
2536
|
+
getHeaderNames() {
|
|
2537
|
+
return [...this._headerStore.values()].map(([e]) => e);
|
|
2538
|
+
}
|
|
2539
|
+
getHeaders() {
|
|
2540
|
+
let e = {};
|
|
2541
|
+
for (let [t, n] of this._headerStore.values()) e[t] = n;
|
|
2542
|
+
return e;
|
|
2543
|
+
}
|
|
2544
|
+
hasHeader(e) {
|
|
2545
|
+
return this._headerStore.has(e.toLowerCase());
|
|
2546
|
+
}
|
|
2547
|
+
removeHeader(e) {
|
|
2548
|
+
if (this.headersSent) throw Error("Cannot remove headers after they are sent to the client");
|
|
2549
|
+
this._headerStore.delete(e.toLowerCase());
|
|
2550
|
+
}
|
|
2551
|
+
_storeHeader(e) {
|
|
2552
|
+
let t = this.hasHeader("content-length"), n = this.getHeader("transfer-encoding");
|
|
2553
|
+
typeof n == "string" && n.toLowerCase().includes("chunked") ? this.chunkedEncoding = !0 : !t && this._shouldSendBody() && (this.chunkedEncoding = !0, this.setHeader("Transfer-Encoding", "chunked"));
|
|
2554
|
+
let r = e + "\r\n";
|
|
2555
|
+
for (let [e, t] of this._headerStore.values()) if (Array.isArray(t)) for (let n of t) r += `${e}: ${n}\r\n`;
|
|
2556
|
+
else r += `${e}: ${t}\r\n`;
|
|
2557
|
+
return r += "\r\n", r;
|
|
2558
|
+
}
|
|
2559
|
+
_writeToSocket(e, t) {
|
|
2560
|
+
if (!this.socket) {
|
|
2561
|
+
t(/* @__PURE__ */ Error("Socket is not available"));
|
|
2562
|
+
return;
|
|
2563
|
+
}
|
|
2564
|
+
this.socket.write(e, t);
|
|
2565
|
+
}
|
|
2566
|
+
write(e, t, n) {
|
|
2567
|
+
return this._bodyWritten = !0, super.write(e, t, n);
|
|
2568
|
+
}
|
|
2569
|
+
_write(e, t, n) {
|
|
2570
|
+
let r = hi(e), i = [];
|
|
2571
|
+
if (this.headersSent ||= (this._implicitHeader(), i.push(C.from(this._headBlock, "latin1")), !0), this.chunkedEncoding ? r.length > 0 && (i.push(C.from(`${r.length.toString(16)}\r\n`, "latin1")), i.push(r), i.push(C.from("\r\n", "latin1"))) : i.push(r), i.length === 0) {
|
|
2572
|
+
n();
|
|
2573
|
+
return;
|
|
2574
|
+
}
|
|
2575
|
+
this._writeToSocket(C.concat(i), n);
|
|
2576
|
+
}
|
|
2577
|
+
_final(e) {
|
|
2578
|
+
let t = [];
|
|
2579
|
+
if (this.headersSent ||= (!this.chunkedEncoding && !this.hasHeader("content-length") && this.setHeader("Content-Length", 0), this._implicitHeader(), t.push(C.from(this._headBlock, "latin1")), !0), this.chunkedEncoding && t.push(C.from("0\r\n\r\n", "latin1")), this.finished = !0, t.length === 0) {
|
|
2580
|
+
e();
|
|
2581
|
+
return;
|
|
2582
|
+
}
|
|
2583
|
+
this._writeToSocket(C.concat(t), e);
|
|
2584
|
+
}
|
|
2585
|
+
end(e, t, n) {
|
|
2586
|
+
if (e != null && typeof e != "function" && !this._bodyWritten && !this.headersSent && !this.chunkedEncoding && !this.hasHeader("content-length")) {
|
|
2587
|
+
let n = typeof t == "string" ? t : void 0;
|
|
2588
|
+
this.setHeader("Content-Length", hi(e, n).length);
|
|
2589
|
+
}
|
|
2590
|
+
return super.end(e, t, n);
|
|
2591
|
+
}
|
|
2592
|
+
_headBlock;
|
|
2593
|
+
}, vi = class extends _i {
|
|
2594
|
+
statusCode = 200;
|
|
2595
|
+
statusMessage;
|
|
2596
|
+
_writeHeadCalled = !1;
|
|
2597
|
+
sendDate = !0;
|
|
2598
|
+
req;
|
|
2599
|
+
socket;
|
|
2600
|
+
_keepAlive = !0;
|
|
2601
|
+
constructor(e) {
|
|
2602
|
+
super(), this.req = e, this.socket = e.socket;
|
|
2603
|
+
}
|
|
2604
|
+
_shouldSendBody() {
|
|
2605
|
+
if (this.req.method === "HEAD") return !1;
|
|
2606
|
+
let e = this.statusCode;
|
|
2607
|
+
return !(e >= 100 && e < 200 || e === 204 || e === 304);
|
|
2608
|
+
}
|
|
2609
|
+
writeHead(e, t, n) {
|
|
2610
|
+
if (this._writeHeadCalled || this.headersSent) throw ui(/* @__PURE__ */ Error("Cannot render headers after they are sent to the client"), "ERR_HTTP_HEADERS_SENT");
|
|
2611
|
+
this._writeHeadCalled = !0, this.statusCode = e;
|
|
2612
|
+
let r = n;
|
|
2613
|
+
if (typeof t == "string" ? this.statusMessage = t : t != null && (r = t), Array.isArray(r)) {
|
|
2614
|
+
let e = Array.isArray(r[0]) ? r : Array.from({ length: Math.floor(r.length / 2) }, (e, t) => [r[t * 2], r[t * 2 + 1]]);
|
|
2615
|
+
for (let [t, n] of e) n !== void 0 && this._appendHeader(t, n);
|
|
2616
|
+
} else if (r) for (let [e, t] of Object.entries(r)) t !== void 0 && this.setHeader(e, t);
|
|
2617
|
+
return this;
|
|
2618
|
+
}
|
|
2619
|
+
_appendHeader(e, t) {
|
|
2620
|
+
let n = this.getHeader(e);
|
|
2621
|
+
if (n === void 0) this.setHeader(e, t);
|
|
2622
|
+
else {
|
|
2623
|
+
let r = [...Array.isArray(n) ? n : [n], ...Array.isArray(t) ? t : [t]].map(String);
|
|
2624
|
+
this.setHeader(e, r);
|
|
2625
|
+
}
|
|
2626
|
+
}
|
|
2627
|
+
_implicitHeader() {
|
|
2628
|
+
let e = this.statusMessage ?? ai[this.statusCode] ?? "unknown";
|
|
2629
|
+
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}`);
|
|
2630
|
+
}
|
|
2631
|
+
writeContinue() {
|
|
2632
|
+
this._writeToSocket(C.from("HTTP/1.1 100 Continue\r\n\r\n", "latin1"), () => {});
|
|
2633
|
+
}
|
|
2634
|
+
setTimeout(e, t) {
|
|
2635
|
+
return this.socket?.setTimeout(e, t), this;
|
|
2636
|
+
}
|
|
2637
|
+
}, yi = (...e) => {
|
|
2638
|
+
let t = {}, n = {}, r, i = [...e], a = i.shift();
|
|
2639
|
+
if (typeof a == "string" || a instanceof URL) {
|
|
2640
|
+
let e = typeof a == "string" ? new URL(a) : a;
|
|
2641
|
+
t = {
|
|
2642
|
+
protocol: e.protocol,
|
|
2643
|
+
hostname: e.hostname,
|
|
2644
|
+
host: e.hostname,
|
|
2645
|
+
port: e.port,
|
|
2646
|
+
path: `${e.pathname}${e.search}`,
|
|
2647
|
+
auth: e.username ? `${e.username}:${e.password}` : void 0
|
|
2648
|
+
};
|
|
2649
|
+
let o = i.shift();
|
|
2650
|
+
typeof o == "function" ? r = o : o && typeof o == "object" && (n = o, r = i.shift());
|
|
2651
|
+
} else a && typeof a == "object" && (n = a, r = i.shift());
|
|
603
2652
|
return {
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
|
|
2653
|
+
options: {
|
|
2654
|
+
...t,
|
|
2655
|
+
...n
|
|
2656
|
+
},
|
|
2657
|
+
callback: r
|
|
607
2658
|
};
|
|
2659
|
+
}, bi = class extends _i {
|
|
2660
|
+
method;
|
|
2661
|
+
path;
|
|
2662
|
+
host;
|
|
2663
|
+
protocol;
|
|
2664
|
+
socket;
|
|
2665
|
+
get connection() {
|
|
2666
|
+
return this.socket;
|
|
2667
|
+
}
|
|
2668
|
+
res = null;
|
|
2669
|
+
aborted = !1;
|
|
2670
|
+
_aborted = !1;
|
|
2671
|
+
constructor(e, t) {
|
|
2672
|
+
super(), this.method = (e.method ?? "GET").toUpperCase(), this.path = e.path ?? "/", this.protocol = e.protocol ?? "http:";
|
|
2673
|
+
let n = e.hostname ?? e.host ?? "localhost";
|
|
2674
|
+
this.host = n;
|
|
2675
|
+
let r = Number(e.port ?? (this.protocol === "https:" ? 443 : 80));
|
|
2676
|
+
if (t && this.once("response", t), e.headers) for (let [t, n] of Object.entries(e.headers)) n !== void 0 && this.setHeader(t, n);
|
|
2677
|
+
if (!this.hasHeader("host")) {
|
|
2678
|
+
let e = this.protocol === "https:" && r === 443 || this.protocol !== "https:" && r === 80;
|
|
2679
|
+
this.setHeader("Host", e ? n : `${n}:${r}`);
|
|
2680
|
+
}
|
|
2681
|
+
e.auth && !this.hasHeader("authorization") && this.setHeader("Authorization", `Basic ${C.from(e.auth).toString("base64")}`), this.socket = new $(), this.emit("socket", this.socket), this.socket.on("error", (e) => {
|
|
2682
|
+
this._aborted || this.emit("error", e);
|
|
2683
|
+
}), this._attachResponseParser(), this.socket.connect({
|
|
2684
|
+
host: n,
|
|
2685
|
+
port: r
|
|
2686
|
+
}, () => {
|
|
2687
|
+
this.emit("connect");
|
|
2688
|
+
});
|
|
2689
|
+
}
|
|
2690
|
+
_shouldSendBody() {
|
|
2691
|
+
return this.method !== "GET" && this.method !== "HEAD" && this.method !== "DELETE";
|
|
2692
|
+
}
|
|
2693
|
+
_implicitHeader() {
|
|
2694
|
+
this._headBlock = this._storeHeader(`${this.method} ${this.path} HTTP/1.1`);
|
|
2695
|
+
}
|
|
2696
|
+
_attachResponseParser() {
|
|
2697
|
+
let e = new gi(this.socket), t = new mi("response", {
|
|
2698
|
+
onHeaders: (n) => {
|
|
2699
|
+
e._applyHead(n), this.method === "HEAD" && (t.skipBody = !0), this.res = e, this.emit("response", e);
|
|
2700
|
+
},
|
|
2701
|
+
onBody: (t) => {
|
|
2702
|
+
e.push(C.from(t));
|
|
2703
|
+
},
|
|
2704
|
+
onComplete: () => {
|
|
2705
|
+
e.complete = !0, e.push(null);
|
|
2706
|
+
}
|
|
2707
|
+
});
|
|
2708
|
+
this.socket.on("data", (e) => {
|
|
2709
|
+
this._aborted || t.execute(e);
|
|
2710
|
+
}), this.socket.on("end", () => {
|
|
2711
|
+
t.finish();
|
|
2712
|
+
}), this.socket.on("close", () => {
|
|
2713
|
+
this.emit("close");
|
|
2714
|
+
});
|
|
2715
|
+
}
|
|
2716
|
+
abort() {
|
|
2717
|
+
this._aborted || (this._aborted = !0, this.aborted = !0, this.emit("abort"), this.socket.destroy());
|
|
2718
|
+
}
|
|
2719
|
+
destroy(e) {
|
|
2720
|
+
return this._aborted ? this : (this._aborted = !0, this.socket.destroy(e), super.destroy(e), this);
|
|
2721
|
+
}
|
|
2722
|
+
end(e, t, n) {
|
|
2723
|
+
return this._aborted ? this : super.end(e, t, n);
|
|
2724
|
+
}
|
|
2725
|
+
_writeToSocket(e, t) {
|
|
2726
|
+
if (this._aborted) {
|
|
2727
|
+
t();
|
|
2728
|
+
return;
|
|
2729
|
+
}
|
|
2730
|
+
super._writeToSocket(e, t);
|
|
2731
|
+
}
|
|
2732
|
+
setTimeout(e, t) {
|
|
2733
|
+
return this.socket.setTimeout(e, t), this;
|
|
2734
|
+
}
|
|
2735
|
+
setNoDelay(e) {
|
|
2736
|
+
this.socket.setNoDelay(e);
|
|
2737
|
+
}
|
|
2738
|
+
setSocketKeepAlive(e, t) {
|
|
2739
|
+
this.socket.setKeepAlive(e, t);
|
|
2740
|
+
}
|
|
2741
|
+
}, xi = new Proxy(class extends Kr {
|
|
2742
|
+
constructor(e, t) {
|
|
2743
|
+
let n = {}, r = t;
|
|
2744
|
+
typeof e == "function" ? r = e : e && (n = e), super(n), r && this.on("request", r), this.on("connection", (e) => this._handleConnection(e));
|
|
2745
|
+
}
|
|
2746
|
+
_handleConnection(e) {
|
|
2747
|
+
let t = null, n = new mi("request", {
|
|
2748
|
+
onHeaders: (r) => {
|
|
2749
|
+
t = new gi(e), t._applyHead(r), r.method === "HEAD" && (n.skipBody = !0);
|
|
2750
|
+
let i = new vi(t), a = String(r.headers.connection ?? "").toLowerCase();
|
|
2751
|
+
i._keepAlive = r.httpVersionMinor >= 1 ? a !== "close" : a === "keep-alive", i.on("finish", () => {
|
|
2752
|
+
i._keepAlive || e.end();
|
|
2753
|
+
}), this.emit("request", t, i);
|
|
2754
|
+
},
|
|
2755
|
+
onBody: (e) => {
|
|
2756
|
+
t?.push(C.from(e));
|
|
2757
|
+
},
|
|
2758
|
+
onComplete: () => {
|
|
2759
|
+
t && (t.complete = !0, t.push(null)), t = null;
|
|
2760
|
+
}
|
|
2761
|
+
});
|
|
2762
|
+
e.on("data", (e) => n.execute(e)), e.on("end", () => {
|
|
2763
|
+
n.finish(), t && t.push(null);
|
|
2764
|
+
}), e.on("error", (t) => this.emit("clientError", t, e));
|
|
2765
|
+
}
|
|
2766
|
+
}, { apply: (e, t, n) => new e(...n) }), Si = class {
|
|
2767
|
+
maxSockets;
|
|
2768
|
+
maxFreeSockets;
|
|
2769
|
+
keepAlive;
|
|
2770
|
+
options;
|
|
2771
|
+
constructor(e = {}) {
|
|
2772
|
+
this.options = e, this.keepAlive = !!e.keepAlive, this.maxSockets = e.maxSockets ?? Infinity, this.maxFreeSockets = e.maxFreeSockets ?? 256;
|
|
2773
|
+
}
|
|
2774
|
+
getName(e = {}) {
|
|
2775
|
+
return `${e.host ?? "localhost"}:${e.port ?? ""}:${e.localAddress ?? ""}`;
|
|
2776
|
+
}
|
|
2777
|
+
destroy() {}
|
|
2778
|
+
}, Ci = new Si(), wi = (...e) => {
|
|
2779
|
+
let { options: t, callback: n } = yi(...e);
|
|
2780
|
+
return new bi(t, n);
|
|
2781
|
+
}, Ti = (...e) => {
|
|
2782
|
+
let t = wi(...e);
|
|
2783
|
+
return t.end(), t;
|
|
2784
|
+
}, Ei = (e, t) => new xi(e, t), Di = {
|
|
2785
|
+
METHODS: ii,
|
|
2786
|
+
STATUS_CODES: ai,
|
|
2787
|
+
Agent: Si,
|
|
2788
|
+
globalAgent: Ci,
|
|
2789
|
+
Server: xi,
|
|
2790
|
+
ServerResponse: vi,
|
|
2791
|
+
IncomingMessage: gi,
|
|
2792
|
+
ClientRequest: bi,
|
|
2793
|
+
OutgoingMessage: _i,
|
|
2794
|
+
createServer: Ei,
|
|
2795
|
+
request: wi,
|
|
2796
|
+
get: Ti
|
|
608
2797
|
};
|
|
609
2798
|
//#endregion
|
|
610
|
-
export {
|
|
2799
|
+
export { Ae as ATTACH_FRAME_EVENT_KEY, Ne as attachFrame, je as attachFramePermission, l as box, ae as changeIframeStyle, Or as clearPremiumTokens, Ee as cookies, Dr as countPremiumTokens, e as createVideoElementHandle, Zr as dgram, D as extension, we as fetch, xe as fetchCredentialedPermission, be as fetchPermission, Me as gotoPermission, i as handleRevivableModules, ni as http, O as isExtensionExposed, t as isType, De as modifyRequestHeadersPermission, Gr as net, Pe as permissions, Fe as promptInstall, Te as readCookiePermission, Lr as refillPremiumTokens, pe as relayWorker, ke as removeRequestHeaderRule, oe as resetIframeStyle, o as revive, de as serverProxyFetch, _e as setMissingExtensionHandler, Oe as setRequestHeaderRule, Sr as storage, a as type, ve as waitForExtensionExposure };
|