shell-mirror 1.5.20 → 1.5.23
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/lib/auto-start.js +2 -2
- package/package.json +1 -1
- package/public/app/terminal-http.html +92 -0
- package/public/app/terminal.js +31 -1
package/lib/auto-start.js
CHANGED
|
@@ -39,8 +39,8 @@ class AutoStart {
|
|
|
39
39
|
return;
|
|
40
40
|
}
|
|
41
41
|
|
|
42
|
-
// Start the server
|
|
43
|
-
await this.
|
|
42
|
+
// Start the server with WebSocket integration
|
|
43
|
+
await this.startAuthenticatedServer(authInfo);
|
|
44
44
|
|
|
45
45
|
} catch (error) {
|
|
46
46
|
console.error('❌ Failed to start Shell Mirror:', error.message);
|
package/package.json
CHANGED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
<!DOCTYPE html>
|
|
2
|
+
<html>
|
|
3
|
+
<head>
|
|
4
|
+
<title>Terminal Mirror (HTTP)</title>
|
|
5
|
+
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/xterm@4.15.0/css/xterm.css" />
|
|
6
|
+
<script src="https://cdn.jsdelivr.net/npm/xterm@4.15.0/lib/xterm.js"></script>
|
|
7
|
+
<script src="https://cdn.jsdelivr.net/npm/xterm-addon-fit@0.5.0/lib/xterm-addon-fit.js"></script>
|
|
8
|
+
<style>
|
|
9
|
+
body, html {
|
|
10
|
+
margin: 0;
|
|
11
|
+
padding: 0;
|
|
12
|
+
height: 100%;
|
|
13
|
+
overflow: hidden;
|
|
14
|
+
background-color: #1e1e1e;
|
|
15
|
+
color: #ccc;
|
|
16
|
+
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
|
|
17
|
+
}
|
|
18
|
+
#terminal-container {
|
|
19
|
+
display: none;
|
|
20
|
+
height: 100%;
|
|
21
|
+
width: 100%;
|
|
22
|
+
background-color: #000000;
|
|
23
|
+
}
|
|
24
|
+
#terminal {
|
|
25
|
+
padding: 8px; /* Mac Terminal.app padding */
|
|
26
|
+
background-color: #000000;
|
|
27
|
+
height: calc(100% - 16px);
|
|
28
|
+
width: calc(100% - 16px);
|
|
29
|
+
}
|
|
30
|
+
#connect-container {
|
|
31
|
+
padding: 2em;
|
|
32
|
+
text-align: center;
|
|
33
|
+
background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
|
|
34
|
+
color: white;
|
|
35
|
+
min-height: 100vh;
|
|
36
|
+
}
|
|
37
|
+
#connect-container h2 {
|
|
38
|
+
margin-bottom: 2em;
|
|
39
|
+
font-size: 2.5rem;
|
|
40
|
+
}
|
|
41
|
+
.http-notice {
|
|
42
|
+
background: rgba(255, 255, 255, 0.1);
|
|
43
|
+
border: 1px solid rgba(255, 255, 255, 0.3);
|
|
44
|
+
border-radius: 10px;
|
|
45
|
+
padding: 20px;
|
|
46
|
+
margin: 20px auto;
|
|
47
|
+
max-width: 600px;
|
|
48
|
+
}
|
|
49
|
+
.http-notice h3 {
|
|
50
|
+
color: #4CAF50;
|
|
51
|
+
margin-bottom: 10px;
|
|
52
|
+
}
|
|
53
|
+
#agent-id-input { font-size: 1.2em; padding: 8px; width: 400px; margin-bottom: 1em; }
|
|
54
|
+
#connect-btn { font-size: 1.2em; padding: 10px 20px; }
|
|
55
|
+
</style>
|
|
56
|
+
</head>
|
|
57
|
+
<body>
|
|
58
|
+
<div id="connect-container">
|
|
59
|
+
<h2>Terminal Mirror</h2>
|
|
60
|
+
|
|
61
|
+
<div class="http-notice">
|
|
62
|
+
<h3>🌐 HTTP Terminal Mode</h3>
|
|
63
|
+
<p>This HTTP version allows secure connections to your local Mac WebSocket server.</p>
|
|
64
|
+
<p>Perfect for local network terminal access!</p>
|
|
65
|
+
</div>
|
|
66
|
+
|
|
67
|
+
<div id="agent-discovery">
|
|
68
|
+
<p>Discovering available Mac agents...</p>
|
|
69
|
+
<div id="agent-list"></div>
|
|
70
|
+
</div>
|
|
71
|
+
<div id="manual-connect" style="display: none; margin-top: 20px;">
|
|
72
|
+
<p>Or manually enter Agent ID:</p>
|
|
73
|
+
<input type="text" id="agent-id-input" placeholder="e.g., agent-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx">
|
|
74
|
+
<br>
|
|
75
|
+
<button id="connect-btn">Connect</button>
|
|
76
|
+
</div>
|
|
77
|
+
<button id="show-manual" style="margin-top: 10px;">Manual Connect</button>
|
|
78
|
+
</div>
|
|
79
|
+
<div id="terminal-container">
|
|
80
|
+
<div id="terminal"></div>
|
|
81
|
+
</div>
|
|
82
|
+
|
|
83
|
+
<!-- Version Footer -->
|
|
84
|
+
<footer style="background: #ff6b35; color: white; text-align: center; padding: 10px 0; font-size: 0.8rem; position: fixed; bottom: 0; left: 0; right: 0; z-index: 1000;">
|
|
85
|
+
<div style="max-width: 1200px; margin: 0 auto;">
|
|
86
|
+
<p id="terminal-version-info">Terminal Mirror (HTTP) • Loading version...</p>
|
|
87
|
+
</div>
|
|
88
|
+
</footer>
|
|
89
|
+
|
|
90
|
+
<script src="/app/terminal.js"></script>
|
|
91
|
+
</body>
|
|
92
|
+
</html>
|
package/public/app/terminal.js
CHANGED
|
@@ -232,7 +232,37 @@ async function initialize() {
|
|
|
232
232
|
let signalingUrl;
|
|
233
233
|
if (SELECTED_AGENT && SELECTED_AGENT.websocketUrl) {
|
|
234
234
|
signalingUrl = SELECTED_AGENT.websocketUrl;
|
|
235
|
-
console.log('[CLIENT] 🌐
|
|
235
|
+
console.log('[CLIENT] 🌐 Agent WebSocket URL:', signalingUrl);
|
|
236
|
+
|
|
237
|
+
// Check for mixed content issue (HTTPS page + WS:// URL)
|
|
238
|
+
const isHttpsPage = window.location.protocol === 'https:';
|
|
239
|
+
const isInsecureWebSocket = signalingUrl.startsWith('ws://');
|
|
240
|
+
|
|
241
|
+
if (isHttpsPage && isInsecureWebSocket) {
|
|
242
|
+
console.warn('[CLIENT] ⚠️ Mixed content detected: HTTPS page cannot connect to insecure WebSocket');
|
|
243
|
+
console.log('[CLIENT] 💡 Solution: Use HTTP terminal page for local WebSocket connections');
|
|
244
|
+
|
|
245
|
+
// Provide user with HTTP terminal URL
|
|
246
|
+
const httpTerminalUrl = `http://shellmirror.app/app/terminal-http.html`;
|
|
247
|
+
console.log(`[CLIENT] 🔗 Redirect to HTTP terminal: ${httpTerminalUrl}`);
|
|
248
|
+
|
|
249
|
+
// Show user-friendly error message
|
|
250
|
+
term.write('\r\n\x1b[33m⚠️ Mixed Content Security Issue\x1b[0m\r\n');
|
|
251
|
+
term.write('\r\nHTTPS pages cannot connect to local WebSocket servers.\r\n');
|
|
252
|
+
term.write('\r\n\x1b[32mSolution:\x1b[0m\r\n');
|
|
253
|
+
term.write(`1. Open: \x1b[36m${httpTerminalUrl}\x1b[0m\r\n`);
|
|
254
|
+
term.write('2. Click on your agent again\r\n');
|
|
255
|
+
term.write('\r\nThis will allow the local WebSocket connection.\r\n');
|
|
256
|
+
|
|
257
|
+
// Auto-redirect after showing message
|
|
258
|
+
setTimeout(() => {
|
|
259
|
+
window.location.href = httpTerminalUrl;
|
|
260
|
+
}, 5000);
|
|
261
|
+
|
|
262
|
+
return; // Don't attempt WebSocket connection
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
console.log('[CLIENT] ✅ Using agent\'s local WebSocket server:', signalingUrl);
|
|
236
266
|
} else {
|
|
237
267
|
// Fallback to web app domain (old behavior)
|
|
238
268
|
signalingUrl = (window.location.protocol === 'https:' ? 'wss://' : 'ws://') + window.location.host;
|