# authenticate-user

> Library authenticate user with JWT

Latest version **1.2.9** (published 2021-06-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install authenticate-user
pnpm add authenticate-user
yarn add authenticate-user
bun add authenticate-user
```

## Health

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

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.9 |
| Published | 2021-06-16 |
| First published | 2021-04-08 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 6 |
| Unpacked size | 8.1 KB |
| Known vulnerabilities | 0 (+3 in 1 direct dependencies) |
| Install scripts | no |
| Author | nghia |
| Maintainers | nqnghia285 |
| Keywords | authenticator, authenticateUserFromReq, authenticateUser, authenticateUserFromSocket, createToken |

## Links

- npm: https://www.npmjs.com/package/authenticate-user
- Repository: https://github.com/nqnghia285/authenticator
- Homepage: https://github.com/nqnghia285/authenticator.git#readme
- npm.io page: https://npm.io/package/authenticate-user

## Dependencies (6)

- [express](https://npm.io/package/express.md) ^4.17.1
- [socket.io](https://npm.io/package/socket.io.md) ^4.0.1
- [@types/node](https://npm.io/package/@types/node.md) ^14.14.37
- [jsonwebtoken](https://npm.io/package/jsonwebtoken.md) ^8.5.1
- [@types/express](https://npm.io/package/@types/express.md) ^4.17.11
- [@types/jsonwebtoken](https://npm.io/package/@types/jsonwebtoken.md) ^8.5.1

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 1.2.9 (latest) — 2021-06-16
- 1.2.8 — 2021-06-14
- 1.2.7 — 2021-06-12
- 1.2.6 — 2021-06-12
- 1.2.5 — 2021-05-12
- 1.2.4 — 2021-04-13
- 1.2.2 — 2021-04-12
- 1.2.1 — 2021-04-12
- 1.2.0 — 2021-04-12
- 1.1.9 — 2021-04-12
- 1.1.8 — 2021-04-12
- 1.1.6 — 2021-04-12
- 1.1.5 — 2021-04-11
- 1.1.4 — 2021-04-10
- 1.1.3 — 2021-04-10
- … 9 more at https://npm.io/package/authenticate-user/versions

## README

# Authenticate User [![Build Status](https://github.com/Links2004/arduinoWebSockets/workflows/CI/badge.svg?branch=master)](https://github.com/nqnghia285/authenticate-user.git)

Authenticate User help us verify json web token cookie to authenticate user.

### Functions:

```typescript
/**
 * @method setTokenName Set token name which is gotten in cookie of header in request
 * @param tokenName string
 */
function setTokenName(tokenName: string): void;
```

```typescript
/**
 * @method authenticateUser Return payload if token is valid, otherwise return undefined
 * @param token string | undefined
 * @param jwtKey Secret
 * @param options VerifyOptions | undefined
 * @returns string | object | undefined
 */
function authenticateUser(token: string | undefined, jwtKey: Secret, options?: VerifyOptions | undefined): string | object | undefined;
```

```typescript
/**
 * @method createToken Return an encoded token if the function is not error, otherwise return undefined
 * @param payload string | object | Buffer | undefined
 * @param jwtKey Secret
 * @param option SignOptions | undefined
 * @returns string | undefined
 */
function createToken(payload: string | object | Buffer | undefined, jwtKey: Secret, options?: SignOptions | undefined): string | undefined;
```

```typescript
/**
 * @method authenticateUserFromReq Return payload if token is valid, otherwise return undefined
 * @param req IRequest
 * @param jwtKey Secret
 * @param options VerifyOptions | undefined
 * @returns string | object | undefined
 */
function authenticateUserFromReq(req: IRequest, jwtKey: Secret, options?: VerifyOptions | undefined): string | object | undefined;
```

```typescript
/**
 * @method authenticateUserFromSocket
 * @param socket Socket
 * @param jwtKey Secret
 * @param options VerifyOptions | undefined
 * @returns string | object | undefined
 */
function authenticateUserFromSocket(socket: Socket, jwtKey: Secret, options?: VerifyOptions | undefined): string | object | undefined;
```

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