@types/passport

  • Version 1.0.6
  • Published
  • 11.1 kB
  • 1 dependency
  • MIT license

Install

npm i @types/passport
yarn add @types/passport
pnpm add @types/passport

Overview

TypeScript definitions for Passport

Index

Variables

variable passport

const passport: passport.PassportStatic;

    Interfaces

    interface AuthenticateOptions

    interface AuthenticateOptions {}

      property assignProperty

      assignProperty?: string;

        property authInfo

        authInfo?: boolean;

          property failureFlash

          failureFlash?: string | boolean;

            property failureMessage

            failureMessage?: boolean | string;

              property failureRedirect

              failureRedirect?: string;

                property failWithError

                failWithError?: boolean;

                  property passReqToCallback

                  passReqToCallback?: boolean;

                    property pauseStream

                    pauseStream?: boolean;

                      property prompt

                      prompt?: string;

                        property scope

                        scope?: string | string[];

                          property session

                          session?: boolean;

                            property state

                            state?: string;

                              property successFlash

                              successFlash?: string | boolean;

                                property successMessage

                                successMessage?: boolean | string;

                                  property successRedirect

                                  successRedirect?: string;

                                    property successReturnToOrRedirect

                                    successReturnToOrRedirect?: string;

                                      property userProperty

                                      userProperty?: string;

                                        interface Authenticator

                                        interface Authenticator<
                                        InitializeRet = express.Handler,
                                        AuthenticateRet = any,
                                        AuthorizeRet = AuthenticateRet,
                                        AuthorizeOptions = AuthenticateOptions
                                        > {}

                                          method authenticate

                                          authenticate: {
                                          (
                                          strategy: string | string[] | Strategy,
                                          callback?: (...args: any[]) => any
                                          ): AuthenticateRet;
                                          (
                                          strategy: string | string[] | Strategy,
                                          options: AuthenticateOptions,
                                          callback?: (...args: any[]) => any
                                          ): AuthenticateRet;
                                          };

                                            method authorize

                                            authorize: {
                                            (
                                            strategy: string | string[],
                                            callback?: (...args: any[]) => any
                                            ): AuthorizeRet;
                                            (
                                            strategy: string | string[],
                                            options: AuthorizeOptions,
                                            callback?: (...args: any[]) => any
                                            ): AuthorizeRet;
                                            };

                                              method deserializeUser

                                              deserializeUser: {
                                              <TID>(
                                              fn: (
                                              id: TID,
                                              done: (err: any, user?: Express.User | false | null) => void
                                              ) => void
                                              ): void;
                                              <TID, TR extends any = any>(
                                              fn: (
                                              req: TR,
                                              id: TID,
                                              done: (err: any, user?: false | Express.User) => void
                                              ) => void
                                              ): void;
                                              };

                                                method framework

                                                framework: <X, Y, Z>(fw: Framework<X, Y, Z>) => Authenticator<X, Y, Z>;

                                                  method initialize

                                                  initialize: (options?: { userProperty: string }) => InitializeRet;

                                                    method serializeUser

                                                    serializeUser: {
                                                    <TID>(
                                                    fn: (user: Express.User, done: (err: any, id?: TID) => void) => void
                                                    ): void;
                                                    <TID, TR extends any = any>(
                                                    fn: (
                                                    req: TR,
                                                    user: Express.User,
                                                    done: (err: any, id?: TID) => void
                                                    ) => void
                                                    ): void;
                                                    };

                                                      method session

                                                      session: (options?: { pauseStream: boolean }) => AuthenticateRet;

                                                        method transformAuthInfo

                                                        transformAuthInfo: (
                                                        fn: (info: any, done: (err: any, info: any) => void) => void
                                                        ) => void;

                                                          method unuse

                                                          unuse: (name: string) => this;

                                                            method use

                                                            use: { (strategy: Strategy): this; (name: string, strategy: Strategy): this };

                                                              interface Framework

                                                              interface Framework<
                                                              InitializeRet = any,
                                                              AuthenticateRet = any,
                                                              AuthorizeRet = AuthenticateRet
                                                              > {}

                                                                method authenticate

                                                                authenticate: (
                                                                passport: Authenticator<InitializeRet, AuthenticateRet, AuthorizeRet>,
                                                                name: string,
                                                                options?: any,
                                                                callback?: (...args: any[]) => any
                                                                ) => (...args: any[]) => AuthenticateRet;

                                                                  method authorize

                                                                  authorize: (
                                                                  passport: Authenticator<InitializeRet, AuthenticateRet, AuthorizeRet>,
                                                                  name: string,
                                                                  options?: any,
                                                                  callback?: (...args: any[]) => any
                                                                  ) => (...args: any[]) => AuthorizeRet;

                                                                    method initialize

                                                                    initialize: (
                                                                    passport: Authenticator<InitializeRet, AuthenticateRet, AuthorizeRet>,
                                                                    options?: any
                                                                    ) => (...args: any[]) => InitializeRet;

                                                                      interface PassportStatic

                                                                      interface PassportStatic extends Authenticator {}

                                                                        property Authenticator

                                                                        Authenticator: { new (): Authenticator };

                                                                          property Passport

                                                                          Passport: PassportStatic['Authenticator'];

                                                                            property Strategy

                                                                            Strategy: { new (): Strategy & StrategyCreatedStatic };

                                                                              interface Profile

                                                                              interface Profile {}

                                                                                property displayName

                                                                                displayName: string;

                                                                                  property emails

                                                                                  emails?: Array<{
                                                                                  value: string;
                                                                                  type?: string;
                                                                                  }>;

                                                                                    property id

                                                                                    id: string;

                                                                                      property name

                                                                                      name?: {
                                                                                      familyName: string;
                                                                                      givenName: string;
                                                                                      middleName?: string;
                                                                                      };

                                                                                        property photos

                                                                                        photos?: Array<{
                                                                                        value: string;
                                                                                        }>;

                                                                                          property provider

                                                                                          provider: string;

                                                                                            property username

                                                                                            username?: string;

                                                                                              interface Strategy

                                                                                              interface Strategy {}

                                                                                                property name

                                                                                                name?: string;

                                                                                                  method authenticate

                                                                                                  authenticate: (this: StrategyCreated<this>, req: any, options?: any) => any;

                                                                                                    interface StrategyCreatedStatic

                                                                                                    interface StrategyCreatedStatic {}

                                                                                                      method error

                                                                                                      error: (err: any) => void;
                                                                                                      • Internal error while performing authentication.

                                                                                                        Strategies should call this function when an internal error occurs during the process of performing authentication; for example, if the user directory is not available.

                                                                                                      method fail

                                                                                                      fail: (challenge?: string | number, status?: number) => void;
                                                                                                      • Fail authentication, with optional challenge and status, defaulting to 401.

                                                                                                        Strategies should call this function to fail an authentication attempt.

                                                                                                      method pass

                                                                                                      pass: () => void;
                                                                                                      • Pass without making a success or fail decision.

                                                                                                        Under most circumstances, Strategies should not need to call this function. It exists primarily to allow previous authentication state to be restored, for example from an HTTP session.

                                                                                                      method redirect

                                                                                                      redirect: (url: string, status?: number) => void;
                                                                                                      • Redirect to url with optional status, defaulting to 302.

                                                                                                        Strategies should call this function to redirect the user (via their user agent) to a third-party website for authentication.

                                                                                                      method success

                                                                                                      success: (user: Express.User, info?: object) => void;
                                                                                                      • Authenticate user, with optional info.

                                                                                                        Strategies should call this function to successfully authenticate a user. user should be an object supplied by the application after it has been given an opportunity to verify credentials. info is an optional argument containing additional user information. This is useful for third-party authentication strategies to pass profile details.

                                                                                                      Type Aliases

                                                                                                      type StrategyCreated

                                                                                                      type StrategyCreated<T, O = T & StrategyCreatedStatic> = {
                                                                                                      [P in keyof O]: O[P];
                                                                                                      };

                                                                                                        Namespaces

                                                                                                        namespace global

                                                                                                        namespace global {}

                                                                                                          namespace global.Express

                                                                                                          namespace global.Express {}

                                                                                                            interface AuthenticatedRequest

                                                                                                            interface AuthenticatedRequest extends Request {}

                                                                                                              property user

                                                                                                              user: User;

                                                                                                                interface AuthInfo

                                                                                                                interface AuthInfo {}

                                                                                                                  interface Request

                                                                                                                  interface Request {}

                                                                                                                    property authInfo

                                                                                                                    authInfo?: AuthInfo;

                                                                                                                      property user

                                                                                                                      user?: User;

                                                                                                                        method isAuthenticated

                                                                                                                        isAuthenticated: () => this is AuthenticatedRequest;

                                                                                                                          method isUnauthenticated

                                                                                                                          isUnauthenticated: () => this is UnauthenticatedRequest;

                                                                                                                            method login

                                                                                                                            login: {
                                                                                                                            (user: User, done: (err: any) => void): void;
                                                                                                                            (user: User, options: any, done: (err: any) => void): void;
                                                                                                                            };

                                                                                                                              method logIn

                                                                                                                              logIn: {
                                                                                                                              (user: User, done: (err: any) => void): void;
                                                                                                                              (user: User, options: any, done: (err: any) => void): void;
                                                                                                                              };

                                                                                                                                method logout

                                                                                                                                logout: () => void;

                                                                                                                                  method logOut

                                                                                                                                  logOut: () => void;

                                                                                                                                    interface UnauthenticatedRequest

                                                                                                                                    interface UnauthenticatedRequest extends Request {}

                                                                                                                                      property user

                                                                                                                                      user?: undefined;

                                                                                                                                        interface User

                                                                                                                                        interface User {}

                                                                                                                                          Package Files (1)

                                                                                                                                          Dependencies (1)

                                                                                                                                          Dev Dependencies (0)

                                                                                                                                          No dev dependencies.

                                                                                                                                          Peer Dependencies (0)

                                                                                                                                          No peer dependencies.

                                                                                                                                          Badge

                                                                                                                                          To add a badge like this onejsDocs.io badgeto your package's README, use the codes available below.

                                                                                                                                          You may also use Shields.io to create a custom badge linking to https://www.jsdocs.io/package/@types/passport.

                                                                                                                                          • Markdown
                                                                                                                                            [![jsDocs.io](https://img.shields.io/badge/jsDocs.io-reference-blue)](https://www.jsdocs.io/package/@types/passport)
                                                                                                                                          • HTML
                                                                                                                                            <a href="https://www.jsdocs.io/package/@types/passport"><img src="https://img.shields.io/badge/jsDocs.io-reference-blue" alt="jsDocs.io"></a>