Skip to main content

Interface: IPluginSandbox

Defined in: src/types/interfaces/plugin.interface.ts:703

Plugin sandbox interface.

Remarks​

Manages V8 isolates for plugin execution using isolated-vm. Provides security isolation with memory and CPU limits.

Example​

const sandbox = container.resolve<IPluginSandbox>('IPluginSandbox');

// Create isolate for plugin
const isolate = await sandbox.createIsolate(manifest);

// Execute code in sandbox
const result = await sandbox.executeInSandbox(isolate, code, context);

// Dispose when done
sandbox.dispose(isolate);

Since​

0.1.0

Methods​

createIsolate()​

createIsolate(manifest): Promise<SandboxIsolate>

Defined in: src/types/interfaces/plugin.interface.ts:710

Creates a new V8 isolate for a plugin.

Parameters​

manifest​

IPluginManifest

Plugin manifest (used for resource limits)

Returns​

Promise<SandboxIsolate>

Sandbox isolate handle


dispose()​

dispose(isolate): void

Defined in: src/types/interfaces/plugin.interface.ts:728

Disposes a single isolate.

Parameters​

isolate​

SandboxIsolate

Isolate to dispose

Returns​

void


disposeAll()​

disposeAll(): void

Defined in: src/types/interfaces/plugin.interface.ts:733

Disposes all isolates.

Returns​

void


executeInSandbox()​

executeInSandbox<T>(isolate, code, context): Promise<T>

Defined in: src/types/interfaces/plugin.interface.ts:721

Executes code in a sandbox isolate.

Type Parameters​

• T

Parameters​

isolate​

SandboxIsolate

Sandbox isolate handle

code​

string

JavaScript code to execute

context​

SandboxContext

Execution context with services

Returns​

Promise<T>

Execution result

Throws​

If resource limits exceeded


getMemoryUsage()​

getMemoryUsage(isolate): number

Defined in: src/types/interfaces/plugin.interface.ts:741

Gets current memory usage for an isolate.

Parameters​

isolate​

SandboxIsolate

Sandbox isolate handle

Returns​

number

Memory usage in bytes