Skip to content

Commit 32260f2

Browse files
ralyodioclaude
andcommitted
fix(settings): hasUserKeys checks IndexedDB fallback for imported keys
Keys imported from backup file go to IndexedDB only; localStorage is never written, so hasUserKeys() returned false on reload. Now checks IndexedDB qryptchat_pq_keypair as fallback when localStorage is empty. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
1 parent 9802410 commit 32260f2

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

‎src/lib/crypto/key-manager.js‎

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55

66
import { Base64, CryptoUtils } from './index.js';
77
import { MasterKeyDerivation } from './master-key-derivation.js';
8+
import { indexedDBManager } from './indexed-db-manager.js';
89

910
/**
1011
* Client-side key management service
@@ -380,9 +381,14 @@ export class KeyManager {
380381
async hasUserKeys() {
381382
try {
382383
if (typeof window === 'undefined') return false;
383-
384-
const userKeys = localStorage.getItem('qryptchat_user_keys');
385-
return !!userKeys;
384+
385+
// Fast path: localStorage marker set by generateUserKeys
386+
if (localStorage.getItem('qryptchat_user_keys')) return true;
387+
388+
// Fallback: keys imported from backup go straight to IndexedDB
389+
// without touching localStorage, so check there too.
390+
const pqKeys = await indexedDBManager.get('qryptchat_pq_keypair');
391+
return !!pqKeys;
386392
} catch (error) {
387393
console.error('🔑 Failed to check user keys:', error);
388394
return false;

0 commit comments

Comments
 (0)