From a2bba58e82e5b14117598536f8fea715434a144f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ph=C3=BA?= Date: Sun, 8 Nov 2015 10:26:58 +0700 Subject: [PATCH 1/3] Create credential.d.ts --- credential/credential.d.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 credential/credential.d.ts diff --git a/credential/credential.d.ts b/credential/credential.d.ts new file mode 100644 index 000000000..d8497ec14 --- /dev/null +++ b/credential/credential.d.ts @@ -0,0 +1,18 @@ +// Type definitions for credential +// Project: https://github.com/ericelliott/credential +// Definitions by: PhĂș +// 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; + +} From 462461d1fb805462351cd83f0d9f44eccab9c9a1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ph=C3=BA?= Date: Sun, 8 Nov 2015 10:38:06 +0700 Subject: [PATCH 2/3] Create credential-tests.ts --- credential/credential-tests.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 credential/credential-tests.ts diff --git a/credential/credential-tests.ts b/credential/credential-tests.ts new file mode 100644 index 000000000..6adec112f --- /dev/null +++ b/credential/credential-tests.ts @@ -0,0 +1,16 @@ +/// + +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'); +}); From 8fc20c0d16934a9429d387a7e5cf6639070cef78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ph=C3=BA?= Date: Sun, 8 Nov 2015 10:51:09 +0700 Subject: [PATCH 3/3] Fix reference syntax --- credential/credential-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/credential/credential-tests.ts b/credential/credential-tests.ts index 6adec112f..6013436b0 100644 --- a/credential/credential-tests.ts +++ b/credential/credential-tests.ts @@ -1,4 +1,4 @@ -/// +/// import * as credential from 'credential';