Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3491507
D11469.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
2 KB
Referenced Files
None
Subscribers
None
D11469.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
@@ -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
Details
Attached
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)
Attached To
Mode
D11469: [native] Add LogInExistingDevice to native_rust_library
Attached
Detach File
Event Timeline
Log In to Comment