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

Commit 8bf785d

Browse files
committed
Expose megolm import/export via the devtools
1 parent 6cffe72 commit 8bf785d

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

src/index.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,27 @@ module.exports.getComponent = function(componentName) {
2828
return Skinner.getComponent(componentName);
2929
};
3030

31+
32+
/* hacky functions for megolm import/export until we give it a UI */
33+
import * as MegolmExportEncryption from './utils/MegolmExportEncryption';
34+
import MatrixClientPeg from './MatrixClientPeg';
35+
36+
window.exportKeys = function(password) {
37+
return MatrixClientPeg.get().exportRoomKeys().then((k) => {
38+
return MegolmExportEncryption.encryptMegolmKeyFile(
39+
JSON.stringify(k), password
40+
);
41+
}).then((f) => {
42+
console.log(new TextDecoder().decode(new Uint8Array(f)));
43+
}).done();
44+
};
45+
46+
window.importKeys = function(password, data) {
47+
const arrayBuffer = new TextEncoder().encode(data).buffer;
48+
return MegolmExportEncryption.decryptMegolmKeyFile(
49+
arrayBuffer, password
50+
).then((j) => {
51+
const k = JSON.parse(j);
52+
return MatrixClientPeg.get().importRoomKeys(k);
53+
});
54+
};

0 commit comments

Comments
 (0)