typescript-virtual-container 1.3.1 → 1.3.3

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.
Files changed (59) hide show
  1. package/README.md +61 -1
  2. package/builds/self-standalone.js +482 -0
  3. package/builds/self-standalone.js.map +7 -0
  4. package/{standalone-wo-sftp.js → builds/standalone-wo-sftp.js} +144 -153
  5. package/{standalone-wo-sftp.js.map → builds/standalone-wo-sftp.js.map} +4 -4
  6. package/{standalone.js → builds/standalone.js} +61 -70
  7. package/{standalone.js.map → builds/standalone.js.map} +4 -4
  8. package/builds/web-full-api.min.js +13 -0
  9. package/builds/web-full-api.min.js.map +7 -0
  10. package/builds/web-iife.min.js +13 -0
  11. package/builds/web-iife.min.js.map +7 -0
  12. package/builds/web.min.js +13 -0
  13. package/builds/web.min.js.map +7 -0
  14. package/dist/SSHMimic/loginBanner.d.ts +7 -0
  15. package/dist/SSHMimic/loginBanner.d.ts.map +1 -0
  16. package/dist/SSHMimic/loginBanner.js +22 -0
  17. package/dist/VirtualShell/index.d.ts +21 -1
  18. package/dist/VirtualShell/index.d.ts.map +1 -1
  19. package/dist/VirtualShell/index.js +34 -2
  20. package/dist/VirtualShell/shell.d.ts.map +1 -1
  21. package/dist/VirtualShell/shell.js +2 -17
  22. package/dist/self-standalone.d.ts +2 -0
  23. package/dist/self-standalone.d.ts.map +1 -0
  24. package/dist/self-standalone.js +147 -0
  25. package/dist/web-api.d.ts +26 -0
  26. package/dist/web-api.d.ts.map +1 -0
  27. package/dist/web-api.js +46 -0
  28. package/dist/web-full.d.ts +4 -0
  29. package/dist/web-full.d.ts.map +1 -0
  30. package/dist/web-full.js +8 -0
  31. package/dist/web.d.ts +108 -0
  32. package/dist/web.d.ts.map +1 -0
  33. package/dist/web.js +773 -0
  34. package/examples/README.md +81 -3
  35. package/examples/app-iife.js +58 -0
  36. package/examples/app.js +28 -0
  37. package/examples/index-cf.html +27 -0
  38. package/examples/index.html +27 -0
  39. package/examples/server.js +55 -0
  40. package/examples/web-iife.min.js +13 -0
  41. package/examples/web.min.js +13 -0
  42. package/package.json +12 -5
  43. package/polyfills/node_child_process/index.js +2 -0
  44. package/polyfills/node_crypto/index.js +7 -0
  45. package/polyfills/node_events/index.js +9 -0
  46. package/polyfills/node_fs/index.js +8 -0
  47. package/polyfills/node_fs/promises.js +4 -0
  48. package/polyfills/node_os/index.js +9 -0
  49. package/polyfills/node_path/index.js +14 -0
  50. package/polyfills/node_vm/index.js +7 -0
  51. package/polyfills/node_zlib/index.js +3 -0
  52. package/src/SSHMimic/loginBanner.ts +36 -0
  53. package/src/VirtualShell/index.ts +60 -2
  54. package/src/VirtualShell/shell.ts +3 -31
  55. package/src/self-standalone.ts +183 -0
  56. package/src/web-api.ts +62 -0
  57. package/src/web-full.ts +11 -0
  58. package/src/web.ts +930 -0
  59. package/tests/web.test.ts +182 -0
package/README.md CHANGED
@@ -13,6 +13,7 @@
13
13
  - [What This Is / What This Is Not](#what-this-is--what-this-is-not)
14
14
  - [Why This Package](#why-this-package)
15
15
  - [Installation](#installation)
16
+ - [Browser Build (web.min.js)](#browser-build-webminjs)
16
17
  - [Compatibility](#compatibility)
17
18
  - [Quick Start](#quick-start)
18
19
  - [Architecture Overview](#architecture-overview)
@@ -78,6 +79,8 @@
78
79
  - A practical tool for deterministic testing, automation pipelines, and SSH-like workflows without running real containers.
79
80
  - A honeypot framework for capturing and auditing attacker behavior.
80
81
 
82
+ TL;DR: this is a shell emulator and virtual environment for developer workflows, not a security sandbox or container runtime.
83
+
81
84
  ### What This Is Not
82
85
 
83
86
  - Not a fully isolated container runtime.
@@ -86,6 +89,8 @@
86
89
 
87
90
  This project emulates shell behavior for developer workflows. `curl` and `wget` use the native `fetch()` API (no host binary). All other network and execution primitives are simulated. It is designed for realism and deployability, not kernel-level security isolation.
88
91
 
92
+ TL;DR: this is not a secure sandbox for running untrusted code. Do not expose it to untrusted users or the public internet without additional isolation layers.
93
+
89
94
  ---
90
95
 
91
96
  ## Why This Package
@@ -129,9 +134,64 @@ bun run build
129
134
  To quickly try a standalone demo:
130
135
 
131
136
  ```bash
132
- curl -s https://raw.githubusercontent.com/itsrealfortune/typescript-virtual-container/refs/heads/main/standalone.js -o standalone.js && node standalone.js && rm -f standalone.js
137
+ curl -s https://raw.githubusercontent.com/itsrealfortune/typescript-virtual-container/refs/heads/main/builds/standalone.js -o standalone.js && node standalone.js && rm -f standalone.js
138
+ ```
139
+
140
+ ### Interactive Readline Demo
141
+
142
+ Build the local readline-based SSH mimic and connect as a specific user:
143
+
144
+ ```bash
145
+ bun run self-standalone-build
146
+ node builds/self-standalone.js --user root
133
147
  ```
134
148
 
149
+ If the selected user exists and has a password, the demo prompts for it. Root skips the password prompt.
150
+
151
+ Standalone JS build is executable from:
152
+ ```bash
153
+ curl -s https://raw.githubusercontent.com/itsrealfortune/typescript-virtual-container/refs/heads/main/builds/self-standalone.js -o self-standalone.js && node self-standalone.js && rm -f self-standalone.js
154
+ ```
155
+ ---
156
+
157
+ ## Browser Build (web.min.js)
158
+
159
+ The package includes a browser-only runtime entrypoint in `src/web.ts`.
160
+ It runs the shell fully in-browser and persists the virtual filesystem in IndexedDB.
161
+
162
+ Build the minified browser bundle:
163
+
164
+ ```bash
165
+ bun run web-build
166
+ ```
167
+
168
+ This generates:
169
+
170
+ - `builds/web.min.js`
171
+ - `builds/web.min.js.map`
172
+
173
+ Use it from a browser module script:
174
+
175
+ ```html
176
+ <script type="module">
177
+ import { createWebShell } from "./builds/web.min.js";
178
+
179
+ const shell = createWebShell("web-vm", {
180
+ indexedDbName: "virtual-env-js",
181
+ storeName: "vfs",
182
+ });
183
+
184
+ const out = await shell.executeCommandLine("pwd && mkdir -p /tmp/demo && cd /tmp/demo && echo hello > file.txt && ls -la");
185
+ console.log(out.stdout);
186
+ </script>
187
+ ```
188
+
189
+ Notes:
190
+
191
+ - This build is browser-targeted and does not include SSH/SFTP networking servers.
192
+ - State is mirrored to IndexedDB via the VFS mirror implementation.
193
+ - If you need SSH/SFTP, use the Node standalone builds instead (`standalone.js` or `standalone-wo-sftp.js`). For a local SSH-like terminal, use `builds/self-standalone.js`.
194
+
135
195
  ---
136
196
 
137
197
  ## Compatibility