@fkn/lib 0.9.20 → 0.9.21
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/account.cjs +1 -1
- package/account.js +24 -17
- package/{api-CyWF0RUj.d.ts → api-B0qRPCcX.d.ts} +8 -0
- package/api-BqRjtWm_.js +311 -0
- package/api-CKO3Hw-O.cjs +3 -0
- package/busy-Bp1E3JPT.js +24 -0
- package/busy-Dv8wzE5M.cjs +1 -0
- package/cloud/dgram.cjs +1 -1
- package/cloud/dgram.js +1 -1
- package/cloud/fetch.cjs +1 -1
- package/cloud/fetch.d.ts +1 -1
- package/cloud/fetch.js +1 -1
- package/cloud/fs.cjs +1 -1
- package/cloud/fs.js +2 -2
- package/cloud/net.cjs +1 -1
- package/cloud/net.d.ts +1 -1
- package/cloud/net.js +1 -1
- package/cloud-BCQTex58.cjs +1 -0
- package/{cloud-CQVtRvcI.d.ts → cloud-BTpJn4jy.d.ts} +2 -2
- package/{cloud-C_1Dt_tR.js → cloud-BlR1He17.js} +77 -74
- package/cloud.cjs +1 -1
- package/cloud.d.ts +3 -3
- package/cloud.js +4 -4
- package/dgram-9hn582qO.cjs +1 -0
- package/{dgram-DlGl_ho1.js → dgram-TB03kqMr.js} +55 -49
- package/dgram.cjs +1 -1
- package/dgram.d.ts +2 -1
- package/dgram.js +1 -1
- package/dns.cjs +1 -1
- package/dns.js +1 -1
- package/{extension-jRuNpBs3.js → extension-BI2NxGtC.js} +2 -2
- package/{extension-B3nD2u7c.cjs → extension-rFQQpEqJ.cjs} +1 -1
- package/extension.cjs +1 -1
- package/extension.js +1 -1
- package/fs/promises.cjs +1 -1
- package/fs/promises.js +1 -1
- package/fs-BUcpl9k4.cjs +1 -0
- package/fs-bpb3Ysdd.js +347 -0
- package/fs.cjs +1 -1
- package/fs.js +1 -1
- package/http.cjs +1 -1
- package/http.d.ts +1 -1
- package/http.js +1 -1
- package/index.cjs +1 -1
- package/index.d.ts +9 -15
- package/index.js +86 -33
- package/net-C2fIMWFr.cjs +1 -0
- package/{net-ByL9yG7X.d.ts → net-CnYxw_sB.d.ts} +3 -1
- package/{net-BbmQeMpt.js → net-Ct8ywVAk.js} +52 -41
- package/net.cjs +1 -1
- package/net.d.ts +1 -1
- package/net.js +1 -1
- package/node-fs-BZCQUmeE.js +404 -0
- package/node-fs-DZPGCYWg.cjs +1 -0
- package/opfs.cjs +1 -1
- package/opfs.js +1 -1
- package/package.json +1 -1
- package/packages.cjs +1 -1
- package/packages.js +165 -149
- package/proxy--aljNHvG.js +69 -0
- package/{proxy-RU8sbq68.d.ts → proxy-CuXtzxSQ.d.ts} +1 -1
- package/proxy-oHfEx1cn.cjs +1 -0
- package/{storage-C8hBot2f.js → storage-C1nW5Tvh.js} +1 -1
- package/{storage-BW-jDLUL.cjs → storage-rXHvV2FU.cjs} +1 -1
- package/api-DQ-V4Lls.js +0 -220
- package/api-kHMHDGar.cjs +0 -3
- package/cloud-C8jfO0iJ.cjs +0 -1
- package/dgram-D2Or5f2e.cjs +0 -1
- package/fs-BW5mVMmu.js +0 -340
- package/fs-DJm0bhjg.cjs +0 -1
- package/net-COzDDBnS.cjs +0 -1
- package/node-fs-BMR2yCEt.cjs +0 -1
- package/node-fs-DKfokOlh.js +0 -401
- package/proxy-B0gNjT8-.cjs +0 -1
- package/proxy-BpqvCJmA.js +0 -43
|
@@ -1,40 +1,41 @@
|
|
|
1
1
|
import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
|
|
2
2
|
import { R as t, _ as n, a as r, f as i, m as a, s as o } from "./lib-k3lstfa4.js";
|
|
3
|
-
import {
|
|
4
|
-
import { t as l } from "./
|
|
5
|
-
import { t as u } from "./
|
|
6
|
-
import { t as d } from "./
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
3
|
+
import { o as s, r as c } from "./api-BqRjtWm_.js";
|
|
4
|
+
import { t as l } from "./busy-Bp1E3JPT.js";
|
|
5
|
+
import { t as u } from "./proxy--aljNHvG.js";
|
|
6
|
+
import { t as d } from "./dns.js";
|
|
7
|
+
import { t as f } from "./cloud/fs.js";
|
|
8
|
+
import { s as p } from "./net-Ct8ywVAk.js";
|
|
9
|
+
import { i as m } from "./dgram-TB03kqMr.js";
|
|
10
|
+
import { t as h } from "./http.js";
|
|
11
|
+
import { expose as g } from "osra";
|
|
11
12
|
//#region node_modules/@mfkn/web-extension/lib/lib/locator-permissions.js
|
|
12
|
-
var
|
|
13
|
+
var _ = {
|
|
13
14
|
scope: "frame.fetchRead",
|
|
14
15
|
category: "network",
|
|
15
16
|
severity: 3,
|
|
16
17
|
unsafe: !0,
|
|
17
18
|
title: "Read your account data on this site",
|
|
18
19
|
description: "Lets the app read pages and data from this site as you, using the session in the frame."
|
|
19
|
-
},
|
|
20
|
+
}, v = {
|
|
20
21
|
scope: "frame.fetchWrite",
|
|
21
22
|
category: "network",
|
|
22
23
|
severity: 3,
|
|
23
24
|
unsafe: !0,
|
|
24
25
|
title: "Change your account data on this site",
|
|
25
26
|
description: "Lets the app send changes to this site as you, using the session in the frame."
|
|
26
|
-
},
|
|
27
|
+
}, y = /* @__PURE__ */ new Set([
|
|
27
28
|
"GET",
|
|
28
29
|
"HEAD",
|
|
29
30
|
"OPTIONS"
|
|
30
|
-
]),
|
|
31
|
+
]), b = (e, t) => y.has((t?.method ?? "GET").toUpperCase()) ? _ : v, x = (e) => {
|
|
31
32
|
let t = [];
|
|
32
33
|
for (let n of e) {
|
|
33
34
|
let e = n.trim().toLowerCase();
|
|
34
35
|
!e || e.length > 253 || /^[a-z0-9]([a-z0-9-]*[a-z0-9])?(\.[a-z0-9]([a-z0-9-]*[a-z0-9])?)*$/.test(e) && (t.includes(e) || t.push(e));
|
|
35
36
|
}
|
|
36
37
|
return t;
|
|
37
|
-
},
|
|
38
|
+
}, S = (e, t) => {
|
|
38
39
|
if (!e.session) return {
|
|
39
40
|
kind: "refuse",
|
|
40
41
|
reason: "frame.fetch on the cloud backend needs its own session: attach with syncCookies: false"
|
|
@@ -66,15 +67,15 @@ var g = {
|
|
|
66
67
|
targetHost: n.hostname,
|
|
67
68
|
promptHosts: r
|
|
68
69
|
};
|
|
69
|
-
},
|
|
70
|
-
let r = new URL("/attach-frame",
|
|
70
|
+
}, C = (e) => e, w = "autoplay; fullscreen; encrypted-media; picture-in-picture; clipboard-read; clipboard-write", T = 2e4, E = 65e3, D = 3e4, O = 5e3, k = /* @__PURE__ */ new Set([]), A = () => "https://fkn.app", j = (e) => !e || e === "about:blank", M = (e) => e ? "" : `incognito-${crypto.randomUUID()}`, N = ({ target: e, session: t, domains: n }) => {
|
|
71
|
+
let r = new URL("/attach-frame", A());
|
|
71
72
|
return e && r.searchParams.set("url", e), t && r.searchParams.set("session", t), n.length && r.searchParams.set("domains", n.join(",")), r.href;
|
|
72
|
-
},
|
|
73
|
+
}, P = (e, t, n) => {
|
|
73
74
|
let r, i = new Promise((e, i) => {
|
|
74
75
|
r = setTimeout(() => i(Error(n)), t);
|
|
75
76
|
});
|
|
76
77
|
return Promise.race([e, i]).finally(() => clearTimeout(r));
|
|
77
|
-
},
|
|
78
|
+
}, F = (e, t) => {
|
|
78
79
|
let n = () => {
|
|
79
80
|
a(), t();
|
|
80
81
|
}, r = e.parentNode, i = new MutationObserver(() => {
|
|
@@ -83,14 +84,14 @@ var g = {
|
|
|
83
84
|
window.removeEventListener("pagehide", n), i.disconnect();
|
|
84
85
|
};
|
|
85
86
|
window.addEventListener("pagehide", n, { once: !0 }), r && i.observe(r, { childList: !0 }), e.isConnected || (a(), t());
|
|
86
|
-
},
|
|
87
|
+
}, I = () => Object.assign(/* @__PURE__ */ Error("cloud.attachFrame: the attached iframe left the document or was reloaded; attach a fresh iframe"), { name: a }), L = (e, t) => {
|
|
87
88
|
let n = [...e.split(";"), ...t.split(";")].map((e) => e.trim()).filter(Boolean);
|
|
88
89
|
return [...new Set(n)].join("; ");
|
|
89
|
-
},
|
|
90
|
+
}, R = [
|
|
90
91
|
300,
|
|
91
92
|
1200,
|
|
92
93
|
4e3
|
|
93
|
-
],
|
|
94
|
+
], z = (e) => {
|
|
94
95
|
let t = () => {
|
|
95
96
|
if (!e.isConnected) return;
|
|
96
97
|
let t = e.style.height, n = e.getBoundingClientRect();
|
|
@@ -99,90 +100,92 @@ var g = {
|
|
|
99
100
|
}, 50));
|
|
100
101
|
};
|
|
101
102
|
t();
|
|
102
|
-
for (let e of
|
|
103
|
-
},
|
|
103
|
+
for (let e of R) setTimeout(t, e);
|
|
104
|
+
}, B = (e) => {
|
|
104
105
|
let t = e.getAttribute("sandbox");
|
|
105
106
|
if (t === null) return;
|
|
106
107
|
let n = new Set(t.toLowerCase().split(/\s+/).filter(Boolean)), r = ["allow-scripts", "allow-same-origin"].filter((e) => !n.has(e));
|
|
107
108
|
if (r.length) throw Error(`cloud.attachFrame: the iframe's sandbox attribute must include ${r.join(" and ")} for the render proxy to load`);
|
|
108
|
-
},
|
|
109
|
+
}, V = async ({ iframe: e, domains: a = [], syncCookies: s = !0, lockdown: u = !1 }) => {
|
|
109
110
|
if (typeof window > "u") throw Error("cloud.attachFrame needs a window realm");
|
|
110
|
-
if (
|
|
111
|
+
if (u) throw Error("cloud.attachFrame does not support lockdown; use the extension backend for a sealed frame");
|
|
111
112
|
if (!e.isConnected) throw Error("cloud.attachFrame: the iframe must be connected to the document before attaching");
|
|
112
|
-
|
|
113
|
-
let
|
|
114
|
-
if (
|
|
113
|
+
B(e);
|
|
114
|
+
let d = e.getAttribute("src") ?? "", f = (() => {
|
|
115
|
+
if (j(d)) return null;
|
|
115
116
|
try {
|
|
116
|
-
return new URL(e.src ||
|
|
117
|
+
return new URL(e.src || d, location.href);
|
|
117
118
|
} catch {
|
|
118
|
-
throw Error(`cloud.attachFrame: the iframe src is not a valid URL: ${
|
|
119
|
+
throw Error(`cloud.attachFrame: the iframe src is not a valid URL: ${d}`);
|
|
119
120
|
}
|
|
120
121
|
})();
|
|
121
|
-
if (
|
|
122
|
-
let e = new URL("/attach-frame",
|
|
123
|
-
if (
|
|
122
|
+
if (f) {
|
|
123
|
+
let e = new URL("/attach-frame", A());
|
|
124
|
+
if (f.origin === e.origin && f.pathname === e.pathname) throw Error("cloud.attachFrame: this iframe is already attached; navigate with the Frame returned by that attach or use a fresh iframe");
|
|
124
125
|
}
|
|
125
|
-
let
|
|
126
|
-
|
|
127
|
-
let
|
|
126
|
+
let p = f?.href ?? "";
|
|
127
|
+
p && o(p);
|
|
128
|
+
let m = p, h = M(s), _ = x(a), v = /* @__PURE__ */ new Set();
|
|
128
129
|
try {
|
|
129
|
-
|
|
130
|
+
v.add(new URL(p).origin);
|
|
130
131
|
} catch {}
|
|
131
|
-
let
|
|
132
|
-
if (e.referrerPolicy = "origin", e.allow =
|
|
133
|
-
target:
|
|
134
|
-
session:
|
|
135
|
-
domains:
|
|
132
|
+
let y = new AbortController(), R = e.referrerPolicy, V = e.allow;
|
|
133
|
+
if (e.referrerPolicy = "origin", e.allow = L(w, e.allow), e.src = N({
|
|
134
|
+
target: p,
|
|
135
|
+
session: h,
|
|
136
|
+
domains: _
|
|
136
137
|
}), !e.contentWindow) throw Error("cloud.attachFrame: the iframe window is not available");
|
|
137
138
|
try {
|
|
138
|
-
let a = await
|
|
139
|
+
let a = await P(g({}, {
|
|
139
140
|
key: "fkn-attach-frame",
|
|
140
|
-
origin:
|
|
141
|
+
origin: A(),
|
|
141
142
|
transport: {
|
|
142
143
|
receive: window,
|
|
143
144
|
emit: e.contentWindow
|
|
144
145
|
},
|
|
145
|
-
unregisterSignal:
|
|
146
|
-
revivableModules:
|
|
147
|
-
}),
|
|
148
|
-
await
|
|
149
|
-
let o =
|
|
150
|
-
|
|
146
|
+
unregisterSignal: y.signal,
|
|
147
|
+
revivableModules: C(t)
|
|
148
|
+
}), T, "cloud.attachFrame: timed out connecting to the render proxy page");
|
|
149
|
+
await P(a.ready(), E, "cloud.attachFrame: the render proxy never became ready"), p && z(e), F(e, () => y.abort());
|
|
150
|
+
let o = l("attached frame");
|
|
151
|
+
y.signal.aborted ? o() : y.signal.addEventListener("abort", o, { once: !0 });
|
|
152
|
+
let s = e.contentWindow, u = () => {
|
|
153
|
+
if (!(!y.signal.aborted && e.isConnected && e.contentWindow === s)) throw y.abort(), I();
|
|
151
154
|
};
|
|
152
155
|
return r({
|
|
153
156
|
executor: {
|
|
154
|
-
execute: (e, t, n) =>
|
|
157
|
+
execute: (e, t, n) => k.has(t) ? Promise.reject(i(t, "cloud")) : (u(), a.executeLocator(e, t, n)),
|
|
155
158
|
highlight: async () => {}
|
|
156
159
|
},
|
|
157
160
|
gate: async (e) => {
|
|
158
161
|
if (e.operation !== "fetch") return;
|
|
159
|
-
let t =
|
|
160
|
-
session:
|
|
161
|
-
declaredHosts:
|
|
162
|
-
approvedOrigins:
|
|
162
|
+
let t = S({
|
|
163
|
+
session: h,
|
|
164
|
+
declaredHosts: _,
|
|
165
|
+
approvedOrigins: v
|
|
163
166
|
}, e.args[0]);
|
|
164
167
|
if (t.kind === "refuse") throw n(t.reason, "fetch");
|
|
165
168
|
if (!await (await c).frameConsent.ensure({
|
|
166
|
-
scope:
|
|
169
|
+
scope: b(e.args[0], e.args[1]).scope,
|
|
167
170
|
hosts: t.promptHosts
|
|
168
171
|
})) throw n("frame.fetch: the user did not grant this", "fetch");
|
|
169
172
|
},
|
|
170
173
|
goto: async (t, n = {}) => {
|
|
171
174
|
let r = new URL(t, location.href).href;
|
|
172
|
-
|
|
175
|
+
u();
|
|
173
176
|
let { timeoutMs: i } = n;
|
|
174
|
-
await
|
|
177
|
+
await P(a.goto(r, n), (i ?? D) + O, "cloud.attachFrame: the render proxy did not answer goto; the frame may have been detached or its page reloaded"), m = r;
|
|
175
178
|
try {
|
|
176
|
-
|
|
179
|
+
v.add(new URL(r).origin);
|
|
177
180
|
} catch {}
|
|
178
|
-
|
|
181
|
+
z(e);
|
|
179
182
|
},
|
|
180
|
-
url: () =>
|
|
183
|
+
url: () => m
|
|
181
184
|
});
|
|
182
185
|
} catch (t) {
|
|
183
|
-
throw
|
|
186
|
+
throw y.abort(), e.referrerPolicy = R, e.allow = V, e.src = p || "about:blank", t;
|
|
184
187
|
}
|
|
185
|
-
},
|
|
188
|
+
}, H = () => typeof window < "u" && !0, U = async () => {
|
|
186
189
|
let e = await c.then((e) => e.cloud.quota());
|
|
187
190
|
return {
|
|
188
191
|
premium: e.premium,
|
|
@@ -194,16 +197,16 @@ var g = {
|
|
|
194
197
|
bytesPerSecond: e.bytesPerSecond,
|
|
195
198
|
bitsPerSecond: e.bytesPerSecond * 8
|
|
196
199
|
};
|
|
197
|
-
},
|
|
198
|
-
attachFrame: () =>
|
|
199
|
-
available: () =>
|
|
200
|
-
dgram: () =>
|
|
201
|
-
dns: () =>
|
|
202
|
-
fetch: () =>
|
|
203
|
-
fs: () =>
|
|
204
|
-
http: () =>
|
|
205
|
-
net: () =>
|
|
206
|
-
quota: () =>
|
|
207
|
-
}),
|
|
200
|
+
}, W = /* @__PURE__ */ e({
|
|
201
|
+
attachFrame: () => V,
|
|
202
|
+
available: () => G,
|
|
203
|
+
dgram: () => m,
|
|
204
|
+
dns: () => d,
|
|
205
|
+
fetch: () => u,
|
|
206
|
+
fs: () => f,
|
|
207
|
+
http: () => h,
|
|
208
|
+
net: () => p,
|
|
209
|
+
quota: () => U
|
|
210
|
+
}), G = () => s;
|
|
208
211
|
//#endregion
|
|
209
|
-
export {
|
|
212
|
+
export { H as a, V as i, W as n, U as r, G as t };
|
package/cloud.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./proxy-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./proxy-oHfEx1cn.cjs"),t=require("./cloud-BCQTex58.cjs"),n=require("./dns.cjs"),r=require("./cloud/fs.cjs"),i=require("./net-C2fIMWFr.cjs"),a=require("./dgram-9hn582qO.cjs"),o=require("./http.cjs");exports.attachFrame=t.i,exports.available=t.t,Object.defineProperty(exports,"dgram",{enumerable:!0,get:function(){return a.i}}),Object.defineProperty(exports,"dns",{enumerable:!0,get:function(){return n.t}}),exports.fetch=e.t,Object.defineProperty(exports,"fs",{enumerable:!0,get:function(){return r.t}}),Object.defineProperty(exports,"http",{enumerable:!0,get:function(){return o.t}}),Object.defineProperty(exports,"net",{enumerable:!0,get:function(){return i.s}}),exports.quota=t.r;
|
package/cloud.d.ts
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { t as cloudFetch } from "./proxy-
|
|
2
|
-
import { a as attachFrame, i as quota, r as QuotaStatus, t as available } from "./cloud-
|
|
1
|
+
import { t as cloudFetch } from "./proxy-CuXtzxSQ.js";
|
|
2
|
+
import { a as attachFrame, i as quota, r as QuotaStatus, t as available } from "./cloud-BTpJn4jy.js";
|
|
3
3
|
import { t as dns_d_exports } from "./dns.js";
|
|
4
4
|
import { n as fs_d_exports } from "./fs-CUmugp10.js";
|
|
5
|
-
import { s as net_d_exports } from "./net-
|
|
5
|
+
import { s as net_d_exports } from "./net-CnYxw_sB.js";
|
|
6
6
|
import { t as dgram_d_exports } from "./dgram.js";
|
|
7
7
|
import { t as http_d_exports } from "./http.js";
|
|
8
8
|
export { type QuotaStatus, attachFrame, available, dgram_d_exports as dgram, dns_d_exports as dns, cloudFetch as fetch, fs_d_exports as fs, http_d_exports as http, net_d_exports as net, quota };
|
package/cloud.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { t as e } from "./proxy
|
|
2
|
-
import { i as t, r as n, t as r } from "./cloud-
|
|
1
|
+
import { t as e } from "./proxy--aljNHvG.js";
|
|
2
|
+
import { i as t, r as n, t as r } from "./cloud-BlR1He17.js";
|
|
3
3
|
import { t as i } from "./dns.js";
|
|
4
4
|
import { t as a } from "./cloud/fs.js";
|
|
5
|
-
import { s as o } from "./net-
|
|
6
|
-
import { i as s } from "./dgram-
|
|
5
|
+
import { s as o } from "./net-Ct8ywVAk.js";
|
|
6
|
+
import { i as s } from "./dgram-TB03kqMr.js";
|
|
7
7
|
import { t as c } from "./http.js";
|
|
8
8
|
export { t as attachFrame, r as available, s as dgram, i as dns, e as fetch, a as fs, c as http, o as net, n as quota };
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./api-CKO3Hw-O.cjs"),n=require("./busy-Dv8wzE5M.cjs"),r=require("./utils-QfNXtEhb.cjs");let i=require("buffer"),a=require("events"),o=require("ip-address");var s=e.t({Socket:()=>c,createSocket:()=>m,default:()=>h}),c=class extends a.EventEmitter{_type;_localAddress;_remoteAddress;_connectedLocally;_connectGeneration=0;_destroyed=!1;_busyRelease;_webVPNUdpSocketPromise;_dataPort;_socketId;_sendQueue=[];_sendQueueBytes=0;_sendFlushScheduled=!1;_peerTailCache=new Map;constructor(e){if(super(e),!e)throw Error(`Missing options`);this._type=e.type,e.connection&&this.__webvpn_udp_socket_init__(e.connection)}_lastRecvBufferSize=0;_lastSendBufferSize=0;_lastTtl=64;_lastMulticastTtl=1;_lastMulticastLoopback=!0;_setUdpOption(e){if(!this._webVPNUdpSocketPromise){this.emit(`error`,Error(`Cannot set socket option before bind`));return}this._webVPNUdpSocketPromise.then(async t=>{if(t)try{await t.setOption(e)}catch(e){this.emit(`error`,e)}})}_dataPortAcks=!1;_dataPortConsumedBytes=0;_dataPortAckedBytes=0;_ackDataPortBatch(e){if(!this._dataPortAcks||!this._dataPort||(this._dataPortConsumedBytes+=e,this._dataPortAckedBytes!==0&&this._dataPortConsumedBytes-this._dataPortAckedBytes<524288))return;this._dataPortAckedBytes=this._dataPortConsumedBytes;let t={type:r.n,consumedBytes:this._dataPortConsumedBytes};this._dataPort.postMessage(t)}_onTransportClosed(e){this._destroyed||(this._destroyed=!0,this._busyRelease?.(),this._dataPort?.close(),this._dataPort=void 0,this.listenerCount(`error`)>0&&this.emit(`error`,Error(e||`WebVPN session closed`)),this.emit(`close`))}_onDataPortBatch(e){let t=new DataView(e),n=!1,r,a=0;for(;a+4<=e.byteLength;){let o=t.getUint32(a);a+=4;let s=a+o;if(s>e.byteLength)break;let c=a+4,l=t.getUint8(c);c+=1;let u,d,p;if(l===2){if(!this._remoteAddress){a=s;continue}u=this._remoteAddress.address,d=this._remoteAddress.family,p=this._remoteAddress.port}else{let n=new Uint8Array(e,c,l===0?4:16);l===0?(d=`IPv4`,u=`${n[0]}.${n[1]}.${n[2]}.${n[3]}`):(d=`IPv6`,u=f(n)),c+=n.byteLength,p=t.getUint16(c),c+=2}let m=t.getUint32(c);c+=4;try{this.emit(`message`,i.Buffer.from(e.slice(c,c+m)),{address:u,family:d,port:p,size:m})}catch(e){n||(n=!0,r=e)}a=s}if(n)throw r}_peerTail(e,t){if(e===void 0||t===void 0)return l;let n=`${e}|${t}`,r=this._peerTailCache.get(n);if(r)return r;let i=o.Address4.isValid(e)?d(e):p(e),a=new Uint8Array(1+i.byteLength+2);return a[0]=i.byteLength===4?0:1,a.set(i,1),new DataView(a.buffer).setUint16(1+i.byteLength,t),this._peerTailCache.size>=4096&&this._peerTailCache.clear(),this._peerTailCache.set(n,a),a}_portSend(e,t,n){let r=this._peerTail(t,n),i=new Uint8Array(8+r.byteLength+4+e.byteLength),a=new DataView(i.buffer);a.setUint32(0,i.byteLength-4),a.setUint32(4,this._socketId),i.set(r,8),a.setUint32(8+r.byteLength,e.byteLength),i.set(e,12+r.byteLength),this._sendQueue.push(i),this._sendQueueBytes+=i.byteLength,!this._sendFlushScheduled&&(this._sendFlushScheduled=!0,queueMicrotask(()=>{this._sendFlushScheduled=!1;let e=this._sendQueue,t=this._sendQueueBytes;if(this._sendQueue=[],this._sendQueueBytes=0,!e.length||!this._dataPort)return;let n=new Uint8Array(t),r=0;for(let t of e)n.set(t,r),r+=t.byteLength;this._dataPort.postMessage(n.buffer,[n.buffer])}))}addMembership(e,t){if(o.Address4.isValid(e)){let n=d(e),r=t&&o.Address4.isValid(t)?d(t):new Uint8Array([0,0,0,0]);this._setUdpOption({type:5,group:n,interface:r})}else if(o.Address6.isValid(e)){let t=p(e);this._setUdpOption({type:7,group:t,ifIndex:0})}else this.emit(`error`,Error(`Invalid multicast address: ${e}`))}address(){if(!this._localAddress)throw Error(`EBADF`);return this._localAddress}bind(...e){let n=r.o(...e),i=this._type===`udp6`?`::`:`0.0.0.0`,a=this.__webvpn_udp_socket_init__(t.r.then(e=>e.cloud.webvpn.udpSocket({type:this._type,address:n.address??i,port:n.port,dataPort:!0})));return n.callback&&a.then(e=>{e&&n.callback.call(this)}),this}__webvpn_udp_socket_init__(e,t){return t&&(this._localAddress={address:t.localAddress,family:t.localFamily,port:t.localPort}),this._busyRelease??=n.t(`udp socket`),this._webVPNUdpSocketPromise=e.then(e=>{if(e.dataPort)this._socketId=e.socketId,this._dataPort=e.dataPort,this._dataPortAcks=e.dataPortAcks===!0,this._dataPort.onmessage=e=>{try{this._onDataPortBatch(e.data)}finally{this._ackDataPortBatch(e.data.byteLength)}};else{let t=e.dataReadableStream.getReader();(async()=>{for(;;){let{value:e,done:n}=await t.read();if(n)return;this.emit(`message`,i.Buffer.from(e.data),{address:e.address,family:e.family,port:e.port,size:e.size})}})().catch(e=>this._onTransportClosed(e instanceof Error?e.message:void 0))}return e.closed?.then(e=>this._onTransportClosed(e?.reason)).catch(()=>{}),this._localAddress={address:e.localAddress,family:e.localFamily,port:e.localPort},e}).catch(e=>{this.emit(`error`,e)}),this._webVPNUdpSocketPromise.then(e=>{if(!e){this._busyRelease?.();return}this.emit(`listening`)}),this._webVPNUdpSocketPromise}close(e){if(!this._webVPNUdpSocketPromise)throw Error(`Socket not bound`);return this._webVPNUdpSocketPromise.then(async t=>{if(!t)throw Error(`Socket not bound`);let n=this._destroyed;this._destroyed=!0,this._busyRelease?.(),this._dataPort?.close(),this._dataPort=void 0;try{await t.close()}finally{try{e&&e()}finally{n||this.emit(`close`)}}}).catch(()=>{}),this}connect(...e){if(!this._webVPNUdpSocketPromise)throw Error(`Socket not bound`);this._webVPNUdpSocketPromise.then(async t=>{if(!t)throw Error(`Socket not bound`);let n=e[0],r=this._type===`udp6`?`::1`:`127.0.0.1`,i=typeof e[1]==`string`?e[1]:r,a=typeof e.at(-1)==`function`?e.at(-1):void 0,o=await t.connect({remotePort:n,remoteAddress:i});this._connectedLocally=o?.local===!0,this._remoteAddress=o?.address?{address:o.address,family:o.family,port:o.port}:{address:i,family:this._type===`udp6`?`IPv6`:`IPv4`,port:n},this._connectGeneration+=1,a&&a()}).catch(e=>{this.emit(`error`,e)})}disconnect(){if(!this._webVPNUdpSocketPromise)throw Error(`Socket not bound`);if(!this._remoteAddress)throw Error(`ERR_SOCKET_DGRAM_NOT_CONNECTED`);let e=this._remoteAddress,t=this._connectedLocally,n=this._connectGeneration;this._remoteAddress=void 0,this._connectedLocally=void 0,this._webVPNUdpSocketPromise.then(e=>e?.disconnect?.()).catch(r=>{this._connectGeneration===n&&(this._remoteAddress=e,this._connectedLocally=t),this.emit(`error`,r)})}dropMembership(e,t){if(o.Address4.isValid(e)){let n=d(e),r=t&&o.Address4.isValid(t)?d(t):new Uint8Array([0,0,0,0]);this._setUdpOption({type:6,group:n,interface:r})}else if(o.Address6.isValid(e)){let t=p(e);this._setUdpOption({type:8,group:t,ifIndex:0})}else this.emit(`error`,Error(`Invalid multicast address: ${e}`))}getRecvBufferSize(){return this._lastRecvBufferSize}getSendBufferSize(){return this._lastSendBufferSize}getSendQueueSize(){return 0}getSendQueueCount(){return 0}ref(){return this}remoteAddress(){if(!this._remoteAddress)throw Error(`ERR_SOCKET_DGRAM_NOT_CONNECTED`);return{address:this._remoteAddress.address,family:this._remoteAddress.family,port:this._remoteAddress.port}}send(...e){this._webVPNUdpSocketPromise||this.bind();let t=r.s(...e),n=u(t.message),i=n;if(t.hasRange){let{offset:e,length:r}=t;if(!Number.isInteger(e)||e<0||e>n.byteLength)throw Object.assign(RangeError(`"offset" is outside of buffer bounds`),{code:`ERR_BUFFER_OUT_OF_BOUNDS`});if(!Number.isInteger(r)||r<0||r>n.byteLength-e)throw Object.assign(RangeError(`"length" is outside of buffer bounds`),{code:`ERR_BUFFER_OUT_OF_BOUNDS`});i=n.subarray(e,e+r)}let a=this._type===`udp6`?`::1`:`127.0.0.1`;if(!this._webVPNUdpSocketPromise)throw Error(`Socket not bound`);this._webVPNUdpSocketPromise.then(e=>{if(!e)throw Error(`Socket not bound`);let n=t.callback,r=t.address??a,s=this._remoteAddress!==void 0&&t.address===void 0;if(this._dataPort&&(s||o.Address4.isValid(r)||o.Address6.isValid(r))){this._portSend(i,s?void 0:r,s?void 0:t.port),n?.call(this,null,i.byteLength);return}e.send({port:t.port,address:r,message:i.byteOffset===0&&i.byteLength===i.buffer.byteLength?i.buffer:i.buffer.slice(i.byteOffset,i.byteOffset+i.byteLength)}).then(()=>n?.call(this,null,i.byteLength),e=>n?n.call(this,e,0):this.emit(`error`,e))})}setBroadcast(e){this._setUdpOption({type:0,value:e})}setMulticastInterface(e){}setMulticastLoopback(e){return this._setUdpOption({type:3,value:e}),this._setUdpOption({type:4,value:e}),this._lastMulticastLoopback=e,e}setMulticastTTL(e){return this._setUdpOption({type:2,value:e}),this._lastMulticastTtl=e,e}setRecvBufferSize(e){this._setUdpOption({type:10,value:e}),this._lastRecvBufferSize=e}setSendBufferSize(e){this._setUdpOption({type:9,value:e}),this._lastSendBufferSize=e}setTTL(e){return this._setUdpOption({type:1,value:e}),this._lastTtl=e,e}unref(){return this}addSourceSpecificMembership(e,t,n){}dropSourceSpecificMembership(e,t,n){}async[Symbol.asyncDispose](){await new Promise(e=>{this.close(e)})}},l=new Uint8Array([2]),u=e=>{if(typeof e==`string`)return r.l.encode(e);if(e instanceof Uint8Array)return e;if(ArrayBuffer.isView(e))return new Uint8Array(e.buffer,e.byteOffset,e.byteLength);if(Array.isArray(e)){let t=e.map(u),n=new Uint8Array(t.reduce((e,t)=>e+t.byteLength,0)),r=0;for(let e of t)n.set(e,r),r+=e.byteLength;return n}return new Uint8Array(e)},d=e=>{let t=e.split(`.`).map(e=>parseInt(e,10));if(t.length!==4||t.some(e=>Number.isNaN(e)||e<0||e>255))throw Error(`Invalid IPv4 address: ${e}`);return new Uint8Array(t)},f=e=>{let t=[];for(let n=0;n<16;n+=2)t.push(e[n]<<8|e[n+1]);let n=-1,r=1;for(let e=0;e<8;){if(t[e]!==0){e++;continue}let i=e;for(;i<8&&t[i]===0;)i++;i-e>r&&(n=e,r=i-e),e=i}return n===-1?t.map(e=>e.toString(16)).join(`:`):`${t.slice(0,n).map(e=>e.toString(16)).join(`:`)}::${t.slice(n+r).map(e=>e.toString(16)).join(`:`)}`},p=e=>{let t=new o.Address6(e).getBitsBase16(0,128).match(/.{2}/g);if(!t||t.length!==16)throw Error(`Invalid IPv6 address: ${e}`);return new Uint8Array(t.map(e=>parseInt(e,16)))},m=(e,t)=>{let n=new c(typeof e==`string`?{type:e}:e);return t&&n.on(`message`,t),n},h={Socket:c,createSocket:m};Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return m}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return h}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return c}});
|
|
@@ -1,21 +1,23 @@
|
|
|
1
1
|
import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
|
|
2
|
-
import { t } from "./api-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
2
|
+
import { r as t } from "./api-BqRjtWm_.js";
|
|
3
|
+
import { t as n } from "./busy-Bp1E3JPT.js";
|
|
4
|
+
import { l as r, n as i, o as a, s as o } from "./utils-DVlbuXmW.js";
|
|
5
|
+
import { Buffer as s } from "buffer";
|
|
6
|
+
import { EventEmitter as c } from "events";
|
|
7
|
+
import { Address4 as l, Address6 as u } from "ip-address";
|
|
7
8
|
//#region src/lib/webvpn/dgram.ts
|
|
8
|
-
var
|
|
9
|
-
Socket: () =>
|
|
10
|
-
createSocket: () =>
|
|
11
|
-
default: () =>
|
|
12
|
-
}),
|
|
9
|
+
var d = /* @__PURE__ */ e({
|
|
10
|
+
Socket: () => f,
|
|
11
|
+
createSocket: () => v,
|
|
12
|
+
default: () => y
|
|
13
|
+
}), f = class extends c {
|
|
13
14
|
_type;
|
|
14
15
|
_localAddress;
|
|
15
16
|
_remoteAddress;
|
|
16
17
|
_connectedLocally;
|
|
17
18
|
_connectGeneration = 0;
|
|
18
19
|
_destroyed = !1;
|
|
20
|
+
_busyRelease;
|
|
19
21
|
_webVPNUdpSocketPromise;
|
|
20
22
|
_dataPort;
|
|
21
23
|
_socketId;
|
|
@@ -52,38 +54,38 @@ var u = /* @__PURE__ */ e({
|
|
|
52
54
|
if (!this._dataPortAcks || !this._dataPort || (this._dataPortConsumedBytes += e, this._dataPortAckedBytes !== 0 && this._dataPortConsumedBytes - this._dataPortAckedBytes < 524288)) return;
|
|
53
55
|
this._dataPortAckedBytes = this._dataPortConsumedBytes;
|
|
54
56
|
let t = {
|
|
55
|
-
type:
|
|
57
|
+
type: i,
|
|
56
58
|
consumedBytes: this._dataPortConsumedBytes
|
|
57
59
|
};
|
|
58
60
|
this._dataPort.postMessage(t);
|
|
59
61
|
}
|
|
60
62
|
_onTransportClosed(e) {
|
|
61
|
-
this._destroyed || (this._destroyed = !0, this._dataPort?.close(), this._dataPort = void 0, this.listenerCount("error") > 0 && this.emit("error", Error(e || "WebVPN session closed")), this.emit("close"));
|
|
63
|
+
this._destroyed || (this._destroyed = !0, this._busyRelease?.(), this._dataPort?.close(), this._dataPort = void 0, this.listenerCount("error") > 0 && this.emit("error", Error(e || "WebVPN session closed")), this.emit("close"));
|
|
62
64
|
}
|
|
63
65
|
_onDataPortBatch(e) {
|
|
64
66
|
let t = new DataView(e), n = !1, r, i = 0;
|
|
65
67
|
for (; i + 4 <= e.byteLength;) {
|
|
66
68
|
let a = t.getUint32(i);
|
|
67
69
|
i += 4;
|
|
68
|
-
let
|
|
69
|
-
if (
|
|
70
|
+
let o = i + a;
|
|
71
|
+
if (o > e.byteLength) break;
|
|
70
72
|
let c = i + 4, l = t.getUint8(c);
|
|
71
73
|
c += 1;
|
|
72
74
|
let u, d, f;
|
|
73
75
|
if (l === 2) {
|
|
74
76
|
if (!this._remoteAddress) {
|
|
75
|
-
i =
|
|
77
|
+
i = o;
|
|
76
78
|
continue;
|
|
77
79
|
}
|
|
78
80
|
u = this._remoteAddress.address, d = this._remoteAddress.family, f = this._remoteAddress.port;
|
|
79
81
|
} else {
|
|
80
82
|
let n = new Uint8Array(e, c, l === 0 ? 4 : 16);
|
|
81
|
-
l === 0 ? (d = "IPv4", u = `${n[0]}.${n[1]}.${n[2]}.${n[3]}`) : (d = "IPv6", u =
|
|
83
|
+
l === 0 ? (d = "IPv4", u = `${n[0]}.${n[1]}.${n[2]}.${n[3]}`) : (d = "IPv6", u = g(n)), c += n.byteLength, f = t.getUint16(c), c += 2;
|
|
82
84
|
}
|
|
83
85
|
let p = t.getUint32(c);
|
|
84
86
|
c += 4;
|
|
85
87
|
try {
|
|
86
|
-
this.emit("message",
|
|
88
|
+
this.emit("message", s.from(e.slice(c, c + p)), {
|
|
87
89
|
address: u,
|
|
88
90
|
family: d,
|
|
89
91
|
port: f,
|
|
@@ -92,15 +94,15 @@ var u = /* @__PURE__ */ e({
|
|
|
92
94
|
} catch (e) {
|
|
93
95
|
n || (n = !0, r = e);
|
|
94
96
|
}
|
|
95
|
-
i =
|
|
97
|
+
i = o;
|
|
96
98
|
}
|
|
97
99
|
if (n) throw r;
|
|
98
100
|
}
|
|
99
101
|
_peerTail(e, t) {
|
|
100
|
-
if (e === void 0 || t === void 0) return
|
|
102
|
+
if (e === void 0 || t === void 0) return p;
|
|
101
103
|
let n = `${e}|${t}`, r = this._peerTailCache.get(n);
|
|
102
104
|
if (r) return r;
|
|
103
|
-
let i =
|
|
105
|
+
let i = l.isValid(e) ? h(e) : _(e), a = new Uint8Array(1 + i.byteLength + 2);
|
|
104
106
|
return a[0] = i.byteLength === 4 ? 0 : 1, a.set(i, 1), new DataView(a.buffer).setUint16(1 + i.byteLength, t), this._peerTailCache.size >= 4096 && this._peerTailCache.clear(), this._peerTailCache.set(n, a), a;
|
|
105
107
|
}
|
|
106
108
|
_portSend(e, t, n) {
|
|
@@ -115,8 +117,8 @@ var u = /* @__PURE__ */ e({
|
|
|
115
117
|
}));
|
|
116
118
|
}
|
|
117
119
|
addMembership(e, t) {
|
|
118
|
-
if (
|
|
119
|
-
let n =
|
|
120
|
+
if (l.isValid(e)) {
|
|
121
|
+
let n = h(e), r = t && l.isValid(t) ? h(t) : new Uint8Array([
|
|
120
122
|
0,
|
|
121
123
|
0,
|
|
122
124
|
0,
|
|
@@ -127,8 +129,8 @@ var u = /* @__PURE__ */ e({
|
|
|
127
129
|
group: n,
|
|
128
130
|
interface: r
|
|
129
131
|
});
|
|
130
|
-
} else if (
|
|
131
|
-
let t =
|
|
132
|
+
} else if (u.isValid(e)) {
|
|
133
|
+
let t = _(e);
|
|
132
134
|
this._setUdpOption({
|
|
133
135
|
type: 7,
|
|
134
136
|
group: t,
|
|
@@ -141,13 +143,13 @@ var u = /* @__PURE__ */ e({
|
|
|
141
143
|
return this._localAddress;
|
|
142
144
|
}
|
|
143
145
|
bind(...e) {
|
|
144
|
-
let n =
|
|
146
|
+
let n = a(...e), r = this._type === "udp6" ? "::" : "0.0.0.0", i = this.__webvpn_udp_socket_init__(t.then((e) => e.cloud.webvpn.udpSocket({
|
|
145
147
|
type: this._type,
|
|
146
148
|
address: n.address ?? r,
|
|
147
149
|
port: n.port,
|
|
148
150
|
dataPort: !0
|
|
149
151
|
})));
|
|
150
|
-
return n.callback &&
|
|
152
|
+
return n.callback && i.then((e) => {
|
|
151
153
|
e && n.callback.call(this);
|
|
152
154
|
}), this;
|
|
153
155
|
}
|
|
@@ -156,7 +158,7 @@ var u = /* @__PURE__ */ e({
|
|
|
156
158
|
address: t.localAddress,
|
|
157
159
|
family: t.localFamily,
|
|
158
160
|
port: t.localPort
|
|
159
|
-
}), this._webVPNUdpSocketPromise = e.then((e) => {
|
|
161
|
+
}), this._busyRelease ??= n("udp socket"), this._webVPNUdpSocketPromise = e.then((e) => {
|
|
160
162
|
if (e.dataPort) this._socketId = e.socketId, this._dataPort = e.dataPort, this._dataPortAcks = e.dataPortAcks === !0, this._dataPort.onmessage = (e) => {
|
|
161
163
|
try {
|
|
162
164
|
this._onDataPortBatch(e.data);
|
|
@@ -170,7 +172,7 @@ var u = /* @__PURE__ */ e({
|
|
|
170
172
|
for (;;) {
|
|
171
173
|
let { value: e, done: n } = await t.read();
|
|
172
174
|
if (n) return;
|
|
173
|
-
this.emit("message",
|
|
175
|
+
this.emit("message", s.from(e.data), {
|
|
174
176
|
address: e.address,
|
|
175
177
|
family: e.family,
|
|
176
178
|
port: e.port,
|
|
@@ -187,7 +189,11 @@ var u = /* @__PURE__ */ e({
|
|
|
187
189
|
}).catch((e) => {
|
|
188
190
|
this.emit("error", e);
|
|
189
191
|
}), this._webVPNUdpSocketPromise.then((e) => {
|
|
190
|
-
|
|
192
|
+
if (!e) {
|
|
193
|
+
this._busyRelease?.();
|
|
194
|
+
return;
|
|
195
|
+
}
|
|
196
|
+
this.emit("listening");
|
|
191
197
|
}), this._webVPNUdpSocketPromise;
|
|
192
198
|
}
|
|
193
199
|
close(e) {
|
|
@@ -195,7 +201,7 @@ var u = /* @__PURE__ */ e({
|
|
|
195
201
|
return this._webVPNUdpSocketPromise.then(async (t) => {
|
|
196
202
|
if (!t) throw Error("Socket not bound");
|
|
197
203
|
let n = this._destroyed;
|
|
198
|
-
this._destroyed = !0, this._dataPort?.close(), this._dataPort = void 0;
|
|
204
|
+
this._destroyed = !0, this._busyRelease?.(), this._dataPort?.close(), this._dataPort = void 0;
|
|
199
205
|
try {
|
|
200
206
|
await t.close();
|
|
201
207
|
} finally {
|
|
@@ -237,8 +243,8 @@ var u = /* @__PURE__ */ e({
|
|
|
237
243
|
});
|
|
238
244
|
}
|
|
239
245
|
dropMembership(e, t) {
|
|
240
|
-
if (
|
|
241
|
-
let n =
|
|
246
|
+
if (l.isValid(e)) {
|
|
247
|
+
let n = h(e), r = t && l.isValid(t) ? h(t) : new Uint8Array([
|
|
242
248
|
0,
|
|
243
249
|
0,
|
|
244
250
|
0,
|
|
@@ -249,8 +255,8 @@ var u = /* @__PURE__ */ e({
|
|
|
249
255
|
group: n,
|
|
250
256
|
interface: r
|
|
251
257
|
});
|
|
252
|
-
} else if (
|
|
253
|
-
let t =
|
|
258
|
+
} else if (u.isValid(e)) {
|
|
259
|
+
let t = _(e);
|
|
254
260
|
this._setUdpOption({
|
|
255
261
|
type: 8,
|
|
256
262
|
group: t,
|
|
@@ -283,7 +289,7 @@ var u = /* @__PURE__ */ e({
|
|
|
283
289
|
}
|
|
284
290
|
send(...e) {
|
|
285
291
|
this._webVPNUdpSocketPromise || this.bind();
|
|
286
|
-
let t =
|
|
292
|
+
let t = o(...e), n = m(t.message), r = n;
|
|
287
293
|
if (t.hasRange) {
|
|
288
294
|
let { offset: e, length: i } = t;
|
|
289
295
|
if (!Number.isInteger(e) || e < 0 || e > n.byteLength) throw Object.assign(/* @__PURE__ */ RangeError("\"offset\" is outside of buffer bounds"), { code: "ERR_BUFFER_OUT_OF_BOUNDS" });
|
|
@@ -295,7 +301,7 @@ var u = /* @__PURE__ */ e({
|
|
|
295
301
|
this._webVPNUdpSocketPromise.then((e) => {
|
|
296
302
|
if (!e) throw Error("Socket not bound");
|
|
297
303
|
let n = t.callback, a = t.address ?? i, o = this._remoteAddress !== void 0 && t.address === void 0;
|
|
298
|
-
if (this._dataPort && (o ||
|
|
304
|
+
if (this._dataPort && (o || l.isValid(a) || u.isValid(a))) {
|
|
299
305
|
this._portSend(r, o ? void 0 : a, o ? void 0 : t.port), n?.call(this, null, r.byteLength);
|
|
300
306
|
return;
|
|
301
307
|
}
|
|
@@ -356,21 +362,21 @@ var u = /* @__PURE__ */ e({
|
|
|
356
362
|
this.close(e);
|
|
357
363
|
});
|
|
358
364
|
}
|
|
359
|
-
},
|
|
360
|
-
if (typeof e == "string") return
|
|
365
|
+
}, p = new Uint8Array([2]), m = (e) => {
|
|
366
|
+
if (typeof e == "string") return r.encode(e);
|
|
361
367
|
if (e instanceof Uint8Array) return e;
|
|
362
368
|
if (ArrayBuffer.isView(e)) return new Uint8Array(e.buffer, e.byteOffset, e.byteLength);
|
|
363
369
|
if (Array.isArray(e)) {
|
|
364
|
-
let t = e.map(
|
|
370
|
+
let t = e.map(m), n = new Uint8Array(t.reduce((e, t) => e + t.byteLength, 0)), r = 0;
|
|
365
371
|
for (let e of t) n.set(e, r), r += e.byteLength;
|
|
366
372
|
return n;
|
|
367
373
|
}
|
|
368
374
|
return new Uint8Array(e);
|
|
369
|
-
},
|
|
375
|
+
}, h = (e) => {
|
|
370
376
|
let t = e.split(".").map((e) => parseInt(e, 10));
|
|
371
377
|
if (t.length !== 4 || t.some((e) => Number.isNaN(e) || e < 0 || e > 255)) throw Error(`Invalid IPv4 address: ${e}`);
|
|
372
378
|
return new Uint8Array(t);
|
|
373
|
-
},
|
|
379
|
+
}, g = (e) => {
|
|
374
380
|
let t = [];
|
|
375
381
|
for (let n = 0; n < 16; n += 2) t.push(e[n] << 8 | e[n + 1]);
|
|
376
382
|
let n = -1, r = 1;
|
|
@@ -384,16 +390,16 @@ var u = /* @__PURE__ */ e({
|
|
|
384
390
|
i - e > r && (n = e, r = i - e), e = i;
|
|
385
391
|
}
|
|
386
392
|
return n === -1 ? t.map((e) => e.toString(16)).join(":") : `${t.slice(0, n).map((e) => e.toString(16)).join(":")}::${t.slice(n + r).map((e) => e.toString(16)).join(":")}`;
|
|
387
|
-
},
|
|
388
|
-
let t = new
|
|
393
|
+
}, _ = (e) => {
|
|
394
|
+
let t = new u(e).getBitsBase16(0, 128).match(/.{2}/g);
|
|
389
395
|
if (!t || t.length !== 16) throw Error(`Invalid IPv6 address: ${e}`);
|
|
390
396
|
return new Uint8Array(t.map((e) => parseInt(e, 16)));
|
|
391
|
-
},
|
|
392
|
-
let n = new
|
|
397
|
+
}, v = (e, t) => {
|
|
398
|
+
let n = new f(typeof e == "string" ? { type: e } : e);
|
|
393
399
|
return t && n.on("message", t), n;
|
|
394
|
-
},
|
|
395
|
-
Socket:
|
|
396
|
-
createSocket:
|
|
400
|
+
}, y = {
|
|
401
|
+
Socket: f,
|
|
402
|
+
createSocket: v
|
|
397
403
|
};
|
|
398
404
|
//#endregion
|
|
399
|
-
export {
|
|
405
|
+
export { d as i, v as n, y as r, f as t };
|
package/dgram.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./dgram-
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./dgram-9hn582qO.cjs");exports.Socket=e.t,exports.createSocket=e.n,exports.default=e.r;
|
package/dgram.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as UdpSocketOption, t as Resolvers } from "./api-
|
|
1
|
+
import { n as UdpSocketOption, t as Resolvers } from "./api-B0qRPCcX.js";
|
|
2
2
|
import { Buffer } from "buffer";
|
|
3
3
|
import { AddressInfo } from "net";
|
|
4
4
|
import { EventEmitter } from "events";
|
|
@@ -30,6 +30,7 @@ declare class Socket extends EventEmitter implements Socket$2 {
|
|
|
30
30
|
_connectedLocally?: boolean;
|
|
31
31
|
_connectGeneration: number;
|
|
32
32
|
_destroyed: boolean;
|
|
33
|
+
_busyRelease?: () => void;
|
|
33
34
|
_webVPNUdpSocketPromise?: Promise<Awaited<ReturnType<WebVpnUdpSocket>> | undefined>;
|
|
34
35
|
_dataPort?: MessagePort;
|
|
35
36
|
_socketId?: number;
|
package/dgram.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { n as e, r as t, t as n } from "./dgram-
|
|
1
|
+
import { n as e, r as t, t as n } from "./dgram-TB03kqMr.js";
|
|
2
2
|
export { n as Socket, e as createSocket, t as default };
|
package/dns.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./api-
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./api-CKO3Hw-O.cjs");var n=e.t({lookup:()=>r}),r=(e,n)=>t.r.then(t=>t.cloud.dns.lookup(e,n));exports.lookup=r,Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return n}});
|
package/dns.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
|
|
2
|
-
import { t } from "./api-
|
|
2
|
+
import { r as t } from "./api-BqRjtWm_.js";
|
|
3
3
|
//#region src/lib/dns.ts
|
|
4
4
|
var n = /* @__PURE__ */ e({ lookup: () => r }), r = (e, n) => t.then((t) => t.cloud.dns.lookup(e, n));
|
|
5
5
|
//#endregion
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
|
|
2
2
|
import { A as t, B as n, C as r, D as i, E as a, F as o, H as s, I as c, L as l, M as u, N as d, O as f, P as p, R as m, S as h, T as g, U as _, V as v, a as y, b, c as x, d as S, g as C, h as w, i as T, j as E, k as D, l as O, m as k, n as A, o as j, p as M, r as N, s as P, t as F, u as I, v as L, w as R, x as z, y as B, z as V } from "./lib-k3lstfa4.js";
|
|
3
|
-
import {
|
|
4
|
-
import { n as U, t as W } from "./proxy
|
|
3
|
+
import { r as H } from "./api-BqRjtWm_.js";
|
|
4
|
+
import { n as U, t as W } from "./proxy--aljNHvG.js";
|
|
5
5
|
import { available as G, fetch as K } from "./desktop.js";
|
|
6
6
|
//#region src/lib/extension-prompt.ts
|
|
7
7
|
var q = async (e) => {
|