Page MenuHomePhabricator

D11469.diff
No OneTemporary

D11469.diff

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
@@ -20,8 +20,8 @@
UploadOneTimeKeysRequest,
};
use grpc_clients::identity::protos::unauth::{
- AuthResponse, DeviceKeyUpload, DeviceType, Empty, IdentityKeyInfo,
- OpaqueLoginFinishRequest, OpaqueLoginStartRequest, Prekey,
+ AuthResponse, DeviceKeyUpload, DeviceType, Empty, ExistingDeviceLoginRequest,
+ IdentityKeyInfo, OpaqueLoginFinishRequest, OpaqueLoginStartRequest, Prekey,
RegistrationFinishRequest, RegistrationStartRequest,
SecondaryDeviceKeysUploadRequest, WalletAuthRequest,
};
@@ -240,6 +240,14 @@
promise_id: u32,
);
+ #[cxx_name = "identityLogInExistingDevice"]
+ fn log_in_existing_device(
+ user_id: String,
+ device_id: String,
+ challenge_response: String,
+ promise_id: u32,
+ );
+
#[cxx_name = "identityFindUserIDForWalletAddress"]
fn find_user_id_for_wallet_address(wallet_address: String, promise_id: u32);
@@ -1502,6 +1510,47 @@
Ok(serde_json::to_string(&user_id_and_access_token)?)
}
+fn log_in_existing_device(
+ user_id: String,
+ device_id: String,
+ challenge_response: String,
+ promise_id: u32,
+) {
+ RUNTIME.spawn(async move {
+ let result =
+ log_in_existing_device_helper(user_id, device_id, challenge_response)
+ .await;
+ handle_string_result_as_callback(result, promise_id);
+ });
+}
+
+async fn log_in_existing_device_helper(
+ user_id: String,
+ device_id: String,
+ challenge_response: String,
+) -> Result<String, Error> {
+ let mut identity_client = get_unauthenticated_client(
+ IDENTITY_SOCKET_ADDR,
+ CODE_VERSION,
+ DEVICE_TYPE.as_str_name().to_lowercase(),
+ )
+ .await?;
+
+ let request = ExistingDeviceLoginRequest {
+ user_id,
+ device_id,
+ challenge_response,
+ };
+
+ let response = identity_client
+ .log_in_existing_device(request)
+ .await?
+ .into_inner();
+
+ let user_id_and_access_token = UserIDAndDeviceAccessToken::from(response);
+ Ok(serde_json::to_string(&user_id_and_access_token)?)
+}
+
#[derive(
Debug, derive_more::Display, derive_more::From, derive_more::Error,
)]

File Metadata

Mime Type
text/plain
Expires
Thu, Dec 19, 7:26 PM (18 h, 24 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2678577
Default Alt Text
D11469.diff (2 KB)

Event Timeline