<commit_before># Tree-house Authentication

Authentication module written in TypeScript providing authentication utilities and JWT methods.

## Installation

Install via npm

```
npm install tree-house-authentication
```

or via yarn

```
yarn add tree-house-authentication
```

## Usage

- `const authenticator = require('tree-house-authentication')`
- `import * as authenticator from 'tree-house-authentication'`

## Configuration
```
const jwtSettings = {
  algorithm: 'HS256',
  expiresIn: '7d',
  audience: 'TREEHOUSE-AUTH',
  issuer: 'treehouse-authentication',
  secretOrKey: '<KEY>',
};
```
> You can find all possible configuration options at [Github: node-jsonwebtoken](https://github.com/auth0/node-jsonwebtoken)

## JWT
### createJwt(payload, jwtSettings)
Returns a json webtoken with the provided payload and configuration. (**Asynchronous**)

### authenticateJwt(token, jwtSettings)
Returns decoded jwt token when the provided token is still valid. (**Asynchronous**)

### decodeJwt(token)
Return a decoded json webtoken. This does not validate the token. (**Synchronous**)

## Utilities
### generateRandomHash(algorithm (optional), secret (optional))
Return a random hash (can be used for tokens) (**Synchronous**)

### getHashedPassword(password, saltCount)
Returns a hashed password. (**Asynchronous**)

### comparePassword(password, hashedPw)
Check whether a password is valid compared with a hashed password. (**Asynchronous**)

## Tests

  You can run `yarn test` to run all tests
  You can run `yarn test:coverage` to run all tests with coverage report
  
## Authors

See the list of [contributors](https://github.com/icapps/tree-house-authentication/contributors) who participated in this project.

## License

This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details<commit_msg>consistency in README<commit_after># Tree-house Authentication

Authentication module written in TypeScript providing authentication utilities and JWT methods.

## Installation

Install via npm

```
npm install tree-house-authentication
```

or via yarn

```
yarn add tree-house-authentication
```

## Usage

- `const authenticator = require('tree-house-authentication')`
- `import * as authenticator from 'tree-house-authentication'`

## Configuration
```
const jwtSettings = {
  algorithm: 'HS256',
  expiresIn: '7d',
  audience: 'TREEHOUSE-AUTH',
  issuer: 'treehouse-authentication',
  secretOrKey: '<KEY>',
};
```
> You can find all possible configuration options at [Github: node-jsonwebtoken](https://github.com/auth0/node-jsonwebtoken)

## JWT
### createJwt(payload, jwtSettings)
Returns a json webtoken with the provided payload and configuration. (**Asynchronous**)

### authenticateJwt(token, jwtSettings)
Returns a decoded jwt token when the provided token is still valid. (**Asynchronous**)

### decodeJwt(token)
Returns a decoded json webtoken. This does not validate the token. (**Synchronous**)

## Utilities
### generateRandomHash(algorithm (optional), secret (optional))
Returns a random hash (can be used for tokens) (**Synchronous**)

### getHashedPassword(password, saltCount)
Returns a hashed password. (**Asynchronous**)

### comparePassword(password, hashedPw)
Check whether a password is valid compared with a hashed password. (**Asynchronous**)

## Tests

  You can run `yarn test` to run all tests
  You can run `yarn test:coverage` to run all tests with coverage report
  
## Authors

See the list of [contributors](https://github.com/icapps/tree-house-authentication/contributors) who participated in this project.

## License

This project is licensed under the MIT License - see the [LICENSE.md](LICENSE.md) file for details
{'fraction_non_alphanumeric': 0.11519740400216333, 'fraction_numerical': 0.0027041644131963224, 'mean_word_length': 5.377586206896551, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 7, 'https://': 4, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5117088', 'n_tokens_mistral': 1079, 'n_tokens_neox': 1045, 'n_words': 370}