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
Skip device verif upgrades when callback not present
This skips the upgrade when the upgrade callback is not present (which is expected as no one sets it currently). This adds logging for around the upgrade process.
This commit is contained in:
@@ -672,7 +672,13 @@ Crypto.prototype._afterCrossSigningLocalKeyChange = async function() {
|
|||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
// check all users for signatures
|
const shouldUpgradeCb = (
|
||||||
|
this._baseApis._cryptoCallbacks.shouldUpgradeDeviceVerifications
|
||||||
|
);
|
||||||
|
if (shouldUpgradeCb) {
|
||||||
|
logger.info("Starting device verification upgrade");
|
||||||
|
|
||||||
|
// Check all users for signatures if upgrade callback present
|
||||||
// FIXME: do this in batches
|
// FIXME: do this in batches
|
||||||
const users = {};
|
const users = {};
|
||||||
for (const [userId, crossSigningInfo]
|
for (const [userId, crossSigningInfo]
|
||||||
@@ -685,12 +691,10 @@ Crypto.prototype._afterCrossSigningLocalKeyChange = async function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const shouldUpgradeCb = (
|
if (Object.keys(users).length > 0) {
|
||||||
this._baseApis._cryptoCallbacks.shouldUpgradeDeviceVerifications
|
logger.info(`Found ${Object.keys(users).length} verif users to upgrade`);
|
||||||
);
|
|
||||||
if (Object.keys(users).length > 0 && shouldUpgradeCb) {
|
|
||||||
try {
|
try {
|
||||||
const usersToUpgrade = await shouldUpgradeCb({users: users});
|
const usersToUpgrade = await shouldUpgradeCb({ users: users });
|
||||||
if (usersToUpgrade) {
|
if (usersToUpgrade) {
|
||||||
for (const userId of usersToUpgrade) {
|
for (const userId of usersToUpgrade) {
|
||||||
if (userId in users) {
|
if (userId in users) {
|
||||||
@@ -707,6 +711,9 @@ Crypto.prototype._afterCrossSigningLocalKeyChange = async function() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger.info("Finished device verification upgrade");
|
||||||
|
}
|
||||||
|
|
||||||
logger.info("Finished cross-signing key change post-processing");
|
logger.info("Finished cross-signing key change post-processing");
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -984,16 +991,21 @@ Crypto.prototype._storeTrustedSelfKeys = async function(keys) {
|
|||||||
* @param {string} userId the user ID whose key should be checked
|
* @param {string} userId the user ID whose key should be checked
|
||||||
*/
|
*/
|
||||||
Crypto.prototype._checkDeviceVerifications = async function(userId) {
|
Crypto.prototype._checkDeviceVerifications = async function(userId) {
|
||||||
|
const shouldUpgradeCb = (
|
||||||
|
this._baseApis._cryptoCallbacks.shouldUpgradeDeviceVerifications
|
||||||
|
);
|
||||||
|
if (!shouldUpgradeCb) {
|
||||||
|
// Upgrading skipped when callback is not present.
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
logger.info(`Starting device verification upgrade for ${userId}`);
|
||||||
if (this._crossSigningInfo.keys.user_signing) {
|
if (this._crossSigningInfo.keys.user_signing) {
|
||||||
const crossSigningInfo = this._deviceList.getStoredCrossSigningForUser(userId);
|
const crossSigningInfo = this._deviceList.getStoredCrossSigningForUser(userId);
|
||||||
if (crossSigningInfo) {
|
if (crossSigningInfo) {
|
||||||
const upgradeInfo = await this._checkForDeviceVerificationUpgrade(
|
const upgradeInfo = await this._checkForDeviceVerificationUpgrade(
|
||||||
userId, crossSigningInfo,
|
userId, crossSigningInfo,
|
||||||
);
|
);
|
||||||
const shouldUpgradeCb = (
|
if (upgradeInfo) {
|
||||||
this._baseApis._cryptoCallbacks.shouldUpgradeDeviceVerifications
|
|
||||||
);
|
|
||||||
if (upgradeInfo && shouldUpgradeCb) {
|
|
||||||
const usersToUpgrade = await shouldUpgradeCb({
|
const usersToUpgrade = await shouldUpgradeCb({
|
||||||
users: {
|
users: {
|
||||||
[userId]: upgradeInfo,
|
[userId]: upgradeInfo,
|
||||||
@@ -1007,6 +1019,7 @@ Crypto.prototype._checkDeviceVerifications = async function(userId) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
logger.info(`Finished device verification upgrade for ${userId}`);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user