diff --git a/types/passport-oauth2/index.d.ts b/types/passport-oauth2/index.d.ts index 28a1a06348..ff9496c08b 100644 --- a/types/passport-oauth2/index.d.ts +++ b/types/passport-oauth2/index.d.ts @@ -4,6 +4,7 @@ // Wang Zishi // Eduardo AC // Ivan Fernandes +// Daphne Smit // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 @@ -72,6 +73,9 @@ declare namespace OAuth2Strategy { sessionKey?: string; store?: StateStore; state?: any; + skipUserProfile?: any; + pkce?: boolean; + proxy?: any; } interface StrategyOptions extends _StrategyOptionsBase { passReqToCallback?: false; diff --git a/types/passport-oauth2/passport-oauth2-tests.ts b/types/passport-oauth2/passport-oauth2-tests.ts index 30faeebda0..b6f5e94699 100644 --- a/types/passport-oauth2/passport-oauth2-tests.ts +++ b/types/passport-oauth2/passport-oauth2-tests.ts @@ -1,6 +1,17 @@ import OAuth2Strategy = require('passport-oauth2'); -import { Strategy, StrategyOptions, StrategyOptionsWithRequest, VerifyCallback, AuthorizationError, TokenError, - InternalOAuthError, Metadata, StateStore, StateStoreStoreCallback, StateStoreVerifyCallback } from 'passport-oauth2'; +import { + Strategy, + StrategyOptions, + StrategyOptionsWithRequest, + VerifyCallback, + AuthorizationError, + TokenError, + InternalOAuthError, + Metadata, + StateStore, + StateStoreStoreCallback, + StateStoreVerifyCallback, +} from 'passport-oauth2'; import { Strategy as PassportStrategy } from 'passport'; import { Request } from 'express'; @@ -9,14 +20,20 @@ const strategyOptions1: StrategyOptions = { callbackURL: 'http://www.example.com/callback', clientID: 'dummy', clientSecret: 'secret', - tokenURL: 'http://www.example.com/token' + tokenURL: 'http://www.example.com/token', }; function verifyFunction1(_accessToken: string, _refreshToken: string, _profile: any, verifyCallback: VerifyCallback) { verifyCallback(new Error('unimplemented')); } -function verifyFunction2(_accessToken: string, _refreshToken: string, _results: any, _profile: any, verifyCallback: VerifyCallback) { +function verifyFunction2( + _accessToken: string, + _refreshToken: string, + _results: any, + _profile: any, + verifyCallback: VerifyCallback, +) { verifyCallback(new Error('unimplemented')); } @@ -24,11 +41,24 @@ const strategy1: OAuth2Strategy = new OAuth2Strategy(strategyOptions1, verifyFun const strategy2: Strategy = new OAuth2Strategy(strategyOptions1, verifyFunction2); -function verifyFunction3(_req: Request, _accessToken: string, _refreshToken: string, _profile: any, verifyCallback: VerifyCallback) { +function verifyFunction3( + _req: Request, + _accessToken: string, + _refreshToken: string, + _profile: any, + verifyCallback: VerifyCallback, +) { verifyCallback(undefined, { userid: '1' }); } -function verifyFunction4(_req: Request, _accessToken: string, _refreshToken: string, _results: any, _profile: any, verifyCallback: VerifyCallback) { +function verifyFunction4( + _req: Request, + _accessToken: string, + _refreshToken: string, + _results: any, + _profile: any, + verifyCallback: VerifyCallback, +) { verifyCallback(undefined, { userid: '1' }); } @@ -37,7 +67,7 @@ const strategyOptions2: StrategyOptionsWithRequest = { clientID: 'dummy', clientSecret: 'secret', tokenURL: 'http://www.example.com/token', - passReqToCallback: true + passReqToCallback: true, }; const strategy3: PassportStrategy = new OAuth2Strategy(strategyOptions2, verifyFunction3); @@ -61,12 +91,17 @@ class MyStrategy extends OAuth2Strategy { const metadata: Metadata = { authorizationURL: 'http://www.example.com/auth', clientID: 'dummy', - tokenURL: 'http://www.example.com/token' + tokenURL: 'http://www.example.com/token', }; class MyStore implements StateStore { store(req: Request, meta: StateStoreStoreCallback | Metadata, callback?: StateStoreStoreCallback): void {} - verify(req: Request, state: string, meta: StateStoreVerifyCallback | Metadata, callback?: StateStoreVerifyCallback): void {} + verify( + req: Request, + state: string, + meta: StateStoreVerifyCallback | Metadata, + callback?: StateStoreVerifyCallback, + ): void {} } const myStore = new MyStore(); @@ -78,13 +113,15 @@ const strategyOptions3: StrategyOptions = { tokenURL: 'http://www.example.com/token', callbackURL: 'http://www.example.com/callback', customHeaders: { - 'content-type': 'text/html' + 'content-type': 'text/html', }, scope: ['scope1', 'scope2'], scopeSeparator: ' ', sessionKey: 'oauth', - state: {id: 1}, - store: myStore + state: { id: 1 }, + store: myStore, + skipUserProfile: true, + pkce: false, }; const strategy5: Strategy = new Strategy(strategyOptions3, verifyFunction2);