diff --git a/src/main/credential.ts b/src/main/credential.ts index 36161e0..f5f7f9e 100644 --- a/src/main/credential.ts +++ b/src/main/credential.ts @@ -11,5 +11,13 @@ export function decrypt(encoded: string): string { if (!safeStorage.isEncryptionAvailable()) { return Buffer.from(encoded, 'base64').toString('utf-8') } - return safeStorage.decryptString(Buffer.from(encoded, 'base64')) + try { + return safeStorage.decryptString(Buffer.from(encoded, 'base64')) + } catch { + // Fallback: the ciphertext may have been encoded with plain base64 + // (e.g. when safeStorage was unavailable at encryption time, or the + // OS keyring changed). Decode as plain base64 so the connection + // attempt can proceed instead of crashing. + return Buffer.from(encoded, 'base64').toString('utf-8') + } }