mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-06-28 22:30:01 +00:00
34
types/passport-github/index.d.ts
vendored
Normal file
34
types/passport-github/index.d.ts
vendored
Normal file
@@ -0,0 +1,34 @@
|
||||
// Type definitions for passport-github 1.1
|
||||
// Project: https://github.com/jaredhanson/passport-github
|
||||
// Definitions by: Yasunori Ohoka <https://github.com/yasupeke>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
|
||||
import passport = require('passport');
|
||||
import express = require('express');
|
||||
|
||||
export interface Profile extends passport.Profile {
|
||||
profileUrl: string;
|
||||
}
|
||||
|
||||
export interface StrategyOption {
|
||||
clientID: string;
|
||||
clientSecret: string;
|
||||
callbackURL: string;
|
||||
|
||||
scope?: string[];
|
||||
userAgent?: string;
|
||||
|
||||
authorizationURL?: string;
|
||||
tokenURL?: string;
|
||||
scopeSeparator?: string;
|
||||
customHeaders?: string;
|
||||
userProfileURL?: string;
|
||||
}
|
||||
|
||||
export class Strategy implements passport.Strategy {
|
||||
constructor(options: StrategyOption, verify: (accessToken: string, refreshToken: string, profile: Profile, done: (error: any, user?: any) => void) => void);
|
||||
userProfile: (accessToken: string, done?: (error: any, profile: Profile) => void) => void;
|
||||
|
||||
name: string;
|
||||
authenticate: (req: express.Request, options?: passport.AuthenticateOptions) => void;
|
||||
}
|
||||
26
types/passport-github/passport-github-tests.ts
Normal file
26
types/passport-github/passport-github-tests.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Created by jcabresos on 4/19/2014.
|
||||
*/
|
||||
import passport = require('passport');
|
||||
import github = require('passport-github');
|
||||
|
||||
// just some test model
|
||||
const User = {
|
||||
findOrCreate(id: string, provider: string, callback: (err: any, user: any) => void): void {
|
||||
callback(null, { username: 'james' });
|
||||
}
|
||||
};
|
||||
|
||||
passport.use(new github.Strategy(
|
||||
{
|
||||
clientID: process.env.PASSPORT_GITHUB_CONSUMER_KEY,
|
||||
clientSecret: process.env.PASSPORT_GITHUB_CONSUMER_SECRET,
|
||||
callbackURL: process.env.PASSPORT_GITHUB_CALLBACK_URL
|
||||
},
|
||||
(accessToken: string, refreshToken: string, profile: github.Profile, done: (error: any, user?: any) => void) => {
|
||||
User.findOrCreate(profile.id, profile.provider, (err, user) => {
|
||||
if (err) { return done(err); }
|
||||
done(null, user);
|
||||
});
|
||||
})
|
||||
);
|
||||
22
types/passport-github/tsconfig.json
Normal file
22
types/passport-github/tsconfig.json
Normal file
@@ -0,0 +1,22 @@
|
||||
{
|
||||
"compilerOptions": {
|
||||
"module": "commonjs",
|
||||
"lib": [
|
||||
"es6"
|
||||
],
|
||||
"noImplicitAny": true,
|
||||
"noImplicitThis": true,
|
||||
"strictNullChecks": true,
|
||||
"baseUrl": "../",
|
||||
"typeRoots": [
|
||||
"../"
|
||||
],
|
||||
"types": [],
|
||||
"noEmit": true,
|
||||
"forceConsistentCasingInFileNames": true
|
||||
},
|
||||
"files": [
|
||||
"index.d.ts",
|
||||
"passport-github-tests.ts"
|
||||
]
|
||||
}
|
||||
1
types/passport-github/tslint.json
Normal file
1
types/passport-github/tslint.json
Normal file
@@ -0,0 +1 @@
|
||||
{ "extends": "dtslint/dt.json" }
|
||||
Reference in New Issue
Block a user