diff options
| author | Oskar Nyberg <oskar@mullvad.net> | 2021-10-01 13:24:33 +0200 |
|---|---|---|
| committer | Oskar Nyberg <oskar@mullvad.net> | 2021-10-01 13:24:33 +0200 |
| commit | 2cc8932c76a2546574f138bf95b88a9978fb0eb8 (patch) | |
| tree | a6b86a49a635184244827854be9b783209629083 /gui/src/main | |
| parent | 26ca38a9520b39ac45102dd7473a965af6220bd6 (diff) | |
| parent | c32d5d1a3a437318e11c5b5f448a02b042bde69a (diff) | |
| download | mullvadvpn-2cc8932c76a2546574f138bf95b88a9978fb0eb8.tar.xz mullvadvpn-2cc8932c76a2546574f138bf95b88a9978fb0eb8.zip | |
Merge branch 'update-to-electron-15'
Diffstat (limited to 'gui/src/main')
| -rw-r--r-- | gui/src/main/daemon-rpc.ts | 2 | ||||
| -rw-r--r-- | gui/src/main/index.ts | 23 |
2 files changed, 14 insertions, 11 deletions
diff --git a/gui/src/main/daemon-rpc.ts b/gui/src/main/daemon-rpc.ts index 89360fbc15..9df81f119e 100644 --- a/gui/src/main/daemon-rpc.ts +++ b/gui/src/main/daemon-rpc.ts @@ -125,7 +125,7 @@ export class DaemonRpc { private connectionObservers: ConnectionObserver[] = []; private nextSubscriptionId = 0; private subscriptions: Map<number, grpc.ClientReadableStream<grpcTypes.DaemonEvent>> = new Map(); - private reconnectionTimeout?: number; + private reconnectionTimeout?: NodeJS.Timer; constructor(connectionParams: string) { this.client = (new ManagementServiceClient( diff --git a/gui/src/main/index.ts b/gui/src/main/index.ts index 3421e72894..b211d9fe12 100644 --- a/gui/src/main/index.ts +++ b/gui/src/main/index.ts @@ -1,4 +1,5 @@ import { exec, execFile } from 'child_process'; +import { randomUUID } from 'crypto'; import { app, BrowserWindow, @@ -15,7 +16,6 @@ import os from 'os'; import * as path from 'path'; import { sprintf } from 'sprintf-js'; import util from 'util'; -import * as uuid from 'uuid'; import config from '../config.json'; import { closeToExpiry, hasExpired } from '../shared/account-expiry'; import { IApplication } from '../shared/application-types'; @@ -95,6 +95,8 @@ const UPDATE_NOTIFICATION_DISABLED = process.env.MULLVAD_DISABLE_UPDATE_NOTIFICA const SANDBOX_DISABLED = app.commandLine.hasSwitch('no-sandbox'); +const ALLOWED_PERMISSIONS = ['clipboard-sanitized-write']; + enum AppQuitStage { unready, initiated, @@ -438,8 +440,8 @@ class ApplicationMain { this.blockPermissionRequests(); // Blocks any http(s) and file requests that aren't supposed to happen. this.blockRequests(); - // Blocks navigation since it's not needed. - this.blockNavigation(); + // Blocks navigation and window.open since it's not needed. + this.blockNavigationAndWindowOpen(); this.updateCurrentLocale(); @@ -1289,7 +1291,7 @@ class ApplicationMain { }); IpcMainEventChannel.problemReport.handleCollectLogs((toRedact) => { - const id = uuid.v4(); + const id = randomUUID(); const reportPath = this.getProblemReportPath(id); const executable = resolveBin('mullvad-problem-report'); const args = ['collect', '--output', reportPath]; @@ -1597,7 +1599,9 @@ class ApplicationMain { session.defaultSession.setPermissionRequestHandler((_webContents, _permission, callback) => { callback(false); }); - session.defaultSession.setPermissionCheckHandler(() => false); + session.defaultSession.setPermissionCheckHandler((_webContents, permission) => + ALLOWED_PERMISSIONS.includes(permission), + ); } // Since the app frontend never performs any network requests, all requests originating from the @@ -1648,11 +1652,11 @@ class ApplicationMain { ); } - private blockNavigation() { + // Blocks navigation and window.open since it's not needed. + private blockNavigationAndWindowOpen() { app.on('web-contents-created', (_event, contents) => { - contents.on('will-navigate', (event) => { - event.preventDefault(); - }); + contents.on('will-navigate', (event) => event.preventDefault()); + contents.setWindowOpenHandler(() => ({ action: 'deny' })); }); } @@ -1721,7 +1725,6 @@ class ApplicationMain { nodeIntegration: false, nodeIntegrationInWorker: false, nodeIntegrationInSubFrames: false, - enableRemoteModule: false, sandbox: !SANDBOX_DISABLED, contextIsolation: true, spellcheck: false, |
