Add crypto info for rust crypto in sentry (#11798)
This commit is contained in:
parent
c7c51d764f
commit
d0b44a541d
1 changed files with 13 additions and 14 deletions
|
@ -38,6 +38,7 @@ type UserContext = {
|
||||||
};
|
};
|
||||||
|
|
||||||
type CryptoContext = {
|
type CryptoContext = {
|
||||||
|
crypto_version?: string;
|
||||||
device_keys?: string;
|
device_keys?: string;
|
||||||
cross_signing_ready?: string;
|
cross_signing_ready?: string;
|
||||||
cross_signing_supported_by_hs?: string;
|
cross_signing_supported_by_hs?: string;
|
||||||
|
@ -116,29 +117,27 @@ function getEnabledLabs(): string {
|
||||||
}
|
}
|
||||||
|
|
||||||
async function getCryptoContext(client: MatrixClient): Promise<CryptoContext> {
|
async function getCryptoContext(client: MatrixClient): Promise<CryptoContext> {
|
||||||
// TODO: make this work with rust crypto
|
const cryptoApi = client.getCrypto();
|
||||||
if (!client.isCryptoEnabled() || !client.crypto) {
|
if (!cryptoApi) {
|
||||||
return {};
|
return {};
|
||||||
}
|
}
|
||||||
const keys = [`ed25519:${client.getDeviceEd25519Key()}`];
|
const keys = [`ed25519:${client.getDeviceEd25519Key()}`];
|
||||||
if (client.getDeviceCurve25519Key) {
|
if (client.getDeviceCurve25519Key) {
|
||||||
keys.push(`curve25519:${client.getDeviceCurve25519Key()}`);
|
keys.push(`curve25519:${client.getDeviceCurve25519Key()}`);
|
||||||
}
|
}
|
||||||
const crossSigning = client.crypto.crossSigningInfo;
|
const crossSigningStatus = await cryptoApi.getCrossSigningStatus();
|
||||||
const secretStorage = client.crypto.secretStorage;
|
const secretStorage = client.secretStorage;
|
||||||
const pkCache = client.getCrossSigningCacheCallbacks();
|
const sessionBackupKeyFromCache = await cryptoApi.getSessionBackupPrivateKey();
|
||||||
const sessionBackupKeyFromCache = await client.crypto.getSessionBackupPrivateKey();
|
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
crypto_version: cryptoApi.getVersion(),
|
||||||
device_keys: keys.join(", "),
|
device_keys: keys.join(", "),
|
||||||
cross_signing_ready: String(await client.isCrossSigningReady()),
|
cross_signing_ready: String(await cryptoApi.isCrossSigningReady()),
|
||||||
cross_signing_key: crossSigning.getId()!,
|
cross_signing_key: (await cryptoApi.getCrossSigningKeyId()) ?? undefined,
|
||||||
cross_signing_privkey_in_secret_storage: String(!!(await crossSigning.isStoredInSecretStorage(secretStorage))),
|
cross_signing_privkey_in_secret_storage: String(crossSigningStatus.privateKeysInSecretStorage),
|
||||||
cross_signing_master_privkey_cached: String(!!(pkCache && (await pkCache.getCrossSigningKeyCache?.("master")))),
|
cross_signing_master_privkey_cached: String(crossSigningStatus.privateKeysCachedLocally.masterKey),
|
||||||
cross_signing_user_signing_privkey_cached: String(
|
cross_signing_user_signing_privkey_cached: String(crossSigningStatus.privateKeysCachedLocally.userSigningKey),
|
||||||
!!(pkCache && (await pkCache.getCrossSigningKeyCache?.("user_signing"))),
|
secret_storage_ready: String(await cryptoApi.isSecretStorageReady()),
|
||||||
),
|
|
||||||
secret_storage_ready: String(await client.isSecretStorageReady()),
|
|
||||||
secret_storage_key_in_account: String(await secretStorage.hasKey()),
|
secret_storage_key_in_account: String(await secretStorage.hasKey()),
|
||||||
session_backup_key_in_secret_storage: String(!!(await client.isKeyBackupKeyStored())),
|
session_backup_key_in_secret_storage: String(!!(await client.isKeyBackupKeyStored())),
|
||||||
session_backup_key_cached: String(!!sessionBackupKeyFromCache),
|
session_backup_key_cached: String(!!sessionBackupKeyFromCache),
|
||||||
|
|
Loading…
Reference in a new issue