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

fix lint error, and incorporate suggestions from richvdh and krombel

Signed-off-by: Hubert Chathi <hubert@uhoreg.ca>
This commit is contained in:
Hubert Chathi
2017-10-12 09:04:12 -04:00
parent 8f252992e4
commit dcab4eb70b

View File

@@ -107,7 +107,7 @@ function OlmDevice(sessionStore) {
// event and we don't consider it a replay attack.
//
// Keys are strings of form "<senderKey>|<session_id>|<message_index>"
// Values are objects containing the event ID and timestamp.
// Values are objects of the form "{id: <event id>, timestamp: <ts>}"
this._inboundGroupSessionMessageIndexes = {};
}
@@ -813,7 +813,6 @@ OlmDevice.prototype.decryptGroupMessage = async function(
roomId, senderKey, sessionId, body, eventId, timestamp,
) {
const self = this;
const argumentsLength = arguments.length;
function decrypt(session, sessionData) {
const res = session.decrypt(body);
@@ -828,14 +827,14 @@ OlmDevice.prototype.decryptGroupMessage = async function(
// and timestamp from the last time we used this message index, then we
// don't consider it a replay attack.
const messageIndexKey = senderKey + "|" + sessionId + "|" + res.message_index;
if (messageIndexKey in self._inboundGroupSessionMessageIndexes
&& (argumentsLength <= 4 // Compatibility for older old versions.
|| self._inboundGroupSessionMessageIndexes[messageIndexKey].id !== eventId
|| self._inboundGroupSessionMessageIndexes[messageIndexKey].timestamp !== timestamp)) {
throw new Error(
"Duplicate message index, possible replay attack: " +
messageIndexKey,
);
if (messageIndexKey in self._inboundGroupSessionMessageIndexes) {
const msgInfo = self._inboundGroupSessionMessageIndexes[messageIndexKey];
if (msgInfo.id !== eventId || msgInfo.timestamp !== timestamp) {
throw new Error(
"Duplicate message index, possible replay attack: " +
messageIndexKey,
);
}
}
self._inboundGroupSessionMessageIndexes[messageIndexKey] = {
id: eventId,