|
6 | 6 |
|
7 | 7 | import { TPromise } from 'vs/base/common/winjs.base'; |
8 | 8 | import { ICredentialsService } from 'vs/platform/credentials/common/credentials'; |
9 | | -import * as keytarType from 'keytar'; |
| 9 | +import * as keytar from 'keytar'; |
10 | 10 |
|
11 | 11 | export class CredentialsService implements ICredentialsService { |
12 | 12 |
|
13 | 13 | _serviceBrand: any; |
14 | 14 |
|
15 | | - private keytarPromise: TPromise<typeof keytarType>; |
16 | | - |
17 | 15 | readSecret(service: string, account: string): TPromise<string | undefined> { |
18 | | - return this.getKeytar() |
19 | | - .then(keytar => TPromise.wrap(keytar.getPassword(service, account))) |
| 16 | + return TPromise.wrap(keytar.getPassword(service, account)) |
20 | 17 | .then(result => result === null ? undefined : result); |
21 | 18 | } |
22 | 19 |
|
23 | 20 | writeSecret(service: string, account: string, secret: string): TPromise<void> { |
24 | | - return this.getKeytar() |
25 | | - .then(keytar => TPromise.wrap(keytar.setPassword(service, account, secret))); |
| 21 | + return TPromise.wrap(keytar.setPassword(service, account, secret)); |
26 | 22 | } |
27 | 23 |
|
28 | 24 | deleteSecret(service: string, account: string): TPromise<boolean> { |
29 | | - return this.getKeytar() |
30 | | - .then(keytar => TPromise.wrap(keytar.deletePassword(service, account))); |
31 | | - } |
32 | | - |
33 | | - private getKeytar(): TPromise<typeof keytarType> { |
34 | | - if (!this.keytarPromise) { |
35 | | - this.keytarPromise = new TPromise<typeof keytarType>((c, e) => { |
36 | | - require(['keytar'], c, e); |
37 | | - }); |
38 | | - } |
39 | | - return this.keytarPromise; |
| 25 | + return TPromise.wrap(keytar.deletePassword(service, account)); |
40 | 26 | } |
41 | 27 | } |
0 commit comments