From 38de744f726fb329ccf9b0fccee7cd1f91ea82dd Mon Sep 17 00:00:00 2001 From: boxdot Date: Wed, 24 Jul 2024 21:02:30 +0200 Subject: [PATCH] fix: add libsignal-service/presage linking fix (#299) --- Cargo.lock | 49 ++++++++++++++++------------------------ Cargo.toml | 10 ++++---- src/dev.rs | 18 ++++++++++++++- src/main.rs | 2 +- src/signal/attachment.rs | 2 ++ src/signal/impl.rs | 16 ++++++++++--- 6 files changed, 58 insertions(+), 39 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 3b77ef1..91a796f 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -541,9 +541,9 @@ checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" [[package]] name = "bytes" -version = "1.6.0" +version = "1.6.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "514de17de45fdb8dc022b1a7975556c53c86f9f0aa5f534b98977b171857c2c9" +checksum = "a12916984aab3fa6e39d655a33e09c0071eb36d6ab3aea5c2d78551f1df6d952" [[package]] name = "cassowary" @@ -1002,15 +1002,14 @@ dependencies = [ [[package]] name = "curve25519-dalek" -version = "4.1.1" -source = "git+https://github.com/signalapp/curve25519-dalek?tag=signal-curve25519-4.1.1#a12ab4e58455bb3dc7cd73a0f9f3443507b2854b" +version = "4.1.3" +source = "git+https://github.com/signalapp/curve25519-dalek?tag=signal-curve25519-4.1.3#7c6d34756355a3566a704da84dce7b1c039a6572" dependencies = [ "cfg-if", "cpufeatures", "curve25519-dalek-derive", "digest", "fiat-crypto", - "platforms", "rustc_version", "serde", "subtle", @@ -1019,8 +1018,8 @@ dependencies = [ [[package]] name = "curve25519-dalek-derive" -version = "0.1.0" -source = "git+https://github.com/signalapp/curve25519-dalek?tag=signal-curve25519-4.1.1#a12ab4e58455bb3dc7cd73a0f9f3443507b2854b" +version = "0.1.1" +source = "git+https://github.com/signalapp/curve25519-dalek?tag=signal-curve25519-4.1.3#7c6d34756355a3566a704da84dce7b1c039a6572" dependencies = [ "proc-macro2", "quote", @@ -2155,7 +2154,7 @@ dependencies = [ [[package]] name = "libsignal-core" version = "0.1.0" -source = "git+https://github.com/signalapp/libsignal?tag=v0.51.0#95bf4e77155b5110e80a8d140cce7adaef8aa0ac" +source = "git+https://github.com/signalapp/libsignal?tag=v0.51.1#2e2896fc235efa293213dd5f0aff4b1f8528bab2" dependencies = [ "num_enum", "uuid", @@ -2164,7 +2163,7 @@ dependencies = [ [[package]] name = "libsignal-protocol" version = "0.1.0" -source = "git+https://github.com/signalapp/libsignal?tag=v0.51.0#95bf4e77155b5110e80a8d140cce7adaef8aa0ac" +source = "git+https://github.com/signalapp/libsignal?tag=v0.51.1#2e2896fc235efa293213dd5f0aff4b1f8528bab2" dependencies = [ "aes", "aes-gcm-siv", @@ -2191,7 +2190,6 @@ dependencies = [ "serde", "sha2", "signal-crypto", - "static_assertions", "subtle", "thiserror", "uuid", @@ -2201,7 +2199,7 @@ dependencies = [ [[package]] name = "libsignal-service" version = "0.1.0" -source = "git+https://github.com/whisperfish/libsignal-service-rs?rev=5a496fd#5a496fdd96eb5e7a53fe7abea5306609239961d0" +source = "git+https://github.com/whisperfish/libsignal-service-rs?rev=1b591540b908112816be131d6baa6eafba2129cb#1b591540b908112816be131d6baa6eafba2129cb" dependencies = [ "aes", "aes-gcm", @@ -2236,7 +2234,7 @@ dependencies = [ [[package]] name = "libsignal-service-hyper" version = "0.1.0" -source = "git+https://github.com/whisperfish/libsignal-service-rs?rev=5a496fd#5a496fdd96eb5e7a53fe7abea5306609239961d0" +source = "git+https://github.com/whisperfish/libsignal-service-rs?rev=1b591540b908112816be131d6baa6eafba2129cb#1b591540b908112816be131d6baa6eafba2129cb" dependencies = [ "async-trait", "async-tungstenite", @@ -2952,9 +2950,9 @@ dependencies = [ [[package]] name = "phonenumber" -version = "0.3.5+8.13.36" +version = "0.3.6+8.13.36" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f174c8db59b620032bd52b655fc97000458850fec0db35fcd4e802b668517ec0" +checksum = "11756237b57b8cc5e97dc8b1e70ea436324d30e7075de63b14fd15073a8f692a" dependencies = [ "bincode", "either", @@ -3041,12 +3039,6 @@ version = "0.3.30" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" -[[package]] -name = "platforms" -version = "3.4.1" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0e4c7666f2019727f9e8e14bf14456e99c707d780922869f1ba473eee101fa49" - [[package]] name = "plotters" version = "0.3.6" @@ -3091,12 +3083,11 @@ dependencies = [ [[package]] name = "poksho" version = "0.7.0" -source = "git+https://github.com/signalapp/libsignal?tag=v0.51.0#95bf4e77155b5110e80a8d140cce7adaef8aa0ac" +source = "git+https://github.com/signalapp/libsignal?tag=v0.51.1#2e2896fc235efa293213dd5f0aff4b1f8528bab2" dependencies = [ "curve25519-dalek", "hmac", "sha2", - "subtle", ] [[package]] @@ -3194,8 +3185,8 @@ checksum = "94e851c7654eed9e68d7d27164c454961a616cf8c203d500607ef22c737b51bb" [[package]] name = "presage" -version = "0.6.1" -source = "git+https://github.com/whisperfish/presage?rev=f93f2de#f93f2dee5b9f0ca3b30b545143194431d9136549" +version = "0.6.2" +source = "git+https://github.com/whisperfish/presage?rev=e2392c42a0392397b9db782607fdd7ab2ea91b5f#e2392c42a0392397b9db782607fdd7ab2ea91b5f" dependencies = [ "base64 0.21.7", "futures", @@ -3215,7 +3206,7 @@ dependencies = [ [[package]] name = "presage-store-cipher" version = "0.1.0" -source = "git+https://github.com/whisperfish/presage?rev=f93f2de#f93f2dee5b9f0ca3b30b545143194431d9136549" +source = "git+https://github.com/whisperfish/presage?rev=e2392c42a0392397b9db782607fdd7ab2ea91b5f#e2392c42a0392397b9db782607fdd7ab2ea91b5f" dependencies = [ "blake3", "chacha20poly1305", @@ -3232,7 +3223,7 @@ dependencies = [ [[package]] name = "presage-store-sled" version = "0.6.0-dev" -source = "git+https://github.com/whisperfish/presage?rev=f93f2de#f93f2dee5b9f0ca3b30b545143194431d9136549" +source = "git+https://github.com/whisperfish/presage?rev=e2392c42a0392397b9db782607fdd7ab2ea91b5f#e2392c42a0392397b9db782607fdd7ab2ea91b5f" dependencies = [ "async-trait", "base64 0.21.7", @@ -3887,7 +3878,7 @@ dependencies = [ [[package]] name = "signal-crypto" version = "0.1.0" -source = "git+https://github.com/signalapp/libsignal?tag=v0.51.0#95bf4e77155b5110e80a8d140cce7adaef8aa0ac" +source = "git+https://github.com/signalapp/libsignal?tag=v0.51.1#2e2896fc235efa293213dd5f0aff4b1f8528bab2" dependencies = [ "aes", "cbc", @@ -5580,7 +5571,7 @@ dependencies = [ [[package]] name = "zkcredential" version = "0.1.0" -source = "git+https://github.com/signalapp/libsignal?tag=v0.51.0#95bf4e77155b5110e80a8d140cce7adaef8aa0ac" +source = "git+https://github.com/signalapp/libsignal?tag=v0.51.1#2e2896fc235efa293213dd5f0aff4b1f8528bab2" dependencies = [ "cfg-if", "curve25519-dalek", @@ -5599,7 +5590,7 @@ dependencies = [ [[package]] name = "zkgroup" version = "0.9.0" -source = "git+https://github.com/signalapp/libsignal?tag=v0.51.0#95bf4e77155b5110e80a8d140cce7adaef8aa0ac" +source = "git+https://github.com/signalapp/libsignal?tag=v0.51.1#2e2896fc235efa293213dd5f0aff4b1f8528bab2" dependencies = [ "aes-gcm-siv", "bincode", diff --git a/Cargo.toml b/Cargo.toml index 9a2ae2f..d6d2cc5 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -28,8 +28,8 @@ debug = true dev = ["prost", "base64"] [dependencies] -presage = { git = "https://github.com/whisperfish/presage", rev = "f93f2de" } -presage-store-sled = { git = "https://github.com/whisperfish/presage", rev = "f93f2de" } +presage = { git = "https://github.com/whisperfish/presage", rev = "e2392c42a0392397b9db782607fdd7ab2ea91b5f" } +presage-store-sled = { git = "https://github.com/whisperfish/presage", rev = "e2392c42a0392397b9db782607fdd7ab2ea91b5f" } # dev feature dependencies prost = { version = "0.12.0", optional = true } @@ -56,7 +56,7 @@ mime_guess = "2.0.4" notify-rust = "4.5.10" once_cell = "1.18.0" opener = "0.7.0" -phonenumber = "0.3.1" +phonenumber = "0.3.6" postcard = { version = "1.0.4", features = ["alloc"] } qr2term = { git = "https://github.com/boxdot/qr2term-rs", rev = "ed8ae7f" } ratatui = "0.26.0" @@ -92,7 +92,7 @@ quickcheck_macros = "1.0.0" name = "app" harness = false -[patch."https://github.com/whisperfish/presage.git"] +# [patch."https://github.com/whisperfish/presage.git"] # presage = { path = "../presage/presage" } # presage-store-sled = { path = "../presage/presage-store-sled" } # @@ -103,4 +103,4 @@ harness = false [patch.crates-io] # signal-protocol uses a fork of this library via the patch mechanism of cargo. # Since it is not transitive, we have to add the patch here explicitly. -"curve25519-dalek" = { git = 'https://github.com/signalapp/curve25519-dalek', tag = 'signal-curve25519-4.1.1' } +"curve25519-dalek" = { git = 'https://github.com/signalapp/curve25519-dalek', tag = 'signal-curve25519-4.1.3' } diff --git a/src/dev.rs b/src/dev.rs index eeb62c8..6c2b3b9 100644 --- a/src/dev.rs +++ b/src/dev.rs @@ -3,7 +3,7 @@ use std::io::BufWriter; use base64::prelude::*; use presage::libsignal_service::content::{Content, Metadata}; -use presage::libsignal_service::ServiceAddress; +use presage::libsignal_service::{ServiceAddress, ServiceIdType}; use presage::proto; use prost::Message; use serde::{Deserialize, Serialize}; @@ -19,6 +19,7 @@ pub struct ContentBase64 { #[derive(Serialize, Deserialize)] #[serde(remote = "Metadata")] struct MetadataDef { + #[serde(with = "ServiceAddressDef")] sender: ServiceAddress, sender_device: u32, timestamp: u64, @@ -27,6 +28,21 @@ struct MetadataDef { server_guid: Option, } +#[derive(Serialize, Deserialize)] +#[serde(remote = "ServiceAddress")] +struct ServiceAddressDef { + pub uuid: Uuid, + #[serde(with = "ServiceIdTypeDef")] + pub identity: ServiceIdType, +} + +#[derive(Serialize, Deserialize)] +#[serde(remote = "ServiceIdType")] +pub enum ServiceIdTypeDef { + AccountIdentity, + PhoneNumberIdentity, +} + impl From for MetadataDef { fn from(metadata: Metadata) -> Self { Self { diff --git a/src/main.rs b/src/main.rs index 7560b21..f94e30a 100644 --- a/src/main.rs +++ b/src/main.rs @@ -50,7 +50,7 @@ async fn main() -> anyhow::Result<()> { let _guard = if args.verbosity > 0 { let file_appender = tracing_appender::rolling::never("./", "gurk.log"); let (non_blocking, guard) = tracing_appender::non_blocking(file_appender); - tracing_subscriber::fmt() + tracing_subscriber::fmt::fmt() .with_max_level(match args.verbosity { 0 => LevelFilter::OFF, 1 => LevelFilter::INFO, diff --git a/src/signal/attachment.rs b/src/signal/attachment.rs index 1bb098f..fca9659 100644 --- a/src/signal/attachment.rs +++ b/src/signal/attachment.rs @@ -100,6 +100,7 @@ fn derive_name(pointer: &AttachmentPointer, digest: &[u8], mime: &Mime) -> Strin #[cfg(test)] mod tests { use hex_literal::hex; + use uuid::Uuid; use super::*; @@ -110,6 +111,7 @@ mod tests { upload_timestamp: u64, ) -> AttachmentPointer { AttachmentPointer { + uuid: Some(Uuid::nil().into_bytes().to_vec()), content_type: Some(content_type.into()), digest: Some(digest.into()), file_name: file_name.map(|s| s.to_owned()), diff --git a/src/signal/impl.rs b/src/signal/impl.rs index 8700cd6..608549b 100644 --- a/src/signal/impl.rs +++ b/src/signal/impl.rs @@ -8,6 +8,7 @@ use presage::libsignal_service::content::{Content, ContentBody}; use presage::libsignal_service::models::Contact; use presage::libsignal_service::prelude::{Group, ProfileKey}; use presage::libsignal_service::sender::AttachmentSpec; +use presage::libsignal_service::ServiceAddress; use presage::manager::{ReceivingMode, Registered}; use presage::proto::data_message::{Quote, Reaction}; use presage::proto::{AttachmentPointer, DataMessage, GroupContextV2, ReceiptMessage}; @@ -98,7 +99,10 @@ impl SignalManager for PresageManager { let mut manager = self.manager.clone(); tokio::task::spawn_local(async move { let body = ContentBody::ReceiptMessage(data_message); - if let Err(error) = manager.send_message(sender_uuid, body, now_timestamp).await { + if let Err(error) = manager + .send_message(ServiceAddress::new_aci(sender_uuid), body, now_timestamp) + .await + { error!(%error, %sender_uuid, "failed to send receipt"); } }); @@ -162,7 +166,10 @@ impl SignalManager for PresageManager { return; } let body = ContentBody::DataMessage(data_message); - if let Err(error) = manager.send_message(uuid, body, timestamp).await { + if let Err(error) = manager + .send_message(ServiceAddress::new_aci(uuid), body, timestamp) + .await + { error!(dest =% uuid, %error, "failed to send message"); let _ = response_tx.send(Err(error.into())); return; @@ -241,7 +248,10 @@ impl SignalManager for PresageManager { let mut manager = self.manager.clone(); let body = ContentBody::DataMessage(data_message); tokio::task::spawn_local(async move { - if let Err(e) = manager.send_message(uuid, body, timestamp).await { + if let Err(e) = manager + .send_message(ServiceAddress::new_aci(uuid), body, timestamp) + .await + { // TODO: Proper error handling error!("failed to send reaction {} to {}: {}", &emoji, uuid, e); }