You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-28 05:03:59 +03:00
Megolm: don't dereference nullable object
It is possible for `room` to be null when passed to MegolmEncryption.encryptMessage; we need to avoid dereferencing it. Instead, make sure that the EncryptionAlgorithm knows about the roomId it is targeting, and use that. Replace the increasingly-long argument list on the EncryptionAlgorithm constructor with a params list, and update DecryptionAlgorithm to match.
This commit is contained in:
@@ -33,13 +33,11 @@ var OLM_ALGORITHM = "m.olm.v1.curve25519-aes-sha2";
|
||||
* @constructor
|
||||
* @extends {module:crypto-algorithms/base.EncryptionAlgorithm}
|
||||
*
|
||||
* @param {string} deviceId The identifier for this device.
|
||||
* @param {module:crypto} crypto crypto core
|
||||
* @param {module:OlmDevice} olmDevice olm.js wrapper
|
||||
*
|
||||
* @param {object} params parameters, as per
|
||||
* {@link module:crypto-algorithms/base.EncryptionAlgorithm}
|
||||
*/
|
||||
function OlmEncryption(deviceId, crypto, olmDevice) {
|
||||
base.EncryptionAlgorithm.call(this, deviceId, crypto, olmDevice);
|
||||
function OlmEncryption(params) {
|
||||
base.EncryptionAlgorithm.call(this, params);
|
||||
}
|
||||
utils.inherits(OlmEncryption, base.EncryptionAlgorithm);
|
||||
|
||||
@@ -58,7 +56,7 @@ OlmEncryption.prototype.initRoomEncryption = function(roomMembers) {
|
||||
/**
|
||||
* @inheritdoc
|
||||
*
|
||||
* @param {module:models/room} room
|
||||
* @param {module:models/room?} room
|
||||
* @param {string} eventType
|
||||
* @param {object} plaintext event content
|
||||
*
|
||||
@@ -138,14 +136,11 @@ OlmEncryption.prototype.encryptMessage = function(room, eventType, content) {
|
||||
*
|
||||
* @constructor
|
||||
* @extends {module:crypto-algorithms/base.DecryptionAlgorithm}
|
||||
*
|
||||
* @param {string} deviceId The identifier for this device.
|
||||
* @param {module:crypto} crypto crypto core
|
||||
* @param {module:OlmDevice} olmDevice olm.js wrapper
|
||||
*
|
||||
* @param {object} params parameters, as per
|
||||
* {@link module:crypto-algorithms/base.DecryptionAlgorithm}
|
||||
*/
|
||||
function OlmDecryption(deviceId, crypto, olmDevice) {
|
||||
base.DecryptionAlgorithm.call(this, deviceId, crypto, olmDevice);
|
||||
function OlmDecryption(params) {
|
||||
base.DecryptionAlgorithm.call(this, params);
|
||||
}
|
||||
utils.inherits(OlmDecryption, base.DecryptionAlgorithm);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user