-
-
Notifications
You must be signed in to change notification settings - Fork 32
/
index.d.ts
48 lines (40 loc) · 910 Bytes
/
index.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
37
38
39
40
41
42
43
44
45
46
47
48
declare class Tokens {
/**
* Token generation/verification class.
*/
constructor(options?: Tokens.Options);
/**
* Create a new CSRF token.
*/
create(secret: string): string;
/**
* Create a new secret key.
*/
secret(): Promise<string>;
/**
* Create a new secret key.
*/
secret(callback: Tokens.SecretCallback): void;
/**
* Create a new secret key synchronously.
*/
secretSync(): string;
/**
* Verify if a given token is valid for a given secret.
*/
verify(secret: string, token: string): boolean;
}
declare namespace Tokens {
export type SecretCallback = (err: Error | null, secret: string) => void;
export interface Options {
/**
* The string length of the salt (default: 8)
*/
saltLength?: number;
/**
* The byte length of the secret key (default: 18)
*/
secretLength?: number;
}
}
export = Tokens;