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 @@ -22,6 +22,10 @@ signedIdentityKeysBlob: SignedIdentityKeysBlob, ) => Promise, +addReservedUsername: (username: string, signature: string) => Promise, + +removeReservedUsername: ( + username: string, + signature: string, + ) => Promise, +TunnelbrokerClient: Class, }; 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,5 +1,6 @@ pub mod add_reserved_username; pub mod register_user; +pub mod remove_reserved_username; pub mod identity_client { tonic::include_proto!("identity.client"); } @@ -8,6 +9,7 @@ use identity_client::{ AddReservedUsernameRequest, DeviceKeyUpload, IdentityKeyInfo, RegistrationFinishRequest, RegistrationStartRequest, + RemoveReservedUsernameRequest, }; use lazy_static::lazy_static; use napi::bindgen_prelude::*; diff --git a/keyserver/addons/rust-node-addon/src/identity_client/remove_reserved_username.rs b/keyserver/addons/rust-node-addon/src/identity_client/remove_reserved_username.rs new file mode 100644 --- /dev/null +++ b/keyserver/addons/rust-node-addon/src/identity_client/remove_reserved_username.rs @@ -0,0 +1,25 @@ +use super::*; + +#[napi] +#[instrument(skip_all)] +pub async fn remove_reserved_username( + username: 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 remove_reserved_username_request = RemoveReservedUsernameRequest { + username, + signature, + }; + + identity_client + .remove_reserved_username(remove_reserved_username_request) + .await + .map_err(|_| Error::from_status(Status::GenericFailure))? + .into_inner(); + + Ok(()) +}