UNPKG

1.26 kBTypeScriptView Raw
1/// <reference types="passport"/>
2
3import { Strategy as PassportStrategy } from "passport-strategy";
4import express = require("express");
5
6interface IStrategyOptions {
7 usernameField?: string | undefined;
8 passwordField?: string | undefined;
9 session?: boolean | undefined;
10 passReqToCallback?: false | undefined;
11}
12
13interface IStrategyOptionsWithRequest {
14 usernameField?: string | undefined;
15 passwordField?: string | undefined;
16 session?: boolean | undefined;
17 passReqToCallback: true;
18}
19
20interface IVerifyOptions {
21 message: string;
22}
23
24interface VerifyFunctionWithRequest {
25 (
26 req: express.Request,
27 username: string,
28 password: string,
29 done: (error: any, user?: Express.User | false, options?: IVerifyOptions) => void,
30 ): void;
31}
32
33interface VerifyFunction {
34 (
35 username: string,
36 password: string,
37 done: (error: any, user?: Express.User | false, options?: IVerifyOptions) => void,
38 ): void;
39}
40
41declare class Strategy extends PassportStrategy {
42 constructor(options: IStrategyOptionsWithRequest, verify: VerifyFunctionWithRequest);
43 constructor(options: IStrategyOptions, verify: VerifyFunction);
44 constructor(verify: VerifyFunction);
45
46 name: string;
47}