pub struct SignalWebSocket<C: WebSocketType> { /* private fields */ }Expand description
A dispatching web socket client for the Signal web socket API.
This structure can be freely cloned, since this acts as a facade for multiple entry and exit points.
Implementations§
Source§impl SignalWebSocket<Identified>
impl SignalWebSocket<Identified>
Sourcepub async fn whoami(&mut self) -> Result<WhoAmIResponse, ServiceError>
pub async fn whoami(&mut self) -> Result<WhoAmIResponse, ServiceError>
Method used to check our own UUID
pub async fn set_account_attributes( &mut self, attributes: AccountAttributes, ) -> Result<(), ServiceError>
Sourcepub async fn unregister_account(&mut self) -> Result<(), ServiceError>
pub async fn unregister_account(&mut self) -> Result<(), ServiceError>
Unregister and delete the account from Signal servers.
This permanently deletes the account and all associated data (groups, contacts, messages). After calling this, the phone number can be re-registered with a fresh account.
CAUTION: This is irreversible. All account data will be lost.
Source§impl SignalWebSocket<Identified>
impl SignalWebSocket<Identified>
Sourcepub async fn discover_contacts(
&mut self,
lookup_request: LookupRequest,
) -> Result<Vec<(E164, Option<ServiceId>)>, ServiceError>
pub async fn discover_contacts( &mut self, lookup_request: LookupRequest, ) -> Result<Vec<(E164, Option<ServiceId>)>, ServiceError>
Resolve phone numbers (with possible extra information) to accounts.
Uses Contact Discovery Service (CDSI) via libsignal-net. The phone numbers are looked up inside an SGX enclave for privacy.
§Arguments
lookup_request- The CDSI lookup request containing phone numbers and other parameters
§Returns
Ok(Vec<Option<ServiceId>>)- Vector of resolved ServiceIds (None if not found)Err(ServiceError)- Network or protocol error
Sourcepub async fn discover_contact_by_phone_number(
&mut self,
phone_number: impl TryIntoE164,
) -> Result<Option<ServiceId>, ServiceError>
pub async fn discover_contact_by_phone_number( &mut self, phone_number: impl TryIntoE164, ) -> Result<Option<ServiceId>, ServiceError>
Resolve a single phone number (E.164 format, e.g., “+15551234567”) to a ServiceId.
Convenience wrapper that looks up a single phone number using CDSI.
§Arguments
phone_number- Phone number in E.164 format (e.g., “+15551234567”)
§Returns
Ok(Option<ServiceId>)- The resolved ServiceId (None if not found)Err(ServiceError)- Network or protocol error
Source§impl SignalWebSocket<Identified>
impl SignalWebSocket<Identified>
pub async fn get_pre_key_status( &mut self, service_id_kind: ServiceIdKind, ) -> Result<PreKeyStatus, ServiceError>
Sourcepub async fn check_pre_keys(
&mut self,
service_id_kind: ServiceIdKind,
digest: &[u8; 32],
) -> Result<bool, ServiceError>
pub async fn check_pre_keys( &mut self, service_id_kind: ServiceIdKind, digest: &[u8; 32], ) -> Result<bool, ServiceError>
Checks for consistency of the repeated-use keys
Supply the digest as follows:
SHA256(identityKeyBytes || signedEcPreKeyId || signedEcPreKeyIdBytes || lastResortKeyId || lastResortKeyBytes)
The IDs are represented as 8-byte big endian ints.
Retuns Ok(true) if the view is consistent, Ok(false) if the view is inconsistent.
pub async fn register_pre_keys( &mut self, service_id_kind: ServiceIdKind, pre_key_state: PreKeyState, ) -> Result<(), ServiceError>
pub async fn get_pre_key( &mut self, destination: &ServiceId, device_id: DeviceId, ) -> Result<PreKeyBundle, ServiceError>
pub async fn get_sender_certificate( &mut self, ) -> Result<SenderCertificate, ServiceError>
pub async fn get_uuid_only_sender_certificate( &mut self, ) -> Result<SenderCertificate, ServiceError>
pub async fn distribute_pni_keys( &mut self, pni_identity_key: &IdentityKey, device_messages: Vec<OutgoingPushMessage>, device_pni_signed_prekeys: HashMap<String, SignedPreKeyEntity>, device_pni_last_resort_kyber_prekeys: HashMap<String, KyberPreKeyEntity>, pni_registration_ids: HashMap<String, u32>, signature_valid_on_each_signed_pre_key: bool, ) -> Result<VerifyAccountResponse, ServiceError>
Source§impl SignalWebSocket<Identified>
impl SignalWebSocket<Identified>
pub async fn unlink_device(&mut self, id: DeviceId) -> Result<(), ServiceError>
Source§impl SignalWebSocket<Identified>
impl SignalWebSocket<Identified>
pub async fn retrieve_profile_by_id( &mut self, address: Aci, profile_key: Option<ProfileKey>, ) -> Result<SignalServiceProfile, ServiceError>
Sourcepub async fn write_profile<'s, C, S>(
&mut self,
version: &ProfileKeyVersion,
name: &[u8],
about: &[u8],
emoji: &[u8],
commitment: &ProfileKeyCommitment,
avatar: AvatarWrite<&mut C>,
) -> Result<Option<String>, ServiceError>
pub async fn write_profile<'s, C, S>( &mut self, version: &ProfileKeyVersion, name: &[u8], about: &[u8], emoji: &[u8], commitment: &ProfileKeyCommitment, avatar: AvatarWrite<&mut C>, ) -> Result<Option<String>, ServiceError>
Writes a profile and returns the avatar URL, if one was provided.
The name, about and emoji fields are encrypted with an ProfileCipher.
See AccountManager for a convenience method.
Java equivalent: writeProfile
Source§impl SignalWebSocket<Unidentified>
impl SignalWebSocket<Unidentified>
pub async fn retrieve_profile_avatar( &mut self, path: &str, ) -> Result<impl AsyncRead + Send + Unpin, ServiceError>
pub async fn retrieve_groups_v2_profile_avatar( &mut self, path: &str, ) -> Result<impl AsyncRead + Send + Unpin, ServiceError>
Source§impl SignalWebSocket<Unidentified>
impl SignalWebSocket<Unidentified>
pub async fn create_verification_session<'a>( &mut self, number: &'a str, push_token: Option<&'a str>, mcc: Option<&'a str>, mnc: Option<&'a str>, ) -> Result<RegistrationSessionMetadataResponse, ServiceError>
pub async fn patch_verification_session<'a>( &mut self, session_id: &'a str, push_token: Option<&'a str>, mcc: Option<&'a str>, mnc: Option<&'a str>, captcha: Option<&'a str>, push_challenge: Option<&'a str>, ) -> Result<RegistrationSessionMetadataResponse, ServiceError>
Sourcepub async fn request_verification_code(
&mut self,
session_id: &str,
client: &str,
transport: VerificationTransport,
) -> Result<RegistrationSessionMetadataResponse, ServiceError>
pub async fn request_verification_code( &mut self, session_id: &str, client: &str, transport: VerificationTransport, ) -> Result<RegistrationSessionMetadataResponse, ServiceError>
Request a verification code.
Signal requires a client type, and they use these three strings internally:
- “android-2021-03”
- “android”
- “ios”
“android-2021-03” allegedly implies FCM support, whereas the other strings don’t. In principle, they will consider any string as “unknown”, so other strings may work too.
Source§impl SignalWebSocket<Identified>
impl SignalWebSocket<Identified>
pub async fn submit_registration_request( &mut self, registration_method: RegistrationMethod<'_>, account_attributes: AccountAttributes, skip_device_transfer: bool, aci_identity_key: &IdentityKey, pni_identity_key: &IdentityKey, device_activation_request: DeviceActivationRequest, ) -> Result<VerifyAccountResponse, ServiceError>
pub async fn submit_verification_code( &mut self, session_id: &str, verification_code: &str, ) -> Result<RegistrationSessionMetadataResponse, ServiceError>
Source§impl<C: WebSocketType> SignalWebSocket<C>
impl<C: WebSocketType> SignalWebSocket<C>
pub async fn send_messages( &mut self, messages: OutgoingPushMessages, ) -> Result<SendMessageResponse, ServiceError>
pub async fn send_messages_unidentified( &mut self, messages: OutgoingPushMessages, access: &UnidentifiedAccess, ) -> Result<SendMessageResponse, ServiceError>
Source§impl<C: WebSocketType> SignalWebSocket<C>
impl<C: WebSocketType> SignalWebSocket<C>
pub async fn get_sticker_pack_manifest( &mut self, id: &str, ) -> Result<impl AsyncRead + Send + Unpin, ServiceError>
pub async fn get_sticker( &mut self, pack_id: &str, sticker_id: u32, ) -> Result<impl AsyncRead + Send + Unpin, ServiceError>
Source§impl SignalWebSocket<Unidentified>
impl SignalWebSocket<Unidentified>
pub async fn look_up_username( &mut self, username: &Username, ) -> Result<Option<Aci>, ServiceError>
pub async fn look_up_username_hash( &mut self, hash: &[u8], ) -> Result<Option<Aci>, ServiceError>
pub async fn look_up_username_link( &mut self, uuid: Uuid, entropy: &[u8; 32], ) -> Result<Option<Username>, ServiceError>
Source§impl<C: WebSocketType> SignalWebSocket<C>
impl<C: WebSocketType> SignalWebSocket<C>
pub fn new( ws: WebSocket, keep_alive_path: String, unidentified_push_service: PushService, ) -> (Self, impl Future<Output = ()>)
pub fn servers(&self) -> SignalServers
pub fn is_closed(&self) -> bool
pub fn is_used(&self) -> bool
pub async fn with_request_stream<R: 'static, F: FnOnce(&mut SignalRequestStream) -> R>( &mut self, f: F, ) -> R
pub fn request( &mut self, r: WebSocketRequestMessage, ) -> impl Future<Output = Result<WebSocketResponseMessage, ServiceError>>
Trait Implementations§
Source§impl<C: Clone + WebSocketType> Clone for SignalWebSocket<C>
impl<C: Clone + WebSocketType> Clone for SignalWebSocket<C>
Source§fn clone(&self) -> SignalWebSocket<C>
fn clone(&self) -> SignalWebSocket<C>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl<C> Freeze for SignalWebSocket<C>
impl<C> !RefUnwindSafe for SignalWebSocket<C>
impl<C> Send for SignalWebSocket<C>where
C: Send,
impl<C> Sync for SignalWebSocket<C>where
C: Sync,
impl<C> Unpin for SignalWebSocket<C>where
C: Unpin,
impl<C> !UnwindSafe for SignalWebSocket<C>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Classify for T
impl<T> Classify for T
type Classified = T
fn classify(self) -> T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> Declassify for T
impl<T> Declassify for T
type Declassified = T
fn declassify(self) -> T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].