# JWT generator utility
Generate a set of headers, including a valid JWT, to be used in Postman or GraphQL playground. 

## Background
This script is intended to work with pre-existing service identities used in integration testing.
Details are here https://www.notion.so/How-to-configure-a-machine-to-have-a-dedicated-Auth0-M2M-Client-and-Automated-JWT-Token-Refresh-2e00d3e763ce497abaf6d2e9a0e947ff#13797177520f807aa780f364c2f21f69

## Installation
Install the dependencies
```
npm i
```

Copy the `.env.show` file to `.env` and fill in the required values.
* `AUTH_USERNAME` is the email of the identity.
* `SERVICE_NAME`: service name used in getting secrets from secrets manager.
* `ORCHARD_IDENTITY_ID`: identity id.
* `ORCHARD_PROFILE_TYPE`: profile type you want to use in your GraphQL request.
* `ORCHARD_PROFILE_ID`: profile id you want to use in your GraphQL request.

## Run
### Set your aws credentials
You need that so you can retrieve the secrets from the secrets manager.
```
awsume prod
```
Then you can run the script
```
npm run generate-headers
```

### Shell alias
You can add the following alias to your shell profile to run the script easily without having to navigate to the project directory.
```
jwt_generate() {
    CURRENT_DIR=$(pwd)
    cd ~/work/collab/ratoui/jwt-generator && \
    awsume prod && \
    npm run generate-headers && \
    cd "$CURRENT_DIR"
}

# Add this to your .bashrc or .zshrc:
alias jwt='jwt_generate'%
```
