chore: add media and apple event entitlements

Fixes https://github.com/microsoft/vscode/issues/119787
Fixes https://github.com/microsoft/vscode/issues/95062
This commit is contained in:
deepak1556 2021-03-30 22:56:04 -07:00
parent 7a9151a29d
commit 325bea69a7
3 changed files with 29 additions and 0 deletions

View file

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

View file

@ -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() {
@ -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',
@ -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);

View file

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