1.0.8 • Published 5 months ago
mont-auth v1.0.8
MontAuth
This is a simple JWT auth system made in TypeScript. It's as simple as it gets, but it's a good starting point for a more complex system.
How to use
- Clone the repository into your project
- Run
npm install
- Create a
.env
file in the root of the project with the following content:
JWT_SECRET="your_secret_key"
JWT_ACCESS_TOKEN_EXPIRES_IN=3600
JWT_REFRESH_TOKEN_EXPIRES_IN=86400
Functions
montAuth.createSession(payload: object, options: Options): MontResponse
- Creates a new access and refresh tokenmontAuth.validate(token: string, options: Options): MontResponse
- Checks if an access token is validmontAuth.refresh(token: string, options: Options): MontResponse
- Refreshes a refresh tokenmontAuth.auto(token: string, options: Options): MontResponse
- Automatically validates or refreshes a token