Increase session timeout to 60min and inactivity to 30min

Fix sendMessage isUnlocked check to prevent immediate lock
Move session extension logic to SecureMasterKeyManager
Improve error messages
Keep validation of crypto keys before encryption
This commit is contained in:
lockbitchat
2025-10-20 02:06:42 -04:00
parent 0d7835cfa2
commit 40381cc0a1
3 changed files with 36 additions and 10 deletions
+13 -3
View File
@@ -13238,8 +13238,18 @@ var EnhancedSecureWebRTCManager = class _EnhancedSecureWebRTCManager {
operationId, operationId,
errorType: error.constructor.name errorType: error.constructor.name
}); });
if (error.message.includes("Session expired")) {
throw new Error("Session expired. Please enter your password to unlock.");
} else if (error.message.includes("Encryption keys not initialized")) {
throw new Error("Session expired due to inactivity. Please reconnect to the chat.");
} else if (error.message.includes("Connection lost")) {
throw new Error("Connection lost. Please check your Internet connection.");
} else if (error.message.includes("Rate limit exceeded")) {
throw new Error("Message rate limit exceeded. Please wait before sending another message.");
} else {
throw error; throw error;
} }
}
}, 2e3); }, 2e3);
} }
processMessageQueue() { processMessageQueue() {
@@ -13509,7 +13519,7 @@ var EnhancedSecureWebRTCManager = class _EnhancedSecureWebRTCManager {
if (error.message.includes("Connection not ready")) { if (error.message.includes("Connection not ready")) {
throw new Error("Connection not ready for file transfer. Check connection status."); throw new Error("Connection not ready for file transfer. Check connection status.");
} else if (error.message.includes("Encryption keys not initialized")) { } else if (error.message.includes("Encryption keys not initialized")) {
throw new Error("Encryption keys not initialized. Try reconnecting."); throw new Error("Session expired due to inactivity. Please reconnect to the chat.");
} else if (error.message.includes("Transfer timeout")) { } else if (error.message.includes("Transfer timeout")) {
throw new Error("File transfer timeout. Check connection and try again."); throw new Error("File transfer timeout. Check connection and try again.");
} else { } else {
@@ -14703,8 +14713,8 @@ var SecureMasterKeyManager = class {
this._isUnlocked = false; this._isUnlocked = false;
this._sessionTimeout = null; this._sessionTimeout = null;
this._lastActivity = null; this._lastActivity = null;
this._sessionTimeoutMs = 15 * 60 * 1e3; this._sessionTimeoutMs = 60 * 60 * 1e3;
this._inactivityTimeoutMs = 5 * 60 * 1e3; this._inactivityTimeoutMs = 30 * 60 * 1e3;
this._pbkdf2Iterations = 1e5; this._pbkdf2Iterations = 1e5;
this._saltSize = 32; this._saltSize = 32;
this._indexedDB = indexedDBWrapper || new SecureIndexedDBWrapper(); this._indexedDB = indexedDBWrapper || new SecureIndexedDBWrapper();
+2 -2
View File
File diff suppressed because one or more lines are too long
+19 -3
View File
@@ -11154,6 +11154,10 @@ async processMessage(data) {
throw new Error('Connection lost during message preparation'); throw new Error('Connection lost during message preparation');
} }
// Note: master key session is managed by SecureMasterKeyManager
// Do not gate here on _isUnlocked to avoid false blocking
// Session timers are handled inside the master key manager on key access
// Validate keys inside critical section // Validate keys inside critical section
if (!this.encryptionKey || !this.macKey || !this.metadataKey) { if (!this.encryptionKey || !this.macKey || !this.metadataKey) {
throw new Error('Encryption keys not initialized'); throw new Error('Encryption keys not initialized');
@@ -11210,8 +11214,20 @@ async processMessage(data) {
operationId: operationId, operationId: operationId,
errorType: error.constructor.name errorType: error.constructor.name
}); });
// Improved user-facing error messages (English)
if (error.message.includes('Session expired')) {
throw new Error('Session expired. Please enter your password to unlock.');
} else if (error.message.includes('Encryption keys not initialized')) {
throw new Error('Session expired due to inactivity. Please reconnect to the chat.');
} else if (error.message.includes('Connection lost')) {
throw new Error('Connection lost. Please check your Internet connection.');
} else if (error.message.includes('Rate limit exceeded')) {
throw new Error('Message rate limit exceeded. Please wait before sending another message.');
} else {
throw error; throw error;
} }
}
}, 2000); // Reduced timeout for crypto operations }, 2000); // Reduced timeout for crypto operations
} }
@@ -11566,7 +11582,7 @@ async processMessage(data) {
if (error.message.includes('Connection not ready')) { if (error.message.includes('Connection not ready')) {
throw new Error('Connection not ready for file transfer. Check connection status.'); throw new Error('Connection not ready for file transfer. Check connection status.');
} else if (error.message.includes('Encryption keys not initialized')) { } else if (error.message.includes('Encryption keys not initialized')) {
throw new Error('Encryption keys not initialized. Try reconnecting.'); throw new Error('Session expired due to inactivity. Please reconnect to the chat.');
} else if (error.message.includes('Transfer timeout')) { } else if (error.message.includes('Transfer timeout')) {
throw new Error('File transfer timeout. Check connection and try again.'); throw new Error('File transfer timeout. Check connection and try again.');
} else { } else {
@@ -13093,8 +13109,8 @@ class SecureMasterKeyManager {
this._lastActivity = null; this._lastActivity = null;
// Configuration // Configuration
this._sessionTimeoutMs = 15 * 60 * 1000; // 15 minutes this._sessionTimeoutMs = 60 * 60 * 1000; // 60 minutes (увеличено с 15 минут)
this._inactivityTimeoutMs = 5 * 60 * 1000; // 5 minutes this._inactivityTimeoutMs = 30 * 60 * 1000; // 30 minutes (увеличено с 5 минут)
// PBKDF2 parameters // PBKDF2 parameters
this._pbkdf2Iterations = 100000; // 100k iterations this._pbkdf2Iterations = 100000; // 100k iterations