package no.zyon.shade.storage

import no.zyon.shade.types.IdentityKeyPair
import no.zyon.shade.types.OneTimePreKey
import no.zyon.shade.types.SessionState
import no.zyon.shade.types.SignedPreKey

/**
 * StorageProvider interface. Mirror @shade/core/storage.ts.
 *
 * Implementations:
 *  - MemoryStorage (for tests)
 *  - KeystoreStorage (EncryptedSharedPreferences + Android Keystore)
 *  - RoomStorage (SQLite via Room, for larger datasets)
 */
interface StorageProvider {
    // Identity
    suspend fun getIdentityKeyPair(): IdentityKeyPair?
    suspend fun saveIdentityKeyPair(keyPair: IdentityKeyPair)
    suspend fun getLocalRegistrationId(): Int
    suspend fun saveLocalRegistrationId(id: Int)

    // Signed prekeys
    suspend fun getSignedPreKey(keyId: Int): SignedPreKey?
    suspend fun saveSignedPreKey(key: SignedPreKey)
    suspend fun removeSignedPreKey(keyId: Int)

    // One-time prekeys
    suspend fun getOneTimePreKey(keyId: Int): OneTimePreKey?
    suspend fun saveOneTimePreKey(key: OneTimePreKey)
    suspend fun removeOneTimePreKey(keyId: Int)
    suspend fun getOneTimePreKeyCount(): Int

    // Sessions
    suspend fun getSession(address: String): SessionState?
    suspend fun saveSession(address: String, state: SessionState)
    suspend fun removeSession(address: String)

    // Trust
    suspend fun isTrustedIdentity(address: String, identityKey: ByteArray): Boolean
    suspend fun saveTrustedIdentity(address: String, identityKey: ByteArray)
}
