this package is going to verify firebase access-token without using firebase admin sdk.
- install the package
NPM
npm i @presswink/firebase-jwt
yarn
yarn add @presswink/firebase-jwt
- Examples
typescript
or es6
import FirebaseJwt from '@presswink/firebase-jwt'
const projectId: string = "firebase-auth"
const jwtToken: string = ""
const jwt = new FirebaseJwt(projectId)
// verify jwt tokens
const verifyResult = jwt.verify(jwtToken)
console.log(verifyResult)
// decode jwt tokens
const decodeResult = jwt.decode(jwtToken)
console.log(decodeResult)
commonjs
const FirebaseJwt = require('@presswink/firebase-jwt')
const projectId = "firebase-auth"
const jwtToken = ""
const jwt = new FirebaseJwt(projectId)
// verify jwt tokens
const verifyResult = jwt.verify(jwtToken)
console.log(verifyResult)
// decode jwt tokens
const decodeResult = jwt.decode(jwtToken)
console.log(decodeResult)
next.js
'use server'
const {NextFirebaseJwt} = require('@presswink/firebase-jwt')
const projectId = "firebase-auth"
const jwtToken = ""
const jwt = new NextFirebaseJwt(projectId)
// verify jwt tokens
const verifyResult = jwt.verify(jwtToken)
console.log(verifyResult)
// decode jwt tokens
const decodeResult = jwt.decode(jwtToken)
console.log(decodeResult)
- clone the repository
git clone https://github.com/presswink/firebase-jwt.git
-
node version should be >=
v22.4.0
-
install packages
NPM
npm i
yarn
yarn install
- build project
NPM
npm run build
yarn
yarn build
- run the test cases
NPM
npm run test
yarn
yarn test