You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-11-29 16:43:09 +03:00
Add debug methods to get the state of OlmSessions
I've been trying to track down issues with the OlmSessions getting out of sync between two devices. To help with this, add a method which can be used from the JS console to inspect the state of OlmSessions.
This commit is contained in:
@@ -488,6 +488,36 @@ Crypto.prototype.setDeviceVerification = function(userId, deviceId, verified, bl
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Get information on the active olm sessions with a user
|
||||
* <p>
|
||||
* Returns a map from device id to an object with keys 'deviceIdKey' (the
|
||||
* device's curve25519 identity key) and 'sessions' (an array of objects in the
|
||||
* same format as that returned by {@link module:OlmDevice#getSessionInfoForDevice}).
|
||||
* <p>
|
||||
* This method is provided for debugging purposes.
|
||||
*
|
||||
* @param {string} userId id of user to inspect
|
||||
*
|
||||
* @return {Object.<string, {deviceIdKey: string, sessions: object[]}>}
|
||||
*/
|
||||
Crypto.prototype.getOlmSessionsForUser = function(userId) {
|
||||
var devices = this.getStoredDevicesForUser(userId);
|
||||
var result = {};
|
||||
for (var j = 0; j < devices.length; ++j) {
|
||||
var device = devices[j];
|
||||
var deviceKey = device.getIdentityKey();
|
||||
var sessions = this._olmDevice.getSessionInfoForDevice(deviceKey);
|
||||
|
||||
result[device.deviceId] = {
|
||||
deviceIdKey: deviceKey,
|
||||
sessions: sessions,
|
||||
};
|
||||
}
|
||||
return result;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Identify a device by curve25519 identity key and determine its verification state
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user