SandboxState class enables serializing a capability set to JSON and restoring it later. This is primarily useful for passing sandbox configuration to child processes.
Use Cases
- Child Process Inheritance: Serialize the sandbox state, pass it to a child process via environment variable, and have the child apply the same restrictions
- Configuration Storage: Save sandbox configurations to disk for later use
- Debugging: Inspect the serialized state to understand what capabilities are configured
Static Methods
fromCaps
SandboxState snapshot from a CapabilitySet.
fromJson
SandboxState from a JSON string.
Methods
toJson
toCaps
CapabilitySet from this state.
Properties
netBlocked
true if network access is blocked in this state.
Example: Child Process Inheritance
Parent Process
Child Process (worker.js)
Example: Configuration File
Save Configuration
Load Configuration
JSON Schema
The serialized JSON has the following structure:The JSON structure is considered internal and may change between versions. Always use
fromJson() and toJson() rather than parsing manually.