Changeset View
Changeset View
Standalone View
Standalone View
keyserver/addons/rust-node-addon/src/identity_client/register_user.rs
use super::*; | use super::*; | ||||
#[napi] | #[napi] | ||||
#[instrument(skip_all)] | #[instrument(skip_all)] | ||||
pub async fn register_user( | pub async fn register_user( | ||||
user_id: String, | user_id: String, | ||||
signing_public_key: String, | signing_public_key: String, | ||||
username: String, | username: String, | ||||
password: String, | password: String, | ||||
session_initialization_info: HashMap<String, String>, | session_initialization_info: HashMap<String, String>, | ||||
) -> Result<String> { | ) -> Result<String> { | ||||
let channel = get_identity_service_channel().await?; | let channel = get_identity_service_channel().await?; | ||||
let token: MetadataValue<_> = IDENTITY_SERVICE_CONFIG | let token: MetadataValue<_> = IDENTITY_SERVICE_CONFIG | ||||
.identity_auth_token | .identity_auth_token | ||||
.parse() | .parse() | ||||
.map_err(|_| Error::from_status(Status::GenericFailure))?; | .map_err(|_| Error::from_status(Status::GenericFailure))?; | ||||
let mut identity_client = | let mut identity_client = IdentityKeyserverServiceClient::with_interceptor( | ||||
IdentityServiceClient::with_interceptor(channel, |mut req: Request<()>| { | channel, | ||||
|mut req: Request<()>| { | |||||
req.metadata_mut().insert("authorization", token.clone()); | req.metadata_mut().insert("authorization", token.clone()); | ||||
Ok(req) | Ok(req) | ||||
}); | }, | ||||
); | |||||
// Create a RegistrationRequest channel and use ReceiverStream to turn the | // Create a RegistrationRequest channel and use ReceiverStream to turn the | ||||
// MPSC receiver into a Stream for outbound messages | // MPSC receiver into a Stream for outbound messages | ||||
let (tx, rx) = mpsc::channel(1); | let (tx, rx) = mpsc::channel(1); | ||||
let stream = ReceiverStream::new(rx); | let stream = ReceiverStream::new(rx); | ||||
let request = Request::new(stream); | let request = Request::new(stream); | ||||
// `response` is the Stream for inbound messages | // `response` is the Stream for inbound messages | ||||
▲ Show 20 Lines • Show All 199 Lines • Show Last 20 Lines |