npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

torsandbox

v0.1.1

Published

Isolated sandbox executor with Tor SOCKS5 routing — no external deps

Downloads

261

Readme

torbox

Isolated sandbox executor with optional Tor SOCKS5 routing.
Zero runtime dependencies — uses bubblewrap or firejail available on the host.

Install

# System deps (one of)
sudo apt install bubblewrap   # recommended
sudo apt install firejail

# Optional: Tor
sudo apt install tor && sudo systemctl start tor

# Module
npm install torbox

Quick start

import { Sandbox } from "torbox";

// Basic sandbox — no Tor
const sb = new Sandbox();

const result = await sb.run({
  lang: "python3",
  code: `
import os, socket
print("hostname:", socket.gethostname())
print("user:", os.getenv("USER", "none"))
  `,
});

console.log(result.stdout);
// hostname: sandbox
// user: none

// With Tor routing
const tor = new Sandbox({
  tor: { host: "127.0.0.1", port: 9050 },
});

const check = await tor.run({
  lang: "python3",
  code: `
import urllib.request, json
res = urllib.request.urlopen("https://check.torproject.org/api/ip", timeout=15)
print(json.load(res))
  `,
});

console.log(check.stdout); // { IP: "...", IsTor: true }

API

new Sandbox(opts?)

| Option | Type | Default | Description | |--------|------|---------|-------------| | backend | "bwrap" \| "firejail" \| "auto" | "auto" | Isolation backend | | tor | TorOptions | — | Enables Tor routing | | tor.host | string | "127.0.0.1" | SOCKS5 host | | tor.port | number | 9050 | SOCKS5 port | | tor.verify | boolean | true | Check Tor is reachable on init | | fs.roBind | Array<{host, guest}> | [] | Extra read-only bind mounts | | fs.rwBind | Array<{host, guest}> | [] | Extra read-write bind mounts | | timeout | number | 30000 | Max execution time (ms) | | env | Record<string,string> | {} | Extra env vars | | cwd | string | "/tmp" | Working dir inside sandbox |

sandbox.run(opts): Promise<ExecResult>

| Option | Type | Description | |--------|------|-------------| | lang | "node" \| "python3" \| "bash" \| "sh" | Interpreter | | code | string | Script source | | stdin | string | Optional stdin | | env | Record<string,string> | Per-run env override | | timeout | number | Per-run timeout override |

Returns ExecResult:

{
  exitCode: number;
  stdout: string;
  stderr: string;
  durationMs: number;
  backend: "bwrap" | "firejail";
  torEnabled: boolean;
}

sandbox.probe(): Promise<{ backend, binPath }>

Resolves config and returns the active backend without executing anything.

sandbox.checkTor(): Promise<void>

Verifies Tor SOCKS5 is reachable. Throws if not.

Isolation model

bubblewrap (bwrap) — recommended

  • New user, PID, UTS, IPC namespaces
  • Read-only bind of /usr, /lib, /bin, /sbin
  • tmpfs on /tmp and /home
  • Network namespace not isolated by default (needed for 127.0.0.1:9050)
  • seccomp via bwrap defaults

firejail

  • All capabilities dropped
  • seccomp default profile
  • Private /tmp
  • No new privileges

Tor routing

When tor is set, the sandbox receives:

ALL_PROXY=socks5h://127.0.0.1:9050
HTTPS_PROXY=socks5h://127.0.0.1:9050
HTTP_PROXY=socks5h://127.0.0.1:9050

socks5h:// — the h means DNS is also resolved through Tor (no local DNS leaks).

Advanced: full network isolation with veth pair

For complete network isolation (sandbox can only reach Tor, nothing else), see the veth POC.

Limitations

  • Linux only (namespaces are a Linux kernel feature)
  • The process running the sandbox needs permission to use bwrap (usually fine on modern distros)
  • Tor must be started separately (systemctl start tor)
  • No Node.js vm module isolation — this is OS-level, not JS-level