mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-06-05 14:59:37 +08:00
Updating keytar typings for v4.0.2 (#16082)
* Updating keytar typings for v4.0.2 * Updating the return types * Adding null return for get/find password
This commit is contained in:
committed by
Sheetal Nandi
parent
238ce6d05d
commit
1ed019e8ad
34
types/keytar/index.d.ts
vendored
34
types/keytar/index.d.ts
vendored
@@ -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 <https://github.com/miniak/>, Brendan Forster <https://github.com/shiftkey/>
|
||||
// Definitions by: Milan Burda <https://github.com/miniak/>, Brendan Forster <https://github.com/shiftkey/>, Hari Juturu <https://github.com/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<string | null>;
|
||||
|
||||
/**
|
||||
* 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<void>;
|
||||
|
||||
/**
|
||||
* 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<boolean>;
|
||||
|
||||
/**
|
||||
* 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<string | null>;
|
||||
|
||||
@@ -1,13 +1,13 @@
|
||||
|
||||
import keytar = require('keytar');
|
||||
|
||||
let success: boolean = false;
|
||||
let setResult: Promise<void>;
|
||||
setResult = keytar.setPassword('keytar-tests', 'username', 'password');
|
||||
|
||||
success = keytar.addPassword('keytar-tests', 'username', 'password');
|
||||
let success: Promise<boolean>;
|
||||
success = keytar.deletePassword('keytar-tests', 'username');
|
||||
success = keytar.replacePassword('keytar-tests', 'username', 'password');
|
||||
|
||||
let password: string = '';
|
||||
let password: Promise<string | null>;
|
||||
|
||||
password = keytar.findPassword('keytar-tests');
|
||||
password = keytar.getPassword('keytar-tests', 'username');
|
||||
|
||||
Reference in New Issue
Block a user