You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-12-01 04:43:29 +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:
@@ -107,7 +107,7 @@ function OlmDevice(sessionStore) {
|
|||||||
// event and we don't consider it a replay attack.
|
// event and we don't consider it a replay attack.
|
||||||
//
|
//
|
||||||
// Keys are strings of form "<senderKey>|<session_id>|<message_index>"
|
// 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 = {};
|
this._inboundGroupSessionMessageIndexes = {};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -813,7 +813,6 @@ OlmDevice.prototype.decryptGroupMessage = async function(
|
|||||||
roomId, senderKey, sessionId, body, eventId, timestamp,
|
roomId, senderKey, sessionId, body, eventId, timestamp,
|
||||||
) {
|
) {
|
||||||
const self = this;
|
const self = this;
|
||||||
const argumentsLength = arguments.length;
|
|
||||||
|
|
||||||
function decrypt(session, sessionData) {
|
function decrypt(session, sessionData) {
|
||||||
const res = session.decrypt(body);
|
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
|
// and timestamp from the last time we used this message index, then we
|
||||||
// don't consider it a replay attack.
|
// don't consider it a replay attack.
|
||||||
const messageIndexKey = senderKey + "|" + sessionId + "|" + res.message_index;
|
const messageIndexKey = senderKey + "|" + sessionId + "|" + res.message_index;
|
||||||
if (messageIndexKey in self._inboundGroupSessionMessageIndexes
|
if (messageIndexKey in self._inboundGroupSessionMessageIndexes) {
|
||||||
&& (argumentsLength <= 4 // Compatibility for older old versions.
|
const msgInfo = self._inboundGroupSessionMessageIndexes[messageIndexKey];
|
||||||
|| self._inboundGroupSessionMessageIndexes[messageIndexKey].id !== eventId
|
if (msgInfo.id !== eventId || msgInfo.timestamp !== timestamp) {
|
||||||
|| self._inboundGroupSessionMessageIndexes[messageIndexKey].timestamp !== timestamp)) {
|
throw new Error(
|
||||||
throw new Error(
|
"Duplicate message index, possible replay attack: " +
|
||||||
"Duplicate message index, possible replay attack: " +
|
messageIndexKey,
|
||||||
messageIndexKey,
|
);
|
||||||
);
|
}
|
||||||
}
|
}
|
||||||
self._inboundGroupSessionMessageIndexes[messageIndexKey] = {
|
self._inboundGroupSessionMessageIndexes[messageIndexKey] = {
|
||||||
id: eventId,
|
id: eventId,
|
||||||
|
|||||||
Reference in New Issue
Block a user