From ab7694a03323fa44fee1c6e052bfc451fc7d07ce Mon Sep 17 00:00:00 2001 From: dstapleton92 Date: Sat, 28 Apr 2018 01:26:44 -0500 Subject: [PATCH] Added support for minor version parameters in bcrypt 2.0 (#25182) * Updated for bcrypt 2.0 * Added missing @param declaration for minor --- types/bcrypt/bcrypt-tests.ts | 9 +++++++++ types/bcrypt/index.d.ts | 22 +++++++++++++++++----- 2 files changed, 26 insertions(+), 5 deletions(-) diff --git a/types/bcrypt/bcrypt-tests.ts b/types/bcrypt/bcrypt-tests.ts index 6824549a61..0d824f40a2 100644 --- a/types/bcrypt/bcrypt-tests.ts +++ b/types/bcrypt/bcrypt-tests.ts @@ -8,15 +8,24 @@ let error: Error; str = bcrypt.genSaltSync(); str = bcrypt.genSaltSync(num); +str = bcrypt.genSaltSync(num, str); bcrypt.genSalt(num, (err: Error, salt: string): void => { error = err; str = salt; }) .then(salt => str = salt) .catch(err => error = err); +bcrypt.genSalt(num, str, (err: Error, salt: string): void => { error = err; str = salt; }) + .then(salt => str = salt) + .catch(err => error = err); + bcrypt.genSalt(num) .then(salt => str = salt) .catch(err => error = err); +bcrypt.genSalt(num, str) + .then(salt => str = salt) + .catch(err => error = err); + bcrypt.genSalt((err: Error, salt: string): void => { error = err; str = salt; }) .then(salt => str = salt) .catch(err => error = err); diff --git a/types/bcrypt/index.d.ts b/types/bcrypt/index.d.ts index 98c7ba97fe..3cf57ca562 100644 --- a/types/bcrypt/index.d.ts +++ b/types/bcrypt/index.d.ts @@ -1,20 +1,32 @@ -// Type definitions for bcrypt 1.0 +// Type definitions for bcrypt 2.0 // Project: https://www.npmjs.org/package/bcrypt -// Definitions by: Peter Harris , Ayman Nedjmeddine +// Definitions by: Peter Harris +// Ayman Nedjmeddine +// David Stapleton // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped /** - * @param rounds The cost of processing the data. Default 10. + * @param rounds The cost of processing the data. Default 10. + * @param minor The minor version of bcrypt to use. Either 'a' or 'b'. Default 'b'. */ -export declare function genSaltSync(rounds?: number): string; +export declare function genSaltSync(rounds?: number, minor?: string): string; /** * @param rounds The cost of processing the data. Default 10. * @param callback A callback to be fire once the sald has been generated. Uses eio making it asynchronous. * @return A promise to be either resolved with the generated salt or rejected with an Error */ -export declare function genSalt(rounds: number, callback?: (err: Error, salt: string) => void): Promise; +export declare function genSalt(rounds?: number, callback?: (err: Error, salt: string) => void): Promise; + +/** + * @param rounds The cost of processing the data. Default 10. + * @param minor The minor version of bcrypt to use. Either 'a' or 'b'. Default 'b'. + * @param callback A callback to be fire once the sald has been generated. Uses eio making it asynchronous. + * @return A promise to be either resolved with the generated salt or rejected with an Error + */ +export declare function genSalt(rounds?: number, minor?: string, callback?: (err: Error, salt: string) => void): Promise; + /** * @param callback A callback to be fire once the sald has been generated. Uses eio making it asynchronous. * @return A promise to be either resolved with the generated salt or rejected with an Error