Skip to content

Commit

Permalink
More things to be fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
hughns committed Oct 31, 2023
1 parent fbd3204 commit 3e21ce9
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/rendezvous/MSC3906Rendezvous.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import { buildFeatureSupportMap, Feature, ServerSupport } from "../feature";
import { logger } from "../logger";
import { sleep } from "../utils";
import { CrossSigningKey } from "../crypto-api";
import { Device } from "../matrix";

enum PayloadType {
Start = "m.login.start",
Expand Down Expand Up @@ -180,7 +181,7 @@ export class MSC3906Rendezvous {
}

private async verifyAndCrossSignDevice(
deviceInfo: DeviceInfo,
deviceInfo: Device,
): Promise<CrossSigningInfo | DeviceInfo | ICrossSigningKey | undefined> {
const crypto = this.client.getCrypto();
if (!crypto) {
Expand Down Expand Up @@ -215,7 +216,8 @@ export class MSC3906Rendezvous {
type: PayloadType.Finish,
outcome: Outcome.Verified,
verifying_device_id: this.client.getDeviceId()!,
verifying_device_key: this.client.getDeviceEd25519Key()!,
// FIXME: this needs fixing too
verifying_device_key: this.client.crypto!.getDeviceEd25519Key()!,
master_key: masterPublicKey,
});

Expand All @@ -239,7 +241,8 @@ export class MSC3906Rendezvous {
return undefined;
}

if (!this.client.crypto) {
const crypto = this.client.getCrypto();
if (!crypto) {
throw new Error("Crypto not available on client");
}

Expand All @@ -249,12 +252,16 @@ export class MSC3906Rendezvous {
throw new Error("No user ID set");
}

let deviceInfo = this.client.crypto.getStoredDevice(userId, this.newDeviceId);
// TODO: is this correct?
let deviceInfo: Device | undefined = (await crypto.getUserDeviceInfo([userId], true))
.get(userId)
?.get(this.newDeviceId);

if (!deviceInfo) {
logger.info("Going to wait for new device to be online");
await sleep(timeout);
deviceInfo = this.client.crypto.getStoredDevice(userId, this.newDeviceId);
// TODO: is this correct?
deviceInfo = (await crypto.getUserDeviceInfo([userId], true)).get(userId)?.get(this.newDeviceId);
}

if (deviceInfo) {
Expand Down

0 comments on commit 3e21ce9

Please sign in to comment.