mirror of
https://github.com/wassname/DefinitelyTyped.git
synced 2026-09-09 11:13:57 +08:00
Merge pull request #6666 from phuvo/credential
Add definitions for `credential`
This commit is contained in:
@@ -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');
|
||||
});
|
||||
Vendored
+18
@@ -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;
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user