another try at audio permissions (and more) for #1086 (#1192)

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)
This commit is contained in:
Mike Sawka 2024-11-01 12:17:19 -07:00 committed by GitHub
parent 55250de97a
commit be3ec7e841
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 40 additions and 25 deletions

View File

@ -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>

View File

@ -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: {

View File

@ -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",
});

View File

@ -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);
});
});