forked from trent_larson/crowd-funder-for-time-pwa
feat: implement secure IPC-based file export for Electron
Replace sandboxed Capacitor filesystem with native IPC for reliable file exports: - Add IPC handler in main process for direct Downloads folder access - Expose secure electronAPI via contextBridge in preload script - Update ElectronPlatformService to use native IPC with web fallback - Add TypeScript definitions for electron APIs - Fix file export issues where files were trapped in virtual filesystem - Enable proper date-stamped backup filenames in Downloads folder - Follow Electron security best practices with process isolation Files now export directly to ~/Downloads with exact path feedback.
This commit is contained in:
33
src/types/global.d.ts
vendored
33
src/types/global.d.ts
vendored
@@ -33,4 +33,37 @@ declare module '@jlongster/sql.js' {
|
||||
}) => Promise<SQL>;
|
||||
|
||||
export default initSqlJs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Electron API types for the main world context bridge.
|
||||
*
|
||||
* These types define the secure IPC APIs exposed by the preload script
|
||||
* to the renderer process for native Electron functionality.
|
||||
*/
|
||||
interface ElectronAPI {
|
||||
/**
|
||||
* Export data to the user's Downloads folder.
|
||||
*
|
||||
* @param fileName - The name of the file to save (e.g., 'backup-2025-07-06.json')
|
||||
* @param data - The content to write to the file (string)
|
||||
* @returns Promise with success status, file path, or error message
|
||||
*/
|
||||
exportData: (fileName: string, data: string) => Promise<{
|
||||
success: boolean;
|
||||
path?: string;
|
||||
error?: string;
|
||||
}>;
|
||||
}
|
||||
|
||||
/**
|
||||
* Global window interface extension for Electron APIs.
|
||||
*
|
||||
* This makes the electronAPI available on the window object
|
||||
* in TypeScript without type errors.
|
||||
*/
|
||||
declare global {
|
||||
interface Window {
|
||||
electronAPI: ElectronAPI;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user