import { ipcMain } from 'electron'; import * as fs from 'fs'; import * as path from 'path'; import os from 'os'; ipcMain.handle('check-keys', async (event, userId) => { try { // Determine base directory based on OS let baseDir; if (process.platform === 'win32') { baseDir = path.join(os.homedir(), 'AppData', 'Roaming', 'ultima'); } else if (process.platform === 'linux') { baseDir = path.join(os.homedir(), '.ultima'); } else if (process.platform === 'darwin') { baseDir = path.join(os.homedir(), 'Library', 'Application Support', 'Ultima'); } // Define file paths const userDir = path.join(baseDir, 'Sessions', userId); const epkFilePath = path.join(userDir, 'epk.txt'); const derivedKeyFilePath = path.join(userDir, 'derivedKey.txt'); if (fs.existsSync(epkFilePath) && fs.existsSync(derivedKeyFilePath)) { return { exists: true }; } else { return { exists: false }; } } catch (error) { return { exists: false, error: error.message }; } });