package com.servdiary.mobile.data import android.content.Context import androidx.security.crypto.EncryptedSharedPreferences import androidx.security.crypto.MasterKey class TokenStore(context: Context) { private val prefs = EncryptedSharedPreferences.create( context, "servdiary_auth", MasterKey.Builder(context).setKeyScheme(MasterKey.KeyScheme.AES256_GCM).build(), EncryptedSharedPreferences.PrefKeyEncryptionScheme.AES256_SIV, EncryptedSharedPreferences.PrefValueEncryptionScheme.AES256_GCM, ) var token: String? get() = prefs.getString(KEY_TOKEN, null) set(value) { prefs.edit().putString(KEY_TOKEN, value).apply() } var teamRole: String? get() = prefs.getString(KEY_ROLE, null) set(value) { prefs.edit().putString(KEY_ROLE, value).apply() } fun clear() { prefs.edit().clear().apply() } companion object { private const val KEY_TOKEN = "token" private const val KEY_ROLE = "team_role" } }