mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-28 08:17:54 +08:00
fix missing protected _oauth2 property
This commit is contained in:
9
types/passport-oauth2/index.d.ts
vendored
9
types/passport-oauth2/index.d.ts
vendored
@@ -1,15 +1,24 @@
|
||||
// Type definitions for passport-oauth2 1.4
|
||||
// Project: https://github.com/jaredhanson/passport-oauth2#readme
|
||||
// Definitions by: Pasi Eronen <https://github.com/pasieronen>
|
||||
// Wang Zishi <https://github.com/WangZishi>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
import { Request } from 'express';
|
||||
import { Strategy } from 'passport';
|
||||
import { OAuth2 } from 'oauth';
|
||||
|
||||
declare class OAuth2Strategy extends Strategy {
|
||||
name: string;
|
||||
|
||||
/**
|
||||
* NOTE: The _oauth2 property is considered "protected". Subclasses are
|
||||
* allowed to use it when making protected resource requests to retrieve
|
||||
* the user profile.
|
||||
*/
|
||||
protected _oauth2: OAuth2;
|
||||
|
||||
constructor(options: OAuth2Strategy.StrategyOptions, verify: OAuth2Strategy.VerifyFunction);
|
||||
constructor(options: OAuth2Strategy.StrategyOptionsWithRequest, verify: OAuth2Strategy.VerifyFunctionWithRequest);
|
||||
|
||||
|
||||
@@ -24,11 +24,11 @@ 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) {
|
||||
verifyCallback(undefined, {userid: '1'});
|
||||
verifyCallback(undefined, { userid: '1' });
|
||||
}
|
||||
|
||||
function verifyFunction4(_req: Request, _accessToken: string, _refreshToken: string, _results: any, _profile: any, verifyCallback: VerifyCallback) {
|
||||
verifyCallback(undefined, {userid: '1'});
|
||||
verifyCallback(undefined, { userid: '1' });
|
||||
}
|
||||
|
||||
const strategyOptions2: StrategyOptionsWithRequest = {
|
||||
@@ -49,3 +49,9 @@ const err1 = new AuthorizationError('Description', 'invalid_request', undefined)
|
||||
const err2 = new TokenError(undefined, 'invalid_request', undefined);
|
||||
|
||||
const err3 = new InternalOAuthError('Hello', {});
|
||||
|
||||
class MyStrategy extends OAuth2Strategy {
|
||||
useProtectedMethod() {
|
||||
this._oauth2.get('http://www.example.com/profile', 'token', 'http://www.example.com/callback');
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user