From 1452ad38815ca529a2f0103fd6140005514a0138 Mon Sep 17 00:00:00 2001 From: mbutsykin Date: Wed, 22 Aug 2018 18:30:47 +0300 Subject: [PATCH 1/5] @types/passport-cognito --- types/passport-cognito/index.d.ts | 23 +++++++++++++++++++ .../passport-cognito-tests.ts | 23 +++++++++++++++++++ types/passport-cognito/tsconfig.json | 23 +++++++++++++++++++ types/passport-cognito/tslint.json | 3 +++ 4 files changed, 72 insertions(+) create mode 100644 types/passport-cognito/index.d.ts create mode 100644 types/passport-cognito/passport-cognito-tests.ts create mode 100644 types/passport-cognito/tsconfig.json create mode 100644 types/passport-cognito/tslint.json diff --git a/types/passport-cognito/index.d.ts b/types/passport-cognito/index.d.ts new file mode 100644 index 0000000000..598f830017 --- /dev/null +++ b/types/passport-cognito/index.d.ts @@ -0,0 +1,23 @@ +import passport = require('passport'); +import express = require('express'); + +interface CognitoStrategyOptions { + userPoolId: string; + clientId: string; + region: string; +} + +type CognitoVerifyFunction = ( + accessToken: string, + idToken: string, + refreshToken: string, + user: object, + done: (error: any, user?: any | false) => 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..0d894068bb --- /dev/null +++ b/types/passport-cognito/passport-cognito-tests.ts @@ -0,0 +1,23 @@ +/** + * Created by Christophe Vidal + */ + +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" +} From cf0caeea703df9311bcad2c94773f2592329159e Mon Sep 17 00:00:00 2001 From: mbutsykin Date: Wed, 22 Aug 2018 18:40:58 +0300 Subject: [PATCH 2/5] lint errors --- types/passport-cognito/index.d.ts | 6 ++++++ types/passport-cognito/passport-cognito-tests.ts | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/types/passport-cognito/index.d.ts b/types/passport-cognito/index.d.ts index 598f830017..731205b888 100644 --- a/types/passport-cognito/index.d.ts +++ b/types/passport-cognito/index.d.ts @@ -1,3 +1,9 @@ +// Type definitions for passport-cognito 0.1.13 +// Project: https://github.com/jaredhanson/passport-cognito +// Definitions by: Maksym Butsykin +// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped +// TypeScript Version: 2.3 + import passport = require('passport'); import express = require('express'); diff --git a/types/passport-cognito/passport-cognito-tests.ts b/types/passport-cognito/passport-cognito-tests.ts index 0d894068bb..c752ca9250 100644 --- a/types/passport-cognito/passport-cognito-tests.ts +++ b/types/passport-cognito/passport-cognito-tests.ts @@ -1,5 +1,5 @@ /** - * Created by Christophe Vidal + * Created by Maksym Butsykin Vidal */ import passport = require("passport"); From af58080daa3b84c405be0fb2474deb11ed9aaf4e Mon Sep 17 00:00:00 2001 From: mbutsykin Date: Wed, 22 Aug 2018 18:41:48 +0300 Subject: [PATCH 3/5] typo --- types/passport-cognito/passport-cognito-tests.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/passport-cognito/passport-cognito-tests.ts b/types/passport-cognito/passport-cognito-tests.ts index c752ca9250..02c80e8734 100644 --- a/types/passport-cognito/passport-cognito-tests.ts +++ b/types/passport-cognito/passport-cognito-tests.ts @@ -1,5 +1,5 @@ /** - * Created by Maksym Butsykin Vidal + * Created by Maksym Butsykin */ import passport = require("passport"); From 01fab8d10ab1c5ab4ddf1fb70651927bed0122b6 Mon Sep 17 00:00:00 2001 From: mbutsykin Date: Wed, 22 Aug 2018 18:42:16 +0300 Subject: [PATCH 4/5] typo --- types/passport-cognito/index.d.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/types/passport-cognito/index.d.ts b/types/passport-cognito/index.d.ts index 731205b888..cfa9b13640 100644 --- a/types/passport-cognito/index.d.ts +++ b/types/passport-cognito/index.d.ts @@ -1,5 +1,5 @@ // Type definitions for passport-cognito 0.1.13 -// Project: https://github.com/jaredhanson/passport-cognito +// Project: https://github.com/kndt84/passport-cognito // Definitions by: Maksym Butsykin // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 From 297b6241fd6803040f6ecee1d3f290e4c6da7cb3 Mon Sep 17 00:00:00 2001 From: mbutsykin Date: Wed, 22 Aug 2018 18:49:11 +0300 Subject: [PATCH 5/5] linter errors --- types/passport-cognito/index.d.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/types/passport-cognito/index.d.ts b/types/passport-cognito/index.d.ts index cfa9b13640..d9dcbe38db 100644 --- a/types/passport-cognito/index.d.ts +++ b/types/passport-cognito/index.d.ts @@ -1,4 +1,4 @@ -// Type definitions for passport-cognito 0.1.13 +// Type definitions for passport-cognito 0.1 // Project: https://github.com/kndt84/passport-cognito // Definitions by: Maksym Butsykin // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped @@ -7,18 +7,18 @@ import passport = require('passport'); import express = require('express'); -interface CognitoStrategyOptions { +export interface CognitoStrategyOptions { userPoolId: string; clientId: string; region: string; } -type CognitoVerifyFunction = ( +export type CognitoVerifyFunction = ( accessToken: string, idToken: string, refreshToken: string, user: object, - done: (error: any, user?: any | false) => void, + done: (error: any, user?: any) => void, ) => any; export class Strategy extends passport.Strategy {