1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-29 16:43:09 +03:00

Factor out a function for doing olm encryption

Make a library file with some constants and a function to pack olm-encrypted
events (which we are going to use from megolm)
This commit is contained in:
Richard van der Hoff
2016-08-19 16:52:04 +01:00
parent 4877edb79b
commit 0234410b43
5 changed files with 122 additions and 49 deletions

View File

@@ -24,10 +24,9 @@ limitations under the License.
var q = require("q");
var utils = require("../utils");
var olmlib = require("../olmlib");
var base = require("./base");
var MEGOLM_ALGORITHM = "m.megolm.v1.aes-sha2";
/**
* Megolm encryption implementation
*
@@ -114,7 +113,7 @@ MegolmEncryption.prototype.encryptMessage = function(room, eventType, content) {
);
var encryptedContent = {
algorithm: MEGOLM_ALGORITHM,
algorithm: olmlib.MEGOLM_ALGORITHM,
sender_key: self._olmDevice.deviceCurve25519Key,
body: ciphertext,
session_id: self._outboundSessionId,
@@ -171,4 +170,6 @@ MegolmDecryption.prototype.decryptEvent = function(event) {
}
};
base.registerAlgorithm(MEGOLM_ALGORITHM, MegolmEncryption, MegolmDecryption);
base.registerAlgorithm(
olmlib.MEGOLM_ALGORITHM, MegolmEncryption, MegolmDecryption
);