sandboxedjs 0.1.27 → 0.1.28

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/dist/index.d.cts CHANGED
@@ -9,6 +9,14 @@ interface ChildHandle {
9
9
  on(event: "stdout" | "stderr" | "exit", listener: (...args: any[]) => void): unknown;
10
10
  exec(): void;
11
11
  sendStdin(data: string): void;
12
+ /**
13
+ * Close the child's input.
14
+ *
15
+ * Without this a child that reads stdin to EOF — every filter, and every
16
+ * tool a library pipes into, `xsel` and `base64` alike — waits forever for
17
+ * an end that never comes, and the parent waits on its exit.
18
+ */
19
+ endStdin?(): void;
12
20
  kill(signal?: string): void;
13
21
  }
14
22
  interface ChildSpawnConfig {
@@ -2426,6 +2434,8 @@ declare class VirtualHttpRouter {
2426
2434
  onListen: ((port: number) => void) | undefined;
2427
2435
  register(port: number, server: VirtualHttpServer, owner: string): void;
2428
2436
  unregister(port: number, server: VirtualHttpServer): void;
2437
+ /** Whether anything in this container is listening on `port`. */
2438
+ activePortsIncludes(port: number): boolean;
2429
2439
  activePorts(owner?: string): number[];
2430
2440
  closeOwner(owner: string): void;
2431
2441
  closeAll(): void;
@@ -2443,6 +2453,7 @@ interface CoreModulesOptions {
2443
2453
  http?: {
2444
2454
  router: VirtualHttpRouter;
2445
2455
  owner: string;
2456
+ fetch?: typeof globalThis.fetch;
2446
2457
  };
2447
2458
  /** Backs `child_process`; without it the module reports as unavailable. */
2448
2459
  spawnChild?: SpawnChild;
@@ -2485,6 +2496,14 @@ declare function createCoreModules(options: CoreModulesOptions): {
2485
2496
  pendingHandles(): number;
2486
2497
  /** Active timers which called `unref()` and therefore only merit startup grace. */
2487
2498
  pendingUnrefed(): number;
2499
+ /**
2500
+ * Client requests sent but not yet read to completion.
2501
+ *
2502
+ * An outbound request is event-loop work in exactly the way a timer is, and
2503
+ * it schedules no timer of its own. Counting it is what stops a program from
2504
+ * exiting in the gap between `http.get` and its response callback.
2505
+ */
2506
+ pendingRequests(): number;
2488
2507
  };
2489
2508
 
2490
2509
  interface EsmTransformResult {
@@ -2572,6 +2591,8 @@ declare class LocalRuntimePod implements RuntimePod {
2572
2591
  private readonly modules;
2573
2592
  private readonly esbuild;
2574
2593
  private rolldownBinding;
2594
+ /** Backs outbound `http`/`https` client requests from inside the sandbox. */
2595
+ private readonly fetch;
2575
2596
  private constructor();
2576
2597
  static boot(options?: LocalRuntimeOptions): Promise<LocalRuntimePod>;
2577
2598
  spawn(command: string, args?: string[], options?: Record<string, unknown>): Promise<RuntimeProcess>;
package/dist/index.d.ts CHANGED
@@ -9,6 +9,14 @@ interface ChildHandle {
9
9
  on(event: "stdout" | "stderr" | "exit", listener: (...args: any[]) => void): unknown;
10
10
  exec(): void;
11
11
  sendStdin(data: string): void;
12
+ /**
13
+ * Close the child's input.
14
+ *
15
+ * Without this a child that reads stdin to EOF — every filter, and every
16
+ * tool a library pipes into, `xsel` and `base64` alike — waits forever for
17
+ * an end that never comes, and the parent waits on its exit.
18
+ */
19
+ endStdin?(): void;
12
20
  kill(signal?: string): void;
13
21
  }
14
22
  interface ChildSpawnConfig {
@@ -2426,6 +2434,8 @@ declare class VirtualHttpRouter {
2426
2434
  onListen: ((port: number) => void) | undefined;
2427
2435
  register(port: number, server: VirtualHttpServer, owner: string): void;
2428
2436
  unregister(port: number, server: VirtualHttpServer): void;
2437
+ /** Whether anything in this container is listening on `port`. */
2438
+ activePortsIncludes(port: number): boolean;
2429
2439
  activePorts(owner?: string): number[];
2430
2440
  closeOwner(owner: string): void;
2431
2441
  closeAll(): void;
@@ -2443,6 +2453,7 @@ interface CoreModulesOptions {
2443
2453
  http?: {
2444
2454
  router: VirtualHttpRouter;
2445
2455
  owner: string;
2456
+ fetch?: typeof globalThis.fetch;
2446
2457
  };
2447
2458
  /** Backs `child_process`; without it the module reports as unavailable. */
2448
2459
  spawnChild?: SpawnChild;
@@ -2485,6 +2496,14 @@ declare function createCoreModules(options: CoreModulesOptions): {
2485
2496
  pendingHandles(): number;
2486
2497
  /** Active timers which called `unref()` and therefore only merit startup grace. */
2487
2498
  pendingUnrefed(): number;
2499
+ /**
2500
+ * Client requests sent but not yet read to completion.
2501
+ *
2502
+ * An outbound request is event-loop work in exactly the way a timer is, and
2503
+ * it schedules no timer of its own. Counting it is what stops a program from
2504
+ * exiting in the gap between `http.get` and its response callback.
2505
+ */
2506
+ pendingRequests(): number;
2488
2507
  };
2489
2508
 
2490
2509
  interface EsmTransformResult {
@@ -2572,6 +2591,8 @@ declare class LocalRuntimePod implements RuntimePod {
2572
2591
  private readonly modules;
2573
2592
  private readonly esbuild;
2574
2593
  private rolldownBinding;
2594
+ /** Backs outbound `http`/`https` client requests from inside the sandbox. */
2595
+ private readonly fetch;
2575
2596
  private constructor();
2576
2597
  static boot(options?: LocalRuntimeOptions): Promise<LocalRuntimePod>;
2577
2598
  spawn(command: string, args?: string[], options?: Record<string, unknown>): Promise<RuntimeProcess>;