d3ace8d611
## Security Fixes - Sanitize OMNIROUTE_MEMORY_MB with parseInt + range validation (64-16384) to prevent command injection via spawn() args - Validate URL protocol in shell.openExternal (http/https only) to prevent RCE in Electron renderer compromise - Bump default memory from 256MB to 512MB ## Electron package-lock.json - Added to .gitignore (5278 lines removed from tracking) ## Test Suite (64 tests, 9 suites) - electron-main.test.mjs: URL validation, IPC channels, window handler - electron-preload.test.mjs: channel whitelist, API surface, open-external - cli-memory.test.mjs: injection prevention, boundary values, .env parsing ## Documentation - Desktop App section added to all 30 READMEs (9 fully translated) - USER_GUIDE.md updated with 512MB default - .env.example reflects new defaults
OmniRoute Electron Desktop App
This directory contains the Electron desktop application wrapper for OmniRoute.
Structure
electron/
├── main.js # Main process (window management, IPC)
├── preload.js # Preload script (secure bridge to renderer)
├── package.json # Electron-specific dependencies
├── types.d.ts # TypeScript definitions
└── assets/ # Application icons and resources
Development
Prerequisites
- Build the Next.js app first:
npm run build
- Install Electron dependencies:
cd electron
npm install
Running in Development
- Start the Next.js development server:
npm run dev
- In another terminal, start Electron:
cd electron
npm run dev
Running in Production Mode
- Build Next.js in standalone mode:
npm run build
- Start Electron:
cd electron
npm start
Building
Build for Current Platform
cd electron
npm run build
Build for Specific Platforms
# Windows
npm run build:win
# macOS
npm run build:mac
# Linux
npm run build:linux
Output
Built applications are placed in dist-electron/:
- Windows:
.exeinstaller (NSIS) - macOS:
.dmginstaller - Linux:
.AppImage
Features
- System Tray Integration: Minimize to tray, quick actions
- Native Notifications: Desktop notifications
- Window Management: Minimize, maximize, close
- Auto-start: Option to launch on system startup
- Offline Support: Local server bundled with the app
Configuration
Environment Variables
The Electron app respects these environment variables:
OMNIROUTE_PORT: Server port (default: 20128)NODE_ENV: Set to 'production' for production builds
Custom Icon
Place your icons in assets/:
icon.ico- Windows icon (256x256)icon.icns- macOS icon bundleicon.png- Linux/general use (512x512)tray-icon.png- System tray icon (16x16 or 32x32)
IPC Channels
| Channel | Direction | Description |
|---|---|---|
get-app-info |
Renderer → Main | Get app name, version, platform |
open-external |
Renderer → Main | Open URL in default browser |
get-data-dir |
Renderer → Main | Get data directory path |
restart-server |
Renderer → Main | Restart the internal server |
server-status |
Main → Renderer | Server status updates |
port-changed |
Main → Renderer | Port change notifications |
Security
contextIsolation: true- Isolates renderer from Node.jsnodeIntegration: false- No direct Node.js access in renderer- Preload script validates IPC channels
- No remote code execution
Troubleshooting
App Won't Start
- Check if port 20128 is available
- Check logs in the console
- Verify the build output exists
White Screen
- Verify Next.js build exists
- Check the server URL in main.js
- Check for console errors
Build Fails
- Ensure you have build tools installed:
- Windows: Visual Studio Build Tools
- macOS: Xcode Command Line Tools
- Linux: build-essential, libsecret-1-dev
License
MIT