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

Commit d0b44a5

Browse files
authored
Add crypto info for rust crypto in sentry (#11798)
1 parent c7c51d7 commit d0b44a5

File tree

1 file changed

+13
-14
lines changed

1 file changed

+13
-14
lines changed

src/sentry.ts

Lines changed: 13 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ type UserContext = {
3838
};
3939

4040
type CryptoContext = {
41+
crypto_version?: string;
4142
device_keys?: string;
4243
cross_signing_ready?: string;
4344
cross_signing_supported_by_hs?: string;
@@ -116,29 +117,27 @@ function getEnabledLabs(): string {
116117
}
117118

118119
async function getCryptoContext(client: MatrixClient): Promise<CryptoContext> {
119-
// TODO: make this work with rust crypto
120-
if (!client.isCryptoEnabled() || !client.crypto) {
120+
const cryptoApi = client.getCrypto();
121+
if (!cryptoApi) {
121122
return {};
122123
}
123124
const keys = [`ed25519:${client.getDeviceEd25519Key()}`];
124125
if (client.getDeviceCurve25519Key) {
125126
keys.push(`curve25519:${client.getDeviceCurve25519Key()}`);
126127
}
127-
const crossSigning = client.crypto.crossSigningInfo;
128-
const secretStorage = client.crypto.secretStorage;
129-
const pkCache = client.getCrossSigningCacheCallbacks();
130-
const sessionBackupKeyFromCache = await client.crypto.getSessionBackupPrivateKey();
128+
const crossSigningStatus = await cryptoApi.getCrossSigningStatus();
129+
const secretStorage = client.secretStorage;
130+
const sessionBackupKeyFromCache = await cryptoApi.getSessionBackupPrivateKey();
131131

132132
return {
133+
crypto_version: cryptoApi.getVersion(),
133134
device_keys: keys.join(", "),
134-
cross_signing_ready: String(await client.isCrossSigningReady()),
135-
cross_signing_key: crossSigning.getId()!,
136-
cross_signing_privkey_in_secret_storage: String(!!(await crossSigning.isStoredInSecretStorage(secretStorage))),
137-
cross_signing_master_privkey_cached: String(!!(pkCache && (await pkCache.getCrossSigningKeyCache?.("master")))),
138-
cross_signing_user_signing_privkey_cached: String(
139-
!!(pkCache && (await pkCache.getCrossSigningKeyCache?.("user_signing"))),
140-
),
141-
secret_storage_ready: String(await client.isSecretStorageReady()),
135+
cross_signing_ready: String(await cryptoApi.isCrossSigningReady()),
136+
cross_signing_key: (await cryptoApi.getCrossSigningKeyId()) ?? undefined,
137+
cross_signing_privkey_in_secret_storage: String(crossSigningStatus.privateKeysInSecretStorage),
138+
cross_signing_master_privkey_cached: String(crossSigningStatus.privateKeysCachedLocally.masterKey),
139+
cross_signing_user_signing_privkey_cached: String(crossSigningStatus.privateKeysCachedLocally.userSigningKey),
140+
secret_storage_ready: String(await cryptoApi.isSecretStorageReady()),
142141
secret_storage_key_in_account: String(await secretStorage.hasKey()),
143142
session_backup_key_in_secret_storage: String(!!(await client.isKeyBackupKeyStored())),
144143
session_backup_key_cached: String(!!sessionBackupKeyFromCache),

0 commit comments

Comments
 (0)