diff --git a/build/azure-pipelines/common/sign-win32.js b/build/azure-pipelines/common/sign-win32.js new file mode 100644 index 0000000000000000000000000000000000000000..3cc503a8e6b9ba170eae7ef6f5ffe196ef81d9c4 --- /dev/null +++ b/build/azure-pipelines/common/sign-win32.js @@ -0,0 +1,17 @@ +"use strict"; +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +Object.defineProperty(exports, "__esModule", { value: true }); +const sign_1 = require("./sign"); +const path = require("path"); +(0, sign_1.main)([ + process.env['EsrpCliDllPath'], + 'windows', + process.env['ESRPPKI'], + process.env['ESRPAADUsername'], + process.env['ESRPAADPassword'], + path.dirname(process.argv[2]), + path.basename(process.argv[2]) +]); diff --git a/build/azure-pipelines/common/sign.js b/build/azure-pipelines/common/sign.js new file mode 100644 index 0000000000000000000000000000000000000000..94ddf5fe2463d3aa1967d8b28c52558d13a55101 --- /dev/null +++ b/build/azure-pipelines/common/sign.js @@ -0,0 +1,77 @@ +"use strict"; +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ +Object.defineProperty(exports, "__esModule", { value: true }); +exports.main = void 0; +const cp = require("child_process"); +const fs = require("fs"); +const tmp = require("tmp"); +const crypto = require("crypto"); +function getParams(type) { + switch (type) { + case 'windows': + return '[{"keyCode":"CP-230012","operationSetCode":"SigntoolSign","parameters":[{"parameterName":"OpusName","parameterValue":"VS Code"},{"parameterName":"OpusInfo","parameterValue":"https://code.visualstudio.com/"},{"parameterName":"Append","parameterValue":"/as"},{"parameterName":"FileDigest","parameterValue":"/fd \\"SHA256\\""},{"parameterName":"PageHash","parameterValue":"/NPH"},{"parameterName":"TimeStamp","parameterValue":"/tr \\"http://rfc3161.gtm.corp.microsoft.com/TSS/HttpTspServer\\" /td sha256"}],"toolName":"sign","toolVersion":"1.0"},{"keyCode":"CP-230012","operationSetCode":"SigntoolVerify","parameters":[{"parameterName":"VerifyAll","parameterValue":"/all"}],"toolName":"sign","toolVersion":"1.0"}]'; + case 'rpm': + return '[{ "keyCode": "CP-450779-Pgp", "operationSetCode": "LinuxSign", "parameters": [], "toolName": "sign", "toolVersion": "1.0" }]'; + case 'darwin-sign': + return '[{"keyCode":"CP-401337-Apple","operationSetCode":"MacAppDeveloperSign","parameters":[{"parameterName":"Hardening","parameterValue":"--options=runtime"}],"toolName":"sign","toolVersion":"1.0"}]'; + case 'darwin-notarize': + return '[{"keyCode":"CP-401337-Apple","operationSetCode":"MacAppNotarize","parameters":[{"parameterName":"BundleId","parameterValue":"$(BundleIdentifier)"}],"toolName":"sign","toolVersion":"1.0"}]'; + default: + throw new Error(`Sign type ${type} not found`); + } +} +function main([esrpCliPath, type, cert, username, password, folderPath, pattern]) { + tmp.setGracefulCleanup(); + const patternPath = tmp.tmpNameSync(); + fs.writeFileSync(patternPath, pattern); + const paramsPath = tmp.tmpNameSync(); + fs.writeFileSync(paramsPath, getParams(type)); + const keyFile = tmp.tmpNameSync(); + const key = crypto.randomBytes(32); + const iv = crypto.randomBytes(16); + fs.writeFileSync(keyFile, JSON.stringify({ key: key.toString('hex'), iv: iv.toString('hex') })); + const clientkeyPath = tmp.tmpNameSync(); + const clientkeyCypher = crypto.createCipheriv('aes-256-cbc', key, iv); + let clientkey = clientkeyCypher.update(password, 'utf8', 'hex'); + clientkey += clientkeyCypher.final('hex'); + fs.writeFileSync(clientkeyPath, clientkey); + const clientcertPath = tmp.tmpNameSync(); + const clientcertCypher = crypto.createCipheriv('aes-256-cbc', key, iv); + let clientcert = clientcertCypher.update(cert, 'utf8', 'hex'); + clientcert += clientcertCypher.final('hex'); + fs.writeFileSync(clientcertPath, clientcert); + const args = [ + esrpCliPath, + 'vsts.sign', + '-a', username, + '-k', clientkeyPath, + '-z', clientcertPath, + '-f', folderPath, + '-p', patternPath, + '-u', 'false', + '-x', 'regularSigning', + '-b', 'input.json', + '-l', 'AzSecPack_PublisherPolicyProd.xml', + '-y', 'inlineSignParams', + '-j', paramsPath, + '-c', '9997', + '-t', '120', + '-g', '10', + '-v', 'Tls12', + '-s', 'https://api.esrp.microsoft.com/api/v1', + '-m', '0', + '-o', 'Microsoft', + '-i', 'https://www.microsoft.com', + '-n', '5', + '-r', 'true', + '-e', keyFile, + ]; + cp.spawnSync('dotnet', args, { stdio: 'inherit' }); +} +exports.main = main; +if (require.main === module) { + main(process.argv.slice(2)); +} diff --git a/build/lib/eslint/vscode-dts-literal-or-types.js b/build/lib/eslint/vscode-dts-literal-or-types.js index e07dfc6de28fe6db66a90d0e6613c05a4ff368e2..cd47753cb177157860ab881e35b97495b97cc81a 100644 --- a/build/lib/eslint/vscode-dts-literal-or-types.js +++ b/build/lib/eslint/vscode-dts-literal-or-types.js @@ -12,9 +12,8 @@ module.exports = new class ApiLiteralOrTypes { } create(context) { return { - ['TSTypeAnnotation TSUnionType TSLiteralType']: (node) => { - var _a; - if (((_a = node.literal) === null || _a === void 0 ? void 0 : _a.type) === 'TSNullKeyword') { + ['TSTypeAnnotation TSUnionType']: (node) => { + if (!node.types.every(value => value.type === 'TSLiteralType')) { return; } context.report({ diff --git a/build/lib/eslint/vscode-dts-literal-or-types.ts b/build/lib/eslint/vscode-dts-literal-or-types.ts index fe4befd84e79453536f4ce3abe7038cabe4f3389..01d1d1d8586340edaa09ce9fc61d4910fe2dc17e 100644 --- a/build/lib/eslint/vscode-dts-literal-or-types.ts +++ b/build/lib/eslint/vscode-dts-literal-or-types.ts @@ -4,6 +4,7 @@ *--------------------------------------------------------------------------------------------*/ import * as eslint from 'eslint'; +import { TSESTree } from '@typescript-eslint/experimental-utils'; export = new class ApiLiteralOrTypes implements eslint.Rule.RuleModule { @@ -14,14 +15,13 @@ export = new class ApiLiteralOrTypes implements eslint.Rule.RuleModule { create(context: eslint.Rule.RuleContext): eslint.Rule.RuleListener { return { - ['TSTypeAnnotation TSUnionType TSLiteralType']: (node: any) => { - if (node.literal?.type === 'TSNullKeyword') { - return; + ['TSTypeAnnotation TSUnionType']: (node: any) => { + if ((node).types.every(value => value.type === 'TSLiteralType')) { + context.report({ + node: node, + messageId: 'useEnum' + }); } - context.report({ - node: node, - messageId: 'useEnum' - }); } }; } diff --git a/build/lib/extensions.js b/build/lib/extensions.js index 271a1464e6267589928d9a3d2d55129ddc570da5..bee77deefcc47952bb3595ee3f8c15888cb309a8 100644 --- a/build/lib/extensions.js +++ b/build/lib/extensions.js @@ -218,11 +218,27 @@ const webBuiltInExtensions = productJson.webBuiltInExtensions || []; * Loosely based on `getExtensionKind` from `src/vs/workbench/services/extensions/common/extensionManifestPropertiesService.ts` */ function isWebExtension(manifest) { + if (Boolean(manifest.browser)) { + return true; + } + if (Boolean(manifest.main)) { + return false; + } + // neither browser nor main if (typeof manifest.extensionKind !== 'undefined') { const extensionKind = Array.isArray(manifest.extensionKind) ? manifest.extensionKind : [manifest.extensionKind]; - return (extensionKind.indexOf('web') >= 0); + if (extensionKind.indexOf('web') >= 0) { + return true; + } + } + if (typeof manifest.contributes !== 'undefined') { + for (const id of ['debuggers', 'terminal', 'typescriptServerPlugins']) { + if (manifest.contributes.hasOwnProperty(id)) { + return false; + } + } } - return (!Boolean(manifest.main) || Boolean(manifest.browser)); + return true; } function packageLocalExtensionsStream(forWeb) { const localExtensionsDescriptions = (glob.sync('extensions/*/package.json') diff --git a/build/lib/util.js b/build/lib/util.js index 6821ff165b08fdc2be665c5eb67d4c907e69f9f0..07523eb53430dc2f598b920fc5a7d3f242e3439a 100644 --- a/build/lib/util.js +++ b/build/lib/util.js @@ -4,7 +4,7 @@ *--------------------------------------------------------------------------------------------*/ 'use strict'; Object.defineProperty(exports, "__esModule", { value: true }); -exports.buildWebNodePaths = exports.getElectronVersion = exports.streamToPromise = exports.versionStringToNumber = exports.filter = exports.rebase = exports.getVersion = exports.ensureDir = exports.rreddir = exports.rimraf = exports.rewriteSourceMappingURL = exports.stripSourceMappingURL = exports.loadSourcemaps = exports.cleanNodeModules = exports.skipDirectories = exports.toFileUri = exports.setExecutableBit = exports.fixWin32DirectoryPermissions = exports.incremental = void 0; +exports.buildWebNodePaths = exports.acquireWebNodePaths = exports.getElectronVersion = exports.streamToPromise = exports.versionStringToNumber = exports.filter = exports.rebase = exports.getVersion = exports.ensureDir = exports.rreddir = exports.rimraf = exports.rewriteSourceMappingURL = exports.stripSourceMappingURL = exports.loadSourcemaps = exports.cleanNodeModules = exports.skipDirectories = exports.toFileUri = exports.setExecutableBit = exports.fixWin32DirectoryPermissions = exports.incremental = void 0; const es = require("event-stream"); const debounce = require("debounce"); const _filter = require("gulp-filter"); @@ -274,31 +274,37 @@ function getElectronVersion() { return target; } exports.getElectronVersion = getElectronVersion; +function acquireWebNodePaths() { + var _a; + const root = path.join(__dirname, '..', '..'); + const webPackageJSON = path.join(root, '/remote/web', 'package.json'); + const webPackages = JSON.parse(fs.readFileSync(webPackageJSON, 'utf8')).dependencies; + const nodePaths = {}; + for (const key of Object.keys(webPackages)) { + const packageJSON = path.join(root, 'node_modules', key, 'package.json'); + const packageData = JSON.parse(fs.readFileSync(packageJSON, 'utf8')); + let entryPoint = (_a = packageData.browser) !== null && _a !== void 0 ? _a : packageData.main; + // On rare cases a package doesn't have an entrypoint so we assume it has a dist folder with a min.js + if (!entryPoint) { + console.warn(`No entry point for ${key} assuming dist/${key}.min.js`); + entryPoint = `dist/${key}.min.js`; + } + // Remove any starting path information so it's all relative info + if (entryPoint.startsWith('./')) { + entryPoint = entryPoint.substr(2); + } + else if (entryPoint.startsWith('/')) { + entryPoint = entryPoint.substr(1); + } + nodePaths[key] = entryPoint; + } + return nodePaths; +} +exports.acquireWebNodePaths = acquireWebNodePaths; function buildWebNodePaths(outDir) { const result = () => new Promise((resolve, _) => { - var _a; const root = path.join(__dirname, '..', '..'); - const webPackageJSON = path.join(root, '/remote/web', 'package.json'); - const webPackages = JSON.parse(fs.readFileSync(webPackageJSON, 'utf8')).dependencies; - const nodePaths = {}; - for (const key of Object.keys(webPackages)) { - const packageJSON = path.join(root, 'node_modules', key, 'package.json'); - const packageData = JSON.parse(fs.readFileSync(packageJSON, 'utf8')); - let entryPoint = (_a = packageData.browser) !== null && _a !== void 0 ? _a : packageData.main; - // On rare cases a package doesn't have an entrypoint so we assume it has a dist folder with a min.js - if (!entryPoint) { - console.warn(`No entry point for ${key} assuming dist/${key}.min.js`); - entryPoint = `dist/${key}.min.js`; - } - // Remove any starting path information so it's all relative info - if (entryPoint.startsWith('./')) { - entryPoint = entryPoint.substr(2); - } - else if (entryPoint.startsWith('/')) { - entryPoint = entryPoint.substr(1); - } - nodePaths[key] = entryPoint; - } + const nodePaths = acquireWebNodePaths(); // Now we write the node paths to out/vs const outDirectory = path.join(root, outDir, 'vs'); fs.mkdirSync(outDirectory, { recursive: true }); diff --git a/src/vs/vscode.proposed.d.ts b/src/vs/vscode.proposed.d.ts index ec071e31653fb9fa85b01f6cb2c961acd72ba3fc..9d726a5091d060ab2a84f26f1a8fce58b9e0707d 100644 --- a/src/vs/vscode.proposed.d.ts +++ b/src/vs/vscode.proposed.d.ts @@ -179,8 +179,7 @@ declare module 'vscode' { * @param options The {@link AuthenticationGetSessionOptions} to use * @returns A thenable that resolves to an authentication session */ - export function getSession(providerId: string, scopes: readonly string[], options: AuthenticationGetSessionOptions & { forceNewSession: true }): Thenable; - export function getSession(providerId: string, scopes: readonly string[], options: AuthenticationGetSessionOptions & { forceNewSession: { detail: string } }): Thenable; + export function getSession(providerId: string, scopes: readonly string[], options: AuthenticationGetSessionOptions & { forceNewSession: true | { detail: string } }): Thenable; } export namespace workspace {