core_crypto_ffi/core_crypto/
proteus.rs1#[cfg(target_family = "wasm")]
2use wasm_bindgen::prelude::*;
3
4use crate::{CoreCrypto, CoreCryptoResult, proteus_impl};
5
6#[cfg_attr(not(target_family = "wasm"), uniffi::export)]
7#[cfg_attr(target_family = "wasm", wasm_bindgen)]
8impl CoreCrypto {
9 pub async fn proteus_session_exists(&self, session_id: String) -> CoreCryptoResult<bool> {
11 proteus_impl!({ self.inner.proteus_session_exists(&session_id).await.map_err(Into::into) })
12 }
13
14 pub async fn proteus_fingerprint(&self) -> CoreCryptoResult<String> {
16 proteus_impl!({ self.inner.proteus_fingerprint().await.map_err(Into::into) })
17 }
18
19 pub async fn proteus_fingerprint_local(&self, session_id: String) -> CoreCryptoResult<String> {
21 proteus_impl!({
22 self.inner
23 .proteus_fingerprint_local(&session_id)
24 .await
25 .map_err(Into::into)
26 })
27 }
28
29 pub async fn proteus_fingerprint_remote(&self, session_id: String) -> CoreCryptoResult<String> {
31 proteus_impl!({
32 self.inner
33 .proteus_fingerprint_remote(&session_id)
34 .await
35 .map_err(Into::into)
36 })
37 }
38}
39
40fn last_resort_prekey_id_inner() -> CoreCryptoResult<u16> {
44 proteus_impl!({ Ok(core_crypto::CoreCrypto::proteus_last_resort_prekey_id()) })
45}
46
47fn fingerprint_prekeybundle_inner(prekey: Vec<u8>) -> CoreCryptoResult<String> {
49 proteus_impl!({ core_crypto::proteus::ProteusCentral::fingerprint_prekeybundle(&prekey).map_err(Into::into) })
50}
51
52#[cfg(target_family = "wasm")]
53#[wasm_bindgen]
54impl CoreCrypto {
55 pub fn proteus_last_resort_prekey_id() -> CoreCryptoResult<u16> {
57 last_resort_prekey_id_inner()
58 }
59
60 pub fn proteus_fingerprint_prekeybundle(prekey: Vec<u8>) -> CoreCryptoResult<String> {
62 fingerprint_prekeybundle_inner(prekey)
63 }
64}
65
66#[cfg(not(target_family = "wasm"))]
67#[uniffi::export]
68impl CoreCrypto {
69 pub fn proteus_last_resort_prekey_id(&self) -> CoreCryptoResult<u16> {
71 last_resort_prekey_id_inner()
72 }
73
74 pub fn proteus_fingerprint_prekeybundle(&self, prekey: Vec<u8>) -> CoreCryptoResult<String> {
76 fingerprint_prekeybundle_inner(prekey)
77 }
78}