# ts-token-creator

> JWT Token Creator

Latest version **1.0.2** (published 2019-03-26) · MIT license · 0 weekly downloads

## Install

```sh
npm install ts-token-creator
pnpm add ts-token-creator
yarn add ts-token-creator
bun add ts-token-creator
```

## 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.2 |
| Published | 2019-03-26 |
| First published | 2019-03-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 2 |
| Unpacked size | 3.9 KB |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Weverton Souza |
| Maintainers | josiane_reis, marinheiro, weverton-silva |
| Keywords | JWT, Token, Generate, HS256 |

## Links

- npm: https://www.npmjs.com/package/ts-token-creator
- Repository: https://github.com/weverton-souza/ts-token-creator
- Homepage: https://github.com/weverton-souza/ts-token-creator#readme
- Issues: https://github.com/weverton-souza/ts-token-creator/issues
- npm.io page: https://npm.io/package/ts-token-creator

## Dependencies (2)

- [crypto-js](https://npm.io/package/crypto-js.md) ^3.1.9-1
- [@types/jest](https://npm.io/package/@types/jest.md) ^24.0.11

## Alternatives

- [@pothos/plugin-authz](https://npm.io/package/@pothos/plugin-authz.md) — 12.4K weekly downloads
- [@bounded-sh/client](https://npm.io/package/@bounded-sh/client.md) — 3.2K weekly downloads
- [@luigi-project/plugin-auth-oauth2](https://npm.io/package/@luigi-project/plugin-auth-oauth2.md) — 2.3K weekly downloads
- [@nocobase/plugin-verification](https://npm.io/package/@nocobase/plugin-verification.md) — 2.0K weekly downloads
- [escher-request](https://npm.io/package/escher-request.md) — 545 weekly downloads

## Recent versions

- 1.0.2 (latest) — 2019-03-26
- 1.0.1 — 2019-03-25

## README

# Token Creator

Needs lots of work...

# Installing

```sh
# npm install ts-token-creator
```

# Example Code
app.module.ts
```js
...
providers: [
  TokenCreator,
]
...
```
Your class.
```js
import { TokenCreator } from 'ts-token-creator'

export class MyClass {

  secret = 'secret';
  
  tokenConfig = {
     header: {
        "alg": "HS256",
        "typ": "JWT"
      },
      body: { // The content of body is optional.
        "sub": "1234567890",
        "name": "John Doe",
        "iat": 1516239022
       },
    };
  
  constructor(private tokenCreator: TokenCreator) {
    const token = this.tokenCreator.hmacSHA256(this.tokenConfig, this.secret);
    console.log(token);
    // Console result: eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOiIxMjM0NTY3ODkwIiwibmFtZSI6IkpvaG4gRG9lIiwiaWF0IjoxNTE2MjM5MDIyfQ.XbPfbIHMI6arZ3Y922BhjWgQzWXcXNrz0ogtVhfEd2o
  }
}
```

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