diff --git a/src/vs/code/electron-browser/sharedProcess/sharedProcessMain.ts b/src/vs/code/electron-browser/sharedProcess/sharedProcessMain.ts index 7d6c0efc302..9ddf3c0eca9 100644 --- a/src/vs/code/electron-browser/sharedProcess/sharedProcessMain.ts +++ b/src/vs/code/electron-browser/sharedProcess/sharedProcessMain.ts @@ -62,7 +62,7 @@ import { IAuthTokenService } from 'vs/platform/auth/common/auth'; import { AuthTokenService } from 'vs/platform/auth/common/authTokenService'; import { AuthTokenChannel } from 'vs/platform/auth/common/authTokenIpc'; import { ICredentialsService } from 'vs/platform/credentials/common/credentials'; -import { KeytarCredentialsService } from 'vs/workbench/services/credentials/node/credentialsService'; +import { KeytarCredentialsService } from 'vs/platform/credentials/node/credentialsService'; export interface ISharedProcessConfiguration { readonly machineId: string; diff --git a/src/vs/platform/auth/common/authTokenService.ts b/src/vs/platform/auth/common/authTokenService.ts index 04f556fbf47..3d5f5a5437b 100644 --- a/src/vs/platform/auth/common/authTokenService.ts +++ b/src/vs/platform/auth/common/authTokenService.ts @@ -9,8 +9,8 @@ import { ICredentialsService } from 'vs/platform/credentials/common/credentials' import { Disposable } from 'vs/base/common/lifecycle'; import { IProductService } from 'vs/platform/product/common/productService'; -const SERVICE_NAME = 'settingsSync'; -const ACCOUNT = 'Test'; +const SERVICE_NAME = 'VS Code'; +const ACCOUNT = 'MyAccount'; export class AuthTokenService extends Disposable implements IAuthTokenService { _serviceBrand: undefined; diff --git a/src/vs/platform/credentials/node/credentialsService.ts b/src/vs/platform/credentials/node/credentialsService.ts new file mode 100644 index 00000000000..8c876d5b759 --- /dev/null +++ b/src/vs/platform/credentials/node/credentialsService.ts @@ -0,0 +1,43 @@ +/*--------------------------------------------------------------------------------------------- + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for license information. + *--------------------------------------------------------------------------------------------*/ + +import { ICredentialsService } from 'vs/platform/credentials/common/credentials'; +import { IdleValue } from 'vs/base/common/async'; +import { registerSingleton } from 'vs/platform/instantiation/common/extensions'; + +type KeytarModule = typeof import('keytar'); +export class KeytarCredentialsService implements ICredentialsService { + + _serviceBrand: undefined; + + private readonly _keytar = new IdleValue>(() => import('keytar')); + + async getPassword(service: string, account: string): Promise { + const keytar = await this._keytar.getValue(); + return keytar.getPassword(service, account); + } + + async setPassword(service: string, account: string, password: string): Promise { + const keytar = await this._keytar.getValue(); + return keytar.setPassword(service, account, password); + } + + async deletePassword(service: string, account: string): Promise { + const keytar = await this._keytar.getValue(); + return keytar.deletePassword(service, account); + } + + async findPassword(service: string): Promise { + const keytar = await this._keytar.getValue(); + return keytar.findPassword(service); + } + + async findCredentials(service: string): Promise> { + const keytar = await this._keytar.getValue(); + return keytar.findCredentials(service); + } +} + +registerSingleton(ICredentialsService, KeytarCredentialsService, true); diff --git a/src/vs/workbench/workbench.desktop.main.ts b/src/vs/workbench/workbench.desktop.main.ts index 44e806231ba..d89f16cc5a4 100644 --- a/src/vs/workbench/workbench.desktop.main.ts +++ b/src/vs/workbench/workbench.desktop.main.ts @@ -46,7 +46,7 @@ import 'vs/workbench/services/extensionManagement/node/extensionManagementServic import 'vs/workbench/services/accessibility/node/accessibilityService'; import 'vs/workbench/services/remote/node/tunnelService'; import 'vs/workbench/services/backup/node/backupFileService'; -import 'vs/workbench/services/credentials/node/credentialsService'; +import 'vs/platform/credentials/node/credentialsService'; import 'vs/workbench/services/url/electron-browser/urlService'; import 'vs/workbench/services/workspaces/electron-browser/workspacesService'; import 'vs/workbench/services/workspaces/electron-browser/workspaceEditingService';