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 kotlinx.coroutines.CoroutineScope
|
||||
import kotlinx.coroutines.launch
|
||||
import timber.log.Timber
|
||||
|
||||
/**
|
||||
* Default implementation of [AuthenticatorBridgeProcessor].
|
||||
|
@ -93,7 +94,13 @@ class AuthenticatorBridgeProcessorImpl(
|
|||
}
|
||||
|
||||
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 {
|
||||
// Encrypt the shared account data with the symmetric key:
|
||||
val encryptedSharedAccountData = authenticatorBridgeRepository
|
||||
|
@ -110,14 +117,31 @@ class AuthenticatorBridgeProcessorImpl(
|
|||
}
|
||||
|
||||
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 totpData = data.decrypt(symmetricEncryptionKey)
|
||||
.onFailure {
|
||||
Timber.e(t = it, message = "Unable to decrypt TOTP data.")
|
||||
return false
|
||||
}
|
||||
.getOrNull()
|
||||
?.totpUri
|
||||
?.toUri()
|
||||
?.getTotpDataOrNull()
|
||||
?: return false
|
||||
?: run {
|
||||
Timber.e(
|
||||
t = IllegalStateException(),
|
||||
message = "Unable to parse TOTP URI.",
|
||||
)
|
||||
return false
|
||||
}
|
||||
addTotpItemFromAuthenticatorManager.pendingAddTotpLoginItemData = totpData
|
||||
applicationContext.startActivity(intent)
|
||||
return true
|
||||
|
|
Loading…
Reference in a new issue