From 3058a1ed343395be46ee84c117575ce32bfa8607 Mon Sep 17 00:00:00 2001 From: Aga Date: Mon, 22 Aug 2022 16:47:26 +0300 Subject: [PATCH] fix: add entitlements info.plist with NSMicrophoneUsageDescription key (#97) * fix: add entitlements info.plist with NSMicrophoneUsageDescription key * Testing hardenedRuntime = true * Disable hardenedRuntime * fixed compilation * request for media access * update mediaType type * increase version for release --- electron/main.ts | 15 ++++++++++++++- entitlements.mac.plist | 16 ++++++++++++++++ package.json | 9 +++++++-- 3 files changed, 37 insertions(+), 3 deletions(-) create mode 100644 entitlements.mac.plist diff --git a/electron/main.ts b/electron/main.ts index 1fbce86..f90f13a 100644 --- a/electron/main.ts +++ b/electron/main.ts @@ -1,4 +1,4 @@ -import { shell, app, BrowserWindow, ipcMain, Tray, Menu, crashReporter } from 'electron' +import { shell, app, BrowserWindow, ipcMain, Tray, Menu, crashReporter, systemPreferences } from 'electron' import * as isDev from 'electron-is-dev' import { getOSName, getFreePort } from './updater' import { exit } from 'process' @@ -202,6 +202,10 @@ const startApp = async (): Promise => { await checkUpdates(win) } + const microphoneResult = await askForMediaAccess('microphone'); + if (!microphoneResult) { + console.log('Microphone permission was not given') + } return Promise.resolve() } @@ -249,3 +253,12 @@ function initializeCrashReport() { crashReporter.start({ uploadToServer: false }) } + +const askForMediaAccess = async (mediaType: 'microphone' | 'camera') => { + if (systemPreferences.askForMediaAccess) { + // Electron currently only implements this on macOS + return await systemPreferences.askForMediaAccess(mediaType); + } + // For other platforms we can't reasonably do anything other than assume we have access. + return true; +} diff --git a/entitlements.mac.plist b/entitlements.mac.plist new file mode 100644 index 0000000..057b2e1 --- /dev/null +++ b/entitlements.mac.plist @@ -0,0 +1,16 @@ + + + + + com.apple.security.cs.allow-jit + + com.apple.security.cs.allow-unsigned-executable-memory + + com.apple.security.cs.allow-dyld-environment-variables + + com.apple.security.device.microphone + + com.apple.security.device.audio-input + + + \ No newline at end of file diff --git a/package.json b/package.json index b390c06..ccf2d0b 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "explorer-desktop-launcher", - "version": "0.1.42", + "version": "0.1.43", "author": "decentraland", "description": "Decentraland Desktop Launcher", "homepage": ".", @@ -112,7 +112,12 @@ "target": [ "dmg", "zip" - ] + ], + "hardenedRuntime": false, + "entitlements": "entitlements.mac.plist", + "extendInfo": { + "NSMicrophoneUsageDescription": "Need microphone access to use voice chat in the application" + } }, "dmg": { "icon": "public/installer-icon.icns",