@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
package/index.js
CHANGED
|
@@ -1,26 +1,27 @@
|
|
|
1
1
|
import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
|
|
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
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
6
|
-
import {
|
|
7
|
-
import {
|
|
8
|
-
import {
|
|
9
|
-
import {
|
|
10
|
-
import { t as
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import { t as
|
|
14
|
-
import { t as
|
|
15
|
-
import { t as
|
|
16
|
-
import {
|
|
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 ee, N as te, O as ne, R as re, S as ie, T as ae, U as oe, V as se, a as u, b as d, c as f, d as p, g as m, h, i as g, j as _, k as v, l as y, m as b, n as x, o as S, p as C, r as w, s as T, t as E, u as D, v as O, x as k, y as A, z as j } from "./lib-k3lstfa4.js";
|
|
3
|
+
import { a as M, c as N, l as P, n as F, r as I, s as L, t as R } from "./api-BqRjtWm_.js";
|
|
4
|
+
import { n as z, t as B } from "./busy-Bp1E3JPT.js";
|
|
5
|
+
import { a as V, i as H, n as U } from "./cloud-BlR1He17.js";
|
|
6
|
+
import { t as W } from "./dns.js";
|
|
7
|
+
import { s as G } from "./net-Ct8ywVAk.js";
|
|
8
|
+
import { i as K } from "./dgram-TB03kqMr.js";
|
|
9
|
+
import { t as ce } from "./http.js";
|
|
10
|
+
import { i as le, n as ue, r as de, t as fe } from "./extension-BI2NxGtC.js";
|
|
11
|
+
import { t as pe } from "./desktop.js";
|
|
12
|
+
import { c as me, u as he } from "./fs-bpb3Ysdd.js";
|
|
13
|
+
import { t as ge } from "./opfs.js";
|
|
14
|
+
import { t as _e } from "./packages.js";
|
|
15
|
+
import { t as ve } from "./account.js";
|
|
16
|
+
import { t as ye } from "./connect-button-Ds9KpXHe.js";
|
|
17
|
+
import { relay as be } from "osra";
|
|
17
18
|
//#region src/lib/frame.ts
|
|
18
|
-
var
|
|
19
|
+
var xe = 1e4, Se = 150, Ce = () => new Promise((e) => {
|
|
19
20
|
if (o()) return e(!0);
|
|
20
|
-
let t, n = setTimeout(() => r(o()),
|
|
21
|
+
let t, n = setTimeout(() => r(o()), xe), r = (r) => {
|
|
21
22
|
clearTimeout(t), clearTimeout(n), a.disconnect(), document.removeEventListener("readystatechange", s), e(r);
|
|
22
23
|
}, i = () => {
|
|
23
|
-
clearTimeout(t), t = setTimeout(() => r(o()),
|
|
24
|
+
clearTimeout(t), t = setTimeout(() => r(o()), Se);
|
|
24
25
|
}, a = new MutationObserver(() => {
|
|
25
26
|
o() && r(!0);
|
|
26
27
|
}), s = () => {
|
|
@@ -30,28 +31,80 @@ var se = 1e4, ce = 150, le = () => new Promise((e) => {
|
|
|
30
31
|
attributes: !0,
|
|
31
32
|
attributeFilter: ["data-fkn-extension"]
|
|
32
33
|
}), document.addEventListener("readystatechange", s), document.readyState === "complete" && i();
|
|
33
|
-
}),
|
|
34
|
+
}), we = async (e) => de() || e.lockdown || !V() || await Ce() ? w(e) : H(e), Te = "https://fkn.app", Ee = async (e, t) => {
|
|
34
35
|
if (typeof window > "u") throw Error("FKN @fkn/lib: relayWorker must be called from the main thread");
|
|
35
|
-
let n = await
|
|
36
|
+
let n = await P;
|
|
36
37
|
if (!n) throw Error("FKN @fkn/lib: relayWorker found no FKN transport in this realm");
|
|
37
|
-
|
|
38
|
+
let r = B("relayed worker");
|
|
39
|
+
t?.unregisterSignal?.aborted ? r() : t?.unregisterSignal?.addEventListener("abort", r, { once: !0 }), be(n, e, {
|
|
38
40
|
key: "fkn-api",
|
|
39
41
|
...n.emit instanceof MessagePort ? {} : {
|
|
40
|
-
originA: t?.originA ??
|
|
42
|
+
originA: t?.originA ?? Te,
|
|
41
43
|
originB: t?.originB ?? "*"
|
|
42
44
|
},
|
|
43
45
|
unregisterSignal: t?.unregisterSignal
|
|
44
46
|
});
|
|
45
|
-
},
|
|
46
|
-
applyUpdate: () =>
|
|
47
|
-
onUpdate: () =>
|
|
48
|
-
updateReady: () =>
|
|
49
|
-
}),
|
|
47
|
+
}, De = async () => typeof window > "u" ? !1 : (await I).connect.prompt(location.origin).catch(() => !1), Oe = async () => typeof window > "u" ? null : (await I).relay.prompt().catch(() => null), ke = /* @__PURE__ */ e({
|
|
48
|
+
applyUpdate: () => Q,
|
|
49
|
+
onUpdate: () => Z,
|
|
50
|
+
updateReady: () => Ae
|
|
51
|
+
}), Ae = async () => typeof window > "u" ? !1 : I.then((e) => e.shell?.updateReady()).then((e) => e === !0).catch(() => !1), q = /* @__PURE__ */ new Set(), J = !1, je = () => {
|
|
52
|
+
J = !0;
|
|
53
|
+
for (let e of [...q]) try {
|
|
54
|
+
e();
|
|
55
|
+
} catch {}
|
|
56
|
+
}, Y = 0, X = () => {
|
|
57
|
+
let e = M();
|
|
58
|
+
!e || q.size === 0 || Y === e.epoch || (Y = e.epoch, J = !1, Promise.resolve(e.remote.shell?.onUpdate(je)).catch(() => {
|
|
59
|
+
Y === e.epoch && (Y = 0);
|
|
60
|
+
}));
|
|
61
|
+
};
|
|
62
|
+
typeof window < "u" && L(X);
|
|
63
|
+
var Z = async (e) => {
|
|
50
64
|
if (typeof window > "u") return () => {};
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
return
|
|
55
|
-
|
|
65
|
+
if (q.add(e), J) try {
|
|
66
|
+
e();
|
|
67
|
+
} catch {}
|
|
68
|
+
return X(), () => {
|
|
69
|
+
q.delete(e);
|
|
70
|
+
};
|
|
71
|
+
}, Q = async () => typeof window > "u" ? !1 : I.then((e) => e.shell?.applyUpdate()).then((e) => e === !0).catch(() => !1), Me = 3e4, Ne = (e) => {
|
|
72
|
+
let t = !1, n = !1;
|
|
73
|
+
return {
|
|
74
|
+
tick: async () => {
|
|
75
|
+
if (!t || n || !e.ownsFrame() || e.inFlight() > 0 || e.busy().length > 0 || e.now() - e.idleSince() < (e.hidden() ? 12e4 : 18e5)) return !1;
|
|
76
|
+
n = !0;
|
|
77
|
+
try {
|
|
78
|
+
return await e.flush().catch(() => {}), await e.apply().catch(() => !0);
|
|
79
|
+
} finally {
|
|
80
|
+
n = !1;
|
|
81
|
+
}
|
|
82
|
+
},
|
|
83
|
+
noteUpdateReady: () => {
|
|
84
|
+
t = !0;
|
|
85
|
+
},
|
|
86
|
+
noteEpoch: () => {
|
|
87
|
+
t = !1, n = !1;
|
|
88
|
+
},
|
|
89
|
+
isPending: () => t
|
|
90
|
+
};
|
|
91
|
+
}, $ = !1, Pe = (e) => ({
|
|
92
|
+
now: () => Date.now(),
|
|
93
|
+
hidden: () => document.visibilityState === "hidden",
|
|
94
|
+
idleSince: () => Math.max(F(), e),
|
|
95
|
+
inFlight: R,
|
|
96
|
+
busy: z,
|
|
97
|
+
ownsFrame: () => N() !== void 0,
|
|
98
|
+
flush: () => me(),
|
|
99
|
+
apply: () => I.then((e) => e.shell.applyUpdate()).then((e) => e === !0)
|
|
100
|
+
});
|
|
101
|
+
(() => {
|
|
102
|
+
if ($ || typeof window > "u" || typeof document > "u") return;
|
|
103
|
+
$ = !0;
|
|
104
|
+
let e = Ne(Pe(Date.now()));
|
|
105
|
+
L(() => e.noteEpoch()), Z(() => e.noteUpdateReady()), setInterval(() => {
|
|
106
|
+
e.tick();
|
|
107
|
+
}, Me);
|
|
108
|
+
})();
|
|
56
109
|
//#endregion
|
|
57
|
-
export {
|
|
110
|
+
export { x as ATTACH_FRAME_EVENT_KEY, t as FORGEABLE_HEADERS, h as LOCATOR_DENIED, m as LOCATOR_ERROR, b as LOCATOR_UNSUPPORTED, ve as account, T as assertAttachableFrameUrl, r as assertFetchableUrl, _ as assertForgeableHeaders, f as assertLockdownApplicable, ee as assertOneCookieIdentity, we as attachFrame, g as attachFramePermission, j as box, U as cloud, De as connect, ye as connectButtonUrl, k as cookies, u as createFrame, n as createVideoElementHandle, pe as desktop, K as dgram, W as dns, fe as extension, ue as fetch, ae as fetchCredentialedPermission, a as fetchLocalPermission, i as fetchPermission, he as fs, S as gotoPermission, re as handleRevivableModules, te as hasForgedCookie, ce as http, ne as isBlockedFetchUrl, y as isBlockedFrameUrl, o as isExtensionExposed, v as isLocalNetworkUrl, C as isLocatorDenied, D as isLocatorUnsupported, p as isTerminalError, se as isType, O as modifyRequestHeadersPermission, G as net, ge as opfs, _e as packages, E as permissions, le as promptInstall, Oe as promptRelay, ie as readCookiePermission, Ee as relayWorker, A as removeRequestHeaderRule, s as revive, c as setMissingExtensionHandler, d as setRequestHeaderRule, ke as shell, oe as type, l as waitForExtensionExposure };
|
package/net-C2fIMWFr.cjs
ADDED
|
@@ -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("stream"),a=require("events");var o=e.t({Server:()=>c,Socket:()=>s,_default:()=>f,connect:()=>l,createConnection:()=>u,createServer:()=>d,default:()=>f,isIP:()=>r.r,isIPv4:()=>r.i,isIPv6:()=>r.a}),s=class extends i.Stream.Duplex{_localAddress;_remoteAddress;_webVPNTcpSocketPromise;constructor(e){if(e?.fd!==void 0)throw Error(`FKN WebVPN does not support file descriptors`);super(e),e?.connection&&this.__webvpn_tcp_socket_init__(e.connection)}_busyRelease;__webvpn_tcp_socket_init__(e,t){if(this._busyRelease??=n.t(`tcp socket`),t&&(this._localAddress={address:t.localAddress,family:t.localFamily,port:t.localPort},this._remoteAddress={address:t.remoteAddress,family:t.remoteFamily,port:t.remotePort}),this._webVPNTcpSocketPromise=e.then(e=>{let t=e.dataReadableStream.getReader(),n=e.dataWritableStream.getWriter();return this._localAddress={address:e.localAddress,family:e.localFamily,port:e.localPort},this._remoteAddress={address:e.remoteAddress,family:e.remoteFamily,port:e.remotePort},{...e,reader:t,writer:n}}).catch(e=>{this.emit(`error`,e)}),!this._webVPNTcpSocketPromise)throw Error(`Socket not connected`);return this._webVPNTcpSocketPromise.then(e=>{if(!e){this._busyRelease?.();return}this.emit(`connect`)}),this._webVPNTcpSocketPromise}_read(e){if(!this._webVPNTcpSocketPromise)throw Error(`Socket not connected`);this._webVPNTcpSocketPromise.then(e=>{if(!e){this.push(null);return}e.reader.read().then(({value:e,done:t})=>{if(t){this.push(null);return}this._restartTimeoutTimer(),this.push(e)}).catch(e=>{this.destroy(e)})})}_write(e,t,n){if(!this._webVPNTcpSocketPromise){n(Error(`Socket not connected`));return}this._webVPNTcpSocketPromise.then(async t=>{if(!t)throw Error(`Socket not connected`);await t.writer.ready,await t.writer.write(e),this._restartTimeoutTimer(),n()}).catch(n)}connect(...e){let n=r.c(...e),i=this.__webvpn_tcp_socket_init__(t.r.then(e=>e.cloud.webvpn.tcpSocket({remoteAddress:n.host??`localhost`,remotePort:n.port})));return n.callback&&i.then(e=>{e&&n.callback.call(this)}),this}_final(e){if(!this._webVPNTcpSocketPromise){e();return}this._webVPNTcpSocketPromise.then(async e=>{e&&await e.writer.close()}).then(()=>e(),t=>e(t))}_destroy(e,t){if(this._timeoutTimer&&clearTimeout(this._timeoutTimer),this._busyRelease?.(),!this._webVPNTcpSocketPromise){t(e);return}this._webVPNTcpSocketPromise.then(async e=>{e&&await(this._resetRequested?e.resetAndDestroy():e.destroy())}).then(()=>t(e),()=>t(e))}destroySoon(){if(this.writableFinished){this.destroy();return}this.once(`finish`,()=>this.destroy()),this.end()}_resetRequested=!1;resetAndDestroy(){return this._resetRequested=!0,this.destroy(),this}_timeoutMs;_timeoutTimer;_restartTimeoutTimer(){this._timeoutTimer&&clearTimeout(this._timeoutTimer),this._timeoutMs&&(this._timeoutTimer=setTimeout(()=>this.emit(`timeout`),this._timeoutMs))}setTimeout(e,t){return t&&this.on(`timeout`,t),this._timeoutMs=e,this._restartTimeoutTimer(),this}setNoDelay(e){let t=e??!0;return this._setTcpOption({type:0,value:t}),this}setKeepAlive(e,t){let n=e??!1,r=t!==void 0&&t>0?Math.max(1,Math.round(t/1e3)):0;return this._setTcpOption({type:2,enabled:n,initialDelaySeconds:r}),this}setSendBufferSize(e){return this._setTcpOption({type:3,value:e}),this}setRecvBufferSize(e){return this._setTcpOption({type:4,value:e}),this}_typeOfService;getTypeOfService(){return this._typeOfService??0}setTypeOfService(e){return this._typeOfService=e,this}_setTcpOption(e){if(!this._webVPNTcpSocketPromise){this.emit(`error`,Error(`Cannot set socket option before connect`));return}this._webVPNTcpSocketPromise.then(async t=>{if(t)try{await t.setOption(e)}catch(e){this.emit(`error`,e)}})}write(e,t,...n){return super.write(e,t,...n)}address(){return this._localAddress??{}}unref(){return this}ref(){return this}autoSelectFamilyAttemptedAddresses;bufferSize;bytesRead;bytesWritten;connecting;pending;get localAddress(){if(!this._localAddress)throw Error(`Socket is not connected`);return this._localAddress.address}get localPort(){if(!this._localAddress)throw Error(`Socket is not connected`);return this._localAddress.port}get localFamily(){if(!this._localAddress)throw Error(`Socket is not connected`);return this._localAddress.family}readyState;get remoteAddress(){if(!this._remoteAddress)throw Error(`Socket is not connected`);return this._remoteAddress.address}get remotePort(){if(!this._remoteAddress)throw Error(`Socket is not connected`);return this._remoteAddress.port}get remoteFamily(){if(!this._remoteAddress)throw Error(`Socket is not connected`);return this._remoteAddress.family}timeout},c=class extends a.EventEmitter{_localAddress;_webVPNTcpSocketListenerPromise;constructor(e,t){super(e),t&&this.on(`connection`,t),e?.connection&&this.__webvpn_tcp_socket_listener_init__(e.connection)}_busyRelease;__webvpn_tcp_socket_listener_init__(e){return this._busyRelease??=n.t(`tcp server`),this._webVPNTcpSocketListenerPromise=e.then(e=>(this._localAddress={address:e.localAddress,family:e.localFamily,port:e.localPort},e)).catch(e=>{this.emit(`error`,e)}),this._webVPNTcpSocketListenerPromise.then(e=>{if(!e){this._busyRelease?.();return}this.emit(`listening`)}),this._webVPNTcpSocketListenerPromise}listen(...e){let n=r.c(...e);this._closeEmitted=!1;let i=e=>{let t=new s;t.__webvpn_tcp_socket_init__(Promise.resolve(e),e),this.emit(`connection`,t)},a=e=>{this._localAddress=void 0;try{e&&this.listenerCount(`error`)>0&&this.emit(`error`,e)}finally{this._emitClose()}},o=e=>t.r.then(t=>t.cloud.webvpn.tcpSocketListener({localAddress:e,localPort:n.port,onConnection:i,onClose:a})),c=n.host?o(n.host):o(`::`).catch(()=>o(`0.0.0.0`)),l=this.__webvpn_tcp_socket_listener_init__(c);return n.callback&&l.then(e=>{e&&n.callback.call(this)}),this}_closeEmitted=!1;_emitClose(){this._closeEmitted||(this._closeEmitted=!0,this._busyRelease?.(),this.emit(`close`))}close(e){return this._webVPNTcpSocketListenerPromise&&this._webVPNTcpSocketListenerPromise.then(async t=>{if(t)try{await t.close(),this._localAddress=void 0,this._emitClose(),e&&e()}catch(t){this._localAddress=void 0,this._emitClose(),e&&e(t)}}),this}address(){return this._localAddress??null}getConnections(e){throw Error(`Method not implemented.`)}ref(){return this}unref(){return this}maxConnections;connections;listening;async[Symbol.asyncDispose](){}},l=(e,t)=>new s().connect(e,t),u=(e,t)=>new s().connect(e,t),d=(e,t)=>{typeof e==`function`&&(t=e,e=void 0);let n=new c(e);return t&&n.on(`connection`,t),n},f={Socket:s,Server:c,connect:l,createConnection:u,createServer:d,isIP:r.r,isIPv4:r.i,isIPv6:r.a};Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return s}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return f}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return c}});
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as TcpSocketOption, r as LocalTcpSocket, t as Resolvers } from "./api-
|
|
1
|
+
import { i as TcpSocketOption, r as LocalTcpSocket, t as Resolvers } from "./api-B0qRPCcX.js";
|
|
2
2
|
import { AddressInfo, ListenOptions, Server, ServerOpts, Socket, SocketConnectOpts, SocketConstructorOpts } from "net";
|
|
3
3
|
import { DuplexOptions, Stream } from "stream";
|
|
4
4
|
import { EventEmitter } from "events";
|
|
@@ -44,6 +44,7 @@ declare class Socket$2 extends Stream.Duplex implements Socket {
|
|
|
44
44
|
* cannot name with no alert and no reply, which reads from outside as the relay never delivering
|
|
45
45
|
* the connection at all.
|
|
46
46
|
*/
|
|
47
|
+
_busyRelease?: () => void;
|
|
47
48
|
__webvpn_tcp_socket_init__(connection: ReturnType<WebVpnTcpSocket>, endpoints?: Awaited<ReturnType<WebVpnTcpSocket>>): Promise<(LocalTcpSocket & {
|
|
48
49
|
reader: ReadableStreamDefaultReader<Uint8Array>;
|
|
49
50
|
writer: WritableStreamDefaultWriter<Uint8Array>;
|
|
@@ -108,6 +109,7 @@ declare class Server$1 extends EventEmitter implements Server {
|
|
|
108
109
|
constructor(options?: ServerOpts & EventEmitterOptions & {
|
|
109
110
|
connection?: ReturnType<WebVpnTcpSocketListener>;
|
|
110
111
|
}, connectionListener?: (socket: Socket$2) => void);
|
|
112
|
+
_busyRelease?: () => void;
|
|
111
113
|
__webvpn_tcp_socket_listener_init__(connection: ReturnType<WebVpnTcpSocketListener>): Promise<{
|
|
112
114
|
localAddress: string;
|
|
113
115
|
localFamily: "IPv4" | "IPv6";
|
|
@@ -1,21 +1,22 @@
|
|
|
1
1
|
import { t as e } from "./rolldown-runtime-Dy4uBu1J.js";
|
|
2
|
-
import { t } from "./api-
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
import {
|
|
2
|
+
import { r as t } from "./api-BqRjtWm_.js";
|
|
3
|
+
import { t as n } from "./busy-Bp1E3JPT.js";
|
|
4
|
+
import { a as r, c as i, i as a, r as o } from "./utils-DVlbuXmW.js";
|
|
5
|
+
import { Stream as s } from "stream";
|
|
6
|
+
import { EventEmitter as c } from "events";
|
|
6
7
|
//#region src/lib/webvpn/net.ts
|
|
7
|
-
var
|
|
8
|
-
Server: () =>
|
|
9
|
-
Socket: () =>
|
|
10
|
-
_default: () =>
|
|
11
|
-
connect: () =>
|
|
12
|
-
createConnection: () =>
|
|
13
|
-
createServer: () =>
|
|
14
|
-
default: () =>
|
|
15
|
-
isIP: () =>
|
|
16
|
-
isIPv4: () =>
|
|
17
|
-
isIPv6: () =>
|
|
18
|
-
}),
|
|
8
|
+
var l = /* @__PURE__ */ e({
|
|
9
|
+
Server: () => d,
|
|
10
|
+
Socket: () => u,
|
|
11
|
+
_default: () => h,
|
|
12
|
+
connect: () => f,
|
|
13
|
+
createConnection: () => p,
|
|
14
|
+
createServer: () => m,
|
|
15
|
+
default: () => h,
|
|
16
|
+
isIP: () => o,
|
|
17
|
+
isIPv4: () => a,
|
|
18
|
+
isIPv6: () => r
|
|
19
|
+
}), u = class extends s.Duplex {
|
|
19
20
|
_localAddress;
|
|
20
21
|
_remoteAddress;
|
|
21
22
|
_webVPNTcpSocketPromise;
|
|
@@ -23,8 +24,9 @@ var c = /* @__PURE__ */ e({
|
|
|
23
24
|
if (e?.fd !== void 0) throw Error("FKN WebVPN does not support file descriptors");
|
|
24
25
|
super(e), e?.connection && this.__webvpn_tcp_socket_init__(e.connection);
|
|
25
26
|
}
|
|
27
|
+
_busyRelease;
|
|
26
28
|
__webvpn_tcp_socket_init__(e, t) {
|
|
27
|
-
if (t && (this._localAddress = {
|
|
29
|
+
if (this._busyRelease ??= n("tcp socket"), t && (this._localAddress = {
|
|
28
30
|
address: t.localAddress,
|
|
29
31
|
family: t.localFamily,
|
|
30
32
|
port: t.localPort
|
|
@@ -51,7 +53,11 @@ var c = /* @__PURE__ */ e({
|
|
|
51
53
|
this.emit("error", e);
|
|
52
54
|
}), !this._webVPNTcpSocketPromise) throw Error("Socket not connected");
|
|
53
55
|
return this._webVPNTcpSocketPromise.then((e) => {
|
|
54
|
-
|
|
56
|
+
if (!e) {
|
|
57
|
+
this._busyRelease?.();
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
this.emit("connect");
|
|
55
61
|
}), this._webVPNTcpSocketPromise;
|
|
56
62
|
}
|
|
57
63
|
_read(e) {
|
|
@@ -83,11 +89,11 @@ var c = /* @__PURE__ */ e({
|
|
|
83
89
|
}).catch(n);
|
|
84
90
|
}
|
|
85
91
|
connect(...e) {
|
|
86
|
-
let n =
|
|
92
|
+
let n = i(...e), r = this.__webvpn_tcp_socket_init__(t.then((e) => e.cloud.webvpn.tcpSocket({
|
|
87
93
|
remoteAddress: n.host ?? "localhost",
|
|
88
94
|
remotePort: n.port
|
|
89
95
|
})));
|
|
90
|
-
return n.callback &&
|
|
96
|
+
return n.callback && r.then((e) => {
|
|
91
97
|
e && n.callback.call(this);
|
|
92
98
|
}), this;
|
|
93
99
|
}
|
|
@@ -101,7 +107,7 @@ var c = /* @__PURE__ */ e({
|
|
|
101
107
|
}).then(() => e(), (t) => e(t));
|
|
102
108
|
}
|
|
103
109
|
_destroy(e, t) {
|
|
104
|
-
if (this._timeoutTimer && clearTimeout(this._timeoutTimer), !this._webVPNTcpSocketPromise) {
|
|
110
|
+
if (this._timeoutTimer && clearTimeout(this._timeoutTimer), this._busyRelease?.(), !this._webVPNTcpSocketPromise) {
|
|
105
111
|
t(e);
|
|
106
112
|
return;
|
|
107
113
|
}
|
|
@@ -219,28 +225,33 @@ var c = /* @__PURE__ */ e({
|
|
|
219
225
|
return this._remoteAddress.family;
|
|
220
226
|
}
|
|
221
227
|
timeout;
|
|
222
|
-
},
|
|
228
|
+
}, d = class extends c {
|
|
223
229
|
_localAddress;
|
|
224
230
|
_webVPNTcpSocketListenerPromise;
|
|
225
231
|
constructor(e, t) {
|
|
226
232
|
super(e), t && this.on("connection", t), e?.connection && this.__webvpn_tcp_socket_listener_init__(e.connection);
|
|
227
233
|
}
|
|
234
|
+
_busyRelease;
|
|
228
235
|
__webvpn_tcp_socket_listener_init__(e) {
|
|
229
|
-
return this._webVPNTcpSocketListenerPromise = e.then((e) => (this._localAddress = {
|
|
236
|
+
return this._busyRelease ??= n("tcp server"), this._webVPNTcpSocketListenerPromise = e.then((e) => (this._localAddress = {
|
|
230
237
|
address: e.localAddress,
|
|
231
238
|
family: e.localFamily,
|
|
232
239
|
port: e.localPort
|
|
233
240
|
}, e)).catch((e) => {
|
|
234
241
|
this.emit("error", e);
|
|
235
242
|
}), this._webVPNTcpSocketListenerPromise.then((e) => {
|
|
236
|
-
|
|
243
|
+
if (!e) {
|
|
244
|
+
this._busyRelease?.();
|
|
245
|
+
return;
|
|
246
|
+
}
|
|
247
|
+
this.emit("listening");
|
|
237
248
|
}), this._webVPNTcpSocketListenerPromise;
|
|
238
249
|
}
|
|
239
250
|
listen(...e) {
|
|
240
|
-
let n =
|
|
251
|
+
let n = i(...e);
|
|
241
252
|
this._closeEmitted = !1;
|
|
242
|
-
let
|
|
243
|
-
let t = new
|
|
253
|
+
let r = (e) => {
|
|
254
|
+
let t = new u();
|
|
244
255
|
t.__webvpn_tcp_socket_init__(Promise.resolve(e), e), this.emit("connection", t);
|
|
245
256
|
}, a = (e) => {
|
|
246
257
|
this._localAddress = void 0;
|
|
@@ -252,7 +263,7 @@ var c = /* @__PURE__ */ e({
|
|
|
252
263
|
}, o = (e) => t.then((t) => t.cloud.webvpn.tcpSocketListener({
|
|
253
264
|
localAddress: e,
|
|
254
265
|
localPort: n.port,
|
|
255
|
-
onConnection:
|
|
266
|
+
onConnection: r,
|
|
256
267
|
onClose: a
|
|
257
268
|
})), s = n.host ? o(n.host) : o("::").catch(() => o("0.0.0.0")), c = this.__webvpn_tcp_socket_listener_init__(s);
|
|
258
269
|
return n.callback && c.then((e) => {
|
|
@@ -261,7 +272,7 @@ var c = /* @__PURE__ */ e({
|
|
|
261
272
|
}
|
|
262
273
|
_closeEmitted = !1;
|
|
263
274
|
_emitClose() {
|
|
264
|
-
this._closeEmitted || (this._closeEmitted = !0, this.emit("close"));
|
|
275
|
+
this._closeEmitted || (this._closeEmitted = !0, this._busyRelease?.(), this.emit("close"));
|
|
265
276
|
}
|
|
266
277
|
close(e) {
|
|
267
278
|
return this._webVPNTcpSocketListenerPromise && this._webVPNTcpSocketListenerPromise.then(async (t) => {
|
|
@@ -288,19 +299,19 @@ var c = /* @__PURE__ */ e({
|
|
|
288
299
|
connections;
|
|
289
300
|
listening;
|
|
290
301
|
async [Symbol.asyncDispose]() {}
|
|
291
|
-
},
|
|
302
|
+
}, f = (e, t) => new u().connect(e, t), p = (e, t) => new u().connect(e, t), m = (e, t) => {
|
|
292
303
|
typeof e == "function" && (t = e, e = void 0);
|
|
293
|
-
let n = new
|
|
304
|
+
let n = new d(e);
|
|
294
305
|
return t && n.on("connection", t), n;
|
|
295
|
-
},
|
|
296
|
-
Socket:
|
|
297
|
-
Server:
|
|
298
|
-
connect:
|
|
299
|
-
createConnection:
|
|
300
|
-
createServer:
|
|
301
|
-
isIP:
|
|
302
|
-
isIPv4:
|
|
303
|
-
isIPv6:
|
|
306
|
+
}, h = {
|
|
307
|
+
Socket: u,
|
|
308
|
+
Server: d,
|
|
309
|
+
connect: f,
|
|
310
|
+
createConnection: p,
|
|
311
|
+
createServer: m,
|
|
312
|
+
isIP: o,
|
|
313
|
+
isIPv4: a,
|
|
314
|
+
isIPv6: r
|
|
304
315
|
};
|
|
305
316
|
//#endregion
|
|
306
|
-
export {
|
|
317
|
+
export { p as a, f as i, u as n, m as o, h as r, l as s, d as t };
|
package/net.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./utils-QfNXtEhb.cjs"),t=require("./net-
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./utils-QfNXtEhb.cjs"),t=require("./net-C2fIMWFr.cjs");exports.Server=t.t,exports.Socket=t.n,exports._default=t.r,exports.default=t.r,exports.connect=t.i,exports.createConnection=t.a,exports.createServer=t.o,exports.isIP=e.r,exports.isIPv4=e.i,exports.isIPv6=e.a;
|
package/net.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as createConnection, c as isIP, i as connect, l as isIPv4, n as Socket, o as createServer, r as _default, t as Server, u as isIPv6 } from "./net-
|
|
1
|
+
import { a as createConnection, c as isIP, i as connect, l as isIPv4, n as Socket, o as createServer, r as _default, t as Server, u as isIPv6 } from "./net-CnYxw_sB.js";
|
|
2
2
|
export { Server, Socket, _default, _default as default, connect, createConnection, createServer, isIP, isIPv4, isIPv6 };
|
package/net.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { a as e, i as t, r as n } from "./utils-DVlbuXmW.js";
|
|
2
|
-
import { a as r, i, n as a, o, r as s, t as c } from "./net-
|
|
2
|
+
import { a as r, i, n as a, o, r as s, t as c } from "./net-Ct8ywVAk.js";
|
|
3
3
|
export { c as Server, a as Socket, s as _default, s as default, i as connect, r as createConnection, o as createServer, n as isIP, t as isIPv4, e as isIPv6 };
|