Clear local storage if we detect that the token is expired. Fixes #197.
Notes
The isTokenExpired treats a token as expired if we're within 30 seconds of expiry. This matches the logic Verdaccio itself uses, which is important since the UI does not match up otherwise.
I used the parseJwt method from this Stack Overflow answer. I noticed the client code in this repo did not depend on any libraries, so I kept it that way.
Summary
Clear local storage if we detect that the token is expired. Fixes #197.
Notes
isTokenExpired
treats a token as expired if we're within 30 seconds of expiry. This matches the logic Verdaccio itself uses, which is important since the UI does not match up otherwise.parseJwt
method from this Stack Overflow answer. I noticed the client code in this repo did not depend on any libraries, so I kept it that way.