Skip to content
This repository was archived by the owner on Sep 11, 2024. It is now read-only.

Commit 04e1b20

Browse files
committed
Call the AsJson forms of import and exportRoomKeys
1 parent 0c56025 commit 04e1b20

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

src/async-components/views/dialogs/security/ExportE2eKeysDialog.tsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -109,10 +109,10 @@ export default class ExportE2eKeysDialog extends React.Component<IProps, IState>
109109
// asynchronous ones.
110110
Promise.resolve()
111111
.then(() => {
112-
return this.props.matrixClient.getCrypto()!.exportRoomKeys();
112+
return this.props.matrixClient.getCrypto()!.exportRoomKeysAsJson();
113113
})
114114
.then((k) => {
115-
return MegolmExportEncryption.encryptMegolmKeyFile(JSON.stringify(k), passphrase);
115+
return MegolmExportEncryption.encryptMegolmKeyFile(k, passphrase);
116116
})
117117
.then((f) => {
118118
const blob = new Blob([f], {

src/async-components/views/dialogs/security/ImportE2eKeysDialog.tsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ export default class ImportE2eKeysDialog extends React.Component<IProps, IState>
108108
return MegolmExportEncryption.decryptMegolmKeyFile(arrayBuffer, passphrase);
109109
})
110110
.then((keys) => {
111-
return this.props.matrixClient.getCrypto()?.importRoomKeys(JSON.parse(keys));
111+
return this.props.matrixClient.getCrypto()?.importRoomKeysAsJson(keys);
112112
})
113113
.then(() => {
114114
// TODO: it would probably be nice to give some feedback about what we've imported here.

test/components/views/dialogs/security/ExportE2eKeysDialog-test.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -66,10 +66,10 @@ describe("ExportE2eKeysDialog", () => {
6666
const cli = createTestClient();
6767
const keys: IMegolmSessionData[] = [];
6868
const passphrase = "ThisIsAMoreSecurePW123$$";
69-
const exportRoomKeys = jest.fn().mockResolvedValue(keys);
69+
const exportRoomKeysAsJson = jest.fn().mockResolvedValue(JSON.stringify(keys));
7070
cli.getCrypto = () => {
7171
return {
72-
exportRoomKeys,
72+
exportRoomKeysAsJson,
7373
} as unknown as CryptoApi;
7474
};
7575

@@ -85,7 +85,7 @@ describe("ExportE2eKeysDialog", () => {
8585
fireEvent.click(container.querySelector("[type=submit]")!);
8686

8787
// Then it exports keys and encrypts them
88-
await waitFor(() => expect(exportRoomKeys).toHaveBeenCalled());
88+
await waitFor(() => expect(exportRoomKeysAsJson).toHaveBeenCalled());
8989
await waitFor(() =>
9090
expect(MegolmExportEncryption.encryptMegolmKeyFile).toHaveBeenCalledWith(JSON.stringify(keys), passphrase),
9191
);

test/components/views/dialogs/security/ImportE2eKeysDialog-test.tsx

+3-3
Original file line numberDiff line numberDiff line change
@@ -71,10 +71,10 @@ describe("ImportE2eKeysDialog", () => {
7171
const cli = createTestClient();
7272
const onFinished = jest.fn();
7373
const file = new File(["test"], "file.txt", { type: "text/plain" });
74-
const importRoomKeys = jest.fn();
74+
const importRoomKeysAsJson = jest.fn();
7575
cli.getCrypto = () => {
7676
return {
77-
importRoomKeys,
77+
importRoomKeysAsJson,
7878
} as unknown as CryptoApi;
7979
};
8080

@@ -90,6 +90,6 @@ describe("ImportE2eKeysDialog", () => {
9090
await userEvent.paste("passphrase");
9191
fireEvent.click(container.querySelector("[type=submit]")!);
9292

93-
await waitFor(() => expect(importRoomKeys).toHaveBeenCalled());
93+
await waitFor(() => expect(importRoomKeysAsJson).toHaveBeenCalled());
9494
});
9595
});

0 commit comments

Comments
 (0)