bg bugfix
This commit is contained in:
1 parent
7eace57528
commit
c30fddb1ef
14 files changed
+3809
-12
No files matched your search
@@ -304,6 +304,26 @@ let mut events = client.subscribe(); // Strea
|
|||||||
* Arrêter la tâche abandonne le long-poll en cours. Ses acks n'ont pas été confirmés : ils
|
* Arrêter la tâche abandonne le long-poll en cours. Ses acks n'ont pas été confirmés : ils
|
||||||
seront simplement renvoyés (ils sont idempotents).
|
seront simplement renvoyés (ils sont idempotents).
|
||||||
|
|
||||||
|
### 5.4 Liaison Flutter (`meow-ffi`)
|
||||||
|
|
||||||
|
* La crate `meow-ffi` (cdylib) est générée par `flutter_rust_bridge` **2.13.0**, épinglée des
|
||||||
|
deux côtés. La configuration se trouve dans `../bastet/flutter_rust_bridge.yaml`, le Dart
|
||||||
|
généré dans `../bastet/lib/src/rust/`. On ne modifie jamais `frb_generated.*`.
|
||||||
|
* Côté Dart, un objet opaque `Meow` représente une identité ouverte, qui se synchronise
|
||||||
|
toujours en tâche de fond. Ses méthodes sont `async` et reprennent celles du client ; les
|
||||||
|
données circulent sous forme de vues simples (`ContactView`, `MessageView`,
|
||||||
|
`HistoryPageView`…). `events()` renvoie un `Stream<MeowEvent>` (classes scellées, `freezed`).
|
||||||
|
* Tous les appels s'exécutent sur un runtime tokio propre à la crate, quel que soit l'exécuteur
|
||||||
|
de flutter_rust_bridge, car HTTP, minuteries et tâche de fond ont besoin de tokio.
|
||||||
|
* Le flux d'événements se termine quand on appelle `close()`. Il faut fermer l'identité *avant*
|
||||||
|
d'annuler l'abonnement Dart : une annulation n'aboutit qu'une fois le flux fermé côté Rust.
|
||||||
|
* La tâche de fond relance son attente (ou son long-poll) dès que l'état change (nouveau
|
||||||
|
contact, espace déverrouillé, message mis en file), grâce à un compteur `watch` incrémenté à
|
||||||
|
chaque sauvegarde.
|
||||||
|
* Tests : `scripts/ffi-test.sh` régénère le code, construit la bibliothèque et `meowsrv`, puis
|
||||||
|
lance `flutter test test/meow_ffi_test.dart` (deux identités, un vrai serveur, tout passe
|
||||||
|
par les événements).
|
||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
## 6. Stockage client (`meow-store`)
|
## 6. Stockage client (`meow-store`)
|
||||||
|
|||||||
@@ -12,12 +12,15 @@ no wire compatibility with the Go v1 stack.
|
|||||||
```bash
|
```bash
|
||||||
scripts/check.sh # fmt --check, clippy -D warnings, cargo test --workspace
|
scripts/check.sh # fmt --check, clippy -D warnings, cargo test --workspace
|
||||||
tests/e2e.sh # full CLI + 2 servers scenario; E2E_STORAGE=redis://... for Redis
|
tests/e2e.sh # full CLI + 2 servers scenario; E2E_STORAGE=redis://... for Redis
|
||||||
|
scripts/ffi-test.sh # regenerate Dart bindings (flutter_rust_bridge 2.13.0) + Dart tests in ../bastet
|
||||||
```
|
```
|
||||||
|
|
||||||
## Rules
|
## Rules
|
||||||
|
|
||||||
* `meow-core` does no I/O and takes time as a parameter. Keep it that way.
|
* `meow-core` does no I/O and takes time as a parameter. Keep it that way.
|
||||||
* No `unsafe` (except the future `meow-ffi`); no `unwrap`/`expect` in library code outside tests.
|
* No `unsafe` (except the generated `meow-ffi/src/frb_generated.rs`, never edited by hand); no
|
||||||
|
`unwrap`/`expect` in library code outside tests.
|
||||||
|
* `meow-ffi/src/api/` is the Dart API: after changing it, run `scripts/ffi-test.sh`.
|
||||||
* Persist ratchet/contact state **before** sending the resulting bytes.
|
* Persist ratchet/contact state **before** sending the resulting bytes.
|
||||||
* `proto/meow.proto` is the single wire schema (compiled by protox, no protoc needed). Bump/extend, never renumber.
|
* `proto/meow.proto` is the single wire schema (compiled by protox, no protoc needed). Bump/extend, never renumber.
|
||||||
* Never log keys, mailbox ids or message content at `info` level.
|
* Never log keys, mailbox ids or message content at `info` level.
|
||||||
Generated
+356
@@ -2,6 +2,21 @@
|
|||||||
# It is not intended for manual editing.
|
# It is not intended for manual editing.
|
||||||
version = 4
|
version = 4
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "addr2line"
|
||||||
|
version = "0.27.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e567177890eb1617b1f774005b66b26b2377afd138a2ca37aae7d8f0c81429d4"
|
||||||
|
dependencies = [
|
||||||
|
"gimli",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "adler2"
|
||||||
|
version = "2.0.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "320119579fcad9c21884f5c4861d16174d0e06250625266f50fe6898340abefa"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "aead"
|
name = "aead"
|
||||||
version = "0.5.2"
|
version = "0.5.2"
|
||||||
@@ -21,6 +36,34 @@ dependencies = [
|
|||||||
"memchr",
|
"memchr",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "allo-isolate"
|
||||||
|
version = "0.1.27"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "449e356a4864c017286dbbec0e12767ea07efba29e3b7d984194c2a7ff3c4550"
|
||||||
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
|
"atomic",
|
||||||
|
"backtrace",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "android_log-sys"
|
||||||
|
version = "0.3.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "84521a3cf562bc62942e294181d9eef17eb38ceb8c68677bc49f144e4c3d4f8d"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "android_logger"
|
||||||
|
version = "0.15.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "dbb4e440d04be07da1f1bf44fb4495ebd58669372fe0cffa6e48595ac5bd88a3"
|
||||||
|
dependencies = [
|
||||||
|
"android_log-sys",
|
||||||
|
"env_filter",
|
||||||
|
"log",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "anstream"
|
name = "anstream"
|
||||||
version = "1.0.0"
|
version = "1.0.0"
|
||||||
@@ -100,6 +143,12 @@ dependencies = [
|
|||||||
"syn 3.0.10",
|
"syn 3.0.10",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "atomic"
|
||||||
|
version = "0.5.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "c59bdb34bc650a32731b31bd8f0829cc15d24a708ee31559e0bb34f2bc320cba"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "atomic-waker"
|
name = "atomic-waker"
|
||||||
version = "1.1.2"
|
version = "1.1.2"
|
||||||
@@ -164,6 +213,21 @@ dependencies = [
|
|||||||
"tracing",
|
"tracing",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "backtrace"
|
||||||
|
version = "0.3.77"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "42f4220217f3288537b83684130f42fad43320b1c3b805f1910d683d52ded24f"
|
||||||
|
dependencies = [
|
||||||
|
"addr2line",
|
||||||
|
"cfg-if",
|
||||||
|
"libc",
|
||||||
|
"miniz_oxide",
|
||||||
|
"object",
|
||||||
|
"rustc-demangle",
|
||||||
|
"windows-link",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "base64"
|
name = "base64"
|
||||||
version = "0.22.1"
|
version = "0.22.1"
|
||||||
@@ -212,12 +276,30 @@ dependencies = [
|
|||||||
"generic-array",
|
"generic-array",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "build-target"
|
||||||
|
version = "0.4.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "832133bbabbbaa9fbdba793456a2827627a7d2b8fb96032fa1e7666d7895832b"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bumpalo"
|
name = "bumpalo"
|
||||||
version = "3.20.4"
|
version = "3.20.4"
|
||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "87a0cf66fd1eb2fb7b822cb78370d82303750809bc6ba855f3f58e517d3238db"
|
checksum = "87a0cf66fd1eb2fb7b822cb78370d82303750809bc6ba855f3f58e517d3238db"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "bytemuck"
|
||||||
|
version = "1.25.2"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "95832e849adfb21180ccb6826a99da14e5d266ae5c2e668e1602cf234f153797"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "byteorder"
|
||||||
|
version = "1.5.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "bytes"
|
name = "bytes"
|
||||||
version = "1.12.2"
|
version = "1.12.2"
|
||||||
@@ -361,6 +443,16 @@ dependencies = [
|
|||||||
"tokio-util",
|
"tokio-util",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "console_error_panic_hook"
|
||||||
|
version = "0.1.7"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a06aeb73f470f66dcdbf7223caeebb85984942f22f1adb2a088cf9668146bbbc"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"wasm-bindgen",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "const-oid"
|
name = "const-oid"
|
||||||
version = "0.9.6"
|
version = "0.9.6"
|
||||||
@@ -423,6 +515,39 @@ dependencies = [
|
|||||||
"syn 2.0.119",
|
"syn 2.0.119",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "dart-sys"
|
||||||
|
version = "4.1.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "57967e4b200d767d091b961d6ab42cc7d0cc14fe9e052e75d0d3cf9eb732d895"
|
||||||
|
dependencies = [
|
||||||
|
"cc",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "dashmap"
|
||||||
|
version = "5.5.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "978747c1d849a7d2ee5e8adc0159961c48fb7e5db2f06af6723b80123bb53856"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"hashbrown 0.14.5",
|
||||||
|
"lock_api",
|
||||||
|
"once_cell",
|
||||||
|
"parking_lot_core",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "delegate-attr"
|
||||||
|
version = "0.3.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "a84c9a9c129b98e707ac9a31e204c10c064dd9f949b7da362310ff1a8b137d79"
|
||||||
|
dependencies = [
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 3.0.10",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "der"
|
name = "der"
|
||||||
version = "0.7.10"
|
version = "0.7.10"
|
||||||
@@ -498,6 +623,16 @@ version = "0.6.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "edd0f118536f44f5ccd48bcb8b111bdc3de888b58c74639dfb034a357d0f206d"
|
checksum = "edd0f118536f44f5ccd48bcb8b111bdc3de888b58c74639dfb034a357d0f206d"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "env_filter"
|
||||||
|
version = "0.1.4"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1bf3c259d255ca70051b30e2e95b5446cdb8949ac4cd22c0d7fd634d89f568e2"
|
||||||
|
dependencies = [
|
||||||
|
"log",
|
||||||
|
"regex",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "equivalent"
|
name = "equivalent"
|
||||||
version = "1.0.3"
|
version = "1.0.3"
|
||||||
@@ -550,6 +685,48 @@ version = "0.5.9"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "5905ec755cc8386d7928353e4d356d2be3e89e81e5ca01fe630a1ca4d08dc175"
|
checksum = "5905ec755cc8386d7928353e4d356d2be3e89e81e5ca01fe630a1ca4d08dc175"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "flutter_rust_bridge"
|
||||||
|
version = "2.13.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "24a973d15b8fc7de9fb29cdfbec58a2ac41f6252492d3b882abfdc603e32b34f"
|
||||||
|
dependencies = [
|
||||||
|
"allo-isolate",
|
||||||
|
"android_logger",
|
||||||
|
"anyhow",
|
||||||
|
"build-target",
|
||||||
|
"bytemuck",
|
||||||
|
"byteorder",
|
||||||
|
"console_error_panic_hook",
|
||||||
|
"dart-sys",
|
||||||
|
"delegate-attr",
|
||||||
|
"flutter_rust_bridge_macros",
|
||||||
|
"futures",
|
||||||
|
"js-sys",
|
||||||
|
"lazy_static",
|
||||||
|
"log",
|
||||||
|
"oslog",
|
||||||
|
"portable-atomic",
|
||||||
|
"threadpool",
|
||||||
|
"tokio",
|
||||||
|
"wasm-bindgen",
|
||||||
|
"wasm-bindgen-futures",
|
||||||
|
"web-sys",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "flutter_rust_bridge_macros"
|
||||||
|
version = "2.13.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "901eec2d226107dad1c55b30f7421c4687bebcf70ed43ca44d1b447ca087b238"
|
||||||
|
dependencies = [
|
||||||
|
"hex",
|
||||||
|
"md-5",
|
||||||
|
"proc-macro2",
|
||||||
|
"quote",
|
||||||
|
"syn 2.0.119",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "fnv"
|
name = "fnv"
|
||||||
version = "1.0.7"
|
version = "1.0.7"
|
||||||
@@ -577,6 +754,21 @@ dependencies = [
|
|||||||
"percent-encoding",
|
"percent-encoding",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "futures"
|
||||||
|
version = "0.3.34"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "9a31d2a3fbaaeb2af2368bbdd904aa8e812d3c04a1ee10d3171f52d556e5d0a3"
|
||||||
|
dependencies = [
|
||||||
|
"futures-channel",
|
||||||
|
"futures-core",
|
||||||
|
"futures-executor",
|
||||||
|
"futures-io",
|
||||||
|
"futures-sink",
|
||||||
|
"futures-task",
|
||||||
|
"futures-util",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "futures-channel"
|
name = "futures-channel"
|
||||||
version = "0.3.34"
|
version = "0.3.34"
|
||||||
@@ -584,6 +776,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
|
|||||||
checksum = "b1f9e3d69d39e4862ffed03ed071a76f9a13ba1d9109d355b0f0aa6b15e393c4"
|
checksum = "b1f9e3d69d39e4862ffed03ed071a76f9a13ba1d9109d355b0f0aa6b15e393c4"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
"futures-core",
|
"futures-core",
|
||||||
|
"futures-sink",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@@ -592,6 +785,23 @@ version = "0.3.34"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e"
|
checksum = "92d699e522242e69e3003b94ecc1f960f3a5e015aa7c5d7486e65ad01dd94f5e"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "futures-executor"
|
||||||
|
version = "0.3.34"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "031b47cf1a3c6cc8bc2fc76cd437f521619387907d469316e7c0bc278f1f5432"
|
||||||
|
dependencies = [
|
||||||
|
"futures-core",
|
||||||
|
"futures-task",
|
||||||
|
"futures-util",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "futures-io"
|
||||||
|
version = "0.3.34"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "53c0fa8157de1303bfffdaa1cc2a673bfffb60102f76b0ef4441659124373fed"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "futures-macro"
|
name = "futures-macro"
|
||||||
version = "0.3.34"
|
version = "0.3.34"
|
||||||
@@ -621,10 +831,13 @@ version = "0.3.34"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc"
|
checksum = "0d50a92467f8ba5dd6e3ee5d4bd04d73ab2e4e1c44474a0674821dfce14b79bc"
|
||||||
dependencies = [
|
dependencies = [
|
||||||
|
"futures-channel",
|
||||||
"futures-core",
|
"futures-core",
|
||||||
|
"futures-io",
|
||||||
"futures-macro",
|
"futures-macro",
|
||||||
"futures-sink",
|
"futures-sink",
|
||||||
"futures-task",
|
"futures-task",
|
||||||
|
"memchr",
|
||||||
"pin-project-lite",
|
"pin-project-lite",
|
||||||
"slab",
|
"slab",
|
||||||
]
|
]
|
||||||
@@ -666,6 +879,18 @@ dependencies = [
|
|||||||
"wasm-bindgen",
|
"wasm-bindgen",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "gimli"
|
||||||
|
version = "0.34.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "1033caf0b349c518623b5396bfb2cf0bddf44f0306d543a250e5743297aafd10"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hashbrown"
|
||||||
|
version = "0.14.5"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hashbrown"
|
name = "hashbrown"
|
||||||
version = "0.15.5"
|
version = "0.15.5"
|
||||||
@@ -699,6 +924,18 @@ version = "0.5.0"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
checksum = "2304e00983f87ffb38b55b444b5e3b60a884b5d30c0fca7d82fe33449bbe55ea"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hermit-abi"
|
||||||
|
version = "0.5.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "e17592d60ebacc7d5e169f4663c5f84f9161cc90328abcfe8456f41e4dfcb284"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "hex"
|
||||||
|
version = "0.4.3"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "7f24254aa9a54b5c858eaee2f5bccdb46aaf0e486a595ed5fd8f86ba55232a70"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "hkdf"
|
name = "hkdf"
|
||||||
version = "0.12.4"
|
version = "0.12.4"
|
||||||
@@ -1018,6 +1255,15 @@ version = "0.8.3"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "47d9d19d1d6efa0109d2f65ff4c85cddd50bd572e5a00127ab10987290bcefae"
|
checksum = "47d9d19d1d6efa0109d2f65ff4c85cddd50bd572e5a00127ab10987290bcefae"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "lock_api"
|
||||||
|
version = "0.4.14"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "224399e74b87b5f3557511d98dff8b14089b3dadafcab6bb93eab67d3aace965"
|
||||||
|
dependencies = [
|
||||||
|
"scopeguard",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "log"
|
name = "log"
|
||||||
version = "0.4.35"
|
version = "0.4.35"
|
||||||
@@ -1111,6 +1357,16 @@ version = "0.8.4"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "47e1ffaa40ddd1f3ed91f717a33c8c0ee23fff369e3aa8772b9605cc1d22f4c3"
|
checksum = "47e1ffaa40ddd1f3ed91f717a33c8c0ee23fff369e3aa8772b9605cc1d22f4c3"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "md-5"
|
||||||
|
version = "0.10.6"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d89e7ee0cfbedfc4da3340218492196241d89eefb6dab27de5df917a6d2e78cf"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"digest",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "memchr"
|
name = "memchr"
|
||||||
version = "2.8.3"
|
version = "2.8.3"
|
||||||
@@ -1176,6 +1432,18 @@ dependencies = [
|
|||||||
"zeroize",
|
"zeroize",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "meow-ffi"
|
||||||
|
version = "0.2.0"
|
||||||
|
dependencies = [
|
||||||
|
"anyhow",
|
||||||
|
"flutter_rust_bridge",
|
||||||
|
"meow-client",
|
||||||
|
"meow-crypto",
|
||||||
|
"tokio",
|
||||||
|
"tracing",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "meow-proto"
|
name = "meow-proto"
|
||||||
version = "0.2.0"
|
version = "0.2.0"
|
||||||
@@ -1249,6 +1517,15 @@ version = "0.3.18"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "d5848f5a9e8117cf94f2f90faac24a87ff81600ff8628c1e3deaab572e76bfa1"
|
checksum = "d5848f5a9e8117cf94f2f90faac24a87ff81600ff8628c1e3deaab572e76bfa1"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "miniz_oxide"
|
||||||
|
version = "0.9.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b63fbc4a50860e98e7b2aa7804ded1db5cbc3aff9193adaff57a6931bf7c4b4c"
|
||||||
|
dependencies = [
|
||||||
|
"adler2",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "mio"
|
name = "mio"
|
||||||
version = "1.2.5"
|
version = "1.2.5"
|
||||||
@@ -1303,6 +1580,25 @@ dependencies = [
|
|||||||
"autocfg",
|
"autocfg",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "num_cpus"
|
||||||
|
version = "1.17.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "91df4bbde75afed763b708b7eee1e8e7651e02d97f6d5dd763e89367e957b23b"
|
||||||
|
dependencies = [
|
||||||
|
"hermit-abi",
|
||||||
|
"libc",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "object"
|
||||||
|
version = "0.40.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "dd229a0361b9d0d4396176e02d65897f487eebeab7caa6d443855ee152ca0b9c"
|
||||||
|
dependencies = [
|
||||||
|
"memchr",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "once_cell"
|
name = "once_cell"
|
||||||
version = "1.21.4"
|
version = "1.21.4"
|
||||||
@@ -1321,6 +1617,30 @@ version = "0.3.1"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381"
|
checksum = "c08d65885ee38876c4f86fa503fb49d7b507c2b62552df7c70b2fce627e06381"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "oslog"
|
||||||
|
version = "0.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "80d2043d1f61d77cb2f4b1f7b7b2295f40507f5f8e9d1c8bf10a1ca5f97a3969"
|
||||||
|
dependencies = [
|
||||||
|
"cc",
|
||||||
|
"dashmap",
|
||||||
|
"log",
|
||||||
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "parking_lot_core"
|
||||||
|
version = "0.9.12"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "2621685985a2ebf1c516881c026032ac7deafcda1a2c9b7850dc81e3dfcb64c1"
|
||||||
|
dependencies = [
|
||||||
|
"cfg-if",
|
||||||
|
"libc",
|
||||||
|
"redox_syscall",
|
||||||
|
"smallvec",
|
||||||
|
"windows-link",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "password-hash"
|
name = "password-hash"
|
||||||
version = "0.5.0"
|
version = "0.5.0"
|
||||||
@@ -1382,6 +1702,12 @@ dependencies = [
|
|||||||
"universal-hash",
|
"universal-hash",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "portable-atomic"
|
||||||
|
version = "1.15.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "05c8b63e8d9609db387f0324918f81d68fe27748f084ef092fb35954d0539a85"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "postcard"
|
name = "postcard"
|
||||||
version = "1.1.3"
|
version = "1.1.3"
|
||||||
@@ -1639,6 +1965,15 @@ dependencies = [
|
|||||||
"url",
|
"url",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "redox_syscall"
|
||||||
|
version = "0.5.18"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "ed2bf2547551a7053d6fdfafda3f938979645c44812fbfcda098faae3f1a362d"
|
||||||
|
dependencies = [
|
||||||
|
"bitflags",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "regex"
|
name = "regex"
|
||||||
version = "1.13.2"
|
version = "1.13.2"
|
||||||
@@ -1744,6 +2079,12 @@ dependencies = [
|
|||||||
"sqlite-wasm-rs",
|
"sqlite-wasm-rs",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "rustc-demangle"
|
||||||
|
version = "0.1.28"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b74b56ffa8bb2830709a538c2cbcae9aa062db0d2a42563bfb09bdaae44020eb"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "rustc-hash"
|
name = "rustc-hash"
|
||||||
version = "2.1.3"
|
version = "2.1.3"
|
||||||
@@ -1819,6 +2160,12 @@ version = "1.0.23"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f"
|
checksum = "9774ba4a74de5f7b1c1451ed6cd5285a32eddb5cccb8cc655a4e50009e06477f"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "scopeguard"
|
||||||
|
version = "1.2.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49"
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "semver"
|
name = "semver"
|
||||||
version = "1.0.28"
|
version = "1.0.28"
|
||||||
@@ -2088,6 +2435,15 @@ dependencies = [
|
|||||||
"cfg-if",
|
"cfg-if",
|
||||||
]
|
]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "threadpool"
|
||||||
|
version = "1.8.1"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "d050e60b33d41c19108b32cea32164033a9013fe3b46cbd4457559bfbf77afaa"
|
||||||
|
dependencies = [
|
||||||
|
"num_cpus",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "tinystr"
|
name = "tinystr"
|
||||||
version = "0.8.5"
|
version = "0.8.5"
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ members = [
|
|||||||
"crates/meow-client",
|
"crates/meow-client",
|
||||||
"crates/meow-server",
|
"crates/meow-server",
|
||||||
"crates/meow-cli",
|
"crates/meow-cli",
|
||||||
|
"crates/meow-ffi",
|
||||||
]
|
]
|
||||||
|
|
||||||
[workspace.package]
|
[workspace.package]
|
||||||
|
|||||||
+4
-3
@@ -17,13 +17,14 @@ Pour reprendre le travail : lire ce fichier, prendre le premier lot ⬜ dont les
|
|||||||
1. ~~**3.8** livraison au moins une fois~~ ✅
|
1. ~~**3.8** livraison au moins une fois~~ ✅
|
||||||
2. ~~**4.5** brancher `meow-store` dans le client et la CLI~~ ✅
|
2. ~~**4.5** brancher `meow-store` dans le client et la CLI~~ ✅
|
||||||
3. ~~5.5, 5.6, 5.9, 5.10~~ ✅
|
3. ~~5.5, 5.6, 5.9, 5.10~~ ✅
|
||||||
4. **7.1 → 7.8** FFI et nouvelle application Flutter (from scratch, voir phase 7).
|
4. ~~7.1~~ ✅, puis **7.2 → 7.8** builds et nouvelle application Flutter (from scratch, voir phase 7).
|
||||||
5. Le reste (phases 8–10) selon les priorités.
|
5. Le reste (phases 8–10) selon les priorités.
|
||||||
|
|
||||||
### Journal
|
### Journal
|
||||||
|
|
||||||
| Date | Lots | Notes |
|
| Date | Lots | Notes |
|
||||||
|---|---|---|
|
|---|---|---|
|
||||||
|
| 2026-11-20 | 7.1 | `meow-ffi` avec `flutter_rust_bridge` 2.13.0 (codegen installé avec `cargo install`) ; Dart généré dans `../bastet/lib/src/rust` (`freezed` pour `MeowEvent`). Runtime tokio propre à la crate. `send_file_data` ajouté au client. **Défaut trouvé par le test Dart** : la tâche de fond ne voyait pas un premier contact ajouté pendant son attente de 30 s ; corrigé par un compteur `watch` des changements, avec un test Rust de non-régression. Tests Dart (identité, mauvais mot de passe, verrou, invitation, messages, accusés, fichiers, contact caché) verts ; 46 tests Rust. |
|
||||||
| 2026-11-20 | 5.10 | `create_invitation`, `answer_invitation`, `publish_invitation` et `accept_published_invitation` prennent `space: Option<&str>` : le contact naît directement dans l'espace caché (ouvert ou créé), l'espace principal n'est pas écrit. CLI : `--space-password` sur les quatre commandes d'invitation. Test client (serveur et fichier, caché des deux côtés) et section e2e. Phase 7 réécrite : nouvelle application dans `../bastet`, chat maison. |
|
| 2026-11-20 | 5.10 | `create_invitation`, `answer_invitation`, `publish_invitation` et `accept_published_invitation` prennent `space: Option<&str>` : le contact naît directement dans l'espace caché (ouvert ou créé), l'espace principal n'est pas écrit. CLI : `--space-password` sur les quatre commandes d'invitation. Test client (serveur et fichier, caché des deux côtés) et section e2e. Phase 7 réécrite : nouvelle application dans `../bastet`, chat maison. |
|
||||||
| 2026-11-20 | 5.9 | `subscribe()` (broadcast de tous les événements), `start()` → `ClientHandle { subscribe, lock, stop }`. Pull et vidage de la file découpés en préparation, réseau, application, pour ne jamais tenir le verrou pendant le réseau. Long-poll raccourci jusqu'au prochain réessai, backoff en cas de panne. `process` ne vide plus la file lui-même (c'est `sync` ou la tâche qui le fait). 44 tests, dont un test de tâche de fond (événement poussé, envoi immédiat pendant un long-poll de 20 s, accusé de lecture, réessai automatique, arrêt). |
|
| 2026-11-20 | 5.9 | `subscribe()` (broadcast de tous les événements), `start()` → `ClientHandle { subscribe, lock, stop }`. Pull et vidage de la file découpés en préparation, réseau, application, pour ne jamais tenir le verrou pendant le réseau. Long-poll raccourci jusqu'au prochain réessai, backoff en cas de panne. `process` ne vide plus la file lui-même (c'est `sync` ou la tâche qui le fait). 44 tests, dont un test de tâche de fond (événement poussé, envoi immédiat pendant un long-poll de 20 s, accusé de lecture, réessai automatique, arrêt). |
|
||||||
| 2026-11-20 | 5.6 | `Status` par message (`Queued`, `Sent`, `Delivered`, `Read`, sans retour en arrière), mis à jour dans le segment qui contient le message. Accusés `DELIVERED` (un par contact et par lot) et `READ` (`mark_read`) dans le ratchet, désactivables par identité (`Settings`). `Event::Receipt`. CLI : `read`, `identity receipts`, statuts dans `history`, `longpoll --exit` ignore les lots ne contenant que des accusés. Correction d'un test de store instable (motif de 3 octets trouvé par hasard dans l'aléa). 43 tests, e2e avec une section « accusés ». |
|
| 2026-11-20 | 5.6 | `Status` par message (`Queued`, `Sent`, `Delivered`, `Read`, sans retour en arrière), mis à jour dans le segment qui contient le message. Accusés `DELIVERED` (un par contact et par lot) et `READ` (`mark_read`) dans le ratchet, désactivables par identité (`Settings`). `Event::Receipt`. CLI : `read`, `identity receipts`, statuts dans `history`, `longpoll --exit` ignore les lots ne contenant que des accusés. Correction d'un test de store instable (motif de 3 octets trouvé par hasard dans l'aléa). 43 tests, e2e avec une section « accusés ». |
|
||||||
@@ -127,9 +128,9 @@ conversation est un widget maison, léger. On réutilise de la v1 :
|
|||||||
|
|
||||||
| Lot | Contenu | Fin | État |
|
| Lot | Contenu | Fin | État |
|
||||||
|---|---|---|---|
|
|---|---|---|---|
|
||||||
| 7.1 | Crate `meow-ffi` (cdylib, `flutter_rust_bridge` v2) : API miroir de `ClientHandle` (create/open/unlock, contacts, invitations, envoi, historique paginé, réglages) + `Stream<Event>` | Génération Dart OK, tests Dart minimaux | ⬜ |
|
| 7.1 | Crate `meow-ffi` (cdylib, `flutter_rust_bridge` 2.13.0) : objet `Meow` miroir de `ClientHandle` (create/open/close/unlock, serveurs, contacts, invitations, envoi de texte et de fichiers en octets, historique paginé, réglages, file d'envoi) + `Stream<MeowEvent>` | `scripts/ffi-test.sh` : génération, build, tests Dart verts | ✅ |
|
||||||
| 7.2 | Builds Android (`cargo-ndk` : arm64-v8a, armeabi-v7a, x86_64) et Linux, script `deploy.sh` vers `../bastet` | `libmeow_ffi.so` chargée par l'application | ⬜ |
|
| 7.2 | Builds Android (`cargo-ndk` : arm64-v8a, armeabi-v7a, x86_64) et Linux, script `deploy.sh` vers `../bastet` | `libmeow_ffi.so` chargée par l'application | ⬜ |
|
||||||
| 7.3 | Squelette de l'application : architecture (état, navigation), thème, icônes et traductions de la v1, écran de déverrouillage (un seul champ : mot de passe principal ou caché), création d'identité, serveurs | Lancement Linux | ⬜ |
|
| 7.3 | Squelette de l'application : architecture (état, navigation), **écrans repensés, plus professionnels, en teintes sable (clair et sombre)** à partir du thème de la v1, icônes et traductions, écran de déverrouillage (un seul champ : mot de passe principal ou caché), création d'identité, serveurs | Lancement Linux | ⬜ |
|
||||||
| 7.4 | Liste des contacts + **écran de conversation maison** : liste virtualisée chargée segment par segment, statuts (envoi, reçu, lu), accusés, fichiers, file d'envoi | Chat fonctionnel sur Linux | ⬜ |
|
| 7.4 | Liste des contacts + **écran de conversation maison** : liste virtualisée chargée segment par segment, statuts (envoi, reçu, lu), accusés, fichiers, file d'envoi | Chat fonctionnel sur Linux | ⬜ |
|
||||||
| 7.5 | Invitations : par serveur (lien + mot de passe), par fichier ou QR, et en présentiel via `peer_secure` (BLE/LAN) qui transporte les octets d'invitation v2 | e2e manuel entre deux appareils | ⬜ |
|
| 7.5 | Invitations : par serveur (lien + mot de passe), par fichier ou QR, et en présentiel via `peer_secure` (BLE/LAN) qui transporte les octets d'invitation v2 | e2e manuel entre deux appareils | ⬜ |
|
||||||
| 7.6 | Espaces cachés dans l'UI (cacher/révéler, inviter dans un espace caché, aucune trace visuelle sans déverrouillage), réglages (accusés, mot de passe) | | ⬜ |
|
| 7.6 | Espaces cachés dans l'UI (cacher/révéler, inviter dans un espace caché, aucune trace visuelle sans déverrouillage), réglages (accusés, mot de passe) | | ⬜ |
|
||||||
|
|||||||
@@ -93,10 +93,12 @@ impl ClientHandle {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Wait for `d`, or until asked to stop. Returns `true` when stopping.
|
/// Wait for `d`, until the client state changes, or until asked to stop. Returns
|
||||||
async fn pause(d: Duration, stop: &mut watch::Receiver<bool>) -> bool {
|
/// `true` when stopping.
|
||||||
|
async fn pause(d: Duration, stop: &mut watch::Receiver<bool>, changes: &mut watch::Receiver<u64>) -> bool {
|
||||||
tokio::select! {
|
tokio::select! {
|
||||||
_ = tokio::time::sleep(d) => *stop.borrow(),
|
_ = tokio::time::sleep(d) => *stop.borrow(),
|
||||||
|
_ = changes.changed() => *stop.borrow(),
|
||||||
_ = stop.changed() => true,
|
_ = stop.changed() => true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -104,6 +106,7 @@ async fn pause(d: Duration, stop: &mut watch::Receiver<bool>) -> bool {
|
|||||||
async fn run(client: Arc<Mutex<MeowClient>>, opts: BackgroundOptions, mut stop: watch::Receiver<bool>) {
|
async fn run(client: Arc<Mutex<MeowClient>>, opts: BackgroundOptions, mut stop: watch::Receiver<bool>) {
|
||||||
let mut wait = opts.long_poll;
|
let mut wait = opts.long_poll;
|
||||||
let mut backoff = opts.backoff;
|
let mut backoff = opts.backoff;
|
||||||
|
let mut changes = client.lock().await.changes.subscribe();
|
||||||
while !*stop.borrow() {
|
while !*stop.borrow() {
|
||||||
// 1. Due deposits (and expiries).
|
// 1. Due deposits (and expiries).
|
||||||
let (plan, transport) = {
|
let (plan, transport) = {
|
||||||
@@ -130,6 +133,8 @@ async fn run(client: Arc<Mutex<MeowClient>>, opts: BackgroundOptions, mut stop:
|
|||||||
// for the next queued deposit to be retried.
|
// for the next queued deposit to be retried.
|
||||||
let plan = {
|
let plan = {
|
||||||
let mut c = client.lock().await;
|
let mut c = client.lock().await;
|
||||||
|
// Everything up to here (including our own saves) is reflected in the plan.
|
||||||
|
changes.borrow_and_update();
|
||||||
let w = match c.next_retry_in() {
|
let w = match c.next_retry_in() {
|
||||||
Some(d) => wait.min(d.max(Duration::from_secs(1))),
|
Some(d) => wait.min(d.max(Duration::from_secs(1))),
|
||||||
None => wait,
|
None => wait,
|
||||||
@@ -139,13 +144,19 @@ async fn run(client: Arc<Mutex<MeowClient>>, opts: BackgroundOptions, mut stop:
|
|||||||
if plan.is_empty() {
|
if plan.is_empty() {
|
||||||
// No contact yet: just keep the queue moving.
|
// No contact yet: just keep the queue moving.
|
||||||
let d = client.lock().await.next_retry_in().unwrap_or(opts.long_poll);
|
let d = client.lock().await.next_retry_in().unwrap_or(opts.long_poll);
|
||||||
if pause(d.clamp(Duration::from_secs(1), opts.long_poll), &mut stop).await {
|
if pause(d.clamp(Duration::from_secs(1), opts.long_poll), &mut stop, &mut changes).await {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
let results = tokio::select! {
|
let results = tokio::select! {
|
||||||
r = execute_pull(&transport, &plan) => r,
|
r = execute_pull(&transport, &plan) => r,
|
||||||
|
// The state changed under us (new contact, unlocked space, message to send):
|
||||||
|
// restart with an up-to-date request. Abandoned acks are simply resent.
|
||||||
|
_ = changes.changed() => {
|
||||||
|
wait = Duration::ZERO;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
_ = stop.changed() => break,
|
_ = stop.changed() => break,
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -172,7 +183,7 @@ async fn run(client: Arc<Mutex<MeowClient>>, opts: BackgroundOptions, mut stop:
|
|||||||
Err(e) => {
|
Err(e) => {
|
||||||
drop(c);
|
drop(c);
|
||||||
tracing::warn!("background pull failed: {e}; retrying in {backoff:?}");
|
tracing::warn!("background pull failed: {e}; retrying in {backoff:?}");
|
||||||
if pause(backoff, &mut stop).await {
|
if pause(backoff, &mut stop, &mut changes).await {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
backoff = (backoff * 2).min(opts.max_backoff);
|
backoff = (backoff * 2).min(opts.max_backoff);
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ use std::time::{Duration, SystemTime, UNIX_EPOCH};
|
|||||||
use futures_util::future::join_all;
|
use futures_util::future::join_all;
|
||||||
use meow_core::contact::{Contact, ContactState};
|
use meow_core::contact::{Contact, ContactState};
|
||||||
use meow_core::invitation::{self, OfferInfo};
|
use meow_core::invitation::{self, OfferInfo};
|
||||||
use meow_core::server::{canonical_url, ServerInfo};
|
use meow_core::server::canonical_url;
|
||||||
use meow_core::{messaging, rpc};
|
use meow_core::{messaging, rpc};
|
||||||
use meow_crypto::password::KdfParams;
|
use meow_crypto::password::KdfParams;
|
||||||
use meow_crypto::{SignPublic, SigningKeyPair};
|
use meow_crypto::{SignPublic, SigningKeyPair};
|
||||||
@@ -38,6 +38,7 @@ use meow_store::{Batch, RetiredMailbox, SpaceId, State as SpaceState, Store};
|
|||||||
|
|
||||||
pub use background::{BackgroundOptions, ClientHandle};
|
pub use background::{BackgroundOptions, ClientHandle};
|
||||||
pub use meow_core::contact::ContactState as State;
|
pub use meow_core::contact::ContactState as State;
|
||||||
|
pub use meow_core::server::ServerInfo;
|
||||||
pub use meow_store::{Content, HistoryEntry, HistoryPage, PendingAck, Settings, Status};
|
pub use meow_store::{Content, HistoryEntry, HistoryPage, PendingAck, Settings, Status};
|
||||||
pub use outbox::{PendingSend, RetryPolicy};
|
pub use outbox::{PendingSend, RetryPolicy};
|
||||||
|
|
||||||
@@ -216,6 +217,9 @@ pub struct MeowClient {
|
|||||||
pending_events: Vec<Event>,
|
pending_events: Vec<Event>,
|
||||||
/// Every event, for subscribers ([`MeowClient::subscribe`]).
|
/// Every event, for subscribers ([`MeowClient::subscribe`]).
|
||||||
events: tokio::sync::broadcast::Sender<Event>,
|
events: tokio::sync::broadcast::Sender<Event>,
|
||||||
|
/// Bumped at every save: the background task restarts its wait when the state
|
||||||
|
/// changed under it (new contact to poll, unlocked space, queued message).
|
||||||
|
changes: tokio::sync::watch::Sender<u64>,
|
||||||
}
|
}
|
||||||
|
|
||||||
type Mailboxes = Vec<(SigningKeyPair, Vec<ServerInfo>)>;
|
type Mailboxes = Vec<(SigningKeyPair, Vec<ServerInfo>)>;
|
||||||
@@ -252,6 +256,7 @@ impl MeowClient {
|
|||||||
retry: RetryPolicy::default(),
|
retry: RetryPolicy::default(),
|
||||||
pending_events: Vec::new(),
|
pending_events: Vec::new(),
|
||||||
events: tokio::sync::broadcast::channel(EVENT_BUFFER).0,
|
events: tokio::sync::broadcast::channel(EVENT_BUFFER).0,
|
||||||
|
changes: tokio::sync::watch::channel(0).0,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -270,6 +275,7 @@ impl MeowClient {
|
|||||||
let batch = std::mem::take(&mut sp.batch);
|
let batch = std::mem::take(&mut sp.batch);
|
||||||
lock(&self.store)?.save(sp.id, &sp.state, batch)?;
|
lock(&self.store)?.save(sp.id, &sp.state, batch)?;
|
||||||
sp.dirty = false;
|
sp.dirty = false;
|
||||||
|
self.changes.send_modify(|v| *v = v.wrapping_add(1));
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -337,6 +343,7 @@ impl MeowClient {
|
|||||||
batch: Batch::default(),
|
batch: Batch::default(),
|
||||||
dirty: false,
|
dirty: false,
|
||||||
});
|
});
|
||||||
|
self.changes.send_modify(|v| *v = v.wrapping_add(1));
|
||||||
Ok(self.spaces.len() - 1)
|
Ok(self.spaces.len() - 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -752,13 +759,23 @@ impl MeowClient {
|
|||||||
|
|
||||||
pub async fn send_file(&mut self, contact_name: &str, path: &Path) -> Result<SendReport> {
|
pub async fn send_file(&mut self, contact_name: &str, path: &Path) -> Result<SendReport> {
|
||||||
let data = tokio::fs::read(path).await?;
|
let data = tokio::fs::read(path).await?;
|
||||||
if data.len() > MAX_FILE_BYTES {
|
|
||||||
return Err(Error::Invalid(format!("file larger than {MAX_FILE_BYTES} bytes")));
|
|
||||||
}
|
|
||||||
let name = path
|
let name = path
|
||||||
.file_name()
|
.file_name()
|
||||||
.map(|n| n.to_string_lossy().to_string())
|
.map(|n| n.to_string_lossy().to_string())
|
||||||
.ok_or_else(|| Error::Invalid("bad file name".into()))?;
|
.ok_or_else(|| Error::Invalid("bad file name".into()))?;
|
||||||
|
self.send_file_data(contact_name, &name, data).await
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Send a file given by its content (mobile platforms often have no path).
|
||||||
|
pub async fn send_file_data(&mut self, contact_name: &str, name: &str, data: Vec<u8>) -> Result<SendReport> {
|
||||||
|
if data.len() > MAX_FILE_BYTES {
|
||||||
|
return Err(Error::Invalid(format!("file larger than {MAX_FILE_BYTES} bytes")));
|
||||||
|
}
|
||||||
|
let name = Path::new(name)
|
||||||
|
.file_name()
|
||||||
|
.map(|n| n.to_string_lossy().to_string())
|
||||||
|
.filter(|n| !n.is_empty())
|
||||||
|
.ok_or_else(|| Error::Invalid("bad file name".into()))?;
|
||||||
let size = data.len() as u64;
|
let size = data.len() as u64;
|
||||||
let body = v2::user_message::Body::File(v2::FileBody {
|
let body = v2::user_message::Body::File(v2::FileBody {
|
||||||
filename: name.clone(),
|
filename: name.clone(),
|
||||||
|
|||||||
@@ -771,3 +771,48 @@ async fn invitations_straight_into_hidden_spaces() {
|
|||||||
assert_eq!(texts(&bob.sync(Duration::ZERO).await.unwrap()), vec!["still secret"]);
|
assert_eq!(texts(&bob.sync(Duration::ZERO).await.unwrap()), vec!["still secret"]);
|
||||||
let _ = std::fs::remove_dir_all(&dir);
|
let _ = std::fs::remove_dir_all(&dir);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// The background task must notice state changes made through the handle (here, a
|
||||||
|
/// first contact while it was idling), not only after its 30 s wait.
|
||||||
|
#[tokio::test(flavor = "multi_thread")]
|
||||||
|
async fn background_task_wakes_up_on_new_contacts() {
|
||||||
|
let servers = vec![spawn_server().await];
|
||||||
|
let dir = tmpdir();
|
||||||
|
let alice = client(&dir, "alice", &servers)
|
||||||
|
.await
|
||||||
|
.start(meow_client::BackgroundOptions::default());
|
||||||
|
let bob = client(&dir, "bob", &servers)
|
||||||
|
.await
|
||||||
|
.start(meow_client::BackgroundOptions::default());
|
||||||
|
let alice_rx = alice.subscribe();
|
||||||
|
let bob_rx = bob.subscribe();
|
||||||
|
tokio::time::sleep(Duration::from_millis(300)).await; // both idle, nothing to poll
|
||||||
|
|
||||||
|
let url = alice
|
||||||
|
.lock()
|
||||||
|
.await
|
||||||
|
.publish_invitation("bob", &[], "", "", 3600, None)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
bob.lock()
|
||||||
|
.await
|
||||||
|
.accept_published_invitation(&url, "", None, &[], None)
|
||||||
|
.await
|
||||||
|
.unwrap();
|
||||||
|
async fn activated(mut rx: tokio::sync::broadcast::Receiver<Event>, who: &str) {
|
||||||
|
tokio::time::timeout(Duration::from_secs(10), async {
|
||||||
|
loop {
|
||||||
|
if let Event::ContactActivated { .. } = rx.recv().await.unwrap() {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
.unwrap_or_else(|_| panic!("{who} not activated in time"))
|
||||||
|
}
|
||||||
|
let (a, b) = (activated(alice_rx, "alice"), activated(bob_rx, "bob"));
|
||||||
|
tokio::join!(a, b);
|
||||||
|
alice.stop().await;
|
||||||
|
bob.stop().await;
|
||||||
|
let _ = std::fs::remove_dir_all(&dir);
|
||||||
|
}
|
||||||
@@ -0,0 +1,22 @@
|
|||||||
|
[package]
|
||||||
|
name = "meow-ffi"
|
||||||
|
description = "Meow v2 bindings for Flutter (flutter_rust_bridge)"
|
||||||
|
version.workspace = true
|
||||||
|
edition.workspace = true
|
||||||
|
license.workspace = true
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
crate-type = ["cdylib", "staticlib", "rlib"]
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
meow-client = { path = "../meow-client" }
|
||||||
|
meow-crypto = { path = "../meow-crypto" }
|
||||||
|
flutter_rust_bridge = "=2.13.0"
|
||||||
|
tokio = { version = "1", features = ["rt-multi-thread", "sync", "macros"] }
|
||||||
|
anyhow = "1"
|
||||||
|
tracing = "0.1"
|
||||||
|
|
||||||
|
# The only crate allowed to contain `unsafe`: the code generated by flutter_rust_bridge.
|
||||||
|
[lints.rust]
|
||||||
|
unsafe_code = "allow"
|
||||||
|
unexpected_cfgs = { level = "warn", check-cfg = ['cfg(frb_expand)'] }
|
||||||
@@ -0,0 +1,611 @@
|
|||||||
|
//! The Dart-facing API: one opaque [`Meow`] object per open identity.
|
||||||
|
//!
|
||||||
|
//! An open identity always runs its background synchronisation (`meow_client`
|
||||||
|
//! `ClientHandle`); the app listens to [`Meow::events`] and calls methods, all
|
||||||
|
//! `async`. Types ending in `View` are plain data copied to Dart.
|
||||||
|
//!
|
||||||
|
//! Every call runs on a crate-owned multi-threaded tokio runtime (HTTP, timers and the
|
||||||
|
//! background task need tokio, whatever executor flutter_rust_bridge uses).
|
||||||
|
|
||||||
|
use std::future::Future;
|
||||||
|
use std::sync::{Arc, Mutex, OnceLock};
|
||||||
|
|
||||||
|
use anyhow::{anyhow, Result};
|
||||||
|
use flutter_rust_bridge::frb;
|
||||||
|
use meow_client::{BackgroundOptions, ClientHandle, Content, Event, MeowClient, ReceiptKind, Settings, Status};
|
||||||
|
use meow_crypto::password::KdfParams;
|
||||||
|
use tokio::sync::broadcast::error::RecvError;
|
||||||
|
|
||||||
|
use crate::frb_generated::StreamSink;
|
||||||
|
|
||||||
|
const INVITATION_TTL: u64 = meow_client::DEFAULT_INVITATION_TTL;
|
||||||
|
|
||||||
|
fn runtime() -> &'static tokio::runtime::Runtime {
|
||||||
|
static RT: OnceLock<tokio::runtime::Runtime> = OnceLock::new();
|
||||||
|
RT.get_or_init(|| {
|
||||||
|
tokio::runtime::Builder::new_multi_thread()
|
||||||
|
.worker_threads(2)
|
||||||
|
.thread_name("meow")
|
||||||
|
.enable_all()
|
||||||
|
.build()
|
||||||
|
.unwrap_or_else(|e| panic!("cannot start the meow runtime: {e}"))
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Run `f` on the meow runtime.
|
||||||
|
async fn run<T: Send + 'static>(f: impl Future<Output = Result<T>> + Send + 'static) -> Result<T> {
|
||||||
|
runtime()
|
||||||
|
.spawn(f)
|
||||||
|
.await
|
||||||
|
.map_err(|e| anyhow!("internal task failed: {e}"))?
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Called once by the generated Dart `RustLib.init()`.
|
||||||
|
#[frb(init)]
|
||||||
|
pub fn init_app() {
|
||||||
|
flutter_rust_bridge::setup_default_user_utils();
|
||||||
|
}
|
||||||
|
|
||||||
|
// ───────────────────────────── views ─────────────────────────────
|
||||||
|
|
||||||
|
pub struct ServerView {
|
||||||
|
pub url: String,
|
||||||
|
pub name: String,
|
||||||
|
/// Short fingerprint of the server signing key (to compare out of band).
|
||||||
|
pub fingerprint: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub enum ContactStatus {
|
||||||
|
/// I invited them; waiting for their answer.
|
||||||
|
OfferSent,
|
||||||
|
/// I answered their invitation; waiting for their confirmation.
|
||||||
|
AnswerSent,
|
||||||
|
/// I confirmed; I can already write, waiting for their acknowledgement.
|
||||||
|
ConfirmSent,
|
||||||
|
Active,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct ContactView {
|
||||||
|
pub id: String,
|
||||||
|
/// My name for this contact.
|
||||||
|
pub name: String,
|
||||||
|
/// The name I present to them.
|
||||||
|
pub my_name: String,
|
||||||
|
/// The name they gave themselves.
|
||||||
|
pub peer_name: Option<String>,
|
||||||
|
pub status: ContactStatus,
|
||||||
|
/// Lives in an (unlocked) hidden space.
|
||||||
|
pub hidden: bool,
|
||||||
|
/// To compare with the contact (same on both sides) once active.
|
||||||
|
pub safety_number: Option<String>,
|
||||||
|
pub created_at: i64,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub enum MessageStatus {
|
||||||
|
/// Outbound, no server accepted it yet.
|
||||||
|
Queued,
|
||||||
|
/// Outbound, accepted by a server.
|
||||||
|
Sent,
|
||||||
|
/// Reached the recipient's device (inbound: received, unread).
|
||||||
|
Delivered,
|
||||||
|
Read,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct MessageView {
|
||||||
|
pub id: Vec<u8>,
|
||||||
|
pub outbound: bool,
|
||||||
|
pub sent_at_ms: i64,
|
||||||
|
pub received_at: i64,
|
||||||
|
pub text: Option<String>,
|
||||||
|
pub file_name: Option<String>,
|
||||||
|
pub file_size: Option<i64>,
|
||||||
|
pub status: MessageStatus,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// One segment of a conversation, oldest message first.
|
||||||
|
pub struct HistoryPageView {
|
||||||
|
pub messages: Vec<MessageView>,
|
||||||
|
pub page: u32,
|
||||||
|
/// Older segment to load next, if any.
|
||||||
|
pub previous: Option<u32>,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct InvitationInfo {
|
||||||
|
pub from: String,
|
||||||
|
pub message: String,
|
||||||
|
pub expires_at: i64,
|
||||||
|
pub servers: Vec<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct SendResult {
|
||||||
|
pub message_id: Vec<u8>,
|
||||||
|
/// Servers that took the message now; 0 = queued, retried automatically.
|
||||||
|
pub delivered_to: u32,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct PendingSendView {
|
||||||
|
pub contact: String,
|
||||||
|
/// Empty for protocol messages (receipts, handshake).
|
||||||
|
pub message_id: Vec<u8>,
|
||||||
|
pub accepted: u32,
|
||||||
|
pub attempts: u32,
|
||||||
|
pub next_attempt: i64,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub struct SettingsView {
|
||||||
|
pub delivered_receipts: bool,
|
||||||
|
pub read_receipts: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub enum MeowEvent {
|
||||||
|
InvitationAccepted {
|
||||||
|
contact: String,
|
||||||
|
},
|
||||||
|
ContactActivated {
|
||||||
|
contact: String,
|
||||||
|
},
|
||||||
|
Message {
|
||||||
|
contact: String,
|
||||||
|
id: Vec<u8>,
|
||||||
|
text: String,
|
||||||
|
sent_at_ms: i64,
|
||||||
|
},
|
||||||
|
/// The content is in the store: [`Meow::file`].
|
||||||
|
File {
|
||||||
|
contact: String,
|
||||||
|
id: Vec<u8>,
|
||||||
|
name: String,
|
||||||
|
size: i64,
|
||||||
|
},
|
||||||
|
Receipt {
|
||||||
|
contact: String,
|
||||||
|
read: bool,
|
||||||
|
message_ids: Vec<Vec<u8>>,
|
||||||
|
},
|
||||||
|
SendFailed {
|
||||||
|
contact: String,
|
||||||
|
message_id: Vec<u8>,
|
||||||
|
},
|
||||||
|
/// The listener fell behind and missed events: reload what is displayed.
|
||||||
|
Lagged {
|
||||||
|
missed: i64,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
|
||||||
|
impl From<Event> for MeowEvent {
|
||||||
|
fn from(e: Event) -> Self {
|
||||||
|
match e {
|
||||||
|
Event::InvitationAccepted { contact } => MeowEvent::InvitationAccepted { contact },
|
||||||
|
Event::ContactActivated { contact } => MeowEvent::ContactActivated { contact },
|
||||||
|
Event::Message {
|
||||||
|
contact,
|
||||||
|
id,
|
||||||
|
text,
|
||||||
|
sent_at_ms,
|
||||||
|
} => MeowEvent::Message {
|
||||||
|
contact,
|
||||||
|
id,
|
||||||
|
text,
|
||||||
|
sent_at_ms: sent_at_ms as i64,
|
||||||
|
},
|
||||||
|
Event::File {
|
||||||
|
contact,
|
||||||
|
id,
|
||||||
|
name,
|
||||||
|
data,
|
||||||
|
} => MeowEvent::File {
|
||||||
|
contact,
|
||||||
|
id,
|
||||||
|
name,
|
||||||
|
size: data.len() as i64,
|
||||||
|
},
|
||||||
|
Event::Receipt {
|
||||||
|
contact,
|
||||||
|
kind,
|
||||||
|
message_ids,
|
||||||
|
} => MeowEvent::Receipt {
|
||||||
|
contact,
|
||||||
|
read: kind == ReceiptKind::Read,
|
||||||
|
message_ids,
|
||||||
|
},
|
||||||
|
Event::SendFailed { contact, message_id } => MeowEvent::SendFailed { contact, message_id },
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn message_view(h: meow_client::HistoryEntry) -> MessageView {
|
||||||
|
let (text, file_name, file_size) = match h.content {
|
||||||
|
Content::Text(t) => (Some(t), None, None),
|
||||||
|
Content::File { name, size } => (None, Some(name), Some(size as i64)),
|
||||||
|
};
|
||||||
|
MessageView {
|
||||||
|
id: h.id,
|
||||||
|
outbound: h.outbound,
|
||||||
|
sent_at_ms: h.sent_at_ms as i64,
|
||||||
|
received_at: h.received_at as i64,
|
||||||
|
text,
|
||||||
|
file_name,
|
||||||
|
file_size,
|
||||||
|
status: match h.status {
|
||||||
|
Status::Queued => MessageStatus::Queued,
|
||||||
|
Status::Sent => MessageStatus::Sent,
|
||||||
|
Status::Delivered => MessageStatus::Delivered,
|
||||||
|
Status::Read => MessageStatus::Read,
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn server_view(s: &meow_client::ServerInfo) -> ServerView {
|
||||||
|
ServerView {
|
||||||
|
url: s.url.clone(),
|
||||||
|
name: s.name.clone(),
|
||||||
|
fingerprint: s.sign_key.fingerprint(),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn opt(s: Option<String>) -> Option<String> {
|
||||||
|
s.filter(|x| !x.is_empty())
|
||||||
|
}
|
||||||
|
|
||||||
|
// ───────────────────────────── Meow ─────────────────────────────
|
||||||
|
|
||||||
|
/// An open identity, synchronising in the background until [`Meow::close`].
|
||||||
|
#[frb(opaque)]
|
||||||
|
pub struct Meow {
|
||||||
|
inner: Mutex<Option<Arc<ClientHandle>>>,
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Run `$body` with `$c: &mut MeowClient`, on the meow runtime.
|
||||||
|
macro_rules! with_client {
|
||||||
|
($self:ident, |$c:ident| $body:expr) => {{
|
||||||
|
let h = $self.handle()?;
|
||||||
|
run(async move {
|
||||||
|
let mut guard = h.lock().await;
|
||||||
|
let $c: &mut MeowClient = &mut guard;
|
||||||
|
$body
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
}};
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Meow {
|
||||||
|
fn start(client: MeowClient) -> Meow {
|
||||||
|
Meow {
|
||||||
|
inner: Mutex::new(Some(Arc::new(client.start(BackgroundOptions::default())))),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn handle(&self) -> Result<Arc<ClientHandle>> {
|
||||||
|
self.inner
|
||||||
|
.lock()
|
||||||
|
.map_err(|_| anyhow!("poisoned"))?
|
||||||
|
.clone()
|
||||||
|
.ok_or_else(|| anyhow!("identity closed"))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── lifecycle ──
|
||||||
|
|
||||||
|
/// Create an identity file. `insecure_fast_kdf` is for tests only.
|
||||||
|
pub async fn create(
|
||||||
|
path: String,
|
||||||
|
nickname: String,
|
||||||
|
password: String,
|
||||||
|
overwrite: bool,
|
||||||
|
insecure_fast_kdf: bool,
|
||||||
|
) -> Result<Meow> {
|
||||||
|
let kdf = if insecure_fast_kdf {
|
||||||
|
KdfParams::INSECURE_TEST
|
||||||
|
} else {
|
||||||
|
KdfParams::DEFAULT
|
||||||
|
};
|
||||||
|
run(async move {
|
||||||
|
let c = MeowClient::create(path.as_ref(), &nickname, &password, kdf, overwrite).await?;
|
||||||
|
Ok(Meow::start(c))
|
||||||
|
})
|
||||||
|
.await
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Open an identity with its main password.
|
||||||
|
pub async fn open(path: String, password: String) -> Result<Meow> {
|
||||||
|
run(async move { Ok(Meow::start(MeowClient::open(path.as_ref(), &password).await?)) }).await
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Stop synchronising and release the identity file.
|
||||||
|
pub async fn close(&self) -> Result<()> {
|
||||||
|
let h = self.inner.lock().map_err(|_| anyhow!("poisoned"))?.take();
|
||||||
|
if let Some(h) = h {
|
||||||
|
run(async move {
|
||||||
|
match Arc::try_unwrap(h) {
|
||||||
|
Ok(h) => drop(h.stop().await),
|
||||||
|
// A call is still running: the task stops when it ends.
|
||||||
|
Err(h) => drop(h),
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
})
|
||||||
|
.await?;
|
||||||
|
}
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Every event from now on (messages, receipts, invitations…). The stream ends when
|
||||||
|
/// the identity is closed: call [`Meow::close`] before cancelling the subscription
|
||||||
|
/// (a cancel only completes once Rust closes the stream).
|
||||||
|
pub fn events(&self, sink: StreamSink<MeowEvent>) -> Result<()> {
|
||||||
|
let mut rx = self.handle()?.subscribe();
|
||||||
|
runtime().spawn(async move {
|
||||||
|
loop {
|
||||||
|
let ev = match rx.recv().await {
|
||||||
|
Ok(e) => MeowEvent::from(e),
|
||||||
|
Err(RecvError::Lagged(n)) => MeowEvent::Lagged { missed: n as i64 },
|
||||||
|
Err(RecvError::Closed) => break,
|
||||||
|
};
|
||||||
|
if sink.add(ev).is_err() {
|
||||||
|
break; // Dart stopped listening
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn nickname(&self) -> Result<String> {
|
||||||
|
with_client!(self, |c| Ok(c.nickname().to_string()))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn change_password(&self, new_password: String) -> Result<()> {
|
||||||
|
with_client!(self, |c| Ok(c.change_password(&new_password).await?))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn settings(&self) -> Result<SettingsView> {
|
||||||
|
with_client!(self, |c| {
|
||||||
|
let s = c.settings();
|
||||||
|
Ok(SettingsView {
|
||||||
|
delivered_receipts: s.delivered_receipts,
|
||||||
|
read_receipts: s.read_receipts,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn set_settings(&self, settings: SettingsView) -> Result<()> {
|
||||||
|
with_client!(self, |c| {
|
||||||
|
c.set_settings(Settings {
|
||||||
|
delivered_receipts: settings.delivered_receipts,
|
||||||
|
read_receipts: settings.read_receipts,
|
||||||
|
})
|
||||||
|
.await?;
|
||||||
|
Ok(())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── hidden spaces ──
|
||||||
|
|
||||||
|
/// Try a password on the hidden spaces; `true` if one opened (its contacts appear).
|
||||||
|
/// Silent and equally slow when nothing opens.
|
||||||
|
pub async fn unlock(&self, password: String) -> Result<bool> {
|
||||||
|
with_client!(self, |c| Ok(c.unlock(&password).await?))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn hide_contact(&self, name: String, space_password: String) -> Result<()> {
|
||||||
|
with_client!(self, |c| Ok(c.hide_contact(&name, &space_password).await?))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn reveal_contact(&self, name: String) -> Result<()> {
|
||||||
|
with_client!(self, |c| Ok(c.reveal_contact(&name).await?))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── servers ──
|
||||||
|
|
||||||
|
pub async fn servers(&self) -> Result<Vec<ServerView>> {
|
||||||
|
with_client!(self, |c| Ok(c.servers().iter().map(server_view).collect()))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Fetch, verify and pin a server's card.
|
||||||
|
pub async fn add_server(&self, url: String) -> Result<ServerView> {
|
||||||
|
with_client!(self, |c| Ok(server_view(&c.add_server(&url).await?)))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn remove_server(&self, url_or_name: String) -> Result<()> {
|
||||||
|
with_client!(self, |c| Ok(c.remove_server(&url_or_name).await?))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── contacts ──
|
||||||
|
|
||||||
|
pub async fn contacts(&self) -> Result<Vec<ContactView>> {
|
||||||
|
with_client!(self, |c| {
|
||||||
|
let mut out = Vec::new();
|
||||||
|
for k in c.contacts() {
|
||||||
|
out.push(ContactView {
|
||||||
|
id: k.id.0.clone(),
|
||||||
|
name: k.name.clone(),
|
||||||
|
my_name: k.my_name.clone(),
|
||||||
|
peer_name: k.peer.as_ref().map(|p| p.name.clone()),
|
||||||
|
status: match k.state {
|
||||||
|
meow_client::State::OfferSent => ContactStatus::OfferSent,
|
||||||
|
meow_client::State::AnswerSent => ContactStatus::AnswerSent,
|
||||||
|
meow_client::State::ConfirmSent => ContactStatus::ConfirmSent,
|
||||||
|
meow_client::State::Active => ContactStatus::Active,
|
||||||
|
},
|
||||||
|
hidden: c.is_hidden(&k.name)?,
|
||||||
|
safety_number: k.safety_number(),
|
||||||
|
created_at: k.created_at as i64,
|
||||||
|
});
|
||||||
|
}
|
||||||
|
Ok(out)
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Delete a contact with its conversation.
|
||||||
|
pub async fn remove_contact(&self, name: String) -> Result<()> {
|
||||||
|
with_client!(self, |c| Ok(c.remove_contact(&name).await?))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── invitations ──
|
||||||
|
// `space_password`: create the contact directly in that hidden space.
|
||||||
|
|
||||||
|
/// Step 1 (file / QR): returns the invitation bytes to hand over.
|
||||||
|
pub async fn create_invitation(
|
||||||
|
&self,
|
||||||
|
contact_name: String,
|
||||||
|
message: String,
|
||||||
|
servers: Vec<String>,
|
||||||
|
space_password: Option<String>,
|
||||||
|
) -> Result<Vec<u8>> {
|
||||||
|
with_client!(self, |c| Ok(c
|
||||||
|
.create_invitation(
|
||||||
|
&contact_name,
|
||||||
|
&servers,
|
||||||
|
&message,
|
||||||
|
INVITATION_TTL,
|
||||||
|
opt(space_password).as_deref()
|
||||||
|
)
|
||||||
|
.await?))
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn inspect_invitation(&self, invitation: Vec<u8>) -> Result<InvitationInfo> {
|
||||||
|
with_client!(self, |c| {
|
||||||
|
let i = c.inspect_invitation(&invitation)?;
|
||||||
|
Ok(InvitationInfo {
|
||||||
|
from: i.initiator_name,
|
||||||
|
message: i.message,
|
||||||
|
expires_at: i.expires_at as i64,
|
||||||
|
servers: i.answer_servers.iter().map(|s| s.url.clone()).collect(),
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Step 2 (file / QR): returns the answer bytes to hand back.
|
||||||
|
pub async fn answer_invitation(
|
||||||
|
&self,
|
||||||
|
invitation: Vec<u8>,
|
||||||
|
contact_name: Option<String>,
|
||||||
|
servers: Vec<String>,
|
||||||
|
space_password: Option<String>,
|
||||||
|
) -> Result<Vec<u8>> {
|
||||||
|
with_client!(self, |c| Ok(c
|
||||||
|
.answer_invitation(
|
||||||
|
&invitation,
|
||||||
|
opt(contact_name).as_deref(),
|
||||||
|
&servers,
|
||||||
|
opt(space_password).as_deref()
|
||||||
|
)
|
||||||
|
.await?))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Step 3 (file / QR): returns the confirmation bytes to hand over.
|
||||||
|
pub async fn accept_answer(&self, answer: Vec<u8>) -> Result<Vec<u8>> {
|
||||||
|
with_client!(self, |c| Ok(c.accept_answer(&answer).await?))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Step 4 (file / QR): returns the contact's name.
|
||||||
|
pub async fn finalize_invitation(&self, confirmation: Vec<u8>) -> Result<String> {
|
||||||
|
with_client!(self, |c| Ok(c.finalize_invitation(&confirmation).await?))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Server invitation: returns the link to share (with the password, out of band).
|
||||||
|
pub async fn publish_invitation(
|
||||||
|
&self,
|
||||||
|
contact_name: String,
|
||||||
|
message: String,
|
||||||
|
password: String,
|
||||||
|
servers: Vec<String>,
|
||||||
|
space_password: Option<String>,
|
||||||
|
) -> Result<String> {
|
||||||
|
with_client!(self, |c| Ok(c
|
||||||
|
.publish_invitation(
|
||||||
|
&contact_name,
|
||||||
|
&servers,
|
||||||
|
&message,
|
||||||
|
&password,
|
||||||
|
INVITATION_TTL,
|
||||||
|
opt(space_password).as_deref()
|
||||||
|
)
|
||||||
|
.await?))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Answer a server invitation link; returns the inviter's name. The rest of the
|
||||||
|
/// handshake completes in the background.
|
||||||
|
pub async fn accept_published_invitation(
|
||||||
|
&self,
|
||||||
|
url: String,
|
||||||
|
password: String,
|
||||||
|
contact_name: Option<String>,
|
||||||
|
servers: Vec<String>,
|
||||||
|
space_password: Option<String>,
|
||||||
|
) -> Result<String> {
|
||||||
|
with_client!(self, |c| Ok(c
|
||||||
|
.accept_published_invitation(
|
||||||
|
&url,
|
||||||
|
&password,
|
||||||
|
opt(contact_name).as_deref(),
|
||||||
|
&servers,
|
||||||
|
opt(space_password).as_deref()
|
||||||
|
)
|
||||||
|
.await?))
|
||||||
|
}
|
||||||
|
|
||||||
|
// ── messages ──
|
||||||
|
|
||||||
|
pub async fn send_text(&self, contact: String, text: String) -> Result<SendResult> {
|
||||||
|
with_client!(self, |c| {
|
||||||
|
let r = c.send_text(&contact, &text).await?;
|
||||||
|
Ok(SendResult {
|
||||||
|
message_id: r.message_id,
|
||||||
|
delivered_to: r.delivered_to as u32,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn send_file(&self, contact: String, file_name: String, data: Vec<u8>) -> Result<SendResult> {
|
||||||
|
with_client!(self, |c| {
|
||||||
|
let r = c.send_file_data(&contact, &file_name, data).await?;
|
||||||
|
Ok(SendResult {
|
||||||
|
message_id: r.message_id,
|
||||||
|
delivered_to: r.delivered_to as u32,
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/// A segment of the conversation (`None`: the latest), oldest first.
|
||||||
|
pub async fn history(&self, contact: String, page: Option<u32>) -> Result<HistoryPageView> {
|
||||||
|
with_client!(self, |c| {
|
||||||
|
let p = c.history_page(&contact, page.map(|p| p as usize))?;
|
||||||
|
Ok(HistoryPageView {
|
||||||
|
messages: p.entries.into_iter().map(message_view).collect(),
|
||||||
|
page: p.page as u32,
|
||||||
|
previous: p.prev.map(|p| p as u32),
|
||||||
|
})
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Content of a received file.
|
||||||
|
pub async fn file(&self, contact: String, message_id: Vec<u8>) -> Result<Option<Vec<u8>>> {
|
||||||
|
with_client!(self, |c| Ok(c.file(&contact, &message_id)?))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Mark the conversation read (sends a read receipt unless disabled).
|
||||||
|
pub async fn mark_read(&self, contact: String) -> Result<u32> {
|
||||||
|
with_client!(self, |c| Ok(c.mark_read(&contact).await? as u32))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Messages not yet accepted by every server.
|
||||||
|
pub async fn pending_sends(&self) -> Result<Vec<PendingSendView>> {
|
||||||
|
with_client!(self, |c| Ok(c
|
||||||
|
.pending_sends()
|
||||||
|
.into_iter()
|
||||||
|
.map(|p| PendingSendView {
|
||||||
|
contact: p.contact,
|
||||||
|
message_id: p.message_id,
|
||||||
|
accepted: p.accepted,
|
||||||
|
attempts: p.attempts,
|
||||||
|
next_attempt: p.next_attempt as i64,
|
||||||
|
})
|
||||||
|
.collect()))
|
||||||
|
}
|
||||||
|
|
||||||
|
/// Retry queued messages now (e.g. when the network comes back).
|
||||||
|
pub async fn flush_outbox(&self) -> Result<()> {
|
||||||
|
with_client!(self, |c| {
|
||||||
|
c.flush_outbox().await?;
|
||||||
|
Ok(())
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
pub mod meow;
|
||||||
File diff suppressed because it is too large.
Load diff
@@ -0,0 +1,9 @@
|
|||||||
|
//! Flutter bindings for Meow v2, generated by `flutter_rust_bridge` from [`api`].
|
||||||
|
//!
|
||||||
|
//! Everything public in `api` becomes Dart. Hand-written code stays free of `unsafe`;
|
||||||
|
//! `frb_generated.rs` is generated (`flutter_rust_bridge_codegen generate`, run from
|
||||||
|
//! the Flutter app) and must not be edited.
|
||||||
|
|
||||||
|
pub mod api;
|
||||||
|
#[rustfmt::skip]
|
||||||
|
mod frb_generated;
|
||||||
Executable
+10
@@ -0,0 +1,10 @@
|
|||||||
|
#!/usr/bin/env bash
|
||||||
|
# Regenerate the Dart bindings, build the native library and the server, and run the
|
||||||
|
# Dart tests of the bindings in the Flutter app (../bastet).
|
||||||
|
set -euo pipefail
|
||||||
|
export PATH="$HOME/.cargo/bin:$PATH"
|
||||||
|
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
||||||
|
APP="$ROOT/../bastet"
|
||||||
|
(cd "$APP" && flutter_rust_bridge_codegen generate)
|
||||||
|
(cd "$ROOT" && cargo build -p meow-ffi && cargo build --bin meowsrv)
|
||||||
|
(cd "$APP" && flutter test test/meow_ffi_test.dart)
|
||||||
Reference in new issue
Block a user