|
| 1 | +// Definitions by: Milan Burda <https://github.com/miniak>, Brendan Forster <https://github.com/shiftkey>, Hari Juturu <https://github.com/juturu> |
| 2 | +// Adapted from DefinitelyTyped: https://github.com/DefinitelyTyped/DefinitelyTyped/blob/master/types/keytar/index.d.ts |
| 3 | + |
| 4 | +// NOTE@coder: copy in from keytar upstream and modify |
| 5 | +// keytar pulls in libsecret-dev, which we want to avoid, |
| 6 | +// and vscode has a 'fallback' for web use that redirects keytar calls to use localStorage. |
| 7 | +// Keep types in here for it to compile correctly. |
| 8 | + |
| 9 | +declare module 'keytar' { |
| 10 | + /** |
| 11 | + * Get the stored password for the service and account. |
| 12 | + * |
| 13 | + * @param service The string service name. |
| 14 | + * @param account The string account name. |
| 15 | + * |
| 16 | + * @returns A promise for the password string. |
| 17 | + */ |
| 18 | + export function getPassword(service: string, account: string): Promise<string | null>; |
| 19 | + |
| 20 | + /** |
| 21 | + * Add the password for the service and account to the keychain. |
| 22 | + * |
| 23 | + * @param service The string service name. |
| 24 | + * @param account The string account name. |
| 25 | + * @param password The string password. |
| 26 | + * |
| 27 | + * @returns A promise for the set password completion. |
| 28 | + */ |
| 29 | + export function setPassword(service: string, account: string, password: string): Promise<void>; |
| 30 | + |
| 31 | + /** |
| 32 | + * Delete the stored password for the service and account. |
| 33 | + * |
| 34 | + * @param service The string service name. |
| 35 | + * @param account The string account name. |
| 36 | + * |
| 37 | + * @returns A promise for the deletion status. True on success. |
| 38 | + */ |
| 39 | + export function deletePassword(service: string, account: string): Promise<boolean>; |
| 40 | + |
| 41 | + /** |
| 42 | + * Find a password for the service in the keychain. |
| 43 | + * |
| 44 | + * @param service The string service name. |
| 45 | + * |
| 46 | + * @returns A promise for the password string. |
| 47 | + */ |
| 48 | + export function findPassword(service: string): Promise<string | null>; |
| 49 | + |
| 50 | + /** |
| 51 | + * Find all accounts and passwords for `service` in the keychain. |
| 52 | + * |
| 53 | + * @param service The string service name. |
| 54 | + * |
| 55 | + * @returns A promise for the array of found credentials. |
| 56 | + */ |
| 57 | + export function findCredentials(service: string): Promise<Array<{ account: string, password: string}>>; |
| 58 | +} |
0 commit comments