提交 945e53a0 编写于 作者: C Christof Marti

Defer loading of keytar (fixes #33998)

上级 1488aafa
......@@ -6,22 +6,29 @@
import { TPromise } from 'vs/base/common/winjs.base';
import { ICredentialsService } from 'vs/platform/credentials/common/credentials';
import * as keytar from 'keytar';
export class CredentialsService implements ICredentialsService {
_serviceBrand: any;
readSecret(service: string, account: string): TPromise<string | undefined> {
return TPromise.wrap(keytar.getPassword(service, account))
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 TPromise.wrap(keytar.setPassword(service, account, secret));
return this.getKeytar()
.then(keytar => TPromise.wrap(keytar.setPassword(service, account, secret)));
}
deleteSecret(service: string, account: string): TPromise<boolean> {
return TPromise.wrap(keytar.deletePassword(service, account));
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'));
}
}
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册