1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-12-07 05:22:15 +03:00

add methods for signing and checking users and devices with cross-signing

This commit is contained in:
Hubert Chathi
2019-05-03 18:05:36 -04:00
parent 32814d1833
commit ec2f07e1aa
5 changed files with 212 additions and 14 deletions

View File

@@ -762,6 +762,29 @@ MatrixClient.prototype.getGlobalBlacklistUnverifiedDevices = function() {
return this._crypto.getGlobalBlacklistUnverifiedDevices();
};
/**
* returns a function that just calls the corresponding function from this._crypto.
*
* @param {string} name the function to call
*
* @return {Function} a wrapper function
*/
function wrapCryptoFunc(name) {
return function(...args) {
if (!this._crypto) { // eslint-disable-line no-invalid-this
throw new Error("End-to-end encryption disabled");
}
return this._crypto[name](...args); // eslint-disable-line no-invalid-this
};
}
MatrixClient.prototype.checkUserTrust
= wrapCryptoFunc("checkUserTrust");
MatrixClient.prototype.checkDeviceTrust
= wrapCryptoFunc("checkDeviceTrust");
/**
* Get e2e information on the device that sent an event
*
@@ -793,6 +816,12 @@ MatrixClient.prototype.isEventSenderVerified = async function(event) {
return device.isVerified();
};
MatrixClient.prototype.resetCrossSigningKeys
= wrapCryptoFunc("resetCrossSigningKeys");
MatrixClient.prototype.setCrossSigningKeys
= wrapCryptoFunc("setCrossSigningKeys");
/**
* Cancel a room key request for this event if one is ongoing and resend the
* request.