You've already forked matrix-js-sdk
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:
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user