diff --git a/types/keytar/index.d.ts b/types/keytar/index.d.ts index 5a27c0c984..f807b19a9f 100644 --- a/types/keytar/index.d.ts +++ b/types/keytar/index.d.ts @@ -1,6 +1,6 @@ -// Type definitions for keytar 3.0.2 +// Type definitions for keytar 4.0.2 // Project: http://atom.github.io/node-keytar/ -// Definitions by: Milan Burda , Brendan Forster +// Definitions by: Milan Burda , Brendan Forster , Hari Juturu // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -10,9 +10,9 @@ * @param service The string service name. * @param account The string account name. * - * @returns the string password or null on failures. + * @returns A promise for the password string. */ -export declare function getPassword(service: string, account: string): string | null; +export declare function getPassword(service: string, account: string): Promise; /** * Add the password for the service and account to the keychain. @@ -21,9 +21,9 @@ export declare function getPassword(service: string, account: string): string | * @param account The string account name. * @param password The string password. * - * @returns true on success, false on failure. + * @returns A promise for the set password completion. */ -export declare function addPassword(service: string, account: string, password: string): boolean; +export declare function setPassword(service: string, account: string, password: string): Promise; /** * Delete the stored password for the service and account. @@ -31,29 +31,15 @@ export declare function addPassword(service: string, account: string, password: * @param service The string service name. * @param account The string account name. * - * @returns true on success, false on failure + * @returns A promise for the deletion status. True on success. */ -export declare function deletePassword(service: string, account: string): boolean; - -/** - * Replace the password for the service and account in the keychain. - * - * This is a simple convenience function that internally calls deletePassword(service, account) - * followed by addPassword(service, account, password). - * - * @param service The string service name. - * @param account The string account name. - * @param password The string password. - * - * @returns true on success, false on failure. - */ -export declare function replacePassword(service: string, account: string, password: string): boolean; +export declare function deletePassword(service: string, account: string): Promise; /** * Find a password for the service in the keychain. * * @param service The string service name. * - * @returns the string password or null on failures. + * @returns A promise for the password string. */ -export declare function findPassword(service: string): string | null; +export declare function findPassword(service: string): Promise; diff --git a/types/keytar/keytar-tests.ts b/types/keytar/keytar-tests.ts index d523050650..f6873838c2 100644 --- a/types/keytar/keytar-tests.ts +++ b/types/keytar/keytar-tests.ts @@ -1,13 +1,13 @@ import keytar = require('keytar'); -let success: boolean = false; +let setResult: Promise; +setResult = keytar.setPassword('keytar-tests', 'username', 'password'); -success = keytar.addPassword('keytar-tests', 'username', 'password'); +let success: Promise; success = keytar.deletePassword('keytar-tests', 'username'); -success = keytar.replacePassword('keytar-tests', 'username', 'password'); -let password: string = ''; +let password: Promise; password = keytar.findPassword('keytar-tests'); password = keytar.getPassword('keytar-tests', 'username');