Skip to content

Commit

Permalink
another try at audio permissions (and more) for #1086 (#1192)
Browse files Browse the repository at this point in the history
the permissions look scary, but the user still needs to grant them.  this just allows the app to ask.  this permission set now matches the entitlements in iTerm and other popular terminal programs (before we were too restrictive)
  • Loading branch information
sawka authored Nov 1, 2024
1 parent 55250de commit be3ec7e
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 25 deletions.
27 changes: 27 additions & 0 deletions build/entitlements.mac.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<!-- required for electron -->
<key>com.apple.security.cs.allow-jit</key>
<true/>
<key>com.apple.security.cs.allow-unsigned-executable-memory</key>
<true/>
<key>com.apple.security.cs.disable-library-validation</key>
<true/>

<!-- we add the following entitlements so that *CLI* applications can request/use these features. this matches iTerm's permission set -->
<key>com.apple.security.device.audio-input</key>
<true/>
<key>com.apple.security.device.camera</key>
<true/>
<key>com.apple.security.personal-information.addressbook</key>
<true/>
<key>com.apple.security.personal-information.calendars</key>
<true/>
<key>com.apple.security.personal-information.location</key>
<true/>
<key>com.apple.security.personal-information.photos-library</key>
<true/>
</dict>
</plist>
15 changes: 13 additions & 2 deletions electron-builder.config.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,20 @@ const config = {
minimumSystemVersion: "10.15.0",
mergeASARs: true,
singleArchFiles: "dist/bin/wavesrv.*",
entitlements: "build/entitlements.mac.plist",
entitlementsInherit: "build/entitlements.mac.plist",
extendInfo: {
NSMicrophoneUsageDescription:
"This app requires microphone access if you'd like to enable audio input for terminal applications.",
NSContactsUsageDescription: "A CLI application running in Wave wants to use your contacts.",
NSRemindersUsageDescription: "A CLI application running in Wave wants to use your reminders.",
NSLocationWhenInUseUsageDescription:
"A CLI application running in Wave wants to use your location information while active.",
NSLocationAlwaysUsageDescription:
"A CLI application running in Wave wants to use your location information, even in the background.",
NSCameraUsageDescription: "A CLI application running in Wave wants to use the camera.",
NSMicrophoneUsageDescription: "A CLI application running in Wave wants to use your microphone.",
NSCalendarsUsageDescription: "A CLI application running in Wave wants to use Calendar data.",
NSLocationUsageDescription: "A CLI application running in Wave wants to use your location information.",
NSAppleEventsUsageDescription: "A CLI application running in Wave wants to use AppleScript.",
},
},
linux: {
Expand Down
11 changes: 0 additions & 11 deletions emain/menu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -78,17 +78,6 @@ function getAppMenu(callbacks: AppMenuCallbacks): Electron.Menu {
}
);
}
appMenu.push({
label: "Permissions",
submenu: [
{
label: "Request Audio Access",
click: (_, window) => {
getWindowWebContents(window)?.send("request-audio-access");
},
},
],
});
appMenu.push({
role: "quit",
});
Expand Down
12 changes: 0 additions & 12 deletions emain/preload.ts
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,3 @@ ipcRenderer.on("webcontentsid-from-blockid", (e, blockId, responseCh) => {
const wcId = webviewElem?.dataset?.webcontentsid;
ipcRenderer.send(responseCh, wcId);
});

ipcRenderer.on("request-audio-access", (e) => {
ipcRenderer.send("fe-log", "Requesting audio access");
navigator.mediaDevices
.getUserMedia({ audio: true })
.then(() => {
ipcRenderer.send("fe-log", "Audio access granted");
})
.catch((err) => {
ipcRenderer.send("fe-log", "Audio access denied: " + err);
});
});

0 comments on commit be3ec7e

Please sign in to comment.