added passport-beam

This commit is contained in:
AtlasDev
2016-10-04 18:32:03 +02:00
parent c8a7c97b43
commit d5cd803691
2 changed files with 64 additions and 0 deletions
+27
View File
@@ -0,0 +1,27 @@
/// <reference path="./passport-beam.d.ts" />
/**
* Created by AtlasDev on 4/10/2016.
* Based on typings from passport-facebook by jcabresos.
*/
import passport = require('passport');
import beam = require('passport-beam');
var User = {
findOrCreate(id:string, provider:string, callback:(err:any, user:any) => void): void {
callback(null, { username: 'Dany' });
}
}
passport.use(new beam.Strategy({
clientID: BEAM_CLIENT_ID,
clientSecret: BEAM_CLIENT_SECRET,
callbackURL: "http://127.0.0.1:3000/auth/beam/callback"
},
function(accessToken:string, refreshToken:string, profile:beam.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-beam 1.0.4
// Project: https://github.com/alfw/passport-beam
// Definitions by: AtlasDev <https://github.com/AtlasDev>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference path="../passport/passport.d.ts"/>
declare module "passport-beam" {
import * as passport from 'passport';
import * as express from 'express';
interface Profile extends passport.Profile {
gender: string;
profileUrl: string;
id: number
username: string;
provider: string;
email: string;
_raw: string;
_json: any;
}
interface IStrategyOption {
clientID: string;
clientSecret: string;
callbackURL: string;
}
class Strategy implements passport.Strategy {
constructor(options: IStrategyOption, verify: (accessToken: string, refreshToken: string, profile: any, done: (error: any, user?: any) => void) => void);
name: string;
authenticate: (req: express.Request, options?: Object) => void;
}
}