mirror of
https://github.com/bitwarden/android.git
synced 2024-11-21 17:05:44 +03:00
BITAU-200 Log non-fatal authenticator bridge errors (#4228)
Co-authored-by: Patrick Honkonen <phonkonen@bitwarden.com>
This commit is contained in:
parent
5a9944f79d
commit
c6beaec102
1 changed files with 27 additions and 3 deletions
|
@ -25,6 +25,7 @@ import com.x8bit.bitwarden.data.platform.util.isBuildVersionBelow
|
||||||
import com.x8bit.bitwarden.ui.vault.util.getTotpDataOrNull
|
import com.x8bit.bitwarden.ui.vault.util.getTotpDataOrNull
|
||||||
import kotlinx.coroutines.CoroutineScope
|
import kotlinx.coroutines.CoroutineScope
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
|
import timber.log.Timber
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Default implementation of [AuthenticatorBridgeProcessor].
|
* Default implementation of [AuthenticatorBridgeProcessor].
|
||||||
|
@ -93,7 +94,13 @@ class AuthenticatorBridgeProcessorImpl(
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun syncAccounts() {
|
override fun syncAccounts() {
|
||||||
val symmetricEncryptionKey = symmetricEncryptionKeyData ?: return
|
val symmetricEncryptionKey = symmetricEncryptionKeyData ?: run {
|
||||||
|
Timber.e(
|
||||||
|
t = IllegalStateException(),
|
||||||
|
message = "Unable to sync accounts when symmetricEncryptionKeyData is null.",
|
||||||
|
)
|
||||||
|
return
|
||||||
|
}
|
||||||
scope.launch {
|
scope.launch {
|
||||||
// Encrypt the shared account data with the symmetric key:
|
// Encrypt the shared account data with the symmetric key:
|
||||||
val encryptedSharedAccountData = authenticatorBridgeRepository
|
val encryptedSharedAccountData = authenticatorBridgeRepository
|
||||||
|
@ -110,14 +117,31 @@ class AuthenticatorBridgeProcessorImpl(
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun startAddTotpLoginItemFlow(data: EncryptedAddTotpLoginItemData): Boolean {
|
override fun startAddTotpLoginItemFlow(data: EncryptedAddTotpLoginItemData): Boolean {
|
||||||
val symmetricEncryptionKey = symmetricEncryptionKeyData ?: return false
|
val symmetricEncryptionKey = symmetricEncryptionKeyData ?: run {
|
||||||
|
Timber.e(
|
||||||
|
t = IllegalStateException(),
|
||||||
|
message = "Unable to start add TOTP item flow when " +
|
||||||
|
"symmetricEncryptionKeyData is null.",
|
||||||
|
)
|
||||||
|
return false
|
||||||
|
}
|
||||||
val intent = createAddTotpItemFromAuthenticatorIntent(context = applicationContext)
|
val intent = createAddTotpItemFromAuthenticatorIntent(context = applicationContext)
|
||||||
val totpData = data.decrypt(symmetricEncryptionKey)
|
val totpData = data.decrypt(symmetricEncryptionKey)
|
||||||
|
.onFailure {
|
||||||
|
Timber.e(t = it, message = "Unable to decrypt TOTP data.")
|
||||||
|
return false
|
||||||
|
}
|
||||||
.getOrNull()
|
.getOrNull()
|
||||||
?.totpUri
|
?.totpUri
|
||||||
?.toUri()
|
?.toUri()
|
||||||
?.getTotpDataOrNull()
|
?.getTotpDataOrNull()
|
||||||
?: return false
|
?: run {
|
||||||
|
Timber.e(
|
||||||
|
t = IllegalStateException(),
|
||||||
|
message = "Unable to parse TOTP URI.",
|
||||||
|
)
|
||||||
|
return false
|
||||||
|
}
|
||||||
addTotpItemFromAuthenticatorManager.pendingAddTotpLoginItemData = totpData
|
addTotpItemFromAuthenticatorManager.pendingAddTotpLoginItemData = totpData
|
||||||
applicationContext.startActivity(intent)
|
applicationContext.startActivity(intent)
|
||||||
return true
|
return true
|
||||||
|
|
Loading…
Reference in a new issue