optimize bml refresh flow
Auto Tag on Version Change / check-version (push) Successful in 3s

This commit is contained in:
2026-05-22 06:01:13 +05:00
parent 01e5c17284
commit b784085605
7 changed files with 143 additions and 65 deletions
@@ -264,10 +264,30 @@ class CredentialStore(context: Context) {
} catch (_: Exception) { null }
}
fun saveBmlProfileExpiresAt(profileId: String, expiresAt: Long) {
prefs.edit().putLong("bml_profile_${profileId}_expires_at", expiresAt).apply()
}
fun loadBmlProfileExpiresAt(profileId: String): Long =
prefs.getLong("bml_profile_${profileId}_expires_at", 0L)
fun saveBmlProfileRefreshToken(profileId: String, refreshToken: String) {
val key = getOrCreateKey()
prefs.edit().putString("bml_profile_${profileId}_enc_refresh_token", encrypt(refreshToken, key)).apply()
}
fun loadBmlProfileRefreshToken(profileId: String): String? {
val key = getOrCreateKey()
val enc = prefs.getString("bml_profile_${profileId}_enc_refresh_token", null) ?: return null
return try { decrypt(enc, key) } catch (_: Exception) { null }
}
fun clearBmlProfileSession(profileId: String) {
prefs.edit()
.remove("bml_profile_${profileId}_enc_token")
.remove("bml_profile_${profileId}_enc_device_id")
.remove("bml_profile_${profileId}_enc_refresh_token")
.remove("bml_profile_${profileId}_expires_at")
.apply()
}