1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-26 17:03:12 +03:00

ask the user if the other user scanned the QR code

This commit is contained in:
Bruno Windels
2020-03-31 15:09:14 +02:00
parent b30f278e03
commit 2c54b8d77e

View File

@@ -49,6 +49,7 @@ export class ReciprocateQRCode extends Base {
"with this method yet."); "with this method yet.");
} }
// 1. check the secret
if (this.startEvent.getContent()['secret'] !== this.request.encodedSharedSecret) { if (this.startEvent.getContent()['secret'] !== this.request.encodedSharedSecret) {
throw newKeyMismatchError(); throw newKeyMismatchError();
} }
@@ -64,6 +65,13 @@ export class ReciprocateQRCode extends Base {
const devices = (await this._baseApis.getStoredDevicesForUser(this.userId)) || []; const devices = (await this._baseApis.getStoredDevicesForUser(this.userId)) || [];
const targetDevice = devices.find(d => { const targetDevice = devices.find(d => {
return d.deviceId === this.request.targetDevice.deviceId; return d.deviceId === this.request.targetDevice.deviceId;
// 2. ask if other user shows shield as well
await new Promise((resolve, reject) => {
this.reciprocateQREvent = {
confirm: resolve,
cancel: reject, // which code should we cancel with here?
};
this.emit("show_reciprocate_qr", this.reciprocateQREvent);
}); });
if (!targetDevice) throw new Error("Device not found, somehow"); if (!targetDevice) throw new Error("Device not found, somehow");
keys[`ed25519:${targetDevice.deviceId}`] = targetDevice.getFingerprint(); keys[`ed25519:${targetDevice.deviceId}`] = targetDevice.getFingerprint();