# nomatic-jwt

> JSON Web Token (JWT) utilities for Node.js

Latest version **2.0.2** (published 2017-12-07) · MIT license · 0 weekly downloads

## Install

```sh
npm install nomatic-jwt
pnpm add nomatic-jwt
yarn add nomatic-jwt
bun add nomatic-jwt
```

## 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 | 2.0.2 |
| Published | 2017-12-07 |
| First published | 2017-08-31 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Brian D. Foster |
| Maintainers | bdfoster |
| Keywords | nomatic, jwt, json, web, token, decode, encode, authentication, authorization, auth |

## Links

- npm: https://www.npmjs.com/package/nomatic-jwt
- Repository: https://github.com/bdfoster/nomatic-jwt
- Homepage: https://github.com/bdfoster/nomatic-jwt#readme
- Issues: https://github.com/bdfoster/nomatic-jwt/issues
- npm.io page: https://npm.io/package/nomatic-jwt

## Dependencies (2)

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

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 2.0.2 (latest) — 2017-12-07
- 2.0.1 — 2017-10-01
- 2.0.0 — 2017-10-01
- 1.0.0 — 2017-10-01
- 0.1.0 — 2017-09-05
- 0.0.3 — 2017-08-31

## README

# nomatic-jwt

[![Greenkeeper badge](https://badges.greenkeeper.io/bdfoster/nomatic-jwt.svg)](https://greenkeeper.io/)
[![Semantic Release](https://img.shields.io/badge/%20%20%F0%9F%93%A6%F0%9F%9A%80-semantic--release-e10079.svg)](https://github.com/semantic-release/semantic-release)
[![GitHub release](https://img.shields.io/github/release/bdfoster/nomatic-jwt.svg)](https://github.com/bdfoster/nomatic-jwt/releases)
[![npm](https://img.shields.io/npm/v/nomatic-jwt.svg)](https://www.npmjs.com/package/nomatic-jwt)
[![Build Status](https://travis-ci.org/bdfoster/nomatic-jwt.svg?branch=greenkeeper%2Finitial)](https://travis-ci.org/bdfoster/nomatic-jwt)
[![Coverage Status](https://coveralls.io/repos/github/bdfoster/nomatic-jwt/badge.svg)](https://coveralls.io/github/bdfoster/nomatic-jwt)
[![Known Vulnerabilities](https://snyk.io/test/github/bdfoster/nomatic-jwt/badge.svg)](https://snyk.io/test/github/bdfoster/nomatic-jwt)
[![dependencies Status](https://david-dm.org/bdfoster/nomatic-jwt/status.svg)](https://david-dm.org/bdfoster/nomatic-jwt)
[![devDependencies Status](https://david-dm.org/bdfoster/nomatic-jwt/dev-status.svg)](https://david-dm.org/bdfoster/nomatic-jwt?type=dev)
[![License](https://img.shields.io/github/license/bdfoster/nomatic-jwt.svg)](https://github.com/bdfoster/nomatic-jwt/blob/master/LICENSE)

An opinionated library for encoding, decoding, and verifying JSON Web Tokens (JWTs), heavily inspired by 
[node-jwt-simple](https://github.com/hokaccha/node-jwt-simple).

### Installation
You can install from [npm](https://npmjs.com/nomatic-jwt) by doing:
```bash
npm i --save nomatic-jwt
```

### Basic Usage
```javascript
const JWT = require('nomatic-jwt').JWT;

const jwt = new JWT({
    algorithm: 'HS256', // "HS256" | "HS384" | "HS512" | "RS256" | "RS384" | "RS512"
    expiresIn: 60 * 60, // 1hr
    key: 'somethingMoreSecureThanThis', // Valid only with HMAC-SHA algorithms
    timeOffset: 60, // allowable wiggle room for expiration (`exp`) and not valid before (`nbf`) claims
    validate: true // If false, won't validate when decoding
});

// Encode
const token = jwt.encode({
    sub: 'user/12345678',
    roles: ['manager']
});
/* eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9
 * .eyJzdWIiOiJ1c2VyLzEyMzQ1Njc4Iiwicm9sZXMiOlsibWFuYWdlciJdLCJleHAiOjE1MDY4Nzk1ODAsIm5iZiI6MTUwNjg3NTk4MCwiaWF0IjoxNTA
 * 2ODc1OTgwfQ
 * .FjHYltcA1Natf6Iu72HyGxkk4GX2phMRG3yNW65_IsQ'
 */


// Decode
const decoded = jwt.decode(token);

```

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