Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add plist with permissions for mac #80

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .editorconfig
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ tab_width = 2
[*.json]
tab_width = 2

[*.html]
[{*.html,*.xml,*.plist}]
tab_width = 2

[{*.markdown,*.md}]
Expand Down
16 changes: 16 additions & 0 deletions build/mac/entitlements.mac.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?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>
<key>com.apple.security.device.audio-input</key>
<true/>
<key>com.apple.security.device.microphone</key>
<true/>
<key>com.apple.security.device.camera</key>
<true/>
<key>com.apple.security.files.user-selected.read-write</key>
<true/>
<key>com.apple.security.network.client</key>
<true/>
</dict>
</plist>
1 change: 1 addition & 0 deletions forge.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ require('dotenv').config()
module.exports = {
packagerConfig: {
icon: './img/icons/icon',
extendInfo: './build/mac/entitlements.mac.plist',
},
rebuildConfig: {},
makers: [
Expand Down
32 changes: 32 additions & 0 deletions src/app/permissionHandlers.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/*
* @copyright Copyright (c) 2023 Grigorii Shartsev <[email protected]>
*
* @author Grigorii Shartsev <[email protected]>
*
* @license GNU AGPL version 3 or any later version
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as
* published by the Free Software Foundation, either version 3 of the
* License, or (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/

/**
* @implements {Parameters<typeof import('electron').session.setPermissionRequestHandler>[0]}
*/
function permissionHandler(webContents, permission, callback, details) {
// TODO: store permissions in a local user config
callback(true)
}

module.exports = {
permissionHandler,
}
4 changes: 4 additions & 0 deletions src/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ const {
dialog,
BrowserWindow,
ipcMain,
session,
} = require('electron')
const {
default: installExtension,
Expand All @@ -41,6 +42,7 @@ const {
const { getOs, isLinux } = require('./shared/os.utils.js')
const { setupMenu } = require('./app/app.menu.js')
const { createHelpWindow } = require('./help/help.window.js')
const { permissionHandler } = require('./app/permissionHandlers.js')

/**
* Separate production and development instances, including application and user data
Expand Down Expand Up @@ -175,6 +177,7 @@ app.whenReady().then(async () => {
mainWindow.close()
mainWindow = createTalkWindow()
createMainWindow = createTalkWindow
session.defaultSession.setPermissionRequestHandler(permissionHandler)
})

ipcMain.handle('authentication:logout', async (event) => {
Expand All @@ -186,6 +189,7 @@ app.whenReady().then(async () => {
mainWindow.once('ready-to-show', () => {
mainWindow.show()
})
session.defaultSession.setPermissionRequestHandler(null)
}
})

Expand Down