Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bring up-to-date with latest matrix-sdk (5d46b35d) #149

Merged
merged 1 commit into from
Oct 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,16 @@
# UNRELEASED

**BREAKING CHANGES**

- Rename `DecryptionErrorCode.SenderIdentityPreviouslyVerified` to
`SenderIdentityVerificationViolation` (in line with changes to
matrix-rust-sdk).

- Rename `UserIdentity` to `OtherUserIdentity` (in line with changes
to matrix-rust-sdk).

- Update matrix-rust-sdk to `#5d46b35d`.

# matrix-sdk-crypto-wasm v9.1.0

- Update matrix-rust-sdk to `866b6e5f`, which includes:
Expand Down
42 changes: 21 additions & 21 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ pub enum DecryptionErrorCode {
/// The sender device is not cross-signed.
UnsignedSenderDevice,
/// The sender's identity is unverified, but was previously verified.
SenderIdentityPreviouslyVerified,
SenderIdentityVerificationViolation,
andybalaam marked this conversation as resolved.
Show resolved Hide resolved
/// Other failure.
UnableToDecrypt,
}
Expand Down Expand Up @@ -75,9 +75,9 @@ impl From<MegolmError> for MegolmDecryptionError {
description: value.to_string().into(),
maybe_withheld: None,
},
MegolmError::SenderIdentityNotTrusted(VerificationLevel::PreviouslyVerified) => {
MegolmError::SenderIdentityNotTrusted(VerificationLevel::VerificationViolation) => {
MegolmDecryptionError {
code: DecryptionErrorCode::SenderIdentityPreviouslyVerified,
code: DecryptionErrorCode::SenderIdentityVerificationViolation,
description: value.to_string().into(),
maybe_withheld: None,
}
Expand Down
22 changes: 11 additions & 11 deletions src/identities.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ use crate::{
verification::{self, VerificationRequest},
};

pub(crate) struct UserIdentities {
inner: matrix_sdk_crypto::UserIdentities,
pub(crate) struct UserIdentity {
inner: matrix_sdk_crypto::UserIdentity,
}

impl_from_to_inner!(matrix_sdk_crypto::UserIdentities => UserIdentities);
impl_from_to_inner!(matrix_sdk_crypto::UserIdentity => UserIdentity);

impl From<UserIdentities> for JsValue {
fn from(user_identities: UserIdentities) -> Self {
use matrix_sdk_crypto::UserIdentities::*;
impl From<UserIdentity> for JsValue {
fn from(user_identities: UserIdentity) -> Self {
use matrix_sdk_crypto::UserIdentity::*;

match user_identities.inner {
Own(own) => JsValue::from(OwnUserIdentity::from(own)),
Other(other) => JsValue::from(UserIdentity::from(other)),
Other(other) => JsValue::from(OtherUserIdentity::from(other)),
}
}
}
Expand Down Expand Up @@ -164,14 +164,14 @@ impl OwnUserIdentity {
/// to be requested to verify our own device with the user identity.
#[wasm_bindgen]
#[derive(Debug)]
pub struct UserIdentity {
inner: matrix_sdk_crypto::UserIdentity,
pub struct OtherUserIdentity {
inner: matrix_sdk_crypto::OtherUserIdentity,
}

impl_from_to_inner!(matrix_sdk_crypto::UserIdentity => UserIdentity);
impl_from_to_inner!(matrix_sdk_crypto::OtherUserIdentity => OtherUserIdentity);

#[wasm_bindgen]
impl UserIdentity {
impl OtherUserIdentity {
/// Is this user identity verified?
#[wasm_bindgen(js_name = "isVerified")]
pub fn is_verified(&self) -> bool {
Expand Down
20 changes: 12 additions & 8 deletions src/machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,12 @@ use std::{

use futures_util::{pin_mut, Stream, StreamExt};
use js_sys::{Array, Function, JsString, Map, Promise, Set};
use matrix_sdk_common::ruma::{
self, events::secret::request::SecretName, serde::Raw, DeviceKeyAlgorithm, OwnedDeviceId,
OwnedTransactionId, OwnedUserId, UInt,
use matrix_sdk_common::{
deserialized_responses::TimelineEvent,
ruma::{
self, events::secret::request::SecretName, serde::Raw, DeviceKeyAlgorithm, OwnedDeviceId,
OwnedTransactionId, OwnedUserId, UInt,
},
};
use matrix_sdk_crypto::{
backups::MegolmV1BackupKey,
Expand Down Expand Up @@ -494,10 +497,11 @@ impl OlmMachine {
responses::DecryptedRoomEvent,
MegolmDecryptionError,
>(async move {
let room_event = me
let room_event: TimelineEvent = me
.decrypt_room_event(&event, room_id.as_ref(), &decryption_settings)
.await
.map_err(MegolmDecryptionError::from)?;
.map_err(MegolmDecryptionError::from)?
.into();
Ok(responses::DecryptedRoomEvent::from(room_event))
}))
}
Expand Down Expand Up @@ -658,8 +662,8 @@ impl OlmMachine {

/// Get the cross signing user identity of a user.
///
/// Returns a promise for an `OwnUserIdentity`, a `UserIdentity`, or
/// `undefined`.
/// Returns a promise for an {@link identities.OwnUserIdentity}, a
/// {@link identities.OtherUserIdentity}, or `undefined`.
#[wasm_bindgen(js_name = "getIdentity")]
pub fn get_identity(&self, user_id: &identifiers::UserId) -> Promise {
let me = self.inner.clone();
Expand All @@ -671,7 +675,7 @@ impl OlmMachine {
Ok(me
.get_identity(user_id.as_ref(), Some(Duration::from_secs(1)))
.await?
.map(identities::UserIdentities::from))
.map(identities::UserIdentity::from))
})
}

Expand Down
4 changes: 2 additions & 2 deletions tests/machine.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ import {
ToDeviceRequest,
TrustRequirement,
UserId,
UserIdentity,
OtherUserIdentity,
VerificationRequest,
Versions,
} from "../pkg";
Expand Down Expand Up @@ -1062,7 +1062,7 @@ describe(OlmMachine.name, () => {
let _ = m.bootstrapCrossSigning(true);
const identity = await m.getIdentity(new UserId("@example:morpheus.localhost"));

expect(identity).toBeInstanceOf(UserIdentity);
expect(identity).toBeInstanceOf(OtherUserIdentity);
expect(identity.isVerified()).toStrictEqual(false);
expect(identity.wasPreviouslyVerified()).toStrictEqual(false);
expect(identity.hasVerificationViolation()).toStrictEqual(false);
Expand Down
Loading