1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-12-02 17:02:31 +03:00

Merge branch 'matthew/warn-unknown-devices' into matthew/blacklist-unverified

This commit is contained in:
Richard van der Hoff
2017-01-26 13:25:10 +00:00
47 changed files with 504 additions and 413 deletions

View File

@@ -69,7 +69,7 @@ function Crypto(baseApis, eventEmitter, sessionStore, userId, deviceId) {
this._roomDecryptors = {};
this._supportedAlgorithms = utils.keys(
algorithms.DECRYPTION_CLASSES
algorithms.DECRYPTION_CLASSES,
);
// build our device keys: these will later be uploaded
@@ -82,7 +82,7 @@ function Crypto(baseApis, eventEmitter, sessionStore, userId, deviceId) {
this._globalBlacklistUnverifiedDevices = false;
let myDevices = this._sessionStore.getEndToEndDevicesForUser(
this._userId
this._userId,
);
if (!myDevices) {
@@ -98,11 +98,12 @@ function Crypto(baseApis, eventEmitter, sessionStore, userId, deviceId) {
keys: this._deviceKeys,
algorithms: this._supportedAlgorithms,
verified: DeviceVerification.VERIFIED,
known: true,
};
myDevices[this._deviceId] = deviceInfo;
this._sessionStore.storeEndToEndDevicesForUser(
this._userId, myDevices
this._userId, myDevices,
);
}
@@ -402,7 +403,7 @@ Crypto.prototype._doKeyDownloadForUsers = function(downloadUsers) {
});
this._baseApis.downloadKeysForUsers(
downloadUsers
downloadUsers,
).done(function(res) {
const dk = res.device_keys || {};
@@ -433,7 +434,7 @@ Crypto.prototype._doKeyDownloadForUsers = function(downloadUsers) {
}
_updateStoredDeviceKeysForUser(
self._olmDevice, userId, userStore, dk[userId]
self._olmDevice, userId, userStore, dk[userId],
);
// update the session store
@@ -446,7 +447,7 @@ Crypto.prototype._doKeyDownloadForUsers = function(downloadUsers) {
storage[deviceId] = userStore[deviceId].toStorage();
}
self._sessionStore.storeEndToEndDevicesForUser(
userId, storage
userId, storage,
);
deferMap[userId].resolve();
@@ -732,7 +733,7 @@ Crypto.prototype.setDeviceVerification = function(userId, deviceId, verified,
}
let knownStatus = dev.known;
if (known !== null) {
if (known !== null && known !== undefined) {
knownStatus = known;
}
@@ -796,7 +797,7 @@ Crypto.prototype.getEventSenderDeviceInfo = function(event) {
// identity key of the device which set up the Megolm session.
const device = this.getDeviceByIdentityKey(
event.getSender(), algorithm, sender_key
event.getSender(), algorithm, sender_key,
);
if (device === null) {
@@ -915,7 +916,7 @@ Crypto.prototype.ensureOlmSessionsForUsers = function(users) {
}
return olmlib.ensureOlmSessionsForDevices(
this._olmDevice, this._baseApis, devicesByUser
this._olmDevice, this._baseApis, devicesByUser,
);
};
@@ -940,13 +941,13 @@ Crypto.prototype.exportRoomKeys = function() {
this._sessionStore.getAllEndToEndInboundGroupSessionKeys().map(
(s) => {
const sess = this._olmDevice.exportInboundGroupSession(
s.senderKey, s.sessionId
s.senderKey, s.sessionId,
);
sess.algorithm = olmlib.MEGOLM_ALGORITHM;
return sess;
}
)
},
),
);
};
@@ -1001,7 +1002,7 @@ Crypto.prototype.encryptEventIfNeeded = function(event, room) {
throw new Error(
"Room was previously configured to use encryption, but is " +
"no longer. Perhaps the homeserver is hiding the " +
"configuration event."
"configuration event.",
);
}
return null;
@@ -1016,7 +1017,7 @@ Crypto.prototype.encryptEventIfNeeded = function(event, room) {
};
return alg.encryptMessage(
room, event.getType(), event.getContent()
room, event.getType(), event.getContent(),
).then(function(encryptedContent) {
event.makeEncrypted("m.room.encrypted", encryptedContent, myKeys);
});
@@ -1119,7 +1120,7 @@ Crypto.prototype._onInitialSyncCompleted = function(rooms) {
const self = this;
this._baseApis.sendToDevice(
"m.new_device", // OH HAI!
content
content,
).done(function() {
self._sessionStore.setDeviceAnnounced();
});
@@ -1227,7 +1228,7 @@ Crypto.prototype._flushNewDeviceRequests = function() {
users.map(function(u) {
r[u] = r[u].catch(function(e) {
console.error(
'Error updating device keys for user ' + u + ':', e
'Error updating device keys for user ' + u + ':', e,
);
// reinstate the pending flags on any users which failed; this will
@@ -1279,7 +1280,7 @@ Crypto.prototype._getRoomDecryptor = function(roomId, algorithm) {
const AlgClass = algorithms.DECRYPTION_CLASSES[algorithm];
if (!AlgClass) {
throw new algorithms.DecryptionError(
'Unknown encryption algorithm "' + algorithm + '".'
'Unknown encryption algorithm "' + algorithm + '".',
);
}
alg = new AlgClass({