fix(matrix): check if requestOwnUserVerification exists before calling

The crypto SDK may not have this function, causing a TypeError on startup.
This adds a runtime check to gracefully handle missing verification support.

Fixes #2901
This commit is contained in:
David Dudok de Wit 2026-01-27 19:24:54 +01:00
parent 640c8d1554
commit 67a7b677e2

View File

@ -250,11 +250,15 @@ export async function monitorMatrixProvider(opts: MonitorMatrixOpts = {}): Promi
// If E2EE is enabled, trigger device verification // If E2EE is enabled, trigger device verification
if (auth.encryption && client.crypto) { if (auth.encryption && client.crypto) {
try { try {
// Request verification from other sessions // Request verification from other sessions (if supported by SDK)
if (typeof client.crypto.requestOwnUserVerification === "function") {
const verificationRequest = await client.crypto.requestOwnUserVerification(); const verificationRequest = await client.crypto.requestOwnUserVerification();
if (verificationRequest) { if (verificationRequest) {
logger.info("matrix: device verification requested - please verify in another client"); logger.info("matrix: device verification requested - please verify in another client");
} }
} else {
logger.debug("matrix: device verification not supported by current crypto SDK version");
}
} catch (err) { } catch (err) {
logger.debug({ error: String(err) }, "Device verification request failed (may already be verified)"); logger.debug({ error: String(err) }, "Device verification request failed (may already be verified)");
} }