Skip to content
This repository has been archived by the owner on Aug 1, 2023. It is now read-only.

Commit

Permalink
refactor: initial security refactor
Browse files Browse the repository at this point in the history
  • Loading branch information
kyranjamie committed Dec 22, 2020
1 parent f2db6e5 commit 0f3a8f4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 7 deletions.
5 changes: 5 additions & 0 deletions app/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,16 @@ import { render } from 'react-dom';
import { AppContainer as ReactHotAppContainer } from 'react-hot-loader';

import { configureStore, history } from './store/configureStore';
import { ipcRenderer, contextBridge } from 'electron';

const { store, persistor } = configureStore();

const AppContainer = process.env.PLAIN_HMR ? Fragment : ReactHotAppContainer;

// contextBridge.exposeInMainWorld('api', {
// xxx: 123,
// });

document.addEventListener('DOMContentLoaded', () => {
// eslint-disable-next-line @typescript-eslint/no-var-requires
const Root = require('./pages/root').default;
Expand Down
13 changes: 7 additions & 6 deletions app/main.dev.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,17 +81,18 @@ const createWindow = async () => {
frame: process.platform !== 'darwin',
titleBarStyle: process.platform === 'darwin' ? 'hidden' : 'default',
icon: path.join(__dirname, '../resources/icon-no-padding-512x512.png'),
webPreferences:
process.env.NODE_ENV === 'development' || process.env.E2E_BUILD === 'true'
webPreferences: {
webSecurity: true,
contextIsolation: true,
...(process.env.NODE_ENV === 'development' || process.env.E2E_BUILD === 'true'
? {
nodeIntegration: true,
}
: {
nodeIntegration: false,
contextIsolation: true,
webSecurity: true,
preload: path.join(__dirname, 'dist/renderer.prod.js'),
},
// preload: path.join(__dirname, 'dist/renderer.prod.js'),
}),
},
});

if (process.platform === 'darwin') mainWindow.setTrafficLightPosition({ x: 10, y: 28 });
Expand Down
2 changes: 1 addition & 1 deletion configs/webpack.config.renderer.prod.babel.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ export default merge.smart(baseConfig, {

mode: 'production',

target: 'electron-preload',
target: 'electron-renderer',

entry: path.join(__dirname, '..', 'app/index.tsx'),

Expand Down

0 comments on commit 0f3a8f4

Please sign in to comment.