Path: redb-route/redb.Route.Firebase/Auth/IFirebaseCredentialProvider.cs
Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route
Page: https://redbase.app/src/dev-2026-12-06/redb-route/redb.Route.Firebase/Auth/IFirebaseCredentialProvider.cs
----
using FirebaseAdmin;
using Google.Cloud.Firestore;
using Google.Cloud.Storage.V1;
namespace redb.Route.Firebase;
///
/// Abstraction for Firebase credential resolution.
/// Enables mocking in unit tests without real service accounts.
///
public interface IFirebaseCredentialProvider
{
///
/// Gets or creates a using the specified credentials.
/// Thread-safe with lazy initialization.
///
/// Optional path to service-account JSON file.
/// Optional Firebase project ID override.
/// Initialized instance.
FirebaseApp GetOrCreateApp(string? credentialPath = null, string? projectId = null);
///
/// Gets a for the specified project. Clients are cached per
/// (projectId, credentialPath) pair. Detects FIRESTORE_EMULATOR_HOST
/// for local development; falls back to production with the given service-account file
/// or Application Default Credentials.
///
/// Optional project ID override.
/// Optional path to service-account JSON file.
/// Firestore database client.
FirestoreDb GetFirestoreDb(string? projectId = null, string? credentialPath = null, string? databaseId = null);
///
/// Gets a . Clients are cached per .
/// Detects STORAGE_EMULATOR_HOST for local development; falls back to production
/// with the given service-account file or Application Default Credentials.
///
/// Optional path to service-account JSON file.
/// Google Cloud Storage client.
StorageClient GetStorageClient(string? credentialPath = null);
///
/// Gets a for signed download URLs. Requires a service-account
/// JSON with a private key — plain ADC cannot sign. Default implementation throws
/// so test doubles stay small.
///
/// Optional path to service-account JSON file.
UrlSigner GetUrlSigner(string? credentialPath = null)
=> throw new NotSupportedException(
$"{GetType().Name} does not provide a UrlSigner.");
}