Rename CreateCrossSigningDialog to InitialCryptoSetupDialog (#28658)
* Rename CreateCrossSigningDialog to InitialCryptoSetup because it will soon encompass things other than just creating cross signing. * Fix name & tests * Fix import * Remove code creating key backup Because this was split out from my key backup by default PR * Fix comment * Convert to named exportpull/28674/merge
parent
9cc5564d50
commit
c659afa8db
|
@ -11,7 +11,7 @@ import { MatrixClient } from "matrix-js-sdk/src/matrix";
|
||||||
|
|
||||||
import AuthPage from "../../views/auth/AuthPage";
|
import AuthPage from "../../views/auth/AuthPage";
|
||||||
import CompleteSecurityBody from "../../views/auth/CompleteSecurityBody";
|
import CompleteSecurityBody from "../../views/auth/CompleteSecurityBody";
|
||||||
import CreateCrossSigningDialog from "../../views/dialogs/security/CreateCrossSigningDialog";
|
import { InitialCryptoSetupDialog } from "../../views/dialogs/security/InitialCryptoSetupDialog";
|
||||||
|
|
||||||
interface IProps {
|
interface IProps {
|
||||||
matrixClient: MatrixClient;
|
matrixClient: MatrixClient;
|
||||||
|
@ -25,7 +25,7 @@ export default class E2eSetup extends React.Component<IProps> {
|
||||||
return (
|
return (
|
||||||
<AuthPage>
|
<AuthPage>
|
||||||
<CompleteSecurityBody>
|
<CompleteSecurityBody>
|
||||||
<CreateCrossSigningDialog
|
<InitialCryptoSetupDialog
|
||||||
matrixClient={this.props.matrixClient}
|
matrixClient={this.props.matrixClient}
|
||||||
onFinished={this.props.onFinished}
|
onFinished={this.props.onFinished}
|
||||||
accountPassword={this.props.accountPassword}
|
accountPassword={this.props.accountPassword}
|
||||||
|
|
|
@ -25,14 +25,19 @@ interface Props {
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Walks the user through the process of creating a cross-signing keys. In most
|
* Walks the user through the process of creating a cross-signing keys.
|
||||||
* cases, only a spinner is shown, but for more complex auth like SSO, the user
|
* In most cases, only a spinner is shown, but for more
|
||||||
* may need to complete some steps to proceed.
|
* complex auth like SSO, the user may need to complete some steps to proceed.
|
||||||
*/
|
*/
|
||||||
const CreateCrossSigningDialog: React.FC<Props> = ({ matrixClient, accountPassword, tokenLogin, onFinished }) => {
|
export const InitialCryptoSetupDialog: React.FC<Props> = ({
|
||||||
|
matrixClient,
|
||||||
|
accountPassword,
|
||||||
|
tokenLogin,
|
||||||
|
onFinished,
|
||||||
|
}) => {
|
||||||
const [error, setError] = useState(false);
|
const [error, setError] = useState(false);
|
||||||
|
|
||||||
const bootstrapCrossSigning = useCallback(async () => {
|
const doSetup = useCallback(async () => {
|
||||||
const cryptoApi = matrixClient.getCrypto();
|
const cryptoApi = matrixClient.getCrypto();
|
||||||
if (!cryptoApi) return;
|
if (!cryptoApi) return;
|
||||||
|
|
||||||
|
@ -40,6 +45,7 @@ const CreateCrossSigningDialog: React.FC<Props> = ({ matrixClient, accountPasswo
|
||||||
|
|
||||||
try {
|
try {
|
||||||
await createCrossSigning(matrixClient, tokenLogin, accountPassword);
|
await createCrossSigning(matrixClient, tokenLogin, accountPassword);
|
||||||
|
|
||||||
onFinished(true);
|
onFinished(true);
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
if (tokenLogin) {
|
if (tokenLogin) {
|
||||||
|
@ -58,8 +64,8 @@ const CreateCrossSigningDialog: React.FC<Props> = ({ matrixClient, accountPasswo
|
||||||
}, [onFinished]);
|
}, [onFinished]);
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
bootstrapCrossSigning();
|
doSetup();
|
||||||
}, [bootstrapCrossSigning]);
|
}, [doSetup]);
|
||||||
|
|
||||||
let content;
|
let content;
|
||||||
if (error) {
|
if (error) {
|
||||||
|
@ -69,7 +75,7 @@ const CreateCrossSigningDialog: React.FC<Props> = ({ matrixClient, accountPasswo
|
||||||
<div className="mx_Dialog_buttons">
|
<div className="mx_Dialog_buttons">
|
||||||
<DialogButtons
|
<DialogButtons
|
||||||
primaryButton={_t("action|retry")}
|
primaryButton={_t("action|retry")}
|
||||||
onPrimaryButtonClick={bootstrapCrossSigning}
|
onPrimaryButtonClick={doSetup}
|
||||||
onCancel={onCancel}
|
onCancel={onCancel}
|
||||||
/>
|
/>
|
||||||
</div>
|
</div>
|
||||||
|
@ -95,5 +101,3 @@ const CreateCrossSigningDialog: React.FC<Props> = ({ matrixClient, accountPasswo
|
||||||
</BaseDialog>
|
</BaseDialog>
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
export default CreateCrossSigningDialog;
|
|
|
@ -12,14 +12,14 @@ import { mocked } from "jest-mock";
|
||||||
import { MatrixClient } from "matrix-js-sdk/src/matrix";
|
import { MatrixClient } from "matrix-js-sdk/src/matrix";
|
||||||
|
|
||||||
import { createCrossSigning } from "../../../../../src/CreateCrossSigning";
|
import { createCrossSigning } from "../../../../../src/CreateCrossSigning";
|
||||||
import CreateCrossSigningDialog from "../../../../../src/components/views/dialogs/security/CreateCrossSigningDialog";
|
import { InitialCryptoSetupDialog } from "../../../../../src/components/views/dialogs/security/InitialCryptoSetupDialog";
|
||||||
import { createTestClient } from "../../../../test-utils";
|
import { createTestClient } from "../../../../test-utils";
|
||||||
|
|
||||||
jest.mock("../../../../../src/CreateCrossSigning", () => ({
|
jest.mock("../../../../../src/CreateCrossSigning", () => ({
|
||||||
createCrossSigning: jest.fn(),
|
createCrossSigning: jest.fn(),
|
||||||
}));
|
}));
|
||||||
|
|
||||||
describe("CreateCrossSigningDialog", () => {
|
describe("InitialCryptoSetupDialog", () => {
|
||||||
let client: MatrixClient;
|
let client: MatrixClient;
|
||||||
let createCrossSigningResolve: () => void;
|
let createCrossSigningResolve: () => void;
|
||||||
let createCrossSigningReject: (e: Error) => void;
|
let createCrossSigningReject: (e: Error) => void;
|
||||||
|
@ -43,7 +43,7 @@ describe("CreateCrossSigningDialog", () => {
|
||||||
const onFinished = jest.fn();
|
const onFinished = jest.fn();
|
||||||
|
|
||||||
render(
|
render(
|
||||||
<CreateCrossSigningDialog
|
<InitialCryptoSetupDialog
|
||||||
matrixClient={client}
|
matrixClient={client}
|
||||||
accountPassword="hunter2"
|
accountPassword="hunter2"
|
||||||
tokenLogin={false}
|
tokenLogin={false}
|
||||||
|
@ -61,7 +61,7 @@ describe("CreateCrossSigningDialog", () => {
|
||||||
|
|
||||||
it("should display an error if createCrossSigning fails", async () => {
|
it("should display an error if createCrossSigning fails", async () => {
|
||||||
render(
|
render(
|
||||||
<CreateCrossSigningDialog
|
<InitialCryptoSetupDialog
|
||||||
matrixClient={client}
|
matrixClient={client}
|
||||||
accountPassword="hunter2"
|
accountPassword="hunter2"
|
||||||
tokenLogin={false}
|
tokenLogin={false}
|
||||||
|
@ -78,7 +78,7 @@ describe("CreateCrossSigningDialog", () => {
|
||||||
const onFinished = jest.fn();
|
const onFinished = jest.fn();
|
||||||
|
|
||||||
render(
|
render(
|
||||||
<CreateCrossSigningDialog
|
<InitialCryptoSetupDialog
|
||||||
matrixClient={client}
|
matrixClient={client}
|
||||||
accountPassword="hunter2"
|
accountPassword="hunter2"
|
||||||
tokenLogin={true}
|
tokenLogin={true}
|
||||||
|
@ -95,7 +95,7 @@ describe("CreateCrossSigningDialog", () => {
|
||||||
const onFinished = jest.fn();
|
const onFinished = jest.fn();
|
||||||
|
|
||||||
render(
|
render(
|
||||||
<CreateCrossSigningDialog
|
<InitialCryptoSetupDialog
|
||||||
matrixClient={client}
|
matrixClient={client}
|
||||||
accountPassword="hunter2"
|
accountPassword="hunter2"
|
||||||
tokenLogin={false}
|
tokenLogin={false}
|
||||||
|
@ -113,7 +113,7 @@ describe("CreateCrossSigningDialog", () => {
|
||||||
|
|
||||||
it("should retry when the retry button is clicked", async () => {
|
it("should retry when the retry button is clicked", async () => {
|
||||||
render(
|
render(
|
||||||
<CreateCrossSigningDialog
|
<InitialCryptoSetupDialog
|
||||||
matrixClient={client}
|
matrixClient={client}
|
||||||
accountPassword="hunter2"
|
accountPassword="hunter2"
|
||||||
tokenLogin={false}
|
tokenLogin={false}
|
Loading…
Reference in New Issue