You've already forked matrix-react-sdk
mirror of
https://github.com/matrix-org/matrix-react-sdk.git
synced 2025-07-28 15:22:05 +03:00
Expose megolm import/export via the devtools
This commit is contained in:
24
src/index.js
24
src/index.js
@ -28,3 +28,27 @@ module.exports.getComponent = function(componentName) {
|
|||||||
return Skinner.getComponent(componentName);
|
return Skinner.getComponent(componentName);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
/* hacky functions for megolm import/export until we give it a UI */
|
||||||
|
import * as MegolmExportEncryption from './utils/MegolmExportEncryption';
|
||||||
|
import MatrixClientPeg from './MatrixClientPeg';
|
||||||
|
|
||||||
|
window.exportKeys = function(password) {
|
||||||
|
return MatrixClientPeg.get().exportRoomKeys().then((k) => {
|
||||||
|
return MegolmExportEncryption.encryptMegolmKeyFile(
|
||||||
|
JSON.stringify(k), password
|
||||||
|
);
|
||||||
|
}).then((f) => {
|
||||||
|
console.log(new TextDecoder().decode(new Uint8Array(f)));
|
||||||
|
}).done();
|
||||||
|
};
|
||||||
|
|
||||||
|
window.importKeys = function(password, data) {
|
||||||
|
const arrayBuffer = new TextEncoder().encode(data).buffer;
|
||||||
|
return MegolmExportEncryption.decryptMegolmKeyFile(
|
||||||
|
arrayBuffer, password
|
||||||
|
).then((j) => {
|
||||||
|
const k = JSON.parse(j);
|
||||||
|
return MatrixClientPeg.get().importRoomKeys(k);
|
||||||
|
});
|
||||||
|
};
|
||||||
|
Reference in New Issue
Block a user