diff --git a/spec/unit/crypto/verification/sas.spec.js b/spec/unit/crypto/verification/sas.spec.js index d26ec3be2..89af121d4 100644 --- a/spec/unit/crypto/verification/sas.spec.js +++ b/spec/unit/crypto/verification/sas.spec.js @@ -27,6 +27,7 @@ import olmlib from '../../../../lib/crypto/olmlib'; import sdk from '../../../..'; import {verificationMethods} from '../../../../lib/crypto'; +import DeviceInfo from '../../../../lib/crypto/deviceinfo'; import SAS from '../../../../lib/crypto/verification/SAS'; @@ -393,11 +394,11 @@ describe("SAS verification", function() { }, ); - alice.setDeviceVerified = expect.createSpy(); - alice.getDeviceEd25519Key = () => { + alice.client.setDeviceVerified = expect.createSpy(); + alice.client.getDeviceEd25519Key = () => { return "alice+base64+ed25519+key"; }; - alice.getStoredDevice = () => { + alice.client.getStoredDevice = () => { return DeviceInfo.fromStorage( { keys: { @@ -407,12 +408,12 @@ describe("SAS verification", function() { "Dynabook", ); }; - alice.downloadKeys = () => { + alice.client.downloadKeys = () => { return Promise.resolve(); }; - bob.setDeviceVerified = expect.createSpy(); - bob.getStoredDevice = () => { + bob.client.setDeviceVerified = expect.createSpy(); + bob.client.getStoredDevice = () => { return DeviceInfo.fromStorage( { keys: { @@ -422,10 +423,10 @@ describe("SAS verification", function() { "Osborne2", ); }; - bob.getDeviceEd25519Key = () => { + bob.client.getDeviceEd25519Key = () => { return "bob+base64+ed25519+key"; }; - bob.downloadKeys = () => { + bob.client.downloadKeys = () => { return Promise.resolve(); }; @@ -433,13 +434,13 @@ describe("SAS verification", function() { bobSasEvent = null; bobPromise = new Promise((resolve, reject) => { - bob.on("event", async (event) => { + bob.client.on("event", async (event) => { const content = event.getContent(); if (event.getType() === "m.room.message" && content.msgtype === "m.key.verification.request") { expect(content.methods).toInclude(SAS.NAME); - expect(content.to).toBe(bob.getUserId()); - const verifier = bob.acceptVerificationDM(event, SAS.NAME); + expect(content.to).toBe(bob.client.getUserId()); + const verifier = bob.client.acceptVerificationDM(event, SAS.NAME); verifier.on("show_sas", (e) => { if (!e.sas.emoji || !e.sas.decimal) { e.cancel(); @@ -462,8 +463,8 @@ describe("SAS verification", function() { }); }); - aliceVerifier = await alice.requestVerificationDM( - bob.getUserId(), "!room_id", [verificationMethods.SAS], + aliceVerifier = await alice.client.requestVerificationDM( + bob.client.getUserId(), "!room_id", [verificationMethods.SAS], ); aliceVerifier.on("show_sas", (e) => { if (!e.sas.emoji || !e.sas.decimal) { @@ -490,10 +491,10 @@ describe("SAS verification", function() { ]); // make sure Alice and Bob verified each other - expect(alice.setDeviceVerified) - .toHaveBeenCalledWith(bob.getUserId(), bob.deviceId); - expect(bob.setDeviceVerified) - .toHaveBeenCalledWith(alice.getUserId(), alice.deviceId); + expect(alice.client.setDeviceVerified) + .toHaveBeenCalledWith(bob.client.getUserId(), bob.client.deviceId); + expect(bob.client.setDeviceVerified) + .toHaveBeenCalledWith(alice.client.getUserId(), alice.client.deviceId); }); }); }); diff --git a/spec/unit/crypto/verification/util.js b/spec/unit/crypto/verification/util.js index d12b0462a..4ffa30553 100644 --- a/spec/unit/crypto/verification/util.js +++ b/spec/unit/crypto/verification/util.js @@ -58,9 +58,9 @@ export async function makeTestClients(userInfos, options) { room_id: room, event_id: eventId, }); - for (const client of clients) { + for (const tc of clients) { setTimeout( - () => client.emit("event", event), + () => tc.client.emit("event", event), 0, ); } diff --git a/src/base-apis.js b/src/base-apis.js index 0e34d5e70..24dd0ada8 100644 --- a/src/base-apis.js +++ b/src/base-apis.js @@ -1719,9 +1719,11 @@ MatrixBaseApis.prototype.uploadKeysRequest = function(content, opts, callback) { }; MatrixBaseApis.prototype.uploadKeySignatures = function(content) { - return this._http.authedRequestWithPrefix( + return this._http.authedRequest( undefined, "POST", '/keys/signatures/upload', undefined, - content, httpApi.PREFIX_UNSTABLE, + content, { + prefix: httpApi.PREFIX_UNSTABLE, + }, ); }; @@ -1811,9 +1813,10 @@ MatrixBaseApis.prototype.getKeyChanges = function(oldToken, newToken) { MatrixBaseApis.prototype.uploadDeviceSigningKeys = function(auth, keys) { const data = Object.assign({}, keys, {auth}); - return this._http.authedRequestWithPrefix( - undefined, "POST", "/keys/device_signing/upload", undefined, data, - httpApi.PREFIX_UNSTABLE, + return this._http.authedRequest( + undefined, "POST", "/keys/device_signing/upload", undefined, data, { + prefix: httpApi.PREFIX_UNSTABLE, + }, ); };