FirebaseStorage

open class FirebaseStorage(val apiKey: String, encryption: PortalEncryption, getToken: suspend () -> String?, tbsHost: String = "backup.web.portalhq.io") : CloudStorageAdapter

Handles Firebase-based cloud storage operations for backup, recovery, and eject flows.

This storage implementation communicates directly with TBS (Trustless Backup Service) using Firebase ID tokens for authentication. The Firebase token is sent via the X-Firebase-Token header alongside the standard Authorization header (client API key).

The customer provides a getToken callback that returns a fresh Firebase ID token. This is called before each TBS request to ensure the token is valid.

Parameters

apiKey

The Portal client API key used for the Authorization header.

encryption

The encryption utility for encrypting/decrypting backup shares.

getToken

A suspend lambda that returns a fresh Firebase ID token. This should typically call FirebaseAuth.getInstance().currentUser?.getIdToken(true).

tbsHost

The TBS host URL. Defaults to "backup.web.portalhq.io". The scheme is auto-detected: localhost/127.0.0.1 uses http://, all other hosts use https://. Pass a full URL with scheme to override.

Constructors

Link copied to clipboard
constructor(apiKey: String, encryption: PortalEncryption, getToken: suspend () -> String?, tbsHost: String = "backup.web.portalhq.io")

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard
open override var api: Api?
Link copied to clipboard
Link copied to clipboard
open override var method: BackupMethods

Functions

Link copied to clipboard
open override fun decrypt(value: String, key: String): String

Decrypts an encrypted value using the provided key.

Link copied to clipboard
open suspend override fun delete(): Boolean

Deletes stored data. Returns true as a placeholder.

Link copied to clipboard
open override fun encrypt(value: String): EncryptedData

Encrypts a given value.

Link copied to clipboard
open suspend override fun read(): String

Retrieves the encryption key from TBS via GET /v1/backup/encrypt-key.

Link copied to clipboard
open suspend override fun validateOperations(): Boolean

Validates if Firebase-based operations can be performed.

Link copied to clipboard
open suspend override fun write(content: String): String

Stores the encryption key on TBS via PUT /v1/backup/encrypt-key.