Commit Graph

1856 Commits

Author SHA1 Message Date
Damir Jelić
bfa89bc73f feat(crypto): Add support for the shared_history flag defined in MSC3061
This patch adds support for the `shared_history` flag from MSC3061 to
the `m.room_key` content, exported room keys, and backed-up room keys.

The flag is now persisted in our `InboundGroupSession`. Additionally,
when creating a new `InboundGroupSession`, we ensure the
`shared_history`  flag is set appropriately.

MSC3061: https://github.com/matrix-org/matrix-spec-proposals/pull/3061
2025-02-25 16:52:23 +01:00
Kévin Commaille
d4b92de8e4 refactor(oidc): Remove support for OIDC RP-Initiated logout
Token revocation was split out from MSC2964 to MSC4254, and RP-Initiated
logout is now mentioned only as an alternative.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-02-24 14:19:48 +01:00
Kévin Commaille
0a4db305b9 refactor(oidc): Move qrcode module inside oidc
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-02-24 13:39:23 +01:00
Kévin Commaille
2eb2ae7959 refactor(oidc): Use the GET /auth_metadata Matrix endpoint (#4673)
This is the method to get the server metadata in the latest draft of
[MSC2965](https://github.com/matrix-org/matrix-spec-proposals/pull/2965).

We still keep the old behavior with `GET /auth_issuer` as fallback for
now because it has wider server support.

There are some pre-main commit cleanups to simplify the main commit.
This can be reviewed commit by commit.

The changes were tested with the oidc_cli example on beta.matrix.org.

Closes #4550.

---------

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-02-18 17:41:48 +01:00
Jorge Martín
8d9d83f15f feat(ffi): add history_visibility_override param to the create room fn 2025-02-18 13:08:02 +01:00
Ivan Enderlin
38e28643f1 fix: Remove support for MSC3575. 2025-02-14 14:00:39 +01:00
Kévin Commaille
c6c7307d6e Merge branch 'main' into qr-login-oauth2 2025-02-13 15:20:10 +01:00
Damir Jelić
861078a95e feat: Add a memoized variant of Oidc::fetch_account_management_url 2025-02-13 12:32:42 +01:00
Damir Jelić
aa9aef44f7 refactor: Rename Oidc::account_management_url to fetch_account_management_url 2025-02-13 12:32:42 +01:00
Kévin Commaille
31e78c2a1b refactor(oidc): Only support public clients (#4634)
This should be the most common case, and is already the only case
supported by the higher level APIs like `url_for_oidc` and
`login_with_qr_code`. It simplifies the API because we can call
`restore_registered_client` directly from `register_client`, which was a
TODO.

- [x] Public API changes documented in changelogs (optional)

---------

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-02-13 11:40:17 +01:00
Stefan Ceriu
2999d10fb9 fix(ffi): check that our own device is cross-signed before responding to incoming user verification requests 2025-02-11 16:39:26 +02:00
Stefan Ceriu
8d74d46d80 chore(ffi): expose UserIdentity was_previously_verified and has_verification_violation methods 2025-02-10 18:28:55 +02:00
Benjamin Bouvier
9f2c572709 fix(timeline): maintain aggregations when an event is deduplicated (#4576)
## Some context

An aggregation is an event that relates to another event: for instance,
a
reaction, a poll response, and so on and so forth.
                               
## Some requirements
                                              
Because of the sync mechanisms and federation, it can happen that a
related
event is received *before* receiving the event it relates to. Those
events
must be accounted for, stashed somewhere, and reapplied later, if/when
the
related-to event shows up.
In addition to that, a room's event cache can also decide to move events
around, in its own internal representation (likely because it ran into
some
duplicate events, or it managed to decrypt a previously UTD event).
When that happens, a timeline opened on the given room
will see a removal then re-insertion of the given event. If that event
was
the target of aggregations, then those aggregations must be re-applied
when
the given event is reinserted.
                                                                       
## Some solution
      
To satisfy both requirements, the [`Aggregations`] "manager" object
provided
by this PR will take care of memoizing aggregations, **for the entire
lifetime of the timeline** (or until it's clear'd by some
caller). Aggregations are saved in memory, and have the same lifetime as
that of a timeline. This makes it possible to apply pending aggregations
to cater for the first use case, and to never lose any aggregations in
the
second use case.

## Some points for the reviewer

- I think the most controversial point is that all aggregations are
memoized for the entire lifetime of the timeline. Would that become an
issue, we can get back to some incremental scheme, in the future:
instead of memoizing aggregations for the entire lifetime of the
timeline, we'd attach them to a single timeline item. When that item is
removed, we'd put the aggregations back into a "pending" stash of
aggregations. If the item is reinserted later, we could peek at the
pending stash of aggregations, remove any that's in there, and reapply
them to the reinserted event. This is what the [first version of this
patch](ec64b9e0bc)
did, in a much more adhoc way, for reactions only; based on the current
PR, we could do the same in a simpler manner
- while the PR has small commits, they don't quite make sense to review
individually, I'm afraid, as I was trying to find a way to make a
general system that would work not only for reactions, poll responses
and ends. As a matter of fact, the first commits may have introduced
code that is changed in subsequent commits, making the review a bit
hazardous. Happy to have a live reviewing party over Element Call, if
that helps, considering the size of the patch.
- future work may include using the aggregations manager for edits too,
leading to more code removal.
2025-02-10 15:38:25 +00:00
Jorge Martín
4b6dd5c857 fix(ffi): Client::resolve_room_alias was mapping the wrong error type
This is used to check if the alias is resolved or not.
2025-02-10 09:39:00 +01:00
Stefan Ceriu
83dd11ea7d chore(ffi): expose the whole sender profile when receiving a verification request 2025-02-07 11:47:59 +02:00
Stefan Ceriu
f9ff4fff50 feat(ffi): add support for starting and responding to user verification requests 2025-02-06 14:01:05 +02:00
Stefan Ceriu
d8f37509af chore(ffi): reduce the verbosity of the store locks and ambiguity map 2025-02-05 17:45:57 +02:00
Jorge Martín
dddbcfbabb fix(ffi): Align RoomList::preview_room with Client::get_room_preview_* functions.
This removes the restriction applied in the FFI layer so only invited and knocked rooms can return room previews.
2025-02-05 14:06:50 +01:00
Damir Jelić
0d4bc65e28 chore: Enable releases for the test crates 2025-02-04 16:32:55 +01:00
Jorge Martín
5e1bae02fe feat(ffi): Add RoomPreview::forget action in the FFI layer 2025-02-04 16:26:15 +01:00
Jorge Martín
05814c5559 refactor(ffi): Map client API errors to ClientError::MatrixApi, containing the error kind, their error code and the associated message 2025-02-04 12:25:51 +01:00
Jorge Martín
8513547e92 feat(ffi): Add FFI bindings for Room::forget.
Also make sure rooms the user has been banned from can also be forgotten, not only left ones.
2025-02-03 19:48:27 +01:00
Kévin Commaille
525f9866a4 refactor(auth-qrcode): Rename everything OIDC to OAuth 2.0
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-02-02 19:41:04 +01:00
Ivan Enderlin
e3958b754c chore(crypto-ffi): Done is a unit type, no need for { .. }. 2025-01-31 14:07:43 +01:00
Damir Jelić
252786d2ef refactor(ui): Make SyncService::stop infallible
The `SyncService::stop()` method could fail for the following reasons:

1. The supervisor was not properly started up, this is a programmer error.
2. The supervisor task wouldn't shut down and instead it returns a JoinError.
3. We couldn't notify the supervisor task that it should shutdown due the channel being closed.

All of those cases shouldn't ever happen and the supervisor task will be
stopped in all of them.

1. Since there is no supervisor to be stopped, we can safely just log an
   error, our tests ensure that a `SyncService::start()` does create a
   supervisor.

2. A JoinError can be returned if the task has been cancelled or if the
   supervisor task has panicked. Since we never cancel the task, nor
   have any panics in the supervisor task, we can assume that this won't
   happen.

3. The supervisor task holds on to a reference to the receiving end of
   the channel, as long as the task is alive the channel can not be
   closed.

In conclusion, it doesn't seem to be useful to forward these error cases
to the user.
2025-01-31 09:58:55 +01:00
Damir Jelić
9d732395ce feat(ui): Introduce a "offline" mode for the SyncService 2025-01-31 09:58:55 +01:00
Ivan Enderlin
5b3b87d3e2 chore(ui): Rename Timeline::subscribe_batched to ::subscribe.
This patch renames `Timeline::subscribe_batched` to
`Timeline::subscribe`. Since the `Timeline::subscribe` method has been
removed because unused, it no longer makes sense to have a “batched”
variant here. Let's simplify things!
2025-01-28 09:54:31 +01:00
Ivan Enderlin
254ac6f2ce refactor(ui): Unify the Timeline pagination API.
This patch simplifies the `Timeline` pagination API as follows:

- a unique `paginate_backwards` method (no more
  `focused_paginate_backwards` and `live_paginate_backwards`),
- a unique `paginate_forwards` method (no more
  `focused_paginate_forwards`, the `live` variant was absent).

The idea is to unify pagination by hiding the `live` and `focused` mode.
It was already partially the case with `paginate_backards`, but the
`live` and `focused` variants were also present. I believe it creates
an unnecessary confusion.
2025-01-27 17:02:09 +01:00
Ivan Enderlin
468a7ac883 doc(ffi): Remove useless #[cfg(doc)] imports.
This patch removes 2 useless imports that are behind a `#[cfg(doc)]` but
never used.
2025-01-27 17:02:09 +01:00
Richard van der Hoff
3e610c80e1 Merge pull request #4581 from matrix-org/rav/refactor_share_keys
crypto: refactor the room key sharing strategies
2025-01-27 15:51:04 +00:00
Richard van der Hoff
7c57f2cee4 crypto: split out new device collection strategies
Rather than a bunch of flags on `DeviceBasedStrategy`, separate the strategies
properly.
2025-01-27 15:34:43 +00:00
Stefan Ceriu
2657eb7866 feat(ui): expose a method for checking whether a message contains only emojis and should be boosted (use a bigger font size) (#4577)
- supports only text room message types
- enumerates through their body's grapheme clusters and check that every
single one of them is an emoji
- part of the `LazyTimelineItemProvider` so that it can be opt in
2025-01-27 14:00:01 +00:00
torrybr
aaecbf07f2 refactor: dont panic if beacon_info is not found 2025-01-27 11:05:24 +01:00
torrybr
f336638a17 refactor: move subscribe into arc 2025-01-27 11:05:24 +01:00
torrybr
839fbe477c feat(beacons): expose ffi functions to start, stop and subscribe 2025-01-27 11:05:24 +01:00
Kévin Commaille
3e78e441d4 refactor(sdk): Move oidc module to authentication::oidc
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-01-22 20:22:13 +01:00
Kévin Commaille
02c2e55855 refactor(sdk): Move matrix_auth module to authentication::matrix
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-01-22 20:22:13 +01:00
Stefan Ceriu
a528624274 chore(ffi): replace all the different timeline builder methods with one taking a configuration (#4561) 2025-01-22 13:56:53 +02:00
Hubert Chathi
e826c54a42 Use the dehydrated device format implemented by vodozemac (#4421)
Signed-off-by: Hubert Chathi <hubertc@matrix.org>
2025-01-22 09:38:48 +01:00
Stefan Ceriu
2cb6ee8e6d chore(ffi): silence useless logs coming out of the ffi crate
Setting the default log level to `debug` results in logs like:

```
log: log_event
log: latest_event
log: log_event
log: log_event
log: room_info
log: latest_event
log: log_event
log: room_info
```

Presumably they're coming out of the custom tracing configuration and we definitely don't need them.
2025-01-16 15:17:24 +02:00
Jorge Martín
bd5d7aafee feat(ffi): Add FFI bindings for fn Room::own_membership_details.
Also add `membership_change_reason` field to `ffi::RoomMember`.
2025-01-14 16:23:51 +01:00
Daniel Salinas
9641aa9082 feat(send queue): Add an enqueued time to to-be-sent events (#4385)
Add a new created_at to the send_queue_events and
dependent_send_queue_events stored records. This will allow clients to
understand how stale a pending message might be in the event that the
queue encounters and error and becomes wedged.

This change is exposed through the FFI on the `EventTimelineItem` struct
as a new optional field named `local_created_at`. It will be `None` for
any Remote event, and `Some` for Local events (except for those that
were enqueued before the migrations were run).

Signed-off-by: Daniel Salinas

---------

Signed-off-by: Daniel Salinas <zzorba@users.noreply.github.com>
Co-authored-by: Daniel Salinas <danielsalinas@daniels-mbp-2.myfiosgateway.com>
Co-authored-by: Benjamin Bouvier <benjamin@bouvier.cc>
Co-authored-by: Daniel Salinas <danielsalinas@Daniels-MBP-2.attlocal.net>
2025-01-13 16:41:05 +00:00
Benjamin Bouvier
279c78b3e2 chore!(encryption): rename are_we_the_last_man_standing to is_last_device
While the former name is arguably more fun, the latter is more
descriptive of what the function does.
2025-01-13 16:51:33 +01:00
Jorge Martín
5548f38393 feat(ffi): Add FFI bindings for the new room privacy settings feature. 2025-01-13 11:29:10 +01:00
Valere
a79d409f9d task(bindings): Expose withdraw_verification in UserIdentity 2025-01-10 15:18:12 +01:00
Kévin Commaille
b3491582d0 feat(sdk): Allow to set and check whether an image is animated
Using MSC4230.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-01-10 14:37:56 +01:00
Jonas Platte
6c053a86bf chore: Fix new nightly warnings 2025-01-09 16:20:51 -05:00
Stefan Ceriu
c4bfbd0f44 feat(ffi): move tracing setup from the final client to the ffi layer (#4492)
Having the final clients define the tracing filters / log levels proved
to be tricky to keep in check resulting missing logs (e.g. recently
introduced modules like the event cache) or unexpected behaviors (e.g.
missing panics because we don't set a global filter). As such we decided
to move the tracing setup and default definitions over to the rust side
and let rust developers have full control over them.

We will now take a general log level and optional extra targets and 
apply them on top of the rust side defined defaults. Targets that log
more than the requested by default will remain unchanged while the
others will increase their log levels to match. Certain targets like
`hyper` will be ignored in this step as they're too verbose others 
like `matrix_sdk` because they're too generic.
2025-01-09 18:08:44 +02:00
Ivan Enderlin
61dd560499 feat: Remove the experimental-sliding-sync feature flag.
Sliding sync is no longer experimental. It has a solid MSC4186, along
with a solid implementation inside Synapse. It's time to consider it
mature.

The SDK continues to support the old MSC3575 in addition to MSC4186.
This patch only removes the `experimental-sliding-sync` feature flag.
2025-01-08 21:30:41 +01:00
Benjamin Bouvier
34e993435d fix(ffi): ensure the log level for panic is always set (#4485)
If it's present, we just let it untouched. Otherwise, we set it to
`error` if it's missing. See code comment explaining why we need this.

This makes sure we log panics at the FFI layer, since the `log-panics`
crate will use the `panic` target at the error level.
2025-01-08 15:51:14 +00:00