typescript-virtual-container 1.5.0 → 1.5.2
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/.vscode/settings.json +2 -2
- package/README.md +41 -21
- package/build.js +22 -0
- package/builds/fortune-nyx-v1.5.1-directbash-k6.1.0.mjs +1768 -0
- package/builds/{standalone-wo-sftp.js → fortune-nyx-v1.5.1-ssh-nosftp.js} +180 -180
- package/builds/{standalone.cjs → fortune-nyx-v1.5.1-ssh.cjs} +17 -17
- package/builds/fortune-nyx-v1.5.1-web.min.js +17022 -0
- package/bun.lock +74 -0
- package/dist/Honeypot/index.d.ts +0 -1
- package/dist/Honeypot/index.js +0 -1
- package/dist/SSHClient/index.d.ts +0 -1
- package/dist/SSHClient/index.js +0 -1
- package/dist/SSHMimic/exec.d.ts +0 -1
- package/dist/SSHMimic/exec.js +0 -1
- package/dist/SSHMimic/executor.d.ts +0 -1
- package/dist/SSHMimic/executor.js +0 -1
- package/dist/SSHMimic/hostKey.d.ts +0 -1
- package/dist/SSHMimic/hostKey.js +0 -1
- package/dist/SSHMimic/index.d.ts +0 -1
- package/dist/SSHMimic/index.js +0 -1
- package/dist/SSHMimic/loginBanner.d.ts +0 -1
- package/dist/SSHMimic/loginBanner.js +0 -1
- package/dist/SSHMimic/loginFormat.d.ts +0 -1
- package/dist/SSHMimic/loginFormat.js +0 -1
- package/dist/SSHMimic/prompt.d.ts +0 -1
- package/dist/SSHMimic/prompt.js +0 -1
- package/dist/SSHMimic/sftp.d.ts +0 -1
- package/dist/SSHMimic/sftp.js +0 -1
- package/dist/VirtualFileSystem/binaryPack.d.ts +0 -1
- package/dist/VirtualFileSystem/binaryPack.js +0 -1
- package/dist/VirtualFileSystem/index.d.ts +0 -1
- package/dist/VirtualFileSystem/index.js +0 -1
- package/dist/VirtualFileSystem/internalTypes.d.ts +0 -1
- package/dist/VirtualFileSystem/internalTypes.js +0 -1
- package/dist/VirtualFileSystem/journal.d.ts +0 -1
- package/dist/VirtualFileSystem/journal.js +3 -2
- package/dist/VirtualFileSystem/path.d.ts +0 -1
- package/dist/VirtualFileSystem/path.js +0 -1
- package/dist/VirtualPackageManager/index.d.ts +0 -1
- package/dist/VirtualPackageManager/index.js +5 -6
- package/dist/VirtualShell/idleManager.d.ts +0 -1
- package/dist/VirtualShell/idleManager.js +0 -1
- package/dist/VirtualShell/index.d.ts +3 -2
- package/dist/VirtualShell/index.js +4 -2
- package/dist/VirtualShell/shell.d.ts +0 -1
- package/dist/VirtualShell/shell.js +0 -1
- package/dist/VirtualShell/shellParser.d.ts +0 -1
- package/dist/VirtualShell/shellParser.js +0 -1
- package/dist/VirtualUserManager/index.d.ts +0 -1
- package/dist/VirtualUserManager/index.js +0 -1
- package/dist/commands/adduser.d.ts +0 -1
- package/dist/commands/adduser.js +0 -1
- package/dist/commands/alias.d.ts +0 -1
- package/dist/commands/alias.js +0 -1
- package/dist/commands/apt.d.ts +0 -1
- package/dist/commands/apt.js +0 -1
- package/dist/commands/awk.d.ts +0 -1
- package/dist/commands/awk.js +0 -1
- package/dist/commands/base64.d.ts +0 -1
- package/dist/commands/base64.js +0 -1
- package/dist/commands/cat.d.ts +0 -1
- package/dist/commands/cat.js +0 -1
- package/dist/commands/cd.d.ts +0 -1
- package/dist/commands/cd.js +0 -1
- package/dist/commands/chmod.d.ts +0 -1
- package/dist/commands/chmod.js +0 -1
- package/dist/commands/clear.d.ts +0 -1
- package/dist/commands/clear.js +0 -1
- package/dist/commands/command-helpers.d.ts +0 -1
- package/dist/commands/command-helpers.js +0 -1
- package/dist/commands/cp.d.ts +0 -1
- package/dist/commands/cp.js +0 -1
- package/dist/commands/curl.d.ts +0 -1
- package/dist/commands/curl.js +0 -1
- package/dist/commands/cut.d.ts +0 -1
- package/dist/commands/cut.js +0 -1
- package/dist/commands/date.d.ts +0 -1
- package/dist/commands/date.js +0 -1
- package/dist/commands/declare.d.ts +0 -1
- package/dist/commands/declare.js +0 -1
- package/dist/commands/deluser.d.ts +0 -1
- package/dist/commands/deluser.js +0 -1
- package/dist/commands/df.d.ts +0 -1
- package/dist/commands/df.js +0 -1
- package/dist/commands/diff.d.ts +0 -1
- package/dist/commands/diff.js +0 -1
- package/dist/commands/dpkg.d.ts +0 -1
- package/dist/commands/dpkg.js +0 -1
- package/dist/commands/du.d.ts +0 -1
- package/dist/commands/du.js +0 -1
- package/dist/commands/echo.d.ts +0 -1
- package/dist/commands/echo.js +0 -1
- package/dist/commands/env.d.ts +0 -1
- package/dist/commands/env.js +0 -1
- package/dist/commands/exit.d.ts +0 -1
- package/dist/commands/exit.js +0 -1
- package/dist/commands/export.d.ts +0 -1
- package/dist/commands/export.js +0 -1
- package/dist/commands/find.d.ts +0 -1
- package/dist/commands/find.js +0 -1
- package/dist/commands/free.d.ts +0 -1
- package/dist/commands/free.js +0 -1
- package/dist/commands/grep.d.ts +0 -1
- package/dist/commands/grep.js +0 -1
- package/dist/commands/groups.d.ts +0 -1
- package/dist/commands/groups.js +0 -1
- package/dist/commands/gzip.d.ts +0 -1
- package/dist/commands/gzip.js +0 -1
- package/dist/commands/head.d.ts +0 -1
- package/dist/commands/head.js +0 -1
- package/dist/commands/help.d.ts +0 -1
- package/dist/commands/help.js +0 -1
- package/dist/commands/helpers.d.ts +0 -1
- package/dist/commands/helpers.js +0 -1
- package/dist/commands/history.d.ts +0 -1
- package/dist/commands/history.js +0 -1
- package/dist/commands/hostname.d.ts +0 -1
- package/dist/commands/hostname.js +0 -1
- package/dist/commands/htop.d.ts +0 -1
- package/dist/commands/htop.js +0 -1
- package/dist/commands/id.d.ts +0 -1
- package/dist/commands/id.js +0 -1
- package/dist/commands/index.d.ts +0 -1
- package/dist/commands/index.js +0 -1
- package/dist/commands/kill.d.ts +0 -1
- package/dist/commands/kill.js +0 -1
- package/dist/commands/ln.d.ts +0 -1
- package/dist/commands/ln.js +0 -1
- package/dist/commands/ls.d.ts +0 -1
- package/dist/commands/ls.js +0 -1
- package/dist/commands/lsb-release.d.ts +0 -1
- package/dist/commands/lsb-release.js +0 -1
- package/dist/commands/man.d.ts +0 -1
- package/dist/commands/man.js +0 -1
- package/dist/commands/manuals-bundle.d.ts +0 -1
- package/dist/commands/manuals-bundle.js +0 -1
- package/dist/commands/mkdir.d.ts +0 -1
- package/dist/commands/mkdir.js +0 -1
- package/dist/commands/mv.d.ts +0 -1
- package/dist/commands/mv.js +0 -1
- package/dist/commands/nano.d.ts +0 -1
- package/dist/commands/nano.js +0 -1
- package/dist/commands/neofetch.d.ts +0 -1
- package/dist/commands/neofetch.js +0 -1
- package/dist/commands/node.d.ts +0 -1
- package/dist/commands/node.js +0 -1
- package/dist/commands/npm.d.ts +0 -1
- package/dist/commands/npm.js +0 -1
- package/dist/commands/passwd.d.ts +0 -1
- package/dist/commands/passwd.js +0 -1
- package/dist/commands/ping.d.ts +0 -1
- package/dist/commands/ping.js +0 -1
- package/dist/commands/printf.d.ts +0 -1
- package/dist/commands/printf.js +0 -1
- package/dist/commands/ps.d.ts +0 -1
- package/dist/commands/ps.js +0 -1
- package/dist/commands/pwd.d.ts +0 -1
- package/dist/commands/pwd.js +0 -1
- package/dist/commands/python.d.ts +0 -1
- package/dist/commands/python.js +0 -1
- package/dist/commands/read.d.ts +0 -1
- package/dist/commands/read.js +0 -1
- package/dist/commands/registry.d.ts +0 -1
- package/dist/commands/registry.js +0 -1
- package/dist/commands/rm.d.ts +0 -1
- package/dist/commands/rm.js +0 -1
- package/dist/commands/runtime.d.ts +0 -1
- package/dist/commands/runtime.js +0 -1
- package/dist/commands/sed.d.ts +0 -1
- package/dist/commands/sed.js +0 -1
- package/dist/commands/seq.d.ts +0 -1
- package/dist/commands/seq.js +0 -1
- package/dist/commands/set.d.ts +0 -1
- package/dist/commands/set.js +0 -1
- package/dist/commands/sh.d.ts +0 -1
- package/dist/commands/sh.js +0 -1
- package/dist/commands/shift.d.ts +0 -1
- package/dist/commands/shift.js +0 -1
- package/dist/commands/sleep.d.ts +0 -1
- package/dist/commands/sleep.js +0 -1
- package/dist/commands/sort.d.ts +0 -1
- package/dist/commands/sort.js +0 -1
- package/dist/commands/source.d.ts +0 -1
- package/dist/commands/source.js +0 -1
- package/dist/commands/stat.d.ts +0 -1
- package/dist/commands/stat.js +0 -1
- package/dist/commands/su.d.ts +0 -1
- package/dist/commands/su.js +0 -1
- package/dist/commands/sudo.d.ts +0 -1
- package/dist/commands/sudo.js +0 -1
- package/dist/commands/tail.d.ts +0 -1
- package/dist/commands/tail.js +0 -1
- package/dist/commands/tar.d.ts +0 -1
- package/dist/commands/tar.js +0 -1
- package/dist/commands/tee.d.ts +0 -1
- package/dist/commands/tee.js +0 -1
- package/dist/commands/test.d.ts +0 -1
- package/dist/commands/test.js +0 -1
- package/dist/commands/touch.d.ts +0 -1
- package/dist/commands/touch.js +0 -1
- package/dist/commands/tr.d.ts +0 -1
- package/dist/commands/tr.js +0 -1
- package/dist/commands/tree.d.ts +0 -1
- package/dist/commands/tree.js +0 -1
- package/dist/commands/true.d.ts +0 -1
- package/dist/commands/true.js +0 -1
- package/dist/commands/type.d.ts +0 -1
- package/dist/commands/type.js +0 -1
- package/dist/commands/uname.d.ts +0 -1
- package/dist/commands/uname.js +0 -1
- package/dist/commands/uniq.d.ts +0 -1
- package/dist/commands/uniq.js +0 -1
- package/dist/commands/unset.d.ts +0 -1
- package/dist/commands/unset.js +0 -1
- package/dist/commands/uptime.d.ts +0 -1
- package/dist/commands/uptime.js +0 -1
- package/dist/commands/wc.d.ts +0 -1
- package/dist/commands/wc.js +0 -1
- package/dist/commands/wget.d.ts +0 -1
- package/dist/commands/wget.js +0 -1
- package/dist/commands/which.d.ts +0 -1
- package/dist/commands/which.js +0 -1
- package/dist/commands/who.d.ts +0 -1
- package/dist/commands/who.js +0 -1
- package/dist/commands/whoami.d.ts +0 -1
- package/dist/commands/whoami.js +0 -1
- package/dist/commands/xargs.d.ts +0 -1
- package/dist/commands/xargs.js +0 -1
- package/dist/index.d.ts +0 -1
- package/dist/index.js +0 -1
- package/dist/modules/linuxRootfs.d.ts +0 -1
- package/dist/modules/linuxRootfs.js +0 -1
- package/dist/modules/neofetch.d.ts +0 -1
- package/dist/modules/neofetch.js +0 -1
- package/dist/modules/shellInteractive.d.ts +0 -1
- package/dist/modules/shellInteractive.js +0 -1
- package/dist/modules/shellRuntime.d.ts +0 -1
- package/dist/modules/shellRuntime.js +0 -1
- package/dist/self-standalone.d.ts +0 -1
- package/dist/self-standalone.js +0 -1
- package/dist/standalone-wo-sftp.d.ts +0 -1
- package/dist/standalone-wo-sftp.js +0 -1
- package/dist/standalone.d.ts +0 -1
- package/dist/standalone.js +0 -1
- package/dist/types/commands.d.ts +0 -1
- package/dist/types/commands.js +0 -1
- package/dist/types/pipeline.d.ts +0 -1
- package/dist/types/pipeline.js +0 -1
- package/dist/types/streams.d.ts +0 -1
- package/dist/types/streams.js +0 -1
- package/dist/types/vfs.d.ts +0 -1
- package/dist/types/vfs.js +0 -1
- package/dist/utils/expand.d.ts +0 -1
- package/dist/utils/expand.js +0 -1
- package/dist/utils/perfLogger.d.ts +0 -1
- package/dist/utils/perfLogger.js +0 -1
- package/dist/utils/tokenize.d.ts +0 -1
- package/dist/utils/tokenize.js +0 -1
- package/dist/utils/vfsDiff.d.ts +0 -1
- package/dist/utils/vfsDiff.js +0 -1
- package/{builds/self-standalone.mjs → docs/app.js} +212 -225
- package/docs/classes/HoneyPot.html +17 -17
- package/docs/classes/IdleManager.html +8 -8
- package/docs/classes/SshClient.html +34 -34
- package/docs/classes/VirtualFileSystem.html +38 -38
- package/docs/classes/VirtualPackageManager.html +19 -19
- package/docs/classes/VirtualSftpServer.html +3 -3
- package/docs/classes/VirtualShell.html +41 -40
- package/docs/classes/VirtualSshServer.html +8 -8
- package/docs/classes/VirtualUserManager.html +32 -32
- package/docs/demo.html +82 -0
- package/docs/functions/assertDiff.html +3 -3
- package/docs/functions/diffSnapshots.html +5 -5
- package/docs/functions/formatDiff.html +3 -3
- package/docs/functions/getArg.html +3 -3
- package/docs/functions/getFlag.html +2 -2
- package/docs/functions/ifFlag.html +2 -2
- package/docs/hierarchy.html +1 -1
- package/docs/index.html +47 -21
- package/docs/interfaces/AuditLogEntry.html +3 -3
- package/docs/interfaces/CommandContext.html +13 -13
- package/docs/interfaces/CommandResult.html +13 -13
- package/docs/interfaces/ExecStream.html +6 -6
- package/docs/interfaces/HoneyPotStats.html +3 -3
- package/docs/interfaces/IdleManagerOptions.html +3 -3
- package/docs/interfaces/InstalledPackage.html +11 -11
- package/docs/interfaces/NanoEditorSession.html +5 -5
- package/docs/interfaces/PackageDefinition.html +14 -14
- package/docs/interfaces/PackageFile.html +5 -5
- package/docs/interfaces/PasswordChallenge.html +9 -9
- package/docs/interfaces/RemoveOptions.html +3 -3
- package/docs/interfaces/ShellEnv.html +4 -4
- package/docs/interfaces/ShellModule.html +8 -8
- package/docs/interfaces/ShellProperties.html +5 -5
- package/docs/interfaces/ShellStream.html +7 -7
- package/docs/interfaces/SudoChallenge.html +9 -9
- package/docs/interfaces/VfsBaseNode.html +7 -7
- package/docs/interfaces/VfsDiff.html +7 -7
- package/docs/interfaces/VfsDiffEntry.html +4 -4
- package/docs/interfaces/VfsDiffModified.html +6 -6
- package/docs/interfaces/VfsDirectoryNode.html +8 -8
- package/docs/interfaces/VfsFileNode.html +9 -9
- package/docs/interfaces/VfsOptions.html +6 -6
- package/docs/interfaces/VfsSnapshot.html +3 -3
- package/docs/interfaces/VfsSnapshotBaseNode.html +4 -4
- package/docs/interfaces/VfsSnapshotDirectoryNode.html +5 -5
- package/docs/interfaces/VfsSnapshotFileNode.html +6 -6
- package/docs/interfaces/VirtualActiveSession.html +7 -7
- package/docs/interfaces/VirtualSftpServerOptions.html +3 -3
- package/docs/interfaces/VirtualShellVfsLike.html +4 -4
- package/docs/interfaces/VirtualShellVfsOptions.html +3 -3
- package/docs/interfaces/WriteFileOptions.html +4 -4
- package/docs/modules.html +1 -1
- package/docs/types/ArgParseOptions.html +3 -3
- package/docs/types/CommandMode.html +2 -2
- package/docs/types/CommandOutcome.html +2 -2
- package/docs/types/IdleState.html +1 -1
- package/docs/types/VfsNodeStats.html +2 -2
- package/docs/types/VfsNodeType.html +2 -2
- package/docs/types/VfsPersistenceMode.html +2 -2
- package/docs/types/VfsSnapshotNode.html +2 -2
- package/examples/app.js +1755 -28
- package/examples/app.ts +299 -0
- package/examples/build.js +27 -0
- package/examples/demo.html +33 -0
- package/examples/index.html +68 -13
- package/package.json +7 -5
- package/polyfills/buffer.js +117 -0
- package/polyfills/node_crypto/index.js +167 -7
- package/polyfills/node_fs/index.js +202 -8
- package/polyfills/node_path/index.js +23 -9
- package/polyfills/process.js +14 -0
- package/polyfills/ssh2/index.js +75 -0
- package/scripts/build-all.mjs +226 -0
- package/scripts/build-names.mjs +43 -0
- package/src/VirtualFileSystem/journal.ts +3 -1
- package/src/VirtualPackageManager/index.ts +6 -7
- package/src/VirtualShell/index.ts +5 -2
- package/tsconfig.json +6 -3
- package/typedoc.json +4 -2
- package/builds/web-full-api.min.js +0 -12
- package/builds/web.min.js +0 -12
- package/dist/Honeypot/index.d.ts.map +0 -1
- package/dist/Honeypot/index.js.map +0 -1
- package/dist/SSHClient/index.d.ts.map +0 -1
- package/dist/SSHClient/index.js.map +0 -1
- package/dist/SSHMimic/exec.d.ts.map +0 -1
- package/dist/SSHMimic/exec.js.map +0 -1
- package/dist/SSHMimic/executor.d.ts.map +0 -1
- package/dist/SSHMimic/executor.js.map +0 -1
- package/dist/SSHMimic/hostKey.d.ts.map +0 -1
- package/dist/SSHMimic/hostKey.js.map +0 -1
- package/dist/SSHMimic/index.d.ts.map +0 -1
- package/dist/SSHMimic/index.js.map +0 -1
- package/dist/SSHMimic/loginBanner.d.ts.map +0 -1
- package/dist/SSHMimic/loginBanner.js.map +0 -1
- package/dist/SSHMimic/loginFormat.d.ts.map +0 -1
- package/dist/SSHMimic/loginFormat.js.map +0 -1
- package/dist/SSHMimic/prompt.d.ts.map +0 -1
- package/dist/SSHMimic/prompt.js.map +0 -1
- package/dist/SSHMimic/sftp.d.ts.map +0 -1
- package/dist/SSHMimic/sftp.js.map +0 -1
- package/dist/VirtualFileSystem/binaryPack.d.ts.map +0 -1
- package/dist/VirtualFileSystem/binaryPack.js.map +0 -1
- package/dist/VirtualFileSystem/index.d.ts.map +0 -1
- package/dist/VirtualFileSystem/index.js.map +0 -1
- package/dist/VirtualFileSystem/internalTypes.d.ts.map +0 -1
- package/dist/VirtualFileSystem/internalTypes.js.map +0 -1
- package/dist/VirtualFileSystem/journal.d.ts.map +0 -1
- package/dist/VirtualFileSystem/journal.js.map +0 -1
- package/dist/VirtualFileSystem/path.d.ts.map +0 -1
- package/dist/VirtualFileSystem/path.js.map +0 -1
- package/dist/VirtualPackageManager/index.d.ts.map +0 -1
- package/dist/VirtualPackageManager/index.js.map +0 -1
- package/dist/VirtualShell/idleManager.d.ts.map +0 -1
- package/dist/VirtualShell/idleManager.js.map +0 -1
- package/dist/VirtualShell/index.d.ts.map +0 -1
- package/dist/VirtualShell/index.js.map +0 -1
- package/dist/VirtualShell/shell.d.ts.map +0 -1
- package/dist/VirtualShell/shell.js.map +0 -1
- package/dist/VirtualShell/shellParser.d.ts.map +0 -1
- package/dist/VirtualShell/shellParser.js.map +0 -1
- package/dist/VirtualUserManager/index.d.ts.map +0 -1
- package/dist/VirtualUserManager/index.js.map +0 -1
- package/dist/commands/adduser.d.ts.map +0 -1
- package/dist/commands/adduser.js.map +0 -1
- package/dist/commands/alias.d.ts.map +0 -1
- package/dist/commands/alias.js.map +0 -1
- package/dist/commands/apt.d.ts.map +0 -1
- package/dist/commands/apt.js.map +0 -1
- package/dist/commands/awk.d.ts.map +0 -1
- package/dist/commands/awk.js.map +0 -1
- package/dist/commands/base64.d.ts.map +0 -1
- package/dist/commands/base64.js.map +0 -1
- package/dist/commands/cat.d.ts.map +0 -1
- package/dist/commands/cat.js.map +0 -1
- package/dist/commands/cd.d.ts.map +0 -1
- package/dist/commands/cd.js.map +0 -1
- package/dist/commands/chmod.d.ts.map +0 -1
- package/dist/commands/chmod.js.map +0 -1
- package/dist/commands/clear.d.ts.map +0 -1
- package/dist/commands/clear.js.map +0 -1
- package/dist/commands/command-helpers.d.ts.map +0 -1
- package/dist/commands/command-helpers.js.map +0 -1
- package/dist/commands/cp.d.ts.map +0 -1
- package/dist/commands/cp.js.map +0 -1
- package/dist/commands/curl.d.ts.map +0 -1
- package/dist/commands/curl.js.map +0 -1
- package/dist/commands/cut.d.ts.map +0 -1
- package/dist/commands/cut.js.map +0 -1
- package/dist/commands/date.d.ts.map +0 -1
- package/dist/commands/date.js.map +0 -1
- package/dist/commands/declare.d.ts.map +0 -1
- package/dist/commands/declare.js.map +0 -1
- package/dist/commands/deluser.d.ts.map +0 -1
- package/dist/commands/deluser.js.map +0 -1
- package/dist/commands/df.d.ts.map +0 -1
- package/dist/commands/df.js.map +0 -1
- package/dist/commands/diff.d.ts.map +0 -1
- package/dist/commands/diff.js.map +0 -1
- package/dist/commands/dpkg.d.ts.map +0 -1
- package/dist/commands/dpkg.js.map +0 -1
- package/dist/commands/du.d.ts.map +0 -1
- package/dist/commands/du.js.map +0 -1
- package/dist/commands/echo.d.ts.map +0 -1
- package/dist/commands/echo.js.map +0 -1
- package/dist/commands/env.d.ts.map +0 -1
- package/dist/commands/env.js.map +0 -1
- package/dist/commands/exit.d.ts.map +0 -1
- package/dist/commands/exit.js.map +0 -1
- package/dist/commands/export.d.ts.map +0 -1
- package/dist/commands/export.js.map +0 -1
- package/dist/commands/find.d.ts.map +0 -1
- package/dist/commands/find.js.map +0 -1
- package/dist/commands/free.d.ts.map +0 -1
- package/dist/commands/free.js.map +0 -1
- package/dist/commands/grep.d.ts.map +0 -1
- package/dist/commands/grep.js.map +0 -1
- package/dist/commands/groups.d.ts.map +0 -1
- package/dist/commands/groups.js.map +0 -1
- package/dist/commands/gzip.d.ts.map +0 -1
- package/dist/commands/gzip.js.map +0 -1
- package/dist/commands/head.d.ts.map +0 -1
- package/dist/commands/head.js.map +0 -1
- package/dist/commands/help.d.ts.map +0 -1
- package/dist/commands/help.js.map +0 -1
- package/dist/commands/helpers.d.ts.map +0 -1
- package/dist/commands/helpers.js.map +0 -1
- package/dist/commands/history.d.ts.map +0 -1
- package/dist/commands/history.js.map +0 -1
- package/dist/commands/hostname.d.ts.map +0 -1
- package/dist/commands/hostname.js.map +0 -1
- package/dist/commands/htop.d.ts.map +0 -1
- package/dist/commands/htop.js.map +0 -1
- package/dist/commands/id.d.ts.map +0 -1
- package/dist/commands/id.js.map +0 -1
- package/dist/commands/index.d.ts.map +0 -1
- package/dist/commands/index.js.map +0 -1
- package/dist/commands/kill.d.ts.map +0 -1
- package/dist/commands/kill.js.map +0 -1
- package/dist/commands/ln.d.ts.map +0 -1
- package/dist/commands/ln.js.map +0 -1
- package/dist/commands/ls.d.ts.map +0 -1
- package/dist/commands/ls.js.map +0 -1
- package/dist/commands/lsb-release.d.ts.map +0 -1
- package/dist/commands/lsb-release.js.map +0 -1
- package/dist/commands/man.d.ts.map +0 -1
- package/dist/commands/man.js.map +0 -1
- package/dist/commands/manuals-bundle.d.ts.map +0 -1
- package/dist/commands/manuals-bundle.js.map +0 -1
- package/dist/commands/mkdir.d.ts.map +0 -1
- package/dist/commands/mkdir.js.map +0 -1
- package/dist/commands/mv.d.ts.map +0 -1
- package/dist/commands/mv.js.map +0 -1
- package/dist/commands/nano.d.ts.map +0 -1
- package/dist/commands/nano.js.map +0 -1
- package/dist/commands/neofetch.d.ts.map +0 -1
- package/dist/commands/neofetch.js.map +0 -1
- package/dist/commands/node.d.ts.map +0 -1
- package/dist/commands/node.js.map +0 -1
- package/dist/commands/npm.d.ts.map +0 -1
- package/dist/commands/npm.js.map +0 -1
- package/dist/commands/passwd.d.ts.map +0 -1
- package/dist/commands/passwd.js.map +0 -1
- package/dist/commands/ping.d.ts.map +0 -1
- package/dist/commands/ping.js.map +0 -1
- package/dist/commands/printf.d.ts.map +0 -1
- package/dist/commands/printf.js.map +0 -1
- package/dist/commands/ps.d.ts.map +0 -1
- package/dist/commands/ps.js.map +0 -1
- package/dist/commands/pwd.d.ts.map +0 -1
- package/dist/commands/pwd.js.map +0 -1
- package/dist/commands/python.d.ts.map +0 -1
- package/dist/commands/python.js.map +0 -1
- package/dist/commands/read.d.ts.map +0 -1
- package/dist/commands/read.js.map +0 -1
- package/dist/commands/registry.d.ts.map +0 -1
- package/dist/commands/registry.js.map +0 -1
- package/dist/commands/rm.d.ts.map +0 -1
- package/dist/commands/rm.js.map +0 -1
- package/dist/commands/runtime.d.ts.map +0 -1
- package/dist/commands/runtime.js.map +0 -1
- package/dist/commands/sed.d.ts.map +0 -1
- package/dist/commands/sed.js.map +0 -1
- package/dist/commands/seq.d.ts.map +0 -1
- package/dist/commands/seq.js.map +0 -1
- package/dist/commands/set.d.ts.map +0 -1
- package/dist/commands/set.js.map +0 -1
- package/dist/commands/sh.d.ts.map +0 -1
- package/dist/commands/sh.js.map +0 -1
- package/dist/commands/shift.d.ts.map +0 -1
- package/dist/commands/shift.js.map +0 -1
- package/dist/commands/sleep.d.ts.map +0 -1
- package/dist/commands/sleep.js.map +0 -1
- package/dist/commands/sort.d.ts.map +0 -1
- package/dist/commands/sort.js.map +0 -1
- package/dist/commands/source.d.ts.map +0 -1
- package/dist/commands/source.js.map +0 -1
- package/dist/commands/stat.d.ts.map +0 -1
- package/dist/commands/stat.js.map +0 -1
- package/dist/commands/su.d.ts.map +0 -1
- package/dist/commands/su.js.map +0 -1
- package/dist/commands/sudo.d.ts.map +0 -1
- package/dist/commands/sudo.js.map +0 -1
- package/dist/commands/tail.d.ts.map +0 -1
- package/dist/commands/tail.js.map +0 -1
- package/dist/commands/tar.d.ts.map +0 -1
- package/dist/commands/tar.js.map +0 -1
- package/dist/commands/tee.d.ts.map +0 -1
- package/dist/commands/tee.js.map +0 -1
- package/dist/commands/test.d.ts.map +0 -1
- package/dist/commands/test.js.map +0 -1
- package/dist/commands/touch.d.ts.map +0 -1
- package/dist/commands/touch.js.map +0 -1
- package/dist/commands/tr.d.ts.map +0 -1
- package/dist/commands/tr.js.map +0 -1
- package/dist/commands/tree.d.ts.map +0 -1
- package/dist/commands/tree.js.map +0 -1
- package/dist/commands/true.d.ts.map +0 -1
- package/dist/commands/true.js.map +0 -1
- package/dist/commands/type.d.ts.map +0 -1
- package/dist/commands/type.js.map +0 -1
- package/dist/commands/uname.d.ts.map +0 -1
- package/dist/commands/uname.js.map +0 -1
- package/dist/commands/uniq.d.ts.map +0 -1
- package/dist/commands/uniq.js.map +0 -1
- package/dist/commands/unset.d.ts.map +0 -1
- package/dist/commands/unset.js.map +0 -1
- package/dist/commands/uptime.d.ts.map +0 -1
- package/dist/commands/uptime.js.map +0 -1
- package/dist/commands/wc.d.ts.map +0 -1
- package/dist/commands/wc.js.map +0 -1
- package/dist/commands/wget.d.ts.map +0 -1
- package/dist/commands/wget.js.map +0 -1
- package/dist/commands/which.d.ts.map +0 -1
- package/dist/commands/which.js.map +0 -1
- package/dist/commands/who.d.ts.map +0 -1
- package/dist/commands/who.js.map +0 -1
- package/dist/commands/whoami.d.ts.map +0 -1
- package/dist/commands/whoami.js.map +0 -1
- package/dist/commands/xargs.d.ts.map +0 -1
- package/dist/commands/xargs.js.map +0 -1
- package/dist/index.d.ts.map +0 -1
- package/dist/index.js.map +0 -1
- package/dist/modules/linuxRootfs.d.ts.map +0 -1
- package/dist/modules/linuxRootfs.js.map +0 -1
- package/dist/modules/neofetch.d.ts.map +0 -1
- package/dist/modules/neofetch.js.map +0 -1
- package/dist/modules/shellInteractive.d.ts.map +0 -1
- package/dist/modules/shellInteractive.js.map +0 -1
- package/dist/modules/shellRuntime.d.ts.map +0 -1
- package/dist/modules/shellRuntime.js.map +0 -1
- package/dist/self-standalone.d.ts.map +0 -1
- package/dist/self-standalone.js.map +0 -1
- package/dist/standalone-wo-sftp.d.ts.map +0 -1
- package/dist/standalone-wo-sftp.js.map +0 -1
- package/dist/standalone.d.ts.map +0 -1
- package/dist/standalone.js.map +0 -1
- package/dist/types/commands.d.ts.map +0 -1
- package/dist/types/commands.js.map +0 -1
- package/dist/types/pipeline.d.ts.map +0 -1
- package/dist/types/pipeline.js.map +0 -1
- package/dist/types/streams.d.ts.map +0 -1
- package/dist/types/streams.js.map +0 -1
- package/dist/types/vfs.d.ts.map +0 -1
- package/dist/types/vfs.js.map +0 -1
- package/dist/utils/expand.d.ts.map +0 -1
- package/dist/utils/expand.js.map +0 -1
- package/dist/utils/perfLogger.d.ts.map +0 -1
- package/dist/utils/perfLogger.js.map +0 -1
- package/dist/utils/tokenize.d.ts.map +0 -1
- package/dist/utils/tokenize.js.map +0 -1
- package/dist/utils/vfsDiff.d.ts.map +0 -1
- package/dist/utils/vfsDiff.js.map +0 -1
- package/dist/web-api.d.ts +0 -26
- package/dist/web-api.d.ts.map +0 -1
- package/dist/web-api.js +0 -47
- package/dist/web-api.js.map +0 -1
- package/dist/web-full.d.ts +0 -4
- package/dist/web-full.d.ts.map +0 -1
- package/dist/web-full.js +0 -9
- package/dist/web-full.js.map +0 -1
- package/dist/web.d.ts +0 -108
- package/dist/web.d.ts.map +0 -1
- package/dist/web.js +0 -774
- package/dist/web.js.map +0 -1
- package/examples/app-iife.js +0 -58
- package/examples/index-cf.html +0 -27
- package/examples/web-iife.min.js +0 -13
- package/examples/web.min.js +0 -12
- package/src/web-api.ts +0 -62
- package/src/web-full.ts +0 -11
- package/src/web.ts +0 -930
- package/tests/web.test.ts +0 -182
|
@@ -1,7 +1,167 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
1
|
+
// ─── SHA-256 (pure JS) ───────────────────────────────────────────────────────
|
|
2
|
+
const K = new Uint32Array([
|
|
3
|
+
0x428a2f98,0x71374491,0xb5c0fbcf,0xe9b5dba5,0x3956c25b,0x59f111f1,0x923f82a4,0xab1c5ed5,
|
|
4
|
+
0xd807aa98,0x12835b01,0x243185be,0x550c7dc3,0x72be5d74,0x80deb1fe,0x9bdc06a7,0xc19bf174,
|
|
5
|
+
0xe49b69c1,0xefbe4786,0x0fc19dc6,0x240ca1cc,0x2de92c6f,0x4a7484aa,0x5cb0a9dc,0x76f988da,
|
|
6
|
+
0x983e5152,0xa831c66d,0xb00327c8,0xbf597fc7,0xc6e00bf3,0xd5a79147,0x06ca6351,0x14292967,
|
|
7
|
+
0x27b70a85,0x2e1b2138,0x4d2c6dfc,0x53380d13,0x650a7354,0x766a0abb,0x81c2c92e,0x92722c85,
|
|
8
|
+
0xa2bfe8a1,0xa81a664b,0xc24b8b70,0xc76c51a3,0xd192e819,0xd6990624,0xf40e3585,0x106aa070,
|
|
9
|
+
0x19a4c116,0x1e376c085,0x2748774c,0x34b0bcb5,0x391c0cb3,0x4ed8aa4a,0x5b9cca4f,0x682e6ff3,
|
|
10
|
+
0x748f82ee,0x78a5636f,0x84c87814,0x8cc70208,0x90befffa,0xa4506ceb,0xbef9a3f7,0xc67178f2,
|
|
11
|
+
]);
|
|
12
|
+
|
|
13
|
+
function sha256(data) {
|
|
14
|
+
const msg = data instanceof Uint8Array ? data : new TextEncoder().encode(data);
|
|
15
|
+
const bits = msg.length * 8;
|
|
16
|
+
const padLen = Math.ceil((msg.length + 9) / 64) * 64;
|
|
17
|
+
const padded = new Uint8Array(padLen);
|
|
18
|
+
padded.set(msg);
|
|
19
|
+
padded[msg.length] = 0x80;
|
|
20
|
+
const dv0 = new DataView(padded.buffer);
|
|
21
|
+
dv0.setUint32(padLen - 4, bits >>> 0, false);
|
|
22
|
+
|
|
23
|
+
let h0=0x6a09e667, h1=0xbb67ae85, h2=0x3c6ef372, h3=0xa54ff53a,
|
|
24
|
+
h4=0x510e527f, h5=0x9b05688c, h6=0x1f83d9ab, h7=0x5be0cd19;
|
|
25
|
+
|
|
26
|
+
const w = new Uint32Array(64);
|
|
27
|
+
const dv = new DataView(padded.buffer);
|
|
28
|
+
for (let i = 0; i < padLen; i += 64) {
|
|
29
|
+
for (let j = 0; j < 16; j++) w[j] = dv.getUint32(i + j * 4, false);
|
|
30
|
+
for (let j = 16; j < 64; j++) {
|
|
31
|
+
const s0 = (w[j-15]>>>7|w[j-15]<<25)^(w[j-15]>>>18|w[j-15]<<14)^(w[j-15]>>>3);
|
|
32
|
+
const s1 = (w[j-2]>>>17|w[j-2]<<15)^(w[j-2]>>>19|w[j-2]<<13)^(w[j-2]>>>10);
|
|
33
|
+
w[j] = (w[j-16] + s0 + w[j-7] + s1) | 0;
|
|
34
|
+
}
|
|
35
|
+
let a=h0,b=h1,c=h2,d=h3,e=h4,f=h5,g=h6,hh=h7;
|
|
36
|
+
for (let j = 0; j < 64; j++) {
|
|
37
|
+
const S1 = (e>>>6|e<<26)^(e>>>11|e<<21)^(e>>>25|e<<7);
|
|
38
|
+
const ch = (e&f)^(~e&g);
|
|
39
|
+
const t1 = (hh + S1 + ch + K[j] + w[j]) | 0;
|
|
40
|
+
const S0 = (a>>>2|a<<30)^(a>>>13|a<<19)^(a>>>22|a<<10);
|
|
41
|
+
const maj = (a&b)^(a&c)^(b&c);
|
|
42
|
+
const t2 = (S0 + maj) | 0;
|
|
43
|
+
hh=g; g=f; f=e; e=(d+t1)|0; d=c; c=b; b=a; a=(t1+t2)|0;
|
|
44
|
+
}
|
|
45
|
+
h0=(h0+a)|0; h1=(h1+b)|0; h2=(h2+c)|0; h3=(h3+d)|0;
|
|
46
|
+
h4=(h4+e)|0; h5=(h5+f)|0; h6=(h6+g)|0; h7=(h7+hh)|0;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
const out = new Uint8Array(32);
|
|
50
|
+
const odv = new DataView(out.buffer);
|
|
51
|
+
[h0,h1,h2,h3,h4,h5,h6,h7].forEach((v,i) => odv.setUint32(i*4, v, false));
|
|
52
|
+
return out;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
// ─── HMAC-SHA256 ─────────────────────────────────────────────────────────────
|
|
56
|
+
function hmacSha256(key, data) {
|
|
57
|
+
const BLOCK = 64;
|
|
58
|
+
let k = key instanceof Uint8Array ? key : new TextEncoder().encode(key);
|
|
59
|
+
if (k.length > BLOCK) k = sha256(k);
|
|
60
|
+
const kpad = new Uint8Array(BLOCK);
|
|
61
|
+
kpad.set(k);
|
|
62
|
+
const ipad = kpad.map(b => b ^ 0x36);
|
|
63
|
+
const opad = kpad.map(b => b ^ 0x5c);
|
|
64
|
+
const inner = new Uint8Array(BLOCK + data.length);
|
|
65
|
+
inner.set(ipad); inner.set(data, BLOCK);
|
|
66
|
+
const outer = new Uint8Array(BLOCK + 32);
|
|
67
|
+
outer.set(opad); outer.set(sha256(inner), BLOCK);
|
|
68
|
+
return sha256(outer);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// ─── PBKDF2-HMAC-SHA256 (sync) ───────────────────────────────────────────────
|
|
72
|
+
function pbkdf2Sync(password, salt, iterations, keylen) {
|
|
73
|
+
const pw = password instanceof Uint8Array ? password : new TextEncoder().encode(password);
|
|
74
|
+
const sl = salt instanceof Uint8Array ? salt : new TextEncoder().encode(salt);
|
|
75
|
+
const hlen = 32;
|
|
76
|
+
const blocks = Math.ceil(keylen / hlen);
|
|
77
|
+
const dk = new Uint8Array(keylen);
|
|
78
|
+
|
|
79
|
+
for (let i = 1; i <= blocks; i++) {
|
|
80
|
+
const ibuf = new Uint8Array(4);
|
|
81
|
+
new DataView(ibuf.buffer).setUint32(0, i, false);
|
|
82
|
+
const saltI = new Uint8Array(sl.length + 4);
|
|
83
|
+
saltI.set(sl);
|
|
84
|
+
saltI.set(ibuf, sl.length);
|
|
85
|
+
|
|
86
|
+
let U = hmacSha256(pw, saltI);
|
|
87
|
+
const T = new Uint8Array(U);
|
|
88
|
+
for (let j = 1; j < iterations; j++) {
|
|
89
|
+
U = hmacSha256(pw, U);
|
|
90
|
+
for (let k = 0; k < hlen; k++) T[k] ^= U[k];
|
|
91
|
+
}
|
|
92
|
+
const offset = (i - 1) * hlen;
|
|
93
|
+
dk.set(T.slice(0, keylen - offset), offset);
|
|
94
|
+
}
|
|
95
|
+
return dk;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
// ─── Exports ─────────────────────────────────────────────────────────────────
|
|
99
|
+
export function randomBytes(n) {
|
|
100
|
+
const a = new Uint8Array(n);
|
|
101
|
+
crypto.getRandomValues(a);
|
|
102
|
+
return a;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
export function randomUUID() {
|
|
106
|
+
return crypto.randomUUID
|
|
107
|
+
? crypto.randomUUID()
|
|
108
|
+
: ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, c =>
|
|
109
|
+
(c ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))).toString(16));
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
export function createHash(alg) {
|
|
113
|
+
const chunks = [];
|
|
114
|
+
return {
|
|
115
|
+
update(d) {
|
|
116
|
+
chunks.push(d instanceof Uint8Array ? d : new TextEncoder().encode(String(d)));
|
|
117
|
+
return this;
|
|
118
|
+
},
|
|
119
|
+
digest(enc = 'hex') {
|
|
120
|
+
const total = chunks.reduce((s, c) => s + c.length, 0);
|
|
121
|
+
const buf = new Uint8Array(total);
|
|
122
|
+
let off = 0;
|
|
123
|
+
for (const c of chunks) { buf.set(c, off); off += c.length; }
|
|
124
|
+
const hash = sha256(buf);
|
|
125
|
+
if (enc === 'hex') return Array.from(hash).map(b => b.toString(16).padStart(2,'0')).join('');
|
|
126
|
+
if (enc === 'base64') return btoa(String.fromCharCode(...hash));
|
|
127
|
+
return hash;
|
|
128
|
+
},
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
export function scryptSync(password, salt, keylen, options = {}) {
|
|
133
|
+
const N = options.N ?? 16384;
|
|
134
|
+
const iterations = Math.max(1000, Math.round(Math.log2(N) * 1000));
|
|
135
|
+
const pw = typeof password === 'string' ? new TextEncoder().encode(password) : password;
|
|
136
|
+
const sl = typeof salt === 'string' ? new TextEncoder().encode(salt) : salt;
|
|
137
|
+
return pbkdf2Sync(pw, sl, iterations, keylen);
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
export function timingSafeEqual(a, b) {
|
|
141
|
+
if (a.length !== b.length) return false;
|
|
142
|
+
let diff = 0;
|
|
143
|
+
for (let i = 0; i < a.length; i++) diff |= a[i] ^ b[i];
|
|
144
|
+
return diff === 0;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
export function generateKeyPairSync() {
|
|
148
|
+
throw new Error('generateKeyPairSync is not implemented in this environment');
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
export function createHmac() {
|
|
152
|
+
throw new Error('createHmac is not implemented in this environment');
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
export function createCipheriv() {
|
|
156
|
+
throw new Error('createCipheriv is not implemented in this environment');
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
export function createDecipheriv() {
|
|
160
|
+
throw new Error('createDecipheriv is not implemented in this environment');
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export function createSign() {
|
|
164
|
+
throw new Error('createSign is not implemented in this environment');
|
|
165
|
+
}
|
|
166
|
+
|
|
167
|
+
export default { randomBytes, randomUUID, createHash, scryptSync, timingSafeEqual, generateKeyPairSync, createHmac, createCipheriv, createDecipheriv, createSign };
|
|
@@ -1,8 +1,202 @@
|
|
|
1
|
-
//
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
1
|
+
// ── In-memory cache backed by IndexedDB (async writes, sync reads from cache) ──
|
|
2
|
+
|
|
3
|
+
const DB_NAME = 'vfs-fs-shim';
|
|
4
|
+
const STORE = 'files';
|
|
5
|
+
let db = null;
|
|
6
|
+
|
|
7
|
+
function openDB() {
|
|
8
|
+
if (db) return Promise.resolve(db);
|
|
9
|
+
return new Promise((resolve, reject) => {
|
|
10
|
+
const req = indexedDB.open(DB_NAME, 1);
|
|
11
|
+
req.onupgradeneeded = e => e.target.result.createObjectStore(STORE);
|
|
12
|
+
req.onsuccess = e => { db = e.target.result; resolve(db); };
|
|
13
|
+
req.onerror = e => reject(e.target.error);
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
// Sync cache (path → Uint8Array | null)
|
|
18
|
+
const memCache = new Map();
|
|
19
|
+
|
|
20
|
+
// Preload all keys into memCache at startup
|
|
21
|
+
openDB().then(db => {
|
|
22
|
+
const tx = db.transaction(STORE, 'readonly');
|
|
23
|
+
const req = tx.objectStore(STORE).openCursor();
|
|
24
|
+
req.onsuccess = e => {
|
|
25
|
+
const cursor = e.target.result;
|
|
26
|
+
if (!cursor) return;
|
|
27
|
+
memCache.set(cursor.key, cursor.value);
|
|
28
|
+
cursor.continue();
|
|
29
|
+
};
|
|
30
|
+
});
|
|
31
|
+
|
|
32
|
+
function idbSet(path, value) {
|
|
33
|
+
openDB().then(db => {
|
|
34
|
+
const tx = db.transaction(STORE, 'readwrite');
|
|
35
|
+
if (value === null) tx.objectStore(STORE).delete(path);
|
|
36
|
+
else tx.objectStore(STORE).put(value, path);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// ── Helpers ──────────────────────────────────────────────────────────────────
|
|
41
|
+
|
|
42
|
+
function toBytes(data, encoding = 'utf8') {
|
|
43
|
+
if (data instanceof Uint8Array) return data;
|
|
44
|
+
if (typeof data === 'string') {
|
|
45
|
+
if (encoding === 'hex') {
|
|
46
|
+
const arr = new Uint8Array(data.length / 2);
|
|
47
|
+
for (let i = 0; i < arr.length; i++)
|
|
48
|
+
arr[i] = parseInt(data.slice(i*2, i*2+2), 16);
|
|
49
|
+
return arr;
|
|
50
|
+
}
|
|
51
|
+
return new TextEncoder().encode(data);
|
|
52
|
+
}
|
|
53
|
+
return new Uint8Array(data);
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
function fromBytes(bytes, encoding = 'utf8') {
|
|
57
|
+
if (!encoding || encoding === 'utf8') return new TextDecoder().decode(bytes);
|
|
58
|
+
if (encoding === 'hex') return Array.from(bytes).map(b => b.toString(16).padStart(2,'0')).join('');
|
|
59
|
+
if (encoding === 'base64') return btoa(String.fromCharCode(...bytes));
|
|
60
|
+
return new TextDecoder().decode(bytes);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
function parentPath(p) {
|
|
64
|
+
const parts = p.split('/').filter(Boolean);
|
|
65
|
+
parts.pop();
|
|
66
|
+
return '/' + parts.join('/');
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
// ── Sync API (reads from memCache) ───────────────────────────────────────────
|
|
70
|
+
|
|
71
|
+
export function existsSync(path) {
|
|
72
|
+
return memCache.has(path);
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
export function readFileSync(path, optionsOrEncoding) {
|
|
76
|
+
if (!memCache.has(path)) throw Object.assign(new Error(`ENOENT: no such file: ${path}`), { code: 'ENOENT' });
|
|
77
|
+
const bytes = memCache.get(path);
|
|
78
|
+
if (bytes === '__DIR__') throw Object.assign(new Error(`EISDIR: ${path}`), { code: 'EISDIR' });
|
|
79
|
+
const enc = typeof optionsOrEncoding === 'string' ? optionsOrEncoding : optionsOrEncoding?.encoding;
|
|
80
|
+
if (enc) return fromBytes(bytes, enc);
|
|
81
|
+
return globalThis.Buffer.from(bytes);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
export function writeFileSync(path, data, optionsOrEncoding) {
|
|
85
|
+
const enc = typeof optionsOrEncoding === 'string' ? optionsOrEncoding : optionsOrEncoding?.encoding;
|
|
86
|
+
const bytes = toBytes(data, enc);
|
|
87
|
+
memCache.set(path, bytes);
|
|
88
|
+
idbSet(path, bytes);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
export function appendFileSync(path, data, optionsOrEncoding) {
|
|
92
|
+
const enc = typeof optionsOrEncoding === 'string' ? optionsOrEncoding : optionsOrEncoding?.encoding;
|
|
93
|
+
const newBytes = toBytes(data, enc);
|
|
94
|
+
const existing = memCache.has(path) ? memCache.get(path) : new Uint8Array(0);
|
|
95
|
+
const merged = new Uint8Array(existing.length + newBytes.length);
|
|
96
|
+
merged.set(existing);
|
|
97
|
+
merged.set(newBytes, existing.length);
|
|
98
|
+
memCache.set(path, merged);
|
|
99
|
+
idbSet(path, merged);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
export function unlinkSync(path) {
|
|
103
|
+
memCache.delete(path);
|
|
104
|
+
idbSet(path, null);
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
export function rmSync(path, options = {}) {
|
|
108
|
+
if (options.recursive) {
|
|
109
|
+
for (const key of [...memCache.keys()]) {
|
|
110
|
+
if (key === path || key.startsWith(path + '/')) {
|
|
111
|
+
memCache.delete(key);
|
|
112
|
+
idbSet(key, null);
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
} else {
|
|
116
|
+
unlinkSync(path);
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export function mkdirSync(path, options = {}) {
|
|
121
|
+
if (options.recursive) {
|
|
122
|
+
// ensure all parents exist
|
|
123
|
+
const parts = path.split('/').filter(Boolean);
|
|
124
|
+
let cur = '';
|
|
125
|
+
for (const p of parts) {
|
|
126
|
+
cur += '/' + p;
|
|
127
|
+
if (!memCache.has(cur)) { memCache.set(cur, '__DIR__'); idbSet(cur, '__DIR__'); }
|
|
128
|
+
}
|
|
129
|
+
} else {
|
|
130
|
+
memCache.set(path, '__DIR__');
|
|
131
|
+
idbSet(path, '__DIR__');
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
|
|
135
|
+
export function readdirSync(path) {
|
|
136
|
+
const prefix = path.endsWith('/') ? path : path + '/';
|
|
137
|
+
return [...memCache.keys()]
|
|
138
|
+
.filter(k => k.startsWith(prefix) && k.slice(prefix.length).split('/').length === 1)
|
|
139
|
+
.map(k => k.slice(prefix.length));
|
|
140
|
+
}
|
|
141
|
+
|
|
142
|
+
export function statSync(path) {
|
|
143
|
+
if (!memCache.has(path)) throw Object.assign(new Error(`ENOENT: ${path}`), { code: 'ENOENT' });
|
|
144
|
+
const val = memCache.get(path);
|
|
145
|
+
const isDir = val === '__DIR__';
|
|
146
|
+
return {
|
|
147
|
+
isDirectory: () => isDir,
|
|
148
|
+
isFile: () => !isDir,
|
|
149
|
+
size: isDir ? 0 : val.length,
|
|
150
|
+
};
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// ── fd stubs (journal uses these) ────────────────────────────────────────────
|
|
154
|
+
|
|
155
|
+
const fdMap = new Map();
|
|
156
|
+
let fdCounter = 10;
|
|
157
|
+
|
|
158
|
+
export const constants = { O_WRONLY: 1, O_CREAT: 64, O_APPEND: 1024 };
|
|
159
|
+
|
|
160
|
+
export function openSync(path, flags) {
|
|
161
|
+
const fd = fdCounter++;
|
|
162
|
+
const append = (flags & constants.O_APPEND) !== 0;
|
|
163
|
+
const existing = memCache.has(path) ? memCache.get(path) : new Uint8Array(0);
|
|
164
|
+
fdMap.set(fd, { path, data: append ? existing : new Uint8Array(0) });
|
|
165
|
+
return fd;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
export function writeSync(fd, buf) {
|
|
169
|
+
const entry = fdMap.get(fd);
|
|
170
|
+
if (!entry) return;
|
|
171
|
+
const merged = new Uint8Array(entry.data.length + buf.length);
|
|
172
|
+
merged.set(entry.data);
|
|
173
|
+
merged.set(buf, entry.data.length);
|
|
174
|
+
entry.data = merged;
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
export function closeSync(fd) {
|
|
178
|
+
const entry = fdMap.get(fd);
|
|
179
|
+
if (!entry) return;
|
|
180
|
+
memCache.set(entry.path, entry.data);
|
|
181
|
+
idbSet(entry.path, entry.data);
|
|
182
|
+
fdMap.delete(fd);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
export const ready = openDB().then(db => new Promise(resolve => {
|
|
186
|
+
const tx = db.transaction(STORE, 'readonly');
|
|
187
|
+
const req = tx.objectStore(STORE).openCursor();
|
|
188
|
+
req.onsuccess = e => {
|
|
189
|
+
const cursor = e.target.result;
|
|
190
|
+
if (!cursor) return resolve(true);
|
|
191
|
+
memCache.set(cursor.key, cursor.value);
|
|
192
|
+
cursor.continue();
|
|
193
|
+
};
|
|
194
|
+
}));
|
|
195
|
+
|
|
196
|
+
globalThis.__fsReady__ = ready;
|
|
197
|
+
|
|
198
|
+
export default {
|
|
199
|
+
existsSync, readFileSync, writeFileSync, appendFileSync,
|
|
200
|
+
unlinkSync, rmSync, mkdirSync, readdirSync, statSync,
|
|
201
|
+
openSync, writeSync, closeSync, constants, ready
|
|
202
|
+
};
|
|
@@ -1,14 +1,28 @@
|
|
|
1
1
|
export const posix = {
|
|
2
|
-
basename(p){ const parts=p.split('/').filter(Boolean); return parts.length?parts[parts.length-1]:''; },
|
|
3
|
-
dirname(p){ if(!p) return '.'; const parts=p.split('/').filter(Boolean); parts.pop(); return parts.length?'/'+parts.join('/'):'/'; },
|
|
4
|
-
join(...parts){ return parts.join('/').replace(/\/+/g,'/'); },
|
|
5
|
-
resolve(...parts){ // naive resolve
|
|
2
|
+
basename(p) { const parts = p.split('/').filter(Boolean); return parts.length ? parts[parts.length - 1] : ''; },
|
|
3
|
+
dirname(p) { if (!p) return '.'; const parts = p.split('/').filter(Boolean); parts.pop(); return parts.length ? '/' + parts.join('/') : '/'; },
|
|
4
|
+
join(...parts) { return parts.join('/').replace(/\/+/g, '/'); },
|
|
5
|
+
resolve(...parts) { // naive resolve
|
|
6
6
|
const joined = parts.join('/');
|
|
7
7
|
if (joined.startsWith('/')) return joined;
|
|
8
|
-
return '/'+joined;
|
|
8
|
+
return '/' + joined;
|
|
9
9
|
},
|
|
10
|
+
normalize(p) {
|
|
11
|
+
const parts = p.split('/');
|
|
12
|
+
const stack = [];
|
|
13
|
+
for (const part of parts) {
|
|
14
|
+
if (part === '..') stack.pop();
|
|
15
|
+
else if (part && part !== '.') stack.push(part);
|
|
16
|
+
}
|
|
17
|
+
return (p.startsWith('/') ? '/' : '') + stack.join('/') || '.';
|
|
18
|
+
}
|
|
10
19
|
};
|
|
11
|
-
export function basename(p){ return posix.basename(p); }
|
|
12
|
-
export function dirname(p){ return posix.dirname(p); }
|
|
13
|
-
export function resolve(...parts){ return posix.resolve(...parts); }
|
|
14
|
-
export
|
|
20
|
+
export function basename(p) { return posix.basename(p); }
|
|
21
|
+
export function dirname(p) { return posix.dirname(p); }
|
|
22
|
+
export function resolve(...parts) { return posix.resolve(...parts); }
|
|
23
|
+
export function join(...parts) {
|
|
24
|
+
return parts.join('/').replace(/\/+/g, '/');
|
|
25
|
+
}
|
|
26
|
+
export function normalize(p) {
|
|
27
|
+
return posix.normalize(p);
|
|
28
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
globalThis.startedat = Date.now();
|
|
2
|
+
export const process = {
|
|
3
|
+
env: { NODE_ENV: 'production' },
|
|
4
|
+
version: 'v20.0.0',
|
|
5
|
+
platform: 'browser',
|
|
6
|
+
browser: true,
|
|
7
|
+
argv: [],
|
|
8
|
+
cwd: () => '/',
|
|
9
|
+
exit: () => {},
|
|
10
|
+
nextTick: (fn, ...args) => queueMicrotask(() => fn(...args)),
|
|
11
|
+
memoryUsage: () => ({ rss: 0, heapTotal: 0, heapUsed: 0, external: 0 }),
|
|
12
|
+
uptime: () => (Date.now() - globalThis.startedat) / 1000,
|
|
13
|
+
};
|
|
14
|
+
globalThis.process = process;
|
|
@@ -0,0 +1,75 @@
|
|
|
1
|
+
// ssh2 polyfill — browser stub. All methods throw NotImplemented.
|
|
2
|
+
|
|
3
|
+
function notImpl(name) {
|
|
4
|
+
return function() {
|
|
5
|
+
throw new Error(`ssh2: ${name} not implemented in browser`);
|
|
6
|
+
};
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
// ── Client ────────────────────────────────────────────────────────────────────
|
|
10
|
+
|
|
11
|
+
export class Client {
|
|
12
|
+
connect() { notImpl('Client.connect')(); }
|
|
13
|
+
end() { notImpl('Client.end')(); }
|
|
14
|
+
destroy() { notImpl('Client.destroy')(); }
|
|
15
|
+
exec() { notImpl('Client.exec')(); }
|
|
16
|
+
shell() { notImpl('Client.shell')(); }
|
|
17
|
+
subsys() { notImpl('Client.subsys')(); }
|
|
18
|
+
sftp() { notImpl('Client.sftp')(); }
|
|
19
|
+
forwardIn() { notImpl('Client.forwardIn')(); }
|
|
20
|
+
unforwardIn() { notImpl('Client.unforwardIn')(); }
|
|
21
|
+
forwardOut() { notImpl('Client.forwardOut')(); }
|
|
22
|
+
openssh_noMoreSessions(){ notImpl('Client.openssh_noMoreSessions')(); }
|
|
23
|
+
openssh_forwardInStreamLocal() { notImpl('Client.openssh_forwardInStreamLocal')(); }
|
|
24
|
+
openssh_unforwardInStreamLocal(){ notImpl('Client.openssh_unforwardInStreamLocal')(); }
|
|
25
|
+
openssh_forwardOutStreamLocal() { notImpl('Client.openssh_forwardOutStreamLocal')(); }
|
|
26
|
+
on() { return this; }
|
|
27
|
+
once() { return this; }
|
|
28
|
+
off() { return this; }
|
|
29
|
+
emit() { return false; }
|
|
30
|
+
removeListener() { return this; }
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
// ── Server ────────────────────────────────────────────────────────────────────
|
|
34
|
+
|
|
35
|
+
export class Server {
|
|
36
|
+
constructor() { notImpl('Server constructor')(); }
|
|
37
|
+
listen() { notImpl('Server.listen')(); }
|
|
38
|
+
close() { notImpl('Server.close')(); }
|
|
39
|
+
on() { return this; }
|
|
40
|
+
once() { return this; }
|
|
41
|
+
off() { return this; }
|
|
42
|
+
emit() { return false; }
|
|
43
|
+
removeListener() { return this; }
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// ── utils ─────────────────────────────────────────────────────────────────────
|
|
47
|
+
|
|
48
|
+
export const utils = {
|
|
49
|
+
generateKeyPair: notImpl('utils.generateKeyPair'),
|
|
50
|
+
generateKeyPairSync: notImpl('utils.generateKeyPairSync'),
|
|
51
|
+
parseKey: notImpl('utils.parseKey'),
|
|
52
|
+
parsePrivateKey: notImpl('utils.parsePrivateKey'),
|
|
53
|
+
parsePublicKey: notImpl('utils.parsePublicKey'),
|
|
54
|
+
decryptKey: notImpl('utils.decryptKey'),
|
|
55
|
+
sftp: {
|
|
56
|
+
OPEN_MODE: {},
|
|
57
|
+
STATUS_CODE: {},
|
|
58
|
+
flagsToString: notImpl('utils.sftp.flagsToString'),
|
|
59
|
+
stringToFlags: notImpl('utils.sftp.stringToFlags'),
|
|
60
|
+
},
|
|
61
|
+
};
|
|
62
|
+
|
|
63
|
+
// ── HTTPAgent stubs ───────────────────────────────────────────────────────────
|
|
64
|
+
|
|
65
|
+
export class HTTPAgent {
|
|
66
|
+
constructor() { notImpl('HTTPAgent constructor')(); }
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
export class HTTPSAgent {
|
|
70
|
+
constructor() { notImpl('HTTPSAgent constructor')(); }
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
// ── default export (mirrors ssh2 CommonJS shape) ─────────────────────────────
|
|
74
|
+
|
|
75
|
+
export default { Client, Server, utils, HTTPAgent, HTTPSAgent };
|