diff --git a/app/src/main/java/com/x8bit/bitwarden/data/platform/processor/AuthenticatorBridgeProcessorImpl.kt b/app/src/main/java/com/x8bit/bitwarden/data/platform/processor/AuthenticatorBridgeProcessorImpl.kt index 29df0ed42..97e7c11f1 100644 --- a/app/src/main/java/com/x8bit/bitwarden/data/platform/processor/AuthenticatorBridgeProcessorImpl.kt +++ b/app/src/main/java/com/x8bit/bitwarden/data/platform/processor/AuthenticatorBridgeProcessorImpl.kt @@ -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