5.0.2 • Published 3 years ago

@ctng/auth-jwt-ls v5.0.2

Weekly downloads
9
License
-
Repository
github
Last release
3 years ago

Auth-Jwt-Ls

This is a library for handling Json Web Tokens by using the jwt-decode library and local storage to persist the token. Additionally it checks if the token is expired.

Usage

Just inject the JwtLocalStorageService and

  • set/get tokens
  • get token's expiration date
  • check if token is expired
  • remove token from local storage

Custom config

By default JwtLocalStorageService assumes that the token object has an exp property with time value in seconds.

If a the token has a different structure or format, a custom JwtConfig can be provided:

{
  provide: JWT_CONFIG,
  useValue: {
    getExpirationDate: (token: CustomToken) => {
      return new Date(token.customExpDate);
    },
  },
},
5.0.2

3 years ago

5.0.1

3 years ago

5.0.0

4 years ago

4.4.0

4 years ago

4.2.0

4 years ago