# @antpack/test-auth

> Lib privada para el manejo de autenticacion de usuarios

Latest version **1.0.0** (published 2022-07-29) · ISC license · 0 weekly downloads

## Install

```sh
npm install @antpack/test-auth
pnpm add @antpack/test-auth
yarn add @antpack/test-auth
bun add @antpack/test-auth
```

## 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.0.0 |
| Published | 2022-07-29 |
| First published | 2022-07-29 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 21.7 KB |
| Known vulnerabilities | 0 (+3 in 1 direct dependencies) |
| Install scripts | no |
| Author | Antpack |
| Maintainers | marioantpack, yoyler-antpack, yeisson_antpack, emirozu, alcode, wanervalencia, desarrolloant |

## Links

- npm: https://www.npmjs.com/package/@antpack/test-auth
- npm.io page: https://npm.io/package/@antpack/test-auth

## Dependencies (2)

- [express](https://npm.io/package/express.md) ^4.18.1
- [jsonwebtoken](https://npm.io/package/jsonwebtoken.md) ^8.5.1

## Recent versions

- 1.0.0 (latest) — 2022-07-29

## README

# auth Antpack
## Lib para generar token y verificar autenticacion
## Installation

Instalar libreria como dependencia de desarrollo.

```sh
npm i antpacAuth
```

IMPORTANTE: se debe trabajar con una variable de entorno:
```sh
SECRET_KEY_JWT=valor_palabra_secreta
```

Importar funcionalidades

```typescript
import { gereateToken } from 'antpackauth';

let token = genearteToken('userID', 'secretKey', ['roloes'])

return eyJhbGciOiJIUzI1NiwejfweivkerCJ9.eyJpdGkiOiIyMzEyMzEyMzEiLCJpcmwiOlsiYWRtaW4iXSwiaWF0IjoxNjU3NzE0NzI3LCJleHAiOjE2NjAzMDY3Mjd9.D3sErs-WQuiwdjcwejcwmcOhpN7-e2V3kl5ZqmD0rSao
```

## Parametros gerate token

| Param | Type | Descripcion
| ------ | ------ | -------- |
| id | String | identificador del usuario
| secret | jwt.secret | Palabra secreta
| roles | array | Array de roles asociado al usuario - default []
| expireNumber | number | tiempo de expiracion del token default = 3600 * 24 *30

##


```typescript
import { auth } from 'antpackauth';

//Se utiliza como middleware verifica si el usuario esta autenticado
router.get('/', auth, controller);
```

```typescript
import { getPayload } from 'antpackauth';

let payload = getPayload('secretKey', 'token');
return {
  iti: 'weerwefewdqw2',
  irl: [ 'admin' ],
  iat: 1657735271,
  exp: 1660327271
}
```

## Parametros getPayload

| Param | Type | Descripcion
| ------ | ------ | -------- |
| secretKey | jwt.secret - string | palabra secreta con la que se genera el token
| token | string | token del usuario

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