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
MatrixClient.getStoredDevicesForUser
Implement MatrixClient.getStoredDevicesForUser which uses Crypto.getStoredDevicesForUser, which is more powerful than listDeviceKeys, and isn't deprecated. Also a couple of accessors for DeviceInfo.
This commit is contained in:
@@ -308,6 +308,8 @@ MatrixClient.prototype.downloadKeys = function(userIds, forceDownload) {
|
|||||||
/**
|
/**
|
||||||
* List the stored device keys for a user id
|
* List the stored device keys for a user id
|
||||||
*
|
*
|
||||||
|
* @deprecated prefer {@link module:client#getStoredDevicesForUser}
|
||||||
|
*
|
||||||
* @param {string} userId the user to list keys for.
|
* @param {string} userId the user to list keys for.
|
||||||
*
|
*
|
||||||
* @return {object[]} list of devices with "id", "verified", "blocked",
|
* @return {object[]} list of devices with "id", "verified", "blocked",
|
||||||
@@ -320,6 +322,22 @@ MatrixClient.prototype.listDeviceKeys = function(userId) {
|
|||||||
return this._crypto.listDeviceKeys(userId);
|
return this._crypto.listDeviceKeys(userId);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Get the stored device keys for a user id
|
||||||
|
*
|
||||||
|
* @param {string} userId the user to list keys for.
|
||||||
|
*
|
||||||
|
* @return {module:crypto-deviceinfo[]} list of devices
|
||||||
|
*/
|
||||||
|
MatrixClient.prototype.getStoredDevicesForUser = function(userId) {
|
||||||
|
if (this._crypto === null) {
|
||||||
|
throw new Error("End-to-end encryption disabled");
|
||||||
|
}
|
||||||
|
return this._crypto.getStoredDevicesForUser(userId);
|
||||||
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mark the given device as verified
|
* Mark the given device as verified
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -112,6 +112,24 @@ DeviceInfo.prototype.getDisplayname = function() {
|
|||||||
return this.unsigned.device_display_name || null;
|
return this.unsigned.device_display_name || null;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if this device is blocked
|
||||||
|
*
|
||||||
|
* @return {Boolean} true if blocked
|
||||||
|
*/
|
||||||
|
DeviceInfo.prototype.isBlocked = function() {
|
||||||
|
return this.verified == DeviceVerification.BLOCKED;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if this device is verified
|
||||||
|
*
|
||||||
|
* @return {Boolean} true if verified
|
||||||
|
*/
|
||||||
|
DeviceInfo.prototype.isVerified = function() {
|
||||||
|
return this.verified == DeviceVerification.VERIFIED;
|
||||||
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @enum
|
* @enum
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -385,8 +385,8 @@ Crypto.prototype.listDeviceKeys = function(userId) {
|
|||||||
result.push({
|
result.push({
|
||||||
id: device.deviceId,
|
id: device.deviceId,
|
||||||
key: ed25519Key,
|
key: ed25519Key,
|
||||||
verified: Boolean(device.verified == DeviceVerification.VERIFIED),
|
verified: Boolean(device.isVerified()),
|
||||||
blocked: Boolean(device.verified == DeviceVerification.BLOCKED),
|
blocked: Boolean(device.isBlocked()),
|
||||||
display_name: device.getDisplayname(),
|
display_name: device.getDisplayname(),
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user