Global System Architecture
Gens-Launcher is the official Graphical User Interface (GUI) of the Gens ecosystem. Built on Electron, its primary role is to orchestrate:
- Secure player authentication via Microsoft and Xbox Live APIs.
- Asset verification, dependency downloading, and launching Minecraft via the in-house
gens-coreengine. - Asynchronous execution and communication with Gens-Horizon, the companion differential cloud sync engine.
Isolated Process Model
The architecture strictly follows Electron's process separation model by splitting responsibilities across three isolated realms:
text
+-------------------------------------------------------------------+
| MAIN PROCESS (Node.js) |
| - main.js: App lifecycle, windows, global CSP |
| - src/main/ipc-auth.js: Mojang proxy, Microsoft tokens |
| - src/main/ipc-game.js: JVM preparation, child_process spawn |
| - src/main/ipc-fs.js: Confined sandboxed file operations |
| - src/main/ipc-horizon.js: Horizon binary bridge |
| - src/main/crypto-utils.js: safeStorage & PBKDF2 / AES-256-GCM |
+---------------------------------+---------------------------------+
|
Async IPC | (ipcMain.handle / invoke)
Strict Whitelist |
v
+-------------------------------------------------------------------+
| SECURITY BRIDGE (preload.js) |
| - contextIsolation: true & sandbox: true |
| - enforceSandbox() / enforceReadSandbox(): Blocks Zip Slip |
| - window.api: Exclusive surface exposed to the DOM |
+---------------------------------+---------------------------------+
|
v
+-------------------------------------------------------------------+
| RENDERER PROCESS (Strict TypeScript) |
| - renderer.js (JSDoc TypeScript strict mode), HTML5, Vanilla CSS |
| - Zero direct Node.js access (require() forbidden) |
| - UI Managers: AccountUI, InstancesUI, ModsUI, CloudUI |
+-------------------------------------------------------------------+Component Breakdown
1. Main Process
Runs in a full Node.js environment with native file system and low-level network access:
main.js: Application entry point. InstantiatesBrowserWindow, enforces globalContent-Security-Policy(CSP) headers, and registers IPC handlers via a typedMainContext.src/main/ipc-auth.js: Manages OAuth2 flows and acts as a secure reverse proxy for Mojang APIs (skins and capes), bypassing CORS without exposing the renderer.src/main/ipc-game.js: Launch engine. Builds JVM startup arguments, downloads dependencies, and spawns the game viachild_processwithout shell evaluation.src/main/ipc-fs.js: Sandboxed filesystem service enforcing both lexical boundaries andfs.realpathSyncsymlink/junction verification (assertPathUnderSandbox).src/main/ipc-horizon.js: Exclusive communication bridge forHorizon.exe/Horizon. Validates local binary SHA-256 hash against official GitHub releases (cached for 2 hours) and whitelists executable flags.src/main/crypto-utils.js: Cryptographic routines. Uses OS-nativesafeStoragewhen available, falling back to PBKDF2 (600,000 iterations with a dedicated 16-byte salt in.key_salt) and AES-256-GCM.
2. The Security Bridge (Preload)
preload.js: Executes in an isolated preload context before locking down internal APIs:- Exposes a hardened
window.apiobject to the DOM viacontextBridge.exposeInMainWorld. - Implements the Software Security Shield:
enforceSandbox()andenforceReadSandbox()mathematically inspect all path operations to preventZip SlipandPath Traversal. - Disk write operations are strictly restricted to
%AppData%\GensLauncher. - File reading outside the sandbox is limited to verified paths (
.minecraft/, detected Java runtimes, and temporary directories).
- Exposes a hardened
3. Renderer Process (User Interface)
renderer.js/ HTML / CSS: Lightweight modular interface strictly type-checked with TypeScript (checkJs: true,strict: true), preserving zero-build-step startup performance.- No direct access to
require()orprocess. - All interactions with the underlying operating system go through asynchronous calls on
window.api.invoke().
Lifecycle and Asynchronous Performance
- Zero
sendSyncPolicy: All blocking operations run asynchronously (ipcRenderer.invokein renderer andipcMain.handlein main). The user interface remains reactive even during multi-gigabyte modpack installations. - Early Environment Injection: Fundamental system metadata (platform, architecture, version, appData path) is injected into
BrowserWindow.additionalArgumentsduring window creation, eliminating synchronous IPC bootstrap calls.