typescript-virtual-container 1.5.7 → 1.5.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +39 -29
- package/dist/.tsbuildinfo +1 -1
- package/dist/SSHMimic/executor.js +9 -0
- package/dist/SSHMimic/prompt.d.ts +2 -1
- package/dist/SSHMimic/prompt.js +28 -6
- package/dist/SSHMimic/sftp.d.ts +1 -1
- package/dist/SSHMimic/sftp.js +1 -1
- package/dist/VirtualShell/index.d.ts +2 -3
- package/dist/VirtualShell/index.js +2 -3
- package/dist/VirtualShell/shell.js +108 -134
- package/dist/VirtualShell/shellParser.js +35 -3
- package/dist/commands/coreutils.d.ts +55 -0
- package/dist/commands/coreutils.js +275 -0
- package/dist/commands/id.js +8 -1
- package/dist/commands/index.d.ts +1 -1
- package/dist/commands/index.js +1 -1
- package/dist/commands/manuals-bundle.js +237 -1
- package/dist/commands/pacman.d.ts +8 -0
- package/dist/commands/pacman.js +15 -0
- package/dist/commands/registry.js +13 -0
- package/dist/commands/rm.d.ts +1 -1
- package/dist/commands/rm.js +48 -11
- package/dist/commands/runtime.d.ts +5 -0
- package/dist/commands/runtime.js +60 -1
- package/dist/commands/sh.js +5 -3
- package/dist/modules/linuxRootfs.js +7 -3
- package/dist/modules/nanoEditor.d.ts +92 -0
- package/dist/modules/nanoEditor.js +974 -0
- package/dist/modules/pacmanGame.d.ts +59 -0
- package/dist/modules/pacmanGame.js +655 -0
- package/dist/modules/webTermRenderer.d.ts +50 -0
- package/dist/modules/webTermRenderer.js +425 -0
- package/dist/types/commands.d.ts +2 -0
- package/dist/types/pipeline.d.ts +2 -0
- package/dist/utils/shellSession.d.ts +10 -0
- package/dist/utils/shellSession.js +56 -0
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
- [How It Works](#how-it-works)
|
|
23
23
|
- [API Reference](#api-reference)
|
|
24
24
|
- [Examples](#examples)
|
|
25
|
-
- [Built-in Commands (
|
|
25
|
+
- [Built-in Commands (127)](#built-in-commands-127)
|
|
26
26
|
- [Shell Scripting](#shell-scripting)
|
|
27
27
|
- [Linux Rootfs & VFS PATH Resolution](#linux-rootfs--vfs-path-resolution)
|
|
28
28
|
- [Configuration](#configuration)
|
|
@@ -44,8 +44,8 @@
|
|
|
44
44
|
| Mode | Entry point | Use case |
|
|
45
45
|
|------|-------------|----------|
|
|
46
46
|
| **SSH/SFTP server** | `VirtualSshServer` / `VirtualSftpServer` | Honeypots, remote testing, training environments |
|
|
47
|
-
| **Web shell** | `builds/fortune-nyx-v1.5.
|
|
48
|
-
| **Standalone CLI** | `builds/fortune-nyx-v1.5.
|
|
47
|
+
| **Web shell** | `builds/fortune-nyx-v1.5.9-web.min.js` (ESM) | Embedded terminals, interactive tutorials, browser demos |
|
|
48
|
+
| **Standalone CLI** | `builds/fortune-nyx-v1.5.9-directbash-k6.1.0.mjs` (single file) | Local shell, one-liner demos, no install required |
|
|
49
49
|
<!-- /BUILD:mode-table -->
|
|
50
50
|
|
|
51
51
|
All three modes share the same core: a pure in-memory VFS, a real shell interpreter, a virtual package manager, and a typed programmatic API.
|
|
@@ -66,22 +66,22 @@ npm install typescript-virtual-container
|
|
|
66
66
|
<!-- BUILD:curl-start -->
|
|
67
67
|
#### Interactive local shell — persists VFS in .vfs/ in the current directory
|
|
68
68
|
```bash
|
|
69
|
-
curl -s https://raw.githubusercontent.com/itsrealfortune/typescript-virtual-container/refs/heads/main/builds/fortune-nyx-v1.5.
|
|
69
|
+
curl -s https://raw.githubusercontent.com/itsrealfortune/typescript-virtual-container/refs/heads/main/builds/fortune-nyx-v1.5.9-directbash-k6.1.0.mjs -o fortune-nyx-v1.5.9-directbash-k6.1.0.mjs && node fortune-nyx-v1.5.9-directbash-k6.1.0.mjs
|
|
70
70
|
```
|
|
71
71
|
|
|
72
72
|
#### SSH server with built-in SFTP subsystem (scp / sftp on port 2222)
|
|
73
73
|
```bash
|
|
74
|
-
curl -s https://raw.githubusercontent.com/itsrealfortune/typescript-virtual-container/refs/heads/main/builds/fortune-nyx-v1.5.
|
|
74
|
+
curl -s https://raw.githubusercontent.com/itsrealfortune/typescript-virtual-container/refs/heads/main/builds/fortune-nyx-v1.5.9-ssh.cjs -o fortune-nyx-v1.5.9-ssh.cjs && node fortune-nyx-v1.5.9-ssh.cjs
|
|
75
75
|
```
|
|
76
76
|
|
|
77
77
|
#### Custom SSH port
|
|
78
78
|
```bash
|
|
79
|
-
node fortune-nyx-v1.5.
|
|
79
|
+
node fortune-nyx-v1.5.9-ssh.cjs --ssh-port=2022
|
|
80
80
|
```
|
|
81
81
|
|
|
82
82
|
#### SSH disabled (handler only, no server started)
|
|
83
83
|
```bash
|
|
84
|
-
node fortune-nyx-v1.5.
|
|
84
|
+
node fortune-nyx-v1.5.9-ssh.cjs --no-ssh
|
|
85
85
|
```
|
|
86
86
|
<!-- /BUILD:curl-start -->
|
|
87
87
|
|
|
@@ -89,16 +89,16 @@ node fortune-nyx-v1.5.7-ssh.cjs --no-ssh
|
|
|
89
89
|
> The standalone builds are intended for quick demos and testing. For production use, it's recommended to install the package and import the relevant classes directly in your codebase for better performance, stability, and security.
|
|
90
90
|
|
|
91
91
|
<!-- BUILD:selfStandalone-options -->
|
|
92
|
-
**`fortune-nyx-v1.5.
|
|
92
|
+
**`fortune-nyx-v1.5.9-directbash-k6.1.0.mjs` options:**
|
|
93
93
|
|
|
94
94
|
```bash
|
|
95
|
-
node fortune-nyx-v1.5.
|
|
96
|
-
node fortune-nyx-v1.5.
|
|
97
|
-
node fortune-nyx-v1.5.
|
|
98
|
-
node fortune-nyx-v1.5.
|
|
99
|
-
node fortune-nyx-v1.5.
|
|
100
|
-
node fortune-nyx-v1.5.
|
|
101
|
-
node fortune-nyx-v1.5.
|
|
95
|
+
node fortune-nyx-v1.5.9-directbash-k6.1.0.mjs # boot as root
|
|
96
|
+
node fortune-nyx-v1.5.9-directbash-k6.1.0.mjs --user alice # boot as alice (prompts for password if set)
|
|
97
|
+
node fortune-nyx-v1.5.9-directbash-k6.1.0.mjs --user=alice # same, inline form
|
|
98
|
+
node fortune-nyx-v1.5.9-directbash-k6.1.0.mjs --hostname=my-box # custom hostname
|
|
99
|
+
node fortune-nyx-v1.5.9-directbash-k6.1.0.mjs --snapshot=/data/.vfs # custom VFS snapshot path
|
|
100
|
+
node fortune-nyx-v1.5.9-directbash-k6.1.0.mjs --help # show all options
|
|
101
|
+
node fortune-nyx-v1.5.9-directbash-k6.1.0.mjs --version # print version
|
|
102
102
|
```
|
|
103
103
|
<!-- /BUILD:selfStandalone-options -->
|
|
104
104
|
|
|
@@ -125,7 +125,7 @@ Two browser bundles are available:
|
|
|
125
125
|
<!-- BUILD:web-table -->
|
|
126
126
|
| Bundle | Format | Entry point | Use case |
|
|
127
127
|
|--------|--------|-------------|----------|
|
|
128
|
-
| `builds/fortune-nyx-v1.5.
|
|
128
|
+
| `builds/fortune-nyx-v1.5.9-web.min.js` | ESM | `createWebShell()` | Embedded terminals, modern bundlers |
|
|
129
129
|
<!-- /BUILD:web-table -->
|
|
130
130
|
|
|
131
131
|
Both bundles persist the VFS in **IndexedDB** — state survives page reloads.
|
|
@@ -137,11 +137,11 @@ bun run build-all # rebuild everything
|
|
|
137
137
|
```
|
|
138
138
|
|
|
139
139
|
<!-- BUILD:web-options -->
|
|
140
|
-
**`fortune-nyx-v1.5.
|
|
140
|
+
**`fortune-nyx-v1.5.9-web.min.js`** — lightweight shell with IndexedDB VFS:
|
|
141
141
|
|
|
142
142
|
```html
|
|
143
143
|
<script type="module">
|
|
144
|
-
import { createWebShell } from "./builds/fortune-nyx-v1.5.
|
|
144
|
+
import { createWebShell } from "./builds/fortune-nyx-v1.5.9-web.min.js";
|
|
145
145
|
|
|
146
146
|
const shell = createWebShell("web-vm", {
|
|
147
147
|
vfs: { databaseName: "virtual-env-js", storeName: "vfs" },
|
|
@@ -153,11 +153,11 @@ bun run build-all # rebuild everything
|
|
|
153
153
|
</script>
|
|
154
154
|
```
|
|
155
155
|
|
|
156
|
-
**`fortune-nyx-v1.5.
|
|
156
|
+
**`fortune-nyx-v1.5.9-web.min.js`** — mirrors the `VirtualShell` programmatic API:
|
|
157
157
|
|
|
158
158
|
```html
|
|
159
159
|
<script type="module">
|
|
160
|
-
import { createVirtualShellShim } from "./builds/fortune-nyx-v1.5.
|
|
160
|
+
import { createVirtualShellShim } from "./builds/fortune-nyx-v1.5.9-web.min.js";
|
|
161
161
|
|
|
162
162
|
const shell = createVirtualShellShim("web-vm");
|
|
163
163
|
await shell.ensureInitialized();
|
|
@@ -483,9 +483,9 @@ echo "Welcome back, root!"
|
|
|
483
483
|
---
|
|
484
484
|
|
|
485
485
|
<details>
|
|
486
|
-
<summary><strong>Built-in Commands (
|
|
486
|
+
<summary><strong>Built-in Commands (127)</strong></summary>
|
|
487
487
|
|
|
488
|
-
Type `help` in the shell for a grouped, colorized listing. Type `help <command>` for detailed usage. Type `man <command>` for full manual pages — all
|
|
488
|
+
Type `help` in the shell for a grouped, colorized listing. Type `help <command>` for detailed usage. Type `man <command>` for full manual pages — all 127 commands are documented.
|
|
489
489
|
|
|
490
490
|
### Navigation
|
|
491
491
|
|
|
@@ -534,6 +534,11 @@ Type `help` in the shell for a grouped, colorized listing. Type `help <command>`
|
|
|
534
534
|
| `file <path...>` | | Determine file type (magic bytes) |
|
|
535
535
|
| `wc [files]` | `-l` `-w` `-c` | Word/line/byte count |
|
|
536
536
|
| `xargs [cmd]` | | Build and execute commands from stdin |
|
|
537
|
+
| `tac [files]` | | Concatenate files in reverse line order |
|
|
538
|
+
| `nl [file]` | `-b` `-n` | Number lines of files |
|
|
539
|
+
| `paste [files]` | `-d` | Merge lines of files side by side |
|
|
540
|
+
| `shuf [file]` | `-n` `-i` | Generate random permutations of input |
|
|
541
|
+
| `column [file]` | `-t` `-s` | Columnate lists; `-t` table mode |
|
|
537
542
|
|
|
538
543
|
### Archive & Compression
|
|
539
544
|
|
|
@@ -577,6 +582,10 @@ Type `help` in the shell for a grouped, colorized listing. Type `help <command>`
|
|
|
577
582
|
| `w` | | Who is logged on and what they are doing |
|
|
578
583
|
| `who` | | Active sessions |
|
|
579
584
|
| `whoami` | | Current user |
|
|
585
|
+
| `nproc` | `--all` | Print number of processing units (returns 4) |
|
|
586
|
+
| `mktemp` | `-d` | Create a temporary file or directory in `/tmp` |
|
|
587
|
+
| `timeout <n> <cmd>` | | Run command with time limit (simulated) |
|
|
588
|
+
| `wait [job...]` | | Wait for background jobs (no-op; jobs are fire-and-forget) |
|
|
580
589
|
|
|
581
590
|
### Network
|
|
582
591
|
|
|
@@ -652,7 +661,7 @@ Type `help` in the shell for a grouped, colorized listing. Type `help <command>`
|
|
|
652
661
|
| `su [user]` | | Switch user |
|
|
653
662
|
| `sudo <cmd>` | `-i` | Run as root |
|
|
654
663
|
|
|
655
|
-
**ℹ️ All
|
|
664
|
+
**ℹ️ All 127 built-in commands include complete JSDoc documentation** with `@category` and `@params` tags. See [src/commands/](https://github.com/itsrealfortune/typescript-virtual-container/tree/main/src/commands) for source code and inline documentation.
|
|
656
665
|
|
|
657
666
|
Custom commands: `shell.addCommand(name, params, callback)`.
|
|
658
667
|
|
|
@@ -1177,8 +1186,8 @@ In `"memory"` mode: no. In `"fs"` mode: one binary file (`vfs-snapshot.vfsb`) in
|
|
|
1177
1186
|
**Can I run multiple isolated shells?**
|
|
1178
1187
|
Yes. Each `new VirtualShell(...)` is completely independent (separate VFS, users, env state).
|
|
1179
1188
|
|
|
1180
|
-
**Does the shell support `&&`, `||`, and
|
|
1181
|
-
Yes — plus pipes, redirections, `if`/`for`/`while`/`case`, and
|
|
1189
|
+
**Does the shell support `&&`, `||`, `;`, and `&`?**
|
|
1190
|
+
Yes — plus pipes, redirections, `if`/`for`/`while`/`case`, function definitions, and background jobs (`cmd &`).
|
|
1182
1191
|
|
|
1183
1192
|
**Can I use this for honeypot deployments?**
|
|
1184
1193
|
Yes — use `HoneyPot.attach()` to capture all activity, configure `maxAuthAttempts` to throttle scanners, export on shutdown.
|
|
@@ -1237,17 +1246,18 @@ Open:
|
|
|
1237
1246
|
- [x] Pure in-memory VFS · symlinks · binary snapshot format (VFSB, ~27% smaller than JSON+base64)
|
|
1238
1247
|
- [x] Linux rootfs on boot — `/etc`, `/proc`, `/sys`, `/dev`, `/usr`, `/var`
|
|
1239
1248
|
- [x] Virtual package manager — `apt`/`dpkg`, 25 packages, VFS file writes
|
|
1240
|
-
- [x]
|
|
1249
|
+
- [x] 127 built-in commands across 11 categories (added `zip`, `unzip`, `bzip2`, `bunzip2`, `lsof`, `strace`, `perl`, `w`, `ip`, `dmesg`, `last`, `basename`, `dirname`, `file`, `tput`, `stty`, `yes`, `fortune`, `cowsay`, `cowthink`, `cmatrix`, `sl`, `bc`, `jobs`, `bg`, `fg`, `tac`, `nl`, `paste`, `shuf`, `column`, `timeout`, `mktemp`, `nproc`, `wait`)
|
|
1241
1250
|
- [x] Real shell interpreter — `if`/`for`/`while`/`until`/`case`/functions, arrays `arr=(...)`, `$(cmd)`, `$((expr))`, `${#VAR}`, `${var#pfx}` `${var##pfx}` `${var%sfx}` `${var%%sfx}` `${var/p/r}` `${var//p/r}` `${var:off:len}` `${arr[@]}`, `{a,b,c}` brace expansion, `{1..N}` ranges, `*.glob` expansion, `!!` history expansion, `\` line continuation, `2>/dev/null` stderr redirect, `2>&1`, `(( x++ ))`, heredoc `<< EOF`, `set -e`/`set -x`, `$RANDOM`/`$LINENO`
|
|
1242
1251
|
- [x] `curl`/`wget` as pure `fetch()` · VFS PATH resolution · `/sbin` root-only
|
|
1243
1252
|
- [x] `/proc/self` and `/proc/<pid>` per-session entries
|
|
1244
1253
|
- [x] Snapshot diff tooling — `diffSnapshots`, `formatDiff`, `assertDiff`
|
|
1245
1254
|
- [x] `node`/`python3`/`npm`/`npx` — package-gated virtual REPL stubs
|
|
1246
1255
|
<!-- BUILD:changelog -->
|
|
1247
|
-
- [x] Web shell bundles (`fortune-nyx-v1.5.
|
|
1248
|
-
- [x] Self-standalone CLI (`fortune-nyx-v1.5.
|
|
1256
|
+
- [x] Web shell bundles (`fortune-nyx-v1.5.9-web.min.js`) — fully browser-native with IndexedDB VFS
|
|
1257
|
+
- [x] Self-standalone CLI (`fortune-nyx-v1.5.9-directbash-k6.1.0.mjs`) — single-file interactive shell, per-user history, tab completion
|
|
1249
1258
|
<!-- /BUILD:changelog -->
|
|
1250
|
-
- [x]
|
|
1259
|
+
- [x] 127+ `man` pages — all built-in commands documented via `man <cmd>`
|
|
1260
|
+
- [x] Background job support — trailing `&` fires commands async; `:(){ :|:& };:` fork-bomb safely blocked by `MAX_CALL_DEPTH` guard; shell function names now accept any non-whitespace identifier (POSIX-compliant)
|
|
1251
1261
|
- [x] Shared `tokenize.ts` — unified tokenizer for shell parser and runtime (eliminates duplication)
|
|
1252
1262
|
- [x] Full readline line editing — `Ctrl+A/E/K/U/W`, `Home`/`End`, `!!` history expansion, `/etc/environment` + `~/.profile` login sourcing
|
|
1253
1263
|
- [x] Interoperable archive formats — `tar` writes real POSIX ustar binary; `zip`/`unzip` use PKZIP+DEFLATE (fflate); files extracted by real system tools via SFTP
|