From 9ad5aeb690dbb968a4a76110dba18f8eb8c822d0 Mon Sep 17 00:00:00 2001 From: Christof Marti Date: Wed, 8 Nov 2017 11:11:13 -0800 Subject: [PATCH] Remove credentials code (fixes #37822) --- src/vs/code/electron-main/app.ts | 7 --- .../credentials/common/credentials.ts | 22 -------- .../credentials/node/credentialsIpc.ts | 56 ------------------- .../credentials/node/credentialsService.ts | 34 ----------- .../extensionHost.contribution.ts | 1 - .../electron-browser/mainThreadCredentials.ts | 37 ------------ src/vs/workbench/api/node/extHost.api.impl.ts | 21 +------ src/vs/workbench/api/node/extHost.protocol.ts | 11 ---- .../workbench/api/node/extHostCredentials.ts | 29 ---------- src/vs/workbench/electron-browser/main.ts | 5 -- 10 files changed, 1 insertion(+), 222 deletions(-) delete mode 100644 src/vs/platform/credentials/common/credentials.ts delete mode 100644 src/vs/platform/credentials/node/credentialsIpc.ts delete mode 100644 src/vs/platform/credentials/node/credentialsService.ts delete mode 100644 src/vs/workbench/api/electron-browser/mainThreadCredentials.ts delete mode 100644 src/vs/workbench/api/node/extHostCredentials.ts diff --git a/src/vs/code/electron-main/app.ts b/src/vs/code/electron-main/app.ts index 5683665f46b..2d1d702c040 100644 --- a/src/vs/code/electron-main/app.ts +++ b/src/vs/code/electron-main/app.ts @@ -35,9 +35,6 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; import { NullTelemetryService } from 'vs/platform/telemetry/common/telemetryUtils'; import { ITelemetryAppenderChannel, TelemetryAppenderClient } from 'vs/platform/telemetry/common/telemetryIpc'; import { TelemetryService, ITelemetryServiceConfig } from 'vs/platform/telemetry/common/telemetryService'; -import { ICredentialsService } from 'vs/platform/credentials/common/credentials'; -import { CredentialsService } from 'vs/platform/credentials/node/credentialsService'; -import { CredentialsChannel } from 'vs/platform/credentials/node/credentialsIpc'; import { resolveCommonProperties, machineIdStorageKey, machineIdIpcChannel } from 'vs/platform/telemetry/node/commonProperties'; import { getDelayedChannel } from 'vs/base/parts/ipc/common/ipc'; import product from 'vs/platform/node/product'; @@ -288,7 +285,6 @@ export class CodeApplication { services.set(IWindowsMainService, new SyncDescriptor(WindowsManager)); services.set(IWindowsService, new SyncDescriptor(WindowsService, this.sharedProcess)); services.set(ILaunchService, new SyncDescriptor(LaunchService)); - services.set(ICredentialsService, new SyncDescriptor(CredentialsService)); // Telemtry if (this.environmentService.isBuilt && !this.environmentService.isExtensionDevelopment && !this.environmentService.args['disable-telemetry'] && !!product.enableTelemetry) { @@ -346,9 +342,6 @@ export class CodeApplication { this.electronIpcServer.registerChannel('windows', windowsChannel); this.sharedProcessClient.done(client => client.registerChannel('windows', windowsChannel)); - const credentialsService = accessor.get(ICredentialsService); - const credentialsChannel = new CredentialsChannel(credentialsService); - this.electronIpcServer.registerChannel('credentials', credentialsChannel); // Lifecycle this.lifecycleService.ready(); diff --git a/src/vs/platform/credentials/common/credentials.ts b/src/vs/platform/credentials/common/credentials.ts deleted file mode 100644 index 07091e2b789..00000000000 --- a/src/vs/platform/credentials/common/credentials.ts +++ /dev/null @@ -1,22 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ -'use strict'; - -import { TPromise } from 'vs/base/common/winjs.base'; -import { createDecorator } from 'vs/platform/instantiation/common/instantiation'; - -export const ICredentialsService = createDecorator('credentialsService'); - -export interface ICredentialsService { - - _serviceBrand: any; - - readSecret(service: string, account: string): TPromise; - - writeSecret(service: string, account: string, secret: string): TPromise; - - deleteSecret(service: string, account: string): TPromise; - -} \ No newline at end of file diff --git a/src/vs/platform/credentials/node/credentialsIpc.ts b/src/vs/platform/credentials/node/credentialsIpc.ts deleted file mode 100644 index 0d1758c03f7..00000000000 --- a/src/vs/platform/credentials/node/credentialsIpc.ts +++ /dev/null @@ -1,56 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ - -'use strict'; - -import { TPromise } from 'vs/base/common/winjs.base'; -import { IChannel } from 'vs/base/parts/ipc/common/ipc'; -import { ICredentialsService } from 'vs/platform/credentials/common/credentials'; - -export interface ICredentialsArgs { - service: string; - account: string; - secret?: string; -} - -export interface ICredentialsChannel extends IChannel { - call(command: 'readSecret', credentials: ICredentialsArgs): TPromise; - call(command: 'writeSecret', credentials: ICredentialsArgs): TPromise; - call(command: 'deleteSecret', credentials: ICredentialsArgs): TPromise; - call(command: string, arg?: any): TPromise; -} - -export class CredentialsChannel implements ICredentialsChannel { - - constructor(private service: ICredentialsService) { } - - call(command: string, arg: ICredentialsArgs): TPromise { - switch (command) { - case 'readSecret': return this.service.readSecret(arg.service, arg.account); - case 'writeSecret': return this.service.writeSecret(arg.service, arg.account, arg.secret); - case 'deleteSecret': return this.service.deleteSecret(arg.service, arg.account); - } - return undefined; - } -} - -export class CredentialsChannelClient implements ICredentialsService { - - _serviceBrand: any; - - constructor(private channel: ICredentialsChannel) { } - - readSecret(service: string, account: string): TPromise { - return this.channel.call('readSecret', { service, account }); - } - - writeSecret(service: string, account: string, secret: string): TPromise { - return this.channel.call('writeSecret', { service, account, secret }); - } - - deleteSecret(service: string, account: string): TPromise { - return this.channel.call('deleteSecret', { service, account }); - } -} \ No newline at end of file diff --git a/src/vs/platform/credentials/node/credentialsService.ts b/src/vs/platform/credentials/node/credentialsService.ts deleted file mode 100644 index f3aa0dd3121..00000000000 --- a/src/vs/platform/credentials/node/credentialsService.ts +++ /dev/null @@ -1,34 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ -'use strict'; - -import { TPromise } from 'vs/base/common/winjs.base'; -import { ICredentialsService } from 'vs/platform/credentials/common/credentials'; - -export class CredentialsService implements ICredentialsService { - - _serviceBrand: any; - - readSecret(service: string, account: string): TPromise { - return this.getKeytar() - .then(keytar => TPromise.wrap(keytar.getPassword(service, account))) - .then(result => result === null ? undefined : result); - } - - writeSecret(service: string, account: string, secret: string): TPromise { - return this.getKeytar() - .then(keytar => TPromise.wrap(keytar.setPassword(service, account, secret))); - } - - deleteSecret(service: string, account: string): TPromise { - return this.getKeytar() - .then(keytar => TPromise.wrap(keytar.deletePassword(service, account))); - } - - private getKeytar() { - // Avoids https://github.com/Microsoft/vscode/issues/33998 - return TPromise.wrap(import('keytar')); - } -} diff --git a/src/vs/workbench/api/electron-browser/extensionHost.contribution.ts b/src/vs/workbench/api/electron-browser/extensionHost.contribution.ts index 2940cda2e51..6fff94f17b5 100644 --- a/src/vs/workbench/api/electron-browser/extensionHost.contribution.ts +++ b/src/vs/workbench/api/electron-browser/extensionHost.contribution.ts @@ -17,7 +17,6 @@ import { LanguageConfigurationFileHandler } from 'vs/workbench/parts/codeEditor/ // --- mainThread participants import './mainThreadCommands'; import './mainThreadConfiguration'; -import './mainThreadCredentials'; import './mainThreadDebugService'; import './mainThreadDecorations'; import './mainThreadDiagnostics'; diff --git a/src/vs/workbench/api/electron-browser/mainThreadCredentials.ts b/src/vs/workbench/api/electron-browser/mainThreadCredentials.ts deleted file mode 100644 index fc728e9f5df..00000000000 --- a/src/vs/workbench/api/electron-browser/mainThreadCredentials.ts +++ /dev/null @@ -1,37 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ -'use strict'; - -import { ExtHostContext, MainThreadCredentialsShape, ExtHostCredentialsShape, MainContext, IExtHostContext } from '../node/extHost.protocol'; -import { ICredentialsService } from 'vs/platform/credentials/common/credentials'; -import { extHostNamedCustomer } from 'vs/workbench/api/electron-browser/extHostCustomers'; - -@extHostNamedCustomer(MainContext.MainThreadCredentials) -export class MainThreadCredentials implements MainThreadCredentialsShape { - - // @ts-ignore unused property - private _proxy: ExtHostCredentialsShape; - - constructor( - extHostContext: IExtHostContext, - @ICredentialsService private _credentialsService: ICredentialsService - ) { - this._proxy = extHostContext.get(ExtHostContext.ExtHostCredentials); - } - - public dispose(): void { - } - - $readSecret(service: string, account: string): Thenable { - return this._credentialsService.readSecret(service, account); - } - - $writeSecret(service: string, account: string, secret: string): Thenable { - return this._credentialsService.writeSecret(service, account, secret); - } - $deleteSecret(service: string, account: string): Thenable { - return this._credentialsService.deleteSecret(service, account); - } -} diff --git a/src/vs/workbench/api/node/extHost.api.impl.ts b/src/vs/workbench/api/node/extHost.api.impl.ts index 275da883ed8..dba907a08fb 100644 --- a/src/vs/workbench/api/node/extHost.api.impl.ts +++ b/src/vs/workbench/api/node/extHost.api.impl.ts @@ -35,7 +35,6 @@ import { ExtHostLanguageFeatures } from 'vs/workbench/api/node/extHostLanguageFe import { ExtHostApiCommands } from 'vs/workbench/api/node/extHostApiCommands'; import { ExtHostTask } from 'vs/workbench/api/node/extHostTask'; import { ExtHostDebugService } from 'vs/workbench/api/node/extHostDebugService'; -import { ExtHostCredentials } from 'vs/workbench/api/node/extHostCredentials'; import { ExtHostWindow } from 'vs/workbench/api/node/extHostWindow'; import * as extHostTypes from 'vs/workbench/api/node/extHostTypes'; import URI from 'vs/base/common/uri'; @@ -103,7 +102,6 @@ export function createApiFactory( const extHostTerminalService = threadService.set(ExtHostContext.ExtHostTerminalService, new ExtHostTerminalService(threadService)); const extHostSCM = threadService.set(ExtHostContext.ExtHostSCM, new ExtHostSCM(threadService, extHostCommands)); const extHostTask = threadService.set(ExtHostContext.ExtHostTask, new ExtHostTask(threadService, extHostWorkspace)); - const extHostCredentials = threadService.set(ExtHostContext.ExtHostCredentials, new ExtHostCredentials(threadService)); const extHostWindow = threadService.set(ExtHostContext.ExtHostWindow, new ExtHostWindow(threadService)); threadService.set(ExtHostContext.ExtHostExtensionService, extensionService); @@ -519,21 +517,8 @@ export function createApiFactory( } }; - // namespace: credentials - const credentials = { - readSecret(service: string, account: string): Thenable { - return extHostCredentials.readSecret(service, account); - }, - writeSecret(service: string, account: string, secret: string): Thenable { - return extHostCredentials.writeSecret(service, account, secret); - }, - deleteSecret(service: string, account: string): Thenable { - return extHostCredentials.deleteSecret(service, account); - } - }; - - const api: typeof vscode = { + return { version: pkg.version, // namespaces commands, @@ -606,10 +591,6 @@ export function createApiFactory( FileChangeType: FileChangeType, FileType: FileType }; - if (extension.enableProposedApi && extension.isBuiltin) { - api['credentials'] = credentials; - } - return api; }; } diff --git a/src/vs/workbench/api/node/extHost.protocol.ts b/src/vs/workbench/api/node/extHost.protocol.ts index 54227f1d4f2..11297cfa814 100644 --- a/src/vs/workbench/api/node/extHost.protocol.ts +++ b/src/vs/workbench/api/node/extHost.protocol.ts @@ -417,12 +417,6 @@ export interface MainThreadDebugServiceShape extends IDisposable { $appendDebugConsole(value: string): TPromise; } -export interface MainThreadCredentialsShape extends IDisposable { - $readSecret(service: string, account: string): Thenable; - $writeSecret(service: string, account: string, secret: string): Thenable; - $deleteSecret(service: string, account: string): Thenable; -} - export interface MainThreadWindowShape extends IDisposable { $getWindowVisibility(): TPromise; } @@ -641,9 +635,6 @@ export interface ExtHostDecorationsShape { $providerDecorations(handle: number, uri: URI): TPromise; } -export interface ExtHostCredentialsShape { -} - export interface ExtHostWindowShape { $onDidChangeWindowFocus(value: boolean): void; } @@ -677,7 +668,6 @@ export const MainContext = { MainThreadExtensionService: createMainId('MainThreadExtensionService'), MainThreadSCM: createMainId('MainThreadSCM'), MainThreadTask: createMainId('MainThreadTask'), - MainThreadCredentials: createMainId('MainThreadCredentials'), MainThreadWindow: createMainId('MainThreadWindow'), }; @@ -703,6 +693,5 @@ export const ExtHostContext = { ExtHostSCM: createExtId('ExtHostSCM'), ExtHostTask: createExtId('ExtHostTask'), ExtHostWorkspace: createExtId('ExtHostWorkspace'), - ExtHostCredentials: createExtId('ExtHostCredentials'), ExtHostWindow: createExtId('ExtHostWindow'), }; diff --git a/src/vs/workbench/api/node/extHostCredentials.ts b/src/vs/workbench/api/node/extHostCredentials.ts deleted file mode 100644 index 26f31d13803..00000000000 --- a/src/vs/workbench/api/node/extHostCredentials.ts +++ /dev/null @@ -1,29 +0,0 @@ -/*--------------------------------------------------------------------------------------------- - * Copyright (c) Microsoft Corporation. All rights reserved. - * Licensed under the MIT License. See License.txt in the project root for license information. - *--------------------------------------------------------------------------------------------*/ -'use strict'; - -import { MainContext, MainThreadCredentialsShape, ExtHostCredentialsShape, IMainContext } from 'vs/workbench/api/node/extHost.protocol'; - - -export class ExtHostCredentials implements ExtHostCredentialsShape { - - private _proxy: MainThreadCredentialsShape; - - constructor(mainContext: IMainContext) { - this._proxy = mainContext.get(MainContext.MainThreadCredentials); - } - - readSecret(service: string, account: string): Thenable { - return this._proxy.$readSecret(service, account); - } - - writeSecret(service: string, account: string, secret: string): Thenable { - return this._proxy.$writeSecret(service, account, secret); - } - - deleteSecret(service: string, account: string): Thenable { - return this._proxy.$deleteSecret(service, account); - } -} diff --git a/src/vs/workbench/electron-browser/main.ts b/src/vs/workbench/electron-browser/main.ts index 648c9992a64..7b3740aff84 100644 --- a/src/vs/workbench/electron-browser/main.ts +++ b/src/vs/workbench/electron-browser/main.ts @@ -39,8 +39,6 @@ import { URLChannelClient } from 'vs/platform/url/common/urlIpc'; import { IURLService } from 'vs/platform/url/common/url'; import { WorkspacesChannelClient } from 'vs/platform/workspaces/common/workspacesIpc'; import { IWorkspacesService } from 'vs/platform/workspaces/common/workspaces'; -import { ICredentialsService } from 'vs/platform/credentials/common/credentials'; -import { CredentialsChannelClient } from 'vs/platform/credentials/node/credentialsIpc'; import fs = require('fs'); gracefulFs.gracefulify(fs); // enable gracefulFs @@ -202,9 +200,6 @@ function createMainProcessServices(mainProcessClient: ElectronIPCClient): Servic const workspacesChannel = mainProcessClient.getChannel('workspaces'); serviceCollection.set(IWorkspacesService, new WorkspacesChannelClient(workspacesChannel)); - const credentialsChannel = mainProcessClient.getChannel('credentials'); - serviceCollection.set(ICredentialsService, new CredentialsChannelClient(credentialsChannel)); - return serviceCollection; } -- GitLab