Skip to content

refactor(desktop-electron): enable contextIsolation and sandbox#23523

Open
Brendonovich wants to merge 1 commit intodevfrom
brendan/electron-context-isolation
Open

refactor(desktop-electron): enable contextIsolation and sandbox#23523
Brendonovich wants to merge 1 commit intodevfrom
brendan/electron-context-isolation

Conversation

@Brendonovich
Copy link
Copy Markdown
Member

Summary

Refactors the Electron desktop app to use proper security practices by enabling contextIsolation and sandbox on BrowserWindows, and removes the injectGlobals anti-pattern.

Changes

  • Security: Enables contextIsolation: true, nodeIntegration: false, and sandbox: true on all BrowserWindows
  • IPC: Replaces injectGlobals (which used executeJavaScript to pollute window) with proper IPC handlers:
    • getWindowConfig — returns { updaterEnabled }
    • consumeInitialDeepLinks — returns pending deep links at startup
  • Preload: Fixes preload output format to CJS (.js instead of .mjs) to work with sandboxed renderer
  • Renderer: Updates all consumers to fetch config/deep links via window.api instead of window.__OPENCODE__

Motivation

The previous approach disabled Electron's security model (sandbox: false, contextIsolation: false) and injected globals via executeJavaScript. This refactor aligns with Electron security best practices while preserving all existing functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant