typescript-virtual-container 1.2.4 → 1.2.6
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 +1056 -1239
- package/benchmark-results.txt +20 -20
- package/dist/SSHMimic/exec.js +2 -2
- package/dist/SSHMimic/executor.d.ts +6 -7
- package/dist/SSHMimic/executor.d.ts.map +1 -1
- package/dist/SSHMimic/executor.js +77 -60
- package/dist/SSHMimic/index.d.ts +19 -2
- package/dist/SSHMimic/index.d.ts.map +1 -1
- package/dist/SSHMimic/index.js +106 -24
- package/dist/SSHMimic/sftp.d.ts.map +1 -1
- package/dist/SSHMimic/sftp.js +14 -0
- package/dist/VirtualFileSystem/index.d.ts +115 -88
- package/dist/VirtualFileSystem/index.d.ts.map +1 -1
- package/dist/VirtualFileSystem/index.js +389 -264
- package/dist/VirtualShell/index.d.ts +3 -4
- package/dist/VirtualShell/index.d.ts.map +1 -1
- package/dist/VirtualShell/index.js +4 -6
- package/dist/VirtualShell/shell.d.ts.map +1 -1
- package/dist/VirtualShell/shell.js +19 -2
- package/dist/VirtualShell/shellParser.d.ts +20 -2
- package/dist/VirtualShell/shellParser.d.ts.map +1 -1
- package/dist/VirtualShell/shellParser.js +229 -120
- package/dist/VirtualUserManager/index.d.ts +25 -0
- package/dist/VirtualUserManager/index.d.ts.map +1 -1
- package/dist/VirtualUserManager/index.js +33 -0
- package/dist/commands/adduser.d.ts.map +1 -1
- package/dist/commands/adduser.js +2 -0
- package/dist/commands/awk.d.ts +3 -0
- package/dist/commands/awk.d.ts.map +1 -0
- package/dist/commands/awk.js +29 -0
- package/dist/commands/base64.d.ts +3 -0
- package/dist/commands/base64.d.ts.map +1 -0
- package/dist/commands/base64.js +20 -0
- package/dist/commands/cat.d.ts.map +1 -1
- package/dist/commands/cat.js +2 -0
- package/dist/commands/cd.d.ts.map +1 -1
- package/dist/commands/cd.js +2 -0
- package/dist/commands/chmod.d.ts +3 -0
- package/dist/commands/chmod.d.ts.map +1 -0
- package/dist/commands/chmod.js +33 -0
- package/dist/commands/clear.d.ts.map +1 -1
- package/dist/commands/clear.js +4 -1
- package/dist/commands/cp.d.ts +3 -0
- package/dist/commands/cp.d.ts.map +1 -0
- package/dist/commands/cp.js +70 -0
- package/dist/commands/curl.d.ts.map +1 -1
- package/dist/commands/curl.js +2 -0
- package/dist/commands/cut.d.ts +3 -0
- package/dist/commands/cut.d.ts.map +1 -0
- package/dist/commands/cut.js +27 -0
- package/dist/commands/date.d.ts +3 -0
- package/dist/commands/date.d.ts.map +1 -0
- package/dist/commands/date.js +22 -0
- package/dist/commands/deluser.d.ts.map +1 -1
- package/dist/commands/deluser.js +2 -0
- package/dist/commands/df.d.ts +3 -0
- package/dist/commands/df.d.ts.map +1 -0
- package/dist/commands/df.js +16 -0
- package/dist/commands/diff.d.ts +3 -0
- package/dist/commands/diff.d.ts.map +1 -0
- package/dist/commands/diff.js +40 -0
- package/dist/commands/du.d.ts +3 -0
- package/dist/commands/du.d.ts.map +1 -0
- package/dist/commands/du.js +39 -0
- package/dist/commands/echo.d.ts.map +1 -1
- package/dist/commands/echo.js +2 -0
- package/dist/commands/env.d.ts.map +1 -1
- package/dist/commands/env.js +6 -14
- package/dist/commands/export.d.ts.map +1 -1
- package/dist/commands/export.js +11 -21
- package/dist/commands/find.d.ts +3 -0
- package/dist/commands/find.d.ts.map +1 -0
- package/dist/commands/find.js +50 -0
- package/dist/commands/grep.d.ts.map +1 -1
- package/dist/commands/grep.js +58 -35
- package/dist/commands/groups.d.ts +3 -0
- package/dist/commands/groups.d.ts.map +1 -0
- package/dist/commands/groups.js +12 -0
- package/dist/commands/gzip.d.ts +4 -0
- package/dist/commands/gzip.d.ts.map +1 -0
- package/dist/commands/gzip.js +40 -0
- package/dist/commands/head.d.ts +3 -0
- package/dist/commands/head.d.ts.map +1 -0
- package/dist/commands/head.js +32 -0
- package/dist/commands/help.d.ts +1 -1
- package/dist/commands/help.d.ts.map +1 -1
- package/dist/commands/help.js +75 -3
- package/dist/commands/hostname.d.ts.map +1 -1
- package/dist/commands/hostname.js +2 -0
- package/dist/commands/htop.d.ts.map +1 -1
- package/dist/commands/htop.js +2 -0
- package/dist/commands/id.d.ts +3 -0
- package/dist/commands/id.d.ts.map +1 -0
- package/dist/commands/id.js +14 -0
- package/dist/commands/index.d.ts +5 -2
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +104 -87
- package/dist/commands/kill.d.ts +3 -0
- package/dist/commands/kill.d.ts.map +1 -0
- package/dist/commands/kill.js +13 -0
- package/dist/commands/ln.d.ts +3 -0
- package/dist/commands/ln.d.ts.map +1 -0
- package/dist/commands/ln.js +44 -0
- package/dist/commands/ls.d.ts.map +1 -1
- package/dist/commands/ls.js +2 -0
- package/dist/commands/mkdir.d.ts.map +1 -1
- package/dist/commands/mkdir.js +2 -0
- package/dist/commands/mv.d.ts +3 -0
- package/dist/commands/mv.d.ts.map +1 -0
- package/dist/commands/mv.js +37 -0
- package/dist/commands/nano.d.ts.map +1 -1
- package/dist/commands/nano.js +2 -0
- package/dist/commands/neofetch.d.ts.map +1 -1
- package/dist/commands/neofetch.js +2 -0
- package/dist/commands/passwd.d.ts.map +1 -1
- package/dist/commands/passwd.js +2 -0
- package/dist/commands/ping.d.ts +3 -0
- package/dist/commands/ping.d.ts.map +1 -0
- package/dist/commands/ping.js +18 -0
- package/dist/commands/ps.d.ts +3 -0
- package/dist/commands/ps.d.ts.map +1 -0
- package/dist/commands/ps.js +17 -0
- package/dist/commands/pwd.d.ts.map +1 -1
- package/dist/commands/pwd.js +2 -0
- package/dist/commands/rm.d.ts.map +1 -1
- package/dist/commands/rm.js +2 -0
- package/dist/commands/sed.d.ts +3 -0
- package/dist/commands/sed.d.ts.map +1 -0
- package/dist/commands/sed.js +47 -0
- package/dist/commands/set.d.ts +3 -0
- package/dist/commands/set.d.ts.map +1 -1
- package/dist/commands/set.js +19 -46
- package/dist/commands/sh.d.ts +0 -1
- package/dist/commands/sh.d.ts.map +1 -1
- package/dist/commands/sh.js +228 -35
- package/dist/commands/sleep.d.ts +3 -0
- package/dist/commands/sleep.d.ts.map +1 -0
- package/dist/commands/sleep.js +13 -0
- package/dist/commands/sort.d.ts +3 -0
- package/dist/commands/sort.d.ts.map +1 -0
- package/dist/commands/sort.js +37 -0
- package/dist/commands/su.d.ts.map +1 -1
- package/dist/commands/su.js +2 -0
- package/dist/commands/sudo.d.ts.map +1 -1
- package/dist/commands/sudo.js +2 -0
- package/dist/commands/tail.d.ts +3 -0
- package/dist/commands/tail.d.ts.map +1 -0
- package/dist/commands/tail.js +35 -0
- package/dist/commands/tar.d.ts +3 -0
- package/dist/commands/tar.d.ts.map +1 -0
- package/dist/commands/tar.js +64 -0
- package/dist/commands/tee.d.ts +3 -0
- package/dist/commands/tee.d.ts.map +1 -0
- package/dist/commands/tee.js +29 -0
- package/dist/commands/touch.d.ts.map +1 -1
- package/dist/commands/touch.js +2 -0
- package/dist/commands/tr.d.ts +3 -0
- package/dist/commands/tr.d.ts.map +1 -0
- package/dist/commands/tr.js +24 -0
- package/dist/commands/tree.d.ts.map +1 -1
- package/dist/commands/tree.js +2 -0
- package/dist/commands/uname.d.ts +3 -0
- package/dist/commands/uname.d.ts.map +1 -0
- package/dist/commands/uname.js +21 -0
- package/dist/commands/uniq.d.ts +3 -0
- package/dist/commands/uniq.d.ts.map +1 -0
- package/dist/commands/uniq.js +33 -0
- package/dist/commands/unset.d.ts.map +1 -1
- package/dist/commands/unset.js +6 -10
- package/dist/commands/wc.d.ts +3 -0
- package/dist/commands/wc.d.ts.map +1 -0
- package/dist/commands/wc.js +50 -0
- package/dist/commands/wget.d.ts.map +1 -1
- package/dist/commands/wget.js +2 -0
- package/dist/commands/who.d.ts.map +1 -1
- package/dist/commands/who.js +2 -0
- package/dist/commands/whoami.d.ts.map +1 -1
- package/dist/commands/whoami.js +2 -0
- package/dist/commands/xargs.d.ts +3 -0
- package/dist/commands/xargs.d.ts.map +1 -0
- package/dist/commands/xargs.js +16 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/types/commands.d.ts +13 -0
- package/dist/types/commands.d.ts.map +1 -1
- package/dist/types/pipeline.d.ts +20 -0
- package/dist/types/pipeline.d.ts.map +1 -1
- package/package.json +5 -2
- package/scripts/publish-package.sh +70 -0
- package/src/SSHMimic/exec.ts +2 -2
- package/src/SSHMimic/executor.ts +95 -98
- package/src/SSHMimic/index.ts +138 -57
- package/src/SSHMimic/sftp.ts +15 -0
- package/src/VirtualFileSystem/index.ts +464 -292
- package/src/VirtualShell/index.ts +4 -6
- package/src/VirtualShell/shell.ts +19 -2
- package/src/VirtualShell/shellParser.ts +202 -168
- package/src/VirtualUserManager/index.ts +36 -0
- package/src/commands/adduser.ts +2 -0
- package/src/commands/awk.ts +30 -0
- package/src/commands/base64.ts +18 -0
- package/src/commands/cat.ts +2 -0
- package/src/commands/cd.ts +2 -0
- package/src/commands/chmod.ts +35 -0
- package/src/commands/clear.ts +4 -1
- package/src/commands/cp.ts +78 -0
- package/src/commands/curl.ts +2 -0
- package/src/commands/cut.ts +29 -0
- package/src/commands/date.ts +24 -0
- package/src/commands/deluser.ts +2 -0
- package/src/commands/df.ts +18 -0
- package/src/commands/diff.ts +29 -0
- package/src/commands/du.ts +39 -0
- package/src/commands/echo.ts +2 -0
- package/src/commands/env.ts +6 -16
- package/src/commands/export.ts +11 -24
- package/src/commands/find.ts +63 -0
- package/src/commands/grep.ts +51 -38
- package/src/commands/groups.ts +14 -0
- package/src/commands/gzip.ts +31 -0
- package/src/commands/head.ts +37 -0
- package/src/commands/help.ts +81 -3
- package/src/commands/hostname.ts +2 -0
- package/src/commands/htop.ts +2 -0
- package/src/commands/id.ts +16 -0
- package/src/commands/index.ts +114 -133
- package/src/commands/kill.ts +14 -0
- package/src/commands/ln.ts +49 -0
- package/src/commands/ls.ts +2 -0
- package/src/commands/mkdir.ts +2 -0
- package/src/commands/mv.ts +45 -0
- package/src/commands/nano.ts +2 -0
- package/src/commands/neofetch.ts +2 -0
- package/src/commands/passwd.ts +2 -0
- package/src/commands/ping.ts +20 -0
- package/src/commands/ps.ts +19 -0
- package/src/commands/pwd.ts +2 -0
- package/src/commands/rm.ts +2 -0
- package/src/commands/sed.ts +45 -0
- package/src/commands/set.ts +19 -50
- package/src/commands/sh.ts +192 -43
- package/src/commands/sleep.ts +14 -0
- package/src/commands/sort.ts +37 -0
- package/src/commands/su.ts +2 -0
- package/src/commands/sudo.ts +2 -0
- package/src/commands/tail.ts +39 -0
- package/src/commands/tar.ts +58 -0
- package/src/commands/tee.ts +25 -0
- package/src/commands/touch.ts +2 -0
- package/src/commands/tr.ts +24 -0
- package/src/commands/tree.ts +2 -0
- package/src/commands/uname.ts +20 -0
- package/src/commands/uniq.ts +28 -0
- package/src/commands/unset.ts +5 -12
- package/src/commands/wc.ts +50 -0
- package/src/commands/wget.ts +2 -0
- package/src/commands/who.ts +2 -0
- package/src/commands/whoami.ts +2 -0
- package/src/commands/xargs.ts +17 -0
- package/src/index.ts +1 -0
- package/src/types/commands.ts +14 -0
- package/src/types/pipeline.ts +23 -0
- package/standalone.js +93 -55
- package/standalone.js.map +4 -4
- package/tests/bun-test-shim.ts +1 -0
- package/tests/sftp.test.ts +115 -191
- package/tests/users.test.ts +42 -88
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EventEmitter } from "node:events";
|
|
2
2
|
import type { CommandContext, CommandResult } from "../types/commands";
|
|
3
3
|
import type { ShellStream } from "../types/streams";
|
|
4
|
-
import VirtualFileSystem from "../VirtualFileSystem";
|
|
4
|
+
import VirtualFileSystem, { type VfsOptions } from "../VirtualFileSystem";
|
|
5
5
|
import { VirtualUserManager } from "../VirtualUserManager";
|
|
6
6
|
export interface ShellProperties {
|
|
7
7
|
kernel: string;
|
|
@@ -15,7 +15,6 @@ export interface ShellProperties {
|
|
|
15
15
|
* client API.
|
|
16
16
|
*/
|
|
17
17
|
declare class VirtualShell extends EventEmitter {
|
|
18
|
-
basePath: string;
|
|
19
18
|
vfs: VirtualFileSystem;
|
|
20
19
|
users: VirtualUserManager;
|
|
21
20
|
hostname: string;
|
|
@@ -26,9 +25,9 @@ declare class VirtualShell extends EventEmitter {
|
|
|
26
25
|
*
|
|
27
26
|
* @param hostname Virtual hostname used for prompts and idents.
|
|
28
27
|
* @param properties Customizable properties shown in `uname -a` and similar commands.
|
|
29
|
-
* @param
|
|
28
|
+
* @param vfsOptions Optional VFS persistence options (mode, snapshotPath).
|
|
30
29
|
*/
|
|
31
|
-
constructor(hostname: string, properties?: ShellProperties,
|
|
30
|
+
constructor(hostname: string, properties?: ShellProperties, vfsOptions?: VfsOptions);
|
|
32
31
|
/**
|
|
33
32
|
* Ensures initialization is complete before allowing operations.
|
|
34
33
|
* Call this before any authentication or command execution.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/VirtualShell/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAGpD,OAAO,iBAAiB,MAAM,sBAAsB,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/VirtualShell/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,KAAK,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,mBAAmB,CAAC;AACvE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAGpD,OAAO,iBAAiB,EAAE,EAAE,KAAK,UAAU,EAAE,MAAM,sBAAsB,CAAC;AAC1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAC;AAG3D,MAAM,WAAW,eAAe;IAC/B,MAAM,EAAE,MAAM,C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GAAG,MAAM,GACtB,IAAI;CAKP;AAED,OAAO,EAAE,YAAY,EAAE,CAAC"}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { EventEmitter } from "node:events";
|
|
2
2
|
import { createCustomCommand, registerCommand, runCommand } from "../commands";
|
|
3
3
|
import { createPerfLogger } from "../utils/perfLogger";
|
|
4
|
-
import VirtualFileSystem from "../VirtualFileSystem";
|
|
4
|
+
import VirtualFileSystem, {} from "../VirtualFileSystem";
|
|
5
5
|
import { VirtualUserManager } from "../VirtualUserManager";
|
|
6
6
|
import { startShell } from "./shell";
|
|
7
7
|
const defaultShellProperties = {
|
|
@@ -24,7 +24,6 @@ function resolveAutoSudoForNewUsers() {
|
|
|
24
24
|
* client API.
|
|
25
25
|
*/
|
|
26
26
|
class VirtualShell extends EventEmitter {
|
|
27
|
-
basePath = ".";
|
|
28
27
|
vfs;
|
|
29
28
|
users;
|
|
30
29
|
hostname;
|
|
@@ -35,15 +34,14 @@ class VirtualShell extends EventEmitter {
|
|
|
35
34
|
*
|
|
36
35
|
* @param hostname Virtual hostname used for prompts and idents.
|
|
37
36
|
* @param properties Customizable properties shown in `uname -a` and similar commands.
|
|
38
|
-
* @param
|
|
37
|
+
* @param vfsOptions Optional VFS persistence options (mode, snapshotPath).
|
|
39
38
|
*/
|
|
40
|
-
constructor(hostname, properties,
|
|
39
|
+
constructor(hostname, properties, vfsOptions) {
|
|
41
40
|
super();
|
|
42
41
|
perf.mark("constructor");
|
|
43
42
|
this.hostname = hostname;
|
|
44
43
|
this.properties = properties || defaultShellProperties;
|
|
45
|
-
this.
|
|
46
|
-
this.vfs = new VirtualFileSystem(this.basePath);
|
|
44
|
+
this.vfs = new VirtualFileSystem(vfsOptions ?? {});
|
|
47
45
|
this.users = new VirtualUserManager(this.vfs, resolveAutoSudoForNewUsers());
|
|
48
46
|
// Store references to avoid TypeScript "used before assigned" errors
|
|
49
47
|
const vfs = this.vfs;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shell.d.ts","sourceRoot":"","sources":["../../src/VirtualShell/shell.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,GAAG,CAAC;
|
|
1
|
+
{"version":3,"file":"shell.d.ts","sourceRoot":"","sources":["../../src/VirtualShell/shell.ts"],"names":[],"mappings":"AAGA,OAAO,KAAK,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,GAAG,CAAC;AAOvD,OAAO,EAGN,KAAK,YAAY,EAEjB,MAAM,yBAAyB,CAAC;AAGjC,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAmBpD,wBAAgB,UAAU,CACzB,UAAU,EAAE,eAAe,EAC3B,MAAM,EAAE,WAAW,EACnB,QAAQ,EAAE,MAAM,EAChB,QAAQ,EAAE,MAAM,EAChB,SAAS,EAAE,MAAM,GAAG,IAAI,EACxB,aAAa,oBAAY,EACzB,YAAY,EAAE,YAAY,YAAyB,EACnD,KAAK,EAAE,YAAY,GACjB,IAAI,CA8mBN"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { readFile, unlink, writeFile } from "node:fs/promises";
|
|
2
2
|
import * as path from "node:path";
|
|
3
|
-
import { getCommandNames, runCommand } from "../commands";
|
|
3
|
+
import { getCommandNames, makeDefaultEnv, runCommand } from "../commands";
|
|
4
4
|
import { spawnHtopProcess, spawnNanoEditorProcess, } from "../modules/shellInteractive";
|
|
5
5
|
import { getVisibleHtopPidList, resolvePath, toTtyLines, } from "../modules/shellRuntime";
|
|
6
6
|
import { formatLoginDate } from "../SSHMimic/loginFormat";
|
|
@@ -12,6 +12,7 @@ export function startShell(properties, stream, authUser, hostname, sessionId, re
|
|
|
12
12
|
let historyIndex = null;
|
|
13
13
|
let historyDraft = "";
|
|
14
14
|
let cwd = `/home/${authUser}`;
|
|
15
|
+
const shellEnv = makeDefaultEnv(authUser, hostname);
|
|
15
16
|
let nanoSession = null;
|
|
16
17
|
let pendingSudo = null;
|
|
17
18
|
const buildCurrentPrompt = () => {
|
|
@@ -21,6 +22,22 @@ export function startShell(properties, stream, authUser, hostname, sessionId, re
|
|
|
21
22
|
};
|
|
22
23
|
const commandNames = Array.from(new Set(getCommandNames())).sort();
|
|
23
24
|
console.log(`[${sessionId}] Shell started for user '${authUser}' at ${remoteAddress}`);
|
|
25
|
+
// Load .bashrc if it exists
|
|
26
|
+
void (async () => {
|
|
27
|
+
const bashrcPath = `/home/${authUser}/.bashrc`;
|
|
28
|
+
if (shell.vfs.exists(bashrcPath)) {
|
|
29
|
+
try {
|
|
30
|
+
const bashrc = shell.vfs.readFile(bashrcPath);
|
|
31
|
+
for (const line of bashrc.split("\n")) {
|
|
32
|
+
const l = line.trim();
|
|
33
|
+
if (!l || l.startsWith("#"))
|
|
34
|
+
continue;
|
|
35
|
+
await runCommand(l, authUser, hostname, "shell", cwd, shell, undefined, shellEnv);
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
catch { /* ignore bashrc errors */ }
|
|
39
|
+
}
|
|
40
|
+
})();
|
|
24
41
|
function renderLine() {
|
|
25
42
|
const prompt = buildCurrentPrompt();
|
|
26
43
|
stream.write(`\r${prompt}${lineBuffer}\u001b[K`);
|
|
@@ -404,7 +421,7 @@ export function startShell(properties, stream, authUser, hostname, sessionId, re
|
|
|
404
421
|
historyDraft = "";
|
|
405
422
|
stream.write("\r\n");
|
|
406
423
|
if (line.length > 0) {
|
|
407
|
-
const result = await Promise.resolve(runCommand(line, authUser, hostname, "shell", cwd, shell));
|
|
424
|
+
const result = await Promise.resolve(runCommand(line, authUser, hostname, "shell", cwd, shell, undefined, shellEnv));
|
|
408
425
|
pushHistory(line);
|
|
409
426
|
if (result.openEditor) {
|
|
410
427
|
await startNanoEditor(result.openEditor.targetPath, result.openEditor.initialContent, result.openEditor.tempPath);
|
|
@@ -1,4 +1,22 @@
|
|
|
1
|
-
import type { Pipeline } from "../types/pipeline";
|
|
2
|
-
/**
|
|
1
|
+
import type { Pipeline, Script } from "../types/pipeline";
|
|
2
|
+
/**
|
|
3
|
+
* Parse a shell input line into a Script (sequence of statements connected
|
|
4
|
+
* by && / || / ;). Each statement contains one Pipeline (commands connected
|
|
5
|
+
* by |).
|
|
6
|
+
*/
|
|
7
|
+
export declare function parseScript(rawInput: string): Script;
|
|
8
|
+
/** Legacy compat: parse a single pipeline (no &&/||/;) */
|
|
3
9
|
export declare function parseShellPipeline(rawInput: string): Pipeline;
|
|
10
|
+
/**
|
|
11
|
+
* Expand ~ and $VAR / ${VAR} / ${VAR:-default} / $(cmd placeholder) in a
|
|
12
|
+
* token, given the current env vars and home path.
|
|
13
|
+
* Command substitution $(…) is NOT executed here — it's left as a marker so
|
|
14
|
+
* the executor can handle it.
|
|
15
|
+
*/
|
|
16
|
+
export declare function expandToken(token: string, env: Record<string, string>, authUser: string, lastExitCode?: number): string;
|
|
17
|
+
/**
|
|
18
|
+
* Expand glob patterns (*, ?, [abc]) against a list of entries.
|
|
19
|
+
* Returns the original pattern if no match.
|
|
20
|
+
*/
|
|
21
|
+
export declare function expandGlob(pattern: string, entries: string[]): string[];
|
|
4
22
|
//# sourceMappingURL=shellParser.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"shellParser.d.ts","sourceRoot":"","sources":["../../src/VirtualShell/shellParser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAmB,MAAM,mBAAmB,CAAC;
|
|
1
|
+
{"version":3,"file":"shellParser.d.ts","sourceRoot":"","sources":["../../src/VirtualShell/shellParser.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,QAAQ,EAAmB,MAAM,EAAwB,MAAM,mBAAmB,CAAC;AAIjG;;;;GAIG;AACH,wBAAgB,WAAW,CAAC,QAAQ,EAAE,MAAM,GAAG,MAAM,CAUpD;AAED,0DAA0D;AAC1D,wBAAgB,kBAAkB,CAAC,QAAQ,EAAE,MAAM,GAAG,QAAQ,CAS7D;AAID;;;;;GAKG;AACH,wBAAgB,WAAW,CAC1B,KAAK,EAAE,MAAM,EACb,GAAG,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,EAC3B,QAAQ,EAAE,MAAM,EAChB,YAAY,SAAI,GACd,MAAM,CA4BR;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAKvE"}
|
|
@@ -1,91 +1,225 @@
|
|
|
1
|
-
|
|
1
|
+
// ── Public API ───────────────────────────────────────────────────────────────
|
|
2
|
+
/**
|
|
3
|
+
* Parse a shell input line into a Script (sequence of statements connected
|
|
4
|
+
* by && / || / ;). Each statement contains one Pipeline (commands connected
|
|
5
|
+
* by |).
|
|
6
|
+
*/
|
|
7
|
+
export function parseScript(rawInput) {
|
|
8
|
+
const trimmed = rawInput.trim();
|
|
9
|
+
if (!trimmed)
|
|
10
|
+
return { statements: [], isValid: true };
|
|
11
|
+
try {
|
|
12
|
+
const statements = parseStatements(trimmed);
|
|
13
|
+
return { statements, isValid: true };
|
|
14
|
+
}
|
|
15
|
+
catch (e) {
|
|
16
|
+
return { statements: [], isValid: false, error: e.message };
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
/** Legacy compat: parse a single pipeline (no &&/||/;) */
|
|
2
20
|
export function parseShellPipeline(rawInput) {
|
|
3
21
|
const trimmed = rawInput.trim();
|
|
4
|
-
if (!trimmed)
|
|
22
|
+
if (!trimmed)
|
|
5
23
|
return { commands: [], isValid: true };
|
|
24
|
+
try {
|
|
25
|
+
const commands = parsePipeline(trimmed);
|
|
26
|
+
return { commands, isValid: true };
|
|
6
27
|
}
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
if (tokenized.error) {
|
|
10
|
-
return {
|
|
11
|
-
commands: [],
|
|
12
|
-
isValid: false,
|
|
13
|
-
error: tokenized.error,
|
|
14
|
-
};
|
|
28
|
+
catch (e) {
|
|
29
|
+
return { commands: [], isValid: false, error: e.message };
|
|
15
30
|
}
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
31
|
+
}
|
|
32
|
+
// ── Variable & tilde expansion ────────────────────────────────────────────────
|
|
33
|
+
/**
|
|
34
|
+
* Expand ~ and $VAR / ${VAR} / ${VAR:-default} / $(cmd placeholder) in a
|
|
35
|
+
* token, given the current env vars and home path.
|
|
36
|
+
* Command substitution $(…) is NOT executed here — it's left as a marker so
|
|
37
|
+
* the executor can handle it.
|
|
38
|
+
*/
|
|
39
|
+
export function expandToken(token, env, authUser, lastExitCode = 0) {
|
|
40
|
+
// tilde expansion
|
|
41
|
+
token = token.replace(/^~(\/|$)/, `/home/${authUser}$1`);
|
|
42
|
+
// $? special var
|
|
43
|
+
token = token.replace(/\$\?/g, String(lastExitCode));
|
|
44
|
+
// $$ PID (mock)
|
|
45
|
+
token = token.replace(/\$\$/g, "1");
|
|
46
|
+
// $# argc (0 for interactive)
|
|
47
|
+
token = token.replace(/\$#/g, "0");
|
|
48
|
+
// ${VAR:-default} and ${VAR:+value}
|
|
49
|
+
token = token.replace(/\$\{([^}:]+):-([^}]*)\}/g, (_, name, def) => env[name] ?? def);
|
|
50
|
+
token = token.replace(/\$\{([^}:]+):\+([^}]*)\}/g, (_, name, val) => env[name] ? val : "");
|
|
51
|
+
// ${VAR}
|
|
52
|
+
token = token.replace(/\$\{([^}]+)\}/g, (_, name) => env[name] ?? "");
|
|
53
|
+
// $VAR (greedy: match longest valid identifier)
|
|
54
|
+
token = token.replace(/\$([A-Za-z_][A-Za-z0-9_]*)/g, (_, name) => env[name] ?? "");
|
|
55
|
+
return token;
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Expand glob patterns (*, ?, [abc]) against a list of entries.
|
|
59
|
+
* Returns the original pattern if no match.
|
|
60
|
+
*/
|
|
61
|
+
export function expandGlob(pattern, entries) {
|
|
62
|
+
if (!/[*?[]/.test(pattern))
|
|
63
|
+
return [pattern];
|
|
64
|
+
const regex = globToRegex(pattern);
|
|
65
|
+
const matches = entries.filter((e) => regex.test(e));
|
|
66
|
+
return matches.length > 0 ? matches.sort() : [pattern];
|
|
67
|
+
}
|
|
68
|
+
function globToRegex(pattern) {
|
|
69
|
+
let re = "^";
|
|
70
|
+
for (let i = 0; i < pattern.length; i++) {
|
|
71
|
+
const c = pattern[i];
|
|
72
|
+
if (c === "*")
|
|
73
|
+
re += ".*";
|
|
74
|
+
else if (c === "?")
|
|
75
|
+
re += ".";
|
|
76
|
+
else if (c === "[") {
|
|
77
|
+
const close = pattern.indexOf("]", i + 1);
|
|
78
|
+
if (close === -1)
|
|
79
|
+
re += "\\[";
|
|
80
|
+
else {
|
|
81
|
+
re += `[${pattern.slice(i + 1, close)}]`;
|
|
82
|
+
i = close;
|
|
83
|
+
}
|
|
28
84
|
}
|
|
85
|
+
else
|
|
86
|
+
re += c.replace(/[.+^${}()|[\]\\]/g, "\\$&");
|
|
29
87
|
}
|
|
30
|
-
return {
|
|
88
|
+
return new RegExp(`${re}$`);
|
|
31
89
|
}
|
|
32
|
-
|
|
33
|
-
function
|
|
34
|
-
|
|
90
|
+
// ── Internal parser ───────────────────────────────────────────────────────────
|
|
91
|
+
function parseStatements(input) {
|
|
92
|
+
// Split by ;, &&, || — respecting quotes and parens
|
|
93
|
+
const segments = splitByLogicalOps(input);
|
|
94
|
+
const statements = [];
|
|
95
|
+
for (const seg of segments) {
|
|
96
|
+
const commands = parsePipeline(seg.text.trim());
|
|
97
|
+
const stmt = { pipeline: { commands, isValid: true } };
|
|
98
|
+
if (seg.op)
|
|
99
|
+
stmt.op = seg.op;
|
|
100
|
+
statements.push(stmt);
|
|
101
|
+
}
|
|
102
|
+
return statements;
|
|
103
|
+
}
|
|
104
|
+
function splitByLogicalOps(input) {
|
|
105
|
+
const segments = [];
|
|
35
106
|
let current = "";
|
|
36
|
-
let
|
|
37
|
-
let
|
|
107
|
+
let depth = 0; // parens/subshell depth
|
|
108
|
+
let inQ = false;
|
|
109
|
+
let qChar = "";
|
|
38
110
|
let i = 0;
|
|
111
|
+
const flush = (op) => {
|
|
112
|
+
if (current.trim())
|
|
113
|
+
segments.push({ text: current, op });
|
|
114
|
+
current = "";
|
|
115
|
+
};
|
|
39
116
|
while (i < input.length) {
|
|
40
117
|
const ch = input[i];
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
}
|
|
46
|
-
else if (ch === quoteChar) {
|
|
47
|
-
inQuotes = false;
|
|
48
|
-
}
|
|
118
|
+
const ch2 = input.slice(i, i + 2);
|
|
119
|
+
if ((ch === '"' || ch === "'") && !inQ) {
|
|
120
|
+
inQ = true;
|
|
121
|
+
qChar = ch;
|
|
49
122
|
current += ch;
|
|
50
123
|
i++;
|
|
124
|
+
continue;
|
|
51
125
|
}
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
tokens: [],
|
|
56
|
-
error: "Syntax error near unexpected token '|'",
|
|
57
|
-
};
|
|
58
|
-
}
|
|
59
|
-
tokens.push(current.trim());
|
|
60
|
-
current = "";
|
|
126
|
+
if (inQ && ch === qChar) {
|
|
127
|
+
inQ = false;
|
|
128
|
+
current += ch;
|
|
61
129
|
i++;
|
|
130
|
+
continue;
|
|
62
131
|
}
|
|
63
|
-
|
|
132
|
+
if (inQ) {
|
|
64
133
|
current += ch;
|
|
65
134
|
i++;
|
|
135
|
+
continue;
|
|
66
136
|
}
|
|
137
|
+
if (ch === "(") {
|
|
138
|
+
depth++;
|
|
139
|
+
current += ch;
|
|
140
|
+
i++;
|
|
141
|
+
continue;
|
|
142
|
+
}
|
|
143
|
+
if (ch === ")") {
|
|
144
|
+
depth--;
|
|
145
|
+
current += ch;
|
|
146
|
+
i++;
|
|
147
|
+
continue;
|
|
148
|
+
}
|
|
149
|
+
if (depth > 0) {
|
|
150
|
+
current += ch;
|
|
151
|
+
i++;
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
if (ch2 === "&&") {
|
|
155
|
+
flush("&&");
|
|
156
|
+
i += 2;
|
|
157
|
+
continue;
|
|
158
|
+
}
|
|
159
|
+
if (ch2 === "||") {
|
|
160
|
+
flush("||");
|
|
161
|
+
i += 2;
|
|
162
|
+
continue;
|
|
163
|
+
}
|
|
164
|
+
if (ch === ";") {
|
|
165
|
+
flush(";");
|
|
166
|
+
i++;
|
|
167
|
+
continue;
|
|
168
|
+
}
|
|
169
|
+
current += ch;
|
|
170
|
+
i++;
|
|
67
171
|
}
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
172
|
+
flush();
|
|
173
|
+
return segments;
|
|
174
|
+
}
|
|
175
|
+
function parsePipeline(input) {
|
|
176
|
+
const pipeTokens = splitByPipe(input);
|
|
177
|
+
return pipeTokens.map(parseCommandWithRedirections);
|
|
178
|
+
}
|
|
179
|
+
function splitByPipe(input) {
|
|
180
|
+
const tokens = [];
|
|
181
|
+
let current = "";
|
|
182
|
+
let inQ = false;
|
|
183
|
+
let qChar = "";
|
|
184
|
+
for (let i = 0; i < input.length; i++) {
|
|
185
|
+
const ch = input[i];
|
|
186
|
+
if ((ch === '"' || ch === "'") && !inQ) {
|
|
187
|
+
inQ = true;
|
|
188
|
+
qChar = ch;
|
|
189
|
+
current += ch;
|
|
190
|
+
continue;
|
|
191
|
+
}
|
|
192
|
+
if (inQ && ch === qChar) {
|
|
193
|
+
inQ = false;
|
|
194
|
+
current += ch;
|
|
195
|
+
continue;
|
|
196
|
+
}
|
|
197
|
+
if (inQ) {
|
|
198
|
+
current += ch;
|
|
199
|
+
continue;
|
|
200
|
+
}
|
|
201
|
+
// || was already consumed at statement level, bare | is pipe
|
|
202
|
+
if (ch === "|" && input[i + 1] !== "|") {
|
|
203
|
+
if (!current.trim())
|
|
204
|
+
throw new Error("Syntax error near unexpected token '|'");
|
|
205
|
+
tokens.push(current.trim());
|
|
206
|
+
current = "";
|
|
207
|
+
}
|
|
208
|
+
else {
|
|
209
|
+
current += ch;
|
|
210
|
+
}
|
|
79
211
|
}
|
|
80
|
-
|
|
81
|
-
|
|
212
|
+
const tail = current.trim();
|
|
213
|
+
if (!tail && tokens.length > 0)
|
|
214
|
+
throw new Error("Syntax error near unexpected token '|'");
|
|
215
|
+
if (tail)
|
|
216
|
+
tokens.push(tail);
|
|
217
|
+
return tokens;
|
|
82
218
|
}
|
|
83
|
-
/** Parse a single command with its redirections (>, >>, <) */
|
|
84
219
|
function parseCommandWithRedirections(token) {
|
|
85
220
|
const parts = tokenizeCommand(token);
|
|
86
|
-
if (parts.length === 0)
|
|
87
|
-
return {
|
|
88
|
-
}
|
|
221
|
+
if (parts.length === 0)
|
|
222
|
+
return { name: "", args: [] };
|
|
89
223
|
const cmdParts = [];
|
|
90
224
|
let inputFile;
|
|
91
225
|
let outputFile;
|
|
@@ -95,35 +229,23 @@ function parseCommandWithRedirections(token) {
|
|
|
95
229
|
const part = parts[i];
|
|
96
230
|
if (part === "<") {
|
|
97
231
|
i++;
|
|
98
|
-
if (i >= parts.length)
|
|
99
|
-
|
|
100
|
-
isValid: false,
|
|
101
|
-
error: "Syntax error: expected filename after <",
|
|
102
|
-
};
|
|
103
|
-
}
|
|
232
|
+
if (i >= parts.length)
|
|
233
|
+
throw new Error("Syntax error: expected filename after <");
|
|
104
234
|
inputFile = parts[i];
|
|
105
235
|
i++;
|
|
106
236
|
}
|
|
107
237
|
else if (part === ">>") {
|
|
108
238
|
i++;
|
|
109
|
-
if (i >= parts.length)
|
|
110
|
-
|
|
111
|
-
isValid: false,
|
|
112
|
-
error: "Syntax error: expected filename after >>",
|
|
113
|
-
};
|
|
114
|
-
}
|
|
239
|
+
if (i >= parts.length)
|
|
240
|
+
throw new Error("Syntax error: expected filename after >>");
|
|
115
241
|
outputFile = parts[i];
|
|
116
242
|
appendOutput = true;
|
|
117
243
|
i++;
|
|
118
244
|
}
|
|
119
245
|
else if (part === ">") {
|
|
120
246
|
i++;
|
|
121
|
-
if (i >= parts.length)
|
|
122
|
-
|
|
123
|
-
isValid: false,
|
|
124
|
-
error: "Syntax error: expected filename after >",
|
|
125
|
-
};
|
|
126
|
-
}
|
|
247
|
+
if (i >= parts.length)
|
|
248
|
+
throw new Error("Syntax error: expected filename after >");
|
|
127
249
|
outputFile = parts[i];
|
|
128
250
|
appendOutput = false;
|
|
129
251
|
i++;
|
|
@@ -133,55 +255,44 @@ function parseCommandWithRedirections(token) {
|
|
|
133
255
|
i++;
|
|
134
256
|
}
|
|
135
257
|
}
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
}
|
|
139
|
-
const name = cmdParts[0].toLowerCase();
|
|
140
|
-
const args = cmdParts.slice(1);
|
|
141
|
-
return {
|
|
142
|
-
command: {
|
|
143
|
-
name,
|
|
144
|
-
args,
|
|
145
|
-
inputFile,
|
|
146
|
-
outputFile,
|
|
147
|
-
appendOutput,
|
|
148
|
-
},
|
|
149
|
-
isValid: true,
|
|
150
|
-
};
|
|
258
|
+
const name = (cmdParts[0] ?? "").toLowerCase();
|
|
259
|
+
return { name, args: cmdParts.slice(1), inputFile, outputFile, appendOutput };
|
|
151
260
|
}
|
|
152
|
-
/** Tokenize a command, respecting quotes and handling >> vs > */
|
|
153
261
|
function tokenizeCommand(input) {
|
|
154
262
|
const tokens = [];
|
|
155
263
|
let current = "";
|
|
156
|
-
let
|
|
157
|
-
let
|
|
264
|
+
let inQ = false;
|
|
265
|
+
let qChar = "";
|
|
158
266
|
let i = 0;
|
|
159
267
|
while (i < input.length) {
|
|
160
268
|
const ch = input[i];
|
|
161
269
|
const next = input[i + 1];
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
}
|
|
172
|
-
else {
|
|
173
|
-
current += ch;
|
|
174
|
-
}
|
|
270
|
+
if ((ch === '"' || ch === "'") && !inQ) {
|
|
271
|
+
inQ = true;
|
|
272
|
+
qChar = ch;
|
|
273
|
+
i++;
|
|
274
|
+
continue;
|
|
275
|
+
}
|
|
276
|
+
if (inQ && ch === qChar) {
|
|
277
|
+
inQ = false;
|
|
278
|
+
qChar = "";
|
|
175
279
|
i++;
|
|
280
|
+
continue;
|
|
176
281
|
}
|
|
177
|
-
|
|
282
|
+
if (inQ) {
|
|
283
|
+
current += ch;
|
|
284
|
+
i++;
|
|
285
|
+
continue;
|
|
286
|
+
}
|
|
287
|
+
if (ch === " ") {
|
|
178
288
|
if (current) {
|
|
179
289
|
tokens.push(current);
|
|
180
290
|
current = "";
|
|
181
291
|
}
|
|
182
292
|
i++;
|
|
293
|
+
continue;
|
|
183
294
|
}
|
|
184
|
-
|
|
295
|
+
if ((ch === ">" || ch === "<") && !inQ) {
|
|
185
296
|
if (current) {
|
|
186
297
|
tokens.push(current);
|
|
187
298
|
current = "";
|
|
@@ -194,14 +305,12 @@ function tokenizeCommand(input) {
|
|
|
194
305
|
tokens.push(ch);
|
|
195
306
|
i++;
|
|
196
307
|
}
|
|
308
|
+
continue;
|
|
197
309
|
}
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
i++;
|
|
201
|
-
}
|
|
310
|
+
current += ch;
|
|
311
|
+
i++;
|
|
202
312
|
}
|
|
203
|
-
if (current)
|
|
313
|
+
if (current)
|
|
204
314
|
tokens.push(current);
|
|
205
|
-
}
|
|
206
315
|
return tokens;
|
|
207
316
|
}
|
|
@@ -189,5 +189,30 @@ export declare class VirtualUserManager extends EventEmitter {
|
|
|
189
189
|
hashPassword(password: string): string;
|
|
190
190
|
private validateUsername;
|
|
191
191
|
private validatePassword;
|
|
192
|
+
private readonly authorizedKeys;
|
|
193
|
+
/**
|
|
194
|
+
* Adds an SSH public key for a user, enabling public-key authentication.
|
|
195
|
+
*
|
|
196
|
+
* @param username Target user.
|
|
197
|
+
* @param algo Key algorithm (e.g. "ssh-rsa", "ssh-ed25519").
|
|
198
|
+
* @param data Raw key data as a Buffer (the base64-decoded key bytes).
|
|
199
|
+
*/
|
|
200
|
+
addAuthorizedKey(username: string, algo: string, data: Buffer): void;
|
|
201
|
+
/**
|
|
202
|
+
* Removes all authorized keys for a user.
|
|
203
|
+
*
|
|
204
|
+
* @param username Target user.
|
|
205
|
+
*/
|
|
206
|
+
removeAuthorizedKeys(username: string): void;
|
|
207
|
+
/**
|
|
208
|
+
* Returns the list of authorized keys for a user.
|
|
209
|
+
* Returns an empty array when no keys are registered.
|
|
210
|
+
*
|
|
211
|
+
* @param username Target user.
|
|
212
|
+
*/
|
|
213
|
+
getAuthorizedKeys(username: string): Array<{
|
|
214
|
+
algo: string;
|
|
215
|
+
data: Buffer;
|
|
216
|
+
}>;
|
|
192
217
|
}
|
|
193
218
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/VirtualUserManager/index.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAI3C,OAAO,KAAK,iBAAiB,MAAM,sBAAsB,CAAC;AAE1D,gDAAgD;AAChD,MAAM,WAAW,iBAAiB;IACjC,yBAAyB;IACzB,QAAQ,EAAE,MAAM,CAAC;IACjB,sDAAsD;IACtD,IAAI,EAAE,MAAM,CAAC;IACb,oDAAoD;IACpD,YAAY,EAAE,MAAM,CAAC;CACrB;AAED,2DAA2D;AAC3D,MAAM,WAAW,oBAAoB;IACpC,wCAAwC;IACxC,EAAE,EAAE,MAAM,CAAC;IACX,iCAAiC;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,2CAA2C;IAC3C,GAAG,EAAE,MAAM,CAAC;IACZ,sCAAsC;IACtC,aAAa,EAAE,MAAM,CAAC;IACtB,g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