Page Menu
Home
Phorge
Search
Configure Global Search
Log In
Files
F32632596
D13230.1767486820.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Flag For Later
Award Token
Size
6 KB
Referenced Files
None
Subscribers
None
D13230.1767486820.diff
View Options
diff --git a/native/native_rust_library/src/identity.rs b/native/native_rust_library/src/identity.rs
--- a/native/native_rust_library/src/identity.rs
+++ b/native/native_rust_library/src/identity.rs
@@ -145,6 +145,21 @@
pub initial_device_list: String,
}
+pub struct RestorePasswordUserInfo {
+ pub username: String,
+ pub nonce: String,
+ pub nonce_signature: String,
+ pub device_keys: DeviceKeys,
+ pub device_list: String,
+}
+
+pub struct RestoreWalletUserInfo {
+ pub siwe_message: String,
+ pub siwe_signature: String,
+ pub device_keys: DeviceKeys,
+ pub device_list: String,
+}
+
/// Counterpart of proto [`AuthResponse`] message
/// that implements the `Serialize` trait.
#[derive(Serialize)]
diff --git a/native/native_rust_library/src/identity/login.rs b/native/native_rust_library/src/identity/login.rs
--- a/native/native_rust_library/src/identity/login.rs
+++ b/native/native_rust_library/src/identity/login.rs
@@ -4,6 +4,7 @@
protos::unauth::{
DeviceKeyUpload, ExistingDeviceLoginRequest, IdentityKeyInfo,
OpaqueLoginFinishRequest, OpaqueLoginStartRequest, Prekey,
+ RestorePasswordUserRequest, RestoreWalletUserRequest,
SecondaryDeviceKeysUploadRequest, WalletAuthRequest,
},
};
@@ -11,7 +12,7 @@
use super::{
IdentityAuthResult, LogInPasswordUserInfo, LogInWalletUserInfo,
- PLATFORM_METADATA,
+ RestorePasswordUserInfo, RestoreWalletUserInfo, PLATFORM_METADATA,
};
use crate::utils::jsi_callbacks::handle_string_result_as_callback;
use crate::{Error, DEVICE_TYPE, IDENTITY_SOCKET_ADDR, RUNTIME};
@@ -88,6 +89,81 @@
});
}
+ // Primary device restore
+ #[instrument]
+ pub fn restore_password_user(
+ username: String,
+ nonce: String,
+ nonce_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>,
+ device_list: String,
+ promise_id: u32,
+ ) {
+ RUNTIME.spawn(async move {
+ let password_user_info = RestorePasswordUserInfo {
+ username,
+ nonce,
+ nonce_signature,
+ device_list,
+ device_keys: DeviceKeys {
+ 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 = restore_password_user_helper(password_user_info).await;
+ handle_string_result_as_callback(result, promise_id);
+ });
+ }
+
+ #[instrument]
+ pub fn restore_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>,
+ device_list: String,
+ promise_id: u32,
+ ) {
+ RUNTIME.spawn(async move {
+ let wallet_user_info = RestoreWalletUserInfo {
+ siwe_message,
+ siwe_signature,
+ device_list,
+ device_keys: DeviceKeys {
+ 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 = restore_wallet_user_helper(wallet_user_info).await;
+ handle_string_result_as_callback(result, promise_id);
+ });
+ }
+
// QR code device log in
pub fn upload_secondary_device_keys_and_log_in(
user_id: String,
@@ -218,6 +294,53 @@
Ok(serde_json::to_string(&auth_result)?)
}
+async fn restore_password_user_helper(
+ password_user_info: RestorePasswordUserInfo,
+) -> Result<String, Error> {
+ let restore_request = RestorePasswordUserRequest {
+ username: password_user_info.username,
+ nonce: password_user_info.nonce,
+ nonce_signature: password_user_info.nonce_signature,
+ device_list: password_user_info.device_list,
+ device_key_upload: Some(password_user_info.device_keys.into()),
+ };
+
+ let mut identity_client =
+ get_unauthenticated_client(IDENTITY_SOCKET_ADDR, PLATFORM_METADATA.clone())
+ .await?;
+
+ let auth_response = identity_client
+ .restore_password_user(restore_request)
+ .await?
+ .into_inner();
+
+ let auth_result = IdentityAuthResult::from(auth_response);
+ Ok(serde_json::to_string(&auth_result)?)
+}
+
+async fn restore_wallet_user_helper(
+ wallet_user_info: RestoreWalletUserInfo,
+) -> Result<String, Error> {
+ let restore_request = RestoreWalletUserRequest {
+ siwe_message: wallet_user_info.siwe_message,
+ siwe_signature: wallet_user_info.siwe_signature,
+ device_list: wallet_user_info.device_list,
+ device_key_upload: Some(wallet_user_info.device_keys.into()),
+ };
+
+ let mut identity_client =
+ get_unauthenticated_client(IDENTITY_SOCKET_ADDR, PLATFORM_METADATA.clone())
+ .await?;
+
+ let auth_response = identity_client
+ .restore_wallet_user(restore_request)
+ .await?
+ .into_inner();
+
+ let auth_result = IdentityAuthResult::from(auth_response);
+ Ok(serde_json::to_string(&auth_result)?)
+}
+
async fn upload_secondary_device_keys_and_log_in_helper(
user_id: String,
nonce: String,
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
@@ -125,6 +125,39 @@
promise_id: u32,
);
+ #[cxx_name = "identityRestorePasswordUser"]
+ fn restore_password_user(
+ username: String,
+ nonce: String,
+ nonce_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>,
+ device_list: String,
+ promise_id: u32,
+ );
+
+ #[cxx_name = "identityRestoreWalletUser"]
+ fn restore_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>,
+ device_list: String,
+ promise_id: u32,
+ );
+
#[cxx_name = "identityUpdateUserPassword"]
fn update_user_password(
user_id: String,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Jan 4, 12:33 AM (12 h, 26 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
5891555
Default Alt Text
D13230.1767486820.diff (6 KB)
Attached To
Mode
D13230: [native_rust_library] Add RestoreUser RPCs to client
Attached
Detach File
Event Timeline
Log In to Comment