JSPM

google-jwt-validation

1.0.2
  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 1
  • Score
    100M100P100Q12233F
  • License ISC

validate google auth jwt via google public keys

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-validation

Import 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",
});