@fkn/lib 0.5.5 → 0.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/account.cjs +1 -1
- package/account.js +2 -2
- package/api/account.d.ts +7 -0
- package/api/broker-bridge.d.ts +12 -0
- package/api/connect-store.d.ts +9 -0
- package/api/connect.d.ts +2 -0
- package/api/data-plane.d.ts +28 -0
- package/api/dns/index.d.ts +1 -0
- package/{cloud/dns.d.ts → api/dns/lookup.d.ts} +2 -6
- package/api/index.d.ts +78 -0
- package/api/install-prompt.d.ts +2 -0
- package/api/local-net/index.d.ts +43 -0
- package/api/overlay-mount.d.ts +2 -0
- package/api/overlay.d.ts +17 -0
- package/api/packages/host.d.ts +12 -0
- package/api/packages/identity.d.ts +1 -0
- package/api/packages/index.d.ts +34 -0
- package/api/packages/picker.d.ts +28 -0
- package/api/packages/registry.d.ts +20 -0
- package/api/packages/store.d.ts +6 -0
- package/api/packages/types.d.ts +56 -0
- package/api/preconnect.d.ts +1 -0
- package/api/proxy/index.d.ts +1 -0
- package/api/proxy/proxy-fetch.d.ts +5 -0
- package/api/quota.d.ts +10 -0
- package/api/rate-token.d.ts +3 -0
- package/api/session-limit.d.ts +1 -0
- package/api/storage.d.ts +20 -0
- package/api/toast.d.ts +1 -0
- package/api/token-source.d.ts +4 -0
- package/api/ui-events.d.ts +8 -0
- package/api/ui-host.d.ts +2 -0
- package/api/webvpn/index.d.ts +3 -0
- package/api/webvpn/packets/metadata.d.ts +31 -0
- package/api/webvpn/packets/tcp-listener.d.ts +39 -0
- package/api/webvpn/packets/tcp.d.ts +88 -0
- package/api/webvpn/packets/udp.d.ts +183 -0
- package/api/webvpn/packets/utils.d.ts +24 -0
- package/api/webvpn/tcp-listener.d.ts +11 -0
- package/api/webvpn/tcp.d.ts +33 -0
- package/api/webvpn/udp.d.ts +33 -0
- package/api/webvpn/utils.d.ts +26 -0
- package/api/webvpn/webtransport.d.ts +62 -0
- package/api/worker/client.d.ts +3 -0
- package/api/worker/protocol.d.ts +15 -0
- package/{api-CDb2pv7C.cjs → api-DD5v1qP9.cjs} +1 -1
- package/{background-DvQm1JHR.js → background-BVBbBOmL.js} +41 -68
- package/background-B_VgpARk.cjs +1 -0
- package/cloud/dgram.cjs +1 -1
- package/cloud/dgram.js +1 -3
- package/cloud/dns.cjs +1 -1
- package/cloud/dns.js +0 -1
- package/cloud/fs/promises.cjs +1 -1
- package/cloud/fs/promises.js +0 -3
- package/cloud/fs.cjs +1 -1
- package/cloud/fs.js +3 -4
- package/cloud/http.cjs +1 -1
- package/cloud/http.js +0 -3
- package/cloud/net.cjs +1 -1
- package/cloud/net.js +2 -3
- package/cloud-5o7yJHeX.cjs +1 -0
- package/cloud-BFyf2uC7.js +112 -0
- package/cloud.cjs +1 -1
- package/cloud.js +8 -12
- package/{connect-button-poDZVmq2.cjs → connect-button-BBEjXzB3.cjs} +1 -1
- package/desktop.cjs +1 -1
- package/desktop.js +1 -1
- package/dgram-CE43gJq9.cjs +1 -0
- package/{dgram-c_Xk7ckJ.js → dgram-wtjARbt0.js} +3 -3
- package/dgram.cjs +1 -1
- package/dgram.js +1 -3
- package/dns.cjs +1 -1
- package/dns.js +2 -2
- package/extension-CPj10qwa.js +67 -0
- package/extension-D-NUXxzF.cjs +1 -0
- package/extension.cjs +1 -1
- package/extension.js +3 -5
- package/fs/promises.cjs +1 -1
- package/fs/promises.js +1 -4
- package/fs-BfmfMBiw.cjs +1 -0
- package/{fs-BQs-x3_j.js → fs-D6nNf1mR.js} +4 -4
- package/fs.cjs +1 -1
- package/fs.js +1 -4
- package/http.cjs +2 -2
- package/http.js +7 -7
- package/index.cjs +1 -1
- package/index.js +23 -26
- package/{account.d.ts → lib/account.d.ts} +5 -8
- package/lib/api.d.ts +300 -0
- package/lib/auto.d.ts +5 -0
- package/lib/cloud/dgram.d.ts +2 -0
- package/lib/cloud/dns.d.ts +1 -0
- package/lib/cloud/frame.d.ts +3 -0
- package/lib/cloud/fs-promises.d.ts +5 -0
- package/lib/cloud/fs.d.ts +22 -0
- package/lib/cloud/http.d.ts +2 -0
- package/lib/cloud/net.d.ts +2 -0
- package/lib/cloud.d.ts +10 -0
- package/lib/connect-button.d.ts +1 -0
- package/lib/connect.d.ts +1 -0
- package/{desktop.d.ts → lib/desktop.d.ts} +6 -8
- package/lib/dns.d.ts +6 -0
- package/lib/dom.d.ts +2 -0
- package/lib/extension-prompt.d.ts +1 -0
- package/lib/extension.d.ts +4 -0
- package/lib/fkn-target.d.ts +1 -0
- package/lib/frame.d.ts +2 -0
- package/lib/fs/content-type.d.ts +1 -0
- package/lib/fs/hybrid.d.ts +10 -0
- package/lib/fs/index.d.ts +87 -0
- package/lib/fs/opfs.d.ts +8 -0
- package/lib/fs/promises.d.ts +8 -0
- package/lib/fs/types.d.ts +16 -0
- package/lib/index.d.ts +18 -0
- package/lib/node-fs/index.d.ts +95 -0
- package/lib/node-fs/shared.d.ts +39 -0
- package/lib/node-fs/store.d.ts +21 -0
- package/lib/opfs/index.d.ts +84 -0
- package/lib/opfs/promises.d.ts +8 -0
- package/lib/overlay.d.ts +14 -0
- package/lib/packages.d.ts +69 -0
- package/lib/proxy.d.ts +5 -0
- package/lib/quota.d.ts +20 -0
- package/lib/react.d.ts +7 -0
- package/lib/relay.d.ts +5 -0
- package/lib/storage.d.ts +22 -0
- package/lib/webvpn/dgram.d.ts +86 -0
- package/lib/webvpn/http.d.ts +180 -0
- package/lib/webvpn/index.d.ts +1 -0
- package/lib/webvpn/net.d.ts +132 -0
- package/lib/webvpn/utils.d.ts +32 -0
- package/net-CpuAhaQC.cjs +1 -0
- package/{net-Bl6_W3bd.js → net-DKMWPXb_.js} +3 -3
- package/net.cjs +1 -1
- package/net.js +2 -3
- package/{node-fs-DQn1TGJz.cjs → node-fs-C0eKnboT.cjs} +1 -1
- package/{node-fs-CdKPXPtW.js → node-fs-Dbf93qP7.js} +1 -1
- package/opfs/promises.cjs +1 -1
- package/opfs/promises.js +0 -1
- package/{opfs-BfcYLPGb.js → opfs-7_GmzQ93.js} +1 -1
- package/opfs-uClkgnb5.cjs +1 -0
- package/opfs.cjs +1 -1
- package/opfs.js +3 -3
- package/package.json +27 -22
- package/packages.cjs +1 -0
- package/packages.js +150 -0
- package/{locator-9s7jNIA2.js → proxy-C8SG1Beo.js} +542 -344
- package/proxy-bPaU3-Cz.cjs +53 -0
- package/react.cjs +1 -1
- package/react.js +1 -1
- package/{chunk-CPXzm0be.js → rolldown-runtime-DF993M8W.js} +1 -1
- package/rolldown-runtime-Doa5O59j.cjs +1 -0
- package/sandbox.d.ts +7 -0
- package/storage-OkwsFLN1.cjs +1 -0
- package/{storage-BcJfnkm3.js → storage-TmeyhZGt.js} +2 -2
- package/{utils-BsNRWMfl.cjs → utils-CoimMjf9.cjs} +1 -1
- package/background-CbU8TkWo.cjs +0 -1
- package/chunk-B6C_zzib.cjs +0 -1
- package/cloud/dgram.d.ts +0 -541
- package/cloud/fs/promises.d.ts +0 -45
- package/cloud/fs.d.ts +0 -75
- package/cloud/http.d.ts +0 -767
- package/cloud/net.d.ts +0 -606
- package/cloud-CWg9zCWm.cjs +0 -1
- package/cloud-eLyGYzbA.js +0 -33
- package/cloud.d.ts +0 -1053
- package/dgram-B3WC4VdJ.cjs +0 -1
- package/dgram.d.ts +0 -541
- package/dns.d.ts +0 -12
- package/extension-BLkZiaAP.js +0 -253
- package/extension-DAiRg5ny.cjs +0 -1
- package/extension.d.ts +0 -859
- package/fs/promises.d.ts +0 -67
- package/fs-DI1maxcZ.cjs +0 -1
- package/fs.d.ts +0 -142
- package/http.d.ts +0 -767
- package/index.d.ts +0 -2316
- package/locator-CHfEe3Jv.cjs +0 -53
- package/net-C5kWnI4C.cjs +0 -1
- package/net.d.ts +0 -606
- package/opfs/promises.d.ts +0 -67
- package/opfs-Dsi4FkJU.cjs +0 -1
- package/opfs.d.ts +0 -140
- package/proxy-A9UvWUaF.cjs +0 -1
- package/proxy-wiZN4eTR.js +0 -14
- package/react.d.ts +0 -12
- package/storage-C2-_-bTO.cjs +0 -1
- /package/{api-ByfayMm1.js → api--bnCFd4w.js} +0 -0
- /package/{connect-button-B_63ldmg.js → connect-button-Ds9KpXHe.js} +0 -0
- /package/{utils-CNydj3OT.js → utils-DPtyxGQu.js} +0 -0
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
import type { Remote } from 'osra';
|
|
2
|
+
import type { ConnectOptions, InstallOptions, InstalledPackage, PackageQuery, PackageResult, PackagesErrorCode, PickOptions } from '../api/packages';
|
|
3
|
+
export type { PackageQuery, PackageResult, InstalledPackage, PickOptions, InstallOptions, ConnectOptions, PackagesErrorCode, } from '../api/packages';
|
|
4
|
+
export type PackagesError = Error & {
|
|
5
|
+
code: PackagesErrorCode;
|
|
6
|
+
};
|
|
7
|
+
/** Search npm for FKN packages, e.g. `search({ type: 'plugin', id: 'stub' })`. */
|
|
8
|
+
export declare const search: (query: PackageQuery) => Promise<PackageResult[]>;
|
|
9
|
+
/** FKN-rendered picker over the same search; resolves the user's selection, already installed. [] on cancel. */
|
|
10
|
+
export declare const pick: (query: PackageQuery, options?: PickOptions) => Promise<PackageResult[]>;
|
|
11
|
+
/** Install a package for this app behind an FKN-rendered confirm. Resolves null when the user declines. */
|
|
12
|
+
export declare const install: (uri: string, options?: InstallOptions) => Promise<InstalledPackage | null>;
|
|
13
|
+
/** The packages installed by this app. */
|
|
14
|
+
export declare const list: () => Promise<InstalledPackage[]>;
|
|
15
|
+
/** Uninstall a package from this app; its frames and connections are torn down. */
|
|
16
|
+
export declare const uninstall: (uri: string) => Promise<void>;
|
|
17
|
+
export type PackageConnection<T = unknown> = {
|
|
18
|
+
/** the package's exposed payload */
|
|
19
|
+
remote: Remote<T>;
|
|
20
|
+
/** settles when the package side of the connection dies (uninstall, reload, crash) - reconnect by calling connect() again */
|
|
21
|
+
closed: Promise<void>;
|
|
22
|
+
/** the raw channel under `remote`, for direct messaging (osra envelopes ride it too - filter by your own message shape) */
|
|
23
|
+
port: MessagePort;
|
|
24
|
+
};
|
|
25
|
+
export type AppConnectOptions = ConnectOptions & {
|
|
26
|
+
/** exposed to the package as ITS `remote` */
|
|
27
|
+
payload?: unknown;
|
|
28
|
+
signal?: AbortSignal;
|
|
29
|
+
/** skip the osra handshake and hand back the untouched port - e.g. to transfer it into a worker and attach() there */
|
|
30
|
+
raw?: boolean;
|
|
31
|
+
};
|
|
32
|
+
export type RawPackageConnection = Omit<PackageConnection<never>, 'remote'>;
|
|
33
|
+
type Connect = {
|
|
34
|
+
<T = unknown>(uri: string, options?: AppConnectOptions & {
|
|
35
|
+
raw?: false;
|
|
36
|
+
}): Promise<PackageConnection<T>>;
|
|
37
|
+
(uri: string, options: AppConnectOptions & {
|
|
38
|
+
raw: true;
|
|
39
|
+
}): Promise<RawPackageConnection>;
|
|
40
|
+
};
|
|
41
|
+
/** Connect to an installed package. Throws a PackagesError with code 'not-installed' when it is not. */
|
|
42
|
+
export declare const connect: Connect;
|
|
43
|
+
/** Run this end of an already-brokered connection port, e.g. after transferring it into a worker. */
|
|
44
|
+
export declare const attach: <T = unknown>(port: MessagePort, payload?: unknown, options?: {
|
|
45
|
+
signal?: AbortSignal;
|
|
46
|
+
}) => Promise<Remote<T>>;
|
|
47
|
+
export type IncomingConnectionInfo = {
|
|
48
|
+
/** the connecting app's identity: its package uri when it runs on a sandbox origin, else its page origin */
|
|
49
|
+
from: string;
|
|
50
|
+
/** the contract tag the app passed to connect(), e.g. 'stub-source@1' */
|
|
51
|
+
protocol: string | null;
|
|
52
|
+
/** this package's canonical uri per the connecting app's install record, e.g. 'npm:@banou/stub-source-example' */
|
|
53
|
+
uri: string;
|
|
54
|
+
/** this package's npm name */
|
|
55
|
+
name: string;
|
|
56
|
+
/** the exact version this frame runs - the pin is encoded into the sandbox origin, immutable per version */
|
|
57
|
+
version: string;
|
|
58
|
+
};
|
|
59
|
+
export type IncomingConnection<T = unknown> = IncomingConnectionInfo & PackageConnection<T>;
|
|
60
|
+
/** produces the payload exposed to a connecting app - called once per incoming connection */
|
|
61
|
+
export type ConnectPayload = (info: IncomingConnectionInfo) => unknown;
|
|
62
|
+
/**
|
|
63
|
+
* Serve connections from apps that installed this package. The first argument is called once per
|
|
64
|
+
* incoming connection with the connection info and returns the payload exposed to that app (its
|
|
65
|
+
* `remote`). The latest registration receives new connections; existing connections are unaffected.
|
|
66
|
+
*/
|
|
67
|
+
export declare const onConnect: <T = unknown>(createPayload: ConnectPayload, handler?: (connection: IncomingConnection<T>) => void) => {
|
|
68
|
+
unsubscribe: () => void;
|
|
69
|
+
};
|
package/lib/proxy.d.ts
ADDED
package/lib/quota.d.ts
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
export type QuotaStatus = {
|
|
2
|
+
/** the user has a paid subscription, throttle never applies */
|
|
3
|
+
premium: boolean;
|
|
4
|
+
/** today's free-tier volume is spent (true even for premium, see `throttled`) */
|
|
5
|
+
overQuota: boolean;
|
|
6
|
+
/** transfers are actually being rate-limited right now (overQuota and not premium) */
|
|
7
|
+
throttled: boolean;
|
|
8
|
+
/** bytes egressed through FKN relays today (per anonymized IP), saturates at limitBytes:
|
|
9
|
+
* consumption past the free-tier volume is private and never reported */
|
|
10
|
+
usedBytes: number;
|
|
11
|
+
/** free-tier daily volume before throttling kicks in */
|
|
12
|
+
limitBytes: number;
|
|
13
|
+
/** bytes of free-tier volume left today */
|
|
14
|
+
remainingBytes: number;
|
|
15
|
+
/** current effective egress rate cap, bytes per second */
|
|
16
|
+
bytesPerSecond: number;
|
|
17
|
+
/** current effective egress rate cap, bits per second (for display) */
|
|
18
|
+
bitsPerSecond: number;
|
|
19
|
+
};
|
|
20
|
+
export declare const quota: () => Promise<QuotaStatus>;
|
package/lib/react.d.ts
ADDED
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { CSSProperties, ReactElement } from 'react';
|
|
2
|
+
export { connectButtonUrl } from './connect-button';
|
|
3
|
+
export type ConnectButtonProps = {
|
|
4
|
+
className?: string;
|
|
5
|
+
style?: CSSProperties;
|
|
6
|
+
};
|
|
7
|
+
export declare const ConnectButton: ({ className, style }?: ConnectButtonProps) => ReactElement;
|
package/lib/relay.d.ts
ADDED
package/lib/storage.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
export type FileEntry = {
|
|
2
|
+
path: string;
|
|
3
|
+
size: number;
|
|
4
|
+
contentType: string | null;
|
|
5
|
+
updatedAt: string;
|
|
6
|
+
};
|
|
7
|
+
export type StorageQuota = {
|
|
8
|
+
usedBytes: number;
|
|
9
|
+
limitBytes: number;
|
|
10
|
+
remaining: number;
|
|
11
|
+
objects: number;
|
|
12
|
+
maxObjects: number;
|
|
13
|
+
};
|
|
14
|
+
export type WriteData = Blob | ArrayBuffer | Uint8Array | string;
|
|
15
|
+
export declare const available: () => Promise<boolean>;
|
|
16
|
+
export declare const list: () => Promise<FileEntry[]>;
|
|
17
|
+
export declare const quota: () => Promise<StorageQuota>;
|
|
18
|
+
export declare const readFile: (path: string) => Promise<Blob>;
|
|
19
|
+
export declare const writeFile: (path: string, data: WriteData, opts?: {
|
|
20
|
+
contentType?: string;
|
|
21
|
+
}) => Promise<void>;
|
|
22
|
+
export declare const remove: (path: string) => Promise<void>;
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
import type { BindOptions, Socket as DgramSocket, RemoteInfo, SocketOptions, SocketType } from 'dgram';
|
|
2
|
+
import type { AddressInfo } from 'net';
|
|
3
|
+
import type { Resolvers } from '../api';
|
|
4
|
+
import { EventEmitter } from 'events';
|
|
5
|
+
import { Buffer } from 'buffer';
|
|
6
|
+
import type { UdpSocketOption } from '../../api/webvpn/packets/udp';
|
|
7
|
+
type WebVpnUdpSocket = Resolvers['cloud']['webvpn']['udpSocket'];
|
|
8
|
+
interface EventEmitterOptions {
|
|
9
|
+
/**
|
|
10
|
+
* Enables automatic capturing of promise rejection.
|
|
11
|
+
*/
|
|
12
|
+
captureRejections?: boolean | undefined;
|
|
13
|
+
}
|
|
14
|
+
export declare class Socket extends EventEmitter implements DgramSocket {
|
|
15
|
+
_type: 'udp4' | 'udp6';
|
|
16
|
+
_localAddress?: {
|
|
17
|
+
address: string;
|
|
18
|
+
family: string;
|
|
19
|
+
port: number;
|
|
20
|
+
};
|
|
21
|
+
_remoteAddress?: {
|
|
22
|
+
address: string;
|
|
23
|
+
family: string;
|
|
24
|
+
port: number;
|
|
25
|
+
};
|
|
26
|
+
_webVPNUdpSocketPromise?: Promise<Awaited<ReturnType<WebVpnUdpSocket>> | undefined>;
|
|
27
|
+
_dataPort?: MessagePort;
|
|
28
|
+
_socketId?: number;
|
|
29
|
+
_sendQueue: Uint8Array[];
|
|
30
|
+
_sendQueueBytes: number;
|
|
31
|
+
_sendFlushScheduled: boolean;
|
|
32
|
+
_peerTailCache: Map<string, Uint8Array<ArrayBufferLike>>;
|
|
33
|
+
constructor(options: SocketOptions & EventEmitterOptions & {
|
|
34
|
+
connection?: ReturnType<WebVpnUdpSocket>;
|
|
35
|
+
});
|
|
36
|
+
_lastRecvBufferSize: number;
|
|
37
|
+
_lastSendBufferSize: number;
|
|
38
|
+
_lastTtl: number;
|
|
39
|
+
_lastMulticastTtl: number;
|
|
40
|
+
_lastMulticastLoopback: boolean;
|
|
41
|
+
_setUdpOption(option: UdpSocketOption): void;
|
|
42
|
+
_onDataPortBatch(buffer: ArrayBuffer): void;
|
|
43
|
+
_peerTail(address: string | undefined, port: number | undefined): Uint8Array;
|
|
44
|
+
_portSend(message: Uint8Array, address: string | undefined, port: number | undefined): void;
|
|
45
|
+
addMembership(multicastAddress: string, multicastInterface?: string | undefined): void;
|
|
46
|
+
address(): AddressInfo;
|
|
47
|
+
bind(port?: number | undefined, address?: string | undefined, callback?: (() => void) | undefined): this;
|
|
48
|
+
bind(port?: number | undefined, callback?: (() => void) | undefined): this;
|
|
49
|
+
bind(callback?: (() => void) | undefined): this;
|
|
50
|
+
bind(options: BindOptions, callback?: (() => void) | undefined): this;
|
|
51
|
+
close(callback?: (() => void) | undefined): this;
|
|
52
|
+
connect(port: number, address?: string, callback?: () => void): void;
|
|
53
|
+
connect(port: number, callback: () => void): void;
|
|
54
|
+
disconnect(): void;
|
|
55
|
+
dropMembership(multicastAddress: string, multicastInterface?: string | undefined): void;
|
|
56
|
+
getRecvBufferSize(): number;
|
|
57
|
+
getSendBufferSize(): number;
|
|
58
|
+
getSendQueueSize(): number;
|
|
59
|
+
getSendQueueCount(): number;
|
|
60
|
+
ref(): this;
|
|
61
|
+
remoteAddress(): AddressInfo;
|
|
62
|
+
send(msg: string | readonly any[] | Uint8Array, port?: number | undefined, address?: string | undefined, callback?: ((error: Error | null, bytes: number) => void) | undefined): void;
|
|
63
|
+
send(msg: string | readonly any[] | Uint8Array, port?: number | undefined, callback?: ((error: Error | null, bytes: number) => void) | undefined): void;
|
|
64
|
+
send(msg: string | readonly any[] | Uint8Array, callback?: ((error: Error | null, bytes: number) => void) | undefined): void;
|
|
65
|
+
send(msg: string | Uint8Array, offset: number, length: number, port?: number | undefined, address?: string | undefined, callback?: ((error: Error | null, bytes: number) => void) | undefined): void;
|
|
66
|
+
send(msg: string | Uint8Array, offset: number, length: number, port?: number | undefined, callback?: ((error: Error | null, bytes: number) => void) | undefined): void;
|
|
67
|
+
send(msg: string | Uint8Array, offset: number, length: number, callback?: ((error: Error | null, bytes: number) => void) | undefined): void;
|
|
68
|
+
send(msg: unknown, offset?: unknown, length?: unknown, port?: unknown, address?: unknown, callback?: unknown): void;
|
|
69
|
+
setBroadcast(flag: boolean): void;
|
|
70
|
+
setMulticastInterface(multicastInterface: string): void;
|
|
71
|
+
setMulticastLoopback(flag: boolean): boolean;
|
|
72
|
+
setMulticastTTL(ttl: number): number;
|
|
73
|
+
setRecvBufferSize(size: number): void;
|
|
74
|
+
setSendBufferSize(size: number): void;
|
|
75
|
+
setTTL(ttl: number): number;
|
|
76
|
+
unref(): this;
|
|
77
|
+
addSourceSpecificMembership(sourceAddress: string, groupAddress: string, multicastInterface?: string | undefined): void;
|
|
78
|
+
dropSourceSpecificMembership(sourceAddress: string, groupAddress: string, multicastInterface?: string | undefined): void;
|
|
79
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
80
|
+
}
|
|
81
|
+
export declare const createSocket: (options: SocketType | SocketOptions, callback?: (msg: Buffer, rinfo: RemoteInfo) => void) => Socket;
|
|
82
|
+
declare const _default: {
|
|
83
|
+
Socket: typeof Socket;
|
|
84
|
+
createSocket: typeof createSocket;
|
|
85
|
+
};
|
|
86
|
+
export default _default;
|
|
@@ -0,0 +1,180 @@
|
|
|
1
|
+
import type { IncomingHttpHeaders, OutgoingHttpHeaders, RequestOptions } from 'http';
|
|
2
|
+
import { Stream } from 'stream';
|
|
3
|
+
import { Buffer } from 'buffer';
|
|
4
|
+
import { Socket as NetSocket, Server as NetServer } from './net';
|
|
5
|
+
export declare const METHODS: string[];
|
|
6
|
+
export declare const STATUS_CODES: Record<number, string>;
|
|
7
|
+
export interface ParsedHead {
|
|
8
|
+
/** request only */
|
|
9
|
+
method?: string;
|
|
10
|
+
/** request only */
|
|
11
|
+
url?: string;
|
|
12
|
+
/** response only */
|
|
13
|
+
statusCode?: number;
|
|
14
|
+
/** response only */
|
|
15
|
+
statusMessage?: string;
|
|
16
|
+
httpVersionMajor: number;
|
|
17
|
+
httpVersionMinor: number;
|
|
18
|
+
httpVersion: string;
|
|
19
|
+
headers: IncomingHttpHeaders;
|
|
20
|
+
rawHeaders: string[];
|
|
21
|
+
}
|
|
22
|
+
interface ParserHandlers {
|
|
23
|
+
onHeaders: (head: ParsedHead) => void;
|
|
24
|
+
onBody: (chunk: Uint8Array) => void;
|
|
25
|
+
onComplete: () => void;
|
|
26
|
+
}
|
|
27
|
+
export declare class HTTPParser {
|
|
28
|
+
private readonly mode;
|
|
29
|
+
private readonly handlers;
|
|
30
|
+
private buf;
|
|
31
|
+
private state;
|
|
32
|
+
private framing;
|
|
33
|
+
private bodyRemaining;
|
|
34
|
+
private chunkState;
|
|
35
|
+
skipBody: boolean;
|
|
36
|
+
constructor(mode: 'request' | 'response', handlers: ParserHandlers);
|
|
37
|
+
execute(chunk: Uint8Array): void;
|
|
38
|
+
finish(): void;
|
|
39
|
+
private reset;
|
|
40
|
+
private parseHead;
|
|
41
|
+
private applyVersion;
|
|
42
|
+
private addHeader;
|
|
43
|
+
private setupBody;
|
|
44
|
+
private consumeBody;
|
|
45
|
+
private consumeChunked;
|
|
46
|
+
}
|
|
47
|
+
export declare class IncomingMessage extends Stream.Readable {
|
|
48
|
+
httpVersion: string;
|
|
49
|
+
httpVersionMajor: number;
|
|
50
|
+
httpVersionMinor: number;
|
|
51
|
+
headers: IncomingHttpHeaders;
|
|
52
|
+
rawHeaders: string[];
|
|
53
|
+
trailers: Record<string, string>;
|
|
54
|
+
rawTrailers: string[];
|
|
55
|
+
/** request only */
|
|
56
|
+
method?: string;
|
|
57
|
+
/** request only */
|
|
58
|
+
url?: string;
|
|
59
|
+
/** response only */
|
|
60
|
+
statusCode?: number;
|
|
61
|
+
/** response only */
|
|
62
|
+
statusMessage?: string;
|
|
63
|
+
complete: boolean;
|
|
64
|
+
socket: NetSocket;
|
|
65
|
+
constructor(socket: NetSocket);
|
|
66
|
+
get connection(): NetSocket;
|
|
67
|
+
_applyHead(head: ParsedHead): void;
|
|
68
|
+
_read(): void;
|
|
69
|
+
setTimeout(msecs: number, callback?: () => void): this;
|
|
70
|
+
}
|
|
71
|
+
declare abstract class OutgoingMessage extends Stream.Writable {
|
|
72
|
+
private _headerStore;
|
|
73
|
+
headersSent: boolean;
|
|
74
|
+
chunkedEncoding: boolean;
|
|
75
|
+
finished: boolean;
|
|
76
|
+
protected _bodyWritten: boolean;
|
|
77
|
+
abstract socket: NetSocket | null;
|
|
78
|
+
setHeader(name: string, value: number | string | readonly string[]): this;
|
|
79
|
+
getHeader(name: string): number | string | string[] | undefined;
|
|
80
|
+
getHeaderNames(): string[];
|
|
81
|
+
getHeaders(): OutgoingHttpHeaders;
|
|
82
|
+
hasHeader(name: string): boolean;
|
|
83
|
+
removeHeader(name: string): void;
|
|
84
|
+
protected _storeHeader(startLine: string): string;
|
|
85
|
+
protected abstract _shouldSendBody(): boolean;
|
|
86
|
+
protected abstract _implicitHeader(): void;
|
|
87
|
+
protected _writeToSocket(data: Buffer, callback: (error?: Error | null) => void): void;
|
|
88
|
+
write(chunk: unknown, encoding?: BufferEncoding | ((error: Error | null | undefined) => void), callback?: (error: Error | null | undefined) => void): boolean;
|
|
89
|
+
_write(chunk: Buffer, _encoding: BufferEncoding, callback: (error?: Error | null) => void): void;
|
|
90
|
+
_final(callback: (error?: Error | null) => void): void;
|
|
91
|
+
end(chunk?: unknown, encoding?: BufferEncoding | (() => void), callback?: () => void): this;
|
|
92
|
+
protected _headBlock?: string;
|
|
93
|
+
}
|
|
94
|
+
export interface ServerResponseOptions {
|
|
95
|
+
req: IncomingMessage;
|
|
96
|
+
}
|
|
97
|
+
export declare class ServerResponse extends OutgoingMessage {
|
|
98
|
+
statusCode: number;
|
|
99
|
+
statusMessage?: string;
|
|
100
|
+
private _writeHeadCalled;
|
|
101
|
+
sendDate: boolean;
|
|
102
|
+
req: IncomingMessage;
|
|
103
|
+
socket: NetSocket | null;
|
|
104
|
+
_keepAlive: boolean;
|
|
105
|
+
constructor(req: IncomingMessage);
|
|
106
|
+
protected _shouldSendBody(): boolean;
|
|
107
|
+
writeHead(statusCode: number, statusMessage?: string | OutgoingHttpHeaders | OutgoingHttpHeaders[keyof OutgoingHttpHeaders][], headers?: OutgoingHttpHeaders): this;
|
|
108
|
+
private _appendHeader;
|
|
109
|
+
protected _implicitHeader(): void;
|
|
110
|
+
writeContinue(): void;
|
|
111
|
+
setTimeout(msecs: number, callback?: () => void): this;
|
|
112
|
+
}
|
|
113
|
+
export interface ClientRequestArgs extends RequestOptions {
|
|
114
|
+
host?: string;
|
|
115
|
+
hostname?: string;
|
|
116
|
+
port?: number | string;
|
|
117
|
+
path?: string;
|
|
118
|
+
}
|
|
119
|
+
export declare class ClientRequest extends OutgoingMessage {
|
|
120
|
+
method: string;
|
|
121
|
+
path: string;
|
|
122
|
+
host: string;
|
|
123
|
+
protocol: string;
|
|
124
|
+
socket: NetSocket;
|
|
125
|
+
/** alias retained for Node compatibility */
|
|
126
|
+
get connection(): NetSocket;
|
|
127
|
+
res: IncomingMessage | null;
|
|
128
|
+
aborted: boolean;
|
|
129
|
+
private _aborted;
|
|
130
|
+
constructor(options: ClientRequestArgs, callback?: (res: IncomingMessage) => void);
|
|
131
|
+
protected _shouldSendBody(): boolean;
|
|
132
|
+
protected _implicitHeader(): void;
|
|
133
|
+
private _attachResponseParser;
|
|
134
|
+
abort(): void;
|
|
135
|
+
destroy(error?: Error): this;
|
|
136
|
+
end(chunk?: unknown, encoding?: unknown, callback?: unknown): this;
|
|
137
|
+
protected _writeToSocket(data: Buffer, callback: (error?: Error | null) => void): void;
|
|
138
|
+
setTimeout(timeout: number, callback?: () => void): this;
|
|
139
|
+
setNoDelay(noDelay?: boolean): void;
|
|
140
|
+
setSocketKeepAlive(enable?: boolean, initialDelay?: number): void;
|
|
141
|
+
}
|
|
142
|
+
export type RequestListener = (req: IncomingMessage, res: ServerResponse) => void;
|
|
143
|
+
declare class ServerImpl extends NetServer {
|
|
144
|
+
constructor(options?: object | RequestListener, requestListener?: RequestListener);
|
|
145
|
+
private _handleConnection;
|
|
146
|
+
}
|
|
147
|
+
export declare const Server: typeof ServerImpl;
|
|
148
|
+
export type Server = ServerImpl;
|
|
149
|
+
export declare class Agent {
|
|
150
|
+
maxSockets: number;
|
|
151
|
+
maxFreeSockets: number;
|
|
152
|
+
keepAlive: boolean;
|
|
153
|
+
options: Record<string, unknown>;
|
|
154
|
+
constructor(options?: Record<string, unknown>);
|
|
155
|
+
getName(options?: {
|
|
156
|
+
host?: string;
|
|
157
|
+
port?: number;
|
|
158
|
+
localAddress?: string;
|
|
159
|
+
}): string;
|
|
160
|
+
destroy(): void;
|
|
161
|
+
}
|
|
162
|
+
export declare const globalAgent: Agent;
|
|
163
|
+
export declare const request: (...args: [options: string | URL | ClientRequestArgs, callback?: (res: IncomingMessage) => void] | [url: string | URL, options: ClientRequestArgs, callback?: (res: IncomingMessage) => void]) => ClientRequest;
|
|
164
|
+
export declare const get: (...args: [options: string | URL | ClientRequestArgs, callback?: (res: IncomingMessage) => void] | [url: string | URL, options: ClientRequestArgs, callback?: (res: IncomingMessage) => void]) => ClientRequest;
|
|
165
|
+
export declare const createServer: (options?: object | RequestListener, requestListener?: RequestListener) => Server;
|
|
166
|
+
export declare const _default: {
|
|
167
|
+
METHODS: string[];
|
|
168
|
+
STATUS_CODES: Record<number, string>;
|
|
169
|
+
Agent: typeof Agent;
|
|
170
|
+
globalAgent: Agent;
|
|
171
|
+
Server: typeof ServerImpl;
|
|
172
|
+
ServerResponse: typeof ServerResponse;
|
|
173
|
+
IncomingMessage: typeof IncomingMessage;
|
|
174
|
+
ClientRequest: typeof ClientRequest;
|
|
175
|
+
OutgoingMessage: typeof OutgoingMessage;
|
|
176
|
+
createServer: typeof createServer;
|
|
177
|
+
request: typeof request;
|
|
178
|
+
get: typeof get;
|
|
179
|
+
};
|
|
180
|
+
export default _default;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './utils';
|
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
import type { Socket as NetSocket, SocketConnectOpts, SocketConstructorOpts, Server as TCPServer, ServerOpts, ListenOptions, AddressInfo } from 'net';
|
|
2
|
+
import type { Resolvers } from '../api';
|
|
3
|
+
import { DuplexOptions, Stream } from 'stream';
|
|
4
|
+
type WebVpnTcpSocket = Resolvers['cloud']['webvpn']['tcpSocket'];
|
|
5
|
+
type WebVpnTcpSocketListener = Resolvers['cloud']['webvpn']['tcpSocketListener'];
|
|
6
|
+
import { EventEmitter } from 'events';
|
|
7
|
+
import { isIP, isIPv4, isIPv6 } from './utils';
|
|
8
|
+
export declare class Socket extends Stream.Duplex implements NetSocket {
|
|
9
|
+
_localAddress?: {
|
|
10
|
+
address: string;
|
|
11
|
+
family: string;
|
|
12
|
+
port: number;
|
|
13
|
+
};
|
|
14
|
+
_remoteAddress?: {
|
|
15
|
+
address: string;
|
|
16
|
+
family: string;
|
|
17
|
+
port: number;
|
|
18
|
+
};
|
|
19
|
+
_webVPNTcpSocketPromise?: Promise<(Awaited<ReturnType<WebVpnTcpSocket>> & {
|
|
20
|
+
reader: ReadableStreamDefaultReader<Uint8Array>;
|
|
21
|
+
writer: WritableStreamDefaultWriter<Uint8Array>;
|
|
22
|
+
}) | undefined>;
|
|
23
|
+
constructor(options?: SocketConstructorOpts & DuplexOptions & {
|
|
24
|
+
connection?: ReturnType<WebVpnTcpSocket>;
|
|
25
|
+
});
|
|
26
|
+
__webvpn_tcp_socket_init__(connection: ReturnType<WebVpnTcpSocket>): Promise<(import("../../api/local-net").LocalTcpSocket & {
|
|
27
|
+
reader: ReadableStreamDefaultReader<Uint8Array>;
|
|
28
|
+
writer: WritableStreamDefaultWriter<Uint8Array>;
|
|
29
|
+
}) | undefined>;
|
|
30
|
+
/** STREAM IMPL */
|
|
31
|
+
_read(size: number): void;
|
|
32
|
+
_write(chunk: Uint8Array, encoding: BufferEncoding, callback: (error?: Error | null) => void): void;
|
|
33
|
+
/** SOCKET IMPL */
|
|
34
|
+
connect(options: SocketConnectOpts, connectionListener?: (() => void) | undefined): this;
|
|
35
|
+
connect(port: number, host: string, connectionListener?: (() => void) | undefined): this;
|
|
36
|
+
connect(port: number, connectionListener?: (() => void) | undefined): this;
|
|
37
|
+
connect(path: string, connectionListener?: (() => void) | undefined): this;
|
|
38
|
+
connect(port: unknown, host?: unknown, connectionListener?: unknown): this;
|
|
39
|
+
_end(chunk: any, cb?: () => void): this;
|
|
40
|
+
_end(chunk: any, encoding?: BufferEncoding, cb?: () => void): this;
|
|
41
|
+
_destroy(error?: Error | null | undefined): this;
|
|
42
|
+
destroySoon(): void;
|
|
43
|
+
resetAndDestroy(): this;
|
|
44
|
+
_timeoutMs?: number;
|
|
45
|
+
_timeoutTimer?: ReturnType<typeof setTimeout>;
|
|
46
|
+
_restartTimeoutTimer(): void;
|
|
47
|
+
setTimeout(timeout: number, callback?: (() => void) | undefined): this;
|
|
48
|
+
setNoDelay(noDelay?: boolean | undefined): this;
|
|
49
|
+
setKeepAlive(enable?: boolean | undefined, initialDelay?: number | undefined): this;
|
|
50
|
+
setSendBufferSize(size: number): this;
|
|
51
|
+
setRecvBufferSize(size: number): this;
|
|
52
|
+
_typeOfService?: number;
|
|
53
|
+
getTypeOfService(): number;
|
|
54
|
+
setTypeOfService(tos: number): this;
|
|
55
|
+
_setTcpOption(option: import('../../api/webvpn/tcp').TcpSocketOption): void;
|
|
56
|
+
write(buffer: Uint8Array | string, cb?: (err?: Error) => void): boolean;
|
|
57
|
+
write(str: Uint8Array | string, encoding?: BufferEncoding, cb?: (err?: Error) => void): boolean;
|
|
58
|
+
address(): AddressInfo | {};
|
|
59
|
+
unref(): this;
|
|
60
|
+
ref(): this;
|
|
61
|
+
autoSelectFamilyAttemptedAddresses: string[];
|
|
62
|
+
bufferSize: number;
|
|
63
|
+
bytesRead: number;
|
|
64
|
+
bytesWritten: number;
|
|
65
|
+
connecting: boolean;
|
|
66
|
+
pending: boolean;
|
|
67
|
+
get localAddress(): string;
|
|
68
|
+
get localPort(): number;
|
|
69
|
+
get localFamily(): string;
|
|
70
|
+
readyState: 'opening' | 'open' | 'readOnly' | 'writeOnly' | 'closed';
|
|
71
|
+
get remoteAddress(): string;
|
|
72
|
+
get remotePort(): number;
|
|
73
|
+
get remoteFamily(): string;
|
|
74
|
+
timeout?: number | undefined;
|
|
75
|
+
}
|
|
76
|
+
interface EventEmitterOptions {
|
|
77
|
+
/**
|
|
78
|
+
* Enables automatic capturing of promise rejection.
|
|
79
|
+
*/
|
|
80
|
+
captureRejections?: boolean | undefined;
|
|
81
|
+
}
|
|
82
|
+
export declare class Server extends EventEmitter implements TCPServer {
|
|
83
|
+
_localAddress?: {
|
|
84
|
+
address: string;
|
|
85
|
+
family: string;
|
|
86
|
+
port: number;
|
|
87
|
+
};
|
|
88
|
+
_webVPNTcpSocketListenerPromise?: Promise<Awaited<ReturnType<WebVpnTcpSocketListener>> | undefined>;
|
|
89
|
+
constructor(options?: ServerOpts & EventEmitterOptions & {
|
|
90
|
+
connection?: ReturnType<WebVpnTcpSocketListener>;
|
|
91
|
+
}, connectionListener?: (socket: Socket) => void);
|
|
92
|
+
__webvpn_tcp_socket_listener_init__(connection: ReturnType<WebVpnTcpSocketListener>): Promise<{
|
|
93
|
+
localAddress: string;
|
|
94
|
+
localFamily: "IPv4" | "IPv6";
|
|
95
|
+
localPort: number;
|
|
96
|
+
close: () => Promise<void>;
|
|
97
|
+
} | undefined>;
|
|
98
|
+
listen(port?: number | undefined, hostname?: string | undefined, backlog?: number | undefined, listeningListener?: (() => void) | undefined): this;
|
|
99
|
+
listen(port?: number | undefined, hostname?: string | undefined, listeningListener?: (() => void) | undefined): this;
|
|
100
|
+
listen(port?: number | undefined, backlog?: number | undefined, listeningListener?: (() => void) | undefined): this;
|
|
101
|
+
listen(port?: number | undefined, listeningListener?: (() => void) | undefined): this;
|
|
102
|
+
listen(path: string, backlog?: number | undefined, listeningListener?: (() => void) | undefined): this;
|
|
103
|
+
listen(path: string, listeningListener?: (() => void) | undefined): this;
|
|
104
|
+
listen(options: ListenOptions, listeningListener?: (() => void) | undefined): this;
|
|
105
|
+
listen(handle: any, backlog?: number | undefined, listeningListener?: (() => void) | undefined): this;
|
|
106
|
+
listen(handle: any, listeningListener?: (() => void) | undefined): this;
|
|
107
|
+
listen(port?: unknown, hostname?: unknown, backlog?: unknown, listeningListener?: unknown): this;
|
|
108
|
+
close(callback?: ((err?: Error | undefined) => void) | undefined): this;
|
|
109
|
+
address(): string | AddressInfo | null;
|
|
110
|
+
getConnections(cb: (error: Error | null, count: number) => void): this;
|
|
111
|
+
ref(): this;
|
|
112
|
+
unref(): this;
|
|
113
|
+
maxConnections: number;
|
|
114
|
+
connections: number;
|
|
115
|
+
listening: boolean;
|
|
116
|
+
[Symbol.asyncDispose](): Promise<void>;
|
|
117
|
+
}
|
|
118
|
+
export declare const connect: (options: SocketConnectOpts, connectionListener?: () => void) => Socket;
|
|
119
|
+
export declare const createConnection: (options: SocketConnectOpts, connectionListener?: () => void) => Socket;
|
|
120
|
+
export declare const createServer: (options?: ServerOpts | ((socket: Socket) => void), connectionListener?: (socket: Socket) => void) => Server;
|
|
121
|
+
export { isIP, isIPv4, isIPv6 };
|
|
122
|
+
export declare const _default: {
|
|
123
|
+
Socket: typeof Socket;
|
|
124
|
+
Server: typeof Server;
|
|
125
|
+
connect: typeof connect;
|
|
126
|
+
createConnection: typeof createConnection;
|
|
127
|
+
createServer: typeof createServer;
|
|
128
|
+
isIP: typeof isIP;
|
|
129
|
+
isIPv4: typeof isIPv4;
|
|
130
|
+
isIPv6: typeof isIPv6;
|
|
131
|
+
};
|
|
132
|
+
export default _default;
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
import type { ListenOptions, SocketConnectOpts } from 'net';
|
|
2
|
+
import { BindOptions } from 'dgram';
|
|
3
|
+
export declare const textEncoder: TextEncoder;
|
|
4
|
+
export declare const textDecoder: TextDecoder;
|
|
5
|
+
export declare const isIPv4: (input: string) => boolean;
|
|
6
|
+
export declare const isIPv6: (input: string) => boolean;
|
|
7
|
+
export declare const isIP: (input: string) => 0 | 4 | 6;
|
|
8
|
+
type TcpConnectArgs = [options: SocketConnectOpts, connectionListener?: () => void] | [port: number, host: string, connectionListener?: () => void] | [port: number, connectionListener?: () => void] | [path: string, connectionListener?: () => void];
|
|
9
|
+
type TcpListenArgs = [port?: number, hostname?: string, backlog?: number, listeningListener?: (() => void)] | [port?: number, hostname?: string, listeningListener?: (() => void)] | [port?: number, backlog?: number, listeningListener?: (() => void)] | [port?: number, listeningListener?: (() => void)] | [path: string, backlog?: number, listeningListener?: (() => void)] | [path: string, listeningListener?: (() => void)] | [options: ListenOptions, listeningListener?: (() => void)] | [handle: any, backlog?: number, listeningListener?: (() => void)] | [handle: any, listeningListener?: (() => void)];
|
|
10
|
+
export declare const normalizeNetArgs: <T extends TcpConnectArgs | TcpListenArgs>(...args: T) => {
|
|
11
|
+
port: number;
|
|
12
|
+
host: string | undefined;
|
|
13
|
+
callback: (() => void) | undefined;
|
|
14
|
+
} | ((T[0] extends object ? T[0] : never) & {
|
|
15
|
+
callback: (() => void) | undefined;
|
|
16
|
+
});
|
|
17
|
+
export declare const normalizeDgramBindArgs: (...args: [port?: number, address?: string, callback?: () => void] | [port?: number, callback?: () => void] | [callback?: () => void] | [options: BindOptions, callback?: () => void]) => {
|
|
18
|
+
exclusive?: boolean | undefined;
|
|
19
|
+
fd?: number | undefined;
|
|
20
|
+
address: string | undefined;
|
|
21
|
+
port: number;
|
|
22
|
+
callback: (() => void) | undefined;
|
|
23
|
+
};
|
|
24
|
+
export declare const normalizeDgramSendArgs: (...args: [msg: string | readonly any[] | Uint8Array, port: number, address: string, callback: (error: Error | null, bytes: number) => void] | [msg: string | readonly any[] | Uint8Array, port: number, callback: (error: Error | null, bytes: number) => void] | [msg: string | readonly any[] | Uint8Array, callback: (error: Error | null, bytes: number) => void] | [msg: string | Uint8Array, offset: number, length: number, port: number, address: string, callback: (error: Error | null, bytes: number) => void] | [msg: string | Uint8Array, offset: number, length: number, port: number, callback: (error: Error | null, bytes: number) => void] | [msg: string | Uint8Array, offset: number, length: number, callback: (error: Error | null, bytes: number) => void]) => {
|
|
25
|
+
message: string | readonly any[] | Uint8Array<ArrayBufferLike>;
|
|
26
|
+
offset: number | ((error: Error | null, bytes: number) => void);
|
|
27
|
+
length: number;
|
|
28
|
+
port: number;
|
|
29
|
+
address: string | undefined;
|
|
30
|
+
callback: (() => void) | undefined;
|
|
31
|
+
};
|
|
32
|
+
export {};
|
package/net-CpuAhaQC.cjs
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
const e=require("./rolldown-runtime-Doa5O59j.cjs"),t=require("./api-DD5v1qP9.cjs"),n=require("./utils-CoimMjf9.cjs");let r=require("stream"),i=require("events");var a=e.n({Server:()=>s,Socket:()=>o,_default:()=>d,connect:()=>c,createConnection:()=>l,createServer:()=>u,default:()=>d,isIP:()=>n.t,isIPv4:()=>n.n,isIPv6:()=>n.r}),o=class extends r.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)}__webvpn_tcp_socket_init__(e){if(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=>{e&&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 r=n.o(...e),i=this.__webvpn_tcp_socket_init__(t.t.then(e=>e.cloud.webvpn.tcpSocket({remoteAddress:r.host??`localhost`,remotePort:r.port})));return r.callback&&i.then(e=>{e&&r.callback.call(this)}),this}_end(...e){return this._webVPNTcpSocketPromise?(e.length!==0&&this.write(e[0],e[1],e[2]),this._webVPNTcpSocketPromise.then(async e=>{e&&await e.end()}),this):this}_destroy(e){return this._timeoutTimer&&clearTimeout(this._timeoutTimer),this._webVPNTcpSocketPromise&&this._webVPNTcpSocketPromise.then(async e=>{e&&await e.destroy()}),this}destroySoon(){this._webVPNTcpSocketPromise&&this._webVPNTcpSocketPromise.then(async e=>{e&&await e.destroySoon()})}resetAndDestroy(){return this._webVPNTcpSocketPromise&&this._webVPNTcpSocketPromise.then(async e=>{e&&await e.resetAndDestroy()}),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},s=class extends i.EventEmitter{_localAddress;_webVPNTcpSocketListenerPromise;constructor(e,t){super(e),t&&this.on(`connection`,t),e?.connection&&this.__webvpn_tcp_socket_listener_init__(e.connection)}__webvpn_tcp_socket_listener_init__(e){return 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=>{e&&this.emit(`listening`)}),this._webVPNTcpSocketListenerPromise}listen(...e){let r=n.o(...e),i=e=>{let t=new o({connection:Promise.resolve(e)});this.emit(`connection`,t)},a=e=>t.t.then(t=>t.cloud.webvpn.tcpSocketListener({localAddress:e,localPort:r.port,onConnection:i})),s=r.host?a(r.host):a(`::`).catch(()=>a(`0.0.0.0`)),c=this.__webvpn_tcp_socket_listener_init__(s);return r.callback&&c.then(e=>{e&&r.callback.call(this)}),this}close(e){return this._webVPNTcpSocketListenerPromise&&this._webVPNTcpSocketListenerPromise.then(async t=>{if(t)try{await t.close(),this._localAddress=void 0,this.emit(`close`),e&&e()}catch(t){this._localAddress=void 0,this.emit(`close`),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](){}},c=(e,t)=>new o().connect(e,t),l=(e,t)=>new o().connect(e,t),u=(e,t)=>{typeof e==`function`&&(t=e,e=void 0);let n=new s(e);return t&&n.on(`connection`,t),n},d={Socket:o,Server:s,connect:c,createConnection:l,createServer:u,isIP:n.t,isIPv4:n.n,isIPv6:n.r};Object.defineProperty(exports,"a",{enumerable:!0,get:function(){return l}}),Object.defineProperty(exports,"i",{enumerable:!0,get:function(){return c}}),Object.defineProperty(exports,"n",{enumerable:!0,get:function(){return o}}),Object.defineProperty(exports,"o",{enumerable:!0,get:function(){return u}}),Object.defineProperty(exports,"r",{enumerable:!0,get:function(){return d}}),Object.defineProperty(exports,"s",{enumerable:!0,get:function(){return a}}),Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return s}});
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { n as e } from "./
|
|
2
|
-
import { t } from "./api
|
|
3
|
-
import { n, o as r, r as i, t as a } from "./utils-
|
|
1
|
+
import { n as e } from "./rolldown-runtime-DF993M8W.js";
|
|
2
|
+
import { t } from "./api--bnCFd4w.js";
|
|
3
|
+
import { n, o as r, r as i, t as a } from "./utils-DPtyxGQu.js";
|
|
4
4
|
import { Stream as o } from "stream";
|
|
5
5
|
import { EventEmitter as s } from "events";
|
|
6
6
|
//#region src/lib/webvpn/net.ts
|
package/net.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}})
|
|
1
|
+
Object.defineProperties(exports,{__esModule:{value:!0},[Symbol.toStringTag]:{value:`Module`}});const e=require("./utils-CoimMjf9.cjs"),t=require("./net-CpuAhaQC.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.t,exports.isIPv4=e.n,exports.isIPv6=e.r;
|
package/net.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import "./
|
|
2
|
-
import { n as
|
|
3
|
-
import { a as r, i, n as a, o, r as s, t as c } from "./net-Bl6_W3bd.js";
|
|
1
|
+
import { n as e, r as t, t as n } from "./utils-DPtyxGQu.js";
|
|
2
|
+
import { a as r, i, n as a, o, r as s, t as c } from "./net-DKMWPXb_.js";
|
|
4
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, e as isIPv4, t as isIPv6 };
|