@lethevimlet/sshift 1.2.1 → 1.3.0
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
CHANGED
|
@@ -60,6 +60,19 @@ function registerSFTPHandlers(socket, io) {
|
|
|
60
60
|
}
|
|
61
61
|
});
|
|
62
62
|
|
|
63
|
+
// SFTP join existing session
|
|
64
|
+
socket.on('sftp-join', (data) => {
|
|
65
|
+
console.log('[SFTP] sftp-join event received for session:', data.sessionId);
|
|
66
|
+
const success = sftpManager.joinSession(socket, data.sessionId);
|
|
67
|
+
if (success) {
|
|
68
|
+
// Add this socket to the tab's active sockets
|
|
69
|
+
addSocketToTab(data.sessionId, socket.id);
|
|
70
|
+
socket.emit('sftp-joined', { sessionId: data.sessionId });
|
|
71
|
+
} else {
|
|
72
|
+
socket.emit('sftp-error', { message: 'Session not found', sessionId: data.sessionId });
|
|
73
|
+
}
|
|
74
|
+
});
|
|
75
|
+
|
|
63
76
|
// SFTP list directory
|
|
64
77
|
socket.on('sftp-list', async (data) => {
|
|
65
78
|
try {
|
|
@@ -400,6 +400,24 @@ class SFTPManager {
|
|
|
400
400
|
getActiveSessions() {
|
|
401
401
|
return this.sessions;
|
|
402
402
|
}
|
|
403
|
+
|
|
404
|
+
// Join an existing SFTP session (for multi-client viewing)
|
|
405
|
+
joinSession(socket, sessionId) {
|
|
406
|
+
const session = this.sessions.get(sessionId);
|
|
407
|
+
if (!session) {
|
|
408
|
+
console.log(`[SFTP] Cannot join session ${sessionId}: session not found`);
|
|
409
|
+
return false;
|
|
410
|
+
}
|
|
411
|
+
|
|
412
|
+
return true;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
// Leave an SFTP session (just removes the socket, doesn't disconnect)
|
|
416
|
+
leaveSession(socket, sessionId) {
|
|
417
|
+
// SFTP sessions don't track per-socket membership like SSH does
|
|
418
|
+
// The session stays alive as long as the SSH connection is active
|
|
419
|
+
console.log(`[SFTP] Socket ${socket.id} left session ${sessionId}`);
|
|
420
|
+
}
|
|
403
421
|
}
|
|
404
422
|
|
|
405
423
|
module.exports = new SFTPManager();
|
package/src/webapp/css/style.css
CHANGED
|
@@ -1222,7 +1222,6 @@ body {
|
|
|
1222
1222
|
.version-info {
|
|
1223
1223
|
font-size: 12px;
|
|
1224
1224
|
color: var(--text-secondary);
|
|
1225
|
-
margin-bottom: 8px;
|
|
1226
1225
|
}
|
|
1227
1226
|
|
|
1228
1227
|
.version-label {
|
|
@@ -1236,10 +1235,10 @@ body {
|
|
|
1236
1235
|
|
|
1237
1236
|
.update-info {
|
|
1238
1237
|
display: flex;
|
|
1238
|
+
flex-direction: column;
|
|
1239
1239
|
align-items: center;
|
|
1240
|
-
gap:
|
|
1241
|
-
|
|
1242
|
-
justify-content: center;
|
|
1240
|
+
gap: 4px;
|
|
1241
|
+
margin-bottom: 4px;
|
|
1243
1242
|
}
|
|
1244
1243
|
|
|
1245
1244
|
.check-updates {
|
|
@@ -1278,7 +1277,6 @@ body {
|
|
|
1278
1277
|
}
|
|
1279
1278
|
|
|
1280
1279
|
.sidebar.collapsed .update-info {
|
|
1281
|
-
flex-direction: column;
|
|
1282
1280
|
gap: 4px;
|
|
1283
1281
|
}
|
|
1284
1282
|
|
package/src/webapp/index.html
CHANGED
|
@@ -263,16 +263,16 @@
|
|
|
263
263
|
<!-- Bookmarks will be populated here -->
|
|
264
264
|
</div>
|
|
265
265
|
<div class="sidebar-footer">
|
|
266
|
-
<div class="version-info">
|
|
267
|
-
<span class="version-label">Version: </span>
|
|
268
|
-
<span class="version-number" id="versionNumber">Loading...</span>
|
|
269
|
-
</div>
|
|
270
266
|
<div class="update-info" id="updateInfo" style="display: none;">
|
|
271
267
|
<span class="check-updates" id="checkUpdates">Check Updates</span>
|
|
272
268
|
<button class="btn btn-sm btn-update" id="updateBtn" style="display: none;">
|
|
273
269
|
<i class="fas fa-download"></i> Update Now!
|
|
274
270
|
</button>
|
|
275
271
|
</div>
|
|
272
|
+
<div class="version-info">
|
|
273
|
+
<span class="version-label">Version: </span>
|
|
274
|
+
<span class="version-number" id="versionNumber">Loading...</span>
|
|
275
|
+
</div>
|
|
276
276
|
</div>
|
|
277
277
|
</aside>
|
|
278
278
|
<div class="sidebar-overlay" id="sidebarOverlay"></div>
|
package/src/webapp/js/app.js
CHANGED
|
@@ -3968,7 +3968,6 @@ const wheelHandler = (e) => {
|
|
|
3968
3968
|
|
|
3969
3969
|
this.socket.on('ssh-error', (data) => {
|
|
3970
3970
|
console.error('[SSHIFT] SSH Error:', data.message, 'sessionId:', data.sessionId);
|
|
3971
|
-
this.showToast(data.message, 'error');
|
|
3972
3971
|
|
|
3973
3972
|
// If session not found and we're restoring, try to reconnect
|
|
3974
3973
|
if (data.sessionId && data.message === 'Session not found') {
|
|
@@ -3976,28 +3975,61 @@ const wheelHandler = (e) => {
|
|
|
3976
3975
|
console.log('[SSHIFT] Session found:', !!session, 'isRestoring:', session?.isRestoring);
|
|
3977
3976
|
|
|
3978
3977
|
if (session && session.isRestoring && session.connectionData) {
|
|
3979
|
-
|
|
3980
|
-
|
|
3981
|
-
|
|
3982
|
-
session.
|
|
3983
|
-
|
|
3984
|
-
|
|
3985
|
-
|
|
3986
|
-
session.
|
|
3987
|
-
session.
|
|
3988
|
-
session.
|
|
3978
|
+
// Only attempt reconnection if we have auth credentials.
|
|
3979
|
+
// When syncing from the server, password/privateKey are stripped,
|
|
3980
|
+
// so reconnecting without them would fail with a misleading auth error.
|
|
3981
|
+
const hasCredentials = session.connectionData.password || session.connectionData.privateKey;
|
|
3982
|
+
if (hasCredentials) {
|
|
3983
|
+
console.log('[SSHIFT] Session not found on server, reconnecting with new connection...');
|
|
3984
|
+
this.showToast('Session expired, reconnecting...', 'warning');
|
|
3985
|
+
session.isRestoring = false;
|
|
3986
|
+
session.connecting = true;
|
|
3987
|
+
session.connected = false;
|
|
3988
|
+
|
|
3989
|
+
// Clear the terminal and show reconnecting message
|
|
3990
|
+
if (session.terminal) {
|
|
3991
|
+
session.terminal.clear();
|
|
3992
|
+
session.terminal.writeln('\x1b[33m⚠ Session expired, reconnecting...\x1b[0m');
|
|
3993
|
+
session.terminal.writeln('');
|
|
3994
|
+
}
|
|
3995
|
+
|
|
3996
|
+
// Emit ssh-connect to create a new connection
|
|
3997
|
+
console.log('[SSHIFT] Emitting ssh-connect for reconnection with sessionId:', data.sessionId);
|
|
3998
|
+
this.socket.emit('ssh-connect', { ...session.connectionData, sessionId: data.sessionId });
|
|
3999
|
+
return; // Don't close the tab
|
|
4000
|
+
} else {
|
|
4001
|
+
// No credentials available - show a user-friendly message
|
|
4002
|
+
console.log('[SSHIFT] Session expired and no credentials available for reconnection');
|
|
4003
|
+
this.showToast('Session expired. Please reconnect manually.', 'warning');
|
|
4004
|
+
if (session.terminal) {
|
|
4005
|
+
session.terminal.writeln('\x1b[33m⚠ Session expired. Please close this tab and reconnect.\x1b[0m');
|
|
4006
|
+
}
|
|
4007
|
+
// Don't close the tab - let the user see the message
|
|
4008
|
+
if (session.terminal) {
|
|
4009
|
+
session.connecting = false;
|
|
4010
|
+
}
|
|
4011
|
+
return;
|
|
3989
4012
|
}
|
|
3990
|
-
|
|
3991
|
-
// Emit ssh-connect to create a new connection
|
|
3992
|
-
console.log('[SSHIFT] Emitting ssh-connect for reconnection with sessionId:', data.sessionId);
|
|
3993
|
-
this.socket.emit('ssh-connect', { ...session.connectionData, sessionId: data.sessionId });
|
|
3994
|
-
return; // Don't close the tab
|
|
3995
4013
|
} else {
|
|
3996
4014
|
console.log('[SSHIFT] Session not eligible for reconnection, closing tab');
|
|
3997
4015
|
}
|
|
3998
4016
|
}
|
|
3999
4017
|
|
|
4000
|
-
|
|
4018
|
+
// Show error toast for genuine errors (not auth failures from stripped credentials)
|
|
4019
|
+
const isStrippedAuthError = data.message && data.message.includes('authentication methods failed');
|
|
4020
|
+
if (isStrippedAuthError) {
|
|
4021
|
+
const session = data.sessionId ? this.sessions.get(data.sessionId) : null;
|
|
4022
|
+
// Suppress the auth error toast if this is a restoring/joined session without credentials
|
|
4023
|
+
if (session && session.isRestoring) {
|
|
4024
|
+
console.log('[SSHIFT] Suppressing auth error toast for restoring session without credentials');
|
|
4025
|
+
} else {
|
|
4026
|
+
this.showToast(data.message, 'error');
|
|
4027
|
+
}
|
|
4028
|
+
} else {
|
|
4029
|
+
this.showToast(data.message, 'error');
|
|
4030
|
+
}
|
|
4031
|
+
|
|
4032
|
+
if (data.sessionId && data.message !== 'Session not found') {
|
|
4001
4033
|
this.closeTab(data.sessionId);
|
|
4002
4034
|
}
|
|
4003
4035
|
});
|
|
@@ -4018,6 +4050,18 @@ const wheelHandler = (e) => {
|
|
|
4018
4050
|
this.onSFTPConnected(data);
|
|
4019
4051
|
});
|
|
4020
4052
|
|
|
4053
|
+
this.socket.on('sftp-joined', (data) => {
|
|
4054
|
+
console.log('[SSHIFT] SFTP Joined session:', data.sessionId);
|
|
4055
|
+
const session = this.sftpSessions.get(data.sessionId);
|
|
4056
|
+
if (session) {
|
|
4057
|
+
session.connecting = false;
|
|
4058
|
+
session.isRestoring = false;
|
|
4059
|
+
// Navigate to the stored path or root to show the session is active
|
|
4060
|
+
const path = session.currentPath || '/';
|
|
4061
|
+
this.socket.emit('sftp-list', { sessionId: data.sessionId, path });
|
|
4062
|
+
}
|
|
4063
|
+
});
|
|
4064
|
+
|
|
4021
4065
|
this.socket.on('sftp-list-result', (data) => {
|
|
4022
4066
|
console.log('[SSHIFT] sftp-list-result received:', data);
|
|
4023
4067
|
console.log('[SSHIFT] sessionId from server:', data.sessionId);
|
|
@@ -4027,7 +4071,45 @@ const wheelHandler = (e) => {
|
|
|
4027
4071
|
});
|
|
4028
4072
|
|
|
4029
4073
|
this.socket.on('sftp-error', (data) => {
|
|
4030
|
-
|
|
4074
|
+
console.error('[SSHIFT] SFTP Error:', data.message, 'sessionId:', data?.sessionId);
|
|
4075
|
+
|
|
4076
|
+
// If session not found and we're restoring, try to reconnect
|
|
4077
|
+
if (data?.sessionId && data.message === 'Session not found') {
|
|
4078
|
+
const session = this.sftpSessions.get(data.sessionId);
|
|
4079
|
+
|
|
4080
|
+
if (session && session.isRestoring && session.connectionData) {
|
|
4081
|
+
// Only attempt reconnection if we have auth credentials
|
|
4082
|
+
const hasCredentials = session.connectionData.password || session.connectionData.privateKey;
|
|
4083
|
+
if (hasCredentials) {
|
|
4084
|
+
console.log('[SFTP] Session not found on server, reconnecting...');
|
|
4085
|
+
this.showToast('SFTP session expired, reconnecting...', 'warning');
|
|
4086
|
+
session.isRestoring = false;
|
|
4087
|
+
session.connecting = true;
|
|
4088
|
+
this.socket.emit('sftp-connect', { ...session.connectionData, sessionId: data.sessionId });
|
|
4089
|
+
return;
|
|
4090
|
+
} else {
|
|
4091
|
+
// No credentials available - show a user-friendly message
|
|
4092
|
+
console.log('[SFTP] Session expired and no credentials available for reconnection');
|
|
4093
|
+
this.showToast('SFTP session expired. Please reconnect manually.', 'warning');
|
|
4094
|
+
session.connecting = false;
|
|
4095
|
+
return;
|
|
4096
|
+
}
|
|
4097
|
+
}
|
|
4098
|
+
}
|
|
4099
|
+
|
|
4100
|
+
// Suppress auth error toast for restoring sessions without credentials
|
|
4101
|
+
const isStrippedAuthError = data.message && data.message.includes('authentication methods failed');
|
|
4102
|
+
if (isStrippedAuthError) {
|
|
4103
|
+
const session = data?.sessionId ? this.sftpSessions.get(data.sessionId) : null;
|
|
4104
|
+
if (session && session.isRestoring) {
|
|
4105
|
+
console.log('[SSHIFT] Suppressing auth error toast for restoring SFTP session without credentials');
|
|
4106
|
+
} else {
|
|
4107
|
+
this.showToast(data.message, 'error');
|
|
4108
|
+
}
|
|
4109
|
+
} else {
|
|
4110
|
+
this.showToast(data.message, 'error');
|
|
4111
|
+
}
|
|
4112
|
+
|
|
4031
4113
|
if (this._activeDownload) {
|
|
4032
4114
|
this.hideTransferProgress(this._activeDownload.sessionId);
|
|
4033
4115
|
this._activeDownload = null;
|
|
@@ -7495,7 +7577,9 @@ const wheelHandler = (e) => {
|
|
|
7495
7577
|
type: 'sftp',
|
|
7496
7578
|
currentPath: '/',
|
|
7497
7579
|
connectionData, // Store for sticky sessions
|
|
7498
|
-
fontSize: this.terminalFontSize // Initialize with default font size
|
|
7580
|
+
fontSize: this.terminalFontSize, // Initialize with default font size
|
|
7581
|
+
isRestoring: !!restoreSessionId, // Flag to indicate if this is a restored session
|
|
7582
|
+
connecting: !restoreSessionId, // Only show connecting state for new connections
|
|
7499
7583
|
});
|
|
7500
7584
|
|
|
7501
7585
|
console.log('[SSHIFT] Switching to SFTP tab:', sessionId);
|
|
@@ -7512,9 +7596,15 @@ const wheelHandler = (e) => {
|
|
|
7512
7596
|
const sftpContainer = document.getElementById(`sftp-${sessionId}`);
|
|
7513
7597
|
console.log('[SSHIFT] SFTP container found:', !!sftpContainer);
|
|
7514
7598
|
|
|
7515
|
-
//
|
|
7516
|
-
|
|
7517
|
-
|
|
7599
|
+
// If restoring a session, try to join it first (no new SSH connection needed)
|
|
7600
|
+
if (restoreSessionId) {
|
|
7601
|
+
console.log('[SSHIFT] Attempting to join existing SFTP session:', restoreSessionId);
|
|
7602
|
+
this.socket.emit('sftp-join', { sessionId: restoreSessionId });
|
|
7603
|
+
} else {
|
|
7604
|
+
// Connect via socket for new sessions
|
|
7605
|
+
console.log('[SSHIFT] Emitting sftp-connect for session:', sessionId);
|
|
7606
|
+
this.socket.emit('sftp-connect', { ...connectionData, sessionId });
|
|
7607
|
+
}
|
|
7518
7608
|
|
|
7519
7609
|
// Save tabs
|
|
7520
7610
|
this.saveTabs();
|