1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-23 17:02:25 +03:00

CryptoApi.resetEncryption should always create a new key backup (#4648)

* fix(crypto api): `resetEncryption` always calls `resetKeyBackup`

* test(crypto api): update `resetEncryption` tests

* chore(crypto api): add logging in `resetEncryption`
This commit is contained in:
Florian Duros
2025-01-23 16:35:37 +01:00
committed by GitHub
parent c0e30ceca0
commit ed397d99ed
3 changed files with 13 additions and 29 deletions

View File

@@ -1477,7 +1477,7 @@ 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;
this.logger.debug("resetEncryption: resetting encryption");
// Disable backup, and delete all the backups from the server
await this.backupManager.deleteAllKeyBackupVersions();
@@ -1491,10 +1491,10 @@ 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();
this.logger.debug("resetEncryption: ended");
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////