# Readme for: ServerUtils_SetAuthKeys_1_0_0

**This method is only internal.**  
This method gets the latest API Keys from the AWS Secrets Manager and updates the cached keys on the server.  

### Why are they Cached
AWS Secrets Manager only has a specific amount of read access for the secrets. 
So to mitigate costs, we cache the value on the server so that it doesn't cost the earth, 
and so it is much faster than having to request the secret each time the service is used.  

### What are the Auth Keys used for?
If a request requires a user to be authenticated, then the JWT token that they use must be signed and encrypted with the correct AuthKey.   
So if a users JWT is not using the correct AuthKey, then we will not be able to decode the JWT.   
This would mean that they have an incorrect JWT and are not authorised.  

## How to call:
As this is called only internally and not visable to the outside, it needs to be called with node like this:
```sh
run-func ../dist/API/ServerUtils/SetAuthKeys/1.0.0/index.js ServerUtils_SetAuthKeys_1_0_0 './Auth/index.json'
```
Or in a typescript file like this:
```typescript
ServerUtils_SetAuthKeys_1_0_0(path: string)
```

## Expected functionality
When this runs, it will update the file specified with the new authKeys.   
The files content will look like this:
```JSON
{
  "current": "currentKey",
  "previous": "previousKey"
}
```
