You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-12-05 17:02:07 +03:00
Always check backup validity, even during enabling
This ensure we run the full backup validity check even when enabling (rather than assuming we've signed things correctly) to ensure any problem are reported right away.
This commit is contained in:
@@ -1506,11 +1506,15 @@ MatrixClient.prototype.createKeyBackupVersion = async function(info) {
|
||||
undefined, "POST", "/room_keys/version", undefined, data,
|
||||
{prefix: httpApi.PREFIX_UNSTABLE},
|
||||
);
|
||||
this.enableKeyBackup({
|
||||
algorithm: info.algorithm,
|
||||
auth_data: info.auth_data,
|
||||
version: res.version,
|
||||
});
|
||||
|
||||
// We could assume everything's okay and enable directly, but this ensures
|
||||
// we run the same signature verification that will be used for future
|
||||
// sessions.
|
||||
await this.checkKeyBackup();
|
||||
if (!this.getKeyBackupEnabled()) {
|
||||
throw new Error("Key backup not usable even though we just created it");
|
||||
}
|
||||
|
||||
return res;
|
||||
};
|
||||
|
||||
|
||||
@@ -952,8 +952,7 @@ Crypto.prototype.setTrustedBackupPubKey = async function(trustedPubKey) {
|
||||
*/
|
||||
Crypto.prototype.checkKeyBackup = async function() {
|
||||
this._checkedForBackup = false;
|
||||
const returnInfo = await this._checkAndStartKeyBackup();
|
||||
return returnInfo;
|
||||
return this._checkAndStartKeyBackup();
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user