You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2026-01-03 23:22:30 +03:00
remove methods arg to requestVerification(DM)
as it's easy to have this argument be out of sync from all the places this is called from the js-sdk. There is also little point, as you can already specify the methods a consumer of the js-sdk wants to provide through the verificationMethods option when creating the client object.
This commit is contained in:
@@ -448,7 +448,7 @@ describe("SAS verification", function() {
|
||||
});
|
||||
|
||||
const aliceRequest = await alice.client.requestVerificationDM(
|
||||
bob.client.getUserId(), "!room_id", [verificationMethods.SAS],
|
||||
bob.client.getUserId(), "!room_id",
|
||||
);
|
||||
await aliceRequest.waitFor(r => r.started);
|
||||
aliceVerifier = aliceRequest.verifier;
|
||||
|
||||
@@ -907,36 +907,32 @@ async function _setDeviceVerification(
|
||||
*
|
||||
* @param {string} userId the user to request verification with
|
||||
* @param {string} roomId the room to use for verification
|
||||
* @param {Array} methods array of verification methods to use. Defaults to
|
||||
* all known methods
|
||||
*
|
||||
* @returns {Promise<module:crypto/verification/request/VerificationRequest>} resolves to a VerificationRequest
|
||||
* when the request has been sent to the other party.
|
||||
*/
|
||||
MatrixClient.prototype.requestVerificationDM = function(userId, roomId, methods) {
|
||||
MatrixClient.prototype.requestVerificationDM = function(userId, roomId) {
|
||||
if (this._crypto === null) {
|
||||
throw new Error("End-to-end encryption disabled");
|
||||
}
|
||||
return this._crypto.requestVerificationDM(userId, roomId, methods);
|
||||
return this._crypto.requestVerificationDM(userId, roomId);
|
||||
};
|
||||
|
||||
/**
|
||||
* Request a key verification from another user.
|
||||
*
|
||||
* @param {string} userId the user to request verification with
|
||||
* @param {Array} methods array of verification methods to use. Defaults to
|
||||
* all known methods
|
||||
* @param {Array} devices array of device IDs to send requests to. Defaults to
|
||||
* all devices owned by the user
|
||||
*
|
||||
* @returns {Promise<module:crypto/verification/request/VerificationRequest>} resolves to a VerificationRequest
|
||||
* when the request has been sent to the other party.
|
||||
*/
|
||||
MatrixClient.prototype.requestVerification = function(userId, methods, devices) {
|
||||
MatrixClient.prototype.requestVerification = function(userId, devices) {
|
||||
if (this._crypto === null) {
|
||||
throw new Error("End-to-end encryption disabled");
|
||||
}
|
||||
return this._crypto.requestVerification(userId, methods, devices);
|
||||
return this._crypto.requestVerification(userId, devices);
|
||||
};
|
||||
|
||||
/**
|
||||
|
||||
@@ -1619,46 +1619,32 @@ Crypto.prototype.setDeviceVerification = async function(
|
||||
return deviceObj;
|
||||
};
|
||||
|
||||
Crypto.prototype.requestVerificationDM = function(userId, roomId, methods) {
|
||||
Crypto.prototype.requestVerificationDM = function(userId, roomId) {
|
||||
const channel = new InRoomChannel(this._baseApis, roomId, userId);
|
||||
return this._requestVerificationWithChannel(
|
||||
userId,
|
||||
methods,
|
||||
channel,
|
||||
this._inRoomVerificationRequests,
|
||||
);
|
||||
};
|
||||
|
||||
Crypto.prototype.requestVerification = function(userId, methods, devices) {
|
||||
Crypto.prototype.requestVerification = function(userId, devices) {
|
||||
if (!devices) {
|
||||
devices = Object.keys(this._deviceList.getRawStoredDevicesForUser(userId));
|
||||
}
|
||||
const channel = new ToDeviceChannel(this._baseApis, userId, devices);
|
||||
return this._requestVerificationWithChannel(
|
||||
userId,
|
||||
methods,
|
||||
channel,
|
||||
this._toDeviceVerificationRequests,
|
||||
);
|
||||
};
|
||||
|
||||
Crypto.prototype._requestVerificationWithChannel = async function(
|
||||
userId, methods, channel, requestsMap,
|
||||
userId, channel, requestsMap,
|
||||
) {
|
||||
let verificationMethods = this._verificationMethods;
|
||||
if (methods) {
|
||||
verificationMethods = methods.reduce((map, name) => {
|
||||
const method = this._verificationMethods.get(name);
|
||||
if (!method) {
|
||||
throw new Error(`Verification method ${name} is not supported.`);
|
||||
} else {
|
||||
map.set(name, method);
|
||||
}
|
||||
return map;
|
||||
}, new Map());
|
||||
}
|
||||
let request = new VerificationRequest(
|
||||
channel, verificationMethods, this._baseApis);
|
||||
channel, this._verificationMethods, this._baseApis);
|
||||
await request.sendRequest();
|
||||
// don't replace the request created by a racing remote echo
|
||||
const racingRequest = requestsMap.getRequestByChannel(channel);
|
||||
|
||||
Reference in New Issue
Block a user