termbeam 1.0.0 → 1.0.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/package.json +1 -1
- package/src/cli.js +33 -6
- package/src/server.js +8 -3
package/package.json
CHANGED
package/src/cli.js
CHANGED
|
@@ -76,7 +76,10 @@ function getWindowsAncestors(startPid, maxDepth = 4) {
|
|
|
76
76
|
if (cols.length <= Math.max(nameIdx, pidIdx, ppidIdx)) continue;
|
|
77
77
|
const pid = parseInt(cols[pidIdx], 10);
|
|
78
78
|
if (Number.isFinite(pid)) {
|
|
79
|
-
processes.set(pid, {
|
|
79
|
+
processes.set(pid, {
|
|
80
|
+
name: cols[nameIdx].trim().toLowerCase(),
|
|
81
|
+
ppid: parseInt(cols[ppidIdx], 10),
|
|
82
|
+
});
|
|
80
83
|
}
|
|
81
84
|
}
|
|
82
85
|
|
|
@@ -137,8 +140,14 @@ function getDefaultShell() {
|
|
|
137
140
|
const comm = result.trim();
|
|
138
141
|
if (comm) {
|
|
139
142
|
const shell = comm.startsWith('-') ? comm.slice(1) : comm;
|
|
140
|
-
log.debug(`Detected parent
|
|
141
|
-
|
|
143
|
+
log.debug(`Detected parent process: ${shell}`);
|
|
144
|
+
// Validate it looks like a real shell (single token, no spaces)
|
|
145
|
+
// When run via npx, comm can be "npm exec ..." which is not a shell
|
|
146
|
+
if (!shell.includes(' ') && !shell.startsWith('npm') && !shell.startsWith('node')) {
|
|
147
|
+
log.debug(`Using detected shell: ${shell}`);
|
|
148
|
+
return shell;
|
|
149
|
+
}
|
|
150
|
+
log.debug(`Parent process "${shell}" is not a shell, falling back`);
|
|
142
151
|
}
|
|
143
152
|
} catch (err) {
|
|
144
153
|
log.debug(`Could not detect parent shell: ${err.message}`);
|
|
@@ -157,10 +166,16 @@ function parseArgs() {
|
|
|
157
166
|
// Resolve log level early (env + args) so shell detection logs are visible
|
|
158
167
|
let logLevel = process.env.TERMBEAM_LOG_LEVEL || 'info';
|
|
159
168
|
for (const arg of process.argv.slice(2)) {
|
|
160
|
-
if (arg.startsWith('--log-level=')) {
|
|
169
|
+
if (arg.startsWith('--log-level=')) {
|
|
170
|
+
logLevel = arg.split('=')[1];
|
|
171
|
+
break;
|
|
172
|
+
}
|
|
161
173
|
}
|
|
162
174
|
for (let i = 2; i < process.argv.length; i++) {
|
|
163
|
-
if (process.argv[i] === '--log-level' && process.argv[i + 1]) {
|
|
175
|
+
if (process.argv[i] === '--log-level' && process.argv[i + 1]) {
|
|
176
|
+
logLevel = process.argv[i + 1];
|
|
177
|
+
break;
|
|
178
|
+
}
|
|
164
179
|
}
|
|
165
180
|
log.setLevel(logLevel);
|
|
166
181
|
|
|
@@ -227,7 +242,19 @@ function parseArgs() {
|
|
|
227
242
|
const { getVersion } = require('./version');
|
|
228
243
|
const version = getVersion();
|
|
229
244
|
|
|
230
|
-
return {
|
|
245
|
+
return {
|
|
246
|
+
port,
|
|
247
|
+
host,
|
|
248
|
+
password,
|
|
249
|
+
useTunnel,
|
|
250
|
+
persistedTunnel,
|
|
251
|
+
shell,
|
|
252
|
+
shellArgs,
|
|
253
|
+
cwd,
|
|
254
|
+
defaultShell,
|
|
255
|
+
version,
|
|
256
|
+
logLevel,
|
|
257
|
+
};
|
|
231
258
|
}
|
|
232
259
|
|
|
233
260
|
module.exports = { parseArgs, printHelp };
|
package/src/server.js
CHANGED
|
@@ -47,7 +47,10 @@ function createTermBeamServer(overrides = {}) {
|
|
|
47
47
|
res.setHeader('X-Frame-Options', 'DENY');
|
|
48
48
|
res.setHeader('Referrer-Policy', 'no-referrer');
|
|
49
49
|
res.setHeader('Cache-Control', 'no-store');
|
|
50
|
-
res.setHeader(
|
|
50
|
+
res.setHeader(
|
|
51
|
+
'Content-Security-Policy',
|
|
52
|
+
"default-src 'self'; script-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net; style-src 'self' 'unsafe-inline' https://cdn.jsdelivr.net; connect-src 'self' ws: wss:; font-src 'self' https://cdn.jsdelivr.net",
|
|
53
|
+
);
|
|
51
54
|
next();
|
|
52
55
|
});
|
|
53
56
|
|
|
@@ -106,7 +109,8 @@ function createTermBeamServer(overrides = {}) {
|
|
|
106
109
|
console.log('');
|
|
107
110
|
console.log(` Beam your terminal to any device 📡 v${config.version}`);
|
|
108
111
|
console.log('');
|
|
109
|
-
const isLanReachable =
|
|
112
|
+
const isLanReachable =
|
|
113
|
+
config.host === '0.0.0.0' || config.host === '::' || config.host === ip;
|
|
110
114
|
const gn = '\x1b[38;5;114m'; // green
|
|
111
115
|
const dm = '\x1b[2m'; // dim
|
|
112
116
|
|
|
@@ -159,7 +163,8 @@ function createTermBeamServer(overrides = {}) {
|
|
|
159
163
|
module.exports = { createTermBeamServer };
|
|
160
164
|
|
|
161
165
|
// Auto-start when run directly (CLI entry point)
|
|
162
|
-
|
|
166
|
+
const _entryBase = path.basename(process.argv[1] || '');
|
|
167
|
+
if (require.main === module || _entryBase === 'termbeam' || _entryBase === 'termbeam.js') {
|
|
163
168
|
const instance = createTermBeamServer();
|
|
164
169
|
|
|
165
170
|
process.on('SIGINT', () => {
|