Skip to content
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

Open
wants to merge 10 commits into
base: develop
Choose a base branch
from

Conversation

dbkr
Copy link
Member

@dbkr dbkr commented Jan 29, 2025

Fixes #29118

Checklist

  • Tests written for new code (and old code if feasible).
  • New or updated public/exported symbols have accurate TSDoc documentation.
  • Linter and other CI checks pass.
  • I have licensed the changes to Element by completing the Contributor License Agreement (CLA)

@dbkr dbkr marked this pull request as ready for review January 31, 2025 13:05
@dbkr dbkr requested review from a team as code owners January 31, 2025 13:05
Comment on lines +56 to +66
const recheckSetupRequired = useCallback(() => {
(async () => {
const crypto = matrixClient.getCrypto()!;
const isCrossSigningReady = await crypto.isCrossSigningReady();
if (isCrossSigningReady) {
setState("main");
} else {
setState("set_up_encryption");
}
})();
}, [matrixClient]);
Copy link
Member

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

Comment on lines +42 to +43
| "reset_identity_compromised"
| "reset_identity_forgot";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think, the doc is missing

Comment on lines +60 to +64
if (isCrossSigningReady) {
setState("main");
} else {
setState("set_up_encryption");
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (isCrossSigningReady) {
setState("main");
} else {
setState("set_up_encryption");
}
if (isCrossSigningReady) setState("main");
else setState("set_up_encryption");

export function EncryptionUserSettingsTab(): JSX.Element {
const [state, setState] = useState<State>("loading");
const setUpEncryptionRequired = useSetUpEncryptionRequired(setState);
interface Props {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Since we have multiple components in the file:

Suggested change
interface Props {
interface EncryptionUserSettingsTabProps {

import { registerAccountMas } from "../oidc";
import { deleteCachedSecrets } from "./utils";

test.use(masHomeserver);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The test needs mas?

Comment on lines +20 to +44
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();
Copy link
Member

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

Copy link
Member

@uhoreg uhoreg left a 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


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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// We won't be prompted for crypto setup unless we have na e2e room, so make one
// We won't be prompted for crypto setup unless we have an e2e room, so make one

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Your key storage is out of sync - Forgot recovery key? - After click silently disappears
3 participants