Pass device-id through options

This commit is contained in:
RMidhunSuresh 2023-03-24 19:28:49 +05:30
parent 321775b800
commit 1c09f20778
4 changed files with 5 additions and 11 deletions

View File

@ -151,6 +151,7 @@ export class CrossSigning {
otherUserId: userId, otherUserId: userId,
clock: this.platform.clock, clock: this.platform.clock,
deviceMessageHandler: this.deviceMessageHandler, deviceMessageHandler: this.deviceMessageHandler,
ourUserDeviceId: this.deviceId,
log log
}, startingMessage); }, startingMessage);

View File

@ -59,7 +59,6 @@ export class SASVerification {
const olmSas = new olm.SAS(); const olmSas = new olm.SAS();
this.olmSas = olmSas; this.olmSas = olmSas;
this.channel = channel; this.channel = channel;
this.channel.setOurDeviceId(options.ourUserDeviceId);
this.setupCancelAfterTimeout(clock); this.setupCancelAfterTimeout(clock);
const stageOptions = {...options, olmSas, eventEmitter: this.eventEmitter}; const stageOptions = {...options, olmSas, eventEmitter: this.eventEmitter};
if (channel.getReceivedMessage(VerificationEventTypes.Start)) { if (channel.getReceivedMessage(VerificationEventTypes.Start)) {
@ -163,6 +162,7 @@ export function tests() {
theirDeviceId, theirDeviceId,
theirUserId, theirUserId,
ourUserId, ourUserId,
ourDeviceId,
receivedMessages, receivedMessages,
deviceTracker, deviceTracker,
txnId, txnId,

View File

@ -44,7 +44,6 @@ export interface IChannel {
getSentMessage(event: VerificationEventTypes): any; getSentMessage(event: VerificationEventTypes): any;
getReceivedMessage(event: VerificationEventTypes): any; getReceivedMessage(event: VerificationEventTypes): any;
setStartMessage(content: any): void; setStartMessage(content: any): void;
setOurDeviceId(id: string): void;
cancelVerification(cancellationType: CancelReason): Promise<void>; cancelVerification(cancellationType: CancelReason): Promise<void>;
acceptMessage: any; acceptMessage: any;
startMessage: any; startMessage: any;
@ -60,6 +59,7 @@ type Options = {
clock: Clock; clock: Clock;
deviceMessageHandler: DeviceMessageHandler; deviceMessageHandler: DeviceMessageHandler;
log: ILogItem; log: ILogItem;
ourUserDeviceId: string;
} }
export class ToDeviceChannel extends Disposables implements IChannel { export class ToDeviceChannel extends Disposables implements IChannel {
@ -88,6 +88,7 @@ export class ToDeviceChannel extends Disposables implements IChannel {
this.hsApi = options.hsApi; this.hsApi = options.hsApi;
this.deviceTracker = options.deviceTracker; this.deviceTracker = options.deviceTracker;
this.otherUserId = options.otherUserId; this.otherUserId = options.otherUserId;
this.ourDeviceId = options.ourUserDeviceId;
this.clock = options.clock; this.clock = options.clock;
this.log = options.log; this.log = options.log;
this.deviceMessageHandler = options.deviceMessageHandler; this.deviceMessageHandler = options.deviceMessageHandler;
@ -279,10 +280,6 @@ export class ToDeviceChannel extends Disposables implements IChannel {
return promise; return promise;
} }
setOurDeviceId(id: string) {
this.ourDeviceId = id;
}
setStartMessage(event) { setStartMessage(event) {
this.startMessage = event; this.startMessage = event;
this._initiatedByUs = event.content.from_device === this.ourDeviceId; this._initiatedByUs = event.content.from_device === this.ourDeviceId;

View File

@ -16,12 +16,12 @@ export class MockChannel implements ITestChannel {
public startMessage: any; public startMessage: any;
public isCancelled: boolean = false; public isCancelled: boolean = false;
private olmSas: any; private olmSas: any;
public ourUserDeviceId: string;
constructor( constructor(
public otherUserDeviceId: string, public otherUserDeviceId: string,
public otherUserId: string, public otherUserId: string,
public ourUserId: string, public ourUserId: string,
public ourUserDeviceId: string,
private fixtures: Map<string, any>, private fixtures: Map<string, any>,
private deviceTracker: any, private deviceTracker: any,
public id: string, public id: string,
@ -111,10 +111,6 @@ export class MockChannel implements ITestChannel {
this.recalculateCommitment(); this.recalculateCommitment();
} }
setOurDeviceId(id: string) {
this.ourUserDeviceId = id;
}
async cancelVerification(_: CancelReason): Promise<void> { async cancelVerification(_: CancelReason): Promise<void> {
console.log("MockChannel.cancelVerification()"); console.log("MockChannel.cancelVerification()");
this.isCancelled = true; this.isCancelled = true;