Feature/types passport oauth2 refresh (#39425)

* added typings for passport-oauth2-refresh library

* fix linting issues with passport-oauth2-refresh
This commit is contained in:
Daphne
2019-10-25 13:28:56 -07:00
committed by Wesley Wigham
parent bb6cb74350
commit fc72468d0a
4 changed files with 57 additions and 0 deletions
+13
View File
@@ -0,0 +1,13 @@
// Type definitions for passport-oauth2-refresh 1.1
// Project: https://github.com/fiznool/passport-oauth2-refresh#readme
// Definitions by: Daphne Smit <https://github.com/daphnesmit>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
// TypeScript Version: 2.3
import { Strategy } from 'passport-oauth2';
export function use(name: string | Strategy, strategy?: Strategy): void;
export function has(name: string): boolean;
export function requestNewAccessToken(name: string, refreshToken: string, params: any, done: () => any): any;
@@ -0,0 +1,20 @@
import { Strategy as OAuth2Strategy, StrategyOptions, VerifyCallback } from 'passport-oauth2';
import { use, requestNewAccessToken } from 'passport-oauth2-refresh';
const strategyOptions1: StrategyOptions = {
authorizationURL: 'http://www.example.com/auth',
callbackURL: 'http://www.example.com/callback',
clientID: 'dummy',
clientSecret: 'secret',
tokenURL: 'http://www.example.com/token'
};
function verifyFunction1(_accessToken: string, _refreshToken: string, _profile: any, verifyCallback: VerifyCallback) {
verifyCallback(new Error('unimplemented'));
}
const strategy1: OAuth2Strategy = new OAuth2Strategy(strategyOptions1, verifyFunction1);
use('strategy1', strategy1);
requestNewAccessToken('strategy1', 'exampleRefreshToken', {}, () => {});
@@ -0,0 +1,23 @@
{
"compilerOptions": {
"module": "commonjs",
"lib": [
"es6"
],
"noImplicitAny": true,
"noImplicitThis": true,
"strictNullChecks": true,
"strictFunctionTypes": true,
"baseUrl": "../",
"typeRoots": [
"../"
],
"types": [],
"noEmit": true,
"forceConsistentCasingInFileNames": true
},
"files": [
"index.d.ts",
"passport-oauth2-refresh-tests.ts"
]
}
@@ -0,0 +1 @@
{ "extends": "dtslint/dt.json" }