Skip to content

Commit c92d946

Browse files
Anderaspoljar
authored andcommitted
Set local trust
1 parent 0cfc754 commit c92d946

File tree

5 files changed

+24
-6
lines changed

5 files changed

+24
-6
lines changed

bindings/apple/build_crypto_xcframework.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,12 @@ lipo -create \
5151
-output "${GENERATED_DIR}/simulator/libmatrix_sdk_crypto_ffi.a"
5252

5353
# Generate uniffi files
54-
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}
54+
uniffi-bindgen generate \
55+
--language swift \
56+
--lib-file "${TARGET_DIR}/aarch64-apple-ios-sim/${REL_TYPE_DIR}/libmatrix_sdk_crypto_ffi.a" \
57+
--config "${SRC_ROOT}/bindings/${TARGET_CRATE}/uniffi.toml" \
58+
--out-dir ${GENERATED_DIR} \
59+
"${SRC_ROOT}/bindings/${TARGET_CRATE}/src/olm.udl"
5560

5661
# Move headers to the right place
5762
HEADERS_DIR=${GENERATED_DIR}/headers

bindings/matrix-sdk-crypto-ffi/src/lib.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ pub use error::{
2828
use js_int::UInt;
2929
pub use logger::{set_logger, Logger};
3030
pub use machine::{KeyRequestPair, OlmMachine};
31-
use matrix_sdk_crypto::types::{EventEncryptionAlgorithm, SigningKey};
31+
use matrix_sdk_crypto::{
32+
types::{EventEncryptionAlgorithm, SigningKey},
33+
LocalTrust,
34+
};
3235
pub use responses::{
3336
BootstrapCrossSigningResult, DeviceLists, KeysImportResult, OutgoingVerificationRequest,
3437
Request, RequestType, SignatureUploadRequest, UploadSigningKeysRequest,

bindings/matrix-sdk-crypto-ffi/src/logger.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ pub fn set_logger(logger: Box<dyn Logger>) {
5151
let _ = tracing_subscriber::fmt()
5252
.with_writer(logger)
5353
.with_env_filter(filter)
54+
.with_ansi(false)
5455
.without_time()
5556
.try_init();
5657
}

bindings/matrix-sdk-crypto-ffi/src/machine.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,19 +283,21 @@ impl OlmMachine {
283283
}
284284
}
285285

286-
/// Mark the device of the given user with the given device ID as trusted.
287-
pub fn mark_device_as_trusted(
286+
/// Set local trust state for the device of the given user without creating
287+
/// or uploading any signatures if verified
288+
pub fn set_local_trust(
288289
&self,
289290
user_id: &str,
290291
device_id: &str,
292+
trust_state: LocalTrust,
291293
) -> Result<(), CryptoStoreError> {
292294
let user_id = parse_user_id(user_id)?;
293295

294296
let device =
295297
self.runtime.block_on(self.inner.get_device(&user_id, device_id.into(), None))?;
296298

297299
if let Some(device) = device {
298-
self.runtime.block_on(device.set_local_trust(LocalTrust::Verified))?;
300+
self.runtime.block_on(device.set_local_trust(trust_state))?;
299301
}
300302

301303
Ok(())

bindings/matrix-sdk-crypto-ffi/src/olm.udl

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -247,6 +247,13 @@ enum RequestType {
247247
"RoomMessage",
248248
};
249249

250+
enum LocalTrust {
251+
"Verified",
252+
"BlackListed",
253+
"Ignored",
254+
"Unset",
255+
};
256+
250257
interface OlmMachine {
251258
[Throws=CryptoStoreError]
252259
constructor(
@@ -282,7 +289,7 @@ interface OlmMachine {
282289
[Throws=CryptoStoreError]
283290
Device? get_device([ByRef] string user_id, [ByRef] string device_id, u32 timeout);
284291
[Throws=CryptoStoreError]
285-
void mark_device_as_trusted([ByRef] string user_id, [ByRef] string device_id);
292+
void set_local_trust([ByRef] string user_id, [ByRef] string device_id, LocalTrust trust_state);
286293
[Throws=SignatureError]
287294
SignatureUploadRequest verify_device([ByRef] string user_id, [ByRef] string device_id);
288295
[Throws=CryptoStoreError]

0 commit comments

Comments
 (0)