# @alphatango/token-provider

> A simple library to resolve JWT tokens.

Latest version **1.0.1** (published 2020-08-12) · MIT license · 0 weekly downloads

## Install

```sh
npm install @alphatango/token-provider
pnpm add @alphatango/token-provider
yarn add @alphatango/token-provider
bun add @alphatango/token-provider
```

## 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 | 1.0.1 |
| Published | 2020-08-12 |
| First published | 2020-08-12 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=10.0.0 |
| Dependencies | 2 |
| Unpacked size | 8.3 KB |
| Known vulnerabilities | 0 (+28 in 2 direct dependencies) |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Alpha Tango Squad |
| Maintainers | akincel, alphatango-deploy, dboerlage, thoean, wparad |

## Links

- npm: https://www.npmjs.com/package/@alphatango/token-provider
- Repository: https://github.com/Cimpress-MCP/AT-TokenProvider
- Homepage: https://github.com/Cimpress-MCP/AT-TokenProvider#readme
- Issues: https://github.com/Cimpress-MCP/AT-TokenProvider/issues
- npm.io page: https://npm.io/package/@alphatango/token-provider

## Dependencies (2)

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

## Recent versions

- 1.0.1 (latest) — 2020-08-12
- 1.0.0 — 2020-08-12

## README

# ATSquad Token Provider

A simple library to resolve JWT tokens.

It uses AWS KMS to decrypt the client secret and then calls the specified token endpoint the retrieve JWT. 

## Using this library

Install the library.

```bash
yarn add @alphatango/token-provider
```

### Token Provider

```typescript
import axios from 'axios';
import TokenProvider from '@alphatango/token-provider';

const configuration = {
  clientId: 'CLIENT_ID',
  encryptedClientSecret: 'BASE64_KMS_ENCRYPTED_CLIENT_SECRET',
  audience: 'https://example.com/',
  tokenEndpoint: 'https://example.com/oauth/token'
};

let kmsClient = new aws.KMS({ region: 'eu-west-1' });
let tokenProvider = new TokenProvider({
  httpClient: axios.create(),
  kmsClient: kmsClient,
  tokenConfiguration: configuration
});

// recommended way to retrieve token (utilizes caching and takes care of token expiration)
let accessToken = await tokenProvider.getToken();

// or bypass caching and get new token
accessToken = await tokenProvider.getTokenWithoutCache();
```

## Contribution

We value your input as part of direct feedback to us, by filing issues, or preferably by directly contributing improvements:

1. Fork this repository
1. Create a branch
1. Contribute
1. Pull request

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