You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-29 16:43:09 +03:00
Make Crypto.importRoomKeys async
This commit is contained in:
@@ -632,12 +632,15 @@ MatrixClient.prototype.exportRoomKeys = function() {
|
||||
* Import a list of room keys previously exported by exportRoomKeys
|
||||
*
|
||||
* @param {Object[]} keys a list of session export objects
|
||||
*
|
||||
* @return {module:client.Promise} a promise which resolves when the keys
|
||||
* have been imported
|
||||
*/
|
||||
MatrixClient.prototype.importRoomKeys = async function(keys) {
|
||||
MatrixClient.prototype.importRoomKeys = function(keys) {
|
||||
if (!this._crypto) {
|
||||
throw new Error("End-to-end encryption disabled");
|
||||
}
|
||||
this._crypto.importRoomKeys(keys);
|
||||
return this._crypto.importRoomKeys(keys);
|
||||
};
|
||||
|
||||
// Room ops
|
||||
|
||||
@@ -703,17 +703,20 @@ Crypto.prototype.exportRoomKeys = function() {
|
||||
* Import a list of room keys previously exported by exportRoomKeys
|
||||
*
|
||||
* @param {Object[]} keys a list of session export objects
|
||||
* @return {module:client.Promise} a promise which resolves once the keys have been imported
|
||||
*/
|
||||
Crypto.prototype.importRoomKeys = function(keys) {
|
||||
keys.map((session) => {
|
||||
if (!session.room_id || !session.algorithm) {
|
||||
console.warn("ignoring session entry with missing fields", session);
|
||||
return;
|
||||
}
|
||||
return Promise.map(
|
||||
keys, (key) => {
|
||||
if (!key.room_id || !key.algorithm) {
|
||||
console.warn("ignoring room key entry with missing fields", key);
|
||||
return;
|
||||
}
|
||||
|
||||
const alg = this._getRoomDecryptor(session.room_id, session.algorithm);
|
||||
alg.importRoomKey(session);
|
||||
});
|
||||
const alg = this._getRoomDecryptor(key.room_id, key.algorithm);
|
||||
alg.importRoomKey(key);
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user