Add a recovery key screen hook. (#5684)

update generateRecoveryKey to take a passphrase option

Wire up AppHooks with recovery key hook

Update xcodeproj

Review fixups

Review fixups

Make the `SecureBackupRecoveryState.viewMode` extension private

Bump the enterprise submodule
This commit is contained in:
Michael
2026-06-18 07:28:57 -05:00
committed by GitHub
parent 73ea338d67
commit 7edca8b5a1
16 changed files with 97 additions and 39 deletions
@@ -110,19 +110,18 @@ class SecureBackupController: SecureBackupControllerProtocol {
return .success(())
}
func generateRecoveryKey() async -> Result<String, SecureBackupControllerError> {
func generateRecoveryKey(withPassphrase passphrase: String?) async -> Result<String, SecureBackupControllerError> {
do {
guard recoveryState.value == .disabled else {
if recoveryState.value == .disabled {
MXLog.info("Enabling recovery")
} else {
MXLog.info("Resetting recovery key")
let key = try await encryption.resetRecoveryKey()
return .success(key)
}
MXLog.info("Enabling recovery")
var keyUploadErrored = false
let recoveryKey = try await encryption.enableRecovery(waitForBackupsToUpload: false, passphrase: nil, progressListener: SDKListener { [weak self] state in
// Note: `enableRecovery` also handles the reset case (equivalent to `resetRecoveryKey`).
// Despite the name, it is the correct call for both initial setup and key rotation.
let recoveryKey = try await encryption.enableRecovery(waitForBackupsToUpload: false, passphrase: passphrase, progressListener: SDKListener { [weak self] state in
guard let self else { return }
switch state {
@@ -55,7 +55,7 @@ protocol SecureBackupControllerProtocol {
func enable() async -> Result<Void, SecureBackupControllerError>
func disable() async -> Result<Void, SecureBackupControllerError>
func generateRecoveryKey() async -> Result<String, SecureBackupControllerError>
func generateRecoveryKey(withPassphrase passphrase: String?) async -> Result<String, SecureBackupControllerError>
func confirmRecoveryKey(_ key: String) async -> Result<Void, SecureBackupControllerError>
func waitForKeyBackupUpload(uploadStateSubject: CurrentValueSubject<SecureBackupSteadyState, Never>) async -> Result<Void, SecureBackupControllerError>