Narcissistic Piano Mover

    @anatine/firebase-utils
    TypeScript icon, indicating that this package has built-in type declarations

    0.0.3 • Public • Published

    Firebase Utilities

    Simple utilities to reduce some firebase-admin tasks.

    Overview

    getFirebaseAdmin(credential, realtimeDbUrl)

    Easy function to initialize firebase-admin only once.

    validateToken(token, firebaseAdminInstance)

    Validates an idToken generated by Firebase Auth (not access token, idToken).

    Also supports the format Bearer <token> or just <token>

    getTestIdToken(firebaseAdminInstance, userId, claims)

    Gets an Id Token from the Firebase Emulator.

    Usage

    An example of using all three tools

    import { getFirebaseAdmin, validateToken, getTestIdToken } from '@anatine/firebase-utils'
    
    const admin = getFirebaseAdmin();
    const uid = 'SomeUserId'
    
    const { idToken } = await getTestIdToken({admin, uid, claims: {status: 'this is awesome'}})
    
    const decodedUserData = await validateToken(idToken, admin)
    
    console.log(decodedUserData)

    Keywords

    none

    Install

    npm i @anatine/firebase-utils

    DownloadsWeekly Downloads

    1

    Version

    0.0.3

    License

    MIT

    Unpacked Size

    9.03 kB

    Total Files

    11

    Last publish

    Collaborators

    • anatidae