mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-05-23 04:47:24 +08:00
added passport-google-oauth definitions
This commit is contained in:
38
passport-google-oauth/passport-google-oauth-tests.ts
Normal file
38
passport-google-oauth/passport-google-oauth-tests.ts
Normal file
@@ -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);
|
||||
});
|
||||
})
|
||||
);
|
||||
60
passport-google-oauth/passport-google-oauth.d.ts
vendored
Normal file
60
passport-google-oauth/passport-google-oauth.d.ts
vendored
Normal file
@@ -0,0 +1,60 @@
|
||||
// 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-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;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user