https://github.com/chientrm/firebase-verifier
Expressjs Middleware for firebase authentication and app check when you don't want to install firebase admin sdk
https://github.com/chientrm/firebase-verifier
firebase firebase-app-check firebase-auth jwt verification
Last synced: 4 months ago
JSON representation
Expressjs Middleware for firebase authentication and app check when you don't want to install firebase admin sdk
- Host: GitHub
- URL: https://github.com/chientrm/firebase-verifier
- Owner: chientrm
- License: mit
- Created: 2023-03-23T03:00:45.000Z (about 3 years ago)
- Default Branch: main
- Last Pushed: 2025-02-10T18:22:22.000Z (over 1 year ago)
- Last Synced: 2025-09-01T03:51:36.166Z (10 months ago)
- Topics: firebase, firebase-app-check, firebase-auth, jwt, verification
- Language: TypeScript
- Homepage:
- Size: 88.9 KB
- Stars: 2
- Watchers: 2
- Forks: 0
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# `firebase-verifier` middleware for `expressjs`
[](https://github.com/chientrm/firebase-verifier/actions/workflows/ci.yml)
[](https://img.shields.io/github/commit-activity/m/chientrm/firebase-verifier)
[](https://github.com/trending/javascript)
[](https://discord.gg/HMMtp3dTPh)
[](https://depfu.com/repos/github/chientrm/firebase-verifier)
[](https://github.com/chientrm/firebase-verifier)
[](https://www.npmjs.com/package/firebase-verifier)
[](https://github.com/chientrm)
[](https://github.com/chientrm/firebase-verifier/issues)
[](https://github.com/chientrm/firebase-verifier/blob/main/LICENSE)
[](https://github.com/chientrm/firebase-verifier)
[](https://www.npmjs.com/package/firebase-verifier)
[](https://github.com/chientrm/firebase-verifier/graphs/contributors)
When you don't want to install `firebase-admin-sdk` just to verify `id token` and/or `app check token`.
## Install
```sh
npm install firebase-verifier
```
## Configs
Obtains `project_id` and `project_no` from [Google Cloud Console](https://console.cloud.google.com)
## Usage
```ts
import express from "express";
import {
authVerifier,
appCheckVerifier,
firebaseVerifier,
} from "firebase-verifier";
const project_id = "";
const project_no = "";
const app = express();
// Verify Id token
app.use(authVerifier(project_id));
app.get("/", (req, res) => {
console.log(res.locals.user);
/* Output
{
"sub": "kxljssoieeJKLe",
"email": "chientrm@gmail.com",
...
}
*/
});
...
// Verify App Check token
app.use(appCheckVerifier(project_no));
app.get("/", (req, res) => {
console.log(res.locals.device);
/* Output
{
...
}
*/
});
...
// Verify both Id token and App Check token
app.use(firebaseVerifier({ project_id, project_no }));
app.get("/", (req, res) => {
console.log(res.locals.user);
console.log(res.locals.device);
});
app.listen(3000);
```
## Check verification
If any of the verifiers failed, `res.locals.user`, `res.locals.device` are null and `res.locals.error` contains the error.