Migrate from electron-store to OS-level secure storage (getSecureStorage)
- Replace `electron-store` with OS-level encrypted storage for secure token, userId, and language management in `LocalSystem` and `keyManager`. - Add `init-user` IPC handler to initialize user data and manage encryption keys. - Update login process to handle encrypted storage saving with fallback for macOS issues. - Add offline warning component to `login/page.tsx` to handle first-time sync requirements. - Remove `electron-store` and associated dependencies from `package.json` and `package-lock.json`.
This commit is contained in:
@@ -1,33 +1,26 @@
|
||||
import type { IpcMainInvokeEvent } from 'electron';
|
||||
import Store from 'electron-store';
|
||||
import { getSecureStorage } from '../storage/SecureStorage.js';
|
||||
|
||||
// ============================================================
|
||||
// SESSION MANAGEMENT - Auto-inject userId and lang
|
||||
// ============================================================
|
||||
|
||||
/**
|
||||
* Electron store instance for session management
|
||||
* - userId: Set during login via 'login-success' event
|
||||
* - userLang: Set via 'set-lang' handler
|
||||
*/
|
||||
const store = new Store({
|
||||
encryptionKey: 'eritors-scribe-secure-key'
|
||||
});
|
||||
|
||||
/**
|
||||
* Get userId from electron-store
|
||||
* Get userId from secure storage (OS-encrypted)
|
||||
* Set during login via 'login-success' event
|
||||
*/
|
||||
function getUserIdFromSession(): string | null {
|
||||
return store.get('userId', null) as string | null;
|
||||
const storage = getSecureStorage();
|
||||
return storage.get<string>('userId', null);
|
||||
}
|
||||
|
||||
/**
|
||||
* Get lang from electron-store
|
||||
* Get lang from secure storage
|
||||
* Set via 'set-lang' handler, defaults to 'fr'
|
||||
*/
|
||||
function getLangFromSession(): 'fr' | 'en' {
|
||||
return store.get('userLang', 'fr') as 'fr' | 'en';
|
||||
const storage = getSecureStorage();
|
||||
return storage.get<'fr' | 'en'>('userLang', 'fr') as 'fr' | 'en';
|
||||
}
|
||||
|
||||
// ============================================================
|
||||
|
||||
Reference in New Issue
Block a user