diff --git a/types/passport-http/index.d.ts b/types/passport-http/index.d.ts index aedb119fa0..bb9dd35c1b 100644 --- a/types/passport-http/index.d.ts +++ b/types/passport-http/index.d.ts @@ -1,62 +1,69 @@ -// Type definitions for passport-http 0.3.0 +// Type definitions for passport-http 0.3 // Project: https://github.com/jaredhanson/passport-http // Definitions by: Christophe Vidal // Tomek Łaziuk // Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped // TypeScript Version: 2.3 -import passport = require("passport"); -import express = require("express"); +import * as passport from "passport"; +import * as express from "express"; -interface BasicStrategyOptions { +export interface BasicStrategyOptions { realm?: string; passReqToCallback?: req; } -interface DigestStrategyOptions { +export interface DigestStrategyOptions { realm?: string; - domain?: string | Array; + domain?: string | string[]; opaque?: string; algorithm?: string; - qop?: string | Array; + qop?: string | string[]; } -interface DigestValidateOptions { +export interface DigestValidateOptions { nonce: string; cnonce: string; nc: number; opaque: string; } -interface BasicVerifyFunction { - (username: string, password: string, done: (error: any, user?: any) => void): void; -} +export type BasicVerifyFunction = ( + username: string, + password: string, + done: (error: any, user?: any) => void, +) => any; -interface BasicVerifyFunctionWithRequest { - (req: express.Request, username: string, password: string, done: (error: any, user?: any) => void): void; -} +export type BasicVerifyFunctionWithRequest = ( + req: express.Request, + username: string, + password: string, + done: (error: any, user?: any) => void, +) => any; -interface DigestSecretFunction { - (username: string, done: (error: any, user?: any, password?: any) => void): void; -} +export type DigestSecretFunction = ( + username: string, + done: (error: any, user?: any, password?: any) => void, +) => any; -interface DigestValidateFunction { - (params: DigestValidateOptions, done: (error: any, valid: boolean) => void): void; -} +export type DigestValidateFunction = ( + params: DigestValidateOptions, + done: (error: any, valid: boolean) => void, +) => any; -declare class BasicStrategy implements passport.Strategy { +export class BasicStrategy implements passport.Strategy { constructor(verify: BasicVerifyFunction); constructor(options: BasicStrategyOptions, verify: BasicVerifyFunction); constructor(options: BasicStrategyOptions, verify: BasicVerifyFunctionWithRequest); name: string; - authenticate: (req: express.Request, options?: Object) => void; + authenticate: (req: express.Request, options?: object) => void; } -declare class DigestStrategy implements passport.Strategy { +export declare class DigestStrategy implements passport.Strategy { constructor(secret: DigestSecretFunction, validate?: DigestValidateFunction); constructor(options: DigestStrategyOptions, secret: DigestSecretFunction, validate?: DigestValidateFunction); name: string; - authenticate: (req: express.Request, options?: Object) => void; + authenticate: (req: express.Request, options?: object) => void; } diff --git a/types/passport-http/passport-http-tests.ts b/types/passport-http/passport-http-tests.ts index 217bb5e289..a9e09b0df1 100644 --- a/types/passport-http/passport-http-tests.ts +++ b/types/passport-http/passport-http-tests.ts @@ -2,18 +2,18 @@ * Created by Christophe Vidal */ -import passport = require("passport"); -import http = require("passport-http"); +import * as passport from "passport"; +import * as http from "passport-http"; -interface IUser { +interface UserInterface { username: string; password?: string; } class User { - public password: string; + password: string; - static findOne(user: IUser, callback: (error: Error, user: User) => void): void { + static findOne(user: UserInterface, callback: (error: Error, user: User) => void): void { callback(null, new User()); } } @@ -26,8 +26,8 @@ function validateParams(nonce: string, cnonce: string, nc: number, opaque: strin passport.use(new http.BasicStrategy((username, password, done) => { User.findOne({ - username: username, - password: password, + username, + password, }, (error, user) => { if (error) { return done(error); @@ -62,7 +62,7 @@ passport.use(new http.BasicStrategy({ })); passport.use(new http.DigestStrategy((username: string, done: any) => { - User.findOne({username: username}, (error, user) => { + User.findOne({username}, (error, user) => { if (error) { return done(error); } @@ -76,7 +76,7 @@ passport.use(new http.DigestStrategy((username: string, done: any) => { })); passport.use(new http.DigestStrategy((username: string, done: any) => { - User.findOne({username: username}, (error, user) => { + User.findOne({username}, (error, user) => { if (error) { return done(error); } @@ -99,7 +99,7 @@ passport.use(new http.DigestStrategy({ algorithm: "MD5", qop: "auth", }, (username: string, done: any) => { - User.findOne({username: username}, (error, user) => { + User.findOne({username}, (error, user) => { if (error) { return done(error); } @@ -119,7 +119,7 @@ passport.use(new http.DigestStrategy({ algorithm: "MD5", qop: "auth", }, (username: string, done: any) => { - User.findOne({username: username}, (error, user) => { + User.findOne({username}, (error, user) => { if (error) { return done(error); }