Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

fix(ensu): prefer legacy localStorage chat key

Prateek Sunal2e26f03f7472
diff --git a/web/apps/ensu/src/services/chat/chatKey.ts b/web/apps/ensu/src/services/chat/chatKey.ts
index 6c8e7a4de2..6257c761ff 100644
--- a/web/apps/ensu/src/services/chat/chatKey.ts
+++ b/web/apps/ensu/src/services/chat/chatKey.ts
@@ -202,10 +202,15 @@ export const initChatKeyStore = async () => {
(remoteLocalStorageKey
? readLocalStorageKey(remoteLocalStorageKey)
: undefined);
+ // Prefer localStorage over legacy secure storage for the local key.
+ // Pre-v0.1.12 builds only used localStorage, so when both exist the
+ // localStorage value is the key that actually encrypted the legacy DB.
+ // Stale OS keyring entries from a previous v0.1.12 install can shadow
+ // the correct localStorage key if secure storage is checked first.
const legacyLocalChatKey =
+ readLocalStorageKey(LOCAL_CHAT_KEY_LOCAL_STORAGE_KEY) ??
legacySecureLocalChatKey ??
- nativeKeys.localChatKey ??
- readLocalStorageKey(LOCAL_CHAT_KEY_LOCAL_STORAGE_KEY);
+ nativeKeys.localChatKey;
const remoteChatKey = secureRemoteChatKey ?? legacyRemoteChatKey;
const localChatKey = secureLocalChatKey ?? legacyLocalChatKey;