diff --git a/keyserver/addons/rust-node-addon/src/tunnelbroker_client.rs b/keyserver/addons/rust-node-addon/src/tunnelbroker_client.rs --- a/keyserver/addons/rust-node-addon/src/tunnelbroker_client.rs +++ b/keyserver/addons/rust-node-addon/src/tunnelbroker_client.rs @@ -64,4 +64,23 @@ }); TunnelbrokerClient { tx } } + + #[napi] + pub async unsafe fn publish( + &mut self, + to_device_id: String, + payload: String, + ) -> napi::Result<()> { + let messages = + vec![tunnelbroker::tunnelbroker_pb::MessageToTunnelbrokerStruct { + to_device_id, + payload, + blob_hashes: vec![], + }]; + + if let Err(_) = tunnelbroker::publish_messages(&self.tx, messages).await { + return Err(napi::Error::from_status(napi::Status::GenericFailure)); + } + Ok(()) + } }