Merge pull request #19162 from davidNHK/fix-types/passport-jwt

[passport-jwt] Add missing function
This commit is contained in:
Mine Starks
2017-08-28 15:24:34 -07:00
committed by GitHub
2 changed files with 5 additions and 2 deletions
+4 -2
View File
@@ -1,7 +1,8 @@
// Type definitions for passport-jwt 2.0
// Project: https://github.com/themikenicholson/passport-jwt
// Definitions by: TANAKA Koichi <https://github.com/mugeso>
// Alex Young <https://github.com/alsiola>
// Definitions by: TANAKA Koichi <https://github.com/mugeso/>
// Alex Young <https://github.com/alsiola/>
// David Ng <https://github.com/davidNHK/>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
import { Strategy as PassportStrategy } from 'passport-strategy';
@@ -45,4 +46,5 @@ export declare namespace ExtractJwt {
export function fromAuthHeaderWithScheme(auth_scheme: string): JwtFromRequestFunction;
export function fromAuthHeader(): JwtFromRequestFunction;
export function fromExtractors(extractors: JwtFromRequestFunction[]): JwtFromRequestFunction;
export function fromAuthHeaderAsBearerToken(): JwtFromRequestFunction;
}
+1
View File
@@ -32,6 +32,7 @@ opts.jwtFromRequest = ExtractJwt.fromBodyField('field_name');
opts.jwtFromRequest = ExtractJwt.fromUrlQueryParameter('param_name');
opts.jwtFromRequest = ExtractJwt.fromAuthHeaderWithScheme('param_name');
opts.jwtFromRequest = ExtractJwt.fromExtractors([ExtractJwt.fromHeader('x-api-key'), ExtractJwt.fromBodyField('field_name'), ExtractJwt.fromUrlQueryParameter('param_name')]);
opts.jwtFromRequest = ExtractJwt.fromAuthHeaderAsBearerToken();
opts.jwtFromRequest = (req: Request) => { return req.query.token; };
opts.secretOrKey = new Buffer('secret');