1
0
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:
Matthew Hodgson
2016-09-16 17:30:26 +01:00
committed by GitHub
6 changed files with 41 additions and 6 deletions

View File

@@ -156,6 +156,8 @@ function MatrixClient(opts) {
opts.sessionStore,
userId, this.deviceId
);
this.olmVersion = Crypto.getOlmVersion();
}
}
utils.inherits(MatrixClient, EventEmitter);

View File

@@ -72,6 +72,14 @@ function _initialise_account(sessionStore, pickleKey, account) {
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
*
@@ -597,7 +605,12 @@ OlmDevice.prototype.addInboundGroupSession = function(
var self = this;
var session = new Olm.InboundGroupSession();
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);
} finally {
session.free();

View File

@@ -124,7 +124,7 @@ MegolmEncryption.prototype._prepareNewSession = function(room) {
this._olmDevice.addInboundGroupSession(
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,
@@ -403,8 +403,7 @@ MegolmDecryption.prototype.onRoomKeyEvent = function(event) {
if (!content.room_id ||
!content.session_id ||
!content.session_key ||
content.chain_index === undefined
!content.session_key
) {
console.error("key event is missing fields");
return;
@@ -412,7 +411,7 @@ MegolmDecryption.prototype.onRoomKeyEvent = function(event) {
this._olmDevice.addInboundGroupSession(
content.room_id, event.getSenderKey(), content.session_id,
content.session_key, content.chain_index, event.getKeysClaimed()
content.session_key, event.getKeysClaimed()
);
};

View File

@@ -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
*

View File

@@ -39,6 +39,6 @@
"uglifyjs": "^2.4.10"
},
"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
View 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]);
});
});