Changeset View
Changeset View
Standalone View
Standalone View
keyserver/addons/rust-node-addon/src/identity_client/update_user.rs
use crate::identity_client::identity as proto; | use crate::identity_client::identity as proto; | ||||
use crate::identity_client::identity::identity_service_client::IdentityServiceClient; | |||||
use crate::identity_client::identity::pake_login_response::Data::AccessToken; | use crate::identity_client::identity::pake_login_response::Data::AccessToken; | ||||
use crate::identity_client::identity::{ | use crate::identity_client::identity::{ | ||||
update_user_request, update_user_response, UpdateUserRequest, | update_user_request, update_user_response, UpdateUserRequest, | ||||
UpdateUserResponse, | UpdateUserResponse, | ||||
}; | }; | ||||
use comm_opaque::Cipher; | use comm_opaque::Cipher; | ||||
use napi::bindgen_prelude::*; | use napi::bindgen_prelude::*; | ||||
use opaque_ke::{ | use opaque_ke::{ | ||||
ClientLogin, ClientLoginFinishParameters, ClientLoginStartParameters, | ClientLogin, ClientLoginFinishParameters, ClientLoginStartParameters, | ||||
ClientLoginStartResult, ClientRegistration, | ClientLoginStartResult, ClientRegistration, | ||||
ClientRegistrationFinishParameters, CredentialFinalization, | ClientRegistrationFinishParameters, CredentialFinalization, | ||||
CredentialResponse, RegistrationUpload, | CredentialResponse, RegistrationUpload, | ||||
}; | }; | ||||
use proto::identity_keyserver_service_client::IdentityKeyserverServiceClient; | |||||
use rand::{rngs::OsRng, CryptoRng, Rng}; | use rand::{rngs::OsRng, CryptoRng, Rng}; | ||||
use tokio::sync::mpsc; | use tokio::sync::mpsc; | ||||
use tokio_stream::wrappers::ReceiverStream; | use tokio_stream::wrappers::ReceiverStream; | ||||
use tonic; | use tonic; | ||||
use tonic::metadata::MetadataValue; | use tonic::metadata::MetadataValue; | ||||
use tracing::{error, instrument}; | use tracing::{error, instrument}; | ||||
use super::{get_identity_service_channel, IDENTITY_SERVICE_CONFIG}; | use super::{get_identity_service_channel, IDENTITY_SERVICE_CONFIG}; | ||||
#[napi] | #[napi] | ||||
#[instrument(skip_all)] | #[instrument(skip_all)] | ||||
pub async fn update_user(user_id: String, password: String) -> Result<String> { | pub async fn update_user(user_id: String, password: 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 = IdentityServiceClient::with_interceptor( | let mut identity_client = IdentityKeyserverServiceClient::with_interceptor( | ||||
channel, | channel, | ||||
|mut req: tonic::Request<()>| { | |mut req: tonic::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 | ||||
▲ Show 20 Lines • Show All 270 Lines • Show Last 20 Lines |