@lethevimlet/sshift 1.1.0 → 1.1.1
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 +29 -0
- package/package.json +25 -23
- package/src/server/endpoints/rest/system.js +81 -7
package/README.md
CHANGED
|
@@ -6,6 +6,7 @@
|
|
|
6
6
|
[](https://www.npmjs.com/package/@lethevimlet/sshift)
|
|
7
7
|
[](https://github.com/lethevimlet/sshift/pkgs/container/sshift)
|
|
8
8
|
[](https://opensource.org/licenses/MIT)
|
|
9
|
+
[](https://socket.dev/npm/package/@lethevimlet/sshift)
|
|
9
10
|
|
|
10
11
|
A modern, responsive web-based SSH and SFTP terminal client built with Node.js, Express, and xterm.js. Designed for the AI coding workflow — featuring tab flash notifications that alert you when AI tools like OpenCode or Claude are waiting for your input, so you never miss a prompt while multitasking. Also features excellent TUI support, tabbed sessions, bookmarks, and mobile-friendly design.
|
|
11
12
|
|
|
@@ -124,6 +125,34 @@ npm install
|
|
|
124
125
|
npm start
|
|
125
126
|
```
|
|
126
127
|
|
|
128
|
+
## 🖥️ CLI Reference
|
|
129
|
+
|
|
130
|
+
```
|
|
131
|
+
sshift Start server on default port (8022)
|
|
132
|
+
sshift --dev Start in development mode (port 3000, separate PID)
|
|
133
|
+
sshift --port 8080 Start server on custom port
|
|
134
|
+
sshift --bind 127.0.0.1 Bind to specific address
|
|
135
|
+
sshift --status Check if sshift is running
|
|
136
|
+
sshift --stop Stop running instance
|
|
137
|
+
sshift --restart Restart running instance
|
|
138
|
+
sshift --dev --status Check if dev instance is running
|
|
139
|
+
sshift --dev --stop Stop dev instance
|
|
140
|
+
sshift --dev --restart Restart dev instance
|
|
141
|
+
sshift --help Show help message
|
|
142
|
+
```
|
|
143
|
+
|
|
144
|
+
| Flag | Shorthand | Description |
|
|
145
|
+
|------|-----------|-------------|
|
|
146
|
+
| `--port <port>` | `-p` | Server port (default: 8022, dev: 3000) |
|
|
147
|
+
| `--bind <addr>` | `-b` | Bind address (default: 0.0.0.0) |
|
|
148
|
+
| `--dev` | `-d` | Development mode — uses `devPort` from config (default 3000) and a separate PID file so dev and production instances can run side-by-side |
|
|
149
|
+
| `--stop` | `-s` | Stop running instance |
|
|
150
|
+
| `--restart` | `-r` | Restart running instance |
|
|
151
|
+
| `--status` | | Check running status |
|
|
152
|
+
| `--help` | `-h` | Show help message |
|
|
153
|
+
|
|
154
|
+
> **Note:** `--dev` sets `NODE_ENV=development`, which switches the default port from 8022 to 3000 (or `devPort` from `config.json`). It also uses a separate PID file (`.sshift-dev.pid`) so you can run a dev instance alongside production and use `--dev --status`/`--dev --stop`/`--dev --restart` to manage it independently.
|
|
155
|
+
|
|
127
156
|
## ⚙️ Configuration
|
|
128
157
|
|
|
129
158
|
SSHIFT uses a priority-based configuration system. Config files are searched in order; the first match wins.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lethevimlet/sshift",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.1",
|
|
4
4
|
"description": "Web-based SSH + SFTP terminal client with tabs and bookmarks",
|
|
5
5
|
"main": "src/server/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -16,25 +16,26 @@
|
|
|
16
16
|
"test:integration": "jest --testPathPatterns='src/tests/integration' --forceExit",
|
|
17
17
|
"test:e2e": "jest --testPathPatterns='src/tests/e2e' --forceExit --runInBand",
|
|
18
18
|
"test:browser": "jest --testPathPatterns='src/tests/browser' --forceExit --runInBand",
|
|
19
|
-
"prepublishOnly": "echo 'Publishing to npm...'"
|
|
19
|
+
"prepublishOnly": "echo 'Publishing to npm...'",
|
|
20
|
+
"install:safe": "sfw pnpm install"
|
|
20
21
|
},
|
|
21
22
|
"dependencies": {
|
|
22
|
-
"@xterm/addon-fit": "
|
|
23
|
-
"@xterm/addon-image": "
|
|
24
|
-
"@xterm/addon-search": "
|
|
25
|
-
"@xterm/addon-serialize": "
|
|
26
|
-
"@xterm/addon-web-links": "
|
|
27
|
-
"@xterm/addon-webgl": "
|
|
28
|
-
"@xterm/headless": "
|
|
29
|
-
"@xterm/xterm": "
|
|
30
|
-
"dotenv": "
|
|
31
|
-
"express": "
|
|
32
|
-
"httpolyglot": "
|
|
33
|
-
"lucide": "
|
|
34
|
-
"selfsigned": "
|
|
35
|
-
"socket.io": "
|
|
36
|
-
"ssh2": "
|
|
37
|
-
"uuid": "
|
|
23
|
+
"@xterm/addon-fit": "0.11.0",
|
|
24
|
+
"@xterm/addon-image": "0.9.0",
|
|
25
|
+
"@xterm/addon-search": "0.16.0",
|
|
26
|
+
"@xterm/addon-serialize": "0.14.0",
|
|
27
|
+
"@xterm/addon-web-links": "0.12.0",
|
|
28
|
+
"@xterm/addon-webgl": "0.19.0",
|
|
29
|
+
"@xterm/headless": "6.0.0",
|
|
30
|
+
"@xterm/xterm": "6.0.0",
|
|
31
|
+
"dotenv": "17.4.0",
|
|
32
|
+
"express": "4.18.2",
|
|
33
|
+
"httpolyglot": "0.1.2",
|
|
34
|
+
"lucide": "1.7.0",
|
|
35
|
+
"selfsigned": "5.5.0",
|
|
36
|
+
"socket.io": "4.7.2",
|
|
37
|
+
"ssh2": "1.15.0",
|
|
38
|
+
"uuid": "9.0.0"
|
|
38
39
|
},
|
|
39
40
|
"keywords": [
|
|
40
41
|
"ssh",
|
|
@@ -60,6 +61,7 @@
|
|
|
60
61
|
"engines": {
|
|
61
62
|
"node": ">=20.0.0"
|
|
62
63
|
},
|
|
64
|
+
"packageManager": "pnpm@10.33.4",
|
|
63
65
|
"publishConfig": {
|
|
64
66
|
"access": "public",
|
|
65
67
|
"provenance": true
|
|
@@ -76,10 +78,10 @@
|
|
|
76
78
|
"LICENSE"
|
|
77
79
|
],
|
|
78
80
|
"devDependencies": {
|
|
79
|
-
"@types/jest": "
|
|
80
|
-
"jest": "
|
|
81
|
-
"puppeteer": "
|
|
82
|
-
"socket.io-client": "
|
|
83
|
-
"ts-jest": "
|
|
81
|
+
"@types/jest": "30.0.0",
|
|
82
|
+
"jest": "30.3.0",
|
|
83
|
+
"puppeteer": "24.40.0",
|
|
84
|
+
"socket.io-client": "4.8.3",
|
|
85
|
+
"ts-jest": "29.4.9"
|
|
84
86
|
}
|
|
85
87
|
}
|
|
@@ -241,10 +241,79 @@ function registerSystemEndpoints(app, io) {
|
|
|
241
241
|
// API: Trigger update
|
|
242
242
|
app.post('/api/update', async (req, res) => {
|
|
243
243
|
try {
|
|
244
|
+
const isLocalhost = req.hostname === 'localhost' || req.hostname === '127.0.0.1' || req.hostname === '::1';
|
|
245
|
+
if (!isLocalhost && !req.headers.authorization && !req.query.token) {
|
|
246
|
+
return res.status(403).json({ error: 'Remote update requires authentication. Set a password or use localhost.' });
|
|
247
|
+
}
|
|
248
|
+
|
|
244
249
|
const { spawn, execSync } = require('child_process');
|
|
245
250
|
const platform = process.platform;
|
|
246
251
|
const dataDir = getDataDir();
|
|
247
252
|
|
|
253
|
+
// Resolve the target version by checking GitHub for the latest release
|
|
254
|
+
// This pins the exact version instead of using @latest, preventing
|
|
255
|
+
// supply chain attacks where a compromised registry could serve a
|
|
256
|
+
// different package than what was published.
|
|
257
|
+
let targetVersion = 'latest';
|
|
258
|
+
const currentPkg = require('../../../../package.json');
|
|
259
|
+
try {
|
|
260
|
+
const https = require('https');
|
|
261
|
+
const githubVersion = await new Promise((resolve, reject) => {
|
|
262
|
+
const opts = {
|
|
263
|
+
hostname: 'api.github.com',
|
|
264
|
+
path: '/repos/lethevimlet/sshift/contents/package.json',
|
|
265
|
+
method: 'GET',
|
|
266
|
+
headers: { 'User-Agent': 'sshift-update-checker', 'Accept': 'application/vnd.github.v3+json' }
|
|
267
|
+
};
|
|
268
|
+
const ghReq = https.request(opts, (ghRes) => {
|
|
269
|
+
let body = '';
|
|
270
|
+
ghRes.on('data', (chunk) => { body += chunk; });
|
|
271
|
+
ghRes.on('end', () => {
|
|
272
|
+
try {
|
|
273
|
+
if (ghRes.statusCode !== 200) return reject(new Error('GitHub API returned ' + ghRes.statusCode));
|
|
274
|
+
const parsed = JSON.parse(body);
|
|
275
|
+
const content = Buffer.from(parsed.content, 'base64').toString('utf8');
|
|
276
|
+
resolve(JSON.parse(content).version);
|
|
277
|
+
} catch (e) { reject(e); }
|
|
278
|
+
});
|
|
279
|
+
});
|
|
280
|
+
ghReq.on('error', reject);
|
|
281
|
+
ghReq.setTimeout(10000, () => { ghReq.destroy(); reject(new Error('GitHub request timed out')); });
|
|
282
|
+
ghReq.end();
|
|
283
|
+
});
|
|
284
|
+
if (githubVersion && /^\d+\.\d+\.\d+$/.test(githubVersion)) {
|
|
285
|
+
// Verify the version actually exists on the npm registry before pinning.
|
|
286
|
+
// GitHub may show a version before npm propagation completes, which would
|
|
287
|
+
// cause all install retries to fail against a non-existent version.
|
|
288
|
+
const npmAvailable = await new Promise((resolve) => {
|
|
289
|
+
const npmReq = https.request({
|
|
290
|
+
hostname: 'registry.npmjs.org',
|
|
291
|
+
path: '/@lethevimlet/sshift/' + githubVersion,
|
|
292
|
+
method: 'GET',
|
|
293
|
+
headers: { 'User-Agent': 'sshift-update-checker' }
|
|
294
|
+
}, (npmRes) => {
|
|
295
|
+
resolve(npmRes.statusCode === 200);
|
|
296
|
+
});
|
|
297
|
+
npmReq.on('error', () => resolve(false));
|
|
298
|
+
npmReq.setTimeout(10000, () => { npmReq.destroy(); resolve(false); });
|
|
299
|
+
npmReq.end();
|
|
300
|
+
});
|
|
301
|
+
if (npmAvailable) {
|
|
302
|
+
targetVersion = githubVersion;
|
|
303
|
+
console.log('[UPDATE] Pinned target version:', targetVersion);
|
|
304
|
+
} else {
|
|
305
|
+
console.warn('[UPDATE] Version', githubVersion, 'found on GitHub but not yet on npm, deferring update');
|
|
306
|
+
return res.status(503).json({
|
|
307
|
+
error: 'Update available but not yet on npm. Try again in a few minutes.',
|
|
308
|
+
localVersion: currentPkg.version,
|
|
309
|
+
remoteVersion: githubVersion
|
|
310
|
+
});
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
} catch (e) {
|
|
314
|
+
console.warn('[UPDATE] Could not resolve version from GitHub, falling back to @latest:', e.message);
|
|
315
|
+
}
|
|
316
|
+
|
|
248
317
|
// Write update marker to indicate update in progress
|
|
249
318
|
const updateMarker = path.join(dataDir, UPDATE_MARKER_FILE);
|
|
250
319
|
let oldVersion = 'unknown';
|
|
@@ -254,7 +323,8 @@ function registerSystemEndpoints(app, io) {
|
|
|
254
323
|
fs.mkdirSync(dataDir, { recursive: true });
|
|
255
324
|
fs.writeFileSync(updateMarker, JSON.stringify({
|
|
256
325
|
startTime: Date.now(),
|
|
257
|
-
oldVersion: pkg.version
|
|
326
|
+
oldVersion: pkg.version,
|
|
327
|
+
targetVersion
|
|
258
328
|
}));
|
|
259
329
|
} catch (e) {
|
|
260
330
|
console.error('[UPDATE] Failed to write update marker:', e.message);
|
|
@@ -383,12 +453,14 @@ function registerSystemEndpoints(app, io) {
|
|
|
383
453
|
res.json({ message: 'Update started. Server will restart automatically.' });
|
|
384
454
|
|
|
385
455
|
if (platform === 'win32') {
|
|
456
|
+
const psTargetSpec = targetVersion !== 'latest' ? `@${targetVersion}` : '@latest';
|
|
386
457
|
const sshiftCmd = sshiftBinPath.includes(' ') ? `& '${sshiftBinPath}'` : `sshift`;
|
|
387
458
|
const psScript = `$ErrorActionPreference = 'Continue'
|
|
388
459
|
$MarkerPath = '${updateMarker}'
|
|
389
460
|
$LogPath = '${updateLogPath}'
|
|
390
461
|
$NodeExe = '${nodeExe}'
|
|
391
462
|
$SshiftBin = '${sshiftBinPath}'
|
|
463
|
+
$TargetSpec = '${psTargetSpec}'
|
|
392
464
|
|
|
393
465
|
# Check if running under Task Scheduler
|
|
394
466
|
$TaskName = "sshift"
|
|
@@ -410,8 +482,8 @@ try {
|
|
|
410
482
|
$NpmSuccess = $false
|
|
411
483
|
while ($NpmAttempts -lt $NpmMaxAttempts) {
|
|
412
484
|
$NpmAttempts++
|
|
413
|
-
Write-Output "$(Get-Date): npm install attempt $NpmAttempts of $NpmMaxAttempts" | Out-File -FilePath $LogPath -Append
|
|
414
|
-
& npm install -g @lethevimlet/sshift
|
|
485
|
+
Write-Output "$(Get-Date): npm install attempt $NpmAttempts of $NpmMaxAttempts (target: @lethevimlet/sshift$TargetSpec)" | Out-File -FilePath $LogPath -Append
|
|
486
|
+
& npm install -g "@lethevimlet/sshift$TargetSpec" 2>&1 | Out-File -FilePath $LogPath -Append
|
|
415
487
|
if ($LASTEXITCODE -eq 0) {
|
|
416
488
|
$NpmSuccess = $true
|
|
417
489
|
break
|
|
@@ -462,11 +534,13 @@ NPM_BIN="${npmBinPath}"
|
|
|
462
534
|
SSHIFT_FALLBACK="${sshiftBinPath}"
|
|
463
535
|
NODE_BIN="${nodeExe}"
|
|
464
536
|
OLD_VERSION="${oldVersion}"
|
|
537
|
+
TARGET_VERSION="${targetVersion}"
|
|
465
538
|
SERVICE_MANAGED="${isServiceManaged ? '1' : '0'}"
|
|
466
539
|
SERVICE_MANAGER="${serviceManager}"
|
|
467
540
|
SERVICE_UNIT="${serviceUnit}"
|
|
468
541
|
|
|
469
|
-
|
|
542
|
+
INSTALL_SPEC="@lethevimlet/sshift@${targetVersion}"
|
|
543
|
+
echo "$(date): Starting sshift update (from v${oldVersion} to ${targetVersion})..." > "$LOG"
|
|
470
544
|
echo "$(date): npm path: $NPM_BIN" >> "$LOG"
|
|
471
545
|
echo "$(date): node path: $NODE_BIN" >> "$LOG"
|
|
472
546
|
echo "$(date): sshift fallback: $SSHIFT_FALLBACK" >> "$LOG"
|
|
@@ -476,7 +550,7 @@ echo "$(date): service_managed: $SERVICE_MANAGED manager: $SERVICE_MANAGER unit:
|
|
|
476
550
|
CURRENT_SSHIFT="$(command -v sshift 2>/dev/null || which sshift 2>/dev/null || echo "$SSHIFT_FALLBACK")"
|
|
477
551
|
|
|
478
552
|
# Run npm install (with retry for registry propagation delay)
|
|
479
|
-
echo "$(date): Running npm install..." >> "$LOG"
|
|
553
|
+
echo "$(date): Running npm install $INSTALL_SPEC ..." >> "$LOG"
|
|
480
554
|
NPM_ATTEMPTS=0
|
|
481
555
|
NPM_MAX_ATTEMPTS=3
|
|
482
556
|
NPM_DELAY=30
|
|
@@ -484,7 +558,7 @@ NPM_SUCCESS=false
|
|
|
484
558
|
while [ $NPM_ATTEMPTS -lt $NPM_MAX_ATTEMPTS ]; do
|
|
485
559
|
NPM_ATTEMPTS=$((NPM_ATTEMPTS + 1))
|
|
486
560
|
echo "$(date): npm install attempt $NPM_ATTEMPTS of $NPM_MAX_ATTEMPTS" >> "$LOG"
|
|
487
|
-
if "$NPM_BIN" install -g
|
|
561
|
+
if "$NPM_BIN" install -g "$INSTALL_SPEC" >> "$LOG" 2>&1; then
|
|
488
562
|
NPM_SUCCESS=true
|
|
489
563
|
break
|
|
490
564
|
fi
|
|
@@ -552,7 +626,7 @@ fi
|
|
|
552
626
|
let spawnCommand, spawnArgs;
|
|
553
627
|
if (platform === 'win32') {
|
|
554
628
|
spawnCommand = 'powershell';
|
|
555
|
-
spawnArgs = ['-ExecutionPolicy', '
|
|
629
|
+
spawnArgs = ['-ExecutionPolicy', 'RemoteSigned', '-File', updateScriptPath.replace('.sh', '.ps1')];
|
|
556
630
|
} else {
|
|
557
631
|
spawnCommand = '/bin/sh';
|
|
558
632
|
spawnArgs = [updateScriptPath];
|