Merge commit 'be3e8236086165e5e45a5a10783823874b3f3ebd' as 'lib/vscode'

This commit is contained in:
Joe Previte
2020-12-15 15:52:33 -07:00
4649 changed files with 1311795 additions and 0 deletions

View File

@@ -0,0 +1,13 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
export interface ICommonEncryptionService {
readonly _serviceBrand: undefined;
encrypt(value: string): Promise<string>;
decrypt(value: string): Promise<string>;
}

View File

@@ -0,0 +1,45 @@
/*---------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { createDecorator } from 'vs/platform/instantiation/common/instantiation';
import { ICommonEncryptionService } from 'vs/platform/encryption/common/encryptionService';
export const IEncryptionMainService = createDecorator<IEncryptionMainService>('encryptionMainService');
export interface IEncryptionMainService extends ICommonEncryptionService { }
export interface Encryption {
encrypt(salt: string, value: string): Promise<string>;
decrypt(salt: string, value: string): Promise<string>;
}
export class EncryptionMainService implements ICommonEncryptionService {
declare readonly _serviceBrand: undefined;
constructor(
private machineId: string) {
}
private encryption(): Promise<Encryption> {
return new Promise((resolve, reject) => require(['vscode-encrypt'], resolve, reject));
}
async encrypt(value: string): Promise<string> {
try {
const encryption = await this.encryption();
return encryption.encrypt(this.machineId, value);
} catch (e) {
return value;
}
}
async decrypt(value: string): Promise<string> {
try {
const encryption = await this.encryption();
return encryption.decrypt(this.machineId, value);
} catch (e) {
return value;
}
}
}