Skip to content

Commit

Permalink
chore: add media and apple event entitlements
Browse files Browse the repository at this point in the history
Fixes #119787
Fixes #95062
  • Loading branch information
deepak1556 committed Mar 31, 2021
1 parent 7a9151a commit 325bea6
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 0 deletions.
6 changes: 6 additions & 0 deletions build/azure-pipelines/darwin/app-entitlements.plist
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,11 @@
<true/>
<key>com.apple.security.cs.allow-dyld-environment-variables</key>
<true/>
<key>com.apple.security.device.audio-input</key>
<true/>
<key>com.apple.security.device.camera</key>
<true/>
<key>com.apple.security.automation.apple-events</key>
<true/>
</dict>
</plist>
11 changes: 11 additions & 0 deletions build/darwin/sign.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,9 @@
'use strict';
Object.defineProperty(exports, "__esModule", { value: true });
const codesign = require("electron-osx-sign");
const fs = require("fs-extra");
const path = require("path");
const plist = require("plist");
const util = require("../lib/util");
const product = require("../../product.json");
async function main() {
Expand All @@ -25,6 +27,7 @@ async function main() {
const helperAppBaseName = product.nameShort;
const gpuHelperAppName = helperAppBaseName + ' Helper (GPU).app';
const rendererHelperAppName = helperAppBaseName + ' Helper (Renderer).app';
const infoPlistPath = path.resolve(appRoot, appName, 'Contents', 'Info.plist');
const defaultOpts = {
app: path.join(appRoot, appName),
platform: 'darwin',
Expand All @@ -46,6 +49,14 @@ async function main() {
} });
const gpuHelperOpts = Object.assign(Object.assign({}, defaultOpts), { app: path.join(appFrameworkPath, gpuHelperAppName), entitlements: path.join(baseDir, 'azure-pipelines', 'darwin', 'helper-gpu-entitlements.plist'), 'entitlements-inherit': path.join(baseDir, 'azure-pipelines', 'darwin', 'helper-gpu-entitlements.plist') });
const rendererHelperOpts = Object.assign(Object.assign({}, defaultOpts), { app: path.join(appFrameworkPath, rendererHelperAppName), entitlements: path.join(baseDir, 'azure-pipelines', 'darwin', 'helper-renderer-entitlements.plist'), 'entitlements-inherit': path.join(baseDir, 'azure-pipelines', 'darwin', 'helper-renderer-entitlements.plist') });
let infoPlistString = await fs.readFile(infoPlistPath, 'utf8');
let infoPlistJson = plist.parse(infoPlistString);
Object.assign(infoPlistJson, {
NSAppleEventsUsageDescription: 'An application in Visual Studio Code wants to use AppleScript.',
NSMicrophoneUsageDescription: 'An application in Visual Studio Code wants to use the Microphone.',
NSCameraUsageDescription: 'An application in Visual Studio Code wants to use the Camera.'
});
await fs.writeFile(infoPlistPath, plist.build(infoPlistJson), 'utf8');
await codesign.signAsync(gpuHelperOpts);
await codesign.signAsync(rendererHelperOpts);
await codesign.signAsync(appOpts);
Expand Down
12 changes: 12 additions & 0 deletions build/darwin/sign.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,9 @@
'use strict';

import * as codesign from 'electron-osx-sign';
import * as fs from 'fs-extra';
import * as path from 'path';
import * as plist from 'plist';
import * as util from '../lib/util';
import * as product from '../../product.json';

Expand All @@ -30,6 +32,7 @@ async function main(): Promise<void> {
const helperAppBaseName = product.nameShort;
const gpuHelperAppName = helperAppBaseName + ' Helper (GPU).app';
const rendererHelperAppName = helperAppBaseName + ' Helper (Renderer).app';
const infoPlistPath = path.resolve(appRoot, appName, 'Contents', 'Info.plist');

const defaultOpts: codesign.SignOptions = {
app: path.join(appRoot, appName),
Expand Down Expand Up @@ -68,6 +71,15 @@ async function main(): Promise<void> {
'entitlements-inherit': path.join(baseDir, 'azure-pipelines', 'darwin', 'helper-renderer-entitlements.plist'),
};

let infoPlistString = await fs.readFile(infoPlistPath, 'utf8');
let infoPlistJson = plist.parse(infoPlistString);
Object.assign(infoPlistJson, {
NSAppleEventsUsageDescription: 'An application in Visual Studio Code wants to use AppleScript.',
NSMicrophoneUsageDescription: 'An application in Visual Studio Code wants to use the Microphone.',
NSCameraUsageDescription: 'An application in Visual Studio Code wants to use the Camera.'
});
await fs.writeFile(infoPlistPath, plist.build(infoPlistJson), 'utf8');

await codesign.signAsync(gpuHelperOpts);
await codesign.signAsync(rendererHelperOpts);
await codesign.signAsync(appOpts as any);
Expand Down

0 comments on commit 325bea6

Please sign in to comment.