You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-12-01 04:43:29 +03:00
Emit an event when a device is verified
We will probably want to share device verification across our own devices at some point, so this will be useful in the future.
This commit is contained in:
@@ -546,6 +546,8 @@ MatrixClient.prototype.listDeviceKeys = function(userId) {
|
||||
*
|
||||
* @param {string} userId owner of the device
|
||||
* @param {string} deviceId unique identifier for the device
|
||||
*
|
||||
* @fires module:client~event:MatrixClient"deviceVerified"
|
||||
*/
|
||||
MatrixClient.prototype.setDeviceVerified = function(userId, deviceId) {
|
||||
if (!this.sessionStore) {
|
||||
@@ -563,6 +565,8 @@ MatrixClient.prototype.setDeviceVerified = function(userId, deviceId) {
|
||||
}
|
||||
dev.verified = true;
|
||||
this.sessionStore.storeEndToEndDevicesForUser(userId, devices);
|
||||
|
||||
this.emit("deviceVerified", userId, deviceId, dev);
|
||||
};
|
||||
|
||||
|
||||
@@ -570,7 +574,9 @@ MatrixClient.prototype.setDeviceVerified = function(userId, deviceId) {
|
||||
* Check if the sender of an event is verified
|
||||
*
|
||||
* @param {MatrixEvent} event event to be checked
|
||||
* @return {boolean} true if the sender of this event has been verified
|
||||
*
|
||||
* @return {boolean} true if the sender of this event has been verified using
|
||||
* {@link module:client~MatrixClient#setDeviceVerified|setDeviceVerified}.
|
||||
*/
|
||||
MatrixClient.prototype.isEventSenderVerified = function(event) {
|
||||
if (!this.sessionStore) {
|
||||
@@ -3680,6 +3686,15 @@ module.exports.CRYPTO_ENABLED = CRYPTO_ENABLED;
|
||||
* });
|
||||
*/
|
||||
|
||||
/**
|
||||
* Fires when a device is marked as verified by {@link
|
||||
* module:client~MatrixClient#setDeviceVerified|MatrixClient.setDeviceVerified}.
|
||||
*
|
||||
* @event module:client~MatrixClient#"deviceVerified"
|
||||
* @param {string} userId the owner of the verified device
|
||||
* @param {module:client~DeviceInfo} device information about the verified device
|
||||
*/
|
||||
|
||||
// EventEmitter JSDocs
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user