From 265b807686458b8a3adeab00ecba82b99927ca53 Mon Sep 17 00:00:00 2001 From: Josh Heyse Date: Wed, 3 Jun 2015 11:56:52 -0500 Subject: [PATCH 1/4] added username to facebook profile --- passport-facebook/passport-facebook.d.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/passport-facebook/passport-facebook.d.ts b/passport-facebook/passport-facebook.d.ts index 855b033f5..26479cc29 100644 --- a/passport-facebook/passport-facebook.d.ts +++ b/passport-facebook/passport-facebook.d.ts @@ -13,6 +13,7 @@ declare module 'passport-facebook' { interface Profile extends passport.Profile { gender: string; profileUrl: string; + username: string; } interface IStrategyOption { From 3bf10e44d143f27b549986d617f37def4c7530ba Mon Sep 17 00:00:00 2001 From: Josh Heyse Date: Wed, 3 Jun 2015 11:57:24 -0500 Subject: [PATCH 2/4] added passport-google-oauth definitions --- .../passport-google-oauth-tests.ts | 38 ++++++++++++ .../passport-google-oauth.d.ts | 60 +++++++++++++++++++ 2 files changed, 98 insertions(+) create mode 100644 passport-google-oauth/passport-google-oauth-tests.ts create mode 100644 passport-google-oauth/passport-google-oauth.d.ts diff --git a/passport-google-oauth/passport-google-oauth-tests.ts b/passport-google-oauth/passport-google-oauth-tests.ts new file mode 100644 index 000000000..60fad97b4 --- /dev/null +++ b/passport-google-oauth/passport-google-oauth-tests.ts @@ -0,0 +1,38 @@ +/** + * Created by jcabresos on 4/19/2014. + */ +import passport = require('passport'); +import google = require('passport-google-oauth'); + +// just some test model +var User = { + findOrCreate(id:string, provider:string, callback:(err:any, user:any) => void): void { + callback(null, {username:'james'}); + } +} + +passport.use(new google.OAuthStrategy({ + consumerKey: process.env.GOOGLE_CONSUMER_KEY, + consumerSecret: process.env.GOOGLE_CONSUMER_SECRET, + callbackURL: process.env.PASSPORT_GOOGLE_CALLBACK_URL + }, + function(accessToken:string, refreshToken:string, profile:google.Profile, done:(error:any, user?:any) => void) { + User.findOrCreate(profile.id, profile.provider, function(err, user) { + if (err) { return done(err); } + done(null, user); + }); + }) +); + +passport.use(new google.OAuth2Strategy({ + clientID: process.env.GOOGLE_CLIENT_ID, + clientSecret: process.env.GOOGLE_CLIENT_SECRET, + callbackURL: process.env.PASSPORT_GOOGLE_CALLBACK_URL + }, + function(accessToken:string, refreshToken:string, profile:google.Profile, done:(error:any, user?:any) => void) { + User.findOrCreate(profile.id, profile.provider, function(err, user) { + if (err) { return done(err); } + done(null, user); + }); + }) +); diff --git a/passport-google-oauth/passport-google-oauth.d.ts b/passport-google-oauth/passport-google-oauth.d.ts new file mode 100644 index 000000000..ea6c1e91a --- /dev/null +++ b/passport-google-oauth/passport-google-oauth.d.ts @@ -0,0 +1,60 @@ +// Type definitions for passport-facebook 1.0.3 +// Project: https://github.com/jaredhanson/passport-facebook +// Definitions by: James Roland Cabresos +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module 'passport-google-oauth' { + + import passport = require('passport'); + import express = require('express'); + + interface Profile extends passport.Profile { + gender: string; + } + + interface IOAuthStrategyOption { + consumerKey: string; + consumerSecret: string; + callbackURL: string; + + reguestTokenURL?: string; + accessTokenURL?: string; + userAuthorizationURL?: string; + sessionKey?: string; + } + + class OAuthStrategy implements passport.Strategy { + constructor(options: IOAuthStrategyOption, + verify: (accessToken: string, refreshToken: string, profile: Profile, done: (error: any, user?: any) => void) => void); + name: string; + authenticate: (req: express.Request, options?: Object) => void; + } + + interface IOAuth2StrategyOption { + clientID: string; + clientSecret: string; + callbackURL: string; + + authorizationURL?: string; + tokenURL?: string; + + accessType?: string; + approval_prompt?: string; + prompt?: string; + loginHint?: string; + userID?: string; + hostedDomain?: string; + display?: string; + requestVisibleActions?: string; + openIDRealm?: string; + } + + class OAuth2Strategy implements passport.Strategy { + constructor(options: IOAuth2StrategyOption, + verify: (accessToken: string, refreshToken: string, profile: Profile, done: (error: any, user?: any) => void) => void); + name: string; + authenticate: (req: express.Request, options?: Object) => void; + } +} From ca327372d6e390c5406cbab28b90934eaf883093 Mon Sep 17 00:00:00 2001 From: Josh Heyse Date: Wed, 3 Jun 2015 11:58:03 -0500 Subject: [PATCH 3/4] added passport-twitter definitions --- passport-twitter/passport-twitter-tests.ts | 25 +++++++++++++++ passport-twitter/passport-twitter.d.ts | 37 ++++++++++++++++++++++ 2 files changed, 62 insertions(+) create mode 100644 passport-twitter/passport-twitter-tests.ts create mode 100644 passport-twitter/passport-twitter.d.ts diff --git a/passport-twitter/passport-twitter-tests.ts b/passport-twitter/passport-twitter-tests.ts new file mode 100644 index 000000000..3abead1b2 --- /dev/null +++ b/passport-twitter/passport-twitter-tests.ts @@ -0,0 +1,25 @@ +/** + * Created by jcabresos on 4/19/2014. + */ +import passport = require('passport'); +import twitter = require('passport-twitter'); + +// just some test model +var User = { + findOrCreate(id:string, provider:string, callback:(err:any, user:any) => void): void { + callback(null, {username:'james'}); + } +} + +passport.use(new twitter.Strategy({ + clientID: process.env.PASSPORT_FACEBOOK_CLIENT_ID, + clientSecret: process.env.PASSPORT_FACEBOOK_CLIENT_SECRET, + callbackURL: process.env.PASSPORT_FACEBOOK_CALLBACK_URL + }, + function(accessToken:string, refreshToken:string, profile:twitter.Profile, done:(error:any, user?:any) => void) { + User.findOrCreate(profile.id, profile.provider, function(err, user) { + if (err) { return done(err); } + done(null, user); + }); + }) +); diff --git a/passport-twitter/passport-twitter.d.ts b/passport-twitter/passport-twitter.d.ts new file mode 100644 index 000000000..22e292acf --- /dev/null +++ b/passport-twitter/passport-twitter.d.ts @@ -0,0 +1,37 @@ +// Type definitions for passport-facebook 1.0.3 +// Project: https://github.com/jaredhanson/passport-facebook +// Definitions by: James Roland Cabresos +// Definitions: https://github.com/borisyankov/DefinitelyTyped + +/// + +declare module 'passport-twitter' { + + import passport = require('passport'); + import express = require('express'); + + interface Profile extends passport.Profile { + gender: string; + } + + interface IStrategyOption { + consumerKey: string; + consumerSecret: string; + callbackURL: string; + + reguestTokenURL?: string; + accessTokenURL?: string; + userAuthorizationURL?: string; + sessionKey?: string; + + userProfileURL?: string; + skipExtendedUserProfile?: boolean; + } + + class Strategy implements passport.Strategy { + constructor(options: IStrategyOption, + verify: (accessToken: string, refreshToken: string, profile: Profile, done: (error: any, user?: any) => void) => void); + name: string; + authenticate: (req: express.Request, options?: Object) => void; + } +} From a1915bad2e932a2be44a718818c3b5286793f26c Mon Sep 17 00:00:00 2001 From: Josh Heyse Date: Wed, 3 Jun 2015 12:35:10 -0500 Subject: [PATCH 4/4] fixed twitter tests, added _raw and _json properties --- passport-facebook/passport-facebook.d.ts | 3 +++ passport-google-oauth/passport-google-oauth.d.ts | 3 +++ passport-twitter/passport-twitter-tests.ts | 6 +++--- passport-twitter/passport-twitter.d.ts | 5 +++++ 4 files changed, 14 insertions(+), 3 deletions(-) diff --git a/passport-facebook/passport-facebook.d.ts b/passport-facebook/passport-facebook.d.ts index 26479cc29..b3adaf860 100644 --- a/passport-facebook/passport-facebook.d.ts +++ b/passport-facebook/passport-facebook.d.ts @@ -14,6 +14,9 @@ declare module 'passport-facebook' { gender: string; profileUrl: string; username: string; + + _raw: string; + _json: any; } interface IStrategyOption { diff --git a/passport-google-oauth/passport-google-oauth.d.ts b/passport-google-oauth/passport-google-oauth.d.ts index ea6c1e91a..27744021f 100644 --- a/passport-google-oauth/passport-google-oauth.d.ts +++ b/passport-google-oauth/passport-google-oauth.d.ts @@ -12,6 +12,9 @@ declare module 'passport-google-oauth' { interface Profile extends passport.Profile { gender: string; + + _raw: string; + _json: any; } interface IOAuthStrategyOption { diff --git a/passport-twitter/passport-twitter-tests.ts b/passport-twitter/passport-twitter-tests.ts index 3abead1b2..ae644dfa2 100644 --- a/passport-twitter/passport-twitter-tests.ts +++ b/passport-twitter/passport-twitter-tests.ts @@ -12,9 +12,9 @@ var User = { } passport.use(new twitter.Strategy({ - clientID: process.env.PASSPORT_FACEBOOK_CLIENT_ID, - clientSecret: process.env.PASSPORT_FACEBOOK_CLIENT_SECRET, - callbackURL: process.env.PASSPORT_FACEBOOK_CALLBACK_URL + consumerKey: process.env.PASSPORT_TWITTER_CONSUMER_KEY, + consumerSecret: process.env.PASSPORT_TWITTER_CONSUMER_SECRET, + callbackURL: process.env.PASSPORT_TWITTER_CALLBACK_URL }, function(accessToken:string, refreshToken:string, profile:twitter.Profile, done:(error:any, user?:any) => void) { User.findOrCreate(profile.id, profile.provider, function(err, user) { diff --git a/passport-twitter/passport-twitter.d.ts b/passport-twitter/passport-twitter.d.ts index 22e292acf..cb43aad26 100644 --- a/passport-twitter/passport-twitter.d.ts +++ b/passport-twitter/passport-twitter.d.ts @@ -12,6 +12,11 @@ declare module 'passport-twitter' { interface Profile extends passport.Profile { gender: string; + username: string; + + _raw: string; + _json: any; + _accessLevel: string; } interface IStrategyOption {