mirror of
https://github.com/matrix-org/matrix-rust-sdk.git
synced 2026-05-14 11:05:32 -04:00
Set local trust
This commit is contained in:
@@ -51,7 +51,12 @@ lipo -create \
|
||||
-output "${GENERATED_DIR}/simulator/libmatrix_sdk_crypto_ffi.a"
|
||||
|
||||
# Generate uniffi files
|
||||
uniffi-bindgen generate "${SRC_ROOT}/bindings/${TARGET_CRATE}/src/olm.udl" --language swift --config "${SRC_ROOT}/bindings/${TARGET_CRATE}/uniffi.toml" --out-dir ${GENERATED_DIR}
|
||||
uniffi-bindgen generate \
|
||||
--language swift \
|
||||
--lib-file "${TARGET_DIR}/aarch64-apple-ios-sim/${REL_TYPE_DIR}/libmatrix_sdk_crypto_ffi.a" \
|
||||
--config "${SRC_ROOT}/bindings/${TARGET_CRATE}/uniffi.toml" \
|
||||
--out-dir ${GENERATED_DIR} \
|
||||
"${SRC_ROOT}/bindings/${TARGET_CRATE}/src/olm.udl"
|
||||
|
||||
# Move headers to the right place
|
||||
HEADERS_DIR=${GENERATED_DIR}/headers
|
||||
|
||||
@@ -28,7 +28,10 @@ pub use error::{
|
||||
use js_int::UInt;
|
||||
pub use logger::{set_logger, Logger};
|
||||
pub use machine::{KeyRequestPair, OlmMachine};
|
||||
use matrix_sdk_crypto::types::{EventEncryptionAlgorithm, SigningKey};
|
||||
use matrix_sdk_crypto::{
|
||||
types::{EventEncryptionAlgorithm, SigningKey},
|
||||
LocalTrust,
|
||||
};
|
||||
pub use responses::{
|
||||
BootstrapCrossSigningResult, DeviceLists, KeysImportResult, OutgoingVerificationRequest,
|
||||
Request, RequestType, SignatureUploadRequest, UploadSigningKeysRequest,
|
||||
|
||||
@@ -51,6 +51,7 @@ pub fn set_logger(logger: Box<dyn Logger>) {
|
||||
let _ = tracing_subscriber::fmt()
|
||||
.with_writer(logger)
|
||||
.with_env_filter(filter)
|
||||
.with_ansi(false)
|
||||
.without_time()
|
||||
.try_init();
|
||||
}
|
||||
|
||||
@@ -283,11 +283,13 @@ impl OlmMachine {
|
||||
}
|
||||
}
|
||||
|
||||
/// Mark the device of the given user with the given device ID as trusted.
|
||||
pub fn mark_device_as_trusted(
|
||||
/// Set local trust state for the device of the given user without creating
|
||||
/// or uploading any signatures if verified
|
||||
pub fn set_local_trust(
|
||||
&self,
|
||||
user_id: &str,
|
||||
device_id: &str,
|
||||
trust_state: LocalTrust,
|
||||
) -> Result<(), CryptoStoreError> {
|
||||
let user_id = parse_user_id(user_id)?;
|
||||
|
||||
@@ -295,7 +297,7 @@ impl OlmMachine {
|
||||
self.runtime.block_on(self.inner.get_device(&user_id, device_id.into(), None))?;
|
||||
|
||||
if let Some(device) = device {
|
||||
self.runtime.block_on(device.set_local_trust(LocalTrust::Verified))?;
|
||||
self.runtime.block_on(device.set_local_trust(trust_state))?;
|
||||
}
|
||||
|
||||
Ok(())
|
||||
|
||||
@@ -247,6 +247,13 @@ enum RequestType {
|
||||
"RoomMessage",
|
||||
};
|
||||
|
||||
enum LocalTrust {
|
||||
"Verified",
|
||||
"BlackListed",
|
||||
"Ignored",
|
||||
"Unset",
|
||||
};
|
||||
|
||||
interface OlmMachine {
|
||||
[Throws=CryptoStoreError]
|
||||
constructor(
|
||||
@@ -282,7 +289,7 @@ interface OlmMachine {
|
||||
[Throws=CryptoStoreError]
|
||||
Device? get_device([ByRef] string user_id, [ByRef] string device_id, u32 timeout);
|
||||
[Throws=CryptoStoreError]
|
||||
void mark_device_as_trusted([ByRef] string user_id, [ByRef] string device_id);
|
||||
void set_local_trust([ByRef] string user_id, [ByRef] string device_id, LocalTrust trust_state);
|
||||
[Throws=SignatureError]
|
||||
SignatureUploadRequest verify_device([ByRef] string user_id, [ByRef] string device_id);
|
||||
[Throws=CryptoStoreError]
|
||||
|
||||
Reference in New Issue
Block a user