<s>[INST] This isn't an edge case, it's an entire cliff face of a scenario!

I'd like to restrict the access to a certain URL. I have a JWT token stored in local storage with two claims: `role` and `privileges`, which are arrays of strings. I want to verify that the token contains the `role` claim and that the `role` is either "admin" or "moderator". I also want to add an extra layer of security by checking that the token is not expired.

How would you implement this in JavaScript?[/INST]