-
-
Notifications
You must be signed in to change notification settings - Fork 828
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Recovery: Fix backup change detection not working in rust #12160
Conversation
5904b1b
to
f0e34e4
Compare
f0e34e4
to
f6b14ce
Compare
@@ -1675,7 +1675,8 @@ export default class MatrixChat extends React.PureComponent<IProps, IState> { | |||
let haveNewVersion: boolean | undefined; | |||
let newVersionInfo: IKeyBackupInfo | null = null; | |||
// if key backup is still enabled, there must be a new backup in place | |||
if (cli.getKeyBackupEnabled()) { | |||
const backupEnabled = (await cli.getCrypto()!.getActiveSessionBackupVersion()) !== null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you just put a Boolean() cast here if the variable is called backupEnabled, or if it's staying as string | null
, maybe call the variable backupVersion
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Udpated. The logic has changed a bit also.
@@ -66,7 +65,7 @@ export default class NewRecoveryMethodDialog extends React.PureComponent<IProps> | |||
const hackWarning = <p className="warning">{_t("encryption|new_recovery_method_detected|warning")}</p>; | |||
|
|||
let content: JSX.Element | undefined; | |||
if (MatrixClientPeg.safeGet().getKeyBackupEnabled()) { | |||
if (this.props.newVersionInfo) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this.props.newVersionInfo
is of type IKeyBackupInfo
. Won't that always be truthy?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right, this code was a bit confusing and I added a bit more.
So I looked at what it was doing, and updated it to make a bit more sense.
So the idea is that when we detect that the backup is removed/updated we want to notify the user.
I don't think it was that usefull to make a difference if the new backup is trusted or not as anyhow it was offering the option to go to settings. And from settings you can do what you want.
So basically there are 2 cases:
- There is no backup anymore: Shows the dialog to setup a new one as a shortcut or go to settings
- There is a new backup: Shows the dialog that notifies you with an option to open the settings.
I added playwrigth tests to test it for rust crypto.
Unfortunatly the detection of change on legacy crypto is harder to trigger.. I disabled the test for legacy for now.
I think that if we really want this feature, we should do it better and improve the code to detect backup changes
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The other option would be to remove that feature until we have clearer requirements
Closing for now as the requirements are not clear enough, and the current solution only partially detect changes |
Fixes element-hq/element-web#26792
React sdk was still making usage of
client#getKeyBackupEnabled()
that is deprecated and failing in rust stack.That would cause the following dialog to not show up:
When the backup is deleted from another session
![image](https://private-user-images.githubusercontent.com/9841565/298106936-9a95d135-cf72-4b63-b72d-71b7a861992f.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjIxMzY4MTIsIm5iZiI6MTcyMjEzNjUxMiwicGF0aCI6Ii85ODQxNTY1LzI5ODEwNjkzNi05YTk1ZDEzNS1jZjcyLTRiNjMtYjcyZC03MWI3YTg2MTk5MmYucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDcyOCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA3MjhUMDMxNTEyWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NDU1YTk0NmRjNDY5NDhjZjhjOThmMjI3NTVkZGQxN2ZiMWJlM2MzMDU1NThjZjliNzFlOWNjODBjMDNlZTg1YiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.FCXFAg8nTru8oiiwK2eANX0pt8T9M1UYLCNpsUL6u-o)
When backup is reset from another session
![image](https://private-user-images.githubusercontent.com/9841565/298107012-d7a3793b-27c4-4094-a90b-35e754e771a0.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjIxMzY4MTIsIm5iZiI6MTcyMjEzNjUxMiwicGF0aCI6Ii85ODQxNTY1LzI5ODEwNzAxMi1kN2EzNzkzYi0yN2M0LTQwOTQtYTkwYi0zNWU3NTRlNzcxYTAucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDcyOCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA3MjhUMDMxNTEyWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9Yzc5MTZjYmQwZDVkYmYyOTI2NTU1ZTlkMTZlNmJiZmU3NDE4MDYxYmVmNzlkMDY1ZmUyZTdlOWZlMzViZmY0MCZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.gbnhfRMpmHQMaaPuGn2Rq5VPOojcX3Kmu3AnB8rCn2k)
Checklist
Here's what your changelog entry will look like:
🐛 Bug Fixes