Files
ERitors-Scribe-Desktop/electron.d.ts
natreex 060693f152 Add OAuth login support and streamline authentication flows
- Introduced `oauthLogin` method in `electron/preload.ts` and backend IPC handlers for OAuth via `BrowserWindow`.
- Replaced web-based OAuth redirection with Electron-specific implementation for Google, Facebook, and Apple.
- Refactored `SocialForm.tsx` to handle OAuth login success and token management via Electron.
- Updated `User`, `QuillSense`, and context methods to include `quill-trial` subscriptions and extended login logic.
- Cleaned up code, removed unused imports, and improved error handling for authentication scenarios.
2026-01-08 11:03:19 -05:00

66 lines
2.3 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>(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>;
// Open external links (browser/native app)
openExternal: (url: string) => Promise<void>;
// OAuth login via BrowserWindow
oauthLogin: (provider: 'google' | 'facebook' | 'apple', baseUrl: string) => Promise<{
success: boolean;
code?: string;
state?: string;
error?: string;
}>;
// 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; lastUserId?: string }>;
offlineSyncCheck: () => Promise<{ shouldSync: boolean; daysSinceSync?: number; syncInterval?: number }>;
}
declare global {
interface Window {
electron: IElectronAPI;
}
}
export {};