You've already forked matrix-js-sdk
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:
@@ -666,10 +666,15 @@ Crypto.prototype._afterCrossSigningLocalKeyChange = async function() {
|
|||||||
// sign the current device with the new key, and upload to the server
|
// sign the current device with the new key, and upload to the server
|
||||||
const device = this._deviceList.getStoredDevice(this._userId, this._deviceId);
|
const device = this._deviceList.getStoredDevice(this._userId, this._deviceId);
|
||||||
const signedDevice = await this._crossSigningInfo.signDevice(this._userId, device);
|
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._userId]: {
|
||||||
[this._deviceId]: signedDevice,
|
[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 = (
|
const shouldUpgradeCb = (
|
||||||
@@ -952,8 +957,14 @@ Crypto.prototype.checkOwnCrossSigningTrust = async function() {
|
|||||||
= this._crossSigningInfo.keys.master;
|
= this._crossSigningInfo.keys.master;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Object.keys(keySignatures).length) {
|
const keysToUpload = Object.keys(keySignatures);
|
||||||
await this._baseApis.uploadKeySignatures({[this._userId]: 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));
|
this.emit("userTrustStatusChanged", userId, this.checkUserTrust(userId));
|
||||||
|
|||||||
Reference in New Issue
Block a user