@secure-exec/nodejs 0.2.0-rc.1
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/LICENSE +191 -0
- package/README.md +7 -0
- package/dist/bindings.d.ts +31 -0
- package/dist/bindings.js +67 -0
- package/dist/bridge/active-handles.d.ts +22 -0
- package/dist/bridge/active-handles.js +112 -0
- package/dist/bridge/child-process.d.ts +99 -0
- package/dist/bridge/child-process.js +672 -0
- package/dist/bridge/dispatch.d.ts +2 -0
- package/dist/bridge/dispatch.js +40 -0
- package/dist/bridge/fs.d.ts +502 -0
- package/dist/bridge/fs.js +3307 -0
- package/dist/bridge/index.d.ts +10 -0
- package/dist/bridge/index.js +41 -0
- package/dist/bridge/module.d.ts +75 -0
- package/dist/bridge/module.js +325 -0
- package/dist/bridge/network.d.ts +1093 -0
- package/dist/bridge/network.js +8651 -0
- package/dist/bridge/os.d.ts +13 -0
- package/dist/bridge/os.js +256 -0
- package/dist/bridge/polyfills.d.ts +9 -0
- package/dist/bridge/polyfills.js +67 -0
- package/dist/bridge/process.d.ts +121 -0
- package/dist/bridge/process.js +1382 -0
- package/dist/bridge/whatwg-url.d.ts +67 -0
- package/dist/bridge/whatwg-url.js +712 -0
- package/dist/bridge-contract.d.ts +774 -0
- package/dist/bridge-contract.js +172 -0
- package/dist/bridge-handlers.d.ts +199 -0
- package/dist/bridge-handlers.js +4263 -0
- package/dist/bridge-loader.d.ts +9 -0
- package/dist/bridge-loader.js +87 -0
- package/dist/bridge-setup.d.ts +1 -0
- package/dist/bridge-setup.js +3 -0
- package/dist/bridge.js +21652 -0
- package/dist/builtin-modules.d.ts +25 -0
- package/dist/builtin-modules.js +312 -0
- package/dist/default-network-adapter.d.ts +13 -0
- package/dist/default-network-adapter.js +351 -0
- package/dist/driver.d.ts +87 -0
- package/dist/driver.js +191 -0
- package/dist/esm-compiler.d.ts +14 -0
- package/dist/esm-compiler.js +68 -0
- package/dist/execution-driver.d.ts +37 -0
- package/dist/execution-driver.js +977 -0
- package/dist/host-network-adapter.d.ts +7 -0
- package/dist/host-network-adapter.js +279 -0
- package/dist/index.d.ts +20 -0
- package/dist/index.js +23 -0
- package/dist/isolate-bootstrap.d.ts +86 -0
- package/dist/isolate-bootstrap.js +125 -0
- package/dist/ivm-compat.d.ts +7 -0
- package/dist/ivm-compat.js +31 -0
- package/dist/kernel-runtime.d.ts +58 -0
- package/dist/kernel-runtime.js +535 -0
- package/dist/module-access.d.ts +75 -0
- package/dist/module-access.js +606 -0
- package/dist/module-resolver.d.ts +8 -0
- package/dist/module-resolver.js +150 -0
- package/dist/os-filesystem.d.ts +42 -0
- package/dist/os-filesystem.js +161 -0
- package/dist/package-bundler.d.ts +36 -0
- package/dist/package-bundler.js +497 -0
- package/dist/polyfills.d.ts +17 -0
- package/dist/polyfills.js +97 -0
- package/dist/worker-adapter.d.ts +21 -0
- package/dist/worker-adapter.js +34 -0
- package/package.json +123 -0
|
@@ -0,0 +1,172 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Bridge contract: typed declarations for the globals shared between the
|
|
3
|
+
* host (Node.js) and the isolate (sandbox V8 context).
|
|
4
|
+
*
|
|
5
|
+
* Two categories:
|
|
6
|
+
* - Host bridge globals: set by the host before bridge code runs (fs refs, timers, etc.)
|
|
7
|
+
* - Runtime bridge globals: installed by the bridge bundle itself (active handles, modules, etc.)
|
|
8
|
+
*
|
|
9
|
+
* The typed `Ref` aliases describe the bridge calling convention for each global.
|
|
10
|
+
*/
|
|
11
|
+
function valuesOf(object) {
|
|
12
|
+
return Object.values(object);
|
|
13
|
+
}
|
|
14
|
+
/** Globals injected by the host before the bridge bundle executes. */
|
|
15
|
+
export const HOST_BRIDGE_GLOBAL_KEYS = {
|
|
16
|
+
dynamicImport: "_dynamicImport",
|
|
17
|
+
loadPolyfill: "_loadPolyfill",
|
|
18
|
+
resolveModule: "_resolveModule",
|
|
19
|
+
loadFile: "_loadFile",
|
|
20
|
+
scheduleTimer: "_scheduleTimer",
|
|
21
|
+
cryptoRandomFill: "_cryptoRandomFill",
|
|
22
|
+
cryptoRandomUuid: "_cryptoRandomUUID",
|
|
23
|
+
cryptoHashDigest: "_cryptoHashDigest",
|
|
24
|
+
cryptoHmacDigest: "_cryptoHmacDigest",
|
|
25
|
+
cryptoPbkdf2: "_cryptoPbkdf2",
|
|
26
|
+
cryptoScrypt: "_cryptoScrypt",
|
|
27
|
+
cryptoCipheriv: "_cryptoCipheriv",
|
|
28
|
+
cryptoDecipheriv: "_cryptoDecipheriv",
|
|
29
|
+
cryptoCipherivCreate: "_cryptoCipherivCreate",
|
|
30
|
+
cryptoCipherivUpdate: "_cryptoCipherivUpdate",
|
|
31
|
+
cryptoCipherivFinal: "_cryptoCipherivFinal",
|
|
32
|
+
cryptoSign: "_cryptoSign",
|
|
33
|
+
cryptoVerify: "_cryptoVerify",
|
|
34
|
+
cryptoAsymmetricOp: "_cryptoAsymmetricOp",
|
|
35
|
+
cryptoCreateKeyObject: "_cryptoCreateKeyObject",
|
|
36
|
+
cryptoGenerateKeyPairSync: "_cryptoGenerateKeyPairSync",
|
|
37
|
+
cryptoGenerateKeySync: "_cryptoGenerateKeySync",
|
|
38
|
+
cryptoGeneratePrimeSync: "_cryptoGeneratePrimeSync",
|
|
39
|
+
cryptoDiffieHellman: "_cryptoDiffieHellman",
|
|
40
|
+
cryptoDiffieHellmanGroup: "_cryptoDiffieHellmanGroup",
|
|
41
|
+
cryptoDiffieHellmanSessionCreate: "_cryptoDiffieHellmanSessionCreate",
|
|
42
|
+
cryptoDiffieHellmanSessionCall: "_cryptoDiffieHellmanSessionCall",
|
|
43
|
+
cryptoSubtle: "_cryptoSubtle",
|
|
44
|
+
fsReadFile: "_fsReadFile",
|
|
45
|
+
fsWriteFile: "_fsWriteFile",
|
|
46
|
+
fsReadFileBinary: "_fsReadFileBinary",
|
|
47
|
+
fsWriteFileBinary: "_fsWriteFileBinary",
|
|
48
|
+
fsReadDir: "_fsReadDir",
|
|
49
|
+
fsMkdir: "_fsMkdir",
|
|
50
|
+
fsRmdir: "_fsRmdir",
|
|
51
|
+
fsExists: "_fsExists",
|
|
52
|
+
fsStat: "_fsStat",
|
|
53
|
+
fsUnlink: "_fsUnlink",
|
|
54
|
+
fsRename: "_fsRename",
|
|
55
|
+
fsChmod: "_fsChmod",
|
|
56
|
+
fsChown: "_fsChown",
|
|
57
|
+
fsLink: "_fsLink",
|
|
58
|
+
fsSymlink: "_fsSymlink",
|
|
59
|
+
fsReadlink: "_fsReadlink",
|
|
60
|
+
fsLstat: "_fsLstat",
|
|
61
|
+
fsTruncate: "_fsTruncate",
|
|
62
|
+
fsUtimes: "_fsUtimes",
|
|
63
|
+
childProcessSpawnStart: "_childProcessSpawnStart",
|
|
64
|
+
childProcessStdinWrite: "_childProcessStdinWrite",
|
|
65
|
+
childProcessStdinClose: "_childProcessStdinClose",
|
|
66
|
+
childProcessKill: "_childProcessKill",
|
|
67
|
+
childProcessSpawnSync: "_childProcessSpawnSync",
|
|
68
|
+
networkFetchRaw: "_networkFetchRaw",
|
|
69
|
+
networkDnsLookupRaw: "_networkDnsLookupRaw",
|
|
70
|
+
networkHttpRequestRaw: "_networkHttpRequestRaw",
|
|
71
|
+
networkHttpServerListenRaw: "_networkHttpServerListenRaw",
|
|
72
|
+
networkHttpServerCloseRaw: "_networkHttpServerCloseRaw",
|
|
73
|
+
networkHttpServerRespondRaw: "_networkHttpServerRespondRaw",
|
|
74
|
+
networkHttpServerWaitRaw: "_networkHttpServerWaitRaw",
|
|
75
|
+
networkHttp2ServerListenRaw: "_networkHttp2ServerListenRaw",
|
|
76
|
+
networkHttp2ServerCloseRaw: "_networkHttp2ServerCloseRaw",
|
|
77
|
+
networkHttp2ServerWaitRaw: "_networkHttp2ServerWaitRaw",
|
|
78
|
+
networkHttp2SessionConnectRaw: "_networkHttp2SessionConnectRaw",
|
|
79
|
+
networkHttp2SessionRequestRaw: "_networkHttp2SessionRequestRaw",
|
|
80
|
+
networkHttp2SessionSettingsRaw: "_networkHttp2SessionSettingsRaw",
|
|
81
|
+
networkHttp2SessionSetLocalWindowSizeRaw: "_networkHttp2SessionSetLocalWindowSizeRaw",
|
|
82
|
+
networkHttp2SessionGoawayRaw: "_networkHttp2SessionGoawayRaw",
|
|
83
|
+
networkHttp2SessionCloseRaw: "_networkHttp2SessionCloseRaw",
|
|
84
|
+
networkHttp2SessionDestroyRaw: "_networkHttp2SessionDestroyRaw",
|
|
85
|
+
networkHttp2SessionWaitRaw: "_networkHttp2SessionWaitRaw",
|
|
86
|
+
networkHttp2ServerPollRaw: "_networkHttp2ServerPollRaw",
|
|
87
|
+
networkHttp2SessionPollRaw: "_networkHttp2SessionPollRaw",
|
|
88
|
+
networkHttp2StreamRespondRaw: "_networkHttp2StreamRespondRaw",
|
|
89
|
+
networkHttp2StreamPushStreamRaw: "_networkHttp2StreamPushStreamRaw",
|
|
90
|
+
networkHttp2StreamWriteRaw: "_networkHttp2StreamWriteRaw",
|
|
91
|
+
networkHttp2StreamEndRaw: "_networkHttp2StreamEndRaw",
|
|
92
|
+
networkHttp2StreamPauseRaw: "_networkHttp2StreamPauseRaw",
|
|
93
|
+
networkHttp2StreamResumeRaw: "_networkHttp2StreamResumeRaw",
|
|
94
|
+
networkHttp2StreamRespondWithFileRaw: "_networkHttp2StreamRespondWithFileRaw",
|
|
95
|
+
networkHttp2ServerRespondRaw: "_networkHttp2ServerRespondRaw",
|
|
96
|
+
upgradeSocketWriteRaw: "_upgradeSocketWriteRaw",
|
|
97
|
+
upgradeSocketEndRaw: "_upgradeSocketEndRaw",
|
|
98
|
+
upgradeSocketDestroyRaw: "_upgradeSocketDestroyRaw",
|
|
99
|
+
netSocketConnectRaw: "_netSocketConnectRaw",
|
|
100
|
+
netSocketWaitConnectRaw: "_netSocketWaitConnectRaw",
|
|
101
|
+
netSocketReadRaw: "_netSocketReadRaw",
|
|
102
|
+
netSocketSetNoDelayRaw: "_netSocketSetNoDelayRaw",
|
|
103
|
+
netSocketSetKeepAliveRaw: "_netSocketSetKeepAliveRaw",
|
|
104
|
+
netSocketWriteRaw: "_netSocketWriteRaw",
|
|
105
|
+
netSocketEndRaw: "_netSocketEndRaw",
|
|
106
|
+
netSocketDestroyRaw: "_netSocketDestroyRaw",
|
|
107
|
+
netSocketUpgradeTlsRaw: "_netSocketUpgradeTlsRaw",
|
|
108
|
+
netSocketGetTlsClientHelloRaw: "_netSocketGetTlsClientHelloRaw",
|
|
109
|
+
netSocketTlsQueryRaw: "_netSocketTlsQueryRaw",
|
|
110
|
+
tlsGetCiphersRaw: "_tlsGetCiphersRaw",
|
|
111
|
+
netServerListenRaw: "_netServerListenRaw",
|
|
112
|
+
netServerAcceptRaw: "_netServerAcceptRaw",
|
|
113
|
+
netServerCloseRaw: "_netServerCloseRaw",
|
|
114
|
+
dgramSocketCreateRaw: "_dgramSocketCreateRaw",
|
|
115
|
+
dgramSocketBindRaw: "_dgramSocketBindRaw",
|
|
116
|
+
dgramSocketRecvRaw: "_dgramSocketRecvRaw",
|
|
117
|
+
dgramSocketSendRaw: "_dgramSocketSendRaw",
|
|
118
|
+
dgramSocketCloseRaw: "_dgramSocketCloseRaw",
|
|
119
|
+
dgramSocketAddressRaw: "_dgramSocketAddressRaw",
|
|
120
|
+
dgramSocketSetBufferSizeRaw: "_dgramSocketSetBufferSizeRaw",
|
|
121
|
+
dgramSocketGetBufferSizeRaw: "_dgramSocketGetBufferSizeRaw",
|
|
122
|
+
resolveModuleSync: "_resolveModuleSync",
|
|
123
|
+
loadFileSync: "_loadFileSync",
|
|
124
|
+
ptySetRawMode: "_ptySetRawMode",
|
|
125
|
+
processConfig: "_processConfig",
|
|
126
|
+
osConfig: "_osConfig",
|
|
127
|
+
log: "_log",
|
|
128
|
+
error: "_error",
|
|
129
|
+
// Kernel FD table operations — dispatched through _loadPolyfill bridge
|
|
130
|
+
fdOpen: "_fdOpen",
|
|
131
|
+
fdClose: "_fdClose",
|
|
132
|
+
fdRead: "_fdRead",
|
|
133
|
+
fdWrite: "_fdWrite",
|
|
134
|
+
fdFstat: "_fdFstat",
|
|
135
|
+
fdFtruncate: "_fdFtruncate",
|
|
136
|
+
fdFsync: "_fdFsync",
|
|
137
|
+
fdGetPath: "_fdGetPath",
|
|
138
|
+
};
|
|
139
|
+
/** Globals exposed by the bridge bundle and runtime scripts inside the isolate. */
|
|
140
|
+
export const RUNTIME_BRIDGE_GLOBAL_KEYS = {
|
|
141
|
+
registerHandle: "_registerHandle",
|
|
142
|
+
unregisterHandle: "_unregisterHandle",
|
|
143
|
+
waitForActiveHandles: "_waitForActiveHandles",
|
|
144
|
+
getActiveHandles: "_getActiveHandles",
|
|
145
|
+
childProcessDispatch: "_childProcessDispatch",
|
|
146
|
+
childProcessModule: "_childProcessModule",
|
|
147
|
+
moduleModule: "_moduleModule",
|
|
148
|
+
osModule: "_osModule",
|
|
149
|
+
httpModule: "_httpModule",
|
|
150
|
+
httpsModule: "_httpsModule",
|
|
151
|
+
http2Module: "_http2Module",
|
|
152
|
+
dnsModule: "_dnsModule",
|
|
153
|
+
dgramModule: "_dgramModule",
|
|
154
|
+
httpServerDispatch: "_httpServerDispatch",
|
|
155
|
+
httpServerUpgradeDispatch: "_httpServerUpgradeDispatch",
|
|
156
|
+
httpServerConnectDispatch: "_httpServerConnectDispatch",
|
|
157
|
+
http2Dispatch: "_http2Dispatch",
|
|
158
|
+
timerDispatch: "_timerDispatch",
|
|
159
|
+
upgradeSocketData: "_upgradeSocketData",
|
|
160
|
+
upgradeSocketEnd: "_upgradeSocketEnd",
|
|
161
|
+
netSocketDispatch: "_netSocketDispatch",
|
|
162
|
+
fsFacade: "_fs",
|
|
163
|
+
requireFrom: "_requireFrom",
|
|
164
|
+
moduleCache: "_moduleCache",
|
|
165
|
+
processExitError: "ProcessExitError",
|
|
166
|
+
};
|
|
167
|
+
export const HOST_BRIDGE_GLOBAL_KEY_LIST = valuesOf(HOST_BRIDGE_GLOBAL_KEYS);
|
|
168
|
+
export const RUNTIME_BRIDGE_GLOBAL_KEY_LIST = valuesOf(RUNTIME_BRIDGE_GLOBAL_KEYS);
|
|
169
|
+
export const BRIDGE_GLOBAL_KEY_LIST = [
|
|
170
|
+
...HOST_BRIDGE_GLOBAL_KEY_LIST,
|
|
171
|
+
...RUNTIME_BRIDGE_GLOBAL_KEY_LIST,
|
|
172
|
+
];
|
|
@@ -0,0 +1,199 @@
|
|
|
1
|
+
import type { CommandExecutor, NetworkAdapter, SpawnedProcess } from "@secure-exec/core";
|
|
2
|
+
import type { VirtualFileSystem } from "@secure-exec/core";
|
|
3
|
+
import type { ResolutionCache } from "./package-bundler.js";
|
|
4
|
+
import type { StdioEvent, StdioHook, ProcessConfig } from "@secure-exec/core/internal/shared/api-types";
|
|
5
|
+
import type { BudgetState } from "./isolate-bootstrap.js";
|
|
6
|
+
/** A bridge handler function invoked when sandbox code calls a bridge global. */
|
|
7
|
+
export type BridgeHandler = (...args: unknown[]) => unknown | Promise<unknown>;
|
|
8
|
+
/** Map of bridge global names to their handler functions. */
|
|
9
|
+
export type BridgeHandlers = Record<string, BridgeHandler>;
|
|
10
|
+
/** Result of building crypto bridge handlers — includes dispose for session cleanup. */
|
|
11
|
+
export interface CryptoBridgeResult {
|
|
12
|
+
handlers: BridgeHandlers;
|
|
13
|
+
dispose: () => void;
|
|
14
|
+
}
|
|
15
|
+
/**
|
|
16
|
+
* Build crypto bridge handlers.
|
|
17
|
+
*
|
|
18
|
+
* All handler functions are plain functions (no ivm.Reference wrapping).
|
|
19
|
+
* The V8 runtime registers these by name on the V8 global.
|
|
20
|
+
* Call dispose() when the execution ends to clear stateful cipher sessions.
|
|
21
|
+
*/
|
|
22
|
+
export declare function buildCryptoBridgeHandlers(): CryptoBridgeResult;
|
|
23
|
+
/** Dependencies for building net socket bridge handlers. */
|
|
24
|
+
export interface NetSocketBridgeDeps {
|
|
25
|
+
/** Dispatch a socket event back to the guest (socketId, event, data?). */
|
|
26
|
+
dispatch: (socketId: number, event: string, data?: string) => void;
|
|
27
|
+
/** Kernel socket table — when provided, routes through kernel instead of host TCP. */
|
|
28
|
+
socketTable?: import("@secure-exec/core").SocketTable;
|
|
29
|
+
/** Process ID for kernel socket ownership. Required when socketTable is set. */
|
|
30
|
+
pid?: number;
|
|
31
|
+
}
|
|
32
|
+
/** Result of building net socket bridge handlers — includes dispose for cleanup. */
|
|
33
|
+
export interface NetSocketBridgeResult {
|
|
34
|
+
handlers: BridgeHandlers;
|
|
35
|
+
dispose: () => void;
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Build net socket bridge handlers.
|
|
39
|
+
*
|
|
40
|
+
* All TCP operations route through kernel sockets (loopback or external via
|
|
41
|
+
* the host adapter).
|
|
42
|
+
* Call dispose() when the execution ends to destroy all open sockets.
|
|
43
|
+
*/
|
|
44
|
+
export declare function buildNetworkSocketBridgeHandlers(deps: NetSocketBridgeDeps): NetSocketBridgeResult;
|
|
45
|
+
/** Dependencies for building sync module resolution bridge handlers. */
|
|
46
|
+
export interface ModuleResolutionBridgeDeps {
|
|
47
|
+
/** Translate sandbox path (e.g. /root/node_modules/...) to host path. */
|
|
48
|
+
sandboxToHostPath: (sandboxPath: string) => string | null;
|
|
49
|
+
/** Translate host path back to sandbox path. */
|
|
50
|
+
hostToSandboxPath: (hostPath: string) => string;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Build sync module resolution bridge handlers.
|
|
54
|
+
*
|
|
55
|
+
* These use Node.js require.resolve() and readFileSync() directly,
|
|
56
|
+
* avoiding the async VirtualFileSystem path. Needed because the async
|
|
57
|
+
* applySyncPromise pattern can't nest inside synchronous bridge
|
|
58
|
+
* callbacks (e.g. net socket data events that trigger require()).
|
|
59
|
+
*/
|
|
60
|
+
export declare function buildModuleResolutionBridgeHandlers(deps: ModuleResolutionBridgeDeps): BridgeHandlers;
|
|
61
|
+
/** Strip env vars that allow library injection or node flag smuggling. */
|
|
62
|
+
export declare function stripDangerousEnv(env: Record<string, string> | undefined): Record<string, string> | undefined;
|
|
63
|
+
export declare function emitConsoleEvent(onStdio: StdioHook | undefined, event: StdioEvent): void;
|
|
64
|
+
/** Dependencies for console bridge handlers. */
|
|
65
|
+
export interface ConsoleBridgeDeps {
|
|
66
|
+
onStdio?: StdioHook;
|
|
67
|
+
budgetState: BudgetState;
|
|
68
|
+
maxOutputBytes?: number;
|
|
69
|
+
}
|
|
70
|
+
/** Build console/logging bridge handlers. */
|
|
71
|
+
export declare function buildConsoleBridgeHandlers(deps: ConsoleBridgeDeps): BridgeHandlers;
|
|
72
|
+
/** Dependencies for module loading bridge handlers. */
|
|
73
|
+
export interface ModuleLoadingBridgeDeps {
|
|
74
|
+
filesystem: VirtualFileSystem;
|
|
75
|
+
resolutionCache: ResolutionCache;
|
|
76
|
+
resolveMode?: "require" | "import";
|
|
77
|
+
/** Convert sandbox path to host path for pnpm/symlink resolution fallback. */
|
|
78
|
+
sandboxToHostPath?: (sandboxPath: string) => string | null;
|
|
79
|
+
}
|
|
80
|
+
/** Build module loading bridge handlers (loadPolyfill, resolveModule, loadFile). */
|
|
81
|
+
export declare function buildModuleLoadingBridgeHandlers(deps: ModuleLoadingBridgeDeps,
|
|
82
|
+
/** Extra handlers to dispatch through _loadPolyfill for V8 runtime compatibility. */
|
|
83
|
+
dispatchHandlers?: BridgeHandlers): BridgeHandlers;
|
|
84
|
+
/** Dependencies for timer bridge handlers. */
|
|
85
|
+
export interface TimerBridgeDeps {
|
|
86
|
+
budgetState: BudgetState;
|
|
87
|
+
maxBridgeCalls?: number;
|
|
88
|
+
activeHostTimers: Set<ReturnType<typeof setTimeout>>;
|
|
89
|
+
}
|
|
90
|
+
/** Build timer bridge handler. */
|
|
91
|
+
export declare function buildTimerBridgeHandlers(deps: TimerBridgeDeps): BridgeHandlers;
|
|
92
|
+
export interface KernelTimerDispatchDeps {
|
|
93
|
+
timerTable: import("@secure-exec/core").TimerTable;
|
|
94
|
+
pid: number;
|
|
95
|
+
budgetState: BudgetState;
|
|
96
|
+
maxBridgeCalls?: number;
|
|
97
|
+
activeHostTimers: Set<ReturnType<typeof setTimeout>>;
|
|
98
|
+
sendStreamEvent(eventType: string, payload: Uint8Array): void;
|
|
99
|
+
}
|
|
100
|
+
export declare function buildKernelTimerDispatchHandlers(deps: KernelTimerDispatchDeps): BridgeHandlers;
|
|
101
|
+
export interface KernelHandleDispatchDeps {
|
|
102
|
+
processTable?: import("@secure-exec/core").ProcessTable;
|
|
103
|
+
pid: number;
|
|
104
|
+
budgetState: BudgetState;
|
|
105
|
+
maxBridgeCalls?: number;
|
|
106
|
+
}
|
|
107
|
+
export declare function buildKernelHandleDispatchHandlers(deps: KernelHandleDispatchDeps): BridgeHandlers;
|
|
108
|
+
/** Dependencies for filesystem bridge handlers. */
|
|
109
|
+
export interface FsBridgeDeps {
|
|
110
|
+
filesystem: VirtualFileSystem;
|
|
111
|
+
budgetState: BudgetState;
|
|
112
|
+
maxBridgeCalls?: number;
|
|
113
|
+
bridgeBase64TransferLimitBytes: number;
|
|
114
|
+
isolateJsonPayloadLimitBytes: number;
|
|
115
|
+
}
|
|
116
|
+
/** Build filesystem bridge handlers (readFile, writeFile, stat, etc.). */
|
|
117
|
+
export declare function buildFsBridgeHandlers(deps: FsBridgeDeps): BridgeHandlers;
|
|
118
|
+
/** Dependencies for child process bridge handlers. */
|
|
119
|
+
export interface ChildProcessBridgeDeps {
|
|
120
|
+
commandExecutor: CommandExecutor;
|
|
121
|
+
processConfig: ProcessConfig;
|
|
122
|
+
budgetState: BudgetState;
|
|
123
|
+
maxBridgeCalls?: number;
|
|
124
|
+
maxChildProcesses?: number;
|
|
125
|
+
isolateJsonPayloadLimitBytes: number;
|
|
126
|
+
activeChildProcesses: Map<number, SpawnedProcess>;
|
|
127
|
+
/** Push child process events into the V8 isolate. */
|
|
128
|
+
sendStreamEvent: (eventType: string, payload: Uint8Array) => void;
|
|
129
|
+
/** Kernel process table — when provided, child processes are registered for cross-runtime visibility. */
|
|
130
|
+
processTable?: import("@secure-exec/core").ProcessTable;
|
|
131
|
+
/** Parent process PID for kernel process table registration. */
|
|
132
|
+
parentPid?: number;
|
|
133
|
+
}
|
|
134
|
+
/** Build child process bridge handlers. */
|
|
135
|
+
export declare function buildChildProcessBridgeHandlers(deps: ChildProcessBridgeDeps): BridgeHandlers;
|
|
136
|
+
/** Dependencies for network bridge handlers. */
|
|
137
|
+
export interface NetworkBridgeDeps {
|
|
138
|
+
networkAdapter: NetworkAdapter;
|
|
139
|
+
budgetState: BudgetState;
|
|
140
|
+
maxBridgeCalls?: number;
|
|
141
|
+
isolateJsonPayloadLimitBytes: number;
|
|
142
|
+
activeHttpServerIds: Set<number>;
|
|
143
|
+
activeHttpServerClosers: Map<number, () => Promise<void>>;
|
|
144
|
+
pendingHttpServerStarts: {
|
|
145
|
+
count: number;
|
|
146
|
+
};
|
|
147
|
+
/** Push HTTP server/upgrade events into the V8 isolate. */
|
|
148
|
+
sendStreamEvent: (eventType: string, payload: Uint8Array) => void;
|
|
149
|
+
/** Kernel socket table for all bridge-managed HTTP server routing. */
|
|
150
|
+
socketTable?: import("@secure-exec/core").SocketTable;
|
|
151
|
+
/** Process ID for kernel socket ownership. */
|
|
152
|
+
pid?: number;
|
|
153
|
+
}
|
|
154
|
+
/** Result of building network bridge handlers — includes dispose for cleanup. */
|
|
155
|
+
export interface NetworkBridgeResult {
|
|
156
|
+
handlers: BridgeHandlers;
|
|
157
|
+
dispose: () => Promise<void>;
|
|
158
|
+
}
|
|
159
|
+
/** Build network bridge handlers (fetch, httpRequest, dnsLookup, httpServer). */
|
|
160
|
+
export declare function buildNetworkBridgeHandlers(deps: NetworkBridgeDeps): NetworkBridgeResult;
|
|
161
|
+
/** Resolve a pending HTTP server response (called from stream callback handler). */
|
|
162
|
+
export declare function resolveHttpServerResponse(options: {
|
|
163
|
+
requestId?: number;
|
|
164
|
+
serverId?: number;
|
|
165
|
+
responseJson: string;
|
|
166
|
+
}): void;
|
|
167
|
+
export declare function resolveHttp2CompatResponse(options: {
|
|
168
|
+
requestId?: number;
|
|
169
|
+
serverId?: number;
|
|
170
|
+
responseJson: string;
|
|
171
|
+
}): void;
|
|
172
|
+
/** Dependencies for PTY bridge handlers. */
|
|
173
|
+
export interface PtyBridgeDeps {
|
|
174
|
+
onPtySetRawMode?: (mode: boolean) => void;
|
|
175
|
+
stdinIsTTY?: boolean;
|
|
176
|
+
}
|
|
177
|
+
/** Build PTY bridge handlers. */
|
|
178
|
+
export declare function buildPtyBridgeHandlers(deps: PtyBridgeDeps): BridgeHandlers;
|
|
179
|
+
/** Dependencies for kernel FD table bridge handlers. */
|
|
180
|
+
export interface KernelFdBridgeDeps {
|
|
181
|
+
filesystem: VirtualFileSystem;
|
|
182
|
+
budgetState: BudgetState;
|
|
183
|
+
maxBridgeCalls?: number;
|
|
184
|
+
}
|
|
185
|
+
/** Result of building kernel FD bridge handlers — includes dispose for cleanup. */
|
|
186
|
+
export interface KernelFdBridgeResult {
|
|
187
|
+
handlers: BridgeHandlers;
|
|
188
|
+
dispose: () => void;
|
|
189
|
+
}
|
|
190
|
+
/**
|
|
191
|
+
* Build kernel FD table bridge handlers.
|
|
192
|
+
*
|
|
193
|
+
* Creates a ProcessFDTable per execution and routes all FD operations
|
|
194
|
+
* (open, close, read, write, fstat, ftruncate, fsync) through it.
|
|
195
|
+
* The FD table tracks file descriptors, cursor positions, and flags.
|
|
196
|
+
* Actual file I/O is delegated to the VirtualFileSystem.
|
|
197
|
+
*/
|
|
198
|
+
export declare function buildKernelFdBridgeHandlers(deps: KernelFdBridgeDeps): KernelFdBridgeResult;
|
|
199
|
+
export declare function createProcessConfigForExecution(processConfig: ProcessConfig, timingMitigation: string, frozenTimeMs: number): ProcessConfig;
|