1
0
mirror of https://github.com/matrix-org/matrix-js-sdk.git synced 2025-11-23 17:02:25 +03:00

Add CryptoApi.setDeviceVerified (#3624)

I need a way to mark devices as trusted for the backup tests.
This commit is contained in:
Richard van der Hoff
2023-07-27 13:16:10 +01:00
committed by GitHub
parent e6fa4cdb3c
commit 73c9f4e322
4 changed files with 98 additions and 0 deletions

View File

@@ -377,6 +377,23 @@ export class RustCrypto extends TypedEventEmitter<RustCryptoEvents, RustCryptoEv
// events. Maybe we need to do the same?
}
/**
* Mark the given device as locally verified.
*
* Implementation of {@link CryptoApi#setDeviceVerified}.
*/
public async setDeviceVerified(userId: string, deviceId: string, verified = true): Promise<void> {
const device: RustSdkCryptoJs.Device | undefined = await this.olmMachine.getDevice(
new RustSdkCryptoJs.UserId(userId),
new RustSdkCryptoJs.DeviceId(deviceId),
);
if (!device) {
throw new Error(`Unknown device ${userId}|${deviceId}`);
}
await device.setLocalTrust(verified ? RustSdkCryptoJs.LocalTrust.Verified : RustSdkCryptoJs.LocalTrust.Unset);
}
/**
* Implementation of {@link CryptoApi#getDeviceVerificationStatus}.
*/