Package Exports
- google-jwt-validation
This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (google-jwt-validation) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.
Readme
google-jwt-validation
Install
npm i google-jwt-validationImport in project
const googleJwtValidation = require("google-jwt-validation");Validate a JWT
googleJwtValidation
.validate({ token })
.then((decoded) => {
//do stuff with your valid token
})
.catch((err) => console.log(err));If you want, you can use await.
Manually refresh google public keys
This will take care to update the keys when become invalid, but if you want, you can refresh the keys by yourself.
googleJwtValidation
.refreshKeys()
.then(({ PEM, JWK }) => {
//do stuff with the copy of the keys
})
.catch((err) => console.log(err));Change default endpoints
To change the default endpoints for the keys, call the changeEndpoints() method
googleJwtValidation.changeEndpoints({
PEM: "https://www.googleapis.com/oauth2/v1/certs",
JWK: "https://www.googleapis.com/oauth2/v3/certs",
});