feature(crypto): verification violation handling and block sending

This commit is contained in:
Valere 2025-01-08 10:38:55 +01:00
parent ce1c01e626
commit 52c57d4d8e
13 changed files with 224 additions and 14 deletions

View file

@ -78,7 +78,11 @@ fun ComposerAlertMolecule(
text = content,
modifier = Modifier.weight(1f),
style = ElementTheme.typography.fontBodyMdRegular,
color = ElementTheme.colors.textPrimary,
color = if (isCritical) {
ElementTheme.colors.textCriticalPrimary
} else {
ElementTheme.colors.textPrimary
},
textAlign = TextAlign.Start,
)
}

View file

@ -66,6 +66,7 @@ interface EncryptionService {
* Remember this identity, ensuring it does not result in a pin violation.
*/
suspend fun pinUserIdentity(userId: UserId): Result<Unit>
suspend fun withdrawVerificationRequirement(userId: UserId): Result<Unit>
}
/**

View file

@ -209,6 +209,10 @@ internal class RustEncryptionService(
getUserIdentity(userId).pin()
}
override suspend fun withdrawVerificationRequirement(userId: UserId): Result<Unit> = runCatching {
getUserIdentity(userId).withdrawVerification()
}
private suspend fun getUserIdentity(userId: UserId): UserIdentity {
return service.userIdentity(
userId = userId.value,

View file

@ -24,6 +24,7 @@ class FakeEncryptionService(
var startIdentityResetLambda: () -> Result<IdentityResetHandle?> = { lambdaError() },
private val pinUserIdentityResult: (UserId) -> Result<Unit> = { lambdaError() },
private val isUserVerifiedResult: (UserId) -> Result<Boolean> = { lambdaError() },
private val withdrawVerificationResult: (UserId) -> Result<Unit> = { lambdaError() },
) : EncryptionService {
private var disableRecoveryFailure: Exception? = null
override val backupStateStateFlow: MutableStateFlow<BackupState> = MutableStateFlow(BackupState.UNKNOWN)
@ -124,6 +125,10 @@ class FakeEncryptionService(
return pinUserIdentityResult(userId)
}
override suspend fun withdrawVerificationRequirement(userId: UserId): Result<Unit> {
return withdrawVerificationResult(userId)
}
override suspend fun isUserVerified(userId: UserId): Result<Boolean> = simulateLongTask {
isUserVerifiedResult(userId)
}