Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3509744
D6997.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
3 KB
Referenced Files
None
Subscribers
None
D6997.diff
View Options
diff --git a/keyserver/addons/rust-node-addon/src/identity_client/compare_users.rs b/keyserver/addons/rust-node-addon/src/identity_client/compare_users.rs
new file mode 100644
--- /dev/null
+++ b/keyserver/addons/rust-node-addon/src/identity_client/compare_users.rs
@@ -0,0 +1,36 @@
+use super::*;
+
+#[napi]
+#[instrument(skip_all)]
+async fn compare_users(
+ users: Vec<String>,
+) -> Result<HashMap<String, Vec<String>>> {
+ let channel = get_identity_service_channel().await?;
+ let token: MetadataValue<_> = IDENTITY_SERVICE_CONFIG
+ .identity_auth_token
+ .parse()
+ .map_err(|_| Error::from_status(Status::GenericFailure))?;
+ let mut identity_client =
+ IdentityServiceClient::with_interceptor(channel, |mut req: Request<()>| {
+ req.metadata_mut().insert("authorization", token.clone());
+ Ok(req)
+ });
+ let request = Request::new(CompareUsersRequest { users: users });
+
+ match identity_client.compare_users(request).await {
+ Ok(tonic_response) => {
+ let compare_users_response = tonic_response.into_inner();
+ let mut compare_result = HashMap::new();
+ compare_result.insert(
+ "usersMissingFromKeyserver".to_string(),
+ compare_users_response.users_missing_from_keyserver,
+ );
+ compare_result.insert(
+ "usersMissingFromIdentity".to_string(),
+ compare_users_response.users_missing_from_identity,
+ );
+ Ok(compare_result)
+ }
+ Err(e) => Err(Error::new(Status::GenericFailure, e.to_string())),
+ }
+}
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
@@ -1,3 +1,4 @@
+pub mod compare_users;
pub mod delete_user;
pub mod login_user;
pub mod register_user;
@@ -21,8 +22,8 @@
registration_request::Data::PakeRegistrationRequestAndUserId,
registration_request::Data::PakeRegistrationUploadAndCredentialRequest,
registration_response::Data::PakeLoginResponse as RegistrationPakeLoginResponse,
- registration_response::Data::PakeRegistrationResponse, DeleteUserRequest,
- LoginRequest, LoginResponse,
+ registration_response::Data::PakeRegistrationResponse, CompareUsersRequest,
+ DeleteUserRequest, LoginRequest, LoginResponse,
PakeCredentialRequestAndUserId as PakeCredentialRequestAndUserIdStruct,
PakeLoginRequest as PakeLoginRequestStruct,
PakeLoginResponse as PakeLoginResponseStruct,
diff --git a/lib/types/rust-binding-types.js b/lib/types/rust-binding-types.js
--- a/lib/types/rust-binding-types.js
+++ b/lib/types/rust-binding-types.js
@@ -15,6 +15,11 @@
publish(toDeviceId: string, payload: string): Promise<void>;
}
+type UserComparisonResult = {
+ +usersMissingFromKeyserver: $ReadOnlyArray<string>,
+ +usersMissingFromIdentity: $ReadOnlyArray<string>,
+};
+
type RustNativeBindingAPI = {
+registerUser: (
userId: string,
@@ -39,6 +44,9 @@
) => Promise<string>,
+deleteUser: (userId: string) => Promise<boolean>,
+updateUser: (userId: string, password: string) => Promise<string>,
+ +compareUsers: (
+ userIds: $ReadOnlyArray<string>,
+ ) => Promise<UserComparisonResult>,
+TunnelbrokerClient: Class<TunnelbrokerClientClass>,
};
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Sun, Dec 22, 7:55 AM (12 h, 23 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2690598
Default Alt Text
D6997.diff (3 KB)
Attached To
Mode
D6997: [keyserver] add new compareUsers function to rust-node-addon
Attached
Detach File
Event Timeline
Log In to Comment