@lethevimlet/sshift 0.9.6 → 0.9.8
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 +3 -1
- package/plugins/opencode-attention/index.js +66 -21
- package/src/server/index.js +1 -1
- package/src/server/utils/config.js +9 -4
- package/src/webapp/index.html +10 -10
- package/src/webapp/js/app.js +13 -6
- package/sshift-install.ps1 +1121 -0
- package/sshift-install.sh +986 -0
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@lethevimlet/sshift",
|
|
3
|
-
"version": "0.9.
|
|
3
|
+
"version": "0.9.8",
|
|
4
4
|
"description": "Web-based SSH + SFTP terminal client with tabs and bookmarks",
|
|
5
5
|
"main": "src/server/index.js",
|
|
6
6
|
"bin": {
|
|
@@ -66,6 +66,8 @@
|
|
|
66
66
|
},
|
|
67
67
|
"files": [
|
|
68
68
|
"sshift",
|
|
69
|
+
"sshift-install.sh",
|
|
70
|
+
"sshift-install.ps1",
|
|
69
71
|
"src/server/",
|
|
70
72
|
"src/webapp/",
|
|
71
73
|
"plugins/",
|
|
@@ -5,12 +5,14 @@
|
|
|
5
5
|
* in an SSH terminal and flashes the tab to alert the user.
|
|
6
6
|
*
|
|
7
7
|
* Detection strategy:
|
|
8
|
-
* - Detects opencode's TUI by looking for "OpenCode" in the terminal state
|
|
8
|
+
* - Detects opencode's TUI by looking for "OpenCode" in the terminal state (sticky: once detected, stays true)
|
|
9
9
|
* - Tracks opencode's processing state via spinner characters (⬝ ■ ▣)
|
|
10
|
-
* -
|
|
11
|
-
*
|
|
12
|
-
* -
|
|
13
|
-
* -
|
|
10
|
+
* - While opencode is working (spinner seen within idleThreshold), ALL flashing is suppressed
|
|
11
|
+
* - When opencode goes idle (no spinner for > idleThreshold ms after working), flashes the tab
|
|
12
|
+
* - Schedules an immediate attention check when spinner stops (no delay waiting for timer)
|
|
13
|
+
* - Detects opencode-specific prompt patterns ("❯", "> ", "(y/n)", etc.)
|
|
14
|
+
* - Prompt detection only activates in confirmed OpenCode sessions (isOpencode gate)
|
|
15
|
+
* - Suppresses re-flash for a cooldown period after spinner stops a flash
|
|
14
16
|
*
|
|
15
17
|
* Configuration (in config.json under plugins[].config):
|
|
16
18
|
* - patterns: string[] - Additional regex patterns to detect attention
|
|
@@ -19,6 +21,7 @@
|
|
|
19
21
|
* - excludePatterns: string[] - Regex patterns to exclude from detection
|
|
20
22
|
* - checkInterval: number - Milliseconds between periodic terminal state checks (default: 2000)
|
|
21
23
|
* - idleThreshold: number - Milliseconds without spinner before considered idle (default: 3000)
|
|
24
|
+
* - cooldownMs: number - Milliseconds to suppress re-flash after spinner stops a flash (default: 1000)
|
|
22
25
|
*/
|
|
23
26
|
|
|
24
27
|
class OpenCodeAttentionPlugin {
|
|
@@ -29,6 +32,7 @@ class OpenCodeAttentionPlugin {
|
|
|
29
32
|
flashDuration: config.flashDuration || 0,
|
|
30
33
|
checkInterval: config.checkInterval || 2000,
|
|
31
34
|
idleThreshold: config.idleThreshold || 3000,
|
|
35
|
+
cooldownMs: config.cooldownMs || 1000,
|
|
32
36
|
...config,
|
|
33
37
|
};
|
|
34
38
|
|
|
@@ -46,17 +50,23 @@ class OpenCodeAttentionPlugin {
|
|
|
46
50
|
isOpencode: false,
|
|
47
51
|
lastSpinnerTime: 0,
|
|
48
52
|
wasWorking: false,
|
|
53
|
+
cooldownUntil: 0,
|
|
54
|
+
idleCheckScheduled: false,
|
|
49
55
|
});
|
|
50
56
|
}
|
|
51
57
|
return this._sessionState.get(sessionId);
|
|
52
58
|
}
|
|
53
59
|
|
|
60
|
+
_isWorking(sessionId) {
|
|
61
|
+
const s = this._getSessionState(sessionId);
|
|
62
|
+
return s.wasWorking && (Date.now() - s.lastSpinnerTime) < this.config.idleThreshold;
|
|
63
|
+
}
|
|
64
|
+
|
|
54
65
|
_buildPatterns(extraPatterns, excludePatterns) {
|
|
55
66
|
const defaultPatterns = [
|
|
56
67
|
/\> $/,
|
|
57
68
|
/\> \x1b/,
|
|
58
|
-
/❯
|
|
59
|
-
/❯ \x1b/,
|
|
69
|
+
/❯ /,
|
|
60
70
|
/waiting for input/i,
|
|
61
71
|
/press enter/i,
|
|
62
72
|
/press any key/i,
|
|
@@ -107,6 +117,9 @@ class OpenCodeAttentionPlugin {
|
|
|
107
117
|
}
|
|
108
118
|
|
|
109
119
|
_startFlash(sessionId) {
|
|
120
|
+
const sessionState = this._getSessionState(sessionId);
|
|
121
|
+
if (Date.now() < sessionState.cooldownUntil) return;
|
|
122
|
+
if (this._isWorking(sessionId)) return;
|
|
110
123
|
if (this._flashing.get(sessionId)) return;
|
|
111
124
|
this._flashing.set(sessionId, true);
|
|
112
125
|
this.ctx.flashTab(sessionId, { duration: this.config.flashDuration || 0 });
|
|
@@ -129,12 +142,33 @@ class OpenCodeAttentionPlugin {
|
|
|
129
142
|
this._dataTimers.set(sessionId, timer);
|
|
130
143
|
}
|
|
131
144
|
|
|
145
|
+
_scheduleIdleCheck(sessionId) {
|
|
146
|
+
const sessionState = this._getSessionState(sessionId);
|
|
147
|
+
if (sessionState.idleCheckScheduled) return;
|
|
148
|
+
sessionState.idleCheckScheduled = true;
|
|
149
|
+
|
|
150
|
+
const delay = this.config.idleThreshold + 200;
|
|
151
|
+
|
|
152
|
+
setTimeout(() => {
|
|
153
|
+
sessionState.idleCheckScheduled = false;
|
|
154
|
+
if (!sessionState.wasWorking) return;
|
|
155
|
+
if (this._isWorking(sessionId)) return;
|
|
156
|
+
this._checkAttention(sessionId);
|
|
157
|
+
}, delay);
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
_isSpinnerChar(text) {
|
|
161
|
+
return /[⬝■▣]/.test(text);
|
|
162
|
+
}
|
|
163
|
+
|
|
132
164
|
_checkAttention(sessionId) {
|
|
165
|
+
if (this._isWorking(sessionId)) return;
|
|
166
|
+
|
|
133
167
|
const state = this.ctx.getTerminalState(sessionId);
|
|
134
168
|
if (!state || !state.state) return;
|
|
135
169
|
|
|
136
170
|
const lines = state.state.split('\n');
|
|
137
|
-
const recentLines = lines.slice(-
|
|
171
|
+
const recentLines = lines.slice(-30);
|
|
138
172
|
|
|
139
173
|
let isOpencode = false;
|
|
140
174
|
let matchedPrompt = false;
|
|
@@ -149,25 +183,27 @@ class OpenCodeAttentionPlugin {
|
|
|
149
183
|
|
|
150
184
|
if (this._matchesPattern(stripped) || this._matchesPattern(line)) {
|
|
151
185
|
matchedPrompt = true;
|
|
152
|
-
break;
|
|
153
186
|
}
|
|
154
187
|
}
|
|
155
188
|
|
|
156
189
|
const sessionState = this._getSessionState(sessionId);
|
|
157
|
-
|
|
190
|
+
if (isOpencode) {
|
|
191
|
+
sessionState.isOpencode = true;
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
if (!sessionState.isOpencode) return;
|
|
158
195
|
|
|
159
196
|
if (matchedPrompt) {
|
|
160
197
|
this._startFlash(sessionId);
|
|
198
|
+
return;
|
|
161
199
|
}
|
|
162
200
|
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
const timeSinceSpinner = now - sessionState.lastSpinnerTime;
|
|
201
|
+
const now = Date.now();
|
|
202
|
+
const timeSinceSpinner = now - sessionState.lastSpinnerTime;
|
|
166
203
|
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
}
|
|
204
|
+
if (sessionState.wasWorking && timeSinceSpinner > this.config.idleThreshold) {
|
|
205
|
+
this._startFlash(sessionId);
|
|
206
|
+
sessionState.wasWorking = false;
|
|
171
207
|
}
|
|
172
208
|
}
|
|
173
209
|
|
|
@@ -175,19 +211,25 @@ class OpenCodeAttentionPlugin {
|
|
|
175
211
|
const stripped = this._stripAnsi(data);
|
|
176
212
|
const sessionState = this._getSessionState(sessionId);
|
|
177
213
|
|
|
178
|
-
|
|
214
|
+
if (/OpenCode/i.test(stripped) || /OpenCode/i.test(data)) {
|
|
215
|
+
sessionState.isOpencode = true;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
const isSpinner = this._isSpinnerChar(stripped) || this._isSpinnerChar(data);
|
|
179
219
|
|
|
180
220
|
if (isSpinner) {
|
|
181
221
|
sessionState.lastSpinnerTime = Date.now();
|
|
182
222
|
sessionState.wasWorking = true;
|
|
223
|
+
this._scheduleIdleCheck(sessionId);
|
|
183
224
|
if (this._flashing.get(sessionId)) {
|
|
184
225
|
this._stopFlash(sessionId);
|
|
226
|
+
sessionState.cooldownUntil = Date.now() + this.config.cooldownMs;
|
|
185
227
|
}
|
|
228
|
+
return;
|
|
186
229
|
}
|
|
187
230
|
|
|
188
|
-
if (
|
|
189
|
-
|
|
190
|
-
}
|
|
231
|
+
if (!sessionState.isOpencode) return;
|
|
232
|
+
if (this._isWorking(sessionId)) return;
|
|
191
233
|
|
|
192
234
|
if (this._matchesPattern(stripped) || this._matchesPattern(data)) {
|
|
193
235
|
this._startFlash(sessionId);
|
|
@@ -203,6 +245,9 @@ class OpenCodeAttentionPlugin {
|
|
|
203
245
|
sessionState.isOpencode = true;
|
|
204
246
|
}
|
|
205
247
|
|
|
248
|
+
if (!sessionState.isOpencode) return;
|
|
249
|
+
if (this._isWorking(sessionId)) return;
|
|
250
|
+
|
|
206
251
|
if (this._matchesPattern(strippedLine) || this._matchesPattern(rawLine)) {
|
|
207
252
|
this._startFlash(sessionId);
|
|
208
253
|
}
|
package/src/server/index.js
CHANGED
|
@@ -232,7 +232,7 @@ async function initializeServer() {
|
|
|
232
232
|
|
|
233
233
|
// Auth middleware - block API endpoints when password is set
|
|
234
234
|
const { isValidAuthToken } = require('./endpoints/rest/auth');
|
|
235
|
-
const AUTH_WHITELIST = ['/auth/status', '/auth/login'];
|
|
235
|
+
const AUTH_WHITELIST = ['/auth/status', '/auth/login', '/cert', '/security-info'];
|
|
236
236
|
|
|
237
237
|
app.use('/api', (req, res, next) => {
|
|
238
238
|
if (AUTH_WHITELIST.some(p => req.path === p)) return next();
|
|
@@ -45,7 +45,8 @@ const defaultConfig = {
|
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
47
|
* Ensure a config file exists. If no config is found in any search path,
|
|
48
|
-
* create config.json
|
|
48
|
+
* create config.json at the user install directory (~/.local/share/sshift/.env/config.json)
|
|
49
|
+
* so it survives npm updates (which replace the package directory).
|
|
49
50
|
* This mirrors the installer create_config behavior.
|
|
50
51
|
*/
|
|
51
52
|
function ensureConfig() {
|
|
@@ -55,7 +56,11 @@ function ensureConfig() {
|
|
|
55
56
|
}
|
|
56
57
|
}
|
|
57
58
|
|
|
58
|
-
const
|
|
59
|
+
const configDir = path.join(USER_INSTALL_DIR, '.env');
|
|
60
|
+
if (!fs.existsSync(configDir)) {
|
|
61
|
+
fs.mkdirSync(configDir, { recursive: true });
|
|
62
|
+
}
|
|
63
|
+
const configPath = path.join(configDir, 'config.json');
|
|
59
64
|
const config = { ...defaultConfig };
|
|
60
65
|
|
|
61
66
|
if (process.env.PORT) {
|
|
@@ -85,8 +90,8 @@ function getConfigPath() {
|
|
|
85
90
|
}
|
|
86
91
|
}
|
|
87
92
|
|
|
88
|
-
// Return default path (
|
|
89
|
-
const defaultPath =
|
|
93
|
+
// Return default path (user install directory, survives npm updates)
|
|
94
|
+
const defaultPath = path.join(USER_INSTALL_DIR, '.env', 'config.json');
|
|
90
95
|
console.log('[CONFIG] Using default path:', defaultPath);
|
|
91
96
|
return defaultPath;
|
|
92
97
|
}
|
package/src/webapp/index.html
CHANGED
|
@@ -1001,6 +1001,16 @@
|
|
|
1001
1001
|
</div>
|
|
1002
1002
|
<div class="modal-body">
|
|
1003
1003
|
<div class="setting-group">
|
|
1004
|
+
<div class="setting-item" style="flex-direction: column; align-items: stretch;">
|
|
1005
|
+
<label class="setting-label"><i class="fas fa-info-circle"></i> Instructions</label>
|
|
1006
|
+
<div class="setting-description" style="font-size: 12px; line-height: 1.5;">
|
|
1007
|
+
<strong>Chrome/Edge (Desktop):</strong> Open <a href="chrome://settings/certificates" style="color: var(--accent-primary); word-break: break-all;">chrome://settings/certificates</a> (or <a href="edge://settings/certificates" style="color: var(--accent-primary);">edge://settings/certificates</a>) in the address bar, then import the downloaded .crt file to "Trusted Root Certification Authorities".<br><br>
|
|
1008
|
+
<strong>Chrome (Android):</strong> Settings > Security > Install from SD card > Select the downloaded file.<br><br>
|
|
1009
|
+
<strong>Firefox:</strong> Open <a href="about:preferences#privacy" style="color: var(--accent-primary);">about:preferences#privacy</a> > View Certificates > Import > Trust for identifying websites.<br><br>
|
|
1010
|
+
<strong>macOS/iOS:</strong> Double-click the .crt file > Add to Keychain > Set trust to "Always Trust". On iOS: Settings > General > VPN & Device Management > Install profile, then Settings > General > About > Certificate Trust Settings > Enable full trust.
|
|
1011
|
+
</div>
|
|
1012
|
+
</div>
|
|
1013
|
+
|
|
1004
1014
|
<div id="swStatusContainer" class="setting-item" style="flex-direction: column; align-items: stretch;">
|
|
1005
1015
|
<label class="setting-label"><i class="fas fa-hard-drive"></i> Service Worker</label>
|
|
1006
1016
|
<div class="setting-description" id="swStatusText">
|
|
@@ -1017,16 +1027,6 @@
|
|
|
1017
1027
|
<i class="fas fa-download"></i> Download Certificate
|
|
1018
1028
|
</button>
|
|
1019
1029
|
</div>
|
|
1020
|
-
|
|
1021
|
-
<div class="setting-item" style="flex-direction: column; align-items: stretch;">
|
|
1022
|
-
<label class="setting-label"><i class="fas fa-info-circle"></i> Instructions</label>
|
|
1023
|
-
<div class="setting-description" style="font-size: 12px; line-height: 1.5;">
|
|
1024
|
-
<strong>Chrome/Edge (Desktop):</strong> Open <a href="chrome://settings/certificates" style="color: var(--accent-primary); word-break: break-all;">chrome://settings/certificates</a> (or <a href="edge://settings/certificates" style="color: var(--accent-primary);">edge://settings/certificates</a>) in the address bar, then import the downloaded .crt file to "Trusted Root Certification Authorities".<br><br>
|
|
1025
|
-
<strong>Chrome (Android):</strong> Settings > Security > Install from SD card > Select the downloaded file.<br><br>
|
|
1026
|
-
<strong>Firefox:</strong> Open <a href="about:preferences#privacy" style="color: var(--accent-primary);">about:preferences#privacy</a> > View Certificates > Import > Trust for identifying websites.<br><br>
|
|
1027
|
-
<strong>macOS/iOS:</strong> Double-click the .crt file > Add to Keychain > Set trust to "Always Trust". On iOS: Settings > General > VPN & Device Management > Install profile, then Settings > General > About > Certificate Trust Settings > Enable full trust.
|
|
1028
|
-
</div>
|
|
1029
|
-
</div>
|
|
1030
1030
|
</div>
|
|
1031
1031
|
|
|
1032
1032
|
<div class="setting-item" style="margin-top: 12px;">
|
package/src/webapp/js/app.js
CHANGED
|
@@ -3540,8 +3540,11 @@ const wheelHandler = (e) => {
|
|
|
3540
3540
|
let state = data.state;
|
|
3541
3541
|
if (data.encoded) {
|
|
3542
3542
|
try {
|
|
3543
|
-
// Decode base64 to
|
|
3544
|
-
|
|
3543
|
+
// Decode base64 to UTF-8 string (atob produces Latin-1 binary;
|
|
3544
|
+
// we must re-decode as UTF-8 to preserve multi-byte characters)
|
|
3545
|
+
const binaryString = atob(data.state);
|
|
3546
|
+
const bytes = Uint8Array.from(binaryString, c => c.charCodeAt(0));
|
|
3547
|
+
state = new TextDecoder().decode(bytes);
|
|
3545
3548
|
console.log('[SSHIFT] Decoded base64 state, size:', state.length);
|
|
3546
3549
|
} catch (e) {
|
|
3547
3550
|
console.error('[SSHIFT] Error decoding base64 state:', e);
|
|
@@ -4767,11 +4770,15 @@ const wheelHandler = (e) => {
|
|
|
4767
4770
|
dontShowCheckbox.checked = stored === 'true';
|
|
4768
4771
|
}
|
|
4769
4772
|
|
|
4770
|
-
// Auto-show on startup if not dismissed
|
|
4773
|
+
// Auto-show on startup if not dismissed and cert not already installed
|
|
4771
4774
|
const dontShow = localStorage.getItem('dontShowSecurityInfo');
|
|
4772
|
-
if (dontShow
|
|
4773
|
-
|
|
4774
|
-
|
|
4775
|
+
if (dontShow === 'true') return;
|
|
4776
|
+
|
|
4777
|
+
const isLocalhost = ['localhost', '127.0.0.1', '::1'].includes(window.location.hostname);
|
|
4778
|
+
const swActive = navigator.serviceWorker && navigator.serviceWorker.controller;
|
|
4779
|
+
if (isLocalhost || swActive) return;
|
|
4780
|
+
|
|
4781
|
+
setTimeout(() => this.openSecurityInfoDialog(), 1000);
|
|
4775
4782
|
}
|
|
4776
4783
|
|
|
4777
4784
|
openSecurityInfoDialog() {
|