firebase-token-verifier
Firebase JWT verifier, implements Verify ID tokens using a third-party JWT library. Use as a lightweight alternative to the Firebase Admin SDK if all you need to do is verify or validate a Firebase JWT.
Install
npm install --save firebase-token-verifier
Usage
firebase-token-verifier
can be used with Promises, async
, or callbacks.
validate()
is just a wrapper around verify()
that also checks the project ID (audience/issuer), and optionally the user ID (subject).
const verifier = ;const token = 'eyJhb...';
Promise
verify
verifier;
validate
// userId is optional// verifier.validate(token, projectId)verifier
async
verify
try let verified = await verifier; console; console; catcherr console; console;
validate
try // userId is optional // verifier.validate(token, projectId) let validated = await verifier; console; console; catcherr console; console;
callback
verify
verifier
validate
// userId is optional// verifier.validate(token, projectId, callback)verifier
Examples
Please see demo.sh
and demo/*.js
.
$ sh demo.sh