From d0b44a541d4c97cd50d801fea5606c1f324c13f7 Mon Sep 17 00:00:00 2001 From: Florian Duros Date: Thu, 26 Oct 2023 17:45:05 +0200 Subject: [PATCH] Add crypto info for rust crypto in sentry (#11798) --- src/sentry.ts | 27 +++++++++++++-------------- 1 file changed, 13 insertions(+), 14 deletions(-) diff --git a/src/sentry.ts b/src/sentry.ts index 588f1c4d9c..d1990a8597 100644 --- a/src/sentry.ts +++ b/src/sentry.ts @@ -38,6 +38,7 @@ type UserContext = { }; type CryptoContext = { + crypto_version?: string; device_keys?: string; cross_signing_ready?: string; cross_signing_supported_by_hs?: string; @@ -116,29 +117,27 @@ function getEnabledLabs(): string { } async function getCryptoContext(client: MatrixClient): Promise { - // TODO: make this work with rust crypto - if (!client.isCryptoEnabled() || !client.crypto) { + const cryptoApi = client.getCrypto(); + if (!cryptoApi) { return {}; } const keys = [`ed25519:${client.getDeviceEd25519Key()}`]; if (client.getDeviceCurve25519Key) { keys.push(`curve25519:${client.getDeviceCurve25519Key()}`); } - const crossSigning = client.crypto.crossSigningInfo; - const secretStorage = client.crypto.secretStorage; - const pkCache = client.getCrossSigningCacheCallbacks(); - const sessionBackupKeyFromCache = await client.crypto.getSessionBackupPrivateKey(); + const crossSigningStatus = await cryptoApi.getCrossSigningStatus(); + const secretStorage = client.secretStorage; + const sessionBackupKeyFromCache = await cryptoApi.getSessionBackupPrivateKey(); return { + crypto_version: cryptoApi.getVersion(), device_keys: keys.join(", "), - cross_signing_ready: String(await client.isCrossSigningReady()), - cross_signing_key: crossSigning.getId()!, - cross_signing_privkey_in_secret_storage: String(!!(await crossSigning.isStoredInSecretStorage(secretStorage))), - cross_signing_master_privkey_cached: String(!!(pkCache && (await pkCache.getCrossSigningKeyCache?.("master")))), - cross_signing_user_signing_privkey_cached: String( - !!(pkCache && (await pkCache.getCrossSigningKeyCache?.("user_signing"))), - ), - secret_storage_ready: String(await client.isSecretStorageReady()), + cross_signing_ready: String(await cryptoApi.isCrossSigningReady()), + cross_signing_key: (await cryptoApi.getCrossSigningKeyId()) ?? undefined, + cross_signing_privkey_in_secret_storage: String(crossSigningStatus.privateKeysInSecretStorage), + cross_signing_master_privkey_cached: String(crossSigningStatus.privateKeysCachedLocally.masterKey), + cross_signing_user_signing_privkey_cached: String(crossSigningStatus.privateKeysCachedLocally.userSigningKey), + secret_storage_ready: String(await cryptoApi.isSecretStorageReady()), secret_storage_key_in_account: String(await secretStorage.hasKey()), session_backup_key_in_secret_storage: String(!!(await client.isKeyBackupKeyStored())), session_backup_key_cached: String(!!sessionBackupKeyFromCache),