mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-02 12:07:28 +00:00
Allow enableRecovery to derive the key from a passphrase
enableRecovery now takes an optional passphrase and returns the recovery key as the suspend result (like resetRecoveryKey), avoiding the flow/return-value race. For the passphrase path the SDK-derived base58 key is kept out of the session-scoped progress flow so it is never surfaced to the user; the caller receives it as the return value and is responsible for scrubbing it. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
+5
-4
@@ -28,7 +28,8 @@ class FakeEncryptionService(
|
||||
private val pinUserIdentityResult: (UserId) -> Result<Unit> = { lambdaError() },
|
||||
private val withdrawVerificationResult: (UserId) -> Result<Unit> = { lambdaError() },
|
||||
private val getUserIdentityResult: (UserId) -> Result<IdentityState?> = { lambdaError() },
|
||||
private val enableRecoveryLambda: (Boolean) -> Result<Unit> = { lambdaError() },
|
||||
private val enableRecoveryLambda: (Boolean, String?) -> Result<String> = { _, _ -> lambdaError() },
|
||||
private val resetRecoveryKeyLambda: () -> Result<String> = { Result.success(FAKE_RECOVERY_KEY) },
|
||||
) : EncryptionService {
|
||||
private var disableRecoveryFailure: Exception? = null
|
||||
override val backupStateStateFlow: MutableStateFlow<BackupState> = MutableStateFlow(BackupState.UNKNOWN)
|
||||
@@ -90,11 +91,11 @@ class FakeEncryptionService(
|
||||
}
|
||||
|
||||
override suspend fun resetRecoveryKey(): Result<String> = simulateLongTask {
|
||||
return Result.success(FAKE_RECOVERY_KEY)
|
||||
return resetRecoveryKeyLambda()
|
||||
}
|
||||
|
||||
override suspend fun enableRecovery(waitForBackupsToUpload: Boolean): Result<Unit> = simulateLongTask {
|
||||
return enableRecoveryLambda(waitForBackupsToUpload)
|
||||
override suspend fun enableRecovery(waitForBackupsToUpload: Boolean, passphrase: String?): Result<String> = simulateLongTask {
|
||||
return enableRecoveryLambda(waitForBackupsToUpload, passphrase)
|
||||
}
|
||||
|
||||
fun givenWaitForBackupUploadSteadyStateFlow(flow: Flow<BackupUploadState>) {
|
||||
|
||||
Reference in New Issue
Block a user