From 3e100ff5ec552494762b7c3a6274dabfcd78fa53 Mon Sep 17 00:00:00 2001 From: Bruno Windels Date: Tue, 8 Sep 2020 10:51:01 +0200 Subject: [PATCH] ensure /keys/query devices have the keys we need --- src/matrix/e2ee/DeviceTracker.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/matrix/e2ee/DeviceTracker.js b/src/matrix/e2ee/DeviceTracker.js index 0b4c73a2..6b6f3894 100644 --- a/src/matrix/e2ee/DeviceTracker.js +++ b/src/matrix/e2ee/DeviceTracker.js @@ -26,8 +26,8 @@ function deviceKeysAsDeviceIdentity(deviceSection) { return { userId, deviceId, - ed25519Key: deviceSection.keys?.[`ed25519:${deviceId}`], - curve25519Key: deviceSection.keys?.[`curve25519:${deviceId}`], + ed25519Key: deviceSection.keys[`ed25519:${deviceId}`], + curve25519Key: deviceSection.keys[`curve25519:${deviceId}`], algorithms: deviceSection.algorithms, displayName: deviceSection.unsigned?.device_display_name, }; @@ -200,6 +200,11 @@ export class DeviceTracker { if (deviceIdOnKeys !== deviceId) { return false; } + const ed25519Key = deviceKeys.keys?.[`ed25519:${deviceId}`]; + const curve25519Key = deviceKeys.keys?.[`curve25519:${deviceId}`]; + if (typeof ed25519Key !== "string" || typeof curve25519Key !== "string") { + return false; + } // don't store our own device if (userId === this._ownUserId && deviceId === this._ownDeviceId) { return false;