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
Olm-related cleanups
A couple of small refactors which fell out of the aborted stuff for upgrading to secure Ed25519 keys, but are useful in their own right. The main functional change here is to calculate the "algorithms" list from DECRYPTION_CLASSES (and hence include megolm in the list).
This commit is contained in:
@@ -23,11 +23,10 @@ limitations under the License.
|
||||
var anotherjson = require('another-json');
|
||||
var q = require("q");
|
||||
|
||||
var utils = require("./utils");
|
||||
var OlmDevice = require("./OlmDevice");
|
||||
var olmlib = require("./olmlib");
|
||||
|
||||
var algorithms = require("./crypto-algorithms");
|
||||
|
||||
var DeviceInfo = require("./crypto-deviceinfo");
|
||||
var DeviceVerification = DeviceInfo.DeviceVerification;
|
||||
|
||||
@@ -58,6 +57,10 @@ function Crypto(baseApis, sessionStore, userId, deviceId) {
|
||||
// EncryptionAlgorithm instance for each room
|
||||
this._roomAlgorithms = {};
|
||||
|
||||
this._supportedAlgorithms = utils.keys(
|
||||
algorithms.DECRYPTION_CLASSES
|
||||
);
|
||||
|
||||
// build our device keys: these will later be uploaded
|
||||
this._deviceKeys = {};
|
||||
this._deviceKeys["ed25519:" + this._deviceId] =
|
||||
@@ -68,7 +71,7 @@ function Crypto(baseApis, sessionStore, userId, deviceId) {
|
||||
// add our own deviceinfo to the sessionstore
|
||||
var deviceInfo = {
|
||||
keys: this._deviceKeys,
|
||||
algorithms: [olmlib.OLM_ALGORITHM],
|
||||
algorithms: this._supportedAlgorithms,
|
||||
verified: DeviceVerification.VERIFIED,
|
||||
};
|
||||
var myDevices = this._sessionStore.getEndToEndDevicesForUser(
|
||||
@@ -121,7 +124,7 @@ function _uploadDeviceKeys(crypto) {
|
||||
var deviceId = crypto._deviceId;
|
||||
|
||||
var deviceKeys = {
|
||||
algorithms: [olmlib.OLM_ALGORITHM],
|
||||
algorithms: crypto._supportedAlgorithms,
|
||||
device_id: deviceId,
|
||||
keys: crypto._deviceKeys,
|
||||
user_id: userId,
|
||||
@@ -288,7 +291,7 @@ function _storeDeviceKeys(_olmDevice, userId, deviceId, userStore, deviceResult)
|
||||
return false;
|
||||
}
|
||||
|
||||
var unsigned = deviceResult.unsigned;
|
||||
var unsigned = deviceResult.unsigned || {};
|
||||
var signatures = deviceResult.signatures || {};
|
||||
var userSigs = signatures[userId] || {};
|
||||
var signature = userSigs[signKeyId];
|
||||
@@ -332,13 +335,12 @@ function _storeDeviceKeys(_olmDevice, userId, deviceId, userStore, deviceResult)
|
||||
userStore[deviceId] = deviceStore = new DeviceInfo(deviceId);
|
||||
}
|
||||
|
||||
deviceStore.keys = deviceResult.keys;
|
||||
deviceStore.algorithms = deviceResult.algorithms;
|
||||
deviceStore.keys = deviceResult.keys || {};
|
||||
deviceStore.algorithms = deviceResult.algorithms || [];
|
||||
deviceStore.unsigned = unsigned;
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Get the stored device keys for a user id
|
||||
*
|
||||
|
||||
Reference in New Issue
Block a user