diff --git a/types/passport-github/index.d.ts b/types/passport-github/index.d.ts new file mode 100644 index 0000000000..38704a0a88 --- /dev/null +++ b/types/passport-github/index.d.ts @@ -0,0 +1,34 @@ +// Type definitions for passport-github 1.1 +// Project: https://github.com/jaredhanson/passport-github +// Definitions by: Yasunori Ohoka +// 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; +} diff --git a/types/passport-github/passport-github-tests.ts b/types/passport-github/passport-github-tests.ts new file mode 100644 index 0000000000..72697a7dd2 --- /dev/null +++ b/types/passport-github/passport-github-tests.ts @@ -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); + }); + }) +); diff --git a/types/passport-github/tsconfig.json b/types/passport-github/tsconfig.json new file mode 100644 index 0000000000..a71ba7d95e --- /dev/null +++ b/types/passport-github/tsconfig.json @@ -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" + ] +} \ No newline at end of file diff --git a/types/passport-github/tslint.json b/types/passport-github/tslint.json new file mode 100644 index 0000000000..3db14f85ea --- /dev/null +++ b/types/passport-github/tslint.json @@ -0,0 +1 @@ +{ "extends": "dtslint/dt.json" }