Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F2897455
D12283.id40851.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
32 KB
Referenced Files
None
Subscribers
None
D12283.id40851.diff
View Options
diff --git a/keyserver/addons/rust-node-addon/src/identity_client/mod.rs b/keyserver/addons/rust-node-addon/src/identity_client/mod.rs
--- a/keyserver/addons/rust-node-addon/src/identity_client/mod.rs
+++ b/keyserver/addons/rust-node-addon/src/identity_client/mod.rs
@@ -23,6 +23,7 @@
};
use grpc_clients::identity::protos::unauthenticated as client_proto;
use grpc_clients::identity::shared::CodeVersionLayer;
+use grpc_clients::identity::PlatformMetadata;
use lazy_static::lazy_static;
use napi::bindgen_prelude::*;
use serde::{Deserialize, Serialize};
@@ -91,8 +92,7 @@
grpc_clients::identity::get_unauthenticated_client(
&IDENTITY_SERVICE_CONFIG.identity_socket_addr,
- CODE_VERSION,
- DEVICE_TYPE.to_string(),
+ PlatformMetadata::new(CODE_VERSION, DEVICE_TYPE),
)
.await
.map_err(|e| {
@@ -115,8 +115,7 @@
user_id,
device_id,
access_token,
- CODE_VERSION,
- DEVICE_TYPE.to_string(),
+ PlatformMetadata::new(CODE_VERSION, DEVICE_TYPE),
)
.await
.map_err(|e| {
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
@@ -1,9 +1,11 @@
-use grpc_clients::identity::get_unauthenticated_client;
use grpc_clients::identity::protos::unauth::{
AuthResponse, DeviceKeyUpload, Empty, IdentityKeyInfo, Prekey,
};
+use grpc_clients::identity::{get_unauthenticated_client, PlatformMetadata};
+use lazy_static::lazy_static;
use serde::Serialize;
+use crate::generated::STATE_VERSION;
use crate::utils::jsi_callbacks::{
handle_bool_result_as_callback, handle_string_result_as_callback,
};
@@ -19,6 +21,15 @@
pub mod registration;
pub mod x3dh;
+lazy_static! {
+ pub static ref PLATFORM_METADATA: PlatformMetadata = PlatformMetadata {
+ device_type: DEVICE_TYPE.as_str_name().to_lowercase(),
+ code_version: CODE_VERSION,
+ state_version: Some(STATE_VERSION),
+ major_desktop_version: None,
+ };
+}
+
pub mod ffi {
use super::*;
@@ -172,12 +183,9 @@
// API implementation helpers
async fn fetch_nonce() -> Result<String, Error> {
- let mut identity_client = get_unauthenticated_client(
- IDENTITY_SOCKET_ADDR,
- CODE_VERSION,
- DEVICE_TYPE.as_str_name().to_lowercase(),
- )
- .await?;
+ let mut identity_client =
+ get_unauthenticated_client(IDENTITY_SOCKET_ADDR, PLATFORM_METADATA.clone())
+ .await?;
let nonce = identity_client
.generate_nonce(Empty {})
.await?
@@ -187,12 +195,9 @@
}
async fn version_supported_helper() -> Result<bool, Error> {
- let mut identity_client = get_unauthenticated_client(
- IDENTITY_SOCKET_ADDR,
- CODE_VERSION,
- DEVICE_TYPE.as_str_name().to_lowercase(),
- )
- .await?;
+ let mut identity_client =
+ get_unauthenticated_client(IDENTITY_SOCKET_ADDR, PLATFORM_METADATA.clone())
+ .await?;
let response = identity_client.ping(Empty {}).await;
match response {
Ok(_) => Ok(true),
diff --git a/native/native_rust_library/src/identity/account_actions.rs b/native/native_rust_library/src/identity/account_actions.rs
--- a/native/native_rust_library/src/identity/account_actions.rs
+++ b/native/native_rust_library/src/identity/account_actions.rs
@@ -8,7 +8,9 @@
use crate::identity::AuthInfo;
use crate::utils::jsi_callbacks::handle_void_result_as_callback;
-use crate::{Error, CODE_VERSION, DEVICE_TYPE, IDENTITY_SOCKET_ADDR, RUNTIME};
+use crate::{Error, IDENTITY_SOCKET_ADDR, RUNTIME};
+
+use super::PLATFORM_METADATA;
pub mod ffi {
use super::*;
@@ -124,8 +126,7 @@
update_password_info.user_id,
update_password_info.device_id,
update_password_info.access_token,
- CODE_VERSION,
- DEVICE_TYPE.as_str_name().to_lowercase(),
+ PLATFORM_METADATA.clone(),
)
.await?;
@@ -160,8 +161,7 @@
auth_info.user_id,
auth_info.device_id,
auth_info.access_token,
- CODE_VERSION,
- DEVICE_TYPE.as_str_name().to_lowercase(),
+ PLATFORM_METADATA.clone(),
)
.await?;
identity_client.delete_wallet_user(Empty {}).await?;
@@ -178,8 +178,7 @@
auth_info.user_id,
auth_info.device_id,
auth_info.access_token,
- CODE_VERSION,
- DEVICE_TYPE.as_str_name().to_lowercase(),
+ PLATFORM_METADATA.clone(),
)
.await?;
@@ -227,8 +226,7 @@
auth_info.user_id,
auth_info.device_id,
auth_info.access_token,
- CODE_VERSION,
- DEVICE_TYPE.as_str_name().to_lowercase(),
+ PLATFORM_METADATA.clone(),
)
.await?;
diff --git a/native/native_rust_library/src/identity/device_list.rs b/native/native_rust_library/src/identity/device_list.rs
--- a/native/native_rust_library/src/identity/device_list.rs
+++ b/native/native_rust_library/src/identity/device_list.rs
@@ -7,7 +7,9 @@
use crate::utils::jsi_callbacks::{
handle_string_result_as_callback, handle_void_result_as_callback,
};
-use crate::{Error, CODE_VERSION, DEVICE_TYPE, IDENTITY_SOCKET_ADDR, RUNTIME};
+use crate::{Error, IDENTITY_SOCKET_ADDR, RUNTIME};
+
+use super::PLATFORM_METADATA;
pub mod ffi {
use super::*;
@@ -81,8 +83,7 @@
auth_info.user_id,
auth_info.device_id,
auth_info.access_token,
- CODE_VERSION,
- DEVICE_TYPE.as_str_name().to_lowercase(),
+ PLATFORM_METADATA.clone(),
)
.await?;
@@ -107,8 +108,7 @@
auth_info.user_id,
auth_info.device_id,
auth_info.access_token,
- CODE_VERSION,
- DEVICE_TYPE.as_str_name().to_lowercase(),
+ PLATFORM_METADATA.clone(),
)
.await?;
@@ -130,8 +130,7 @@
auth_info.user_id,
auth_info.device_id,
auth_info.access_token,
- CODE_VERSION,
- DEVICE_TYPE.as_str_name().to_lowercase(),
+ PLATFORM_METADATA.clone(),
)
.await?;
diff --git a/native/native_rust_library/src/identity/exact_user_search.rs b/native/native_rust_library/src/identity/exact_user_search.rs
--- a/native/native_rust_library/src/identity/exact_user_search.rs
+++ b/native/native_rust_library/src/identity/exact_user_search.rs
@@ -1,6 +1,5 @@
use crate::{
- handle_string_result_as_callback, Error, CODE_VERSION, DEVICE_TYPE,
- IDENTITY_SOCKET_ADDR, RUNTIME,
+ handle_string_result_as_callback, Error, IDENTITY_SOCKET_ADDR, RUNTIME,
};
use find_user_id_request::Identifier as RequestIdentifier;
use grpc_clients::identity::{
@@ -10,6 +9,8 @@
use serde::Serialize;
use tracing::instrument;
+use super::PLATFORM_METADATA;
+
#[derive(Serialize)]
#[serde(rename_all = "camelCase")]
struct FindUserIDResponse {
@@ -52,12 +53,9 @@
identifier: Some(identifier),
};
- let mut identity_client = get_unauthenticated_client(
- IDENTITY_SOCKET_ADDR,
- CODE_VERSION,
- DEVICE_TYPE.as_str_name().to_lowercase(),
- )
- .await?;
+ let mut identity_client =
+ get_unauthenticated_client(IDENTITY_SOCKET_ADDR, PLATFORM_METADATA.clone())
+ .await?;
let response = identity_client
.find_user_id(find_user_id_request)
diff --git a/native/native_rust_library/src/identity/farcaster.rs b/native/native_rust_library/src/identity/farcaster.rs
--- a/native/native_rust_library/src/identity/farcaster.rs
+++ b/native/native_rust_library/src/identity/farcaster.rs
@@ -2,7 +2,7 @@
utils::jsi_callbacks::{
handle_string_result_as_callback, handle_void_result_as_callback,
},
- Error, CODE_VERSION, DEVICE_TYPE, IDENTITY_SOCKET_ADDR, RUNTIME,
+ Error, IDENTITY_SOCKET_ADDR, RUNTIME,
};
use grpc_clients::identity::{
get_auth_client, get_unauthenticated_client,
@@ -11,6 +11,8 @@
};
use serde::Serialize;
+use super::PLATFORM_METADATA;
+
#[derive(Serialize)]
#[serde(rename_all = "camelCase")]
struct FarcasterUser {
@@ -77,12 +79,9 @@
) -> Result<String, Error> {
let get_farcaster_users_request = GetFarcasterUsersRequest { farcaster_ids };
- let mut identity_client = get_unauthenticated_client(
- IDENTITY_SOCKET_ADDR,
- CODE_VERSION,
- DEVICE_TYPE.as_str_name().to_lowercase(),
- )
- .await?;
+ let mut identity_client =
+ get_unauthenticated_client(IDENTITY_SOCKET_ADDR, PLATFORM_METADATA.clone())
+ .await?;
let response = identity_client
.get_farcaster_users(get_farcaster_users_request)
@@ -113,8 +112,7 @@
user_id,
device_id,
access_token,
- CODE_VERSION,
- DEVICE_TYPE.as_str_name().to_lowercase(),
+ PLATFORM_METADATA.clone(),
)
.await?;
@@ -138,8 +136,7 @@
user_id,
device_id,
access_token,
- CODE_VERSION,
- DEVICE_TYPE.as_str_name().to_lowercase(),
+ PLATFORM_METADATA.clone(),
)
.await?;
diff --git a/native/native_rust_library/src/identity/find_user_identities.rs b/native/native_rust_library/src/identity/find_user_identities.rs
--- a/native/native_rust_library/src/identity/find_user_identities.rs
+++ b/native/native_rust_library/src/identity/find_user_identities.rs
@@ -7,7 +7,9 @@
use crate::identity::AuthInfo;
use crate::utils::jsi_callbacks::handle_string_result_as_callback;
-use crate::{Error, CODE_VERSION, DEVICE_TYPE, IDENTITY_SOCKET_ADDR, RUNTIME};
+use crate::{Error, IDENTITY_SOCKET_ADDR, RUNTIME};
+
+use super::PLATFORM_METADATA;
pub mod ffi {
use super::*;
@@ -92,8 +94,7 @@
auth_info.user_id,
auth_info.device_id,
auth_info.access_token,
- CODE_VERSION,
- DEVICE_TYPE.as_str_name().to_lowercase(),
+ PLATFORM_METADATA.clone(),
)
.await?;
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
@@ -9,9 +9,12 @@
};
use tracing::instrument;
-use super::{IdentityAuthResult, LogInPasswordUserInfo, LogInWalletUserInfo};
+use super::{
+ IdentityAuthResult, LogInPasswordUserInfo, LogInWalletUserInfo,
+ PLATFORM_METADATA,
+};
use crate::utils::jsi_callbacks::handle_string_result_as_callback;
-use crate::{Error, CODE_VERSION, DEVICE_TYPE, IDENTITY_SOCKET_ADDR, RUNTIME};
+use crate::{Error, DEVICE_TYPE, IDENTITY_SOCKET_ADDR, RUNTIME};
#[allow(clippy::too_many_arguments)]
pub mod ffi {
@@ -164,12 +167,9 @@
force: None,
};
- let mut identity_client = get_unauthenticated_client(
- IDENTITY_SOCKET_ADDR,
- CODE_VERSION,
- DEVICE_TYPE.as_str_name().to_lowercase(),
- )
- .await?;
+ let mut identity_client =
+ get_unauthenticated_client(IDENTITY_SOCKET_ADDR, PLATFORM_METADATA.clone())
+ .await?;
let response = identity_client
.log_in_password_user_start(login_start_request)
@@ -205,12 +205,9 @@
initial_device_list: "".to_string(),
};
- let mut identity_client = get_unauthenticated_client(
- IDENTITY_SOCKET_ADDR,
- CODE_VERSION,
- DEVICE_TYPE.as_str_name().to_lowercase(),
- )
- .await?;
+ let mut identity_client =
+ get_unauthenticated_client(IDENTITY_SOCKET_ADDR, PLATFORM_METADATA.clone())
+ .await?;
let login_response = identity_client
.log_in_wallet_user(login_request)
@@ -227,12 +224,9 @@
nonce_signature: String,
device_key_upload: DeviceKeyUpload,
) -> Result<String, Error> {
- let mut identity_client = get_unauthenticated_client(
- IDENTITY_SOCKET_ADDR,
- CODE_VERSION,
- DEVICE_TYPE.as_str_name().to_lowercase(),
- )
- .await?;
+ let mut identity_client =
+ get_unauthenticated_client(IDENTITY_SOCKET_ADDR, PLATFORM_METADATA.clone())
+ .await?;
let request = SecondaryDeviceKeysUploadRequest {
user_id,
@@ -256,12 +250,9 @@
nonce: String,
nonce_signature: 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 mut identity_client =
+ get_unauthenticated_client(IDENTITY_SOCKET_ADDR, PLATFORM_METADATA.clone())
+ .await?;
let request = ExistingDeviceLoginRequest {
user_id,
diff --git a/native/native_rust_library/src/identity/registration.rs b/native/native_rust_library/src/identity/registration.rs
--- a/native/native_rust_library/src/identity/registration.rs
+++ b/native/native_rust_library/src/identity/registration.rs
@@ -1,6 +1,6 @@
use crate::{
- utils::jsi_callbacks::handle_string_result_as_callback, Error, CODE_VERSION,
- DEVICE_TYPE, IDENTITY_SOCKET_ADDR, RUNTIME,
+ utils::jsi_callbacks::handle_string_result_as_callback, Error,
+ IDENTITY_SOCKET_ADDR, RUNTIME,
};
use comm_opaque2::client::Registration;
use grpc_clients::identity::{
@@ -16,7 +16,7 @@
use super::{
farcaster::farcaster_id_string_to_option, IdentityAuthResult,
RegisterPasswordUserInfo, RegisterReservedPasswordUserInfo,
- RegisterReservedWalletUserInfo, RegisterWalletUserInfo,
+ RegisterReservedWalletUserInfo, RegisterWalletUserInfo, PLATFORM_METADATA,
};
#[allow(clippy::too_many_arguments)]
@@ -201,12 +201,9 @@
initial_device_list: password_user_info.initial_device_list,
};
- let mut identity_client = get_unauthenticated_client(
- IDENTITY_SOCKET_ADDR,
- CODE_VERSION,
- DEVICE_TYPE.as_str_name().to_lowercase(),
- )
- .await?;
+ let mut identity_client =
+ get_unauthenticated_client(IDENTITY_SOCKET_ADDR, PLATFORM_METADATA.clone())
+ .await?;
let response = identity_client
.register_password_user_start(registration_start_request)
.await?;
@@ -249,12 +246,9 @@
initial_device_list: password_user_info.initial_device_list,
};
- let mut identity_client = get_unauthenticated_client(
- IDENTITY_SOCKET_ADDR,
- CODE_VERSION,
- DEVICE_TYPE.as_str_name().to_lowercase(),
- )
- .await?;
+ let mut identity_client =
+ get_unauthenticated_client(IDENTITY_SOCKET_ADDR, PLATFORM_METADATA.clone())
+ .await?;
let response = identity_client
.register_reserved_password_user_start(registration_start_request)
.await?;
@@ -292,12 +286,9 @@
initial_device_list: wallet_user_info.initial_device_list,
};
- let mut identity_client = get_unauthenticated_client(
- IDENTITY_SOCKET_ADDR,
- CODE_VERSION,
- DEVICE_TYPE.as_str_name().to_lowercase(),
- )
- .await?;
+ let mut identity_client =
+ get_unauthenticated_client(IDENTITY_SOCKET_ADDR, PLATFORM_METADATA.clone())
+ .await?;
let registration_response = identity_client
.register_wallet_user(registration_request)
@@ -320,12 +311,9 @@
initial_device_list: wallet_user_info.initial_device_list,
};
- let mut identity_client = get_unauthenticated_client(
- IDENTITY_SOCKET_ADDR,
- CODE_VERSION,
- DEVICE_TYPE.as_str_name().to_lowercase(),
- )
- .await?;
+ let mut identity_client =
+ get_unauthenticated_client(IDENTITY_SOCKET_ADDR, PLATFORM_METADATA.clone())
+ .await?;
let registration_response = identity_client
.register_reserved_wallet_user(registration_request)
diff --git a/native/native_rust_library/src/identity/x3dh.rs b/native/native_rust_library/src/identity/x3dh.rs
--- a/native/native_rust_library/src/identity/x3dh.rs
+++ b/native/native_rust_library/src/identity/x3dh.rs
@@ -12,7 +12,9 @@
use crate::utils::jsi_callbacks::{
handle_string_result_as_callback, handle_void_result_as_callback,
};
-use crate::{Error, CODE_VERSION, DEVICE_TYPE, IDENTITY_SOCKET_ADDR, RUNTIME};
+use crate::{Error, IDENTITY_SOCKET_ADDR, RUNTIME};
+
+use super::PLATFORM_METADATA;
pub mod ffi {
use super::*;
@@ -284,8 +286,7 @@
auth_info.user_id,
auth_info.device_id,
auth_info.access_token,
- CODE_VERSION,
- DEVICE_TYPE.as_str_name().to_lowercase(),
+ PLATFORM_METADATA.clone(),
)
.await?;
let response = identity_client
@@ -313,8 +314,7 @@
auth_info.user_id,
auth_info.device_id,
auth_info.access_token,
- CODE_VERSION,
- DEVICE_TYPE.as_str_name().to_lowercase(),
+ PLATFORM_METADATA.clone(),
)
.await?;
let response = identity_client
@@ -342,8 +342,7 @@
auth_info.user_id,
auth_info.device_id,
auth_info.access_token,
- CODE_VERSION,
- DEVICE_TYPE.as_str_name().to_lowercase(),
+ PLATFORM_METADATA.clone(),
)
.await?;
let response = identity_client
@@ -365,8 +364,7 @@
auth_info.user_id,
auth_info.device_id,
auth_info.access_token,
- CODE_VERSION,
- DEVICE_TYPE.as_str_name().to_lowercase(),
+ PLATFORM_METADATA.clone(),
)
.await?
.refresh_user_prekeys(refresh_request)
@@ -384,8 +382,7 @@
auth_info.user_id,
auth_info.device_id,
auth_info.access_token,
- CODE_VERSION,
- DEVICE_TYPE.as_str_name().to_lowercase(),
+ PLATFORM_METADATA.clone(),
)
.await?;
diff --git a/services/commtest/src/identity/device.rs b/services/commtest/src/identity/device.rs
--- a/services/commtest/src/identity/device.rs
+++ b/services/commtest/src/identity/device.rs
@@ -1,5 +1,7 @@
use comm_opaque2::client::{Login, Registration};
-use grpc_clients::identity::{get_auth_client, get_unauthenticated_client};
+use grpc_clients::identity::{
+ get_auth_client, get_unauthenticated_client, PlatformMetadata,
+};
use rand::{distributions::Alphanumeric, Rng};
use crate::identity::olm_account_infos::generate_random_olm_key;
@@ -97,8 +99,7 @@
let mut identity_client = get_unauthenticated_client(
&service_addr::IDENTITY_GRPC.to_string(),
- PLACEHOLDER_CODE_VERSION,
- DEVICE_TYPE.to_string(),
+ PlatformMetadata::new(PLACEHOLDER_CODE_VERSION, DEVICE_TYPE),
)
.await
.expect("Couldn't connect to identity service");
@@ -179,8 +180,7 @@
let mut identity_client = get_unauthenticated_client(
&service_addr::IDENTITY_GRPC.to_string(),
- PLACEHOLDER_CODE_VERSION,
- DEVICE_TYPE.to_string(),
+ PlatformMetadata::new(PLACEHOLDER_CODE_VERSION, DEVICE_TYPE),
)
.await
.expect("Couldn't connect to identity service");
@@ -226,8 +226,7 @@
user_id,
device_id,
access_token,
- PLACEHOLDER_CODE_VERSION,
- DEVICE_TYPE.to_string(),
+ PlatformMetadata::new(PLACEHOLDER_CODE_VERSION, DEVICE_TYPE),
)
.await
.expect("Couldnt connect to auth identity service");
diff --git a/services/commtest/tests/identity_access_tokens_tests.rs b/services/commtest/tests/identity_access_tokens_tests.rs
--- a/services/commtest/tests/identity_access_tokens_tests.rs
+++ b/services/commtest/tests/identity_access_tokens_tests.rs
@@ -6,6 +6,7 @@
use grpc_clients::identity::protos::unauth::{
Empty, ExistingDeviceLoginRequest,
};
+use grpc_clients::identity::PlatformMetadata;
use grpc_clients::identity::{
get_unauthenticated_client, protos::unauth::VerifyUserAccessTokenRequest,
};
@@ -17,8 +18,7 @@
let mut identity_client = get_unauthenticated_client(
&identity_grpc_endpoint,
- PLACEHOLDER_CODE_VERSION,
- DEVICE_TYPE.to_string(),
+ PlatformMetadata::new(PLACEHOLDER_CODE_VERSION, DEVICE_TYPE),
)
.await
.expect("Couldn't connect to identity service");
@@ -37,8 +37,7 @@
let identity_grpc_endpoint = service_addr::IDENTITY_GRPC.to_string();
let mut client = get_unauthenticated_client(
&identity_grpc_endpoint,
- PLACEHOLDER_CODE_VERSION,
- DEVICE_TYPE.to_string(),
+ PlatformMetadata::new(PLACEHOLDER_CODE_VERSION, DEVICE_TYPE),
)
.await
.expect("Couldn't connect to identity service");
diff --git a/services/commtest/tests/identity_device_list_tests.rs b/services/commtest/tests/identity_device_list_tests.rs
--- a/services/commtest/tests/identity_device_list_tests.rs
+++ b/services/commtest/tests/identity_device_list_tests.rs
@@ -9,12 +9,12 @@
use commtest::identity::SigningCapableAccount;
use commtest::service_addr;
use grpc_clients::identity::authenticated::ChainedInterceptedAuthClient;
-use grpc_clients::identity::get_auth_client;
use grpc_clients::identity::protos::auth::{
PeersDeviceListsRequest, UpdateDeviceListRequest,
};
use grpc_clients::identity::protos::authenticated::GetDeviceListRequest;
use grpc_clients::identity::DeviceType;
+use grpc_clients::identity::{get_auth_client, PlatformMetadata};
use serde::{Deserialize, Serialize};
// 1. register user with android device
@@ -41,8 +41,7 @@
viewer.user_id.clone(),
viewer.device_id,
viewer.access_token,
- PLACEHOLDER_CODE_VERSION,
- DEVICE_TYPE.to_string(),
+ PlatformMetadata::new(PLACEHOLDER_CODE_VERSION, DEVICE_TYPE),
)
.await
.expect("Couldn't connect to identity service");
@@ -107,8 +106,7 @@
primary_device.user_id.clone(),
primary_device.device_id,
primary_device.access_token,
- PLACEHOLDER_CODE_VERSION,
- DEVICE_TYPE.to_string(),
+ PlatformMetadata::new(PLACEHOLDER_CODE_VERSION, DEVICE_TYPE),
)
.await
.expect("Couldn't connect to identity service");
@@ -170,8 +168,7 @@
user.user_id.clone(),
user.device_id,
user.access_token,
- PLACEHOLDER_CODE_VERSION,
- DEVICE_TYPE.to_string(),
+ PlatformMetadata::new(PLACEHOLDER_CODE_VERSION, DEVICE_TYPE),
)
.await
.expect("Couldn't connect to identity service");
@@ -270,8 +267,7 @@
viewer.user_id.clone(),
viewer.device_id,
viewer.access_token,
- PLACEHOLDER_CODE_VERSION,
- DEVICE_TYPE.to_string(),
+ PlatformMetadata::new(PLACEHOLDER_CODE_VERSION, DEVICE_TYPE),
)
.await
.expect("Couldn't connect to identity service");
@@ -335,8 +331,7 @@
viewer.user_id.clone(),
viewer.device_id,
viewer.access_token,
- PLACEHOLDER_CODE_VERSION,
- DEVICE_TYPE.to_string(),
+ PlatformMetadata::new(PLACEHOLDER_CODE_VERSION, DEVICE_TYPE),
)
.await
.expect("Couldn't connect to identity service");
@@ -413,8 +408,7 @@
user.user_id.clone(),
user.device_id,
user.access_token,
- PLACEHOLDER_CODE_VERSION,
- DEVICE_TYPE.to_string(),
+ PlatformMetadata::new(PLACEHOLDER_CODE_VERSION, DEVICE_TYPE),
)
.await
.expect("Couldn't connect to identity service");
diff --git a/services/commtest/tests/identity_integration_tests.rs b/services/commtest/tests/identity_integration_tests.rs
--- a/services/commtest/tests/identity_integration_tests.rs
+++ b/services/commtest/tests/identity_integration_tests.rs
@@ -2,6 +2,7 @@
register_user_device, DEVICE_TYPE, PLACEHOLDER_CODE_VERSION,
};
use commtest::service_addr;
+use grpc_clients::identity::PlatformMetadata;
use grpc_clients::identity::{
get_auth_client, get_unauthenticated_client,
protos::auth::{Identity, UserIdentitiesRequest},
@@ -16,8 +17,7 @@
let mut client = get_unauthenticated_client(
&service_addr::IDENTITY_GRPC.to_string(),
- PLACEHOLDER_CODE_VERSION,
- DEVICE_TYPE.to_string(),
+ PlatformMetadata::new(PLACEHOLDER_CODE_VERSION, DEVICE_TYPE),
)
.await
.expect("Couldn't connect to identity service");
@@ -48,8 +48,7 @@
device_info.user_id.clone(),
device_info.device_id,
device_info.access_token,
- PLACEHOLDER_CODE_VERSION,
- DEVICE_TYPE.to_string(),
+ PlatformMetadata::new(PLACEHOLDER_CODE_VERSION, DEVICE_TYPE),
)
.await
.expect("Couldn't connect to identity service");
diff --git a/services/commtest/tests/identity_keyserver_tests.rs b/services/commtest/tests/identity_keyserver_tests.rs
--- a/services/commtest/tests/identity_keyserver_tests.rs
+++ b/services/commtest/tests/identity_keyserver_tests.rs
@@ -3,6 +3,7 @@
};
use commtest::identity::olm_account_infos::generate_random_olm_key;
use commtest::service_addr;
+use grpc_clients::identity::PlatformMetadata;
use grpc_clients::identity::{
get_auth_client,
protos::authenticated::{
@@ -20,8 +21,7 @@
device_info.user_id.clone(),
device_info.device_id,
device_info.access_token,
- PLACEHOLDER_CODE_VERSION,
- DEVICE_TYPE.to_string(),
+ PlatformMetadata::new(PLACEHOLDER_CODE_VERSION, DEVICE_TYPE),
)
.await
.expect("Couldn't connect to identity service");
diff --git a/services/commtest/tests/identity_one_time_key_tests.rs b/services/commtest/tests/identity_one_time_key_tests.rs
--- a/services/commtest/tests/identity_one_time_key_tests.rs
+++ b/services/commtest/tests/identity_one_time_key_tests.rs
@@ -3,6 +3,7 @@
};
use commtest::identity::olm_account_infos::generate_random_olm_key;
use commtest::service_addr;
+use grpc_clients::identity::PlatformMetadata;
use grpc_clients::identity::{
get_auth_client, protos::authenticated::OutboundKeysForUserRequest,
protos::authenticated::UploadOneTimeKeysRequest,
@@ -17,8 +18,7 @@
device_info.user_id,
device_info.device_id,
device_info.access_token,
- PLACEHOLDER_CODE_VERSION,
- DEVICE_TYPE.to_string(),
+ PlatformMetadata::new(PLACEHOLDER_CODE_VERSION, DEVICE_TYPE),
)
.await
.expect("Couldn't connect to identity service");
@@ -49,8 +49,7 @@
device_info.user_id.clone(),
device_info.device_id,
device_info.access_token,
- PLACEHOLDER_CODE_VERSION,
- DEVICE_TYPE.to_string(),
+ PlatformMetadata::new(PLACEHOLDER_CODE_VERSION, DEVICE_TYPE),
)
.await
.expect("Couldn't connect to identity service");
@@ -167,8 +166,7 @@
device_info.user_id,
device_info.device_id,
device_info.access_token,
- PLACEHOLDER_CODE_VERSION,
- DEVICE_TYPE.to_string(),
+ PlatformMetadata::new(PLACEHOLDER_CODE_VERSION, DEVICE_TYPE),
)
.await
.expect("Couldn't connect to identity service");
diff --git a/services/commtest/tests/identity_prekey_tests.rs b/services/commtest/tests/identity_prekey_tests.rs
--- a/services/commtest/tests/identity_prekey_tests.rs
+++ b/services/commtest/tests/identity_prekey_tests.rs
@@ -2,6 +2,7 @@
register_user_device, DEVICE_TYPE, PLACEHOLDER_CODE_VERSION,
};
use commtest::service_addr;
+use grpc_clients::identity::PlatformMetadata;
use grpc_clients::identity::{
get_auth_client,
protos::{authenticated::RefreshUserPrekeysRequest, unauth::Prekey},
@@ -16,8 +17,7 @@
device_info.user_id,
device_info.device_id,
device_info.access_token,
- PLACEHOLDER_CODE_VERSION,
- DEVICE_TYPE.to_string(),
+ PlatformMetadata::new(PLACEHOLDER_CODE_VERSION, DEVICE_TYPE),
)
.await
.expect("Couldn't connect to identity service");
diff --git a/services/commtest/tests/identity_tunnelbroker_tests.rs b/services/commtest/tests/identity_tunnelbroker_tests.rs
--- a/services/commtest/tests/identity_tunnelbroker_tests.rs
+++ b/services/commtest/tests/identity_tunnelbroker_tests.rs
@@ -5,10 +5,10 @@
use commtest::service_addr;
use commtest::tunnelbroker::socket::{create_socket, receive_message};
use futures_util::StreamExt;
-use grpc_clients::identity::get_auth_client;
use grpc_clients::identity::protos::authenticated::{
OutboundKeysForUserRequest, UploadOneTimeKeysRequest,
};
+use grpc_clients::identity::{get_auth_client, PlatformMetadata};
use tunnelbroker_messages::RefreshKeyRequest;
#[tokio::test]
@@ -42,8 +42,7 @@
device_info.user_id.clone(),
device_info.device_id,
device_info.access_token,
- PLACEHOLDER_CODE_VERSION,
- DEVICE_TYPE.to_string(),
+ PlatformMetadata::new(PLACEHOLDER_CODE_VERSION, DEVICE_TYPE),
)
.await
.expect("Couldn't connect to identity service");
diff --git a/services/identity/src/websockets/auth.rs b/services/identity/src/websockets/auth.rs
--- a/services/identity/src/websockets/auth.rs
+++ b/services/identity/src/websockets/auth.rs
@@ -1,5 +1,5 @@
use client_proto::VerifyUserAccessTokenRequest;
-use grpc_clients::identity;
+use grpc_clients::identity::{self, PlatformMetadata};
use grpc_clients::tonic::Request;
use identity::get_unauthenticated_client;
use identity::protos::unauthenticated as client_proto;
@@ -20,8 +20,7 @@
) -> Result<bool, WebsocketError> {
let grpc_client = get_unauthenticated_client(
DEFAULT_IDENTITY_ENDPOINT,
- PLACEHOLDER_CODE_VERSION,
- DEVICE_TYPE.to_string(),
+ PlatformMetadata::new(PLACEHOLDER_CODE_VERSION, DEVICE_TYPE),
)
.await;
diff --git a/services/tunnelbroker/src/identity/mod.rs b/services/tunnelbroker/src/identity/mod.rs
--- a/services/tunnelbroker/src/identity/mod.rs
+++ b/services/tunnelbroker/src/identity/mod.rs
@@ -1,5 +1,5 @@
use client_proto::VerifyUserAccessTokenRequest;
-use grpc_clients::identity;
+use grpc_clients::identity::{self, PlatformMetadata};
use grpc_clients::tonic::Request;
use identity::get_unauthenticated_client;
use identity::protos::unauthenticated as client_proto;
@@ -21,8 +21,7 @@
) -> Result<bool, Error> {
let mut grpc_client = get_unauthenticated_client(
&CONFIG.identity_endpoint,
- PLACEHOLDER_CODE_VERSION,
- DEVICE_TYPE.to_string(),
+ PlatformMetadata::new(PLACEHOLDER_CODE_VERSION, DEVICE_TYPE),
)
.await?;
let message = VerifyUserAccessTokenRequest {
diff --git a/shared/grpc_clients/src/identity/authenticated.rs b/shared/grpc_clients/src/identity/authenticated.rs
--- a/shared/grpc_clients/src/identity/authenticated.rs
+++ b/shared/grpc_clients/src/identity/authenticated.rs
@@ -1,4 +1,7 @@
-use super::protos::authenticated::identity_client_service_client::IdentityClientServiceClient as AuthClient;
+use super::{
+ protos::authenticated::identity_client_service_client::IdentityClientServiceClient as AuthClient,
+ PlatformMetadata,
+};
use tonic::{
codegen::InterceptedService,
metadata::{errors::InvalidMetadataValue, Ascii, MetadataValue},
@@ -47,8 +50,7 @@
user_id: String,
device_id: String,
access_token: String,
- code_version: u64,
- device_type: String,
+ platform_metadata: PlatformMetadata,
) -> Result<ChainedInterceptedAuthClient, Error> {
use crate::get_grpc_service_channel;
@@ -60,12 +62,7 @@
access_token,
};
- let version_interceptor = CodeVersionLayer {
- device_type,
- code_version,
- state_version: None,
- major_desktop_version: None,
- };
+ let version_interceptor = CodeVersionLayer::from(platform_metadata);
let chained = ChainedInterceptor {
first: auth_interceptor,
diff --git a/shared/grpc_clients/src/identity/mod.rs b/shared/grpc_clients/src/identity/mod.rs
--- a/shared/grpc_clients/src/identity/mod.rs
+++ b/shared/grpc_clients/src/identity/mod.rs
@@ -17,4 +17,5 @@
pub use authenticated::get_auth_client;
pub use device::DeviceType;
+pub use shared::PlatformMetadata;
pub use unauthenticated::get_unauthenticated_client;
diff --git a/shared/grpc_clients/src/identity/shared.rs b/shared/grpc_clients/src/identity/shared.rs
--- a/shared/grpc_clients/src/identity/shared.rs
+++ b/shared/grpc_clients/src/identity/shared.rs
@@ -21,7 +21,7 @@
impl PlatformMetadata {
/// Simplified constructor for basic params only
- fn new(code_version: u64, device_type: impl Into<String>) -> Self {
+ pub fn new(code_version: u64, device_type: impl Into<String>) -> Self {
Self {
code_version,
device_type: device_type.into(),
diff --git a/shared/grpc_clients/src/identity/unauthenticated/client.rs b/shared/grpc_clients/src/identity/unauthenticated/client.rs
--- a/shared/grpc_clients/src/identity/unauthenticated/client.rs
+++ b/shared/grpc_clients/src/identity/unauthenticated/client.rs
@@ -1,5 +1,5 @@
/// This file is meant to contain commonly used RPCs
-use crate::error::Error;
+use crate::{error::Error, identity::PlatformMetadata};
use super::get_unauthenticated_client;
use crate::identity::protos::unauthenticated::{
@@ -17,8 +17,11 @@
code_version: u64,
device_type: String,
) -> Result<bool, Error> {
- let mut grpc_client =
- get_unauthenticated_client(identity_url, code_version, device_type).await?;
+ let mut grpc_client = get_unauthenticated_client(
+ identity_url,
+ PlatformMetadata::new(code_version, device_type),
+ )
+ .await?;
let message = VerifyUserAccessTokenRequest {
user_id: user_id.to_string(),
@@ -36,8 +39,11 @@
code_version: u64,
device_type: String,
) -> Result<(), Error> {
- let mut grpc_client =
- get_unauthenticated_client(identity_url, code_version, device_type).await?;
+ let mut grpc_client = get_unauthenticated_client(
+ identity_url,
+ PlatformMetadata::new(code_version, device_type),
+ )
+ .await?;
let request = Request::new(Empty {});
grpc_client.ping(request).await?;
Ok(())
diff --git a/shared/grpc_clients/src/identity/unauthenticated/mod.rs b/shared/grpc_clients/src/identity/unauthenticated/mod.rs
--- a/shared/grpc_clients/src/identity/unauthenticated/mod.rs
+++ b/shared/grpc_clients/src/identity/unauthenticated/mod.rs
@@ -5,25 +5,19 @@
use super::{
protos::unauth::identity_client_service_client::IdentityClientServiceClient,
- shared::CodeVersionLayer,
+ shared::CodeVersionLayer, PlatformMetadata,
};
use crate::error::Error;
pub async fn get_unauthenticated_client(
url: &str,
- code_version: u64,
- device_type: String,
+ platform_metadata: PlatformMetadata,
) -> Result<
IdentityClientServiceClient<InterceptedService<Channel, CodeVersionLayer>>,
Error,
> {
let channel = crate::get_grpc_service_channel(url).await?;
- let version_interceptor = CodeVersionLayer {
- device_type,
- code_version,
- state_version: None,
- major_desktop_version: None,
- };
+ let version_interceptor = CodeVersionLayer::from(platform_metadata);
Ok(IdentityClientServiceClient::with_interceptor(
channel,
version_interceptor,
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sat, Oct 5, 11:32 PM (22 h, 8 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2246840
Default Alt Text
D12283.id40851.diff (32 KB)
Attached To
Mode
D12283: [grpc_clients] Accept PlatformMetadata when creating client
Attached
Detach File
Event Timeline
Log In to Comment