You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-26 17:03:12 +03:00
Pass through function to discard megolm session
To make debugging crypto slightly faster
This commit is contained in:
@@ -702,6 +702,21 @@ MatrixClient.prototype.isRoomEncrypted = function(roomId) {
|
|||||||
return this._roomList.isRoomEncrypted(roomId);
|
return this._roomList.isRoomEncrypted(roomId);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Forces the current outbound group session to be discarded such
|
||||||
|
* that another one will be created next time an event is sent.
|
||||||
|
*
|
||||||
|
* @param roomId The ID of the room to discard the session for
|
||||||
|
*
|
||||||
|
* This should not normally be necessary.
|
||||||
|
*/
|
||||||
|
MatrixClient.prototype.forceDiscardSession = function(roomId) {
|
||||||
|
if (!this._crypto) {
|
||||||
|
throw new Error("End-to-End encryption disabled");
|
||||||
|
}
|
||||||
|
return this._crypto.forceDiscardSession(roomId);
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a list containing all of the room keys
|
* Get a list containing all of the room keys
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
/*
|
/*
|
||||||
Copyright 2015, 2016 OpenMarket Ltd
|
Copyright 2015, 2016 OpenMarket Ltd
|
||||||
|
Copyright 2018 New Vector Ltd
|
||||||
|
|
||||||
Licensed under the Apache License, Version 2.0 (the "License");
|
Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
you may not use this file except in compliance with the License.
|
you may not use this file except in compliance with the License.
|
||||||
@@ -496,6 +497,16 @@ MegolmEncryption.prototype.encryptMessage = function(room, eventType, content) {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Forces the current outbound group session to be discarded such
|
||||||
|
* that another one will be created next time an event is sent.
|
||||||
|
*
|
||||||
|
* This should not normally be necessary.
|
||||||
|
*/
|
||||||
|
MegolmEncryption.prototype.forceDiscardSession = function() {
|
||||||
|
this._setupPromise = this._setupPromise.then(() => null);
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Checks the devices we're about to send to and see if any are entirely
|
* Checks the devices we're about to send to and see if any are entirely
|
||||||
* unknown to the user. If so, warn the user, and mark them as known to
|
* unknown to the user. If so, warn the user, and mark them as known to
|
||||||
|
|||||||
@@ -621,6 +621,23 @@ Crypto.prototype.getEventSenderDeviceInfo = function(event) {
|
|||||||
return device;
|
return device;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Forces the current outbound group session to be discarded such
|
||||||
|
* that another one will be created next time an event is sent.
|
||||||
|
*
|
||||||
|
* @param roomId The ID of the room to discard the session for
|
||||||
|
*
|
||||||
|
* This should not normally be necessary.
|
||||||
|
*/
|
||||||
|
Crypto.prototype.forceDiscardSession = function(roomId) {
|
||||||
|
const alg = this._roomEncryptors[roomId];
|
||||||
|
if (alg === undefined) throw new Error("Room not encrypted");
|
||||||
|
if (alg.forceDiscardSession === undefined) {
|
||||||
|
throw new Error("Room encryption algorithm doesn't support session discarding");
|
||||||
|
}
|
||||||
|
alg.forceDiscardSession();
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Configure a room to use encryption (ie, save a flag in the sessionstore).
|
* Configure a room to use encryption (ie, save a flag in the sessionstore).
|
||||||
*
|
*
|
||||||
|
|||||||
Reference in New Issue
Block a user