diff --git a/keyserver/addons/rust-node-addon/rust-binding-types.js b/keyserver/addons/rust-node-addon/rust-binding-types.js --- a/keyserver/addons/rust-node-addon/rust-binding-types.js +++ b/keyserver/addons/rust-node-addon/rust-binding-types.js @@ -21,6 +21,7 @@ password: string, signedIdentityKeysBlob: SignedIdentityKeysBlob, ) => Promise, + +addReservedUsername: (message: string, signature: string) => Promise, +TunnelbrokerClient: Class, }; diff --git a/keyserver/addons/rust-node-addon/src/identity_client/add_reserved_username.rs b/keyserver/addons/rust-node-addon/src/identity_client/add_reserved_username.rs new file mode 100644 --- /dev/null +++ b/keyserver/addons/rust-node-addon/src/identity_client/add_reserved_username.rs @@ -0,0 +1,23 @@ +use super::*; + +#[napi] +#[instrument(skip_all)] +pub async fn add_reserved_username( + message: String, + signature: String, +) -> Result<()> { + // Set up the gRPC client that will be used to talk to the Identity service + let channel = get_identity_service_channel().await?; + let mut identity_client = IdentityClientServiceClient::new(channel); + + let add_reserved_username_request = + AddReservedUsernameRequest { message, signature }; + + identity_client + .add_reserved_username(add_reserved_username_request) + .await + .map_err(|_| Error::from_status(Status::GenericFailure))? + .into_inner(); + + Ok(()) +} 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 add_reserved_username; pub mod register_user; pub mod identity_client { tonic::include_proto!("identity.client"); @@ -5,8 +6,8 @@ use identity_client::identity_client_service_client::IdentityClientServiceClient; use identity_client::{ - DeviceKeyUpload, IdentityKeyInfo, RegistrationFinishRequest, - RegistrationStartRequest, + AddReservedUsernameRequest, DeviceKeyUpload, IdentityKeyInfo, + RegistrationFinishRequest, RegistrationStartRequest, }; use lazy_static::lazy_static; use napi::bindgen_prelude::*;