-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
67 lines (61 loc) · 2.29 KB
/
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
// Type definitions for express-jwt
// Project: https://www.npmjs.org/package/express-jwt
// Definitions by: Wonshik Kim <https://github.com/wokim>
// Kacper Polak <https://github.com/kacepe>
// Sl1MBoy <https://github.com/Sl1MBoy>
// Milan Mimra <https://github.com/milan-mimra>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
import express = require('express');
import unless = require('express-unless');
export = jwt;
declare function jwt(options: jwt.Options): jwt.RequestHandler;
declare namespace jwt {
export type secretType = string | Buffer
export type ErrorCode =
"revoked_token" |
"invalid_token" |
"credentials_bad_scheme" |
"credentials_bad_format" |
"credentials_required"
export interface SecretCallbackLong {
(req: express.Request, header: any, payload: any, done: (err: any, secret?: secretType) => void): void;
}
export interface SecretCallback {
(req: express.Request, payload: any, done: (err: any, secret?: secretType) => void): void;
}
export interface PayloadSanitizer {
(unsanizitedToken: any, callback: PayloadSanitizerCallback): void;
}
export interface PayloadSanitizerCallback {
(err: any, token: any): void;
}
export interface IsRevokedCallback {
(req: express.Request, payload: any, done: (err: any, revoked?: boolean) => void): void;
}
export interface GetTokenCallback {
(req: express.Request): any;
}
export interface Options {
secret: secretType | SecretCallback | SecretCallbackLong;
userProperty?: string;
skip?: string[];
credentialsRequired?: boolean;
isRevoked?: IsRevokedCallback;
requestProperty?: string;
getToken?: GetTokenCallback;
payloadSanitizer?: PayloadSanitizer;
[property: string]: any;
}
export interface RequestHandler extends express.RequestHandler {
unless: typeof unless;
}
export class UnauthorizedError extends Error {
status: number;
message: string;
name: 'UnauthorizedError';
code: ErrorCode;
inner: { message: string };
constructor(code: ErrorCode, error: { message: string });
}
}