Files
ERitors-Scribe-Desktop/electron.d.ts
natreex f85c2d2269 Add offline mode support with PIN configuration and management
- Introduce `OfflinePinSetup` component for users to configure secure offline access.
- Add new `AIUsageContext` and extend `OfflineProvider` for offline-related state management.
- Implement offline login functionality in `electron/main.ts` with PIN verification and fallback support.
- Enhance IPC handlers to manage offline mode data, PIN setup, and synchronization.
- Update localization files (`en.json`, `fr.json`) with offline mode and PIN-related strings.
- Add `bcrypt` and `@types/bcrypt` dependencies for secure PIN hashing and validation.
- Refactor login and session management to handle offline mode scenarios with improved error handling and flow.
2025-11-19 19:58:55 -05:00

55 lines
2.0 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>;
// Offline mode management
offlinePinSet: (pin: string) => Promise<{ success: boolean; error?: string }>;
offlinePinVerify: (pin: string) => Promise<{ success: boolean; userId?: string; error?: string }>;
offlineModeSet: (enabled: boolean, syncInterval?: number) => Promise<{ success: boolean }>;
offlineModeGet: () => Promise<{ enabled: boolean; syncInterval: number; hasPin: boolean }>;
offlineSyncCheck: () => Promise<{ shouldSync: boolean; daysSinceSync?: number; syncInterval?: number }>;
}
declare global {
interface Window {
electron: IElectronAPI;
}
}
export {};