Commit Graph

13223 Commits

Author SHA1 Message Date
Ivan Enderlin
d03ed3063c feat: Introduce EncryptionState.
This patch introduces the new `EncryptionState` to represent the 3
possible states: `Encrypted`, `NotEncrypted` or `Unknown`. All the
`is_encrypted` methods have been replaced by `encryption_state`.
The most noticable change is in `matrix_sdk::Room` where `async fn
is_encrypted(&self) -> Result<bool>` has been replaced by `fn fn
encryption_state(&self) -> EncryptionState`. However, a new `async
fn latest_encryption_state(&self) -> Result<EncryptionState>` method
“restores” the previous behaviour by calling `request_encryption_state`
if necessary.

The idea is that the caller is now responsible to call
`request_encryption_state` if desired, or use `latest_encryption_state`
to automate the call if necessary. `encryption_state` is now non-async
and infallible everywhere.

`matrix-sdk-ffi` has been updated but no methods have been added for
the moment.
2025-03-11 12:28:16 +01:00
Stefan Ceriu
ea8664c487 Merge pull request #4780 from matrix-org/stefan/invitesRoomSummaryFallback
Invites room summary fallback
2025-03-11 11:02:23 +02:00
Stefan Ceriu
ca025f8cca feat(ffi): forget the room when rejecting invites
- we're doing this as an extra layer of protection against spam attacks.
2025-03-11 10:16:27 +02:00
Stefan Ceriu
78e19fce32 chore(sdk): rewrite the room summary fallback test on top of the MatrixMockServer 2025-03-11 09:22:29 +02:00
Andy Balaam
c8536e9e46 fix(crypto): Redecrypt non-UTD messages to remove no-longer-relevant warning shields (#4644)
Fixes https://github.com/element-hq/element-meta/issues/2697
Fixes https://github.com/element-hq/crypto-internal/issues/398

I'm sorry it's a big change. I've tried to break it into decent commits,
and I did a couple of preparatory PRs to make it less painful, but it's
still a bit to get your head around.

The basic idea is that when a session is updated and we call
`retry_event_decryption`, we don't only look at UTDs any more - now we
also look at decrypted events, and re-request their `EncryptionInfo`, in
case it has improved.

---------

Signed-off-by: Andy Balaam <mail@artificialworlds.net>
Co-authored-by: Richard van der Hoff <1389908+richvdh@users.noreply.github.com>
Co-authored-by: Benjamin Bouvier <benjamin@bouvier.cc>
2025-03-11 07:01:54 +00:00
Benjamin Bouvier
1caa6069db refactor(timeline): move is_utd() to TimelineItemContent
It's unusual to have the method on the parent type when the field type
could also hold the method. In fact, this was the only bool getter
inspecting the timeline's content, so let's move the method next to as
its siblings, for consistency, and let's spell it out fully for clarity.
2025-03-11 07:43:53 +01:00
Stefan Ceriu
abe8338e5c chore(ffi): expose a method for retrieving rooms based on their identifier 2025-03-10 19:11:59 +02:00
Stefan Ceriu
5373e39ce5 chore(ffi): remove now unnecessary invited_room and inviter methods as those should be retrieved through the room preview 2025-03-10 19:11:58 +02:00
Stefan Ceriu
5875973c13 feature(ffi): have previews for invited rooms fallback to cached client data if fetching the preview fails
- relates to element-hq/element-x-ios/issues/3713
- this will allow us to interact with them even if the given homeserver doesn't have MSC3266 enabled
2025-03-10 19:11:58 +02:00
dependabot[bot]
3fbf159d0e chore(deps): bump crate-ci/typos from 1.30.0 to 1.30.1
Bumps [crate-ci/typos](https://github.com/crate-ci/typos) from 1.30.0 to 1.30.1.
- [Release notes](https://github.com/crate-ci/typos/releases)
- [Changelog](https://github.com/crate-ci/typos/blob/master/CHANGELOG.md)
- [Commits](https://github.com/crate-ci/typos/compare/v1.30.0...v1.30.1)

---
updated-dependencies:
- dependency-name: crate-ci/typos
  dependency-type: direct:production
  update-type: version-update:semver-patch
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-03-10 16:38:20 +01:00
Kévin Commaille
b5c4fe3f7d test(sdk): Allow any MockEndpoint to override the expected access token
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-10 10:52:53 +01:00
Kévin Commaille
516d066d4c test(sdk): Add a constructor for MockEndpoint on MatrixMockServer
Allows to reduce duplication and will allow to add common logic.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-10 10:52:53 +01:00
Kévin Commaille
fbcd5a71aa test(sdk): Always call MockEndpoint::respond_with
Instead of MockBuilder::respond_with. This reduces duplcation and will
allow to add some common logic when building the endpoints.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-10 10:52:53 +01:00
Ivan Enderlin
b5a23086fd test(sdk): Add test for maybe_apply_new_redaction.
This patch adds a test for `maybe_apply_new_redaction` when the redacted
event is not loaded in-memory, i.e. when it lives in the store only.
2025-03-10 09:45:41 +01:00
Kévin Commaille
a9ce3f6963 chore: Add changelog for merging SessionTokens
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-10 09:12:38 +01:00
Kévin Commaille
a27f8f79a4 refactor(sdk): Move the session tokens into the AuthCtx
To avoid duplicating the code between both authentication APIs.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-10 09:12:38 +01:00
Kévin Commaille
dd01479c6b refactor(sdk): Use a single SessionTokens type
Since MatrixSessionTokens and OidcSessionTokens are identical.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-10 09:12:38 +01:00
dependabot[bot]
e7f85ba545 chore(deps): bump ring from 0.17.8 to 0.17.13
Bumps [ring](https://github.com/briansmith/ring) from 0.17.8 to 0.17.13.
- [Changelog](https://github.com/briansmith/ring/blob/main/RELEASES.md)
- [Commits](https://github.com/briansmith/ring/commits)

---
updated-dependencies:
- dependency-name: ring
  dependency-type: indirect
...

Signed-off-by: dependabot[bot] <support@github.com>
2025-03-10 09:41:43 +02:00
Andy Balaam
48767da6cc refactor(test): Make use of is_utd method in integration test 2025-03-07 14:20:45 +00:00
Andy Balaam
73754399be feat(timeline): Provide is_utd on EventTimelineItem 2025-03-07 14:20:45 +00:00
Kévin Commaille
18f5668e3e Add assertion messages
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-07 13:10:52 +01:00
Kévin Commaille
bc92e55b53 Improve tests
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-07 13:10:52 +01:00
Kévin Commaille
230feff430 test(sdk): Add tests for handle_refresh_tokens and Oidc
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-07 13:10:52 +01:00
Kévin Commaille
8bb4387dc4 fix(oidc): Match the proper error type for invalid refresh token
Since we do not use mas-oidc-client anymore, the error to match has changed.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-07 13:10:52 +01:00
Kévin Commaille
2506ba8364 refactor(oidc): Use oauth2 for token revocation
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-07 12:50:58 +01:00
Damir Jelić
daad6d662f fix(multiverse): Don't wait for sync service state changes when shutting down
The SyncService::stop method guarantees that the sync service will be
stopped after it has completed so there's no need to wait for state
changes.

The state change might not even come, if you pressed `S` to stop the
sync service manually.
2025-03-06 16:16:11 +01:00
Damir Jelić
53853c2d9a refactor(multiverse): Put the login logic into a separate function 2025-03-06 15:46:07 +01:00
Damir Jelić
40de714e81 refactor(multiverse): Use clap to simplify the CLI argument parsing 2025-03-06 15:46:07 +01:00
Damir Jelić
27bde16843 refactor(multiverse): Simplify the terminal and panic hook setups 2025-03-06 15:46:07 +01:00
Damir Jelić
5e8f8d5513 refactor(multiverse): Simplify the tracing setup 2025-03-06 15:46:07 +01:00
Damir Jelić
120970c4ea chore(multiverse): Bump the deps 2025-03-06 15:46:07 +01:00
Kévin Commaille
740e729606 docs(oidc): Document the arguments of url_for_oidc
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-06 12:27:30 +01:00
Kévin Commaille
60b140b684 chore: Add changelog for using oauth2
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-06 12:27:30 +01:00
Kévin Commaille
9a165468eb test(oidc): Add more checks for the authorization URL
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-06 12:27:30 +01:00
Kévin Commaille
e15897b3f1 refactor(oidc): Use oauth2 for authorization code grant
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-06 12:27:30 +01:00
Kévin Commaille
52f98582f1 refactor(oidc): Use oauth2 client for refreshing access tokens
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-06 12:27:30 +01:00
Kévin Commaille
2e72c23868 refactor(oidc): Move error types to the error module
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-06 12:27:30 +01:00
Kévin Commaille
0967027feb refactor(oidc): Use ClientId type from oauth2
Avoids to use 2 similar types with the same name.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-06 12:27:30 +01:00
Andy Balaam
6c9b1ef3c1 fix(common): Rename all snapshots in deserialized_responses to have shorter names matrix-sdk-ffi/20250306 2025-03-05 15:29:44 +00:00
Damir Jelić
8cceded0ae refactor(oidc): Move the fallback issuer discovery logic into a separate method 2025-03-05 15:37:04 +01:00
Jorge Martín
ff181475a0 fix(client): Add handle_verification_events field to BaseClient.
This is done to fix an issue with these events being received and processed twice when `NotificationProcessSetup` is `SingleProcess`, causing issues with user verification.

This can be used to ignore verification requests in this sliding sync instance, preventing issues found where several sliding sync instances with the same client process events simultaneously and re-process the same verification request events during their initial syncs.
2025-03-05 15:09:31 +01:00
Andy Balaam
074c0e59e0 fix(common): Shorten the name of the snapshot_test_encryption_info 2025-03-05 14:03:51 +00:00
Kévin Commaille
1d7c60c46a chore: Add changelog about ID tokens support removal
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-05 14:19:27 +01:00
Kévin Commaille
377f34fae2 refactor(oidc): Get rid of OidcBackend
Now that we don't use it for tests, we don't need it anymore.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-05 14:19:27 +01:00
Kévin Commaille
26cb805e0f test(oidc): Use MatrixMockServer in the remaining tests
Gets rid of the MockImpl for OidcBackend.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-05 14:19:27 +01:00
Kévin Commaille
81dbe2060c refactor(oidc): Remove support for ID tokens
ID tokens are a feature of OpenID Connect, we don't need them to support OAuth 2.0.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2025-03-05 14:19:27 +01:00
Ivan Enderlin
fd0fca436b chore(sdk): Remove the request_body instrument's field.
Many fields here are not argument of the `send` method, but are set
later with `Span::record`. Grepping all these fields reveal they are all
set except `request_body` apparently.
2025-03-05 14:15:29 +01:00
Ivan Enderlin
3d653d3fdc fix(sqlite): Design a new schema to get faster insertions.
This patch is twofold. First off, it provides a new schema allowing to
improve the performance of `SqliteEventCacheStore` for 100_000 events
from 6.7k events/sec to 284k events/sec on my machine.

Second, it now assumes that `EventCacheStore` does NOT store invalid
events. It was already the case, but the SQLite schema was not rejecting
invalid event in case some were handled. It's now explicitely forbidden.
2025-03-05 13:57:08 +01:00
Ivan Enderlin
b22bb3ee9f fix(sqlite): Use a prepared statement to insert events.
This patch uses a prepared statement to insert events in the linked
chunks. It offers more predictable performance, and SQLite prefers that.
2025-03-05 13:57:08 +01:00
Ivan Enderlin
7f17b4be7b bench: Add a benchmark for the LinkedChunk with the EventCacheStore. 2025-03-05 13:57:08 +01:00