- 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`.
48 lines
1.5 KiB
TypeScript
48 lines
1.5 KiB
TypeScript
/**
|
|
* TypeScript declarations for window.electron API
|
|
* Must match exactly with electron/preload.ts
|
|
*
|
|
* Usage:
|
|
* - Use invoke<T>(channel, ...args) for all IPC calls
|
|
* - Shortcuts are provided for common operations (tokens, lang, encryption)
|
|
*/
|
|
export interface IElectronAPI {
|
|
// Platform info
|
|
platform: NodeJS.Platform;
|
|
|
|
// Generic invoke method - use this for all IPC calls
|
|
invoke: <T = any>(channel: string, ...args: any[]) => Promise<T>;
|
|
|
|
// Token management (shortcuts for convenience)
|
|
getToken: () => Promise<string | null>;
|
|
setToken: (token: string) => Promise<void>;
|
|
removeToken: () => Promise<void>;
|
|
|
|
// Language management (shortcuts for convenience)
|
|
getLang: () => Promise<'fr' | 'en'>;
|
|
setLang: (lang: 'fr' | 'en') => Promise<void>;
|
|
|
|
// Auth events (one-way communication)
|
|
loginSuccess: (token: string) => void;
|
|
logout: () => void;
|
|
|
|
// User initialization (after getting user info from server)
|
|
initUser: (userId: string) => Promise<{ success: boolean; keyCreated?: boolean; error?: string }>;
|
|
|
|
// Encryption key management (shortcuts for convenience)
|
|
generateEncryptionKey: (userId: string) => Promise<string>;
|
|
getUserEncryptionKey: (userId: string) => Promise<string | null>;
|
|
setUserEncryptionKey: (userId: string, encryptionKey: string) => Promise<void>;
|
|
|
|
// Database initialization (shortcut for convenience)
|
|
dbInitialize: (userId: string, encryptionKey: string) => Promise<boolean>;
|
|
}
|
|
|
|
declare global {
|
|
interface Window {
|
|
electron: IElectronAPI;
|
|
}
|
|
}
|
|
|
|
export {};
|