added passport-twitter definitions

This commit is contained in:
Josh Heyse
2015-06-03 11:58:03 -05:00
parent 3bf10e44d1
commit ca327372d6
2 changed files with 62 additions and 0 deletions
@@ -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);
});
})
);
+37
View File
@@ -0,0 +1,37 @@
// Type definitions for passport-facebook 1.0.3
// Project: https://github.com/jaredhanson/passport-facebook
// Definitions by: James Roland Cabresos <https://github.com/staticfunction>
// Definitions: https://github.com/borisyankov/DefinitelyTyped
/// <reference path="../passport/passport.d.ts"/>
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;
}
}