Change secretOrKey to union type of string or Buffer, and add relevant test.

This commit is contained in:
Alex Young
2017-06-29 10:52:48 +01:00
parent 4d12d79360
commit 45006ffe13
2 changed files with 3 additions and 1 deletions

View File

@@ -1,6 +1,7 @@
// 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: https://github.com/DefinitelyTyped/DefinitelyTyped
import {Strategy as PassportStrategy} from 'passport-strategy';
@@ -12,7 +13,7 @@ export declare class Strategy extends PassportStrategy {
}
export interface StrategyOptions {
secretOrKey: string;
secretOrKey: string | Buffer;
jwtFromRequest: JwtFromRequestFunction;
issuer?: string;
audience?: string;

View File

@@ -33,5 +33,6 @@ 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 = (req: Request) => { return req.query.token; };
opts.secretOrKey = new Buffer('secret');
declare function findUser(condition: {id: string}, callback: (error: any, user :any) => void): void;