A lightweight library to decode and verify RS JWT meant for the browser.
;const verifier =issuer: ''audience: 'gYSNlU4YC4V1YPdqq8zPQcup6rJw1Mbt';verifier;
Initializes the verifier.
- issuer: the issuer you trust to sign the tokens.
- audience: the audience the token is issued for.
- leeway: when there is a clock skew times between the signing and verifying servers. The leeway should not be bigger than five minutes.
- jwksCache: the verifier will try to fetch the JWKS from the
jwksURIif provided) each time it verifies a token. You can provide a cache to store the keys and avoid repeated requests. For the contract, check this example. Hint: for in-memory cache, an easy way is to just provide
new Map(), which is a valid object for jwksCache.
- jwksURI: A valid, direct URI to fetch the JSON Web Key Set (JWKS). Defaults to
- error: the validation error if any, null otherwise
- payload: the decoded jwt payload
This method will decode the ID token, then verify the token for OIDC compliance using a series of checks on the claims found inside the token.
- id_token: the id_token to verify.
- nonce: the nonce previously sent to tha authorization server.
This method will decode the token header and payload WITHOUT doing any verification.
- id_token: the id_token to decode.
- header: the decoded header.
- payload: the decoded payload.
- encoded: the parts without decode
- header: the header string.
- payload: the payload string.
- signature: the signature string.
To make it as lightweight as posible, it only provides support for RS256 tokens. It can be easily extensible to other RS* algorithms.
If you have found a bug or if you have a feature request, please report them at this repository issues section. Please do not report security vulnerabilities on the public GitHub issue tracker. The Responsible Disclosure Program details the procedure for disclosing security issues.
This project is licensed under the MIT license. See the LICENSE file for more info.