# @ctng/auth-jwt-ls

> This is a library for handling Json Web Tokens by using the [jwt-decode](https://github.com/auth0/jwt-decode) library and local storage to persist the token. Additionally it checks if the token is expired.

Latest version **5.0.2** (published 2021-01-19) · 0 weekly downloads

## Install

```sh
npm install @ctng/auth-jwt-ls
pnpm add @ctng/auth-jwt-ls
yarn add @ctng/auth-jwt-ls
bun add @ctng/auth-jwt-ls
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 5.0.2 |
| Published | 2021-01-19 |
| First published | 2020-03-27 |
| Weekly downloads | 0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 1 |
| Unpacked size | 48.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Maintainers | moema, alfredson |

## Links

- npm: https://www.npmjs.com/package/@ctng/auth-jwt-ls
- Repository: https://github.com/moemamoe/ctng
- Homepage: https://github.com/moemamoe/ctng#readme
- Issues: https://github.com/moemamoe/ctng/issues
- npm.io page: https://npm.io/package/@ctng/auth-jwt-ls

## Dependencies (1)

- [tslib](https://npm.io/package/tslib.md) ^2.0.0

## Recent versions

- 5.0.2 (latest) — 2021-01-19
- 5.0.1 — 2021-01-19
- 5.0.0 — 2020-07-29
- 4.4.0 — 2020-04-29
- 4.2.0 — 2020-03-27

## README

# Auth-Jwt-Ls

This is a library for handling Json Web Tokens by using the [jwt-decode](https://github.com/auth0/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:

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

---
_Source: https://npm.io/package/@ctng/auth-jwt-ls · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
