From 78c6283deb68095e714e3dd394c4027644ba2ee2 Mon Sep 17 00:00:00 2001 From: UrielCh Date: Mon, 10 Apr 2017 15:20:54 -0700 Subject: [PATCH] improve support of passReqToCallback option in passport Strategies for facebook, google-oauth2, local and twitter --- types/passport-facebook/index.d.ts | 17 +++++------------ types/passport-google-oauth/index.d.ts | 7 +++++++ types/passport-local/index.d.ts | 4 ++-- types/passport-twitter/index.d.ts | 8 +++++++- 4 files changed, 21 insertions(+), 15 deletions(-) diff --git a/types/passport-facebook/index.d.ts b/types/passport-facebook/index.d.ts index 320a2169ba..cd35cbe0c8 100644 --- a/types/passport-facebook/index.d.ts +++ b/types/passport-facebook/index.d.ts @@ -11,9 +11,9 @@ import passport = require('passport'); import express = require('express'); interface Profile extends passport.Profile { - gender: string; - profileUrl: string; - username: string; + gender?: string; + profileUrl?: string; + username?: string; _raw: string; _json: any; @@ -33,15 +33,8 @@ interface IStrategyOption { profileFields?: string[]; } -interface IStrategyOptionWithRequest { - clientID: string; - clientSecret: string; - callbackURL: string; - - scopeSeparator?: string; - enableProof?: boolean; - profileFields?: string[]; - passReqToCallback: boolean; +interface IStrategyOptionWithRequest extends IStrategyOption { + passReqToCallback: true; } interface VerifyFunction { diff --git a/types/passport-google-oauth/index.d.ts b/types/passport-google-oauth/index.d.ts index 0dd283001b..50930a45ad 100644 --- a/types/passport-google-oauth/index.d.ts +++ b/types/passport-google-oauth/index.d.ts @@ -62,9 +62,16 @@ interface IOAuth2StrategyOption { openIDRealm?: string; } +interface IOAuth2StrategyOptionWithRequest extends IOAuth2StrategyOption { + passReqToCallback: true; +} + declare class OAuth2Strategy implements passport.Strategy { constructor(options: IOAuth2StrategyOption, verify: (accessToken: string, refreshToken: string, profile: Profile, done: (error: any, user?: any) => void) => void); + constructor(options: IOAuth2StrategyOptionWithRequest, + verify: (req: express.Request, accessToken: string, refreshToken: string, profile: Profile, done: (error: any, user?: any) => void) => void); + name: string; authenticate: (req: express.Request, options?: Object) => void; } diff --git a/types/passport-local/index.d.ts b/types/passport-local/index.d.ts index f5047a4a29..4a87b132d8 100644 --- a/types/passport-local/index.d.ts +++ b/types/passport-local/index.d.ts @@ -13,13 +13,13 @@ import express = require('express'); interface IStrategyOptions { usernameField?: string; passwordField?: string; - passReqToCallback?: boolean; + passReqToCallback?: false; } interface IStrategyOptionsWithRequest { usernameField?: string; passwordField?: string; - passReqToCallback: boolean; + passReqToCallback: true; } interface IVerifyOptions { diff --git a/types/passport-twitter/index.d.ts b/types/passport-twitter/index.d.ts index 387fa7ab44..1ee2d4482f 100644 --- a/types/passport-twitter/index.d.ts +++ b/types/passport-twitter/index.d.ts @@ -24,7 +24,6 @@ interface IStrategyOption { consumerSecret: string; callbackURL: string; - passReqToCallback?: true; includeEmail?: true; reguestTokenURL?: string; @@ -36,9 +35,16 @@ interface IStrategyOption { skipExtendedUserProfile?: boolean; } +interface IStrategyOptionWithRequest extends IStrategyOption { + passReqToCallback: true; +} + declare class Strategy implements passport.Strategy { constructor(options: IStrategyOption, verify: (accessToken: string, refreshToken: string, profile: Profile, done: (error: any, user?: any) => void) => void); + constructor(options: IStrategyOptionWithRequest, + verify: (req: express.Request, accessToken: string, refreshToken: string, profile: Profile, done: (error: any, user?: any) => void) => void); + name: string; authenticate: (req: express.Request, options?: Object) => void; }