diff --git a/libsignal-service/protobuf/SignalService.proto b/libsignal-service/protobuf/SignalService.proto index 2de3e6ac7..37506c78a 100644 --- a/libsignal-service/protobuf/SignalService.proto +++ b/libsignal-service/protobuf/SignalService.proto @@ -439,9 +439,11 @@ message Verified { message SyncMessage { message Sent { message UnidentifiedDeliveryStatus { - reserved /*destinationE164*/ 1; - optional string destinationServiceId = 3; - optional bool unidentified = 2; + reserved /*destinationE164*/ 1; + optional string destinationServiceId = 3; + optional bool unidentified = 2; + reserved /*destinationPni*/ 4; + optional bytes destinationIdentityKey = 5; } message StoryMessageRecipient { @@ -460,6 +462,8 @@ message SyncMessage { optional StoryMessage storyMessage = 8; repeated StoryMessageRecipient storyMessageRecipients = 9; optional EditMessage editMessage = 10; + reserved /*destinationPni*/ 11; + // NEXT ID: 12 } message Contacts { @@ -610,6 +614,7 @@ message SyncMessage { ACCEPTED = 1; NOT_ACCEPTED = 2; DELETE = 3; + OBSERVED = 4; } optional bytes conversationId = 1; @@ -621,17 +626,79 @@ message SyncMessage { } message CallLinkUpdate { + enum Type { + UPDATE = 0; + DELETE = 1; + } + optional bytes rootKey = 1; optional bytes adminPassKey = 2; + optional Type type = 3; } message CallLogEvent { enum Type { - CLEAR = 0; + CLEAR = 0; + MARKED_AS_READ = 1; + MARKED_AS_READ_IN_CONVERSATION = 2; + } + + optional Type type = 1; + optional uint64 timestamp = 2; + /* Data identifying a conversation. The service ID for 1:1, the group ID for + * group, or the room ID for an ad-hoc call. See also + * `CallEvent/conversationId`. */ + optional bytes conversationId = 3; + /* An identifier for a call. Generated directly for 1:1, or derived from + * the era ID for group and ad-hoc calls. See also `CallEvent/callId`. */ + optional uint64 callId = 4; + } + + message DeleteForMe { + message ConversationIdentifier { + oneof identifier { + string threadServiceId = 1; + bytes threadGroupId = 2; + string threadE164 = 3; + } + } + + message AddressableMessage { + oneof author { + string authorServiceId = 1; + string authorE164 = 2; + } + optional uint64 sentTimestamp = 3; + } + + message MessageDeletes { + optional ConversationIdentifier conversation = 1; + repeated AddressableMessage messages = 2; + } + + message AttachmentDelete { + optional ConversationIdentifier conversation = 1; + optional AddressableMessage targetMessage = 2; + optional bytes uuid = 3; // The `uuid` from the `Attachment`. + optional bytes fallbackDigest = 4; + optional bytes fallbackPlaintextHash = 5; + } + + message ConversationDelete { + optional ConversationIdentifier conversation = 1; + repeated AddressableMessage mostRecentMessages = 2; + repeated AddressableMessage mostRecentNonExpiringMessages = 4; + optional bool isFullDelete = 3; + } + + message LocalOnlyConversationDelete { + optional ConversationIdentifier conversation = 1; } - optional Type type = 1; - optional uint64 timestamp = 2; + repeated MessageDeletes messageDeletes = 1; + repeated ConversationDelete conversationDeletes = 2; + repeated LocalOnlyConversationDelete localOnlyConversationDeletes = 3; + repeated AttachmentDelete attachmentDeletes = 4; } optional Sent sent = 1; @@ -655,6 +722,7 @@ message SyncMessage { optional CallEvent callEvent = 19; optional CallLinkUpdate callLinkUpdate = 20; optional CallLogEvent callLogEvent = 21; + optional DeleteForMe deleteForMe = 22; } message AttachmentPointer { @@ -686,7 +754,8 @@ message AttachmentPointer { optional string blurHash = 12; optional uint64 uploadTimestamp = 13; optional uint32 cdnNumber = 14; - // Next ID: 19 + optional bytes uuid = 20; + // Next ID: 21 } message GroupContext { @@ -730,7 +799,7 @@ message ContactDetails { optional string color = 4; optional Verified verified = 5; optional bytes profileKey = 6; - optional bool blocked = 7; + reserved /*blocked*/ 7; optional uint32 expireTimer = 8; optional uint32 inboxPosition = 10; optional bool archived = 11; diff --git a/libsignal-service/protobuf/update-protos.sh b/libsignal-service/protobuf/update-protos.sh index 12d264a1e..9cecc710e 100755 --- a/libsignal-service/protobuf/update-protos.sh +++ b/libsignal-service/protobuf/update-protos.sh @@ -3,11 +3,11 @@ set -euo pipefail update_proto() { case "$1" in - Signal-Android) - git_revision="940cee0f30d6a2873ae08c65bb821c34302ccf5d" + Signal-Android) + git_revision="251cec5dee06d8d36f0177967d675e8eac2ba32f" prefix="libsignal-service/src/main/protowire/";; Signal-Desktop) - git_revision="70858d9063446b07b19c03ae7d0c01075a2849e3" + git_revision="f46872b6e980132e8045b3288eb88d803f365a10" prefix="protos/";; esac curl -LOf https://raw.githubusercontent.com/signalapp/${1}/${git_revision}/${prefix}${2} diff --git a/libsignal-service/src/models.rs b/libsignal-service/src/models.rs index 0ff81cf95..a780dc0f9 100644 --- a/libsignal-service/src/models.rs +++ b/libsignal-service/src/models.rs @@ -28,7 +28,6 @@ pub struct Contact { #[serde(skip)] pub verified: Verified, pub profile_key: Vec, - pub blocked: bool, pub expire_timer: u32, pub inbox_position: u32, pub archived: bool, @@ -69,7 +68,6 @@ impl Contact { color: contact_details.color.clone(), verified: contact_details.verified.clone().unwrap_or_default(), profile_key: contact_details.profile_key().to_vec(), - blocked: contact_details.blocked(), expire_timer: contact_details.expire_timer(), inbox_position: contact_details.inbox_position(), archived: contact_details.archived(), diff --git a/libsignal-service/src/sender.rs b/libsignal-service/src/sender.rs index cc168c0ff..d838f8e33 100644 --- a/libsignal-service/src/sender.rs +++ b/libsignal-service/src/sender.rs @@ -2,8 +2,8 @@ use std::{collections::HashSet, time::SystemTime}; use chrono::prelude::*; use libsignal_protocol::{ - process_prekey_bundle, DeviceId, IdentityKeyPair, ProtocolStore, - SenderCertificate, SenderKeyStore, SignalProtocolError, + process_prekey_bundle, DeviceId, IdentityKey, IdentityKeyPair, + ProtocolStore, SenderCertificate, SenderKeyStore, SignalProtocolError, }; use rand::{CryptoRng, Rng}; use tracing::{info, trace}; @@ -55,6 +55,7 @@ pub type SendMessageResult = Result; #[derive(Debug, Clone)] pub struct SentMessage { pub recipient: ServiceAddress, + pub used_identity_key: IdentityKey, pub unidentified: bool, pub needs_sync: bool, } @@ -490,7 +491,7 @@ where let content_bytes = content.encode_to_vec(); for _ in 0..4u8 { - let messages = self + let (messages, used_identity_key) = self .create_encrypted_messages( &recipient, unidentified_access.map(|x| &x.certificate), @@ -520,6 +521,7 @@ where tracing::debug!("message sent!"); return Ok(SentMessage { recipient, + used_identity_key, unidentified: unidentified_access.is_some(), needs_sync, }); @@ -704,7 +706,8 @@ where recipient: &ServiceAddress, unidentified_access: Option<&SenderCertificate>, content: &[u8], - ) -> Result, MessageSenderError> { + ) -> Result<(Vec, IdentityKey), MessageSenderError> + { let mut messages = vec![]; let mut devices: HashSet = self @@ -776,7 +779,15 @@ where } } - Ok(messages) + let identity_key = self + .protocol_store + .get_identity(&recipient.to_protocol_address(DEFAULT_DEVICE_ID)) + .await? + .ok_or(MessageSenderError::UntrustedIdentity { + address: *recipient, + })?; + + Ok((messages, identity_key)) } /// Equivalent to `getEncryptedMessage` @@ -883,6 +894,7 @@ where let SentMessage { recipient, unidentified, + used_identity_key, .. } = sent; UnidentifiedDeliveryStatus { @@ -890,6 +902,9 @@ where recipient.uuid.to_string(), ), unidentified: Some(*unidentified), + destination_identity_key: Some( + used_identity_key.serialize().into(), + ), } }) .collect();