mainThreadCredentials.ts 1.5 KB
Newer Older
C
Christof Marti 已提交
1 2 3 4 5 6
/*---------------------------------------------------------------------------------------------
 *  Copyright (c) Microsoft Corporation. All rights reserved.
 *  Licensed under the MIT License. See License.txt in the project root for license information.
 *--------------------------------------------------------------------------------------------*/
'use strict';

7
import { ExtHostContext, MainThreadCredentialsShape, ExtHostCredentialsShape, MainContext, IExtHostContext } from '../node/extHost.protocol';
C
Christof Marti 已提交
8
import { ICredentialsService } from 'vs/platform/credentials/common/credentials';
9
import { extHostNamedCustomer } from 'vs/workbench/api/electron-browser/extHostCustomers';
C
Christof Marti 已提交
10

11
@extHostNamedCustomer(MainContext.MainThreadCredentials)
12
export class MainThreadCredentials implements MainThreadCredentialsShape {
C
Christof Marti 已提交
13

14
	// @ts-ignore unused property
C
Christof Marti 已提交
15 16
	private _proxy: ExtHostCredentialsShape;

17 18 19 20 21 22 23 24
	constructor(
		extHostContext: IExtHostContext,
		@ICredentialsService private _credentialsService: ICredentialsService
	) {
		this._proxy = extHostContext.get(ExtHostContext.ExtHostCredentials);
	}

	public dispose(): void {
C
Christof Marti 已提交
25 26 27 28 29 30 31 32 33 34 35 36 37
	}

	$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);
	}
}