1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-25 05:23:13 +03:00

Make some OlmDevice megolm methods async

* OlmDevice.hasInboundSessionKeys
* OlmDevice.getInboundGroupSessionKey

The latter means that MegolmDecryption.shareKeysWithDevice takes longer before
it sends out the keyshare, so means the unit test needed an update
This commit is contained in:
Richard van der Hoff
2017-08-10 15:01:56 +01:00
parent 337c9cbea3
commit 8a0f73bf81
3 changed files with 22 additions and 16 deletions

View File

@@ -725,7 +725,7 @@ MegolmDecryption.prototype.onRoomKeyEvent = function(event) {
/**
* @inheritdoc
*/
MegolmDecryption.prototype.hasKeysForKeyRequest = async function(keyRequest) {
MegolmDecryption.prototype.hasKeysForKeyRequest = function(keyRequest) {
const body = keyRequest.requestBody;
return this._olmDevice.hasInboundSessionKeys(
@@ -766,10 +766,10 @@ MegolmDecryption.prototype.shareKeysWithDevice = function(keyRequest) {
+ userId + ":" + deviceId,
);
const payload = this._buildKeyForwardingMessage(
return this._buildKeyForwardingMessage(
body.room_id, body.sender_key, body.session_id,
);
}).then((payload) => {
const encryptedContent = {
algorithm: olmlib.OLM_ALGORITHM,
sender_key: this._olmDevice.deviceCurve25519Key,
@@ -797,10 +797,10 @@ MegolmDecryption.prototype.shareKeysWithDevice = function(keyRequest) {
}).done();
};
MegolmDecryption.prototype._buildKeyForwardingMessage = function(
MegolmDecryption.prototype._buildKeyForwardingMessage = async function(
roomId, senderKey, sessionId,
) {
const key = this._olmDevice.getInboundGroupSessionKey(
const key = await this._olmDevice.getInboundGroupSessionKey(
roomId, senderKey, sessionId,
);