[MM-33828] Define CSP for all BrowserWindows, enable contextIsolation for main/settings window, other fixes (#1517)
* [MM-33828] Added CSP to renderer process pages and turned off remote module when not needed * Turn on contextIsolation and turn off nodeIntegration for main and settings windows * Check for details.reason instead of object
This commit is contained in:
28
src/main/preload/mainWindow.js
Normal file
28
src/main/preload/mainWindow.js
Normal file
@@ -0,0 +1,28 @@
|
||||
// Copyright (c) 2016-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
// Copyright (c) 2015-2016 Yuya Ochiai
|
||||
|
||||
'use strict';
|
||||
|
||||
import os from 'os';
|
||||
import {ipcRenderer, contextBridge} from 'electron';
|
||||
|
||||
contextBridge.exposeInMainWorld('ipcRenderer', {
|
||||
send: ipcRenderer.send,
|
||||
on: (channel, listener) => ipcRenderer.on(channel, (_, ...args) => listener(null, ...args)),
|
||||
invoke: ipcRenderer.invoke,
|
||||
});
|
||||
|
||||
contextBridge.exposeInMainWorld('os', {
|
||||
isWindows10: os.platform() === 'win32' && os.release().startsWith('10'),
|
||||
});
|
||||
|
||||
contextBridge.exposeInMainWorld('process', {
|
||||
platform: process.platform,
|
||||
env: process.env,
|
||||
});
|
||||
|
||||
contextBridge.exposeInMainWorld('timers', {
|
||||
setImmediate,
|
||||
});
|
||||
|
Reference in New Issue
Block a user