# @theorchard/grass-token-manager

**Note**. This is a port of the https://github.com/theorchard/js-grass-tokenmanager package.

Manages the periodic refreshing of a grass token with a short ttl. Given a token
request endpoint and a refresh milliseconds timeout, it continuously uses a
setInterval to make the token request call.

## Usage

```ts
import TokenManagerService from '@theorchard/grass-token-manager';

// Gets the global instance of the manager (if any)
const tokenManager = TokenManagerService();

// Configures the global instance of the manager
const tokenManager = TokenManagerService({
    tokenRequestUrl: '/grasssession'
});

// Get the current token:
const token = tokenManager.getToken();

// Set a new token:
tokenManager.setToken({token: 'abc123', tokenDuration: <milliseconds>});
```
