matrix-org / matrix-org/matrix-rust-sdk

async support for ClientSessionDelegate in the FFI

Open
#4,516 3 comments 0 reactions 0 assignees View on GitHub
Dominant language
Rust
Stars
2.3k
Forks
500
Avg merge
1d 16h
Merged PRs (30d)
106

Description

At the moment the FFI bindings for interacting with the keychain are both blocking (non-async) functions. Unfortunately the host language I am using this with (react-native) features an async keychain, presenting some challenges, especially with 'reloading' the keychain when dealing with OIDC locks.

I've locally made a change to use an async_trait here and it seems to be working just fine. It required some adjustment of the traits in matrix_sdk::authentication as well since async functions cannot be passed quite as easily, but its not too bad.

```
#[matrix_sdk_ffi_macros::export(callback_interface)]
#[async_trait::async_trait]
pub trait ClientSessionDelegate: Sync + Send {
async fn retrieve_session_from_keychain(&self, user_id: String)
-> Result;
async fn save_session_in_keychain(&self, session: Session);
}
```

Would be happy to package this up and merge it if there is appetite for such a change.

Contributor guide

Open the contributing guide

Research direction

Start by locating the FFI ClientSessionDelegate and then read the related traits in matrix_sdk::authentication. Check how the async_trait change affects session retrieval and saving from the react-native host; done means both keychain operations can be called asynchronously through the FFI without breaking the adjusted authentication traits.

Written by the indexing model from the issue text.

Assessment

Tech stack
react-native, rust
Domain
authentication, mobile-dev
Issue type
Feature
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.