1.0.19 • Published 6 months ago

firebase-verifier v1.0.19

Weekly downloads
-
License
MIT
Repository
github
Last release
6 months ago

firebase-verifier middleware for expressjs

ci Commit Languages Discord Dependencies Repo size Download Sponsors Issues License Version Contributors Contributors

When you don't want to install firebase-admin-sdk just to verify id token and/or app check token.

Install

npm install firebase-verifier

Configs

Obtains project_id and project_no from Google Cloud Console

Usage

import express from "express";
import {
  authVerifier,
  appCheckVerifier,
  firebaseVerifier,
} from "firebase-verifier";

const project_id = "<project_id>";
const project_no = "<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.

1.0.19

6 months ago

1.0.18

8 months ago

1.0.17

8 months ago

1.0.16

8 months ago

1.0.15

9 months ago

1.0.14

12 months ago

1.0.9

1 year ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.13

1 year ago

1.0.12

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago

0.0.6

1 year ago

0.0.5

1 year ago

0.0.4

1 year ago

0.0.3

1 year ago

0.0.2

1 year ago

0.0.1

1 year ago