Struct threema_gateway::E2eApi
[−]
[src]
pub struct E2eApi { /* fields omitted */ }
Struct to talk to the E2E API (with end-to-end encryption).
Methods
impl E2eApi
[src]
fn new<I: Into<String>, S: Into<String>>(
id: I,
secret: S,
private_key: SecretKey
) -> Self
id: I,
secret: S,
private_key: SecretKey
) -> Self
Initialize the simple API with the Gateway ID, the Gateway Secret and the Private Key.
fn encrypt_raw(
&self,
data: &[u8],
recipient_key: &RecipientKey
) -> EncryptedMessage
&self,
data: &[u8],
recipient_key: &RecipientKey
) -> EncryptedMessage
Encrypt raw bytes for the specified recipient public key.
fn encrypt_text_msg(
&self,
text: &str,
recipient_key: &RecipientKey
) -> EncryptedMessage
&self,
text: &str,
recipient_key: &RecipientKey
) -> EncryptedMessage
Encrypt a text message for the specified recipient public key.
fn encrypt_image_msg(
&self,
blob_id: &BlobId,
img_size_bytes: u32,
image_data_nonce: &[u8; 24],
recipient_key: &RecipientKey
) -> EncryptedMessage
&self,
blob_id: &BlobId,
img_size_bytes: u32,
image_data_nonce: &[u8; 24],
recipient_key: &RecipientKey
) -> EncryptedMessage
Encrypt an image message for the specified recipient public key.
Before calling this function, you need to encrypt the image data (JPEG
format) with encrypt_raw
and
upload the ciphertext to the blob server.
The image size needs to be specified in bytes. Note that the size is only used for download size displaying purposes and has no security implications.
fn encrypt_file_msg(
&self,
file_blob_id: &BlobId,
thumbnail_blob_id: Option<&BlobId>,
blob_encryption_key: &Key,
mime_type: &Mime,
file_name: Option<&str>,
file_size_bytes: u32,
description: Option<&str>,
recipient_key: &RecipientKey
) -> EncryptedMessage
&self,
file_blob_id: &BlobId,
thumbnail_blob_id: Option<&BlobId>,
blob_encryption_key: &Key,
mime_type: &Mime,
file_name: Option<&str>,
file_size_bytes: u32,
description: Option<&str>,
recipient_key: &RecipientKey
) -> EncryptedMessage
Encrypt a file message for the specified recipient public key.
Before calling this function, you need to symetrically encrypt the file
data (libsodium secretbox, random key) and upload the ciphertext to the
blob server. If you also want to set a thumbnail, do the same with the
update data (in JPEG format) and use the same key. Use the nonce
000...1
for the file and 000...2
for the thumbnail.
The file size needs to be specified in bytes. Note that the size is only used for download size displaying purposes and has no security implications.
fn send(&self, to: &str, message: &EncryptedMessage) -> Result<String, ApiError>
Send an encrypted E2E message to the specified Threema ID.
Cost: 1 credit.
fn lookup_pubkey(&self, id: &str) -> Result<String, ApiError>
Fetch the public key for the specified Threema ID.
For the end-to-end encrypted mode, you need the public key of the recipient in order to encrypt a message. While it's best to obtain this directly from the recipient (extract it from the QR code), this may not be convenient, and therefore you can also look up the key associated with a given ID from the server.
It is strongly recommended that you cache the public keys to avoid querying the API for each message.
fn lookup_id(&self, criterion: &LookupCriterion) -> Result<String, ApiError>
Look up a Threema ID in the directory.
An ID can be looked up either by a phone number or an e-mail
address, in plaintext or hashed form. You can specify one of those
criteria using the LookupCriterion
enum.
fn lookup_capabilities(&self, id: &str) -> Result<Capabilities, ApiError>
Look up the capabilities of a certain Threema ID.
Before you send a file to a Threema ID using the blob upload (+file message), you may want to check whether the recipient uses a Threema version that supports receiving files. The receiver may be using an old version, or a platform where file reception is not supported.
fn lookup_credits(&self) -> Result<i64, ApiError>
Look up a remaining gateway credits.
fn blob_upload(&self, data: &EncryptedMessage) -> Result<BlobId, ApiError>
Upload encrypted data to the blob server.
Cost: 1 credit.
fn blob_upload_raw(&self, data: &[u8]) -> Result<BlobId, ApiError>
Upload raw data to the blob server.
Cost: 1 credit.
Trait Implementations
impl Debug for E2eApi
[src]
impl Clone for E2eApi
[src]
fn clone(&self) -> E2eApi
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl PartialEq for E2eApi
[src]
fn eq(&self, __arg_0: &E2eApi) -> bool
This method tests for self
and other
values to be equal, and is used by ==
. Read more
fn ne(&self, __arg_0: &E2eApi) -> bool
This method tests for !=
.