Basic usage
Register abindings object when creating the runtime. Each leaf function becomes callable from sandbox code via SecureExec.bindings.
SecureExec.bindings global:
Sync and async
Both sync and async host functions work. If the host function isasync or returns a Promise, the sandbox call returns a Promise. Otherwise it returns the value directly.
Serialization
Arguments and return values are serialized using V8 structured clone. Supported types:| Type | Supported |
|---|---|
| Primitives (string, number, boolean, null, undefined) | Yes |
| Plain objects and arrays | Yes |
Uint8Array / ArrayBuffer | Yes |
Date, Map, Set, RegExp | Yes |
Error objects | Yes |
| Nested/circular references | Yes |
| Functions | No |
| Symbols | No |
WeakMap / WeakSet | No |
Constraints
- Valid identifiers: binding keys must be valid JavaScript identifiers.
- Max depth: nesting is limited to 4 levels.
- Max leaves: up to 64 leaf functions per runtime.
- Reserved prefix: keys starting with
_are reserved for internal bridge names and will be rejected. - Immutable: bindings are set at runtime construction and cannot be changed.
SecureExec.bindingsis recursively frozen — sandbox code cannot mutate it.
The SecureExec global
SecureExec is always present on globalThis inside the sandbox, even when no bindings are registered. It is non-writable and non-configurable.