mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2025-02-02 07:31:38 +01:00
Add more logging
This commit is contained in:
parent
8e08916502
commit
c08e136d25
@ -14,15 +14,14 @@ See the License for the specific language governing permissions and
|
|||||||
limitations under the License.
|
limitations under the License.
|
||||||
*/
|
*/
|
||||||
import {BaseSASVerificationStage} from "./BaseSASVerificationStage";
|
import {BaseSASVerificationStage} from "./BaseSASVerificationStage";
|
||||||
import {KEY_AGREEMENT_LIST, HASHES_LIST, MAC_LIST, SAS_LIST} from "./constants";
|
|
||||||
import {CancelTypes, VerificationEventTypes} from "../channel/types";
|
import {CancelTypes, VerificationEventTypes} from "../channel/types";
|
||||||
import type {ILogItem} from "../../../../logging/types";
|
import {KEY_AGREEMENT_LIST, HASHES_LIST, MAC_LIST, SAS_LIST} from "./constants";
|
||||||
import {SendAcceptVerificationStage} from "./SendAcceptVerificationStage";
|
import {SendAcceptVerificationStage} from "./SendAcceptVerificationStage";
|
||||||
import {SendKeyStage} from "./SendKeyStage";
|
import {SendKeyStage} from "./SendKeyStage";
|
||||||
|
import type {ILogItem} from "../../../../logging/types";
|
||||||
|
|
||||||
export class SelectVerificationMethodStage extends BaseSASVerificationStage {
|
export class SelectVerificationMethodStage extends BaseSASVerificationStage {
|
||||||
private hasSentStartMessage = false;
|
private hasSentStartMessage = false;
|
||||||
// should somehow emit something that tells the ui to hide the select option
|
|
||||||
private allowSelection = true;
|
private allowSelection = true;
|
||||||
|
|
||||||
async completeStage() {
|
async completeStage() {
|
||||||
@ -35,7 +34,7 @@ export class SelectVerificationMethodStage extends BaseSASVerificationStage {
|
|||||||
// We received the start message
|
// We received the start message
|
||||||
this.allowSelection = false;
|
this.allowSelection = false;
|
||||||
if (this.hasSentStartMessage) {
|
if (this.hasSentStartMessage) {
|
||||||
await this.resolveStartConflict();
|
await this.resolveStartConflict(log);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
this.channel.setStartMessage(this.channel.receivedMessages.get(VerificationEventTypes.Start));
|
this.channel.setStartMessage(this.channel.receivedMessages.get(VerificationEventTypes.Start));
|
||||||
@ -56,18 +55,30 @@ export class SelectVerificationMethodStage extends BaseSASVerificationStage {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private async resolveStartConflict() {
|
private async resolveStartConflict(log: ILogItem) {
|
||||||
const receivedStartMessage = this.channel.receivedMessages.get(VerificationEventTypes.Start);
|
await log.wrap("resolveStartConflict", async () => {
|
||||||
const sentStartMessage = this.channel.sentMessages.get(VerificationEventTypes.Start);
|
const receivedStartMessage = this.channel.receivedMessages.get(VerificationEventTypes.Start);
|
||||||
if (receivedStartMessage.content.method !== sentStartMessage.content.method) {
|
const sentStartMessage = this.channel.sentMessages.get(VerificationEventTypes.Start);
|
||||||
await this.channel.cancelVerification(CancelTypes.UnexpectedMessage);
|
if (receivedStartMessage.content.method !== sentStartMessage.content.method) {
|
||||||
return;
|
/**
|
||||||
}
|
* If the two m.key.verification.start messages do not specify the same verification method,
|
||||||
// In the case of conflict, the lexicographically smaller id wins
|
* then the verification should be cancelled with a code of m.unexpected_message.
|
||||||
const our = this.ourUserId === this.otherUserId ? this.ourUserDeviceId : this.ourUserId;
|
*/
|
||||||
const their = this.ourUserId === this.otherUserId ? this.otherUserDeviceId : this.otherUserId;
|
log.log({
|
||||||
const startMessageToUse = our < their ? sentStartMessage : receivedStartMessage;
|
l: "Methods don't match for the start messages",
|
||||||
this.channel.setStartMessage(startMessageToUse);
|
received: receivedStartMessage.content.method,
|
||||||
|
sent: sentStartMessage.content.method,
|
||||||
|
});
|
||||||
|
await this.channel.cancelVerification(CancelTypes.UnexpectedMessage);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// In the case of conflict, the lexicographically smaller id wins
|
||||||
|
const our = this.ourUserId === this.otherUserId ? this.ourUserDeviceId : this.ourUserId;
|
||||||
|
const their = this.ourUserId === this.otherUserId ? this.otherUserDeviceId : this.otherUserId;
|
||||||
|
const startMessageToUse = our < their ? sentStartMessage : receivedStartMessage;
|
||||||
|
log.log({ l: "Start message resolved", message: startMessageToUse, our, their })
|
||||||
|
this.channel.setStartMessage(startMessageToUse);
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async selectEmojiMethod(log: ILogItem) {
|
async selectEmojiMethod(log: ILogItem) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user