1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-12-01 04:43:29 +03:00

Upload cross-signing key signatures in the background

At the moment, uploading cross-signing key signatures is a slow process that can
potentially take many minutes (!) for large accounts / slow servers. This
changes to do the bootstrapping related versions of this in the background.

Note that key signature uploads for interactive flows like verification are
still blocking for now.

Fixes https://github.com/vector-im/riot-web/issues/12223
This commit is contained in:
J. Ryan Stinnett
2020-03-09 15:08:12 +00:00
parent 951fff45e6
commit c02928f294

View File

@@ -666,10 +666,15 @@ Crypto.prototype._afterCrossSigningLocalKeyChange = async function() {
// sign the current device with the new key, and upload to the server
const device = this._deviceList.getStoredDevice(this._userId, this._deviceId);
const signedDevice = await this._crossSigningInfo.signDevice(this._userId, device);
await this._baseApis.uploadKeySignatures({
logger.info(`Starting background key sig upload for ${this._deviceId}`);
this._baseApis.uploadKeySignatures({
[this._userId]: {
[this._deviceId]: signedDevice,
},
}).then(() => {
logger.info(`Finished background key sig upload for ${this._deviceId}`);
}).catch(e => {
logger.error(`Error during background key sig upload for ${this._deviceId}`, e);
});
const shouldUpgradeCb = (
@@ -952,8 +957,14 @@ Crypto.prototype.checkOwnCrossSigningTrust = async function() {
= this._crossSigningInfo.keys.master;
}
if (Object.keys(keySignatures).length) {
await this._baseApis.uploadKeySignatures({[this._userId]: keySignatures});
const keysToUpload = Object.keys(keySignatures);
if (keysToUpload.length) {
logger.info(`Starting background key sig upload for ${keysToUpload}`);
this._baseApis.uploadKeySignatures({ [this._userId]: keySignatures }).then(() => {
logger.info(`Finished background key sig upload for ${keysToUpload}`);
}).catch(e => {
logger.error(`Error during background key sig upload for ${keysToUpload}`, e);
});
}
this.emit("userTrustStatusChanged", userId, this.checkUserTrust(userId));