Simplify checks for cross-signing setup (#9721)
When the user logs in, we need to know if we should prompt them to verify from an existing device, which means figuring out if the user has set up cross-signing keys. Currently we do this by explicitly downloading the user's keys and then trying to fetch the cross-signing key. This is trickier to implement with the rust-sdk, so instead let's use the newly-added `userHasCrossSigningKeys` in the js-sdk.
This commit is contained in:
parent
73986faa7d
commit
c3aabafc12
1 changed files with 10 additions and 4 deletions
|
@ -371,10 +371,14 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
||||||
}
|
}
|
||||||
|
|
||||||
const promisesList: Promise<any>[] = [this.firstSyncPromise.promise];
|
const promisesList: Promise<any>[] = [this.firstSyncPromise.promise];
|
||||||
|
let crossSigningIsSetUp = false;
|
||||||
if (cryptoEnabled) {
|
if (cryptoEnabled) {
|
||||||
// wait for the client to finish downloading cross-signing keys for us so we
|
// check if the user has previously published public cross-signing keys,
|
||||||
// know whether or not we have keys set up on this account
|
// as a proxy to figure out if it's worth prompting the user to verify
|
||||||
promisesList.push(cli.downloadKeys([cli.getUserId()]));
|
// from another device.
|
||||||
|
promisesList.push((async () => {
|
||||||
|
crossSigningIsSetUp = await cli.userHasCrossSigningKeys();
|
||||||
|
})());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now update the state to say we're waiting for the first sync to complete rather
|
// Now update the state to say we're waiting for the first sync to complete rather
|
||||||
|
@ -388,14 +392,16 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const crossSigningIsSetUp = cli.getStoredCrossSigningForUser(cli.getUserId());
|
|
||||||
if (crossSigningIsSetUp) {
|
if (crossSigningIsSetUp) {
|
||||||
|
// if the user has previously set up cross-signing, verify this device so we can fetch the
|
||||||
|
// private keys.
|
||||||
if (SecurityCustomisations.SHOW_ENCRYPTION_SETUP_UI === false) {
|
if (SecurityCustomisations.SHOW_ENCRYPTION_SETUP_UI === false) {
|
||||||
this.onLoggedIn();
|
this.onLoggedIn();
|
||||||
} else {
|
} else {
|
||||||
this.setStateForNewView({ view: Views.COMPLETE_SECURITY });
|
this.setStateForNewView({ view: Views.COMPLETE_SECURITY });
|
||||||
}
|
}
|
||||||
} else if (await cli.doesServerSupportUnstableFeature("org.matrix.e2e_cross_signing")) {
|
} else if (await cli.doesServerSupportUnstableFeature("org.matrix.e2e_cross_signing")) {
|
||||||
|
// if cross-signing is not yet set up, do so now if possible.
|
||||||
this.setStateForNewView({ view: Views.E2E_SETUP });
|
this.setStateForNewView({ view: Views.E2E_SETUP });
|
||||||
} else {
|
} else {
|
||||||
this.onLoggedIn();
|
this.onLoggedIn();
|
||||||
|
|
Loading…
Reference in a new issue