diff options
Diffstat (limited to 'packages/main/src/infrastructure/electron/impl')
-rw-r--r-- | packages/main/src/infrastructure/electron/impl/devTools.ts | 43 | ||||
-rw-r--r-- | packages/main/src/infrastructure/electron/impl/hardenSession.ts | 14 |
2 files changed, 30 insertions, 27 deletions
diff --git a/packages/main/src/infrastructure/electron/impl/devTools.ts b/packages/main/src/infrastructure/electron/impl/devTools.ts index 10f4545..6db88d1 100644 --- a/packages/main/src/infrastructure/electron/impl/devTools.ts +++ b/packages/main/src/infrastructure/electron/impl/devTools.ts | |||
@@ -18,34 +18,32 @@ | |||
18 | * SPDX-License-Identifier: AGPL-3.0-only | 18 | * SPDX-License-Identifier: AGPL-3.0-only |
19 | */ | 19 | */ |
20 | 20 | ||
21 | import type { BrowserWindow } from 'electron'; | 21 | import { app, type BrowserWindow } from 'electron'; |
22 | |||
23 | /* eslint-disable | ||
24 | import/no-extraneous-dependencies, | ||
25 | global-require, | ||
26 | @typescript-eslint/no-var-requires, | ||
27 | unicorn/prefer-module -- | ||
28 | Hack to lazily require a CJS module from an ES module transpiled into a CJS module. | ||
29 | */ | ||
22 | 30 | ||
23 | /** | 31 | /** |
24 | * URL prefixes Sophie is allowed load in dev mode. | 32 | * Makes sure we use a separate data dir for development. |
25 | * | ||
26 | * In dev mode, in addition to the application itself, | ||
27 | * Sophie must be able do download and load the devtools and related extensions, | ||
28 | * so we have to make exceptions in the UI process request filter. | ||
29 | */ | 33 | */ |
30 | export const DEVMODE_ALLOWED_URL_PREFIXES = [ | 34 | export function ensureDevDataDir(): void { |
31 | 'chrome-extension:', | 35 | // Use alternative directory when debugging to avoid clobbering the main installation. |
32 | 'devtools:', | 36 | app.setPath('userData', `${app.getPath('userData')}-dev`); |
33 | 'https://clients2.google.com/service/update2/crx', | 37 | const userData = app.getPath('userData'); |
34 | 'https://clients2.googleusercontent.com/crx', | 38 | const mkdirp = require('mkdirp') as typeof import('mkdirp'); |
35 | ]; | 39 | mkdirp.sync(userData); |
40 | } | ||
36 | 41 | ||
37 | /** | 42 | /** |
38 | * Enables using source maps for node stack traces. | 43 | * Enables using source maps for node stack traces. |
39 | */ | 44 | */ |
40 | export function enableStacktraceSourceMaps(): void { | 45 | export function enableStacktraceSourceMaps(): void { |
41 | const sourceMapSupport = | 46 | const sourceMapSupport = |
42 | /* eslint-disable-next-line | ||
43 | import/no-extraneous-dependencies, | ||
44 | global-require, | ||
45 | @typescript-eslint/no-var-requires, | ||
46 | unicorn/prefer-module -- | ||
47 | Hack to lazily require a CJS module from an ES module transpiled into a CJS module. | ||
48 | */ | ||
49 | require('source-map-support') as typeof import('source-map-support'); | 47 | require('source-map-support') as typeof import('source-map-support'); |
50 | sourceMapSupport.install(); | 48 | sourceMapSupport.install(); |
51 | } | 49 | } |
@@ -61,13 +59,6 @@ export async function installDevToolsExtensions(): Promise<void> { | |||
61 | default: installExtension, | 59 | default: installExtension, |
62 | REACT_DEVELOPER_TOOLS, | 60 | REACT_DEVELOPER_TOOLS, |
63 | REDUX_DEVTOOLS, | 61 | REDUX_DEVTOOLS, |
64 | /* eslint-disable-next-line | ||
65 | import/no-extraneous-dependencies, | ||
66 | global-require, | ||
67 | @typescript-eslint/no-var-requires, | ||
68 | unicorn/prefer-module -- | ||
69 | Hack to lazily require a CJS module from an ES module transpiled into a CJS module. | ||
70 | */ | ||
71 | } = require('electron-devtools-installer') as typeof import('electron-devtools-installer'); | 62 | } = require('electron-devtools-installer') as typeof import('electron-devtools-installer'); |
72 | await installExtension([REACT_DEVELOPER_TOOLS, REDUX_DEVTOOLS], { | 63 | await installExtension([REACT_DEVELOPER_TOOLS, REDUX_DEVTOOLS], { |
73 | forceDownload: false, | 64 | forceDownload: false, |
diff --git a/packages/main/src/infrastructure/electron/impl/hardenSession.ts b/packages/main/src/infrastructure/electron/impl/hardenSession.ts index 10b694a..53675a7 100644 --- a/packages/main/src/infrastructure/electron/impl/hardenSession.ts +++ b/packages/main/src/infrastructure/electron/impl/hardenSession.ts | |||
@@ -25,7 +25,19 @@ import type { Session } from 'electron'; | |||
25 | import { getLogger } from '../../../utils/log'; | 25 | import { getLogger } from '../../../utils/log'; |
26 | import type Resources from '../../resources/Resources'; | 26 | import type Resources from '../../resources/Resources'; |
27 | 27 | ||
28 | import { DEVMODE_ALLOWED_URL_PREFIXES } from './devTools'; | 28 | /** |
29 | * URL prefixes Sophie is allowed load in dev mode. | ||
30 | * | ||
31 | * In dev mode, in addition to the application itself, | ||
32 | * Sophie must be able do download and load the devtools and related extensions, | ||
33 | * so we have to make exceptions in the UI process request filter. | ||
34 | */ | ||
35 | export const DEVMODE_ALLOWED_URL_PREFIXES = [ | ||
36 | 'chrome-extension:', | ||
37 | 'devtools:', | ||
38 | 'https://clients2.google.com/service/update2/crx', | ||
39 | 'https://clients2.googleusercontent.com/crx', | ||
40 | ]; | ||
29 | 41 | ||
30 | const log = getLogger('hardenSession'); | 42 | const log = getLogger('hardenSession'); |
31 | 43 | ||