mirror of
https://github.com/vector-im/hydrogen-web.git
synced 2024-11-20 03:25:52 +01:00
Sign the actual device/user
This commit is contained in:
parent
960c701454
commit
f56cfba906
@ -40,20 +40,20 @@ export class DeviceVerificationViewModel extends ErrorReportViewModel<SegmentTyp
|
||||
|
||||
constructor(options: Readonly<Options>) {
|
||||
super(options);
|
||||
this.init(options);
|
||||
this.start(options);
|
||||
}
|
||||
|
||||
private async init(options: Options): Promise<void> {
|
||||
private async start(options: Options): Promise<void> {
|
||||
const room = options.room;
|
||||
let requestOrUserId: SASRequest | string;
|
||||
requestOrUserId =
|
||||
options.request ??
|
||||
options.userId ??
|
||||
this.getOption("session").userId;
|
||||
await this.start(requestOrUserId, room);
|
||||
await this.startVerification(requestOrUserId, room);
|
||||
}
|
||||
|
||||
private async start(requestOrUserId: SASRequest | string, room?: Room) {
|
||||
private async startVerification(requestOrUserId: SASRequest | string, room?: Room) {
|
||||
await this.logAndCatch("DeviceVerificationViewModel.start", (log) => {
|
||||
const crossSigning = this.getOption("session").crossSigning.get();
|
||||
this.sas = crossSigning.startVerification(requestOrUserId, room, log);
|
||||
@ -64,7 +64,12 @@ export class DeviceVerificationViewModel extends ErrorReportViewModel<SegmentTyp
|
||||
if (typeof requestOrUserId === "string") {
|
||||
this.updateCurrentStageViewModel(new WaitingForOtherUserViewModel(this.childOptions({ sas: this.sas })));
|
||||
}
|
||||
return this.sas.verify();
|
||||
if (this.sas.isCrossSigningAnotherUser) {
|
||||
return crossSigning.signUser(this.sas, log);
|
||||
}
|
||||
else {
|
||||
return crossSigning.signDevice(this.sas, log);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -84,6 +84,7 @@ enum MSKVerification {
|
||||
export interface IVerificationMethod {
|
||||
verify(): Promise<boolean>;
|
||||
otherDeviceId: string;
|
||||
otherUserId: string;
|
||||
}
|
||||
|
||||
export class CrossSigning {
|
||||
@ -295,8 +296,9 @@ export class CrossSigning {
|
||||
}
|
||||
|
||||
/** @return the signed MSK for the given user id */
|
||||
async signUser(userId: string, verification: IVerificationMethod, log: ILogItem): Promise<CrossSigningKey | undefined> {
|
||||
async signUser(verification: IVerificationMethod, log: ILogItem): Promise<CrossSigningKey | undefined> {
|
||||
return log.wrap("CrossSigning.signUser", async log => {
|
||||
const userId = verification.otherUserId;
|
||||
log.set("id", userId);
|
||||
if (!this._isMasterKeyTrusted) {
|
||||
log.set("mskNotTrusted", true);
|
||||
|
Loading…
Reference in New Issue
Block a user