Skip to content

Commit

Permalink
fix(crypto api): resetEncryption always calls resetKeyBackup
Browse files Browse the repository at this point in the history
  • Loading branch information
florianduros committed Jan 23, 2025
1 parent c0e30ce commit 431bfe5
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
2 changes: 1 addition & 1 deletion src/crypto-api/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ export interface CryptoApi {
* - Disable backing up room keys and delete any existing backups.
* - Remove the default secret storage key from the account data (ie: the recovery key).
* - Reset the cross-signing keys.
* - Re-enable backing up room keys if enabled before.
* - Create a new key backup.
*
* @param authUploadDeviceSigningKeys - Callback to authenticate the upload of device signing keys.
* Used when resetting the cross signing keys.
Expand Down
8 changes: 2 additions & 6 deletions src/rust-crypto/rust-crypto.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1477,8 +1477,6 @@ export class RustCrypto extends TypedEventEmitter<RustCryptoEvents, CryptoEventH
* Implementation of {@link CryptoApi#resetEncryption}.
*/
public async resetEncryption(authUploadDeviceSigningKeys: UIAuthCallback<void>): Promise<void> {
const backupEnabled = (await this.backupManager.getActiveBackupVersion()) !== null;

// Disable backup, and delete all the backups from the server
await this.backupManager.deleteAllKeyBackupVersions();

Expand All @@ -1491,10 +1489,8 @@ export class RustCrypto extends TypedEventEmitter<RustCryptoEvents, CryptoEventH
authUploadDeviceSigningKeys,
});

// If key backup was enabled, we create a new backup
if (backupEnabled) {
await this.resetKeyBackup();
}
// Create a new key backup
await this.resetKeyBackup();
}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
Expand Down

0 comments on commit 431bfe5

Please sign in to comment.