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

Verify all the things

This commit is contained in:
Travis Ralston
2020-01-30 11:10:03 +00:00
parent 5fbaa9cfa7
commit 769bfeb10f

View File

@@ -77,10 +77,30 @@ export class ReciprocateQRCode extends Base {
const masterKey = xsignInfo.getId("master");
const masterKeyId = `ed25519:${masterKey}`;
await this._verifyKeys(this.userId, {[masterKeyId]:masterKey}, (keyId, device, keyInfo) => {
console.log({keyId, device, keyInfo});
if (keyId !== masterKeyId) {
if (keyInfo !== masterKey) {
console.error("key ID from key info does not match");
throw newKeyMismatchError();
}
if (keyId !== masterKeyId) {
console.error("key id doesn't match");
throw newKeyMismatchError();
}
if (device.deviceId !== masterKey) {
console.error("master key does not match device ID");
throw newKeyMismatchError();
}
for (const deviceKeyId in device.keys) {
if (deviceKeyId !== masterKeyId) {
console.error("device key ID does not match");
throw newKeyMismatchError();
}
if (device.keys[deviceKeyId] !== masterKey) {
console.error("master key does not match");
throw newKeyMismatchError();
}
}
// Otherwise it is probably fine
});
}
}