From f75faf72883be0552a54f13a96614caeab9952cf Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Mon, 20 Feb 2017 15:39:43 +1100 Subject: [PATCH 1/5] keytar will return null when it fails --- keytar/index.d.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/keytar/index.d.ts b/keytar/index.d.ts index 12dbd63316..963910e4bb 100644 --- a/keytar/index.d.ts +++ b/keytar/index.d.ts @@ -12,7 +12,7 @@ * * @returns the string password or null on failures. */ -export declare function getPassword(service: string, account: string): string; +export declare function getPassword(service: string, account: string): string | null; /** * Add the password for the service and account to the keychain. @@ -33,7 +33,7 @@ export declare function addPassword(service: string, account: string, password: * * @returns the string password or null on failures. */ -export declare function deletePassword(service: string, account: string): string; +export declare function deletePassword(service: string, account: string): string | null; /** * Replace the password for the service and account in the keychain. @@ -56,4 +56,4 @@ export declare function replacePassword(service: string, account: string, passwo * * @returns the string password or null on failures. */ -export declare function findPassword(service: string): string; +export declare function findPassword(service: string): string | null; From 2338f6707140401e4c379810ccca06bf6039ad77 Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Mon, 20 Feb 2017 15:46:56 +1100 Subject: [PATCH 2/5] deletePassword returns a boolean --- keytar/index.d.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/keytar/index.d.ts b/keytar/index.d.ts index 963910e4bb..63690b90d7 100644 --- a/keytar/index.d.ts +++ b/keytar/index.d.ts @@ -31,9 +31,9 @@ export declare function addPassword(service: string, account: string, password: * @param service The string service name. * @param account The string account name. * - * @returns the string password or null on failures. + * @returns true on success, false on failure */ -export declare function deletePassword(service: string, account: string): string | null; +export declare function deletePassword(service: string, account: string): boolean; /** * Replace the password for the service and account in the keychain. From 0bb2a11a92a965fcefb57433a85b05e68c7d155e Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Mon, 20 Feb 2017 15:47:02 +1100 Subject: [PATCH 3/5] bump the version --- keytar/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keytar/index.d.ts b/keytar/index.d.ts index 63690b90d7..e046223ee7 100644 --- a/keytar/index.d.ts +++ b/keytar/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for keytar 3.0.0 +// Type definitions for keytar 3.0.2 // Project: http://atom.github.io/node-keytar/ // Definitions by: Milan Burda // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From 28cbb4fcb79d1b5a54c38d80d919e703aeba0f8d Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Fri, 24 Feb 2017 09:19:08 +1100 Subject: [PATCH 4/5] added as a contributor --- keytar/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/keytar/index.d.ts b/keytar/index.d.ts index e046223ee7..5a27c0c984 100644 --- a/keytar/index.d.ts +++ b/keytar/index.d.ts @@ -1,6 +1,6 @@ // Type definitions for keytar 3.0.2 // Project: http://atom.github.io/node-keytar/ -// Definitions by: Milan Burda +// Definitions by: Milan Burda , Brendan Forster // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped From 1753b8c0cb1a388dd202602da5e027a86af302ff Mon Sep 17 00:00:00 2001 From: Brendan Forster Date: Fri, 24 Feb 2017 11:00:39 +1100 Subject: [PATCH 5/5] updated tests to validate returned values --- keytar/keytar-tests.ts | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/keytar/keytar-tests.ts b/keytar/keytar-tests.ts index 91a43ebbe9..d523050650 100644 --- a/keytar/keytar-tests.ts +++ b/keytar/keytar-tests.ts @@ -1,8 +1,13 @@ import keytar = require('keytar'); -keytar.addPassword('keytar-tests', 'username', 'password'); -keytar.deletePassword('keytar-tests', 'username'); -keytar.findPassword('keytar-tests'); -keytar.getPassword('keytar-tests', 'username'); -keytar.replacePassword('keytar-tests', 'username', 'password'); +let success: boolean = false; + +success = keytar.addPassword('keytar-tests', 'username', 'password'); +success = keytar.deletePassword('keytar-tests', 'username'); +success = keytar.replacePassword('keytar-tests', 'username', 'password'); + +let password: string = ''; + +password = keytar.findPassword('keytar-tests'); +password = keytar.getPassword('keytar-tests', 'username');