zentoken
Authentication like a zen.
Zentoken is an authentication status manager based on a standard two-token scheme (access token and refresh token). Zentoken keeps track of expiring tokens and updates them. Do not complicate your apps. Use fetch, Axios, etc. as if authentication is not needed.
yarn add zentoken
or npm install --save zentoken
Usage
You need to create Zen
instance first:
const zen = // How many milliseconds before the expiration // do you need to update the token? refreshOffset: 60000 // Implementation of authentication request { return } // Implementation of fetch refresh token request { return } // Implementation of fetch access token request { return } zenzenzen { sessionStorage} const refreshToken = sessionStorage if refreshToken zen
And now you can log in:
zen
If you use fetch:
const fetch = zen
If you use Axios:
const zenInterceptor = zen axiosinterceptorsrequest
API
WIP.