Commit graph

7 commits

Author SHA1 Message Date
Johannes Millan
85c7b2e99f fix(electron): update remaining plugin-api import paths
- Fix import paths in electron/plugin-node-executor.ts
- Fix import paths in electron/preload.ts
- Change from dist/types to src/types for plugin-api imports
2025-06-24 21:04:38 +02:00
Johannes Millan
b1b73a2823 refactor(plugins): simplify Node.js execution to KISS principle
- Remove unnecessary PLUGIN_REGISTER_FOR_NODE/PLUGIN_UNREGISTER_FOR_NODE
- Eliminate tmp directory usage - scripts execute via -e flag directly
- Pass manifest with each execution request instead of registration
- Simplify from 535 lines to 227 lines (57% reduction)
- Remove complex execution contexts and resource tracking
- Direct VM execution for safe scripts, spawn with -e for complex ones

Benefits:
- No more temp file management overhead
- No registration/unregistration complexity
- Permissions checked on each execution (fail-safe)
- Much simpler to understand and maintain
- Same security model, less code
2025-06-24 21:04:25 +02:00
Johannes Millan
d812254341 feat(sync-md-plugin): add manual sync button and initial sync on config
- Add 'Sync Now' button to UI for manual triggering
- Perform initial sync when plugin loads with valid config
- Add debug logging for task update hooks
- Add syncNow message handler for bidirectional sync support
- This helps test sync functionality and ensures initial data is written
2025-06-24 21:04:24 +02:00
Johannes Millan
53afb45097 fix(electron): add direct execution for simple Node scripts to avoid spawn issues
- Add canExecuteDirectly() to check if script only uses safe fs operations
- Add executeDirectly() to run simple scripts in VM sandbox without spawning
- Set ELECTRON_RUN_AS_NODE environment variable for spawn fallback
- Improve error handling for missing node executable
- Fix linting issues by using proper imports
- This fixes 'spawn node ENOENT' errors when Node.js is not in PATH
2025-06-24 21:04:24 +02:00
Johannes Millan
d1b743b4a3 refactor(plugin): improve type safety by removing 'as any' castings
- Create window-ea.d.ts to properly type window.ea (ElectronAPI)
- Replace all 'as any' castings with proper types
- Update all any[] to unknown[] for better type safety
- Import proper types (PluginManifest) in electron files
- Update plugin-api types to use unknown instead of any
- Fix app.getPath type casting with proper parameter types
- Rebuild plugin-api dist files with updated types
2025-06-24 21:04:23 +02:00
Johannes Millan
81e5d9a0dd feat(plugin): improve Node.js execution security and error handling
- Enhanced sandboxing with frozen prototypes and constructor removal
- Added comprehensive input validation for script requests
- Improved error handling with line/column information
- Added resource usage tracking (memory monitoring)
- Added cleanup method for plugin resources
- Better path traversal protection with ID sanitization
- Enhanced dangerous globals removal (fs, crypto, etc.)
- Added structured error types with error codes
- Built and updated plugin-api dist files
2025-06-24 21:04:23 +02:00
Johannes Millan
27e084e39a feat(plugin): add Node.js script execution API for plugins
- Implement secure Node.js script executor in Electron main process
- Add sandboxed execution environment with memory/timeout limits
- Create two-stage consent dialog for nodeExecution permission
- Add plugin registration/unregistration with main process
- Integrate executeNodeScript method into plugin API
- Add IPC handlers for plugin-to-main communication
- Ensure consent is checked when enabling plugins
- Add proper cleanup on plugin unload

Security features:
- Dangerous globals removed from execution context
- Plugin-specific working directories
- Configurable memory and timeout limits
- Persistent consent storage
- Only available in Electron environment
2025-06-24 21:04:23 +02:00