@types/koa-passport
TypeScript icon, indicating that this package has built-in type declarations

6.0.3 • Public • Published

Installation

npm install --save @types/koa-passport

Summary

This package contains type definitions for koa-passport (https://github.com/rkusa/koa-passport).

Details

Files were exported from https://github.com/DefinitelyTyped/DefinitelyTyped/tree/master/types/koa-passport.

index.d.ts

/* =================== USAGE ===================

    import * as passport from 'koa-passport';
    app.use(passport.initialize());
    app.use(passport.session());

 =============================================== */

import { Middleware } from "koa";

import * as passport from "passport";

declare module "koa" {
    interface ExtendableContext {
        login(user: any, options?: any): Promise<void>;
        logIn: ExtendableContext["login"];

        logout(): Promise<void>;
        logOut: ExtendableContext["logout"];

        isAuthenticated(): boolean;
        isUnauthenticated(): boolean;
    }
}

declare namespace KoaPassport {
    class 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 | string[], callback?: (...args: any[]) => any): Middleware;
        authenticate(
            strategy: string | string[],
            options: passport.AuthenticateOptions | object,
            callback?: (...args: any[]) => any,
        ): Middleware;
        authorize(strategy: string | string[], callback?: (...args: any[]) => any): Middleware;
        authorize(strategy: string | string[], options: any, callback?: (...args: any[]) => any): Middleware;

        serializeUser: passport.Authenticator["serializeUser"];
        deserializeUser: passport.Authenticator["deserializeUser"];
        transformAuthInfo: passport.Authenticator["transformAuthInfo"];
    }

    interface Static extends KoaPassport {
        KoaPassport: typeof KoaPassport;
        Passport: typeof passport.Passport;
        Authenticator: Static["Passport"];
    }
}

declare const koaPassport: KoaPassport.Static;

export = koaPassport;

Additional Details

Credits

These definitions were written by horiuchi, Tomek Łaziuk, and Tümay Çeber.

Readme

Keywords

none

Package Sidebar

Install

npm i @types/koa-passport

Weekly Downloads

25,740

Version

6.0.3

License

MIT

Unpacked Size

7.03 kB

Total Files

5

Last publish

Collaborators

  • types