From ae60c30ab88078e8d093ec4f899760442fdec99c Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Fri, 24 Mar 2023 20:27:11 +0530 Subject: [PATCH] VerificationEventTypes -> VerificationEventType --- src/fixtures/matrix/sas/events.ts | 20 +++++------ src/matrix/verification/CrossSigning.ts | 6 ++-- .../verification/SAS/SASVerification.ts | 14 ++++---- .../verification/SAS/channel/Channel.ts | 34 +++++++++---------- .../verification/SAS/channel/MockChannel.ts | 20 +++++------ src/matrix/verification/SAS/channel/types.ts | 2 +- .../SAS/stages/CalculateSASStage.ts | 8 ++--- .../stages/SelectVerificationMethodStage.ts | 16 ++++----- .../SAS/stages/SendAcceptVerificationStage.ts | 6 ++-- .../verification/SAS/stages/SendDoneStage.ts | 4 +-- .../verification/SAS/stages/SendKeyStage.ts | 6 ++-- .../verification/SAS/stages/SendMacStage.ts | 6 ++-- .../verification/SAS/stages/SendReadyStage.ts | 4 +-- .../stages/SendRequestVerificationStage.ts | 6 ++-- .../verification/SAS/stages/VerifyMacStage.ts | 6 ++-- 15 files changed, 79 insertions(+), 79 deletions(-) diff --git a/src/fixtures/matrix/sas/events.ts b/src/fixtures/matrix/sas/events.ts index 753a6e97..b3c8228f 100644 --- a/src/fixtures/matrix/sas/events.ts +++ b/src/fixtures/matrix/sas/events.ts @@ -10,7 +10,7 @@ accept -> key -> mac -> done */ -import {VerificationEventTypes} from "../../../matrix/verification/SAS/channel/types"; +import {VerificationEventType} from "../../../matrix/verification/SAS/channel/types"; function generateResponses(userId: string, deviceId: string, txnId: string) { const readyMessage = { @@ -125,7 +125,7 @@ export class SASFixtures { return this; } - fixtures(): Map { + fixtures(): Map { const responses = generateResponses(this.userId, this.deviceId, this.txnId); const array: any[] = []; const addToArray = (type) => array.push([type, responses[type]]); @@ -134,14 +134,14 @@ export class SASFixtures { const item = this.order[i]; switch (item) { case COMBINATIONS.YOU_SENT_REQUEST: - addToArray(VerificationEventTypes.Ready); + addToArray(VerificationEventType.Ready); break; case COMBINATIONS.THEY_SENT_START: { - addToArray(VerificationEventTypes.Start); + addToArray(VerificationEventType.Start); const nextItem = this.order[i+1]; if (nextItem === COMBINATIONS.YOU_SENT_START) { if (this._youWinConflict) { - addToArray(VerificationEventTypes.Accept); + addToArray(VerificationEventType.Accept); i = i + 2; continue; } @@ -152,7 +152,7 @@ export class SASFixtures { const nextItem = this.order[i+1] if (nextItem === COMBINATIONS.THEY_SENT_START) { if (this._youWinConflict) { - addToArray(VerificationEventTypes.Accept); + addToArray(VerificationEventType.Accept); } break; @@ -160,15 +160,15 @@ export class SASFixtures { if (this.order[i-1] === COMBINATIONS.THEY_SENT_START) { break; } - addToArray(VerificationEventTypes.Accept); + addToArray(VerificationEventType.Accept); break; } } i = i + 1; } - addToArray(VerificationEventTypes.Key); - addToArray(VerificationEventTypes.Mac); - addToArray(VerificationEventTypes.Done); + addToArray(VerificationEventType.Key); + addToArray(VerificationEventType.Mac); + addToArray(VerificationEventType.Done); return new Map(array); } } diff --git a/src/matrix/verification/CrossSigning.ts b/src/matrix/verification/CrossSigning.ts index 369487df..dee5053d 100644 --- a/src/matrix/verification/CrossSigning.ts +++ b/src/matrix/verification/CrossSigning.ts @@ -27,7 +27,7 @@ import type {ISignatures} from "./common"; import {SASVerification} from "./SAS/SASVerification"; import {ToDeviceChannel} from "./SAS/channel/Channel"; import type {DeviceMessageHandler} from "../DeviceMessageHandler.js"; -import {VerificationEventTypes} from "./SAS/channel/types"; +import {VerificationEventType} from "./SAS/channel/types"; type Olm = typeof OlmNamespace; @@ -80,8 +80,8 @@ export class CrossSigning { )) { return; } - if (unencryptedEvent.type === VerificationEventTypes.Request || - unencryptedEvent.type === VerificationEventTypes.Start) { + if (unencryptedEvent.type === VerificationEventType.Request || + unencryptedEvent.type === VerificationEventType.Start) { await this.platform.logger.run("Start verification from request", async (log) => { const sas = this.startVerification(unencryptedEvent.sender, unencryptedEvent, log); await sas?.start(); diff --git a/src/matrix/verification/SAS/SASVerification.ts b/src/matrix/verification/SAS/SASVerification.ts index e105f5b2..551d196f 100644 --- a/src/matrix/verification/SAS/SASVerification.ts +++ b/src/matrix/verification/SAS/SASVerification.ts @@ -21,7 +21,7 @@ import type {DeviceTracker} from "../../e2ee/DeviceTracker.js"; import type * as OlmNamespace from "@matrix-org/olm"; import {IChannel} from "./channel/Channel"; import {HomeServerApi} from "../../net/HomeServerApi"; -import {CancelReason, VerificationEventTypes} from "./channel/types"; +import {CancelReason, VerificationEventType} from "./channel/types"; import {SendReadyStage} from "./stages/SendReadyStage"; import {SelectVerificationMethodStage} from "./stages/SelectVerificationMethodStage"; import {VerificationCancelledError} from "./VerificationCancelledError"; @@ -61,10 +61,10 @@ export class SASVerification extends EventEmitter { this.channel = channel; this.setupCancelAfterTimeout(clock); const stageOptions = {...options, olmSas, eventEmitter: this}; - if (channel.getReceivedMessage(VerificationEventTypes.Start)) { + if (channel.getReceivedMessage(VerificationEventType.Start)) { this.startStage = new SelectVerificationMethodStage(stageOptions); } - else if (channel.getReceivedMessage(VerificationEventTypes.Request)) { + else if (channel.getReceivedMessage(VerificationEventType.Request)) { this.startStage = new SendReadyStage(stageOptions); } else { @@ -283,7 +283,7 @@ export function tests() { const receivedMessages = new SASFixtures(theirUserId, theirDeviceId, txnId) .theySentStart() .fixtures(); - const startingMessage = receivedMessages.get(VerificationEventTypes.Start); + const startingMessage = receivedMessages.get(VerificationEventType.Start); const { sas } = await createSASRequest( ourUserId, ourDeviceId, @@ -404,7 +404,7 @@ export function tests() { .youSentStart() .theyWinConflict() .fixtures(); - const startingMessage = receivedMessages.get(VerificationEventTypes.Start); + const startingMessage = receivedMessages.get(VerificationEventType.Start); console.log(receivedMessages); const { sas } = await createSASRequest( ourUserId, @@ -445,7 +445,7 @@ export function tests() { .youSentStart() .youWinConflict() .fixtures(); - const startingMessage = receivedMessages.get(VerificationEventTypes.Start); + const startingMessage = receivedMessages.get(VerificationEventType.Start); console.log(receivedMessages); const { sas, logger } = await createSASRequest( ourUserId, @@ -600,7 +600,7 @@ export function tests() { .youSentRequest() .theySentStart() .fixtures(); - receivedMessages.get(VerificationEventTypes.Start).content.key_agreement_protocols = ["foo"]; + receivedMessages.get(VerificationEventType.Start).content.key_agreement_protocols = ["foo"]; const { sas } = await createSASRequest( ourUserId, ourDeviceId, diff --git a/src/matrix/verification/SAS/channel/Channel.ts b/src/matrix/verification/SAS/channel/Channel.ts index 700bd569..495352f3 100644 --- a/src/matrix/verification/SAS/channel/Channel.ts +++ b/src/matrix/verification/SAS/channel/Channel.ts @@ -20,7 +20,7 @@ import type {ILogItem} from "../../../../logging/types"; import type {Clock} from "../../../../platform/web/dom/Clock.js"; import type {DeviceMessageHandler} from "../../../DeviceMessageHandler.js"; import {makeTxnId} from "../../../common.js"; -import {CancelReason, VerificationEventTypes} from "./types"; +import {CancelReason, VerificationEventType} from "./types"; import {Disposables} from "../../../../utils/Disposables"; import {VerificationCancelledError} from "../VerificationCancelledError"; import {Deferred} from "../../../../utils/Deferred"; @@ -42,8 +42,8 @@ const messageFromErrorType = { export interface IChannel { send(eventType: string, content: any, log: ILogItem): Promise; waitForEvent(eventType: string): Promise; - getSentMessage(event: VerificationEventTypes): any; - getReceivedMessage(event: VerificationEventTypes): any; + getSentMessage(event: VerificationEventType): any; + getReceivedMessage(event: VerificationEventType): any; setStartMessage(content: any): void; cancelVerification(cancellationType: CancelReason): Promise; acceptMessage: any; @@ -70,8 +70,8 @@ export class ToDeviceChannel extends Disposables implements IChannel { private readonly otherUserId: string; private readonly clock: Clock; private readonly deviceMessageHandler: DeviceMessageHandler; - private readonly sentMessages: Map = new Map(); - private readonly receivedMessages: Map = new Map(); + private readonly sentMessages: Map = new Map(); + private readonly receivedMessages: Map = new Map(); private readonly waitMap: Map> = new Map(); private readonly log: ILogItem; public otherUserDeviceId: string; @@ -120,12 +120,12 @@ export class ToDeviceChannel extends Disposables implements IChannel { return this._isCancelled; } - async send(eventType: VerificationEventTypes, content: any, log: ILogItem): Promise { + async send(eventType: VerificationEventType, content: any, log: ILogItem): Promise { await log.wrap("ToDeviceChannel.send", async () => { if (this.isCancelled) { throw new VerificationCancelledError(); } - if (eventType === VerificationEventTypes.Request) { + if (eventType === VerificationEventType.Request) { // Handle this case specially await this.handleRequestEventSpecially(eventType, content, log); return; @@ -143,7 +143,7 @@ export class ToDeviceChannel extends Disposables implements IChannel { }); } - private async handleRequestEventSpecially(eventType: VerificationEventTypes, content: any, log: ILogItem) { + private async handleRequestEventSpecially(eventType: VerificationEventType, content: any, log: ILogItem) { await log.wrap("ToDeviceChannel.handleRequestEventSpecially", async () => { const timestamp = this.clock.now(); const txnId = makeTxnId(); @@ -161,17 +161,17 @@ export class ToDeviceChannel extends Disposables implements IChannel { }); } - getReceivedMessage(event: VerificationEventTypes) { + getReceivedMessage(event: VerificationEventType) { return this.receivedMessages.get(event); } - getSentMessage(event: VerificationEventTypes) { + getSentMessage(event: VerificationEventType) { return this.sentMessages.get(event); } get acceptMessage(): any { - return this.receivedMessages.get(VerificationEventTypes.Accept) ?? - this.sentMessages.get(VerificationEventTypes.Accept); + return this.receivedMessages.get(VerificationEventType.Accept) ?? + this.sentMessages.get(VerificationEventType.Accept); } @@ -194,11 +194,11 @@ export class ToDeviceChannel extends Disposables implements IChannel { log.log({ l: "event", event }); this.resolveAnyWaits(event); this.receivedMessages.set(event.type, event); - if (event.type === VerificationEventTypes.Ready) { + if (event.type === VerificationEventType.Ready) { this.handleReadyMessage(event, log); return; } - if (event.type === VerificationEventTypes.Cancel) { + if (event.type === VerificationEventType.Cancel) { this._isCancelled = true; this.dispose(); return; @@ -223,7 +223,7 @@ export class ToDeviceChannel extends Disposables implements IChannel { [this.otherUserId]: deviceMessages } } - await this.hsApi.sendToDevice(VerificationEventTypes.Cancel, payload, makeTxnId(), { log }).response(); + await this.hsApi.sendToDevice(VerificationEventType.Cancel, payload, makeTxnId(), { log }).response(); } async cancelVerification(cancellationType: CancelReason) { @@ -242,7 +242,7 @@ export class ToDeviceChannel extends Disposables implements IChannel { } } } - await this.hsApi.sendToDevice(VerificationEventTypes.Cancel, payload, makeTxnId(), { log }).response(); + await this.hsApi.sendToDevice(VerificationEventType.Cancel, payload, makeTxnId(), { log }).response(); this._isCancelled = true; this.dispose(); }); @@ -257,7 +257,7 @@ export class ToDeviceChannel extends Disposables implements IChannel { } } - waitForEvent(eventType: VerificationEventTypes): Promise { + waitForEvent(eventType: VerificationEventType): Promise { if (this._isCancelled) { throw new VerificationCancelledError(); } diff --git a/src/matrix/verification/SAS/channel/MockChannel.ts b/src/matrix/verification/SAS/channel/MockChannel.ts index bb516627..6f707790 100644 --- a/src/matrix/verification/SAS/channel/MockChannel.ts +++ b/src/matrix/verification/SAS/channel/MockChannel.ts @@ -2,7 +2,7 @@ import type {ILogItem} from "../../../../lib"; import {createCalculateMAC} from "../mac"; import {VerificationCancelledError} from "../VerificationCancelledError"; import {IChannel} from "./Channel"; -import {CancelReason, VerificationEventTypes} from "./types"; +import {CancelReason, VerificationEventType} from "./types"; import anotherjson from "another-json"; interface ITestChannel extends IChannel { @@ -29,7 +29,7 @@ export class MockChannel implements ITestChannel { startingMessage?: any, ) { if (startingMessage) { - const eventType = startingMessage.content.method ? VerificationEventTypes.Start : VerificationEventTypes.Request; + const eventType = startingMessage.content.method ? VerificationEventType.Start : VerificationEventType.Request; this.id = startingMessage.content.transaction_id; this.receivedMessages.set(eventType, startingMessage); } @@ -54,10 +54,10 @@ export class MockChannel implements ITestChannel { else { await new Promise(() => {}); } - if (eventType === VerificationEventTypes.Mac) { + if (eventType === VerificationEventType.Mac) { await this.recalculateMAC(); } - if(eventType === VerificationEventTypes.Accept && this.startMessage) { + if(eventType === VerificationEventType.Accept && this.startMessage) { } return event; } @@ -68,7 +68,7 @@ export class MockChannel implements ITestChannel { return; } const {content} = this.startMessage; - const {content: keyMessage} = this.fixtures.get(VerificationEventTypes.Key); + const {content: keyMessage} = this.fixtures.get(VerificationEventType.Key); const key = keyMessage.key; const commitmentStr = key + anotherjson.stringify(content); const olmUtil = new this.olm.Utility(); @@ -86,7 +86,7 @@ export class MockChannel implements ITestChannel { this.ourUserId + this.ourUserDeviceId + this.id; - const { content: macContent } = this.receivedMessages.get(VerificationEventTypes.Mac); + const { content: macContent } = this.receivedMessages.get(VerificationEventType.Mac); const macMethod = this.acceptMessage.content.message_authentication_code; const calculateMac = createCalculateMAC(this.olmSas, macMethod); const input = Object.keys(macContent.mac).sort().join(","); @@ -117,15 +117,15 @@ export class MockChannel implements ITestChannel { } get acceptMessage(): any { - return this.receivedMessages.get(VerificationEventTypes.Accept) ?? - this.sentMessages.get(VerificationEventTypes.Accept); + return this.receivedMessages.get(VerificationEventType.Accept) ?? + this.sentMessages.get(VerificationEventType.Accept); } - getReceivedMessage(event: VerificationEventTypes) { + getReceivedMessage(event: VerificationEventType) { return this.receivedMessages.get(event); } - getSentMessage(event: VerificationEventTypes) { + getSentMessage(event: VerificationEventType) { return this.sentMessages.get(event); } diff --git a/src/matrix/verification/SAS/channel/types.ts b/src/matrix/verification/SAS/channel/types.ts index 400404b7..4a1483b7 100644 --- a/src/matrix/verification/SAS/channel/types.ts +++ b/src/matrix/verification/SAS/channel/types.ts @@ -1,4 +1,4 @@ -export const enum VerificationEventTypes { +export const enum VerificationEventType { Request = "m.key.verification.request", Ready = "m.key.verification.ready", Start = "m.key.verification.start", diff --git a/src/matrix/verification/SAS/stages/CalculateSASStage.ts b/src/matrix/verification/SAS/stages/CalculateSASStage.ts index fc509aea..d602d18d 100644 --- a/src/matrix/verification/SAS/stages/CalculateSASStage.ts +++ b/src/matrix/verification/SAS/stages/CalculateSASStage.ts @@ -15,7 +15,7 @@ limitations under the License. */ import anotherjson from "another-json"; import {BaseSASVerificationStage} from "./BaseSASVerificationStage"; -import {CancelReason, VerificationEventTypes} from "../channel/types"; +import {CancelReason, VerificationEventType} from "../channel/types"; import {generateEmojiSas} from "../generator"; import {ILogItem} from "../../../../logging/types"; import {SendMacStage} from "./SendMacStage"; @@ -82,8 +82,8 @@ export class CalculateSASStage extends BaseSASVerificationStage { async verifyHashCommitment(log: ILogItem) { return await log.wrap("CalculateSASStage.verifyHashCommitment", async () => { - const acceptMessage = this.channel.getReceivedMessage(VerificationEventTypes.Accept).content; - const keyMessage = this.channel.getReceivedMessage(VerificationEventTypes.Key).content; + const acceptMessage = this.channel.getReceivedMessage(VerificationEventType.Accept).content; + const keyMessage = this.channel.getReceivedMessage(VerificationEventType.Key).content; const commitmentStr = keyMessage.key + anotherjson.stringify(this.channel.startMessage.content); const receivedCommitment = acceptMessage.commitment; const hash = this.olmUtil.sha256(commitmentStr); @@ -136,7 +136,7 @@ export class CalculateSASStage extends BaseSASVerificationStage { } get theirKey(): string { - const {content} = this.channel.getReceivedMessage(VerificationEventTypes.Key); + const {content} = this.channel.getReceivedMessage(VerificationEventType.Key); return content.key; } } diff --git a/src/matrix/verification/SAS/stages/SelectVerificationMethodStage.ts b/src/matrix/verification/SAS/stages/SelectVerificationMethodStage.ts index f4cccfbf..da6099ee 100644 --- a/src/matrix/verification/SAS/stages/SelectVerificationMethodStage.ts +++ b/src/matrix/verification/SAS/stages/SelectVerificationMethodStage.ts @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ import {BaseSASVerificationStage} from "./BaseSASVerificationStage"; -import {CancelReason, VerificationEventTypes} from "../channel/types"; +import {CancelReason, VerificationEventType} from "../channel/types"; import {KEY_AGREEMENT_LIST, HASHES_LIST, MAC_LIST, SAS_LIST} from "./constants"; import {SendAcceptVerificationStage} from "./SendAcceptVerificationStage"; import {SendKeyStage} from "./SendKeyStage"; @@ -27,8 +27,8 @@ export class SelectVerificationMethodStage extends BaseSASVerificationStage { async completeStage() { await this.log.wrap("SelectVerificationMethodStage.completeStage", async (log) => { this.eventEmitter.emit("SelectVerificationStage", this); - const startMessage = this.channel.waitForEvent(VerificationEventTypes.Start); - const acceptMessage = this.channel.waitForEvent(VerificationEventTypes.Accept); + const startMessage = this.channel.waitForEvent(VerificationEventType.Start); + const acceptMessage = this.channel.waitForEvent(VerificationEventType.Accept); const { content } = await Promise.race([startMessage, acceptMessage]); if (content.method) { // We received the start message @@ -37,12 +37,12 @@ export class SelectVerificationMethodStage extends BaseSASVerificationStage { await this.resolveStartConflict(log); } else { - this.channel.setStartMessage(this.channel.getReceivedMessage(VerificationEventTypes.Start)); + this.channel.setStartMessage(this.channel.getReceivedMessage(VerificationEventType.Start)); } } else { // We received the accept message - this.channel.setStartMessage(this.channel.getSentMessage(VerificationEventTypes.Start)); + this.channel.setStartMessage(this.channel.getSentMessage(VerificationEventType.Start)); } if (this.channel.initiatedByUs) { await acceptMessage; @@ -57,8 +57,8 @@ export class SelectVerificationMethodStage extends BaseSASVerificationStage { private async resolveStartConflict(log: ILogItem) { await log.wrap("resolveStartConflict", async () => { - const receivedStartMessage = this.channel.getReceivedMessage(VerificationEventTypes.Start); - const sentStartMessage = this.channel.getSentMessage(VerificationEventTypes.Start); + const receivedStartMessage = this.channel.getReceivedMessage(VerificationEventType.Start); + const sentStartMessage = this.channel.getSentMessage(VerificationEventType.Start); if (receivedStartMessage.content.method !== sentStartMessage.content.method) { /** * If the two m.key.verification.start messages do not specify the same verification method, @@ -96,7 +96,7 @@ export class SelectVerificationMethodStage extends BaseSASVerificationStage { * This will cause the Promise.race in completeStage() to resolve and we'll move * to the next stage (where we will send the key). */ - await this.channel.send(VerificationEventTypes.Start, content, log); + await this.channel.send(VerificationEventType.Start, content, log); this.hasSentStartMessage = true; } } diff --git a/src/matrix/verification/SAS/stages/SendAcceptVerificationStage.ts b/src/matrix/verification/SAS/stages/SendAcceptVerificationStage.ts index c69d41df..1606a53f 100644 --- a/src/matrix/verification/SAS/stages/SendAcceptVerificationStage.ts +++ b/src/matrix/verification/SAS/stages/SendAcceptVerificationStage.ts @@ -16,7 +16,7 @@ limitations under the License. import anotherjson from "another-json"; import {BaseSASVerificationStage} from "./BaseSASVerificationStage"; import {HASHES_LIST, MAC_LIST, SAS_SET, KEY_AGREEMENT_LIST} from "./constants"; -import {CancelReason, VerificationEventTypes} from "../channel/types"; +import {CancelReason, VerificationEventType} from "../channel/types"; import {SendKeyStage} from "./SendKeyStage"; // from element-web @@ -45,8 +45,8 @@ export class SendAcceptVerificationStage extends BaseSASVerificationStage { short_authentication_string: sasMethod, commitment: this.olmUtil.sha256(commitmentStr), }; - await this.channel.send(VerificationEventTypes.Accept, content, log); - await this.channel.waitForEvent(VerificationEventTypes.Key); + await this.channel.send(VerificationEventType.Accept, content, log); + await this.channel.waitForEvent(VerificationEventType.Key); this.setNextStage(new SendKeyStage(this.options)); }); } diff --git a/src/matrix/verification/SAS/stages/SendDoneStage.ts b/src/matrix/verification/SAS/stages/SendDoneStage.ts index 915a697a..2d3195b1 100644 --- a/src/matrix/verification/SAS/stages/SendDoneStage.ts +++ b/src/matrix/verification/SAS/stages/SendDoneStage.ts @@ -14,12 +14,12 @@ See the License for the specific language governing permissions and limitations under the License. */ import {BaseSASVerificationStage} from "./BaseSASVerificationStage"; -import {VerificationEventTypes} from "../channel/types"; +import {VerificationEventType} from "../channel/types"; export class SendDoneStage extends BaseSASVerificationStage { async completeStage() { await this.log.wrap("SendDoneStage.completeStage", async (log) => { - await this.channel.send(VerificationEventTypes.Done, {}, log); + await this.channel.send(VerificationEventType.Done, {}, log); }); } } diff --git a/src/matrix/verification/SAS/stages/SendKeyStage.ts b/src/matrix/verification/SAS/stages/SendKeyStage.ts index 0e00890b..4f9f45de 100644 --- a/src/matrix/verification/SAS/stages/SendKeyStage.ts +++ b/src/matrix/verification/SAS/stages/SendKeyStage.ts @@ -14,21 +14,21 @@ See the License for the specific language governing permissions and limitations under the License. */ import {BaseSASVerificationStage} from "./BaseSASVerificationStage"; -import {VerificationEventTypes} from "../channel/types"; +import {VerificationEventType} from "../channel/types"; import {CalculateSASStage} from "./CalculateSASStage"; export class SendKeyStage extends BaseSASVerificationStage { async completeStage() { await this.log.wrap("SendKeyStage.completeStage", async (log) => { const ourSasKey = this.olmSAS.get_pubkey(); - await this.channel.send(VerificationEventTypes.Key, {key: ourSasKey}, log); + await this.channel.send(VerificationEventType.Key, {key: ourSasKey}, log); /** * We may have already got the key in SendAcceptVerificationStage, * in which case waitForEvent will return a resolved promise with * that content. Otherwise, waitForEvent will actually wait for the * key message. */ - await this.channel.waitForEvent(VerificationEventTypes.Key); + await this.channel.waitForEvent(VerificationEventType.Key); this.setNextStage(new CalculateSASStage(this.options)); }); } diff --git a/src/matrix/verification/SAS/stages/SendMacStage.ts b/src/matrix/verification/SAS/stages/SendMacStage.ts index e80df19f..b8b39780 100644 --- a/src/matrix/verification/SAS/stages/SendMacStage.ts +++ b/src/matrix/verification/SAS/stages/SendMacStage.ts @@ -15,7 +15,7 @@ limitations under the License. */ import {BaseSASVerificationStage} from "./BaseSASVerificationStage"; import {ILogItem} from "../../../../logging/types"; -import {VerificationEventTypes} from "../channel/types"; +import {VerificationEventType} from "../channel/types"; import {createCalculateMAC} from "../mac"; import {VerifyMacStage} from "./VerifyMacStage"; @@ -26,7 +26,7 @@ export class SendMacStage extends BaseSASVerificationStage { const macMethod = acceptMessage.message_authentication_code; const calculateMAC = createCalculateMAC(this.olmSAS, macMethod); await this.sendMAC(calculateMAC, log); - await this.channel.waitForEvent(VerificationEventTypes.Mac); + await this.channel.waitForEvent(VerificationEventType.Mac); this.setNextStage(new VerifyMacStage(this.options)); }); } @@ -55,7 +55,7 @@ export class SendMacStage extends BaseSASVerificationStage { } const keys = calculateMAC(keyList.sort().join(","), baseInfo + "KEY_IDS"); - await this.channel.send(VerificationEventTypes.Mac, { mac, keys }, log); + await this.channel.send(VerificationEventType.Mac, { mac, keys }, log); } } diff --git a/src/matrix/verification/SAS/stages/SendReadyStage.ts b/src/matrix/verification/SAS/stages/SendReadyStage.ts index 78a2448c..c4fc0cc6 100644 --- a/src/matrix/verification/SAS/stages/SendReadyStage.ts +++ b/src/matrix/verification/SAS/stages/SendReadyStage.ts @@ -14,7 +14,7 @@ See the License for the specific language governing permissions and limitations under the License. */ import {BaseSASVerificationStage} from "./BaseSASVerificationStage"; -import {VerificationEventTypes} from "../channel/types"; +import {VerificationEventType} from "../channel/types"; import {SelectVerificationMethodStage} from "./SelectVerificationMethodStage"; export class SendReadyStage extends BaseSASVerificationStage { @@ -24,7 +24,7 @@ export class SendReadyStage extends BaseSASVerificationStage { "from_device": this.ourUserDeviceId, "methods": ["m.sas.v1"], }; - await this.channel.send(VerificationEventTypes.Ready, content, log); + await this.channel.send(VerificationEventType.Ready, content, log); this.setNextStage(new SelectVerificationMethodStage(this.options)); }); } diff --git a/src/matrix/verification/SAS/stages/SendRequestVerificationStage.ts b/src/matrix/verification/SAS/stages/SendRequestVerificationStage.ts index f3ea42b0..73c8019e 100644 --- a/src/matrix/verification/SAS/stages/SendRequestVerificationStage.ts +++ b/src/matrix/verification/SAS/stages/SendRequestVerificationStage.ts @@ -15,7 +15,7 @@ limitations under the License. */ import {BaseSASVerificationStage} from "./BaseSASVerificationStage"; import {SelectVerificationMethodStage} from "./SelectVerificationMethodStage"; -import {VerificationEventTypes} from "../channel/types"; +import {VerificationEventType} from "../channel/types"; export class SendRequestVerificationStage extends BaseSASVerificationStage { async completeStage() { @@ -24,9 +24,9 @@ export class SendRequestVerificationStage extends BaseSASVerificationStage { "from_device": this.ourUserDeviceId, "methods": ["m.sas.v1"], }; - await this.channel.send(VerificationEventTypes.Request, content, log); + await this.channel.send(VerificationEventType.Request, content, log); this.setNextStage(new SelectVerificationMethodStage(this.options)); - await this.channel.waitForEvent(VerificationEventTypes.Ready); + await this.channel.waitForEvent(VerificationEventType.Ready); }); } } diff --git a/src/matrix/verification/SAS/stages/VerifyMacStage.ts b/src/matrix/verification/SAS/stages/VerifyMacStage.ts index 8366abfc..e19f695a 100644 --- a/src/matrix/verification/SAS/stages/VerifyMacStage.ts +++ b/src/matrix/verification/SAS/stages/VerifyMacStage.ts @@ -15,7 +15,7 @@ limitations under the License. */ import {BaseSASVerificationStage} from "./BaseSASVerificationStage"; import {ILogItem} from "../../../../logging/types"; -import {CancelReason, VerificationEventTypes} from "../channel/types"; +import {CancelReason, VerificationEventType} from "../channel/types"; import {createCalculateMAC} from "../mac"; import {SendDoneStage} from "./SendDoneStage"; @@ -28,13 +28,13 @@ export class VerifyMacStage extends BaseSASVerificationStage { const macMethod = acceptMessage.message_authentication_code; const calculateMAC = createCalculateMAC(this.olmSAS, macMethod); await this.checkMAC(calculateMAC, log); - await this.channel.waitForEvent(VerificationEventTypes.Done); + await this.channel.waitForEvent(VerificationEventType.Done); this.setNextStage(new SendDoneStage(this.options)); }); } private async checkMAC(calculateMAC: (input: string, info: string) => string, log: ILogItem): Promise { - const {content} = this.channel.getReceivedMessage(VerificationEventTypes.Mac); + const {content} = this.channel.getReceivedMessage(VerificationEventType.Mac); const baseInfo = "MATRIX_KEY_VERIFICATION_MAC" + this.otherUserId +