Revert "Merge from vscode 81d7885dc2e9dc617e1522697a2966bc4025a45d (#5949)" (#5983)

This reverts commit d15a3fcc98.
This commit is contained in:
Karl Burtram
2019-06-11 12:35:58 -07:00
committed by GitHub
parent 95a50b7892
commit 5a7562a37b
926 changed files with 11394 additions and 19540 deletions

View File

@@ -5,19 +5,27 @@
import { extHostNamedCustomer } from 'vs/workbench/api/common/extHostCustomers';
import { MainContext, MainThreadKeytarShape, IExtHostContext } from 'vs/workbench/api/common/extHost.protocol';
import { ICredentialsService } from 'vs/platform/credentials/common/credentials';
import { optional } from 'vs/platform/instantiation/common/instantiation';
interface IKeytarModule {
getPassword(service: string, account: string): Promise<string | null>;
setPassword(service: string, account: string, password: string): Promise<void>;
deletePassword(service: string, account: string): Promise<boolean>;
findPassword(service: string): Promise<string | null>;
}
@extHostNamedCustomer(MainContext.MainThreadKeytar)
export class MainThreadKeytar implements MainThreadKeytarShape {
private readonly _credentialsService?: ICredentialsService;
private _keytar: IKeytarModule | null;
constructor(
_extHostContext: IExtHostContext,
@optional(ICredentialsService) credentialsService: ICredentialsService,
extHostContext: IExtHostContext
) {
this._credentialsService = credentialsService;
try {
this._keytar = <IKeytarModule>require.__$__nodeRequire('keytar');
} catch (e) {
this._keytar = null;
}
}
dispose(): void {
@@ -25,28 +33,28 @@ export class MainThreadKeytar implements MainThreadKeytarShape {
}
async $getPassword(service: string, account: string): Promise<string | null> {
if (this._credentialsService) {
return this._credentialsService.getPassword(service, account);
if (this._keytar) {
return this._keytar.getPassword(service, account);
}
return null;
}
async $setPassword(service: string, account: string, password: string): Promise<void> {
if (this._credentialsService) {
return this._credentialsService.setPassword(service, account, password);
if (this._keytar) {
return this._keytar.setPassword(service, account, password);
}
}
async $deletePassword(service: string, account: string): Promise<boolean> {
if (this._credentialsService) {
return this._credentialsService.deletePassword(service, account);
if (this._keytar) {
return this._keytar.deletePassword(service, account);
}
return false;
}
async $findPassword(service: string): Promise<string | null> {
if (this._credentialsService) {
return this._credentialsService.findPassword(service);
if (this._keytar) {
return this._keytar.findPassword(service);
}
return null;
}