add missing scopeSeparator option and tests

This commit is contained in:
Ivan Fernandes
2018-12-04 16:16:29 -02:00
parent 475a46b12d
commit e7f4d0148e
2 changed files with 33 additions and 1 deletions
+1
View File
@@ -67,6 +67,7 @@ declare namespace OAuth2Strategy {
callbackURL?: string;
customHeaders?: OutgoingHttpHeaders;
scope?: string | string[];
scopeSeparator?: string;
sessionKey?: string;
store?: StateStore;
state?: any;
+32 -1
View File
@@ -1,5 +1,5 @@
import OAuth2Strategy = require('passport-oauth2');
import { Strategy, StrategyOptions, StrategyOptionsWithRequest, VerifyCallback, AuthorizationError, TokenError, InternalOAuthError } 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';
@@ -56,3 +56,34 @@ class MyStrategy extends OAuth2Strategy {
this._oauth2.get('http://www.example.com/profile', 'token', (err, result, response) => response);
}
}
const metadata: Metadata = {
authorizationURL: 'http://www.example.com/auth',
clientID: 'dummy',
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 {}
}
const myStore = new MyStore;
const strategyOptions3: StrategyOptions = {
authorizationURL: 'http://www.example.com/auth',
clientID: 'dummy',
clientSecret: 'secret',
tokenURL: 'http://www.example.com/token',
callbackURL: 'http://www.example.com/callback',
customHeaders: {
'content-type': 'text/html'
},
scope: ['scope1', 'scope2'],
scopeSeparator: ' ',
sessionKey: 'oauth',
state: {id: 1},
store: myStore
};
const strategy5: Strategy = new Strategy(strategyOptions3, verifyFunction2);