mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-03 11:41:44 +00:00
koa-passport 4.0
This commit is contained in:
Vendored
+39
-33
@@ -1,6 +1,7 @@
|
||||
// Type definitions for koa-passport 2.x
|
||||
// Type definitions for koa-passport 4.0
|
||||
// Project: https://github.com/rkusa/koa-passport
|
||||
// Definitions by: horiuchi <https://github.com/horiuchi>
|
||||
// Tomek Łaziuk <https://github.com/tlaziuk>
|
||||
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
|
||||
// TypeScript Version: 2.3
|
||||
|
||||
@@ -12,52 +13,57 @@
|
||||
|
||||
=============================================== */
|
||||
|
||||
import * as Koa from "koa";
|
||||
import {
|
||||
Middleware,
|
||||
} from "koa";
|
||||
|
||||
import * as passport from "passport";
|
||||
|
||||
declare module "koa" {
|
||||
interface Context {
|
||||
authInfo?: any;
|
||||
user?: any;
|
||||
|
||||
login(user: any): Promise<void>;
|
||||
login(user: any, options: Object): Promise<void>;
|
||||
logIn(user: any): Promise<void>;
|
||||
logIn(user: any, options: Object): Promise<void>;
|
||||
logIn: Context["login"];
|
||||
|
||||
logout(): void;
|
||||
logOut(): void;
|
||||
logOut: Context["logout"];
|
||||
|
||||
isAuthenticated(): boolean;
|
||||
isUnauthenticated(): boolean;
|
||||
}
|
||||
}
|
||||
|
||||
import * as passport from "passport";
|
||||
|
||||
interface KoaPassport {
|
||||
use(strategy: passport.Strategy): this;
|
||||
use(name: string, strategy: passport.Strategy): this;
|
||||
unuse(name: string): this;
|
||||
framework(fw: passport.Framework): this;
|
||||
initialize(options?: { userProperty: string; }): Koa.Middleware;
|
||||
session(options?: { pauseStream: boolean; }): Koa.Middleware;
|
||||
|
||||
authenticate(strategy: string, callback?: Function): Koa.Middleware;
|
||||
authenticate(strategy: string, options: Object, callback?: Function): Koa.Middleware;
|
||||
authenticate(strategies: string[], callback?: Function): Koa.Middleware;
|
||||
authenticate(strategies: string[], options: Object, callback?: Function): Koa.Middleware;
|
||||
authorize(strategy: string, callback?: Function): Koa.Middleware;
|
||||
authorize(strategy: string, options: Object, callback?: Function): Koa.Middleware;
|
||||
authorize(strategies: string[], callback?: Function): Koa.Middleware;
|
||||
authorize(strategies: string[], options: Object, callback?: Function): Koa.Middleware;
|
||||
serializeUser(fn: (user: any, done: (err: any, id: any) => void) => void): void;
|
||||
deserializeUser(fn: (id: any, done: (err: any, user: any) => void) => void): void;
|
||||
transformAuthInfo(fn: (info: any, done: (err: any, info: any) => void) => void): void;
|
||||
}
|
||||
declare const koaPassport: KoaPassport;
|
||||
|
||||
declare namespace KoaPassport {
|
||||
interface Profile extends passport.Profile { }
|
||||
interface Framework extends passport.Framework { }
|
||||
|
||||
interface KoaPassport {
|
||||
use(strategy: passport.Strategy): this;
|
||||
use(name: string, strategy: passport.Strategy): this;
|
||||
unuse(name: string): this;
|
||||
framework(fw: passport.Framework): this;
|
||||
initialize(options?: { userProperty: string; }): Middleware;
|
||||
session(options?: { pauseStream: boolean; }): Middleware;
|
||||
|
||||
authenticate(strategy: string, callback?: Function): Middleware;
|
||||
authenticate(strategy: string, options: Object, callback?: Function): Middleware;
|
||||
authenticate(strategies: string[], callback?: Function): Middleware;
|
||||
authenticate(strategies: string[], options: Object, callback?: Function): Middleware;
|
||||
authorize(strategy: string, callback?: Function): Middleware;
|
||||
authorize(strategy: string, options: Object, callback?: Function): Middleware;
|
||||
authorize(strategies: string[], callback?: Function): Middleware;
|
||||
authorize(strategies: string[], options: Object, callback?: Function): Middleware;
|
||||
serializeUser(fn: (user: any, done: (err: any, id: any) => void) => void): void;
|
||||
deserializeUser(fn: (id: any, done: (err: any, user: any) => void) => void): void;
|
||||
transformAuthInfo(fn: (info: any, done: (err: any, info: any) => void) => void): void;
|
||||
}
|
||||
|
||||
interface Static extends KoaPassport {
|
||||
KoaPassport: { new(): KoaPassport };
|
||||
Passport: { new(): passport.Passport };
|
||||
Authenticator: Static["Passport"];
|
||||
}
|
||||
}
|
||||
|
||||
declare const koaPassport: KoaPassport.Static;
|
||||
|
||||
export = koaPassport;
|
||||
|
||||
@@ -36,3 +36,4 @@ app.use(
|
||||
})
|
||||
);
|
||||
|
||||
class KoaPasspordChild extends passport.KoaPassport { }
|
||||
|
||||
Reference in New Issue
Block a user