Skip to content
This repository has been archived by the owner on Sep 11, 2024. It is now read-only.

Commit

Permalink
Add crypto info for rust crypto in sentry (#11798)
Browse files Browse the repository at this point in the history
  • Loading branch information
florianduros authored Oct 26, 2023
1 parent c7c51d7 commit d0b44a5
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions src/sentry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type UserContext = {
};

type CryptoContext = {
crypto_version?: string;
device_keys?: string;
cross_signing_ready?: string;
cross_signing_supported_by_hs?: string;
Expand Down Expand Up @@ -116,29 +117,27 @@ function getEnabledLabs(): string {
}

async function getCryptoContext(client: MatrixClient): Promise<CryptoContext> {
// 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),
Expand Down

0 comments on commit d0b44a5

Please sign in to comment.