package app.closer.data.local

import android.content.Context
import dagger.hilt.android.qualifiers.ApplicationContext
import javax.inject.Inject
import javax.inject.Singleton

@Singleton
class RecoveryPhraseStore @Inject constructor(
    @ApplicationContext context: Context
) {
    private val prefs = SecurePreferencesFactory.encryptedSharedPreferences(context, PREFS_NAME)

    fun save(phrase: String) = prefs.edit().putString(KEY_PHRASE, phrase).apply()
    fun load(): String? = prefs.getString(KEY_PHRASE, null)
    fun clear() = prefs.edit().remove(KEY_PHRASE).apply()

    companion object {
        private const val PREFS_NAME = "closer_recovery"
        private const val KEY_PHRASE = "recovery_phrase"
    }
}
