Merge pull request #6666 from phuvo/credential

Add definitions for `credential`
This commit is contained in:
Masahiro Wakame
2015-11-11 19:15:26 +09:00
2 changed files with 34 additions and 0 deletions
+16
View File
@@ -0,0 +1,16 @@
/// <reference path="credential.d.ts" />
import * as credential from 'credential';
credential.hash('password', function(err: Error, hash: string) {
if (err) console.error(err);
else console.log(hash);
});
const hash = '{}';
const password = 'test';
credential.verify(hash, password, function(err: Error, isValid: boolean) {
if (err) console.error(err);
else console.log(isValid ? 'Password match' : 'Incorrect password');
});
+18
View File
@@ -0,0 +1,18 @@
// Type definitions for credential
// Project: https://github.com/ericelliott/credential
// Definitions by: Phú <https://github.com/phuvo>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare module 'credential' {
type HashCallback = (err: Error, hash: string) => void;
type VerifyCallback = (err: Error, isValid: boolean) => void;
module credential {
function hash(password: string, callback: HashCallback): void;
function verify(hash: string, password: string, callback: VerifyCallback): void;
}
export = credential;
}