@types/passport

  • Version 1.0.11
  • Published
  • 11.8 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 | undefined;

        property authInfo

        authInfo?: boolean | undefined;

          property failureFlash

          failureFlash?: string | boolean | undefined;

            property failureMessage

            failureMessage?: boolean | string | undefined;

              property failureRedirect

              failureRedirect?: string | undefined;

                property failWithError

                failWithError?: boolean | undefined;

                  property keepSessionInfo

                  keepSessionInfo?: boolean | undefined;

                    property passReqToCallback

                    passReqToCallback?: boolean | undefined;

                      property pauseStream

                      pauseStream?: boolean | undefined;

                        property prompt

                        prompt?: string | undefined;

                          property scope

                          scope?: string | string[] | undefined;

                            property session

                            session?: boolean | undefined;

                              property state

                              state?: string | undefined;

                                property successFlash

                                successFlash?: string | boolean | undefined;

                                  property successMessage

                                  successMessage?: boolean | string | undefined;

                                    property successRedirect

                                    successRedirect?: string | undefined;

                                      property successReturnToOrRedirect

                                      successReturnToOrRedirect?: string | undefined;

                                        property userProperty

                                        userProperty?: string | undefined;

                                          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 IncomingMessage = express.Request>(
                                                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 IncomingMessage = express.Request>(
                                                      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 | undefined;
                                                                                    }>
                                                                                    | undefined;

                                                                                      property id

                                                                                      id: string;

                                                                                        property name

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

                                                                                          property photos

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

                                                                                            property provider

                                                                                            provider: string;

                                                                                              property username

                                                                                              username?: string | undefined;

                                                                                                interface Strategy

                                                                                                interface Strategy {}

                                                                                                  property name

                                                                                                  name?: string | undefined;

                                                                                                    method authenticate

                                                                                                    authenticate: (
                                                                                                    this: StrategyCreated<this>,
                                                                                                    req: express.Request,
                                                                                                    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 | { [key: string]: any; message?: string },
                                                                                                        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 | undefined;

                                                                                                                        property user

                                                                                                                        user?: User | undefined;

                                                                                                                          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: {
                                                                                                                                  (options: { keepSessionInfo?: boolean }, done: (err: any) => void): void;
                                                                                                                                  (done: (err: any) => void): void;
                                                                                                                                  };

                                                                                                                                    method logOut

                                                                                                                                    logOut: {
                                                                                                                                    (options: { keepSessionInfo?: boolean }, done: (err: any) => void): void;
                                                                                                                                    (done: (err: any) => void): 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>