You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-08-18 05:42:00 +03:00
Return device key list in a stable order, add a check for the list in the tests
This commit is contained in:
@@ -267,8 +267,16 @@ MatrixClient.prototype.listDeviceKeys = function(userId) {
|
|||||||
var devices = this.sessionStore.getEndToEndDevicesForUser(userId);
|
var devices = this.sessionStore.getEndToEndDevicesForUser(userId);
|
||||||
var result = [];
|
var result = [];
|
||||||
if (devices) {
|
if (devices) {
|
||||||
for (var deviceId in devices) {
|
var deviceId;
|
||||||
|
var deviceIds = [];
|
||||||
|
for (deviceId in devices) {
|
||||||
if (devices.hasOwnProperty(deviceId)) {
|
if (devices.hasOwnProperty(deviceId)) {
|
||||||
|
deviceIds.push(deviceId);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
deviceIds.sort();
|
||||||
|
for (var i = 0; i < deviceIds.length; ++i) {
|
||||||
|
deviceId = deviceIds[i];
|
||||||
var device = devices[deviceId];
|
var device = devices[deviceId];
|
||||||
var ed25519Key = device.keys["ed25519:" + deviceId];
|
var ed25519Key = device.keys["ed25519:" + deviceId];
|
||||||
if (ed25519Key) {
|
if (ed25519Key) {
|
||||||
@@ -279,7 +287,6 @@ MatrixClient.prototype.listDeviceKeys = function(userId) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return result;
|
return result;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@@ -32,6 +32,7 @@ describe("MatrixClient crypto", function() {
|
|||||||
var bobOneTimeKeys;
|
var bobOneTimeKeys;
|
||||||
var bobDeviceKeys;
|
var bobDeviceKeys;
|
||||||
var bobDeviceCurve25519Key;
|
var bobDeviceCurve25519Key;
|
||||||
|
var bobDeviceEd25519Key;
|
||||||
var aliLocalStore;
|
var aliLocalStore;
|
||||||
var aliStorage;
|
var aliStorage;
|
||||||
var bobStorage;
|
var bobStorage;
|
||||||
@@ -101,6 +102,7 @@ describe("MatrixClient crypto", function() {
|
|||||||
expect(bobDeviceKeys).toBeDefined();
|
expect(bobDeviceKeys).toBeDefined();
|
||||||
expect(bobOneTimeKeys).toBeDefined();
|
expect(bobOneTimeKeys).toBeDefined();
|
||||||
bobDeviceCurve25519Key = bobDeviceKeys.keys["curve25519:bvcxz"];
|
bobDeviceCurve25519Key = bobDeviceKeys.keys["curve25519:bvcxz"];
|
||||||
|
bobDeviceEd25519Key = bobDeviceKeys.keys["ed25519:bvcxz"];
|
||||||
done();
|
done();
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -116,7 +118,12 @@ describe("MatrixClient crypto", function() {
|
|||||||
result[bobUserId] = bobKeys;
|
result[bobUserId] = bobKeys;
|
||||||
return {device_keys: result};
|
return {device_keys: result};
|
||||||
});
|
});
|
||||||
aliClient.downloadKeys([bobUserId]);
|
aliClient.downloadKeys([bobUserId]).then(function() {
|
||||||
|
expect(aliClient.listDeviceKeys(bobUserId)).toEqual([{
|
||||||
|
id: "bvcxz",
|
||||||
|
key: bobDeviceEd25519Key
|
||||||
|
}]);
|
||||||
|
});
|
||||||
httpBackend.flush().done(function() {
|
httpBackend.flush().done(function() {
|
||||||
var devices = aliStorage.getEndToEndDevicesForUser(bobUserId);
|
var devices = aliStorage.getEndToEndDevicesForUser(bobUserId);
|
||||||
expect(devices).toEqual(bobKeys);
|
expect(devices).toEqual(bobKeys);
|
||||||
|
Reference in New Issue
Block a user