Skip to content

Commit b51c0b7

Browse files
maskarjohannesjo
andauthored
feat(electron): grant microphone and clipboard permissions (#40)
* feat(electron): grant microphone and clipboard permissions Add permission handler for media (microphone) and clipboard-read access. Add audio-input entitlement for macOS builds. * fix(electron): scope media permission to audio-only, add NSMicrophoneUsageDescription - Check details.mediaTypes to grant only audio (microphone), deny video (camera) - Add NSMicrophoneUsageDescription for macOS hardened runtime compatibility --------- Co-authored-by: maskar <Maskar@users.noreply.github.com> Co-authored-by: Johannes Millan <johannes.millan@gmail.com>
1 parent 933931a commit b51c0b7

3 files changed

Lines changed: 23 additions & 2 deletions

File tree

build/entitlements.mac.plist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,7 @@
88
<true/>
99
<key>com.apple.security.cs.disable-library-validation</key>
1010
<true/>
11+
<key>com.apple.security.device.audio-input</key>
12+
<true/>
1113
</dict>
1214
</plist>

electron/main.ts

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { app, BrowserWindow, shell } from 'electron';
1+
import { app, BrowserWindow, session, shell } from 'electron';
22
import path from 'path';
33
import fs from 'fs';
44
import { fileURLToPath } from 'url';
@@ -138,7 +138,23 @@ function createWindow() {
138138
});
139139
}
140140

141-
app.whenReady().then(createWindow);
141+
app.whenReady().then(() => {
142+
// Grant microphone and clipboard access (deny camera/video)
143+
session.defaultSession.setPermissionRequestHandler(
144+
(_webContents, permission, callback, details) => {
145+
if (permission === 'clipboard-read') {
146+
return callback(true);
147+
}
148+
if (permission === 'media') {
149+
const types = (details as { mediaTypes?: string[] }).mediaTypes ?? [];
150+
return callback(types.every((t) => t === 'audio'));
151+
}
152+
callback(false);
153+
},
154+
);
155+
156+
createWindow();
157+
});
142158

143159
app.on('before-quit', () => {
144160
killAllAgents();

package.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,9 @@
113113
"target": "dmg",
114114
"category": "public.app-category.developer-tools",
115115
"hardenedRuntime": true,
116+
"extendInfo": {
117+
"NSMicrophoneUsageDescription": "Parallel Code needs microphone access for voice input in terminal sessions."
118+
},
116119
"gatekeeperAssess": false,
117120
"notarize": true,
118121
"x64ArchFiles": "Contents/Resources/app.asar.unpacked/node_modules/node-pty/prebuilds/**",

0 commit comments

Comments
 (0)