forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpassport-jwt.d.ts
50 lines (42 loc) · 1.79 KB
/
passport-jwt.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
// Type definitions for passport-jwt 2.0
// Project: https://github.com/themikenicholson/passport-jwt
// Definitions by: TANAKA Koichi <https://github.com/mugeso/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../passport-strategy/passport-strategy.d.ts" />
/// <reference path="../express/express.d.ts" />
declare module 'passport-jwt' {
import {Strategy as PassportStrategy} from 'passport-strategy';
import {Request} from 'express';
export class Strategy extends PassportStrategy {
constructor(opt: StrategyOptions, verify: VerifyCallback);
constructor(opt: StrategyOptions, verify: VerifyCallbackWithRequest);
}
export interface StrategyOptions {
secretOrKey: string;
jwtFromRequest: JwtFromRequestFunction;
issuer?: string;
audience?: string;
algorithms?: string[];
ignoreExpiration?: boolean;
passReqToCallback?: boolean;
}
export interface VerifyCallback {
(payload: any, done: VerifiedCallback): void;
}
export interface VerifyCallbackWithRequest {
(req: Request, payload: any, done: VerifiedCallback): void;
}
export interface VerifiedCallback {
(error: any, user?: any, info?: any): void;
}
export interface JwtFromRequestFunction {
(req: Request): string;
}
export namespace ExtractJwt {
export function fromHeader(header_name: string): JwtFromRequestFunction;
export function fromBodyField(field_name: string): JwtFromRequestFunction;
export function fromUrlQueryParameter(param_name: string): JwtFromRequestFunction;
export function fromAuthHeaderWithScheme(auth_scheme: string): JwtFromRequestFunction;
export function fromAuthHeader(): JwtFromRequestFunction;
}
}