提交 9ad5aeb6 编写于 作者: C Christof Marti

Remove credentials code (fixes #37822)

上级 c561784a
...@@ -35,9 +35,6 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry'; ...@@ -35,9 +35,6 @@ import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { NullTelemetryService } from 'vs/platform/telemetry/common/telemetryUtils'; import { NullTelemetryService } from 'vs/platform/telemetry/common/telemetryUtils';
import { ITelemetryAppenderChannel, TelemetryAppenderClient } from 'vs/platform/telemetry/common/telemetryIpc'; import { ITelemetryAppenderChannel, TelemetryAppenderClient } from 'vs/platform/telemetry/common/telemetryIpc';
import { TelemetryService, ITelemetryServiceConfig } from 'vs/platform/telemetry/common/telemetryService'; 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 { resolveCommonProperties, machineIdStorageKey, machineIdIpcChannel } from 'vs/platform/telemetry/node/commonProperties';
import { getDelayedChannel } from 'vs/base/parts/ipc/common/ipc'; import { getDelayedChannel } from 'vs/base/parts/ipc/common/ipc';
import product from 'vs/platform/node/product'; import product from 'vs/platform/node/product';
...@@ -288,7 +285,6 @@ export class CodeApplication { ...@@ -288,7 +285,6 @@ export class CodeApplication {
services.set(IWindowsMainService, new SyncDescriptor(WindowsManager)); services.set(IWindowsMainService, new SyncDescriptor(WindowsManager));
services.set(IWindowsService, new SyncDescriptor(WindowsService, this.sharedProcess)); services.set(IWindowsService, new SyncDescriptor(WindowsService, this.sharedProcess));
services.set(ILaunchService, new SyncDescriptor(LaunchService)); services.set(ILaunchService, new SyncDescriptor(LaunchService));
services.set(ICredentialsService, new SyncDescriptor(CredentialsService));
// Telemtry // Telemtry
if (this.environmentService.isBuilt && !this.environmentService.isExtensionDevelopment && !this.environmentService.args['disable-telemetry'] && !!product.enableTelemetry) { if (this.environmentService.isBuilt && !this.environmentService.isExtensionDevelopment && !this.environmentService.args['disable-telemetry'] && !!product.enableTelemetry) {
...@@ -346,9 +342,6 @@ export class CodeApplication { ...@@ -346,9 +342,6 @@ export class CodeApplication {
this.electronIpcServer.registerChannel('windows', windowsChannel); this.electronIpcServer.registerChannel('windows', windowsChannel);
this.sharedProcessClient.done(client => client.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 // Lifecycle
this.lifecycleService.ready(); this.lifecycleService.ready();
......
/*---------------------------------------------------------------------------------------------
* 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<ICredentialsService>('credentialsService');
export interface ICredentialsService {
_serviceBrand: any;
readSecret(service: string, account: string): TPromise<string | undefined>;
writeSecret(service: string, account: string, secret: string): TPromise<void>;
deleteSecret(service: string, account: string): TPromise<boolean>;
}
\ No newline at end of file
/*---------------------------------------------------------------------------------------------
* 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<string>;
call(command: 'writeSecret', credentials: ICredentialsArgs): TPromise<void>;
call(command: 'deleteSecret', credentials: ICredentialsArgs): TPromise<boolean>;
call(command: string, arg?: any): TPromise<any>;
}
export class CredentialsChannel implements ICredentialsChannel {
constructor(private service: ICredentialsService) { }
call(command: string, arg: ICredentialsArgs): TPromise<any> {
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<string | undefined> {
return this.channel.call('readSecret', { service, account });
}
writeSecret(service: string, account: string, secret: string): TPromise<void> {
return this.channel.call('writeSecret', { service, account, secret });
}
deleteSecret(service: string, account: string): TPromise<boolean> {
return this.channel.call('deleteSecret', { service, account });
}
}
\ No newline at end of file
/*---------------------------------------------------------------------------------------------
* 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<string | undefined> {
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<void> {
return this.getKeytar()
.then(keytar => TPromise.wrap(keytar.setPassword(service, account, secret)));
}
deleteSecret(service: string, account: string): TPromise<boolean> {
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'));
}
}
...@@ -17,7 +17,6 @@ import { LanguageConfigurationFileHandler } from 'vs/workbench/parts/codeEditor/ ...@@ -17,7 +17,6 @@ import { LanguageConfigurationFileHandler } from 'vs/workbench/parts/codeEditor/
// --- mainThread participants // --- mainThread participants
import './mainThreadCommands'; import './mainThreadCommands';
import './mainThreadConfiguration'; import './mainThreadConfiguration';
import './mainThreadCredentials';
import './mainThreadDebugService'; import './mainThreadDebugService';
import './mainThreadDecorations'; import './mainThreadDecorations';
import './mainThreadDiagnostics'; import './mainThreadDiagnostics';
......
/*---------------------------------------------------------------------------------------------
* 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<string | undefined> {
return this._credentialsService.readSecret(service, account);
}
$writeSecret(service: string, account: string, secret: string): Thenable<void> {
return this._credentialsService.writeSecret(service, account, secret);
}
$deleteSecret(service: string, account: string): Thenable<boolean> {
return this._credentialsService.deleteSecret(service, account);
}
}
...@@ -35,7 +35,6 @@ import { ExtHostLanguageFeatures } from 'vs/workbench/api/node/extHostLanguageFe ...@@ -35,7 +35,6 @@ import { ExtHostLanguageFeatures } from 'vs/workbench/api/node/extHostLanguageFe
import { ExtHostApiCommands } from 'vs/workbench/api/node/extHostApiCommands'; import { ExtHostApiCommands } from 'vs/workbench/api/node/extHostApiCommands';
import { ExtHostTask } from 'vs/workbench/api/node/extHostTask'; import { ExtHostTask } from 'vs/workbench/api/node/extHostTask';
import { ExtHostDebugService } from 'vs/workbench/api/node/extHostDebugService'; 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 { ExtHostWindow } from 'vs/workbench/api/node/extHostWindow';
import * as extHostTypes from 'vs/workbench/api/node/extHostTypes'; import * as extHostTypes from 'vs/workbench/api/node/extHostTypes';
import URI from 'vs/base/common/uri'; import URI from 'vs/base/common/uri';
...@@ -103,7 +102,6 @@ export function createApiFactory( ...@@ -103,7 +102,6 @@ export function createApiFactory(
const extHostTerminalService = threadService.set(ExtHostContext.ExtHostTerminalService, new ExtHostTerminalService(threadService)); const extHostTerminalService = threadService.set(ExtHostContext.ExtHostTerminalService, new ExtHostTerminalService(threadService));
const extHostSCM = threadService.set(ExtHostContext.ExtHostSCM, new ExtHostSCM(threadService, extHostCommands)); const extHostSCM = threadService.set(ExtHostContext.ExtHostSCM, new ExtHostSCM(threadService, extHostCommands));
const extHostTask = threadService.set(ExtHostContext.ExtHostTask, new ExtHostTask(threadService, extHostWorkspace)); 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)); const extHostWindow = threadService.set(ExtHostContext.ExtHostWindow, new ExtHostWindow(threadService));
threadService.set(ExtHostContext.ExtHostExtensionService, extensionService); threadService.set(ExtHostContext.ExtHostExtensionService, extensionService);
...@@ -519,21 +517,8 @@ export function createApiFactory( ...@@ -519,21 +517,8 @@ export function createApiFactory(
} }
}; };
// namespace: credentials
const credentials = {
readSecret(service: string, account: string): Thenable<string | undefined> {
return extHostCredentials.readSecret(service, account);
},
writeSecret(service: string, account: string, secret: string): Thenable<void> {
return extHostCredentials.writeSecret(service, account, secret);
},
deleteSecret(service: string, account: string): Thenable<boolean> {
return extHostCredentials.deleteSecret(service, account);
}
};
const api: typeof vscode = { return <typeof vscode>{
version: pkg.version, version: pkg.version,
// namespaces // namespaces
commands, commands,
...@@ -606,10 +591,6 @@ export function createApiFactory( ...@@ -606,10 +591,6 @@ export function createApiFactory(
FileChangeType: <any>FileChangeType, FileChangeType: <any>FileChangeType,
FileType: <any>FileType FileType: <any>FileType
}; };
if (extension.enableProposedApi && extension.isBuiltin) {
api['credentials'] = credentials;
}
return api;
}; };
} }
......
...@@ -417,12 +417,6 @@ export interface MainThreadDebugServiceShape extends IDisposable { ...@@ -417,12 +417,6 @@ export interface MainThreadDebugServiceShape extends IDisposable {
$appendDebugConsole(value: string): TPromise<any>; $appendDebugConsole(value: string): TPromise<any>;
} }
export interface MainThreadCredentialsShape extends IDisposable {
$readSecret(service: string, account: string): Thenable<string | undefined>;
$writeSecret(service: string, account: string, secret: string): Thenable<void>;
$deleteSecret(service: string, account: string): Thenable<boolean>;
}
export interface MainThreadWindowShape extends IDisposable { export interface MainThreadWindowShape extends IDisposable {
$getWindowVisibility(): TPromise<boolean>; $getWindowVisibility(): TPromise<boolean>;
} }
...@@ -641,9 +635,6 @@ export interface ExtHostDecorationsShape { ...@@ -641,9 +635,6 @@ export interface ExtHostDecorationsShape {
$providerDecorations(handle: number, uri: URI): TPromise<DecorationData>; $providerDecorations(handle: number, uri: URI): TPromise<DecorationData>;
} }
export interface ExtHostCredentialsShape {
}
export interface ExtHostWindowShape { export interface ExtHostWindowShape {
$onDidChangeWindowFocus(value: boolean): void; $onDidChangeWindowFocus(value: boolean): void;
} }
...@@ -677,7 +668,6 @@ export const MainContext = { ...@@ -677,7 +668,6 @@ export const MainContext = {
MainThreadExtensionService: createMainId<MainThreadExtensionServiceShape>('MainThreadExtensionService'), MainThreadExtensionService: createMainId<MainThreadExtensionServiceShape>('MainThreadExtensionService'),
MainThreadSCM: createMainId<MainThreadSCMShape>('MainThreadSCM'), MainThreadSCM: createMainId<MainThreadSCMShape>('MainThreadSCM'),
MainThreadTask: createMainId<MainThreadTaskShape>('MainThreadTask'), MainThreadTask: createMainId<MainThreadTaskShape>('MainThreadTask'),
MainThreadCredentials: createMainId<MainThreadCredentialsShape>('MainThreadCredentials'),
MainThreadWindow: createMainId<MainThreadWindowShape>('MainThreadWindow'), MainThreadWindow: createMainId<MainThreadWindowShape>('MainThreadWindow'),
}; };
...@@ -703,6 +693,5 @@ export const ExtHostContext = { ...@@ -703,6 +693,5 @@ export const ExtHostContext = {
ExtHostSCM: createExtId<ExtHostSCMShape>('ExtHostSCM'), ExtHostSCM: createExtId<ExtHostSCMShape>('ExtHostSCM'),
ExtHostTask: createExtId<ExtHostTaskShape>('ExtHostTask'), ExtHostTask: createExtId<ExtHostTaskShape>('ExtHostTask'),
ExtHostWorkspace: createExtId<ExtHostWorkspaceShape>('ExtHostWorkspace'), ExtHostWorkspace: createExtId<ExtHostWorkspaceShape>('ExtHostWorkspace'),
ExtHostCredentials: createExtId<ExtHostCredentialsShape>('ExtHostCredentials'),
ExtHostWindow: createExtId<ExtHostWindowShape>('ExtHostWindow'), ExtHostWindow: createExtId<ExtHostWindowShape>('ExtHostWindow'),
}; };
/*---------------------------------------------------------------------------------------------
* 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<string | undefined> {
return this._proxy.$readSecret(service, account);
}
writeSecret(service: string, account: string, secret: string): Thenable<void> {
return this._proxy.$writeSecret(service, account, secret);
}
deleteSecret(service: string, account: string): Thenable<boolean> {
return this._proxy.$deleteSecret(service, account);
}
}
...@@ -39,8 +39,6 @@ import { URLChannelClient } from 'vs/platform/url/common/urlIpc'; ...@@ -39,8 +39,6 @@ import { URLChannelClient } from 'vs/platform/url/common/urlIpc';
import { IURLService } from 'vs/platform/url/common/url'; import { IURLService } from 'vs/platform/url/common/url';
import { WorkspacesChannelClient } from 'vs/platform/workspaces/common/workspacesIpc'; import { WorkspacesChannelClient } from 'vs/platform/workspaces/common/workspacesIpc';
import { IWorkspacesService } from 'vs/platform/workspaces/common/workspaces'; 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'); import fs = require('fs');
gracefulFs.gracefulify(fs); // enable gracefulFs gracefulFs.gracefulify(fs); // enable gracefulFs
...@@ -202,9 +200,6 @@ function createMainProcessServices(mainProcessClient: ElectronIPCClient): Servic ...@@ -202,9 +200,6 @@ function createMainProcessServices(mainProcessClient: ElectronIPCClient): Servic
const workspacesChannel = mainProcessClient.getChannel('workspaces'); const workspacesChannel = mainProcessClient.getChannel('workspaces');
serviceCollection.set(IWorkspacesService, new WorkspacesChannelClient(workspacesChannel)); serviceCollection.set(IWorkspacesService, new WorkspacesChannelClient(workspacesChannel));
const credentialsChannel = mainProcessClient.getChannel('credentials');
serviceCollection.set(ICredentialsService, new CredentialsChannelClient(credentialsChannel));
return serviceCollection; return serviceCollection;
} }
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册