-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
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
Wire up the "Forgot recovery key" button for the "Key storage out of sync" toast #29138
Conversation
const recheckSetupRequired = useCallback(() => { | ||
(async () => { | ||
const crypto = matrixClient.getCrypto()!; | ||
const isCrossSigningReady = await crypto.isCrossSigningReady(); | ||
if (isCrossSigningReady) { | ||
setState("main"); | ||
} else { | ||
setState("set_up_encryption"); | ||
} | ||
})(); | ||
}, [matrixClient]); |
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.
I'm in favour to use a custom hook like useSetUpEncryptionRequired
before. It helps the readability of the component imo
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.
Something like this? I find the custom hook a bit awkward in this scenario since you have to pass a lot of functions around, but I don't mind too much.
src/components/views/settings/tabs/user/EncryptionUserSettingsTab.tsx
Outdated
Show resolved
Hide resolved
if (isCrossSigningReady) { | ||
setState("main"); | ||
} else { | ||
setState("set_up_encryption"); | ||
} |
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.
if (isCrossSigningReady) { | |
setState("main"); | |
} else { | |
setState("set_up_encryption"); | |
} | |
if (isCrossSigningReady) setState("main"); | |
else setState("set_up_encryption"); |
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.
I'd really rather not if at all possible: I find these line-ifs split over multiple lines very confusing, and I think our code style permits line ifs only if they're one single line.
src/components/views/settings/tabs/user/EncryptionUserSettingsTab.tsx
Outdated
Show resolved
Hide resolved
playwright/e2e/crypto/toasts.spec.ts
Outdated
import { registerAccountMas } from "../oidc"; | ||
import { deleteCachedSecrets } from "./utils"; | ||
|
||
test.use(masHomeserver); |
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 test needs mas?
playwright/e2e/crypto/toasts.spec.ts
Outdated
test.beforeEach(async ({ page, app, mailpitClient }) => { | ||
await page.goto("/#/login"); | ||
await page.getByRole("button", { name: "Continue" }).click(); | ||
await registerAccountMas(page, mailpitClient, "alice", "[email protected]", "Pa$sW0rD!"); | ||
|
||
await expect(page.getByRole("heading", { level: 1, name: "Welcome alice" })).toBeVisible(); | ||
|
||
// We won't be prompted for crypto setup unless we have na e2e room, so make one | ||
await page.getByRole("button", { name: "Add room" }).click(); | ||
await page.getByRole("menuitem", { name: "New room" }).click(); | ||
await page.getByRole("textbox", { name: "Name" }).fill("Test room"); | ||
await page.getByRole("button", { name: "Create room" }).click(); | ||
|
||
// Now set up recovery (otherwise we'll delete the only copy of the secret) | ||
await page.getByLabel("User menu").click(); | ||
await page.getByLabel("All settings").click(); | ||
await page.getByRole("tab", { name: "Encryption" }).click(); | ||
await page.getByRole("button", { name: "Set up recovery" }).click(); | ||
await page.getByRole("button", { name: "Continue" }).click(); | ||
recoveryKey = await page.getByTestId("recoveryKey").textContent(); | ||
await page.getByRole("button", { name: "Continue" }).click(); | ||
await page.getByRole("textbox", { name: "Enter recovery key" }).fill(recoveryKey); | ||
await page.getByRole("button", { name: "Finish set up" }).click(); | ||
|
||
await expect(page.getByRole("button", { name: "Change recovery key" })).toBeVisible(); |
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.
Can't we use crypto/utils#createBot
to create a second session, bootstrap cross singing and create a recovery key?
crypto/utils#verifySession
can be used to verify the current session too
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.
It took a bit but I think this is working with the bot client now.
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.
From a crypto point of view, looks OK
Co-authored-by: Florian Duros <[email protected]>
…tofsync_forgotpassword
…sync" toast (#29138) * Wire up the "Forgot recovery key" button for the "Key storage out of sync" toast * Unused import & fix test * Test 'forgot' variant * Fix dependencies * Add more toast tests * Unused import * Test initialState in Encryption Tab * Let's see if github has any more luck running this test than me * Working playwright test with screenshot * year * Convert playwright test to use the bot client * Disambiguate Co-authored-by: Florian Duros <[email protected]> * Add doc & do other part of rename * Split out into custom hook * Fix tests --------- Co-authored-by: Florian Duros <[email protected]> (cherry picked from commit 9657d39)
"Wire up", but what actually happens? can we get some screenshots or something? |
* - "reset_identity_compromised": The panel to show when the user is resetting their identity, in te case where their key is compromised. | ||
* - "reset_identity_forgot": The panel to show when the user is resetting their identity, in the case where they forgot their recovery key. | ||
* - `secrets_not_cached`: The secrets are not cached locally. This can happen if we verified another device and secret-gossiping failed, or the other device itself lacked the secrets. | ||
* If the "set_up_encryption" and "secrets_not_cached" conditions are both filled, "set_up_encryption" prevails. |
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.
what on earth is going on with the indentation here?
const checkEncryptionState = useCheckEncryptionState(setState); | ||
interface EncryptionUserSettingsTabProps { | ||
/** | ||
* If the tab should start in a state other than the deasult |
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.
desault
export function EncryptionUserSettingsTab(): JSX.Element { | ||
const [state, setState] = useState<State>("loading"); | ||
const checkEncryptionState = useCheckEncryptionState(setState); | ||
interface EncryptionUserSettingsTabProps { |
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.
FWIW, my reading of https://github.com/element-hq/element-web/blob/develop/code_style.md#react is that the Props interface should be called Props
, but I'm perfectly happy for it to have a better name
@@ -50,6 +50,7 @@ import { EncryptionUserSettingsTab } from "../settings/tabs/user/EncryptionUserS | |||
interface IProps { | |||
initialTabId?: UserTab; | |||
showMsc4108QrCode?: boolean; | |||
showResetIdentity?: boolean; |
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.
documentation please. What does this do? Is false
the same as undefined
?
const payload: OpenToTabPayload = { | ||
action: Action.ViewUserSettings, | ||
initialTabId: UserTab.Encryption, | ||
props: { showResetIdentity: true }, | ||
}; | ||
defaultDispatcher.dispatch(payload); |
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.
a comment in here might not go amiss. What does this payload actually do?
@@ -32,23 +32,35 @@ import { RecoveryPanelOutOfSync } from "../../encryption/RecoveryPanelOutOfSync" | |||
* This happens when the user has a recovery key and the user clicks on "Change recovery key" button of the RecoveryPanel. | |||
* - "set_recovery_key": The panel to show when the user is setting up their recovery key. | |||
* This happens when the user doesn't have a key a recovery key and the user clicks on "Set up recovery key" button of the RecoveryPanel. | |||
* - "reset_identity": The panel to show when the user is resetting their identity. | |||
* - `secrets_not_cached`: The secrets are not cached locally. This can happen if we verified another device and secret-gossiping failed, or the other device itself lacked the secrets. | |||
* - "reset_identity_compromised": The panel to show when the user is resetting their identity, in te case where their key is compromised. |
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.
te
/** | ||
* The variant of the panel to show. We show more warnings in the 'compromised' variant (no use in showing a user this | ||
* warning if they have to reset because they no longer have their key) | ||
* "compromised" is shown when the user chooses 'reset' explicitly in settings, usually because they believe their | ||
* identity has been compromised. | ||
* "forgot" is shown when the user has just forgotten their passphrase. | ||
*/ |
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.
Formatting is weird here. Newlines don't do anything in tsdoc; either commit to new paragraphs with a blank line, or match the generated output by removing the linebreaks (presumably the former in this case). You can't just sit on the fence.
const useSecurityKey = page.locator(".mx_Dialog").getByRole("button", { name: "use your Security Key" }); | ||
if (await useSecurityKey.isVisible()) { | ||
await useSecurityKey.click(); | ||
} |
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.
comment would be good here. Why is this sometimes necessary and sometimes not?
import { test, expect } from "../../element-web-test"; | ||
import { createBot, deleteCachedSecrets, logIntoElement } from "./utils"; | ||
|
||
test.describe("Key storage out of sync toast", () => { |
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.
(don't we already have some tests for this toast somewhere else?)
}); | ||
|
||
test("should prompt for recovery key if 'enter recovery key' pressed", { tag: "@screenshot" }, async ({ page }) => { | ||
// Need to wait for 2 to appear since playwright only evaluates 'first()' initially, so the waiting won't work |
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.
Need to wait for 2 to appear since playwright only evaluates 'first()' initially, so the waiting won't work
wat?
…Key storage out of sync" toast (#29190) * Wire up the "Forgot recovery key" button for the "Key storage out of sync" toast (#29138) * Wire up the "Forgot recovery key" button for the "Key storage out of sync" toast * Unused import & fix test * Test 'forgot' variant * Fix dependencies * Add more toast tests * Unused import * Test initialState in Encryption Tab * Let's see if github has any more luck running this test than me * Working playwright test with screenshot * year * Convert playwright test to use the bot client * Disambiguate Co-authored-by: Florian Duros <[email protected]> * Add doc & do other part of rename * Split out into custom hook * Fix tests --------- Co-authored-by: Florian Duros <[email protected]> (cherry picked from commit 9657d39) * Update fetchdep.sh to understand merge queues --------- Co-authored-by: David Baker <[email protected]> Co-authored-by: Michael Telatynski <[email protected]>
Fixes #29118
Checklist
public
/exported
symbols have accurate TSDoc documentation.