by Jovan K.

The Firebase Admin Node.js SDK enables privileged server-side access to Firebase services including Authentication, Realtime Database, and Cloud Messaging from Node.js 20+ environments.
This block provides the full TypeScript source of the Firebase Admin Node.js SDK (user@example.com), enabling privileged server-side access to Firebase services including Authentication, Firestore, Realtime Database, Cloud Messaging, App Check, and more. The typical buyer is a backend or serverless Node.js developer who needs direct control over SDK internals, wants to bundle selectively, or is vendoring the source into a monorepo.
app/ - Core app initialization, lifecycle, credential wiring, and the FirebaseApp classapp-check/ - App Check token generation and verificationauth/ - Firebase Authentication: user management, token verification, tenant/project configcredential/ - Credential providers: cert, applicationDefault, refreshTokendata-connect/ - Firebase Data Connect client and APIdatabase/ - Realtime Database accesseventarc/ - Eventarc event publishingextensions/ - Firebase Extensions API clientfirestore/ - Cloud Firestore access and internal helpersfunctions/ - Cloud Functions task queue and API clientinstallations/ - Firebase Installations APIinstance-id/ - Instance ID API (legacy)machine-learning/ - Firebase ML model managementmessaging/ - Firebase Cloud Messaging (FCM)phone-number-verification/ - Phone number verification utilitiesproject-management/ - Firebase project and app managementremote-config/ - Remote Config template managementsecurity-rules/ - Security Rules managementstorage/ - Cloud Storage bucket accessutils/ - Internal error types, HTTP helpers, and SDK versionindex.ts - Root entry point; re-exports the default namespacedefault-namespace.ts / default-namespace.d.ts - Legacy admin.* namespace surfacefirebase-namespace-api.ts - TypeScript interfaces for the namespace APISpin up an isolated sandbox and run it server-side — no local setup.
Tetrees AI Review of this version
This TypeScript cli / script completed archive review with strong static results. Structure, dependency manifests, documentation, functional source, and common risk patterns were checked by the Tetrees verification pipeline; runtime phases are stated separately.
Deterministic AVCP artifact review
Pipeline avcp-2026-08-04.1 · SHA-256 ee8c0f7c54909087…
This version-scoped review deterministically inspects the submitted archive for structure, dependencies, documentation, functional source, and common malicious or high-risk signals. Build and test phases are reported as passed only after an isolated sandbox audition. It is not a guarantee of perfect security.
Reviewed Aug 7, 2026
Push this product straight into your AI IDE, web builder or cloud IDE.
Connect Tetrees to a compatible AI IDE, list products you own, and request the verified ZIP without exposing seller upload controls.
No reviews yet.
Sign in to join the discussion
Loading discussion…
index.d.ts - Top-level type declarationsnpm install @fastify/busboy @firebase/database-compat @firebase/database-types \
farmhash-modern fast-deep-equal google-auth-library jsonwebtoken jwks-rsa \
node-forge uuid
No native build steps, iOS pod install, or Android linking are required. This is a pure Node.js package. Node.js 20 or higher is strongly recommended (18 is deprecated).
Drop the source into your project, e.g. src/vendor/firebase-admin/. The internal imports use relative paths and will resolve correctly from that location.
TypeScript config — ensure src/vendor/firebase-admin/ is inside your rootDir and that esModuleInterop is enabled:
{
"compilerOptions": {
"rootDir": "src",
"esModuleInterop": true,
"module": "commonjs",
"target": "ES2020",
"strict": true,
"resolveJsonModule": true
}
}
{
"compilerOptions": {
"paths": {
"firebase-admin/*": ["./src/vendor/firebase-admin/*"]
}
}
}
# Option A: path to a service account JSON file
export GOOGLE_APPLICATION_CREDENTIALS="/path/to/serviceAccount.json"
# Option B: inline JSON (useful in containerized environments)
export FIREBASE_SERVICE_ACCOUNT_JSON='{"type":"service_account",...}'
import { initializeApp, cert } from './vendor/firebase-admin/app';
initializeApp({
credential: cert('/path/to/serviceAccount.json'),
databaseURL: 'https://<PROJECT_ID>.firebaseio.com',
});
import { initializeApp, AppOptions } from './vendor/firebase-admin/app';
function initializeApp(options?: AppOptions, name?: string): App;
Creates and registers a Firebase App instance. Call once at server startup. Pass options with a credential and optional databaseURL, storageBucket, projectId. A second name argument supports multiple app instances.
import { getAuth } from './vendor/firebase-admin/auth';
function getAuth(app?: App): Auth;
Returns the Auth service for the default app or a given App. Use this to verify ID tokens, create custom tokens, manage users, and configure multi-tenancy. Call without arguments after initializeApp() to use the default app.
import { getAppCheck } from './vendor/firebase-admin/app-check';
function getAppCheck(app?: App): AppCheck;
Returns the AppCheck service. Use it to verify App Check tokens sent from client applications, protecting backend endpoints from abuse. Accepts an optional App for multi-app setups.
import { applicationDefault, cert, refreshToken } from './vendor/firebase-admin/app';
function cert(serviceAccountPathOrObject: string | ServiceAccount, httpAgent?: Agent): Credential;
function applicationDefault(httpAgent?: Agent): Credential;
function refreshToken(refreshTokenPathOrObject: string | object, httpAgent?: Agent): Credential;
Credential factories. Use cert with an explicit service account, applicationDefault on Google Cloud infrastructure (GCE, Cloud Run, GKE), or refreshToken for OAuth2 refresh-token files.
A common backend pattern: protect an API route by verifying the Firebase ID token passed in the Authorization header.
import express, { Request, Response, NextFunction } from 'express';
import { initializeApp, cert } from './vendor/firebase-admin/app';
import { getAuth } from './vendor/firebase-admin/auth';
initializeApp({ credential: cert(process.env.GOOGLE_APPLICATION_CREDENTIALS!) });
const app = express();
async function firebaseAuth(req: Request, res: Response, next: NextFunction) {
const header = req.headers.authorization ?? '';
if (!header.startsWith('Bearer ')) {
return res.status(401).json({ error: 'Missing token' });
}
const idToken = header.slice(7);
try {
const decoded = await getAuth().verifyIdToken(idToken);
(req as any).uid = decoded.uid;
next();
} catch {
res.status(403).json({ error: 'Invalid token' });
}
}
app.get('/profile', firebaseAuth, (req, res) => {
res.json({ uid: (req as any).uid });
});
app.listen(3000);
Mint a custom Firebase token so a server process or a trusted third-party service can authenticate as a specific user.
import { initializeApp, cert } from './vendor/firebase-admin/app';
import { getAuth } from './vendor/firebase-admin/auth';
initializeApp({ credential: cert('./serviceAccount.json') });
async function mintToken(uid: string, claims: Record<string, unknown>): Promise<string> {
const customToken = await getAuth().createCustomToken(uid, claims);
return customToken;
}
mintToken('user-123', { role: 'admin', plan: 'pro' }).then((token) => {
console.log('Custom token:', token);
});
Protect a sensitive endpoint by confirming the request originates from a legitimate app instance.
import { initializeApp, applicationDefault } from './vendor/firebase-admin/app';
import { getAppCheck, VerifyAppCheckTokenResponse } from './vendor/firebase-admin/app-check';
initializeApp({ credential: applicationDefault() });
async function verifyRequest(appCheckToken: string): Promise<VerifyAppCheckTokenResponse> {
const result = await getAppCheck().verifyToken(appCheckToken);
return result;
}
// In your request handler:
async function handler(req: any, res: any) {
const token = req.headers['x-firebase-appcheck'] as string;
try {
const { appId } = await verifyRequest(token);
console.log('Verified app:', appId);
res.json({ ok: true });
} catch {
res.status(401).json({ error: 'App Check failed' });
}
}
index.ts - Entry point that re-exports the default Firebase namespace and emits a warning if loaded in a browser.default-namespace.ts / default-namespace.d.ts - The legacy admin.* surface (e.g. admin.auth(), admin.firestore()). Kept for backward compat.firebase-namespace-api.ts - TypeScript interfaces describing the full namespace shape, used for typing the default export.index.d.ts - Ambient declarations for the top-level module.app/ - initializeApp, getApp, getApps, deleteApp, App, AppOptions, credential types, and SDK version constant.app-check/ - AppCheck class, token generation, token verification, and associated API types.auth/ - Full Auth implementation: Auth, BaseAuth, user record types, token generator/verifier, tenant manager, project config manager.credential/ - Re-exports credential factories and types under the credential namespace for legacy compatibility.data-connect/ - Data Connect service class and internal API client.database/ - Realtime Database service wrapper and namespace.eventarc/ - Eventarc channel client for publishing CloudEvents.extensions/ - Firebase Extensions runtime config API.firestore/ - Firestore service wrapper; delegates to @google-cloud/firestore.functions/ - Cloud Functions task queue enqueue client.installations/ - Firebase Installations service.instance-id/ - Legacy Instance ID API.machine-learning/ - Firebase ML custom model management.messaging/ - FCM send, subscribe, unsubscribe, and batch send.phone-number-verification/ - Phone number verification helpers.project-management/ - Firebase project and app metadata management.remote-config/ - Remote Config template fetch, publish, and rollback.security-rules/ - Firestore and Storage security rules management.storage/ - Cloud Storage getStorage() and bucket helpers.utils/ - Shared error classes (FirebaseAppError, AppErrorCodes), HTTP utility functions, and getSdkVersion().initializeApp called multiple times — calling it more than once without a name argument throws "Firebase App named '[DEFAULT]' already exists". Guard with getApps().length === 0 before calling initializeApp.GOOGLE_APPLICATION_CREDENTIALS not set and using applicationDefault() — the SDK throws a credential error at runtime. Set the env var to the absolute path of a service account JSON file, or use cert() with an explicit path.index.ts uses export = (CommonJS-style). In an ESM project, import with import admin = require('./vendor/firebase-admin') or enable esModuleInterop: true and use import * as admin from './vendor/firebase-admin'.google-auth-library.getAuth() / getAppCheck() without an argument, they bind to the default app. In multi-tenant scenarios, pass the specific App instance returned by initializeApp(options, 'appName').farmhash-modern is a native addon — it compiles via node-gyp. Ensure python3, make, and a C++ compiler are available in your build environment, especially inside Docker images.I have vendored the Firebase Admin Node.js SDK source (firebase-admin@13.8.0)
into my project at `src/vendor/firebase-admin/`. There is a USAGE.md at the
root of that directory explaining the layout, exports, and working examples.
Please help me integrate this SDK into my existing Node.js / TypeScript / Express project:
1. Read USAGE.md and the source structure under `src/vendor/firebase-admin/`.
2. Add `initializeApp` initialization at server startup using the `cert` credential
factory, pulling the service account path from the `GOOGLE_APPLICATION_CREDENTIALS`
environment variable.
3. Add an Express middleware that verifies Firebase ID tokens using `getAuth().verifyIdToken()`.
4. Wire the middleware onto the protected routes in my existing router.
5. Ensure `tsconfig.json` has `esModuleInterop: true` and that the vendor path
is inside `rootDir`.
6. Do not install the npm package `firebase-admin`; all imports must point to
`src/vendor/firebase-admin/` using relative paths or the path alias defined
in tsconfig.
7. Show me the final file changes step by step.
The Firebase Admin Node.js SDK is licensed under the Apache License, Version 2.0. See source/LICENSE if present, or refer to the official repository.
Upstream npm package: firebase-admin — maintained by Google LLC / the Firebase team.
This product’s unique contribution is clean room implementation of valuable code block into AVCP compatible standard.
The full install guide and integration prompts unlock after purchase.
CRM, ERP, Admin & Internal Tools
Free