diff --git a/spec/integ/crypto/verification.spec.ts b/spec/integ/crypto/verification.spec.ts index 8e008ad5c30..5238871d208 100644 --- a/spec/integ/crypto/verification.spec.ts +++ b/spec/integ/crypto/verification.spec.ts @@ -414,7 +414,7 @@ describe.each(Object.entries(CRYPTO_BACKENDS))("verification (%s)", (backend: st expect(request.phase).toEqual(VerificationPhase.Ready); // we should now have QR data we can display - const qrCodeBuffer = request.getQRCodeBytes()!; + const qrCodeBuffer = (await request.generateQRCode())!; expect(qrCodeBuffer).toBeTruthy(); // https://spec.matrix.org/v1.7/client-server-api/#qr-code-format diff --git a/src/crypto-api/verification.ts b/src/crypto-api/verification.ts index 1d079b8b3a2..12a14bb5092 100644 --- a/src/crypto-api/verification.ts +++ b/src/crypto-api/verification.ts @@ -152,9 +152,19 @@ export interface VerificationRequest * Get the data for a QR code allowing the other device to verify this one, if it supports it. * * Only set after a .ready if the other party can scan a QR code, otherwise undefined. + * + * @deprecated Not supported in Rust Crypto. Use {@link VerificationRequest#generateQRCode} instead. */ getQRCodeBytes(): Buffer | undefined; + /** + * Generate the data for a QR code allowing the other device to verify this one, if it supports it. + * + * Only returns data once `phase` is {@link VerificationPhase.Ready} and the other party can scan a QR code; + * otherwise returns `undefined`. + */ + generateQRCode(): Promise; + /** * If this request has been cancelled, the cancellation code (e.g `m.user`) which is responsible for cancelling * this verification. diff --git a/src/crypto/verification/request/VerificationRequest.ts b/src/crypto/verification/request/VerificationRequest.ts index 7a1a999cf74..7bcb948b4e3 100644 --- a/src/crypto/verification/request/VerificationRequest.ts +++ b/src/crypto/verification/request/VerificationRequest.ts @@ -268,7 +268,7 @@ export class VerificationRequest { + return this.getQRCodeBytes(); + } + /** Checks whether the other party supports a given verification method. * This is useful when setting up the QR code UI, as it is somewhat asymmetrical: * if the other party supports SCAN_QR, we should show a QR code in the UI, and vice versa. diff --git a/src/rust-crypto/verification.ts b/src/rust-crypto/verification.ts index fbf65f64f90..3d8fc48e0ff 100644 --- a/src/rust-crypto/verification.ts +++ b/src/rust-crypto/verification.ts @@ -322,15 +322,23 @@ export class RustVerificationRequest } /** - * Get the data for a QR code allowing the other device to verify this one, if it supports it. - * - * Only set after a .ready if the other party can scan a QR code, otherwise undefined. + * Stub implementation of {@link Crypto.VerificationRequest#getQRCodeBytes}. */ public getQRCodeBytes(): Buffer | undefined { // TODO return undefined; } + /** + * Generate the data for a QR code allowing the other device to verify this one, if it supports it. + * + * Implementation of {@link Crypto.VerificationRequest#generateQRCode}. + */ + public async generateQRCode(): Promise { + // TODO + return undefined; + } + /** * If this request has been cancelled, the cancellation code (e.g `m.user`) which is responsible for cancelling * this verification.