/*--------------------------------------------------------------------------------------------- * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the Source EULA. 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'; type KeytarModule = { getPassword(service: string, account: string): Promise; setPassword(service: string, account: string, password: string): Promise; deletePassword(service: string, account: string): Promise; findPassword(service: string): Promise; }; export class KeytarCredentialsService implements ICredentialsService { _serviceBrand: any; 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); } }