1
0
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:
J. Ryan Stinnett
2019-12-12 12:39:06 +00:00
parent 3f448df1d3
commit 443e01d38c
2 changed files with 10 additions and 7 deletions

View File

@@ -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;
};

View File

@@ -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();
};
/**