mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-01-30 21:47:35 +00:00
Merge pull request #17892 from kzay/passport-discord
Added declarations for 'passport-discord'.
This commit is contained in:
commit
fec9cd6842
46
types/passport-discord/index.d.ts
vendored
Normal file
46
types/passport-discord/index.d.ts
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
// Type definitions for passport-discord 0.1
|
||||
// Project: https://github.com/nicholastay/passport-discord#readme
|
||||
// Definitions by: Gonthier Renaud <https://github.com/kzay>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.2
|
||||
/** Declaration file generated by dts-gen */
|
||||
|
||||
import * as passport from 'passport';
|
||||
import * as express from 'express';
|
||||
|
||||
export class Strategy implements passport.Strategy {
|
||||
constructor(options: Strategy.StrategyOption, verify: (accessToken: string, refreshToken: string, profile: Strategy.Profile, done: (error: any, user?: any) => void) => void);
|
||||
name: string;
|
||||
authenticate: (req: express.Request, options?: object) => void;
|
||||
|
||||
authorizationParams(options: any): any;
|
||||
|
||||
checkScope(scope: any, accessToken: any, cb: any): any;
|
||||
|
||||
parseErrorResponse(body: any, status: any): any;
|
||||
|
||||
tokenParams(options: any): any;
|
||||
|
||||
userProfile(accessToken: any, done: any): any;
|
||||
}
|
||||
|
||||
export namespace Strategy {
|
||||
interface StrategyOption {
|
||||
clientID: string;
|
||||
clientSecret: string;
|
||||
callbackURL: string;
|
||||
scope?: string[];
|
||||
}
|
||||
|
||||
interface Profile extends passport.Profile {
|
||||
profileUrl: string;
|
||||
id: any;
|
||||
username: string;
|
||||
discriminator: string;
|
||||
avatar: string;
|
||||
verified: boolean;
|
||||
email: string;
|
||||
_raw: any;
|
||||
_json: any;
|
||||
}
|
||||
}
|
||||
25
types/passport-discord/passport-discord-tests.ts
Normal file
25
types/passport-discord/passport-discord-tests.ts
Normal file
@ -0,0 +1,25 @@
|
||||
/**
|
||||
* Created by kzaY on 07/09/2017.
|
||||
*/
|
||||
import passport = require('passport');
|
||||
import discord = require('passport-discord');
|
||||
|
||||
// just some test model
|
||||
let User = {
|
||||
findOrCreate(discordId: any, callback: (err: any, user: any) => void): void {
|
||||
callback(null, { username: 'james' });
|
||||
}
|
||||
};
|
||||
|
||||
passport.use(new discord.Strategy(
|
||||
{
|
||||
clientID: 'clientID',
|
||||
clientSecret: 'clientSecret',
|
||||
callbackURL: 'callbackURL'
|
||||
},
|
||||
(accessToken: string, refreshToken: string, profile: any, cb: any) => {
|
||||
User.findOrCreate({ discordId: profile.id }, (err, user) => {
|
||||
return cb(err, user);
|
||||
});
|
||||
}
|
||||
));
|
||||
22
types/passport-discord/tsconfig.json
Normal file
22
types/passport-discord/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-discord-tests.ts"
|
||||
]
|
||||
}
|
||||
5
types/passport-discord/tslint.json
Normal file
5
types/passport-discord/tslint.json
Normal file
@ -0,0 +1,5 @@
|
||||
{
|
||||
"extends": "dtslint/dt.json",
|
||||
"rules": {
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue
Block a user