fahipay serialized multi-login added
Auto Tag on Version Change / check-version (push) Successful in 4s

This commit is contained in:
2026-05-19 16:13:36 +05:00
parent 782e2e7674
commit 8c40322ff0
19 changed files with 486 additions and 302 deletions
@@ -29,6 +29,7 @@ class MibLoginFlow(private val credentialStore: CredentialStore) {
var onSessionRefreshed: ((MibSession, List<MibProfile>) -> Unit)? = null
// Stored after login so the session can be silently recovered on 419
@Volatile private var loginId: String = ""
@Volatile private var storedUsername: String? = null
@Volatile private var storedPasswordHash: String? = null
@Volatile private var storedOtpSeed: String? = null
@@ -58,11 +59,12 @@ class MibLoginFlow(private val credentialStore: CredentialStore) {
* Returns list of accounts from all profiles on success.
*/
fun login(username: String, passwordHash: String, otpSeed: String): List<MibAccount> {
loginId = username
storedUsername = username
storedPasswordHash = passwordHash
storedOtpSeed = otpSeed
val appId = getOrCreateAppId()
val keys = credentialStore.loadMibKeys()
val keys = credentialStore.loadMibKeys(loginId)
return if (keys != null) {
regularLogin(username, passwordHash, appId, keys.first, keys.second)
@@ -106,7 +108,7 @@ class MibLoginFlow(private val credentialStore: CredentialStore) {
val keyData = otpResp.getJSONArray("data").getJSONObject(0)
val key1 = keyData.getString("key1")
val key2 = keyData.getString("key2")
credentialStore.saveMibKeys(key1, key2)
credentialStore.saveMibKeys(loginId, key1, key2)
return regularLogin(username, passwordHash, appId, key1, key2)
}
@@ -139,7 +141,7 @@ class MibLoginFlow(private val credentialStore: CredentialStore) {
lastSession = session2
lastProfiles = profiles // keep ALL profiles so settings can show them all
val hidden = credentialStore.getHiddenMibProfileIds()
val hidden = credentialStore.getHiddenMibProfileIds(loginId)
// When the server already selected the profile and returned balances in A41
// (single-profile case: profileSelected=true), use those accounts directly
@@ -433,11 +435,11 @@ class MibLoginFlow(private val credentialStore: CredentialStore) {
private fun generateOtp(seed: String): String = Totp.generate(seed)
private fun getOrCreateAppId(): String {
var id = credentialStore.loadMibAppId()
var id = credentialStore.loadMibAppId(loginId)
if (id == null) {
val chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
id = "IOS17.2-" + (1..15).map { chars[Random.nextInt(chars.length)] }.joinToString("")
credentialStore.saveMibAppId(id)
credentialStore.saveMibAppId(loginId, id)
}
return id
}