angular2-jwt

  • Version 0.2.3
  • Published
  • No dependencies
  • MIT license

Install

npm i angular2-jwt
yarn add angular2-jwt
pnpm add angular2-jwt

Overview

Helper library for handling JWTs in Angular 2+

Index

Variables

variable AUTH_PROVIDERS

const AUTH_PROVIDERS: any[];

    Functions

    function provideAuth

    provideAuth: (config?: IAuthConfigOptional) => Provider[];

      function tokenNotExpired

      tokenNotExpired: (tokenName?: string, jwt?: string) => boolean;
      • Checks for presence of token and that token hasn't expired. For use with the router decorator and NgIf

      Classes

      class AuthConfig

      class AuthConfig {}
      • Sets up the authentication configuration.

      constructor

      constructor(config?: IAuthConfigOptional);

        method getConfig

        getConfig: () => IAuthConfig;

          class AuthConfigConsts

          class AuthConfigConsts {}

            property DEFAULT_HEADER_NAME

            static DEFAULT_HEADER_NAME: string;

              property DEFAULT_TOKEN_NAME

              static DEFAULT_TOKEN_NAME: string;

                property HEADER_PREFIX_BEARER

                static HEADER_PREFIX_BEARER: string;

                  class AuthHttp

                  class AuthHttp {}
                  • Allows for explicit authenticated HTTP requests.

                  constructor

                  constructor(options: AuthConfig, http: any, defOpts?: any);

                    property tokenStream

                    tokenStream: any;

                      method delete

                      delete: (url: string, options?: any) => any;

                        method get

                        get: (url: string, options?: any) => any;

                          method head

                          head: (url: string, options?: any) => any;

                            method options

                            options: (url: string, options?: any) => any;

                              method patch

                              patch: (url: string, body: any, options?: any) => any;

                                method post

                                post: (url: string, body: any, options?: any) => any;

                                  method put

                                  put: (url: string, body: any, options?: any) => any;

                                    method request

                                    request: (url: string | Request, options?: any) => any;

                                      method requestWithToken

                                      requestWithToken: (req: any, token: string) => any;

                                        method setGlobalHeaders

                                        setGlobalHeaders: (
                                        headers: Array<Object>,
                                        request: Request | RequestOptionsArgs
                                        ) => void;

                                          class AuthHttpError

                                          class AuthHttpError extends Error {}

                                            class AuthModule

                                            class AuthModule {}
                                            • Module for angular2-jwt

                                              Modifiers

                                              • @experimental

                                            constructor

                                            constructor(parentModule: AuthModule);

                                              method forRoot

                                              static forRoot: (config: AuthConfig) => any;

                                                class JwtHelper

                                                class JwtHelper {}
                                                • Helper class to decode and find JWT expiration.

                                                method decodeToken

                                                decodeToken: (token: string) => any;

                                                  method getTokenExpirationDate

                                                  getTokenExpirationDate: (token: string) => Date;

                                                    method isTokenExpired

                                                    isTokenExpired: (token: string, offsetSeconds?: number) => boolean;

                                                      method urlBase64Decode

                                                      urlBase64Decode: (str: string) => string;

                                                        Interfaces

                                                        interface IAuthConfig

                                                        interface IAuthConfig {}

                                                          property globalHeaders

                                                          globalHeaders: Array<Object>;

                                                            property headerName

                                                            headerName: string;

                                                              property headerPrefix

                                                              headerPrefix: string;

                                                                property noClientCheck

                                                                noClientCheck: boolean;

                                                                  property noJwtError

                                                                  noJwtError: boolean;

                                                                    property noTokenScheme

                                                                    noTokenScheme?: boolean;

                                                                      property tokenGetter

                                                                      tokenGetter: () => string | Promise<string>;

                                                                        property tokenName

                                                                        tokenName: string;

                                                                          interface IAuthConfigOptional

                                                                          interface IAuthConfigOptional {}

                                                                            property globalHeaders

                                                                            globalHeaders?: Array<Object>;

                                                                              property headerName

                                                                              headerName?: string;

                                                                                property headerPrefix

                                                                                headerPrefix?: string;

                                                                                  property noClientCheck

                                                                                  noClientCheck?: boolean;

                                                                                    property noJwtError

                                                                                    noJwtError?: boolean;

                                                                                      property noTokenScheme

                                                                                      noTokenScheme?: boolean;

                                                                                        property tokenGetter

                                                                                        tokenGetter?: () => string | Promise<string>;

                                                                                          property tokenName

                                                                                          tokenName?: string;

                                                                                            Package Files (1)

                                                                                            Dependencies (0)

                                                                                            No dependencies.

                                                                                            Dev Dependencies (24)

                                                                                            Peer Dependencies (3)

                                                                                            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/angular2-jwt.

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