diff --git a/passport-facebook/passport-facebook-test.ts b/passport-facebook/passport-facebook-test.ts new file mode 100644 index 0000000000..b35770479f --- /dev/null +++ b/passport-facebook/passport-facebook-test.ts @@ -0,0 +1,25 @@ +/** + * Created by jcabresos on 4/19/2014. + */ +import passport = require('passport'); +import facebook = require('passport-facebook'); + +// 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 facebook.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:facebook.Profile, done:(error:any, user?:any) => void) { + User.findOrCreate(profile.id, profile.provider, function(err, user) { + if (err) { return done(err); } + done(null, user); + }); + }) +); \ No newline at end of file diff --git a/passport-facebook/passport-facebook.d.ts b/passport-facebook/passport-facebook.d.ts new file mode 100644 index 0000000000..c6a9d97b26 --- /dev/null +++ b/passport-facebook/passport-facebook.d.ts @@ -0,0 +1,31 @@ +// 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-facebook' { + + import passport = require('passport'); + import express = require('express'); + + interface Profile { + id:string; + provider:string; + displayName:string; + name:{familyName:string; givenName:string; middleName:string}; + profileUrl:string; + } + + interface User { + + } + + class Strategy implements passport.Strategy{ + constructor(options:{clientID:string; clientSecret:string; callbackURL:string}, + verify:(accessToken:string, refreshToken:string, profile:Profile, done:(error:any, user?:any) => void) => void); + name: string; + authenticate:(req: express.Request, options?: Object) => void; + } +} \ No newline at end of file