firebase-auth-cloudflare-workers is a specialized, zero-dependency library designed to facilitate Firebase ID token (JWT) verification directly within Cloudflare Workers environments. Currently stable at version 2.0.6, it provides a robust solution for authenticating users by leveraging Web Standard APIs, ensuring minimal bundle size and optimized performance at the edge. Key differentiators include its complete independence from external npm dependencies, full support for UTF-8 character encoding, and dedicated integration with the Firebase Auth Emulator for local development and testing. The library enables developers to offload authentication logic to the Cloudflare edge, reducing latency and reliance on origin servers for token validation. While a specific release cadence isn't published, updates typically align with evolving Firebase authentication standards or Cloudflare Workers platform features.
npm install firebase-auth-cloudflare-workersVerified import paths — ran on the pinned version, not inferred.
Demonstrates how to set up a Cloudflare Worker using the module syntax to verify a Firebase ID token, including KV store initialization for caching public JWKs and basic error handling. This is a complete, runnable example for a worker.
Always use `Auth.getOrInitialize` to retrieve the Auth instance, passing the necessary environment variables for consistent behavior across requests.
For enhanced security, call `authObj.verifyIdToken(idToken, true, env)` to ensure revocation status is checked. Be aware this incurs an additional network request to Firebase Auth backend.
Ensure `FIREBASE_AUTH_EMULATOR_HOST` is correctly configured in your Worker's `Bindings` interface and `wrangler.toml`, and always pass the `env` object to `authObj.verifyIdToken` when developing with the emulator.
Refer to the official documentation for specific migration guides if upgrading from major version 1.x. Ensure `import { Auth } from 'firebase-auth-cloudflare-workers';` and associated types are correct.Verify that `env.PROJECT_ID` in your Worker's `Bindings` and `wrangler.toml` exactly matches your Firebase project ID (e.g., `example-project12345`). This ID is part of the token's claims.
Ensure the client application is refreshing Firebase ID tokens regularly before they expire. The client-side Firebase SDK handles this automatically, but custom implementations might need explicit refresh logic.
Add the `[[kv_namespaces]]` entry to your `wrangler.toml` and ensure `binding = "PUBLIC_JWK_CACHE_KV"` matches the name used in your code, along with a valid `id` for your KV namespace.
Check the `PUBLIC_JWK_CACHE_KEY` and `PUBLIC_JWK_CACHE_KV` configurations. Ensure the KV store is accessible and correctly storing / retrieving the public JSON Web Keys (JWKs). Clear the KV cache if keys might be stale.
No dependency data recorded yet.