Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32523297
D11080.1767135029.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
4 KB
Referenced Files
None
Subscribers
None
D11080.1767135029.diff
View Options
diff --git a/native/native_rust_library/src/lib.rs b/native/native_rust_library/src/lib.rs
--- a/native/native_rust_library/src/lib.rs
+++ b/native/native_rust_library/src/lib.rs
@@ -27,10 +27,12 @@
use tokio::runtime::{Builder, Runtime};
use tonic::{Request, Status};
use tracing::instrument;
+use wallet_registration::register_wallet_user;
mod argon2_tools;
mod backup;
mod constants;
+mod wallet_registration;
use argon2_tools::compute_backup_key_str;
@@ -88,6 +90,21 @@
promise_id: u32,
);
+ #[cxx_name = "identityRegisterWalletUser"]
+ fn register_wallet_user(
+ siwe_message: String,
+ siwe_signature: String,
+ key_payload: String,
+ key_payload_signature: String,
+ content_prekey: String,
+ content_prekey_signature: String,
+ notif_prekey: String,
+ notif_prekey_signature: String,
+ content_one_time_keys: Vec<String>,
+ notif_one_time_keys: Vec<String>,
+ promise_id: u32,
+ );
+
#[cxx_name = "identityLogInWalletUser"]
fn log_in_wallet_user(
siwe_message: String,
diff --git a/native/native_rust_library/src/wallet_registration.rs b/native/native_rust_library/src/wallet_registration.rs
new file mode 100644
--- /dev/null
+++ b/native/native_rust_library/src/wallet_registration.rs
@@ -0,0 +1,88 @@
+use crate::{
+ handle_string_result_as_callback, Error, UserIDAndDeviceAccessToken,
+ WalletUserInfo, CODE_VERSION, DEVICE_TYPE, IDENTITY_SOCKET_ADDR, RUNTIME,
+};
+use grpc_clients::identity::{
+ get_unauthenticated_client,
+ protos::unauth::{
+ DeviceKeyUpload, IdentityKeyInfo, Prekey, WalletAuthRequest,
+ },
+};
+use tracing::instrument;
+
+#[instrument]
+pub fn register_wallet_user(
+ siwe_message: String,
+ siwe_signature: String,
+ key_payload: String,
+ key_payload_signature: String,
+ content_prekey: String,
+ content_prekey_signature: String,
+ notif_prekey: String,
+ notif_prekey_signature: String,
+ content_one_time_keys: Vec<String>,
+ notif_one_time_keys: Vec<String>,
+ promise_id: u32,
+) {
+ RUNTIME.spawn(async move {
+ let wallet_user_info = WalletUserInfo {
+ siwe_message,
+ siwe_signature,
+ key_payload,
+ key_payload_signature,
+ content_prekey,
+ content_prekey_signature,
+ notif_prekey,
+ notif_prekey_signature,
+ content_one_time_keys,
+ notif_one_time_keys,
+ };
+ let result = register_wallet_user_helper(wallet_user_info).await;
+ handle_string_result_as_callback(result, promise_id);
+ });
+}
+
+async fn register_wallet_user_helper(
+ wallet_user_info: WalletUserInfo,
+) -> Result<String, Error> {
+ let registration_request = WalletAuthRequest {
+ siwe_message: wallet_user_info.siwe_message,
+ siwe_signature: wallet_user_info.siwe_signature,
+ device_key_upload: Some(DeviceKeyUpload {
+ device_key_info: Some(IdentityKeyInfo {
+ payload: wallet_user_info.key_payload,
+ payload_signature: wallet_user_info.key_payload_signature,
+ social_proof: None, // The SIWE message and signature are the social proof
+ }),
+ content_upload: Some(Prekey {
+ prekey: wallet_user_info.content_prekey,
+ prekey_signature: wallet_user_info.content_prekey_signature,
+ }),
+ notif_upload: Some(Prekey {
+ prekey: wallet_user_info.notif_prekey,
+ prekey_signature: wallet_user_info.notif_prekey_signature,
+ }),
+ one_time_content_prekeys: wallet_user_info.content_one_time_keys,
+ one_time_notif_prekeys: wallet_user_info.notif_one_time_keys,
+ device_type: DEVICE_TYPE.into(),
+ }),
+ };
+
+ let mut identity_client = get_unauthenticated_client(
+ IDENTITY_SOCKET_ADDR,
+ CODE_VERSION,
+ DEVICE_TYPE.as_str_name().to_lowercase(),
+ )
+ .await?;
+
+ let registration_response = identity_client
+ .register_wallet_user(registration_request)
+ .await?
+ .into_inner();
+
+ let user_id_and_access_token = UserIDAndDeviceAccessToken {
+ user_id: registration_response.user_id,
+ access_token: registration_response.access_token,
+ };
+ Ok(serde_json::to_string(&user_id_and_access_token)?)
+}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Dec 30, 10:50 PM (16 h, 38 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5870602
Default Alt Text
D11080.1767135029.diff (4 KB)
Attached To
Mode
D11080: [native_rust_library] add register_wallet_user function
Attached
Detach File
Event Timeline
Log In to Comment