Commit Graph

2231 Commits

Author SHA1 Message Date
Kévin Commaille
856dd01009 Upgrade http, ruma, reqwest and wiremock dependencies (#3362)
They need to be updated together
because the latters depend on the former.

matrix-authentication-service is still using http 0.2
so we need to add a conversion layer between both major versions
for OIDC requests.

We need to update vodozemac too because of a dependency resolution issue.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2024-04-30 14:04:56 +02:00
Kévin Commaille
ea1a01000f sdk: Use the GET /auth_issuer endpoint for OIDC
The well-known method is deprecated.

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2024-04-30 12:33:31 +02:00
Doug
4618d7ca7d ffi: Allow creation of a matrix.to link for any room alias. 2024-04-29 12:00:36 +02:00
Ivan Enderlin
25f893b0bb Merge branch 'main' into bnjbvr/permalink-mvp 2024-04-25 16:02:23 +02:00
Andy Balaam
415617080a Merge pull request #3337 from matrix-org/andybalaam/utd-type-info
crypto: UtdCause enum in reporting hooks and encryption event
2024-04-25 08:55:50 +01:00
Andy Balaam
2c7afc201f Merge pull request #3326 from matrix-org/andybalaam/allow-setting-encryption-settings
ffi: Expose encryption settings via FFI
2024-04-25 08:55:43 +01:00
Andy Balaam
89abb75d4d crypto: Include UTD cause in FFI EncryptedMessage 2024-04-24 12:16:17 +01:00
Benjamin Bouvier
397a26e00b ffi: add bindings for the timeline focus mode and associated functions 2024-04-23 19:02:59 +02:00
Andy Balaam
ebcf1c434c ffi: Expose encryption_settings via FFI 2024-04-23 15:45:29 +01:00
Andy Balaam
b5e2eb6831 crypto: Add a UtdCause and code to determine it for membership 2024-04-23 15:44:39 +01:00
Benjamin Bouvier
d9864373f3 timeline: add the ability to set a prefix for internal IDs 2024-04-23 13:19:32 +02:00
Benjamin Bouvier
e4331ac9b8 timeline: use a string instead of a u64 to identify timeline items
This will allow to define a prefix later, to distinguish detached
timelines from live timelines.
2024-04-23 13:19:32 +02:00
Benjamin Bouvier
5916192fb6 ffi: don't abort RoomInfo creation if the room member invite event is missing
`Room::invite_details()` can return an error if the room member event
(the invite) is missing from the store. Usually that would be a sign
that the state is semi-broken, since there should always be such an
event for an invited room. But if it's missing, it shouldn't break the
creation of a `RoomInfo`, and just be missing from the struct.
2024-04-23 11:05:44 +02:00
Benjamin Bouvier
90c35b6b34 room preview: add support for MSC3266, room summary 2024-04-22 14:55:47 +02:00
Andy Balaam
1f524f2dec Merge pull request #3327 from matrix-org/andybalaam/expose-wait-e2ee
ffi: Expose Encryption::wait_for_e2ee_initialization_tasks
2024-04-19 11:26:06 +01:00
Benjamin Bouvier
f322dcd200 sdk: give the ability to get a room's preview 2024-04-18 11:29:24 +02:00
Andy Balaam
8a313df6a4 ffi: Expose Encryption::wait_for_e2ee_initialization_tasks 2024-04-12 14:20:17 +01:00
Stefan Ceriu
e12f917559 ffi: expose method for parsing Matrix URIs and converting them into actual Matrix entities 2024-04-11 16:27:20 +02:00
Stefan Ceriu
20f0346733 ffi: expose method for genering user matrix.to permalinks 2024-04-11 16:27:20 +02:00
Kévin Commaille
8a8ad22961 ffi: Use async functions in AuthenticationService (#3294)
* ffi: Use async functions in AuthenticationService
* Fix swift tests
* Set async_runtime for uniffi::export attribute
* Rename RwLocks
* Get rid of unnecessary map_err

---------

Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2024-04-04 15:54:20 +00:00
Stefan Ceriu
682c17c9d8 feat: add support for storing breacrumbs in the state store 2024-04-04 11:23:55 +02:00
Kévin Commaille
da2abccc0d chore: Disable clippy::assigning_clones lint
Signed-off-by: Kévin Commaille <zecakeh@tedomum.fr>
2024-04-02 15:05:41 +02:00
Stefan Ceriu
29f7f88a2c ffi: expose room and event matrix.to permalink builder methods 2024-04-02 10:35:23 +02:00
Thomas
95a471b0d2 ffi: Expose discovered sliding sync proxy URL (#3266)
Closes #3265.

There is currently no way to get the URL of a homeserver's sliding sync proxy before logging in on the homeserver.

I suggest exposing the URL via the `HomeserverLoginDetail` struct after configuring the homeserver (through `configure_homeserver`).

Since the homeserver may not declare a corresponding sliding sync proxy, this value is an `Optional`. It is used later in `configure_homeserver` to check if a sliding sync proxy exists and throws an error otherwise. Previously, this check was done against the client's `discovered_sliding_sync_proxy` function.

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

Signed-off-by: Thomas Völkl <thomas@vollkorntomate.de>
Signed-off-by: Benjamin Bouvier <public@benj.me>
Co-authored-by: Benjamin Bouvier <public@benj.me>
2024-03-22 17:21:24 +00:00
Hubert Chathi
8d968604e9 chore: Update Ruma to version that uses web-time crate (#3264) 2024-03-22 12:30:19 +01:00
Ivan Enderlin
daaf17198c Merge pull request #3257 from Hywan/fix-issue-3213
doc(crypto-ffi): `Device::first_time_seen_ts` has an incorrect unit
2024-03-21 16:24:03 +01:00
Ivan Enderlin
7df31406dc feat(bindings): added join room by id to ffi
feat(bindings): added join room by id to ffi
2024-03-21 12:18:33 +01:00
Mauro Romito
d447f63e33 fixed invalid parsing 2024-03-21 11:53:44 +01:00
Kegan Dougal
c13fb7e19f uniffi: wrap TaskHandle up in an Arc<>
Up until uniffi 0.26 it was not possible to send objects
across the boundary unless they were wrapped in an `Arc<>`,
see https://github.com/mozilla/uniffi-rs/pull/1672

The bindings generator used in complement-crypto only supports
up to uniffi 0.25, meaning having a function which returns objects
ends up erroring with:
```
error[E0277]: the trait bound `TaskHandle: LowerReturn<UniFfiTag>` is not satisfied
   --> bindings/matrix-sdk-ffi/src/room_directory_search.rs:109:10
    |
109 |     ) -> TaskHandle {
    |          ^^^^^^^^^^ the trait `LowerReturn<UniFfiTag>` is not implemented for `TaskHandle`
    |
    = help: the following other types implement trait `LowerReturn<UT>`:
              <bool as LowerReturn<UT>>
              <i8 as LowerReturn<UT>>
              <i16 as LowerReturn<UT>>
              <i32 as LowerReturn<UT>>
              <i64 as LowerReturn<UT>>
              <u8 as LowerReturn<UT>>
              <u16 as LowerReturn<UT>>
              <u32 as LowerReturn<UT>>
            and 133 others

error[E0277]: the trait bound `TaskHandle: LowerReturn<_>` is not satisfied
   --> bindings/matrix-sdk-ffi/src/room_directory_search.rs:82:1
    |
82  | #[uniffi::export(async_runtime = "tokio")]
    | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `LowerReturn<_>` is not implemented for `TaskHandle`
    |
    = help: the following other types implement trait `LowerReturn<UT>`:
              <bool as LowerReturn<UT>>
              <i8 as LowerReturn<UT>>
              <i16 as LowerReturn<UT>>
              <i32 as LowerReturn<UT>>
              <i64 as LowerReturn<UT>>
              <u8 as LowerReturn<UT>>
              <u16 as LowerReturn<UT>>
              <u32 as LowerReturn<UT>>
            and 133 others
```

This PR wraps the offending function in an `Arc<>` to make it uniffi 0.25 compatible,
which unbreaks complement crypto.
2024-03-21 10:40:37 +00:00
Mauro Romito
17805cbcd8 feat(bindings): added join room by id to ffi 2024-03-21 11:39:04 +01:00
hanadi92
36c39b837a refactor: create a pusher manager to set and delete
Signed-off-by: hanadi92 <hanadi.tamimi@gmail.com>
2024-03-21 09:53:43 +01:00
hanadi92
b83a644260 fix: use async instead of block on runtime
Signed-off-by: hanadi92 <hanadi.tamimi@gmail.com>
2024-03-21 09:53:43 +01:00
hanadi92
7c4d180297 ffi: add delete_pusher method
Signed-off-by: hanadi92 <hanadi.tamimi@gmail.com>
2024-03-21 09:53:43 +01:00
Ivan Enderlin
ae170362a5 doc(crypto-ffi): Device::first_time_seen_ts has an incorrect unit.
This patch changes seconds to milliseconds for the description of
`Device::first_time_seen_ts`.
2024-03-21 09:05:30 +01:00
Ivan Enderlin
8eafaa58fb Merge pull request #3169 from matrix-org/mauroromito/directory_search
Room Directory Search
2024-03-20 15:43:18 +01:00
Damir Jelić
3ccd2e9f8f crypto: Remove the KeysBackup variant of the OutgoingRequest enum
Backing up room keys isn't part of the outgoing requests processing
loop, instead the user is supposed to have a separate loop calling
`BackupMachine::backup()`.
2024-03-19 16:23:13 +01:00
Hubert Chathi
1e35188aec Add a dehydrated flag to device_keys of dehydrated devices (#3164)
Signed-off-by: Hubert Chathi <hubert@uhoreg.ca>
Co-authored-by: Damir Jelić <poljar@termina.org.uk>
2024-03-19 14:33:13 +00:00
Benjamin Bouvier
c6da40cf55 ffi: bump opentelemetry crates
This gets rid of multiple duplicate crates in the dependency tree.
2024-03-19 14:21:59 +01:00
Damir Jelić
c59465c54c crypto: Rotate fallback keys in a time-based manner (#3151)
Fallback keys until now have been rotated on the basis that the
homeserver tells us that a fallback key has been used.

Now this leads to various problems if the server tells us too often that
it has been used, i.e. if we receive the same sync response too often.
It leaves us also open to the homeserver being dishonest and never
telling us that the fallback key has been used.

Let's avoid all these problems by just rotating the fallback key in a
time-based manner.

Signed-off-by: Damir Jelić <poljar@termina.org.uk>
Co-authored-by: Andy Balaam <andy.balaam@matrix.org>
2024-03-19 13:16:37 +01:00
Jorge Martin Espinosa
0c4b62f664 sdk: move get_profile from Client to Account (#3238)
This also renames and streamlines the existing `Account::get_profile` function to `Account::fetch_profile` which now calls the more general function.
2024-03-19 12:03:32 +00:00
Marco Antonio Alvarez
10069fbead MSC2530: added the ability to send media with captions (#3226)
Now that there is some support for [MSC2530](https://github.com/matrix-org/matrix-spec-proposals/pull/2530), I gave adding sending captions a try. ( This is my first time with Rust 😄  )

I tried it on Element X with a hardcoded caption and it seems to work well
![image](https://github.com/matrix-org/matrix-rust-sdk/assets/683652/597e5ebf-f7f2-498f-97a4-ac98613c1134)

(It even got forwarded through mautrix-whatsapp and the caption was visible on the Whatsapp side)

---

* ffi: Expose filename and formatted body fields for media captions

In relevance to MSC2530

* MSC2530: added the ability to send media with captions

Signed-off-by: Marco Antonio Alvarez <surakin@gmail.com>

* signoff

Signed-off-by: Marco Antonio Alvarez <surakin@gmail.com>

* fixing the import messup

* fix missing parameters in documentation

* fix formatting

* move optional parameters to the end

* more formatting fixes

* more formatting fixes

* rename url parameter to filename in send_attachment and helpers

* fix send_attachment documentation example

* move caption and formatted_caption into attachmentconfig

* fix formatting

* fix formatting

* fix formatting (hopefully the last one)

* updated stale comments

* simplify attachment message comments

---------

Signed-off-by: Marco Antonio Alvarez <surakin@gmail.com>
Co-authored-by: SpiritCroc <dev@spiritcroc.de>
2024-03-19 11:08:47 +01:00
Mauro
655ac0725c Merge branch 'main' into mauroromito/directory_search 2024-03-14 17:56:23 +01:00
SpiritCroc
2520804a60 ffi: Expose filename and formatted body fields for media captions
In relevance to MSC2530
2024-03-14 14:43:03 +01:00
Benjamin Bouvier
73684ab57c ui/timeline: allow subscribing to UTDs and late-decrypt events (#3206)
This adds a new mechanism in the UI crate (since re-attempts to decrypt happen in the timeline, as of today — later that'll happen in the event cache) to notify whenever we run into a UTD (an event couldn't be decrypted) or a late-decryption event (after some time, a UTD could be decrypted).

This new hook will deduplicate pings for the same event (identifying events on their event id), and also implements an optional grace period. If an event was a UTD:

- if it's still a UTD after the grace period, then it's reported with a `None` `time_to_decrypt`,
- if it's not a UTD anymore (i.e. it's been decrypted in the meanwhile), then it's reported with a `time_to_decrypt` set to the time it took to decrypt the event (approximate, since it starts counting from the time the timeline receives it, not the time the SDK fails to decrypt it at first).

It's configurable as an optional hook on timeline builders. For the FFI, it's configurable at the sync service's level with a "delegate", and then the sync service will forward the hook to the timelines it creates, and the hook will forward the UTD info to the delegate.

Part of https://github.com/element-hq/element-meta/issues/2300.

---

* ui: add a new module and trait for subscribing to unable-to-decrypt notifications

and late decryptions (i.e. the key came in after the event that required it for decryption).

* timeline: hook in (!) the unable-to-decrypt hook

* timeline: prefix some test names with test_

* utd hook: delay reporting a UTDs

* ffi: add support for configuring the utd hook

* utd hook: switch strategy, have a single hook

And have the data structure contain extra information about late-decryption events.

* utd hook: rename `SmartUtdHook` to `UtdHookManager`

* ffi: configure the UTD hook with a grace period of 60 seconds

And ignore UTDs that have been late-decrypted in less than 4 seconds.

* utd hook: update documentation and satisfy the clippy gods

* ffi: introduce another UnableToDecryptInfo FFI struct that exposes simplified fields from the SDK's version

* review: introduce type alias for pending utd reports

* review: address other review comments
2024-03-14 14:13:44 +01:00
Mauro
5e692931dd Apply suggestions from code review
Co-authored-by: Ivan Enderlin <ivan@mnt.io>
Signed-off-by: Mauro <34335419+Velin92@users.noreply.github.com>
2024-03-14 10:42:27 +01:00
Mauro Romito
a52a2329a1 pr suggestions
improved the conversion by using a try from and changed the nex_token to a search state to indicate the current state of the search
2024-03-13 12:43:26 +01:00
Ivan Enderlin
6f9147de86 Merge pull request #3205 from matrix-org/stefan/invites_main_room_list
feat: Expose a room list filter for Invites only
2024-03-13 11:43:10 +01:00
Stefan Ceriu
eea475854c feat: Expose a verification state listener directly from Encryption 2024-03-12 14:36:05 +01:00
Stefan Ceriu
16dcfb2e84 feat: Expose a room list filter for Invites only 2024-03-11 17:41:28 +02:00
Mauro
9ef78a484c Merge branch 'main' into mauroromito/directory_search 2024-03-11 16:30:55 +01:00