1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-11-14 10:26:19 +01:00
bitwarden-browser/apps/desktop/src/preload.ts
Daniel García 4be25e3df3
[PM-3756] Disable node integration and enable context isolation in desktop (#6975)
* Disable node integration and enable context isolation

* Review comments

* Log in renderer through IPC

* Missed imports

* Mock electron API

* resourcesPath is undefined in the preload, but process.windowsStore works correctly

* Replace fromBufferToUtf8 conditional implementation for the `buffer` package

The current non-node implementation is different than the node implementation,
as the non-node would break when the contents can't be parsed as a URI component.
Replacing the impl by the `buffer` package makes the result match in both environments.

* Fix lint

* Add some more tests

* Remove buffer from devDependencies
2024-02-08 18:00:19 +01:00

23 lines
648 B
TypeScript

import { contextBridge } from "electron";
import auth from "./auth/preload";
import platform from "./platform/preload";
/**
* Bitwarden Preload script.
*
* This file contains the "glue" between the main process and the renderer process. Please ensure
* that you have read through the following articles before modifying any preload script.
*
* https://www.electronjs.org/docs/latest/tutorial/tutorial-preload
* https://www.electronjs.org/docs/latest/api/context-bridge
*/
// Each team owns a subspace of the `ipc` global variable in the renderer.
export const ipc = {
auth,
platform,
};
contextBridge.exposeInMainWorld("ipc", ipc);