@iso4/sandbox 0.6.3 → 0.7.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/README.md CHANGED
@@ -88,6 +88,9 @@ const options = {
88
88
  Functions in bridge return values are currently dropped — return plain data,
89
89
  not class instances with methods.
90
90
 
91
+ `SANDBOX_GLOBALS` is a `Set` of every name a fresh sandbox already defines.
92
+ Check generated names against it before installing them.
93
+
91
94
  ## TypeScript-checked rebinding
92
95
 
93
96
  `prepare()` infers the globals shape `G` from what you pass, and the
package/dist/index.d.mts CHANGED
@@ -170,6 +170,9 @@ interface ResourceLimits {
170
170
  * are owned by the runtime; shadowing `Response` would silently break
171
171
  * serialization.
172
172
  *
173
+ * {@link SANDBOX_GLOBALS} holds every name a fresh sandbox defines, V8
174
+ * built-ins included.
175
+ *
173
176
  * Common usage:
174
177
  * ```ts
175
178
  * globals: {
@@ -1463,7 +1466,16 @@ interface RunError {
1463
1466
  type ResetCause = "cpu" | "memory" | "wall" | "abort" | "internal";
1464
1467
  type RunErrorCode = "ERR_USER_CODE" | "ERR_MEMORY_LIMIT" | "ERR_CPU_TIMEOUT" | "ERR_WALL_TIMEOUT" | "ERR_ABORTED" | "ERR_MODULE_NOT_FOUND" | "ERR_COMPILE" | "ERR_FUNCTION_ARGUMENT_NOT_SUPPORTED" | "ERR_EXPORT_NOT_SERIALIZABLE" | "ERR_TYPE_NOT_SERIALIZABLE" | "ERR_EXPORT_TOO_LARGE" | "ERR_CALL_TARGET_NOT_FOUND" | "ERR_HOST_BRIDGE" | "ERR_BRIDGE_PAYLOAD_TOO_LARGE" | "ERR_BRIDGE_CALL_LIMIT_EXCEEDED" | "ERR_INSTANCE_RESET" | "ERR_CAPACITY_MEMORY" | "ERR_QUEUE_FULL" | "ERR_UNDECLARED_BINDING" | "ERR_RESERVED_NAME" | "ERR_FROZEN_BINDING" | "ERR_INVALID_REBIND" | "ERR_PREFIX_DID_NOT_SETTLE" | "ERR_PREFIX_BRIDGE_CALL" | "ERR_WARMUP_LIMIT" | "ERR_PREFIX_DISPOSED" | "ERR_PROTOCOL_DESYNC" | "ERR_INTERNAL";
1465
1468
  //#endregion
1469
+ //#region src/globals.d.ts
1470
+ /**
1471
+ * Every global name a fresh sandbox defines: the JS built-ins of the bundled
1472
+ * V8 plus the runtime's own (`console`, `waitUntil`, timers, web classes).
1473
+ * A host global under one of these names replaces the built-in, or is
1474
+ * silently ignored for `undefined`, `NaN` and `Infinity`.
1475
+ */
1476
+ declare const SANDBOX_GLOBALS: ReadonlySet<string>;
1477
+ //#endregion
1466
1478
  //#region src/index.d.ts
1467
1479
  declare function createSandbox(options?: SandboxOptions): Promise<Sandbox>;
1468
1480
  //#endregion
1469
- export { type BridgeCallEntry, type BridgeCallEntryBase, type BridgeCallFailureReason, type BridgeGlobal, type BridgeWithShim, type CallResult, type CallSuccess, type CallTarget, type CreateSandbox, type DataGlobal, type GlobalOptions, type HostExportData, type HostExportFunction, type HostGlobalValue, type HostGlobals, type HostModuleObject, type HostModuleValue, type ImportValue, type Imports, type MemoryLimit, type OneOffResourceLimits, type PrecompileOptions, type Prefix, type PrefixCallOptions, type PrefixRunOptions, type ReadExportsOptions, type ReadExportsResult, type RebindGlobals, type RebindHostModule, type RebindImports, type RebindValue, type ResetCause, type ResourceLimits, type RunCallOptions, type RunError, type RunErrorCode, type RunFailure, type RunOptions, type RunResult, type RunSuccess, type Sandbox, type SandboxExports, type SandboxOptions, type SandboxStats, type StringGlobal, type WaitUntilResult, createSandbox };
1481
+ export { type BridgeCallEntry, type BridgeCallEntryBase, type BridgeCallFailureReason, type BridgeGlobal, type BridgeWithShim, type CallResult, type CallSuccess, type CallTarget, type CreateSandbox, type DataGlobal, type GlobalOptions, type HostExportData, type HostExportFunction, type HostGlobalValue, type HostGlobals, type HostModuleObject, type HostModuleValue, type ImportValue, type Imports, type MemoryLimit, type OneOffResourceLimits, type PrecompileOptions, type Prefix, type PrefixCallOptions, type PrefixRunOptions, type ReadExportsOptions, type ReadExportsResult, type RebindGlobals, type RebindHostModule, type RebindImports, type RebindValue, type ResetCause, type ResourceLimits, type RunCallOptions, type RunError, type RunErrorCode, type RunFailure, type RunOptions, type RunResult, type RunSuccess, SANDBOX_GLOBALS, type Sandbox, type SandboxExports, type SandboxOptions, type SandboxStats, type StringGlobal, type WaitUntilResult, createSandbox };
package/dist/index.mjs CHANGED
@@ -3301,6 +3301,90 @@ var RunPool = class {
3301
3301
  };
3302
3302
  //#endregion
3303
3303
  //#region src/globals.ts
3304
+ /**
3305
+ * Every global name a fresh sandbox defines: the JS built-ins of the bundled
3306
+ * V8 plus the runtime's own (`console`, `waitUntil`, timers, web classes).
3307
+ * A host global under one of these names replaces the built-in, or is
3308
+ * silently ignored for `undefined`, `NaN` and `Infinity`.
3309
+ */
3310
+ const SANDBOX_GLOBALS = new Set([
3311
+ "AggregateError",
3312
+ "Array",
3313
+ "ArrayBuffer",
3314
+ "AsyncDisposableStack",
3315
+ "Atomics",
3316
+ "BigInt",
3317
+ "BigInt64Array",
3318
+ "BigUint64Array",
3319
+ "Boolean",
3320
+ "DataView",
3321
+ "Date",
3322
+ "DisposableStack",
3323
+ "Error",
3324
+ "EvalError",
3325
+ "FinalizationRegistry",
3326
+ "Float16Array",
3327
+ "Float32Array",
3328
+ "Float64Array",
3329
+ "Function",
3330
+ "Headers",
3331
+ "Infinity",
3332
+ "Int16Array",
3333
+ "Int32Array",
3334
+ "Int8Array",
3335
+ "Intl",
3336
+ "Iterator",
3337
+ "JSON",
3338
+ "Map",
3339
+ "Math",
3340
+ "NaN",
3341
+ "Number",
3342
+ "Object",
3343
+ "Promise",
3344
+ "Proxy",
3345
+ "RangeError",
3346
+ "ReferenceError",
3347
+ "Reflect",
3348
+ "RegExp",
3349
+ "Request",
3350
+ "Response",
3351
+ "Set",
3352
+ "String",
3353
+ "SuppressedError",
3354
+ "Symbol",
3355
+ "SyntaxError",
3356
+ "Temporal",
3357
+ "TextDecoder",
3358
+ "TextEncoder",
3359
+ "TypeError",
3360
+ "URIError",
3361
+ "URL",
3362
+ "URLSearchParams",
3363
+ "Uint16Array",
3364
+ "Uint32Array",
3365
+ "Uint8Array",
3366
+ "Uint8ClampedArray",
3367
+ "WeakMap",
3368
+ "WeakRef",
3369
+ "WeakSet",
3370
+ "clearTimeout",
3371
+ "console",
3372
+ "decodeURI",
3373
+ "decodeURIComponent",
3374
+ "encodeURI",
3375
+ "encodeURIComponent",
3376
+ "escape",
3377
+ "eval",
3378
+ "globalThis",
3379
+ "isFinite",
3380
+ "isNaN",
3381
+ "parseFloat",
3382
+ "parseInt",
3383
+ "setTimeout",
3384
+ "undefined",
3385
+ "unescape",
3386
+ "waitUntil"
3387
+ ]);
3304
3388
  function isBridgeWithShim(v) {
3305
3389
  return typeof v === "object" && v !== null && v.kind === "bridge-with-shim";
3306
3390
  }
@@ -4201,4 +4285,4 @@ var PrefixImpl = class {
4201
4285
  }
4202
4286
  };
4203
4287
  //#endregion
4204
- export { createSandbox };
4288
+ export { SANDBOX_GLOBALS, createSandbox };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@iso4/sandbox",
3
- "version": "0.6.3",
3
+ "version": "0.7.0",
4
4
  "type": "module",
5
5
  "description": "Fast, sandboxed V8 isolate runtime for agent-generated JavaScript. Two-process architecture for crash isolation.",
6
6
  "keywords": [
@@ -49,10 +49,10 @@
49
49
  "vitest": "^4.1.5"
50
50
  },
51
51
  "optionalDependencies": {
52
- "@iso4/v8-darwin-arm64": "^0.6.3",
53
- "@iso4/v8-darwin-x64": "^0.6.3",
54
- "@iso4/v8-linux-arm64-gnu": "^0.6.3",
55
- "@iso4/v8-linux-x64-gnu": "^0.6.3"
52
+ "@iso4/v8-darwin-arm64": "^0.7.0",
53
+ "@iso4/v8-darwin-x64": "^0.7.0",
54
+ "@iso4/v8-linux-arm64-gnu": "^0.7.0",
55
+ "@iso4/v8-linux-x64-gnu": "^0.7.0"
56
56
  },
57
57
  "engines": {
58
58
  "node": ">=24.0.0"