Skip to main content
1

Install

npm install secure-exec
2

Create a runtime

A runtime needs a system driver that provides host capabilities like filesystem and network access.
import {
  NodeRuntime,
  createNodeDriver,
  createNodeRuntimeDriverFactory,
} from "secure-exec";

const runtime = new NodeRuntime({
  systemDriver: createNodeDriver(),
  runtimeDriverFactory: createNodeRuntimeDriverFactory(),
});
3

Run code

Use run() when you want a value back and exec() when you care about side effects like logging, files, networking, or long-lived handles.
import {
  NodeRuntime,
  createNodeDriver,
  createNodeRuntimeDriverFactory,
} from "secure-exec";

const runtime = new NodeRuntime({
  systemDriver: createNodeDriver(),
  runtimeDriverFactory: createNodeRuntimeDriverFactory(),
});

const result = await runtime.run<{ message: string }>(
  "module.exports = { message: 'hello from secure-exec' };"
);

const message = result.exports?.message;
// "hello from secure-exec"

Next steps

SDK Overview

Full tour of the API surface and core concepts.

Permissions

Control filesystem, network, and process access.

Security Model

Trust boundaries, timing hardening, and resource limits.