# jwt-status-list

> [![codecov](https://codecov.io/gh/cre8/Token-Status-List/graph/badge.svg?token=pGfC2eXYaJ)](https://codecov.io/gh/cre8/Token-Status-List)

Latest version **0.0.5** (published 2024-05-07) · Apache-2.0 license · 0 weekly downloads

> **Deprecated.** This package is deprecated.

## Install

```sh
npm install jwt-status-list
pnpm add jwt-status-list
yarn add jwt-status-list
bun add jwt-status-list
```

## Health

**Score 10/100 (F)** — status: deprecated.

Negative: deprecated.

## Facts

| | |
|---|---|
| Version | 0.0.5 |
| Published | 2024-05-07 |
| First published | 2024-05-06 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=18.0.0 |
| Dependencies | 2 |
| Unpacked size | 18.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Mirko Mollik |
| Maintainers | mirkom |
| Keywords | sd-jwt-vc, status-list, sd-jwt |

## Links

- npm: https://www.npmjs.com/package/jwt-status-list
- Repository: https://github.com/cre8/Token-Status-List
- Homepage: https://github.com/cre8/Token-Status-List#readme
- Issues: https://github.com/cre8/Token-Status-List/issues
- npm.io page: https://npm.io/package/jwt-status-list

## Dependencies (2)

- [pako](https://npm.io/package/pako.md) ^2.1.0
- [base64url](https://npm.io/package/base64url.md) ^3.0.1

## Alternatives

- [@clerk/clerk-expo](https://npm.io/package/@clerk/clerk-expo.md) — 133.6K weekly downloads
- [@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

## Recent versions

- 0.0.5 (latest) — 2024-05-07
- 0.0.4 — 2024-05-06
- 0.0.3 — 2024-05-06
- 0.0.2 — 2024-05-06
- 0.0.1 — 2024-05-06

## README

[![codecov](https://codecov.io/gh/cre8/Token-Status-List/graph/badge.svg?token=pGfC2eXYaJ)](https://codecov.io/gh/cre8/Token-Status-List)

# JWT Status List

This implementation is based on the this [IETF draft](https://datatracker.ietf.org/doc/draft-ietf-oauth-status-list/)

This status list is an encoded bit string where the status can be represented by multiple bits. This library provides functions to create and read the status list from a JWT and also to verify the status of a specific entry.


## Installation

```bash
npm install jwt-status-list
```

## Usage

Creation of a JWT Status List:
```typescript
// pass the list as an array and the amount of bits per entry.
const list = new StatusList([1, 0, 1, 1, 1], 1);
const iss = 'https://example.com';
const payload: JWTPayload = {
    iss,
    sub: `${iss}/statuslist/1`,
    iat: new Date().getTime() / 1000,
};
const header: JWTHeaderParameters = { alg: 'ES256' };

const jwt = createUnsignedJWT(list, payload, header);

// Sign the JWT with the private key
const signedJwt = await jwt.sign(privateKey);

```

Interaction with a JWT Status List:
```typescript
//validation of the JWT is not provided by this library!!!

// jwt that includes the status list reference
const reference = getStatusListFromJWT(jwt);

// download the status list
const list = await fetch(reference.uri);

//TODO: validate that the list jwt is signed by the issuer and is not expired!!!

//extract the status list
const statusList = getListFromStatusListJWT(list);

//get the status of a specific entry
const status = statusList.getStatus(reference.idx);

// handle the status
```

## Development

Install the dependencies:

```bash
pnpm install
```

Run the tests:

```bash
pnpm test
```

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