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
Merge pull request #205 from matrix-org/markjh/megolm
Update the olm library version to 1.3.0
This commit is contained in:
@@ -156,6 +156,8 @@ function MatrixClient(opts) {
|
|||||||
opts.sessionStore,
|
opts.sessionStore,
|
||||||
userId, this.deviceId
|
userId, this.deviceId
|
||||||
);
|
);
|
||||||
|
|
||||||
|
this.olmVersion = Crypto.getOlmVersion();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
utils.inherits(MatrixClient, EventEmitter);
|
utils.inherits(MatrixClient, EventEmitter);
|
||||||
|
|||||||
@@ -72,6 +72,14 @@ function _initialise_account(sessionStore, pickleKey, account) {
|
|||||||
sessionStore.storeEndToEndAccount(pickled);
|
sessionStore.storeEndToEndAccount(pickled);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {array} The version of Olm.
|
||||||
|
*/
|
||||||
|
OlmDevice.getOlmVersion = function() {
|
||||||
|
return Olm.get_library_version();
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* extract our OlmAccount from the session store and call the given function
|
* extract our OlmAccount from the session store and call the given function
|
||||||
*
|
*
|
||||||
@@ -597,7 +605,12 @@ OlmDevice.prototype.addInboundGroupSession = function(
|
|||||||
var self = this;
|
var self = this;
|
||||||
var session = new Olm.InboundGroupSession();
|
var session = new Olm.InboundGroupSession();
|
||||||
try {
|
try {
|
||||||
session.create(chainIndex, sessionKey);
|
session.create(sessionKey);
|
||||||
|
if (sessionId != session.session_id()) {
|
||||||
|
throw new Error(
|
||||||
|
"Mismatched group session ID from senderKey: " + senderKey
|
||||||
|
);
|
||||||
|
}
|
||||||
self._saveInboundGroupSession(roomId, senderKey, sessionId, session);
|
self._saveInboundGroupSession(roomId, senderKey, sessionId, session);
|
||||||
} finally {
|
} finally {
|
||||||
session.free();
|
session.free();
|
||||||
|
|||||||
@@ -124,7 +124,7 @@ MegolmEncryption.prototype._prepareNewSession = function(room) {
|
|||||||
|
|
||||||
this._olmDevice.addInboundGroupSession(
|
this._olmDevice.addInboundGroupSession(
|
||||||
this._roomId, this._olmDevice.deviceCurve25519Key, session_id,
|
this._roomId, this._olmDevice.deviceCurve25519Key, session_id,
|
||||||
key.key, key.chain_index
|
key.key
|
||||||
);
|
);
|
||||||
|
|
||||||
// we're going to share the key with all current members of the room,
|
// we're going to share the key with all current members of the room,
|
||||||
@@ -403,8 +403,7 @@ MegolmDecryption.prototype.onRoomKeyEvent = function(event) {
|
|||||||
|
|
||||||
if (!content.room_id ||
|
if (!content.room_id ||
|
||||||
!content.session_id ||
|
!content.session_id ||
|
||||||
!content.session_key ||
|
!content.session_key
|
||||||
content.chain_index === undefined
|
|
||||||
) {
|
) {
|
||||||
console.error("key event is missing fields");
|
console.error("key event is missing fields");
|
||||||
return;
|
return;
|
||||||
@@ -412,7 +411,7 @@ MegolmDecryption.prototype.onRoomKeyEvent = function(event) {
|
|||||||
|
|
||||||
this._olmDevice.addInboundGroupSession(
|
this._olmDevice.addInboundGroupSession(
|
||||||
content.room_id, event.getSenderKey(), content.session_id,
|
content.room_id, event.getSenderKey(), content.session_id,
|
||||||
content.session_key, content.chain_index, event.getKeysClaimed()
|
content.session_key, event.getKeysClaimed()
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
@@ -135,6 +135,13 @@ function _registerEventHandlers(crypto, eventEmitter) {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return {string} The version of Olm.
|
||||||
|
*/
|
||||||
|
Crypto.getOlmVersion = function() {
|
||||||
|
return OlmDevice.getOlmVersion();
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the Ed25519 key for this device
|
* Get the Ed25519 key for this device
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -39,6 +39,6 @@
|
|||||||
"uglifyjs": "^2.4.10"
|
"uglifyjs": "^2.4.10"
|
||||||
},
|
},
|
||||||
"optionalDependencies": {
|
"optionalDependencies": {
|
||||||
"olm": "https://matrix.org/packages/npm/olm/olm-1.2.0.tgz"
|
"olm": "https://matrix.org/packages/npm/olm/olm-1.3.0.tgz"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
14
spec/unit/crypto.spec.js
Normal file
14
spec/unit/crypto.spec.js
Normal file
@@ -0,0 +1,14 @@
|
|||||||
|
|
||||||
|
"use strict";
|
||||||
|
var Crypto = require("../../lib/crypto");
|
||||||
|
var sdk = require("../..");
|
||||||
|
|
||||||
|
describe("Crypto", function() {
|
||||||
|
if (!sdk.CRYPTO_ENABLED) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
it("Crypto exposes the correct olm library version", function() {
|
||||||
|
expect(Crypto.getOlmVersion()).toEqual([1, 3, 0]);
|
||||||
|
});
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user