Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3333741
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
8 KB
Referenced Files
None
Subscribers
None
View Options
diff --git a/native/native_rust_library/src/identity_client.rs b/native/native_rust_library/src/identity_client.rs
index 7d66880a1..3b13d7e4e 100644
--- a/native/native_rust_library/src/identity_client.rs
+++ b/native/native_rust_library/src/identity_client.rs
@@ -1,32 +1,52 @@
use tonic::Status;
use crate::IdentityClient;
pub async fn register_user(
mut _client: Box<IdentityClient>,
- _user_id: String,
- _signing_public_key: String,
_username: String,
_password: String,
+ _key_payload: String,
+ _key_payload_signature: String,
+ _identity_prekey: String,
+ _identity_prekey_signature: String,
+ _notif_prekey: String,
+ _notif_prekey_signature: String,
+ _identity_onetime_keys: Vec<String>,
+ _notif_onetime_keys: Vec<String>,
) -> Result<String, Status> {
unimplemented!();
}
+// User could be logging in from new device, need to resend device information
pub async fn login_user_pake(
mut _client: Box<IdentityClient>,
- _user_id: String,
- _signing_public_key: String,
+ _username: String,
_password: String,
+ _key_payload: String,
+ _key_payload_signature: String,
+ _identity_prekey: String,
+ _identity_prekey_signature: String,
+ _notif_prekey: String,
+ _notif_prekey_signature: String,
+ _identity_onetime_keys: Vec<String>,
+ _notif_onetime_keys: Vec<String>,
) -> Result<String, Status> {
unimplemented!();
}
pub async fn login_user_wallet(
mut _client: Box<IdentityClient>,
- _user_id: String,
- _signing_public_key: String,
_siwe_message: String,
_siwe_signature: String,
+ _key_payload: String,
+ _key_payload_signature: String,
+ _identity_prekey: String,
+ _identity_prekey_signature: String,
+ _notif_prekey: String,
+ _notif_prekey_signature: String,
+ _identity_onetime_keys: Vec<String>,
+ _notif_onetime_keys: Vec<String>,
) -> Result<String, Status> {
unimplemented!();
}
diff --git a/native/native_rust_library/src/lib.rs b/native/native_rust_library/src/lib.rs
index a875ab191..f8bf31e08 100644
--- a/native/native_rust_library/src/lib.rs
+++ b/native/native_rust_library/src/lib.rs
@@ -1,157 +1,214 @@
use lazy_static::lazy_static;
use std::sync::Arc;
use tokio::runtime::{Builder, Runtime};
use tonic::{transport::Channel, Status};
use tracing::instrument;
use tunnelbroker::tunnelbroker_service_client::TunnelbrokerServiceClient;
mod crypto_tools;
mod identity_client;
mod identity {
tonic::include_proto!("identity.client");
}
mod tunnelbroker {
tonic::include_proto!("tunnelbroker");
}
use crypto_tools::generate_device_id;
use identity::identity_client_service_client::IdentityClientServiceClient;
lazy_static! {
pub static ref RUNTIME: Arc<Runtime> = Arc::new(
Builder::new_multi_thread()
.worker_threads(1)
.max_blocking_threads(1)
.enable_all()
.build()
.unwrap()
);
}
#[cxx::bridge]
mod ffi {
enum DeviceType {
KEYSERVER,
WEB,
MOBILE,
}
extern "Rust" {
// Identity Service Client
type IdentityClient;
#[cxx_name = "identityInitializeClient"]
fn initialize_identity_client(addr: String) -> Box<IdentityClient>;
#[cxx_name = "identityRegisterUserBlocking"]
fn identity_register_user_blocking(
client: Box<IdentityClient>,
- user_id: String,
- signing_public_key: String,
username: String,
password: String,
+ key_payload: String,
+ key_payload_signature: String,
+ identity_prekey: String,
+ identity_prekey_signature: String,
+ notif_prekey: String,
+ notif_prekey_signature: String,
+ identity_onetime_keys: Vec<String>,
+ notif_onetime_keys: Vec<String>,
) -> Result<String>;
#[cxx_name = "identityLoginUserPakeBlocking"]
fn identity_login_user_pake_blocking(
client: Box<IdentityClient>,
- user_id: String,
- signing_public_key: String,
+ username: String,
password: String,
+ key_payload: String,
+ key_payload_signature: String,
+ identity_prekey: String,
+ identity_prekey_signature: String,
+ notif_prekey: String,
+ notif_prekey_signature: String,
+ identity_onetime_keys: Vec<String>,
+ notif_onetime_keys: Vec<String>,
) -> Result<String>;
#[cxx_name = "identityLoginUserWalletBlocking"]
fn identity_login_user_wallet_blocking(
client: Box<IdentityClient>,
- user_id: String,
- signing_public_key: String,
siwe_message: String,
siwe_signature: String,
+ key_payload: String,
+ key_payload_signature: String,
+ identity_prekey: String,
+ identity_prekey_signature: String,
+ notif_prekey: String,
+ notif_prekey_signature: String,
+ identity_onetime_keys: Vec<String>,
+ notif_onetime_keys: Vec<String>,
) -> Result<String>;
// Tunnelbroker Service Client
type TunnelbrokerClient;
#[cxx_name = "TunnelbrokerInitializeClient"]
fn initialize_tunnelbroker_client(addr: String) -> Box<TunnelbrokerClient>;
// Crypto Tools
fn generate_device_id(device_type: DeviceType) -> Result<String>;
}
}
#[derive(Debug)]
pub struct IdentityClient {
identity_client: IdentityClientServiceClient<Channel>,
}
fn initialize_identity_client(addr: String) -> Box<IdentityClient> {
Box::new(IdentityClient {
identity_client: RUNTIME
.block_on(IdentityClientServiceClient::connect(addr))
.unwrap(),
})
}
#[instrument]
fn identity_register_user_blocking(
client: Box<IdentityClient>,
- user_id: String,
- signing_public_key: String,
username: String,
password: String,
+ key_payload: String,
+ key_payload_signature: String,
+ identity_prekey: String,
+ identity_prekey_signature: String,
+ notif_prekey: String,
+ notif_prekey_signature: String,
+ identity_onetime_keys: Vec<String>,
+ notif_onetime_keys: Vec<String>,
) -> Result<String, Status> {
RUNTIME.block_on(identity_client::register_user(
client,
- user_id,
- signing_public_key,
username,
password,
+ key_payload,
+ key_payload_signature,
+ identity_prekey,
+ identity_prekey_signature,
+ notif_prekey,
+ notif_prekey_signature,
+ identity_onetime_keys,
+ notif_onetime_keys,
))
}
#[instrument]
fn identity_login_user_pake_blocking(
client: Box<IdentityClient>,
- user_id: String,
- signing_public_key: String,
+ username: String,
password: String,
+ key_payload: String,
+ key_payload_signature: String,
+ identity_prekey: String,
+ identity_prekey_signature: String,
+ notif_prekey: String,
+ notif_prekey_signature: String,
+ identity_onetime_keys: Vec<String>,
+ notif_onetime_keys: Vec<String>,
) -> Result<String, Status> {
RUNTIME.block_on(identity_client::login_user_pake(
client,
- user_id,
- signing_public_key,
+ username,
password,
+ key_payload,
+ key_payload_signature,
+ identity_prekey,
+ identity_prekey_signature,
+ notif_prekey,
+ notif_prekey_signature,
+ identity_onetime_keys,
+ notif_onetime_keys,
))
}
#[instrument]
fn identity_login_user_wallet_blocking(
client: Box<IdentityClient>,
- user_id: String,
- signing_public_key: String,
siwe_message: String,
siwe_signature: String,
+ key_payload: String,
+ key_payload_signature: String,
+ identity_prekey: String,
+ identity_prekey_signature: String,
+ notif_prekey: String,
+ notif_prekey_signature: String,
+ identity_onetime_keys: Vec<String>,
+ notif_onetime_keys: Vec<String>,
) -> Result<String, Status> {
RUNTIME.block_on(identity_client::login_user_wallet(
client,
- user_id,
- signing_public_key,
siwe_message,
siwe_signature,
+ key_payload,
+ key_payload_signature,
+ identity_prekey,
+ identity_prekey_signature,
+ notif_prekey,
+ notif_prekey_signature,
+ identity_onetime_keys,
+ notif_onetime_keys,
))
}
#[derive(Debug)]
pub struct TunnelbrokerClient {
tunnelbroker_client: TunnelbrokerServiceClient<Channel>,
}
fn initialize_tunnelbroker_client(addr: String) -> Box<TunnelbrokerClient> {
Box::new(TunnelbrokerClient {
tunnelbroker_client: RUNTIME
.block_on(TunnelbrokerServiceClient::connect(addr))
.expect("Failed to create Tokio runtime for the Tunnelbroker client"),
})
}
File Metadata
Details
Attached
Mime Type
text/x-diff
Expires
Sat, Nov 23, 5:09 AM (1 d, 18 h)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2560045
Default Alt Text
(8 KB)
Attached To
Mode
rCOMM Comm
Attached
Detach File
Event Timeline
Log In to Comment