Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add getShowSasCallbacks, getShowQrCodeCallbacks to VerifierBase #3422

Merged
merged 11 commits into from
Jun 6, 2023
27 changes: 26 additions & 1 deletion src/crypto/verification/Base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,12 @@ import { IVerificationChannel } from "./request/Channel";
import { MatrixClient } from "../../client";
import { VerificationRequest } from "./request/VerificationRequest";
import { TypedEventEmitter } from "../../models/typed-event-emitter";
import { VerifierEvent, VerifierEventHandlerMap } from "../../crypto-api/verification";
import {
ShowQrCodeCallbacks,
ShowSasCallbacks,
VerifierEvent,
VerifierEventHandlerMap,
} from "../../crypto-api/verification";

const timeoutException = new Error("Verification timed out");

Expand Down Expand Up @@ -373,4 +378,24 @@ export class VerificationBase<
public get events(): string[] | undefined {
return undefined;
}

/**
* Get the details for an SAS verification, if one is in progress
*
* Returns `null`, unless this verifier is for a SAS-based verification and we are waiting for the user to confirm
* the SAS matches.
*/
public getShowSasCallbacks(): ShowSasCallbacks | null {
return null;
}

/**
* Get the details for a QR code verification, if one is in progress
*
* Returns `null`, unless this verifier is for a QR-code-based verification and we are waiting for the user to
* confirm a match.
*/
public getShowQrCodeCallbacks(): ShowQrCodeCallbacks | null {
return null;
}
}
4 changes: 4 additions & 0 deletions src/crypto/verification/QRCode.ts
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,10 @@ export class ReciprocateQRCode extends Base {
}
});
};

public getShowQrCodeCallbacks(): ShowQrCodeCallbacks | null {
return this.reciprocateQREvent ?? null;
}
}

const CODE_VERSION = 0x02; // the version of binary QR codes we support
Expand Down
4 changes: 4 additions & 0 deletions src/crypto/verification/SAS.ts
Original file line number Diff line number Diff line change
Expand Up @@ -480,4 +480,8 @@ export class SAS extends Base {
}
});
}

public getShowSasCallbacks(): ShowSasCallbacks | null {
return this.sasEvent ?? null;
}
}