forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcredential.d.ts
36 lines (30 loc) · 1.13 KB
/
credential.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
// 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' {
interface defaultOptions {
keyLength: number;
work: number;
hashMethod: string;
}
interface hashObject {
hash: string;
salt: string;
keyLength: number;
hashMethod: string;
iterations: number;
}
type HashCallback = (err: Error, hash: hashObject) => void;
type VerifyCallback = (err: Error, isValid: boolean) => void;
function credential(defaultOptions?: defaultOptions): {
hash(password: string, callback: HashCallback): void;
hash(password: string): Promise<hashObject>;
// iterations(work: number, base): number;
verify(hash: hashObject | string, password: string, callback: VerifyCallback): void;
verify(hash: hashObject | string, password: string): Promise<boolean>;
expired(hash: string, days: number): boolean;
}
namespace credential { }
export = credential;
}