From 1c09f20778d5a9b2c4527860e4670eb264b6dc4a Mon Sep 17 00:00:00 2001 From: RMidhunSuresh Date: Fri, 24 Mar 2023 19:28:49 +0530 Subject: [PATCH] Pass device-id through options --- src/matrix/verification/CrossSigning.ts | 1 + src/matrix/verification/SAS/SASVerification.ts | 2 +- src/matrix/verification/SAS/channel/Channel.ts | 7 ++----- src/matrix/verification/SAS/channel/MockChannel.ts | 6 +----- 4 files changed, 5 insertions(+), 11 deletions(-) diff --git a/src/matrix/verification/CrossSigning.ts b/src/matrix/verification/CrossSigning.ts index b5af8b8d..369487df 100644 --- a/src/matrix/verification/CrossSigning.ts +++ b/src/matrix/verification/CrossSigning.ts @@ -151,6 +151,7 @@ export class CrossSigning { otherUserId: userId, clock: this.platform.clock, deviceMessageHandler: this.deviceMessageHandler, + ourUserDeviceId: this.deviceId, log }, startingMessage); diff --git a/src/matrix/verification/SAS/SASVerification.ts b/src/matrix/verification/SAS/SASVerification.ts index 355acd26..3831d413 100644 --- a/src/matrix/verification/SAS/SASVerification.ts +++ b/src/matrix/verification/SAS/SASVerification.ts @@ -59,7 +59,6 @@ export class SASVerification { const olmSas = new olm.SAS(); this.olmSas = olmSas; this.channel = channel; - this.channel.setOurDeviceId(options.ourUserDeviceId); this.setupCancelAfterTimeout(clock); const stageOptions = {...options, olmSas, eventEmitter: this.eventEmitter}; if (channel.getReceivedMessage(VerificationEventTypes.Start)) { @@ -163,6 +162,7 @@ export function tests() { theirDeviceId, theirUserId, ourUserId, + ourDeviceId, receivedMessages, deviceTracker, txnId, diff --git a/src/matrix/verification/SAS/channel/Channel.ts b/src/matrix/verification/SAS/channel/Channel.ts index 0fb2cb7c..35bd3842 100644 --- a/src/matrix/verification/SAS/channel/Channel.ts +++ b/src/matrix/verification/SAS/channel/Channel.ts @@ -44,7 +44,6 @@ export interface IChannel { getSentMessage(event: VerificationEventTypes): any; getReceivedMessage(event: VerificationEventTypes): any; setStartMessage(content: any): void; - setOurDeviceId(id: string): void; cancelVerification(cancellationType: CancelReason): Promise; acceptMessage: any; startMessage: any; @@ -60,6 +59,7 @@ type Options = { clock: Clock; deviceMessageHandler: DeviceMessageHandler; log: ILogItem; + ourUserDeviceId: string; } export class ToDeviceChannel extends Disposables implements IChannel { @@ -88,6 +88,7 @@ export class ToDeviceChannel extends Disposables implements IChannel { this.hsApi = options.hsApi; this.deviceTracker = options.deviceTracker; this.otherUserId = options.otherUserId; + this.ourDeviceId = options.ourUserDeviceId; this.clock = options.clock; this.log = options.log; this.deviceMessageHandler = options.deviceMessageHandler; @@ -279,10 +280,6 @@ export class ToDeviceChannel extends Disposables implements IChannel { return promise; } - setOurDeviceId(id: string) { - this.ourDeviceId = id; - } - setStartMessage(event) { this.startMessage = event; this._initiatedByUs = event.content.from_device === this.ourDeviceId; diff --git a/src/matrix/verification/SAS/channel/MockChannel.ts b/src/matrix/verification/SAS/channel/MockChannel.ts index a9cc4dea..bb516627 100644 --- a/src/matrix/verification/SAS/channel/MockChannel.ts +++ b/src/matrix/verification/SAS/channel/MockChannel.ts @@ -16,12 +16,12 @@ export class MockChannel implements ITestChannel { public startMessage: any; public isCancelled: boolean = false; private olmSas: any; - public ourUserDeviceId: string; constructor( public otherUserDeviceId: string, public otherUserId: string, public ourUserId: string, + public ourUserDeviceId: string, private fixtures: Map, private deviceTracker: any, public id: string, @@ -111,10 +111,6 @@ export class MockChannel implements ITestChannel { this.recalculateCommitment(); } - setOurDeviceId(id: string) { - this.ourUserDeviceId = id; - } - async cancelVerification(_: CancelReason): Promise { console.log("MockChannel.cancelVerification()"); this.isCancelled = true;