@secure-exec/core 0.1.1-rc.1 → 0.1.1-rc.3

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.
@@ -34,7 +34,11 @@
34
34
  const request = String(specifier);
35
35
  const referrer = typeof fromPath === "string" && fromPath.length > 0 ? fromPath : __fallbackReferrer;
36
36
  const allowRequireFallback = request.endsWith(".cjs") || request.endsWith(".json");
37
- const namespace = await globalThis._dynamicImport(request, referrer);
37
+ const namespace = await globalThis._dynamicImport.apply(
38
+ void 0,
39
+ [request, referrer],
40
+ { result: { promise: true } }
41
+ );
38
42
  if (namespace !== null) {
39
43
  return namespace;
40
44
  }
@@ -23,65 +23,26 @@
23
23
 
24
24
  // isolate-runtime/src/inject/setup-fs-facade.ts
25
25
  var __runtimeExposeCustomGlobal = getRuntimeExposeCustomGlobal();
26
- var __fsFacade = {};
27
- Object.defineProperties(__fsFacade, {
28
- readFile: { get() {
29
- return globalThis._fsReadFile;
30
- }, enumerable: true },
31
- writeFile: { get() {
32
- return globalThis._fsWriteFile;
33
- }, enumerable: true },
34
- readFileBinary: { get() {
35
- return globalThis._fsReadFileBinary;
36
- }, enumerable: true },
37
- writeFileBinary: { get() {
38
- return globalThis._fsWriteFileBinary;
39
- }, enumerable: true },
40
- readDir: { get() {
41
- return globalThis._fsReadDir;
42
- }, enumerable: true },
43
- mkdir: { get() {
44
- return globalThis._fsMkdir;
45
- }, enumerable: true },
46
- rmdir: { get() {
47
- return globalThis._fsRmdir;
48
- }, enumerable: true },
49
- exists: { get() {
50
- return globalThis._fsExists;
51
- }, enumerable: true },
52
- stat: { get() {
53
- return globalThis._fsStat;
54
- }, enumerable: true },
55
- unlink: { get() {
56
- return globalThis._fsUnlink;
57
- }, enumerable: true },
58
- rename: { get() {
59
- return globalThis._fsRename;
60
- }, enumerable: true },
61
- chmod: { get() {
62
- return globalThis._fsChmod;
63
- }, enumerable: true },
64
- chown: { get() {
65
- return globalThis._fsChown;
66
- }, enumerable: true },
67
- link: { get() {
68
- return globalThis._fsLink;
69
- }, enumerable: true },
70
- symlink: { get() {
71
- return globalThis._fsSymlink;
72
- }, enumerable: true },
73
- readlink: { get() {
74
- return globalThis._fsReadlink;
75
- }, enumerable: true },
76
- lstat: { get() {
77
- return globalThis._fsLstat;
78
- }, enumerable: true },
79
- truncate: { get() {
80
- return globalThis._fsTruncate;
81
- }, enumerable: true },
82
- utimes: { get() {
83
- return globalThis._fsUtimes;
84
- }, enumerable: true }
85
- });
26
+ var __fsFacade = {
27
+ readFile: globalThis._fsReadFile,
28
+ writeFile: globalThis._fsWriteFile,
29
+ readFileBinary: globalThis._fsReadFileBinary,
30
+ writeFileBinary: globalThis._fsWriteFileBinary,
31
+ readDir: globalThis._fsReadDir,
32
+ mkdir: globalThis._fsMkdir,
33
+ rmdir: globalThis._fsRmdir,
34
+ exists: globalThis._fsExists,
35
+ stat: globalThis._fsStat,
36
+ unlink: globalThis._fsUnlink,
37
+ rename: globalThis._fsRename,
38
+ chmod: globalThis._fsChmod,
39
+ chown: globalThis._fsChown,
40
+ link: globalThis._fsLink,
41
+ symlink: globalThis._fsSymlink,
42
+ readlink: globalThis._fsReadlink,
43
+ lstat: globalThis._fsLstat,
44
+ truncate: globalThis._fsTruncate,
45
+ utimes: globalThis._fsUtimes
46
+ };
86
47
  __runtimeExposeCustomGlobal("_fs", __fsFacade);
87
48
  })();
@@ -3,11 +3,10 @@
3
3
  * host (Node.js) and the isolate (sandbox V8 context).
4
4
  *
5
5
  * Two categories:
6
- * - Host bridge globals: set by the host before bridge code runs (fs fns, timers, etc.)
6
+ * - Host bridge globals: set by the host before bridge code runs (fs refs, timers, etc.)
7
7
  * - Runtime bridge globals: installed by the bridge bundle itself (active handles, modules, etc.)
8
8
  *
9
- * Each type alias is a plain function signature. The Rust V8 runtime registers
10
- * these as real JS functions on the global; bridge code calls them directly.
9
+ * The typed `Ref` aliases describe the isolated-vm calling convention for each global.
11
10
  */
12
11
  export type ValueOf<T> = T[keyof T];
13
12
  /** Globals injected by the host before the bridge bundle executes. */
@@ -15,10 +14,25 @@ export declare const HOST_BRIDGE_GLOBAL_KEYS: {
15
14
  readonly dynamicImport: "_dynamicImport";
16
15
  readonly loadPolyfill: "_loadPolyfill";
17
16
  readonly resolveModule: "_resolveModule";
17
+ readonly resolveModuleSync: "_resolveModuleSync";
18
18
  readonly loadFile: "_loadFile";
19
+ readonly loadFileSync: "_loadFileSync";
19
20
  readonly scheduleTimer: "_scheduleTimer";
20
21
  readonly cryptoRandomFill: "_cryptoRandomFill";
21
22
  readonly cryptoRandomUuid: "_cryptoRandomUUID";
23
+ readonly cryptoHashDigest: "_cryptoHashDigest";
24
+ readonly cryptoHmacDigest: "_cryptoHmacDigest";
25
+ readonly cryptoPbkdf2: "_cryptoPbkdf2";
26
+ readonly cryptoScrypt: "_cryptoScrypt";
27
+ readonly cryptoCipheriv: "_cryptoCipheriv";
28
+ readonly cryptoDecipheriv: "_cryptoDecipheriv";
29
+ readonly cryptoCipherivCreate: "_cryptoCipherivCreate";
30
+ readonly cryptoCipherivUpdate: "_cryptoCipherivUpdate";
31
+ readonly cryptoCipherivFinal: "_cryptoCipherivFinal";
32
+ readonly cryptoSign: "_cryptoSign";
33
+ readonly cryptoVerify: "_cryptoVerify";
34
+ readonly cryptoGenerateKeyPairSync: "_cryptoGenerateKeyPairSync";
35
+ readonly cryptoSubtle: "_cryptoSubtle";
22
36
  readonly fsReadFile: "_fsReadFile";
23
37
  readonly fsWriteFile: "_fsWriteFile";
24
38
  readonly fsReadFileBinary: "_fsReadFileBinary";
@@ -48,6 +62,14 @@ export declare const HOST_BRIDGE_GLOBAL_KEYS: {
48
62
  readonly networkHttpRequestRaw: "_networkHttpRequestRaw";
49
63
  readonly networkHttpServerListenRaw: "_networkHttpServerListenRaw";
50
64
  readonly networkHttpServerCloseRaw: "_networkHttpServerCloseRaw";
65
+ readonly upgradeSocketWriteRaw: "_upgradeSocketWriteRaw";
66
+ readonly upgradeSocketEndRaw: "_upgradeSocketEndRaw";
67
+ readonly upgradeSocketDestroyRaw: "_upgradeSocketDestroyRaw";
68
+ readonly netSocketConnectRaw: "_netSocketConnectRaw";
69
+ readonly netSocketWriteRaw: "_netSocketWriteRaw";
70
+ readonly netSocketEndRaw: "_netSocketEndRaw";
71
+ readonly netSocketDestroyRaw: "_netSocketDestroyRaw";
72
+ readonly netSocketUpgradeTlsRaw: "_netSocketUpgradeTlsRaw";
51
73
  readonly ptySetRawMode: "_ptySetRawMode";
52
74
  readonly processConfig: "_processConfig";
53
75
  readonly osConfig: "_osConfig";
@@ -69,6 +91,12 @@ export declare const RUNTIME_BRIDGE_GLOBAL_KEYS: {
69
91
  readonly http2Module: "_http2Module";
70
92
  readonly dnsModule: "_dnsModule";
71
93
  readonly httpServerDispatch: "_httpServerDispatch";
94
+ readonly httpServerUpgradeDispatch: "_httpServerUpgradeDispatch";
95
+ readonly upgradeSocketData: "_upgradeSocketData";
96
+ readonly upgradeSocketEnd: "_upgradeSocketEnd";
97
+ readonly netModule: "_netModule";
98
+ readonly tlsModule: "_tlsModule";
99
+ readonly netSocketDispatch: "_netSocketDispatch";
72
100
  readonly fsFacade: "_fs";
73
101
  readonly requireFrom: "_requireFrom";
74
102
  readonly moduleCache: "_moduleCache";
@@ -81,10 +109,25 @@ export declare const HOST_BRIDGE_GLOBAL_KEY_LIST: ValueOf<{
81
109
  readonly dynamicImport: "_dynamicImport";
82
110
  readonly loadPolyfill: "_loadPolyfill";
83
111
  readonly resolveModule: "_resolveModule";
112
+ readonly resolveModuleSync: "_resolveModuleSync";
84
113
  readonly loadFile: "_loadFile";
114
+ readonly loadFileSync: "_loadFileSync";
85
115
  readonly scheduleTimer: "_scheduleTimer";
86
116
  readonly cryptoRandomFill: "_cryptoRandomFill";
87
117
  readonly cryptoRandomUuid: "_cryptoRandomUUID";
118
+ readonly cryptoHashDigest: "_cryptoHashDigest";
119
+ readonly cryptoHmacDigest: "_cryptoHmacDigest";
120
+ readonly cryptoPbkdf2: "_cryptoPbkdf2";
121
+ readonly cryptoScrypt: "_cryptoScrypt";
122
+ readonly cryptoCipheriv: "_cryptoCipheriv";
123
+ readonly cryptoDecipheriv: "_cryptoDecipheriv";
124
+ readonly cryptoCipherivCreate: "_cryptoCipherivCreate";
125
+ readonly cryptoCipherivUpdate: "_cryptoCipherivUpdate";
126
+ readonly cryptoCipherivFinal: "_cryptoCipherivFinal";
127
+ readonly cryptoSign: "_cryptoSign";
128
+ readonly cryptoVerify: "_cryptoVerify";
129
+ readonly cryptoGenerateKeyPairSync: "_cryptoGenerateKeyPairSync";
130
+ readonly cryptoSubtle: "_cryptoSubtle";
88
131
  readonly fsReadFile: "_fsReadFile";
89
132
  readonly fsWriteFile: "_fsWriteFile";
90
133
  readonly fsReadFileBinary: "_fsReadFileBinary";
@@ -114,6 +157,14 @@ export declare const HOST_BRIDGE_GLOBAL_KEY_LIST: ValueOf<{
114
157
  readonly networkHttpRequestRaw: "_networkHttpRequestRaw";
115
158
  readonly networkHttpServerListenRaw: "_networkHttpServerListenRaw";
116
159
  readonly networkHttpServerCloseRaw: "_networkHttpServerCloseRaw";
160
+ readonly upgradeSocketWriteRaw: "_upgradeSocketWriteRaw";
161
+ readonly upgradeSocketEndRaw: "_upgradeSocketEndRaw";
162
+ readonly upgradeSocketDestroyRaw: "_upgradeSocketDestroyRaw";
163
+ readonly netSocketConnectRaw: "_netSocketConnectRaw";
164
+ readonly netSocketWriteRaw: "_netSocketWriteRaw";
165
+ readonly netSocketEndRaw: "_netSocketEndRaw";
166
+ readonly netSocketDestroyRaw: "_netSocketDestroyRaw";
167
+ readonly netSocketUpgradeTlsRaw: "_netSocketUpgradeTlsRaw";
117
168
  readonly ptySetRawMode: "_ptySetRawMode";
118
169
  readonly processConfig: "_processConfig";
119
170
  readonly osConfig: "_osConfig";
@@ -134,6 +185,12 @@ export declare const RUNTIME_BRIDGE_GLOBAL_KEY_LIST: ValueOf<{
134
185
  readonly http2Module: "_http2Module";
135
186
  readonly dnsModule: "_dnsModule";
136
187
  readonly httpServerDispatch: "_httpServerDispatch";
188
+ readonly httpServerUpgradeDispatch: "_httpServerUpgradeDispatch";
189
+ readonly upgradeSocketData: "_upgradeSocketData";
190
+ readonly upgradeSocketEnd: "_upgradeSocketEnd";
191
+ readonly netModule: "_netModule";
192
+ readonly tlsModule: "_tlsModule";
193
+ readonly netSocketDispatch: "_netSocketDispatch";
137
194
  readonly fsFacade: "_fs";
138
195
  readonly requireFrom: "_requireFrom";
139
196
  readonly moduleCache: "_moduleCache";
@@ -143,10 +200,25 @@ export declare const BRIDGE_GLOBAL_KEY_LIST: readonly (ValueOf<{
143
200
  readonly dynamicImport: "_dynamicImport";
144
201
  readonly loadPolyfill: "_loadPolyfill";
145
202
  readonly resolveModule: "_resolveModule";
203
+ readonly resolveModuleSync: "_resolveModuleSync";
146
204
  readonly loadFile: "_loadFile";
205
+ readonly loadFileSync: "_loadFileSync";
147
206
  readonly scheduleTimer: "_scheduleTimer";
148
207
  readonly cryptoRandomFill: "_cryptoRandomFill";
149
208
  readonly cryptoRandomUuid: "_cryptoRandomUUID";
209
+ readonly cryptoHashDigest: "_cryptoHashDigest";
210
+ readonly cryptoHmacDigest: "_cryptoHmacDigest";
211
+ readonly cryptoPbkdf2: "_cryptoPbkdf2";
212
+ readonly cryptoScrypt: "_cryptoScrypt";
213
+ readonly cryptoCipheriv: "_cryptoCipheriv";
214
+ readonly cryptoDecipheriv: "_cryptoDecipheriv";
215
+ readonly cryptoCipherivCreate: "_cryptoCipherivCreate";
216
+ readonly cryptoCipherivUpdate: "_cryptoCipherivUpdate";
217
+ readonly cryptoCipherivFinal: "_cryptoCipherivFinal";
218
+ readonly cryptoSign: "_cryptoSign";
219
+ readonly cryptoVerify: "_cryptoVerify";
220
+ readonly cryptoGenerateKeyPairSync: "_cryptoGenerateKeyPairSync";
221
+ readonly cryptoSubtle: "_cryptoSubtle";
150
222
  readonly fsReadFile: "_fsReadFile";
151
223
  readonly fsWriteFile: "_fsWriteFile";
152
224
  readonly fsReadFileBinary: "_fsReadFileBinary";
@@ -176,6 +248,14 @@ export declare const BRIDGE_GLOBAL_KEY_LIST: readonly (ValueOf<{
176
248
  readonly networkHttpRequestRaw: "_networkHttpRequestRaw";
177
249
  readonly networkHttpServerListenRaw: "_networkHttpServerListenRaw";
178
250
  readonly networkHttpServerCloseRaw: "_networkHttpServerCloseRaw";
251
+ readonly upgradeSocketWriteRaw: "_upgradeSocketWriteRaw";
252
+ readonly upgradeSocketEndRaw: "_upgradeSocketEndRaw";
253
+ readonly upgradeSocketDestroyRaw: "_upgradeSocketDestroyRaw";
254
+ readonly netSocketConnectRaw: "_netSocketConnectRaw";
255
+ readonly netSocketWriteRaw: "_netSocketWriteRaw";
256
+ readonly netSocketEndRaw: "_netSocketEndRaw";
257
+ readonly netSocketDestroyRaw: "_netSocketDestroyRaw";
258
+ readonly netSocketUpgradeTlsRaw: "_netSocketUpgradeTlsRaw";
179
259
  readonly ptySetRawMode: "_ptySetRawMode";
180
260
  readonly processConfig: "_processConfig";
181
261
  readonly osConfig: "_osConfig";
@@ -195,57 +275,120 @@ export declare const BRIDGE_GLOBAL_KEY_LIST: readonly (ValueOf<{
195
275
  readonly http2Module: "_http2Module";
196
276
  readonly dnsModule: "_dnsModule";
197
277
  readonly httpServerDispatch: "_httpServerDispatch";
278
+ readonly httpServerUpgradeDispatch: "_httpServerUpgradeDispatch";
279
+ readonly upgradeSocketData: "_upgradeSocketData";
280
+ readonly upgradeSocketEnd: "_upgradeSocketEnd";
281
+ readonly netModule: "_netModule";
282
+ readonly tlsModule: "_tlsModule";
283
+ readonly netSocketDispatch: "_netSocketDispatch";
198
284
  readonly fsFacade: "_fs";
199
285
  readonly requireFrom: "_requireFrom";
200
286
  readonly moduleCache: "_moduleCache";
201
287
  readonly processExitError: "ProcessExitError";
202
288
  }>)[];
203
- export type DynamicImportBridgeRef = (specifier: string, fromPath: string) => Promise<Record<string, unknown> | null>;
204
- export type LoadPolyfillBridgeRef = (moduleName: string) => string | null;
205
- export type ResolveModuleBridgeRef = (request: string, fromDir: string) => string | null;
206
- export type LoadFileBridgeRef = (path: string) => string | null;
289
+ /** An isolated-vm Reference that resolves async via `{ result: { promise: true } }`. */
290
+ export interface BridgeApplyRef<TArgs extends unknown[], TResult> {
291
+ apply(ctx: undefined, args: TArgs, options: {
292
+ result: {
293
+ promise: true;
294
+ };
295
+ }): Promise<TResult>;
296
+ }
297
+ /** An isolated-vm Reference called synchronously (blocks the isolate). */
298
+ export interface BridgeApplySyncRef<TArgs extends unknown[], TResult> {
299
+ applySync(ctx: undefined, args: TArgs): TResult;
300
+ }
301
+ /**
302
+ * An isolated-vm Reference that blocks the isolate while the host resolves
303
+ * a Promise. Used for sync-looking APIs (require, readFileSync) that need
304
+ * async host operations.
305
+ */
306
+ export interface BridgeApplySyncPromiseRef<TArgs extends unknown[], TResult> {
307
+ applySyncPromise(ctx: undefined, args: TArgs): TResult;
308
+ }
309
+ export type DynamicImportBridgeRef = BridgeApplyRef<[
310
+ string,
311
+ string
312
+ ], Record<string, unknown> | null>;
313
+ export type LoadPolyfillBridgeRef = BridgeApplyRef<[string], string | null>;
314
+ export type ResolveModuleBridgeRef = BridgeApplySyncPromiseRef<[
315
+ string,
316
+ string
317
+ ], string | null>;
318
+ export type LoadFileBridgeRef = BridgeApplySyncPromiseRef<[string], string | null>;
207
319
  export type RequireFromBridgeFn = (request: string, dirname: string) => unknown;
208
320
  export type ModuleCacheBridgeRecord = Record<string, unknown>;
209
- export type ProcessLogBridgeRef = (msg: string) => void;
210
- export type ProcessErrorBridgeRef = (msg: string) => void;
211
- export type ScheduleTimerBridgeRef = (delayMs: number) => Promise<void>;
212
- export type CryptoRandomFillBridgeRef = (byteLength: number) => Uint8Array;
213
- export type CryptoRandomUuidBridgeRef = () => string;
214
- export type FsReadFileBridgeRef = (path: string) => string;
215
- export type FsWriteFileBridgeRef = (path: string, content: string) => void;
216
- export type FsReadFileBinaryBridgeRef = (path: string) => Uint8Array;
217
- export type FsWriteFileBinaryBridgeRef = (path: string, content: Uint8Array) => void;
218
- export type FsReadDirEntry = {
219
- name: string;
220
- isDirectory: boolean;
221
- };
222
- export type FsReadDirBridgeRef = (path: string) => FsReadDirEntry[];
223
- export type FsMkdirBridgeRef = (path: string, recursive: boolean) => void;
224
- export type FsRmdirBridgeRef = (path: string) => void;
225
- export type FsExistsBridgeRef = (path: string) => boolean;
226
- export type FsStatResult = {
227
- mode: number;
228
- size: number;
229
- isDirectory: boolean;
230
- atimeMs: number;
231
- mtimeMs: number;
232
- ctimeMs: number;
233
- birthtimeMs: number;
234
- };
235
- export type FsStatBridgeRef = (path: string) => FsStatResult;
236
- export type FsUnlinkBridgeRef = (path: string) => void;
237
- export type FsRenameBridgeRef = (oldPath: string, newPath: string) => void;
238
- export type FsChmodBridgeRef = (path: string, mode: number) => void;
239
- export type FsChownBridgeRef = (path: string, uid: number, gid: number) => void;
240
- export type FsLinkBridgeRef = (existingPath: string, newPath: string) => void;
241
- export type FsSymlinkBridgeRef = (target: string, path: string) => void;
242
- export type FsReadlinkBridgeRef = (path: string) => string;
243
- export type FsLstatResult = FsStatResult & {
244
- isSymbolicLink: boolean;
245
- };
246
- export type FsLstatBridgeRef = (path: string) => FsLstatResult;
247
- export type FsTruncateBridgeRef = (path: string, length: number) => void;
248
- export type FsUtimesBridgeRef = (path: string, atime: number, mtime: number) => void;
321
+ export type ProcessLogBridgeRef = BridgeApplySyncRef<[string], void>;
322
+ export type ProcessErrorBridgeRef = BridgeApplySyncRef<[string], void>;
323
+ export type ScheduleTimerBridgeRef = BridgeApplyRef<[number], void>;
324
+ export type CryptoRandomFillBridgeRef = BridgeApplySyncRef<[number], string>;
325
+ export type CryptoRandomUuidBridgeRef = BridgeApplySyncRef<[], string>;
326
+ export type CryptoHashDigestBridgeRef = BridgeApplySyncRef<[string, string], string>;
327
+ export type CryptoHmacDigestBridgeRef = BridgeApplySyncRef<[string, string, string], string>;
328
+ export type CryptoPbkdf2BridgeRef = BridgeApplySyncRef<[
329
+ string,
330
+ string,
331
+ number,
332
+ number,
333
+ string
334
+ ], string>;
335
+ export type CryptoScryptBridgeRef = BridgeApplySyncRef<[
336
+ string,
337
+ string,
338
+ number,
339
+ string
340
+ ], string>;
341
+ export type CryptoCipherivBridgeRef = BridgeApplySyncRef<[
342
+ string,
343
+ string,
344
+ string,
345
+ string
346
+ ], string>;
347
+ export type CryptoDecipherivBridgeRef = BridgeApplySyncRef<[
348
+ string,
349
+ string,
350
+ string,
351
+ string,
352
+ string
353
+ ], string>;
354
+ export type CryptoSignBridgeRef = BridgeApplySyncRef<[
355
+ string,
356
+ string,
357
+ string
358
+ ], string>;
359
+ export type CryptoVerifyBridgeRef = BridgeApplySyncRef<[
360
+ string,
361
+ string,
362
+ string,
363
+ string
364
+ ], boolean>;
365
+ export type CryptoGenerateKeyPairSyncBridgeRef = BridgeApplySyncRef<[
366
+ string,
367
+ string
368
+ ], string>;
369
+ export type CryptoSubtleBridgeRef = BridgeApplySyncRef<[string], string>;
370
+ export type FsReadFileBridgeRef = BridgeApplySyncPromiseRef<[string], string>;
371
+ export type FsWriteFileBridgeRef = BridgeApplySyncPromiseRef<[string, string], void>;
372
+ export type FsReadFileBinaryBridgeRef = BridgeApplySyncPromiseRef<[string], string>;
373
+ export type FsWriteFileBinaryBridgeRef = BridgeApplySyncPromiseRef<[
374
+ string,
375
+ string
376
+ ], void>;
377
+ export type FsReadDirBridgeRef = BridgeApplySyncPromiseRef<[string], string>;
378
+ export type FsMkdirBridgeRef = BridgeApplySyncPromiseRef<[string, boolean], void>;
379
+ export type FsRmdirBridgeRef = BridgeApplySyncPromiseRef<[string], void>;
380
+ export type FsExistsBridgeRef = BridgeApplySyncPromiseRef<[string], boolean>;
381
+ export type FsStatBridgeRef = BridgeApplySyncPromiseRef<[string], string>;
382
+ export type FsUnlinkBridgeRef = BridgeApplySyncPromiseRef<[string], void>;
383
+ export type FsRenameBridgeRef = BridgeApplySyncPromiseRef<[string, string], void>;
384
+ export type FsChmodBridgeRef = BridgeApplySyncPromiseRef<[string, number], void>;
385
+ export type FsChownBridgeRef = BridgeApplySyncPromiseRef<[string, number, number], void>;
386
+ export type FsLinkBridgeRef = BridgeApplySyncPromiseRef<[string, string], void>;
387
+ export type FsSymlinkBridgeRef = BridgeApplySyncPromiseRef<[string, string], void>;
388
+ export type FsReadlinkBridgeRef = BridgeApplySyncPromiseRef<[string], string>;
389
+ export type FsLstatBridgeRef = BridgeApplySyncPromiseRef<[string], string>;
390
+ export type FsTruncateBridgeRef = BridgeApplySyncPromiseRef<[string, number], void>;
391
+ export type FsUtimesBridgeRef = BridgeApplySyncPromiseRef<[string, number, number], void>;
249
392
  /** Combined filesystem bridge facade installed as `globalThis._fs` in the isolate. */
250
393
  export interface FsFacadeBridge {
251
394
  readFile: FsReadFileBridgeRef;
@@ -268,52 +411,35 @@ export interface FsFacadeBridge {
268
411
  truncate: FsTruncateBridgeRef;
269
412
  utimes: FsUtimesBridgeRef;
270
413
  }
271
- export type ChildProcessSpawnStartBridgeRef = (command: string, argsJson: string, optionsJson: string) => number;
272
- export type ChildProcessStdinWriteBridgeRef = (sessionId: number, data: Uint8Array) => void;
273
- export type ChildProcessStdinCloseBridgeRef = (sessionId: number) => void;
274
- export type ChildProcessKillBridgeRef = (sessionId: number, signal: number) => void;
275
- export type SpawnSyncBridgeResult = {
276
- stdout: string;
277
- stderr: string;
278
- code: number;
279
- maxBufferExceeded?: boolean;
280
- };
281
- export type ChildProcessSpawnSyncBridgeRef = (command: string, argsJson: string, optionsJson: string) => SpawnSyncBridgeResult;
282
- export type NetworkFetchResult = {
283
- ok: boolean;
284
- status: number;
285
- statusText: string;
286
- headers?: Record<string, string>;
287
- url?: string;
288
- redirected?: boolean;
289
- body?: string;
290
- };
291
- export type NetworkFetchRawBridgeRef = (url: string, optionsJson: string) => Promise<NetworkFetchResult>;
292
- export type NetworkDnsLookupResult = {
293
- error?: string;
294
- code?: string;
295
- address?: string;
296
- family?: number;
297
- };
298
- export type NetworkDnsLookupRawBridgeRef = (hostname: string) => Promise<NetworkDnsLookupResult>;
299
- export type NetworkHttpRequestResult = {
300
- headers?: Record<string, string>;
301
- url?: string;
302
- status?: number;
303
- statusText?: string;
304
- body?: string;
305
- trailers?: Record<string, string>;
306
- };
307
- export type NetworkHttpRequestRawBridgeRef = (url: string, optionsJson: string) => Promise<NetworkHttpRequestResult>;
308
- export type NetworkHttpServerListenResult = {
309
- address: {
310
- address: string;
311
- family: string;
312
- port: number;
313
- } | null;
314
- };
315
- export type NetworkHttpServerListenRawBridgeRef = (optionsJson: string) => Promise<NetworkHttpServerListenResult>;
316
- export type NetworkHttpServerCloseRawBridgeRef = (serverId: number) => Promise<void>;
317
- export type PtySetRawModeBridgeRef = (mode: boolean) => void;
414
+ export type ChildProcessSpawnStartBridgeRef = BridgeApplySyncRef<[
415
+ string,
416
+ string,
417
+ string
418
+ ], number>;
419
+ export type ChildProcessStdinWriteBridgeRef = BridgeApplySyncRef<[
420
+ number,
421
+ Uint8Array
422
+ ], void>;
423
+ export type ChildProcessStdinCloseBridgeRef = BridgeApplySyncRef<[number], void>;
424
+ export type ChildProcessKillBridgeRef = BridgeApplySyncRef<[number, number], void>;
425
+ export type ChildProcessSpawnSyncBridgeRef = BridgeApplySyncPromiseRef<[
426
+ string,
427
+ string,
428
+ string
429
+ ], string>;
430
+ export type NetworkFetchRawBridgeRef = BridgeApplyRef<[string, string], string>;
431
+ export type NetworkDnsLookupRawBridgeRef = BridgeApplyRef<[string], string>;
432
+ export type NetworkHttpRequestRawBridgeRef = BridgeApplyRef<[string, string], string>;
433
+ export type NetworkHttpServerListenRawBridgeRef = BridgeApplyRef<[string], string>;
434
+ export type NetworkHttpServerCloseRawBridgeRef = BridgeApplyRef<[number], void>;
435
+ export type UpgradeSocketWriteRawBridgeRef = BridgeApplySyncRef<[number, string], void>;
436
+ export type UpgradeSocketEndRawBridgeRef = BridgeApplySyncRef<[number], void>;
437
+ export type UpgradeSocketDestroyRawBridgeRef = BridgeApplySyncRef<[number], void>;
438
+ export type NetSocketConnectRawBridgeRef = BridgeApplySyncRef<[string, number], number>;
439
+ export type NetSocketWriteRawBridgeRef = BridgeApplySyncRef<[number, string], void>;
440
+ export type NetSocketEndRawBridgeRef = BridgeApplySyncRef<[number], void>;
441
+ export type NetSocketDestroyRawBridgeRef = BridgeApplySyncRef<[number], void>;
442
+ export type NetSocketUpgradeTlsRawBridgeRef = BridgeApplySyncRef<[number, string], void>;
443
+ export type PtySetRawModeBridgeRef = BridgeApplySyncRef<[boolean], void>;
318
444
  export type RegisterHandleBridgeFn = (id: string, description: string) => void;
319
445
  export type UnregisterHandleBridgeFn = (id: string) => void;
@@ -3,11 +3,10 @@
3
3
  * host (Node.js) and the isolate (sandbox V8 context).
4
4
  *
5
5
  * Two categories:
6
- * - Host bridge globals: set by the host before bridge code runs (fs fns, timers, etc.)
6
+ * - Host bridge globals: set by the host before bridge code runs (fs refs, timers, etc.)
7
7
  * - Runtime bridge globals: installed by the bridge bundle itself (active handles, modules, etc.)
8
8
  *
9
- * Each type alias is a plain function signature. The Rust V8 runtime registers
10
- * these as real JS functions on the global; bridge code calls them directly.
9
+ * The typed `Ref` aliases describe the isolated-vm calling convention for each global.
11
10
  */
12
11
  function valuesOf(object) {
13
12
  return Object.values(object);
@@ -17,10 +16,25 @@ export const HOST_BRIDGE_GLOBAL_KEYS = {
17
16
  dynamicImport: "_dynamicImport",
18
17
  loadPolyfill: "_loadPolyfill",
19
18
  resolveModule: "_resolveModule",
19
+ resolveModuleSync: "_resolveModuleSync",
20
20
  loadFile: "_loadFile",
21
+ loadFileSync: "_loadFileSync",
21
22
  scheduleTimer: "_scheduleTimer",
22
23
  cryptoRandomFill: "_cryptoRandomFill",
23
24
  cryptoRandomUuid: "_cryptoRandomUUID",
25
+ cryptoHashDigest: "_cryptoHashDigest",
26
+ cryptoHmacDigest: "_cryptoHmacDigest",
27
+ cryptoPbkdf2: "_cryptoPbkdf2",
28
+ cryptoScrypt: "_cryptoScrypt",
29
+ cryptoCipheriv: "_cryptoCipheriv",
30
+ cryptoDecipheriv: "_cryptoDecipheriv",
31
+ cryptoCipherivCreate: "_cryptoCipherivCreate",
32
+ cryptoCipherivUpdate: "_cryptoCipherivUpdate",
33
+ cryptoCipherivFinal: "_cryptoCipherivFinal",
34
+ cryptoSign: "_cryptoSign",
35
+ cryptoVerify: "_cryptoVerify",
36
+ cryptoGenerateKeyPairSync: "_cryptoGenerateKeyPairSync",
37
+ cryptoSubtle: "_cryptoSubtle",
24
38
  fsReadFile: "_fsReadFile",
25
39
  fsWriteFile: "_fsWriteFile",
26
40
  fsReadFileBinary: "_fsReadFileBinary",
@@ -50,6 +64,14 @@ export const HOST_BRIDGE_GLOBAL_KEYS = {
50
64
  networkHttpRequestRaw: "_networkHttpRequestRaw",
51
65
  networkHttpServerListenRaw: "_networkHttpServerListenRaw",
52
66
  networkHttpServerCloseRaw: "_networkHttpServerCloseRaw",
67
+ upgradeSocketWriteRaw: "_upgradeSocketWriteRaw",
68
+ upgradeSocketEndRaw: "_upgradeSocketEndRaw",
69
+ upgradeSocketDestroyRaw: "_upgradeSocketDestroyRaw",
70
+ netSocketConnectRaw: "_netSocketConnectRaw",
71
+ netSocketWriteRaw: "_netSocketWriteRaw",
72
+ netSocketEndRaw: "_netSocketEndRaw",
73
+ netSocketDestroyRaw: "_netSocketDestroyRaw",
74
+ netSocketUpgradeTlsRaw: "_netSocketUpgradeTlsRaw",
53
75
  ptySetRawMode: "_ptySetRawMode",
54
76
  processConfig: "_processConfig",
55
77
  osConfig: "_osConfig",
@@ -71,6 +93,12 @@ export const RUNTIME_BRIDGE_GLOBAL_KEYS = {
71
93
  http2Module: "_http2Module",
72
94
  dnsModule: "_dnsModule",
73
95
  httpServerDispatch: "_httpServerDispatch",
96
+ httpServerUpgradeDispatch: "_httpServerUpgradeDispatch",
97
+ upgradeSocketData: "_upgradeSocketData",
98
+ upgradeSocketEnd: "_upgradeSocketEnd",
99
+ netModule: "_netModule",
100
+ tlsModule: "_tlsModule",
101
+ netSocketDispatch: "_netSocketDispatch",
74
102
  fsFacade: "_fs",
75
103
  requireFrom: "_requireFrom",
76
104
  moduleCache: "_moduleCache",
@@ -148,10 +148,10 @@ export function getConsoleSetupCode(budget = DEFAULT_CONSOLE_SERIALIZATION_BUDGE
148
148
  const formatConsoleArgs = ${formatConsoleArgs.toString()};
149
149
 
150
150
  globalThis.console = {
151
- log: (...args) => _log(formatConsoleArgs(args, __consoleBudget)),
152
- error: (...args) => _error(formatConsoleArgs(args, __consoleBudget)),
153
- warn: (...args) => _error(formatConsoleArgs(args, __consoleBudget)),
154
- info: (...args) => _log(formatConsoleArgs(args, __consoleBudget)),
151
+ log: (...args) => _log.applySync(undefined, [formatConsoleArgs(args, __consoleBudget)]),
152
+ error: (...args) => _error.applySync(undefined, [formatConsoleArgs(args, __consoleBudget)]),
153
+ warn: (...args) => _error.applySync(undefined, [formatConsoleArgs(args, __consoleBudget)]),
154
+ info: (...args) => _log.applySync(undefined, [formatConsoleArgs(args, __consoleBudget)]),
155
155
  };
156
156
  `;
157
157
  }