# nodejs-token-auth

> Token authentication system

Latest version **1.0.3** (published 2021-07-17) · ISC license · 0 weekly downloads

## Install

```sh
npm install nodejs-token-auth
pnpm add nodejs-token-auth
yarn add nodejs-token-auth
bun add nodejs-token-auth
```

## Health

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

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.3 |
| Published | 2021-07-17 |
| First published | 2021-07-16 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 1 |
| Unpacked size | 5.2 KB |
| Known vulnerabilities | 0 (+1 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Sandeep Kumar |
| Maintainers | sandeep2007 |
| Keywords | nodejs-toke-auth, Rest, API |

## Links

- npm: https://www.npmjs.com/package/nodejs-token-auth
- Repository: https://github.com/sandeep2007/nodejs-token-auth
- Homepage: https://github.com/sandeep2007/nodejs-token-auth#readme
- Issues: https://github.com/sandeep2007/nodejs-token-auth/issues
- npm.io page: https://npm.io/package/nodejs-token-auth

## Dependencies (1)

- [uuid](https://npm.io/package/uuid.md) ^8.3.2

## Alternatives

- [launchdarkly-js-client-sdk](https://npm.io/package/launchdarkly-js-client-sdk.md) — 2.5M weekly downloads
- [@elastic/elasticsearch](https://npm.io/package/@elastic/elasticsearch.md) — 2.1M weekly downloads
- [@c8y/client](https://npm.io/package/@c8y/client.md) — 15.3K weekly downloads
- [@signaldb/maverickjs](https://npm.io/package/@signaldb/maverickjs.md) — 1.7K weekly downloads
- [@bbc/http-transport-cache](https://npm.io/package/@bbc/http-transport-cache.md) — 1.2K weekly downloads

## Recent versions

- 1.0.3 (latest) — 2021-07-17
- 1.0.2 — 2021-07-16
- 1.0.0 — 2021-07-16

## README

# Nodejs Token Auth

This module allows you to manage user tokens and easily integrate them with API. It uses in-memory storage for fast and better performance. The garbage collector continuously cleans expired and unused tokens.

## Installation

Use the package manager [npm](https://www.npmjs.com/package/nodejs-token-auth) to install nodejs-token-auth.

```bash
npm i nodejs-token-auth
```

## Usage

```nodejs
const { 
getTokenId, 
getToken, 
getTokenHeader, 
setToken, 
updateToken,
deleteToken, 
refreshTokenId, 
extendTokenTime
} = require('nodejs-token-auth')

# get token Id
 const tokenId = getTokenId();

# set token value
 setToken(tokenId, { id: '91c6468e-19cf-4741-baa5-24c48b095c5e', name: "user 1" })

# update token value
 updateToken(tokenId, { email: 'user@mail.com' })

# refresh token Id
 const newTokenId = refreshTokenId(tokenId)

# extend the token time
 extendTokenTime(tokenId);

# get token
 const tokenBody = getToken(newTokenId)

# get token header
 const tokenHeader = getTokenHeader(newTokenId)

# delete token
 deleteToken(tokenId)
```

## Contributing
Pull requests are welcome. For major changes, please open an issue first to discuss what you would like to change.

## License
[ISC](https://choosealicense.com/licenses/isc/)

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