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
|
* Import a list of room keys previously exported by exportRoomKeys
|
||||||
*
|
*
|
||||||
* @param {Object[]} keys a list of session export objects
|
* @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) {
|
if (!this._crypto) {
|
||||||
throw new Error("End-to-end encryption disabled");
|
throw new Error("End-to-end encryption disabled");
|
||||||
}
|
}
|
||||||
this._crypto.importRoomKeys(keys);
|
return this._crypto.importRoomKeys(keys);
|
||||||
};
|
};
|
||||||
|
|
||||||
// Room ops
|
// Room ops
|
||||||
|
|||||||
@@ -703,17 +703,20 @@ Crypto.prototype.exportRoomKeys = function() {
|
|||||||
* Import a list of room keys previously exported by exportRoomKeys
|
* Import a list of room keys previously exported by exportRoomKeys
|
||||||
*
|
*
|
||||||
* @param {Object[]} keys a list of session export objects
|
* @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) {
|
Crypto.prototype.importRoomKeys = function(keys) {
|
||||||
keys.map((session) => {
|
return Promise.map(
|
||||||
if (!session.room_id || !session.algorithm) {
|
keys, (key) => {
|
||||||
console.warn("ignoring session entry with missing fields", session);
|
if (!key.room_id || !key.algorithm) {
|
||||||
|
console.warn("ignoring room key entry with missing fields", key);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const alg = this._getRoomDecryptor(session.room_id, session.algorithm);
|
const alg = this._getRoomDecryptor(key.room_id, key.algorithm);
|
||||||
alg.importRoomKey(session);
|
alg.importRoomKey(key);
|
||||||
});
|
},
|
||||||
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
Reference in New Issue
Block a user