diff --git a/types/passport-cognito/index.d.ts b/types/passport-cognito/index.d.ts new file mode 100644 index 0000000000..d9dcbe38db --- /dev/null +++ b/types/passport-cognito/index.d.ts @@ -0,0 +1,29 @@ +// Type definitions for passport-cognito 0.1 +// Project: https://github.com/kndt84/passport-cognito +// Definitions by: Maksym Butsykin +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + +import passport = require('passport'); +import express = require('express'); + +export interface CognitoStrategyOptions { + userPoolId: string; + clientId: string; + region: string; +} + +export type CognitoVerifyFunction = ( + accessToken: string, + idToken: string, + refreshToken: string, + user: object, + done: (error: any, user?: any) => void, +) => any; + +export class Strategy extends passport.Strategy { + constructor(options: CognitoStrategyOptions, verify: CognitoVerifyFunction); + + name: string; + authenticate(req: express.Request, options?: object): void; +} diff --git a/types/passport-cognito/passport-cognito-tests.ts b/types/passport-cognito/passport-cognito-tests.ts new file mode 100644 index 0000000000..02c80e8734 --- /dev/null +++ b/types/passport-cognito/passport-cognito-tests.ts @@ -0,0 +1,23 @@ +/** + * Created by Maksym Butsykin + */ + +import passport = require("passport"); +import cognito = require("passport-cognito"); + +passport.use( + new cognito.Strategy( + { + clientId: "clientId", + region: "region", + userPoolId: "userPoolId" + }, + ( + accessToken: string, + idToken: string, + refreshToken: string, + user: object, + cb: (err: Error | null, user?: object | false) => void + ) => {} + ) +); diff --git a/types/passport-cognito/tsconfig.json b/types/passport-cognito/tsconfig.json new file mode 100644 index 0000000000..eedb7f9a0f --- /dev/null +++ b/types/passport-cognito/tsconfig.json @@ -0,0 +1,23 @@ +{ + "compilerOptions": { + "module": "commonjs", + "lib": [ + "es6" + ], + "noImplicitAny": true, + "noImplicitThis": true, + "strictNullChecks": false, + "strictFunctionTypes": true, + "baseUrl": "../", + "typeRoots": [ + "../" + ], + "types": [], + "noEmit": true, + "forceConsistentCasingInFileNames": true + }, + "files": [ + "index.d.ts", + "passport-cognito-tests.ts" + ] +} diff --git a/types/passport-cognito/tslint.json b/types/passport-cognito/tslint.json new file mode 100644 index 0000000000..f93cf8562a --- /dev/null +++ b/types/passport-cognito/tslint.json @@ -0,0 +1,3 @@ +{ + "extends": "dtslint/dt.json" +}