refactor: rename to to better reflect meaning
This commit is contained in:
@@ -176,8 +176,8 @@ impl Convert for auth::Error {
|
||||
InvalidChallengeSolution => ProtoAuthResult::InvalidSignature,
|
||||
ApproveError(auth::ApproveError::Denied) => ProtoAuthResult::ApprovalDenied,
|
||||
ApproveError(auth::ApproveError::Upstream(
|
||||
crate::actors::flow_coordinator::ApprovalError::NoUserAgentsConnected,
|
||||
)) => ProtoAuthResult::NoUserAgentsOnline,
|
||||
crate::actors::flow_coordinator::ApprovalError::NoOperatorsConnected,
|
||||
)) => ProtoAuthResult::NoOperatorsOnline,
|
||||
ApproveError(auth::ApproveError::Internal)
|
||||
| DatabasePoolUnavailable
|
||||
| DatabaseOperationFailed
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
use crate::peers::{client::ClientConnection, user_agent::UserAgentConnection};
|
||||
use crate::peers::{client::ClientConnection, operator::OperatorConnection};
|
||||
use arbiter_proto::{
|
||||
proto::{
|
||||
client::{ClientRequest, ClientResponse},
|
||||
user_agent::{UserAgentRequest, UserAgentResponse},
|
||||
operator::{OperatorRequest, OperatorResponse},
|
||||
},
|
||||
transport::grpc::GrpcBi,
|
||||
};
|
||||
@@ -14,7 +14,7 @@ use tracing::info;
|
||||
mod request_tracker;
|
||||
|
||||
pub mod client;
|
||||
pub mod user_agent;
|
||||
pub mod operator;
|
||||
|
||||
mod common;
|
||||
|
||||
@@ -33,7 +33,7 @@ pub trait TryConvert {
|
||||
|
||||
#[async_trait]
|
||||
impl arbiter_proto::proto::arbiter_service_server::ArbiterService for super::Server {
|
||||
type UserAgentStream = ReceiverStream<Result<UserAgentResponse, Status>>;
|
||||
type OperatorStream = ReceiverStream<Result<OperatorResponse, Status>>;
|
||||
type ClientStream = ReceiverStream<Result<ClientResponse, Status>>;
|
||||
|
||||
#[tracing::instrument(level = "debug", skip(self))]
|
||||
@@ -52,23 +52,23 @@ impl arbiter_proto::proto::arbiter_service_server::ArbiterService for super::Ser
|
||||
}
|
||||
|
||||
#[tracing::instrument(level = "debug", skip(self))]
|
||||
async fn user_agent(
|
||||
async fn operator(
|
||||
&self,
|
||||
request: Request<tonic::Streaming<UserAgentRequest>>,
|
||||
) -> Result<Response<Self::UserAgentStream>, Status> {
|
||||
request: Request<tonic::Streaming<OperatorRequest>>,
|
||||
) -> Result<Response<Self::OperatorStream>, Status> {
|
||||
let req_stream = request.into_inner();
|
||||
|
||||
let (bi, rx) = GrpcBi::from_bi_stream(req_stream);
|
||||
|
||||
tokio::spawn(user_agent::start(
|
||||
UserAgentConnection {
|
||||
tokio::spawn(operator::start(
|
||||
OperatorConnection {
|
||||
db: self.context.db.clone(),
|
||||
actors: self.context.actors.clone(),
|
||||
},
|
||||
bi,
|
||||
));
|
||||
|
||||
info!(event = "connection established", "grpc.user_agent");
|
||||
info!(event = "connection established", "grpc.operator");
|
||||
|
||||
Ok(Response::new(rx))
|
||||
}
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
use crate::{
|
||||
grpc::request_tracker::RequestTracker,
|
||||
peers::user_agent::{OutOfBand, UserAgentConnection, UserAgentSession},
|
||||
peers::operator::{OutOfBand, OperatorConnection, OperatorSession},
|
||||
};
|
||||
use arbiter_proto::{
|
||||
proto::user_agent::{
|
||||
UserAgentRequest, UserAgentResponse,
|
||||
user_agent_request::Payload as UserAgentRequestPayload,
|
||||
user_agent_response::Payload as UserAgentResponsePayload,
|
||||
proto::operator::{
|
||||
OperatorRequest, OperatorResponse,
|
||||
operator_request::Payload as OperatorRequestPayload,
|
||||
operator_response::Payload as OperatorResponsePayload,
|
||||
},
|
||||
transport::{Error as TransportError, Receiver, Sender, grpc::GrpcBi},
|
||||
};
|
||||
@@ -38,8 +38,8 @@ impl Sender<OutOfBand> for OutOfBandAdapter {
|
||||
}
|
||||
|
||||
async fn dispatch_loop(
|
||||
mut bi: GrpcBi<UserAgentRequest, UserAgentResponse>,
|
||||
actor: ActorRef<UserAgentSession>,
|
||||
mut bi: GrpcBi<OperatorRequest, OperatorResponse>,
|
||||
actor: ActorRef<OperatorSession>,
|
||||
mut receiver: mpsc::Receiver<OutOfBand>,
|
||||
mut request_tracker: RequestTracker,
|
||||
) {
|
||||
@@ -53,7 +53,7 @@ async fn dispatch_loop(
|
||||
|
||||
let payload = sdk_client::out_of_band_payload(oob);
|
||||
|
||||
if bi.send(Ok(UserAgentResponse { id: None, payload: Some(payload) })).await.is_err() {
|
||||
if bi.send(Ok(OperatorResponse { id: None, payload: Some(payload) })).await.is_err() {
|
||||
return;
|
||||
}
|
||||
}
|
||||
@@ -64,7 +64,7 @@ async fn dispatch_loop(
|
||||
let conn = match message {
|
||||
Ok(conn) => conn,
|
||||
Err(err) => {
|
||||
warn!(error = ?err, "Failed to receive user agent request");
|
||||
warn!(error = ?err, "Failed to receive operator request");
|
||||
return;
|
||||
}
|
||||
};
|
||||
@@ -78,13 +78,13 @@ async fn dispatch_loop(
|
||||
};
|
||||
|
||||
let Some(payload) = conn.payload else {
|
||||
let _ = bi.send(Err(Status::invalid_argument("Missing user-agent request payload"))).await;
|
||||
let _ = bi.send(Err(Status::invalid_argument("Missing operator request payload"))).await;
|
||||
return;
|
||||
};
|
||||
|
||||
match dispatch_inner(&actor, payload).await {
|
||||
Ok(Some(response)) => {
|
||||
if bi.send(Ok(UserAgentResponse {
|
||||
if bi.send(Ok(OperatorResponse {
|
||||
id: Some(request_id),
|
||||
payload: Some(response),
|
||||
})).await.is_err() {
|
||||
@@ -93,7 +93,7 @@ async fn dispatch_loop(
|
||||
}
|
||||
Ok(None) => {}
|
||||
Err(status) => {
|
||||
error!(?status, "Failed to process user agent request");
|
||||
error!(?status, "Failed to process operator request");
|
||||
let _ = bi.send(Err(status)).await;
|
||||
return;
|
||||
}
|
||||
@@ -104,23 +104,23 @@ async fn dispatch_loop(
|
||||
}
|
||||
|
||||
async fn dispatch_inner(
|
||||
actor: &ActorRef<UserAgentSession>,
|
||||
payload: UserAgentRequestPayload,
|
||||
) -> Result<Option<UserAgentResponsePayload>, Status> {
|
||||
actor: &ActorRef<OperatorSession>,
|
||||
payload: OperatorRequestPayload,
|
||||
) -> Result<Option<OperatorResponsePayload>, Status> {
|
||||
match payload {
|
||||
UserAgentRequestPayload::Vault(req) => vault::dispatch(actor, req).await,
|
||||
UserAgentRequestPayload::Evm(req) => evm::dispatch(actor, req).await,
|
||||
UserAgentRequestPayload::SdkClient(req) => sdk_client::dispatch(actor, req).await,
|
||||
UserAgentRequestPayload::Auth(..) => {
|
||||
warn!("Unsupported post-auth user agent auth request");
|
||||
Err(Status::invalid_argument("Unsupported user-agent request"))
|
||||
OperatorRequestPayload::Vault(req) => vault::dispatch(actor, req).await,
|
||||
OperatorRequestPayload::Evm(req) => evm::dispatch(actor, req).await,
|
||||
OperatorRequestPayload::SdkClient(req) => sdk_client::dispatch(actor, req).await,
|
||||
OperatorRequestPayload::Auth(..) => {
|
||||
warn!("Unsupported post-auth operator auth request");
|
||||
Err(Status::invalid_argument("Unsupported operator request"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub async fn start(
|
||||
mut conn: UserAgentConnection,
|
||||
mut bi: GrpcBi<UserAgentRequest, UserAgentResponse>,
|
||||
mut conn: OperatorConnection,
|
||||
mut bi: GrpcBi<OperatorRequest, OperatorResponse>,
|
||||
) {
|
||||
let mut request_tracker = RequestTracker::default();
|
||||
|
||||
@@ -129,16 +129,16 @@ pub async fn start(
|
||||
|
||||
let actor = {
|
||||
let transport = auth::AuthTransportAdapter::new(&mut bi, &mut request_tracker);
|
||||
match crate::peers::user_agent::start(&mut conn, transport, Box::new(oob_adapter)).await {
|
||||
match crate::peers::operator::start(&mut conn, transport, Box::new(oob_adapter)).await {
|
||||
Ok(actor) => actor,
|
||||
Err(e) => {
|
||||
warn!(error = ?e, "User agent connection failed");
|
||||
warn!(error = ?e, "Operator connection failed");
|
||||
return;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
info!("User agent session established");
|
||||
info!("Operator session established");
|
||||
|
||||
dispatch_loop(bi, actor.clone(), oob_receiver, request_tracker).await;
|
||||
actor.kill();
|
||||
@@ -1,16 +1,16 @@
|
||||
use crate::{grpc::request_tracker::RequestTracker, peers::user_agent::auth};
|
||||
use crate::{grpc::request_tracker::RequestTracker, peers::operator::auth};
|
||||
use arbiter_crypto::authn;
|
||||
use arbiter_proto::{
|
||||
proto::user_agent::{
|
||||
UserAgentRequest, UserAgentResponse,
|
||||
proto::operator::{
|
||||
OperatorRequest, OperatorResponse,
|
||||
auth::{
|
||||
self as proto_auth, AuthChallenge as ProtoAuthChallenge,
|
||||
AuthChallengeRequest as ProtoAuthChallengeRequest,
|
||||
AuthChallengeSolution as ProtoAuthChallengeSolution, AuthResult as ProtoAuthResult,
|
||||
request::Payload as AuthRequestPayload, response::Payload as AuthResponsePayload,
|
||||
},
|
||||
user_agent_request::Payload as UserAgentRequestPayload,
|
||||
user_agent_response::Payload as UserAgentResponsePayload,
|
||||
operator_request::Payload as OperatorRequestPayload,
|
||||
operator_response::Payload as OperatorResponsePayload,
|
||||
},
|
||||
transport::{Bi, Error as TransportError, Receiver, Sender, grpc::GrpcBi},
|
||||
};
|
||||
@@ -20,13 +20,13 @@ use tonic::Status;
|
||||
use tracing::warn;
|
||||
|
||||
pub(super) struct AuthTransportAdapter<'a> {
|
||||
pub(super) bi: &'a mut GrpcBi<UserAgentRequest, UserAgentResponse>,
|
||||
pub(super) bi: &'a mut GrpcBi<OperatorRequest, OperatorResponse>,
|
||||
pub(super) request_tracker: &'a mut RequestTracker,
|
||||
}
|
||||
|
||||
impl<'a> AuthTransportAdapter<'a> {
|
||||
pub(super) const fn new(
|
||||
bi: &'a mut GrpcBi<UserAgentRequest, UserAgentResponse>,
|
||||
bi: &'a mut GrpcBi<OperatorRequest, OperatorResponse>,
|
||||
request_tracker: &'a mut RequestTracker,
|
||||
) -> Self {
|
||||
Self {
|
||||
@@ -35,7 +35,7 @@ impl<'a> AuthTransportAdapter<'a> {
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) const fn bi_mut(&mut self) -> &mut GrpcBi<UserAgentRequest, UserAgentResponse> {
|
||||
pub(super) const fn bi_mut(&mut self) -> &mut GrpcBi<OperatorRequest, OperatorResponse> {
|
||||
self.bi
|
||||
}
|
||||
|
||||
@@ -45,21 +45,21 @@ impl<'a> AuthTransportAdapter<'a> {
|
||||
|
||||
pub(super) async fn send_response_payload(
|
||||
&mut self,
|
||||
payload: UserAgentResponsePayload,
|
||||
payload: OperatorResponsePayload,
|
||||
) -> Result<(), TransportError> {
|
||||
self.bi
|
||||
.send(Ok(UserAgentResponse {
|
||||
.send(Ok(OperatorResponse {
|
||||
id: Some(self.request_tracker.current_request_id()),
|
||||
payload: Some(payload),
|
||||
}))
|
||||
.await
|
||||
}
|
||||
|
||||
async fn send_user_agent_response(
|
||||
async fn send_operator_response(
|
||||
&mut self,
|
||||
payload: AuthResponsePayload,
|
||||
) -> Result<(), TransportError> {
|
||||
self.send_response_payload(UserAgentResponsePayload::Auth(proto_auth::Response {
|
||||
self.send_response_payload(OperatorResponsePayload::Auth(proto_auth::Response {
|
||||
payload: Some(payload),
|
||||
}))
|
||||
.await
|
||||
@@ -107,7 +107,7 @@ impl Sender<Result<auth::Outbound, auth::Error>> for AuthTransportAdapter<'_> {
|
||||
}
|
||||
};
|
||||
|
||||
self.send_user_agent_response(payload).await
|
||||
self.send_operator_response(payload).await
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,7 +117,7 @@ impl Receiver<auth::Inbound> for AuthTransportAdapter<'_> {
|
||||
let request = match self.bi.recv().await? {
|
||||
Ok(request) => request,
|
||||
Err(error) => {
|
||||
warn!(error = ?error, "Failed to receive user agent auth request");
|
||||
warn!(error = ?error, "Failed to receive operator auth request");
|
||||
return None;
|
||||
}
|
||||
};
|
||||
@@ -133,16 +133,16 @@ impl Receiver<auth::Inbound> for AuthTransportAdapter<'_> {
|
||||
let Some(payload) = request.payload else {
|
||||
warn!(
|
||||
event = "received request with empty payload",
|
||||
"grpc.useragent.auth_adapter"
|
||||
"grpc.operator.auth_adapter"
|
||||
);
|
||||
return None;
|
||||
};
|
||||
|
||||
let UserAgentRequestPayload::Auth(auth_request) = payload else {
|
||||
let OperatorRequestPayload::Auth(auth_request) = payload else {
|
||||
let _ = self
|
||||
.bi
|
||||
.send(Err(Status::invalid_argument(
|
||||
"Unsupported user-agent auth request",
|
||||
"Unsupported operator auth request",
|
||||
)))
|
||||
.await;
|
||||
return None;
|
||||
@@ -151,7 +151,7 @@ impl Receiver<auth::Inbound> for AuthTransportAdapter<'_> {
|
||||
let Some(payload) = auth_request.payload else {
|
||||
warn!(
|
||||
event = "received auth request with empty payload",
|
||||
"grpc.useragent.auth_adapter"
|
||||
"grpc.operator.auth_adapter"
|
||||
);
|
||||
return None;
|
||||
};
|
||||
@@ -164,7 +164,7 @@ impl Receiver<auth::Inbound> for AuthTransportAdapter<'_> {
|
||||
let Ok(pubkey) = authn::PublicKey::try_from(pubkey.as_slice()) else {
|
||||
warn!(
|
||||
event = "received request with invalid public key",
|
||||
"grpc.useragent.auth_adapter"
|
||||
"grpc.operator.auth_adapter"
|
||||
);
|
||||
return None;
|
||||
};
|
||||
@@ -3,8 +3,8 @@ use crate::{
|
||||
Convert, TryConvert,
|
||||
common::inbound::{RawEvmAddress, RawEvmTransaction},
|
||||
},
|
||||
peers::user_agent::{
|
||||
UserAgentSession,
|
||||
peers::operator::{
|
||||
OperatorSession,
|
||||
session::handlers::{
|
||||
GrantMutationError, HandleEvmWalletCreate, HandleEvmWalletList, HandleGrantCreate,
|
||||
HandleGrantDelete, HandleGrantList, HandleSignTransaction,
|
||||
@@ -24,12 +24,12 @@ use arbiter_proto::proto::{
|
||||
wallet_create_response::Result as WalletCreateResult,
|
||||
wallet_list_response::Result as WalletListResult,
|
||||
},
|
||||
user_agent::{
|
||||
operator::{
|
||||
evm::{
|
||||
self as proto_evm, SignTransactionRequest as ProtoSignTransactionRequest,
|
||||
request::Payload as EvmRequestPayload, response::Payload as EvmResponsePayload,
|
||||
},
|
||||
user_agent_response::Payload as UserAgentResponsePayload,
|
||||
operator_response::Payload as OperatorResponsePayload,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -37,16 +37,16 @@ use kameo::actor::ActorRef;
|
||||
use tonic::Status;
|
||||
use tracing::warn;
|
||||
|
||||
const fn wrap_evm_response(payload: EvmResponsePayload) -> UserAgentResponsePayload {
|
||||
UserAgentResponsePayload::Evm(proto_evm::Response {
|
||||
const fn wrap_evm_response(payload: EvmResponsePayload) -> OperatorResponsePayload {
|
||||
OperatorResponsePayload::Evm(proto_evm::Response {
|
||||
payload: Some(payload),
|
||||
})
|
||||
}
|
||||
|
||||
pub(super) async fn dispatch(
|
||||
actor: &ActorRef<UserAgentSession>,
|
||||
actor: &ActorRef<OperatorSession>,
|
||||
req: proto_evm::Request,
|
||||
) -> Result<Option<UserAgentResponsePayload>, Status> {
|
||||
) -> Result<Option<OperatorResponsePayload>, Status> {
|
||||
let Some(payload) = req.payload else {
|
||||
return Err(Status::invalid_argument("Missing EVM request payload"));
|
||||
};
|
||||
@@ -62,8 +62,8 @@ pub(super) async fn dispatch(
|
||||
}
|
||||
|
||||
async fn handle_wallet_create(
|
||||
actor: &ActorRef<UserAgentSession>,
|
||||
) -> Result<Option<UserAgentResponsePayload>, Status> {
|
||||
actor: &ActorRef<OperatorSession>,
|
||||
) -> Result<Option<OperatorResponsePayload>, Status> {
|
||||
let result = match actor.ask(HandleEvmWalletCreate {}).await {
|
||||
Ok((wallet_id, address)) => WalletCreateResult::Wallet(WalletEntry {
|
||||
id: wallet_id,
|
||||
@@ -82,8 +82,8 @@ async fn handle_wallet_create(
|
||||
}
|
||||
|
||||
async fn handle_wallet_list(
|
||||
actor: &ActorRef<UserAgentSession>,
|
||||
) -> Result<Option<UserAgentResponsePayload>, Status> {
|
||||
actor: &ActorRef<OperatorSession>,
|
||||
) -> Result<Option<OperatorResponsePayload>, Status> {
|
||||
let result = match actor.ask(HandleEvmWalletList {}).await {
|
||||
Ok(wallets) => WalletListResult::Wallets(WalletList {
|
||||
wallets: wallets
|
||||
@@ -107,8 +107,8 @@ async fn handle_wallet_list(
|
||||
}
|
||||
|
||||
async fn handle_grant_list(
|
||||
actor: &ActorRef<UserAgentSession>,
|
||||
) -> Result<Option<UserAgentResponsePayload>, Status> {
|
||||
actor: &ActorRef<OperatorSession>,
|
||||
) -> Result<Option<OperatorResponsePayload>, Status> {
|
||||
let result = match actor.ask(HandleGrantList {}).await {
|
||||
Ok(grants) => EvmGrantListResult::Grants(EvmGrantList {
|
||||
grants: grants
|
||||
@@ -134,9 +134,9 @@ async fn handle_grant_list(
|
||||
}
|
||||
|
||||
async fn handle_grant_create(
|
||||
actor: &ActorRef<UserAgentSession>,
|
||||
actor: &ActorRef<OperatorSession>,
|
||||
req: EvmGrantCreateRequest,
|
||||
) -> Result<Option<UserAgentResponsePayload>, Status> {
|
||||
) -> Result<Option<OperatorResponsePayload>, Status> {
|
||||
let basic = req
|
||||
.shared
|
||||
.ok_or_else(|| Status::invalid_argument("Missing shared grant settings"))?
|
||||
@@ -164,9 +164,9 @@ async fn handle_grant_create(
|
||||
}
|
||||
|
||||
async fn handle_grant_delete(
|
||||
actor: &ActorRef<UserAgentSession>,
|
||||
actor: &ActorRef<OperatorSession>,
|
||||
req: EvmGrantDeleteRequest,
|
||||
) -> Result<Option<UserAgentResponsePayload>, Status> {
|
||||
) -> Result<Option<OperatorResponsePayload>, Status> {
|
||||
let result = match actor
|
||||
.ask(HandleGrantDelete {
|
||||
grant_id: req.grant_id,
|
||||
@@ -190,9 +190,9 @@ async fn handle_grant_delete(
|
||||
}
|
||||
|
||||
async fn handle_sign_transaction(
|
||||
actor: &ActorRef<UserAgentSession>,
|
||||
actor: &ActorRef<OperatorSession>,
|
||||
req: ProtoSignTransactionRequest,
|
||||
) -> Result<Option<UserAgentResponsePayload>, Status> {
|
||||
) -> Result<Option<OperatorResponsePayload>, Status> {
|
||||
let request = req
|
||||
.request
|
||||
.ok_or_else(|| Status::invalid_argument("Missing sign transaction request"))?;
|
||||
@@ -14,7 +14,7 @@ use arbiter_proto::{
|
||||
TransactionRateLimit as ProtoTransactionRateLimit, VolumeRateLimit as ProtoVolumeRateLimit,
|
||||
specific_grant::Grant as ProtoSpecificGrantType,
|
||||
},
|
||||
proto::user_agent::sdk_client::{WalletAccess, WalletAccessEntry as SdkClientWalletAccess},
|
||||
proto::operator::sdk_client::{WalletAccess, WalletAccessEntry as SdkClientWalletAccess},
|
||||
};
|
||||
|
||||
use alloy::primitives::{Address, U256};
|
||||
@@ -10,7 +10,7 @@ use arbiter_proto::proto::{
|
||||
TransactionRateLimit as ProtoTransactionRateLimit, VolumeRateLimit as ProtoVolumeRateLimit,
|
||||
specific_grant::Grant as ProtoSpecificGrantType,
|
||||
},
|
||||
user_agent::sdk_client::{WalletAccess, WalletAccessEntry as ProtoSdkClientWalletAccess},
|
||||
operator::sdk_client::{WalletAccess, WalletAccessEntry as ProtoSdkClientWalletAccess},
|
||||
};
|
||||
|
||||
use chrono::{DateTime, Utc};
|
||||
@@ -1,8 +1,8 @@
|
||||
use crate::{
|
||||
db::models::NewEvmWalletAccess,
|
||||
grpc::Convert,
|
||||
peers::user_agent::{
|
||||
OutOfBand, UserAgentSession,
|
||||
peers::operator::{
|
||||
OutOfBand, OperatorSession,
|
||||
session::handlers::{
|
||||
HandleGrantEvmWalletAccess, HandleListWalletAccess, HandleNewClientApprove,
|
||||
HandleRevokeEvmWalletAccess, HandleSdkClientList,
|
||||
@@ -12,7 +12,7 @@ use crate::{
|
||||
use arbiter_crypto::authn;
|
||||
use arbiter_proto::proto::{
|
||||
shared::ClientInfo as ProtoClientMetadata,
|
||||
user_agent::{
|
||||
operator::{
|
||||
sdk_client::{
|
||||
self as proto_sdk_client, ConnectionCancel as ProtoSdkClientConnectionCancel,
|
||||
ConnectionRequest as ProtoSdkClientConnectionRequest,
|
||||
@@ -24,7 +24,7 @@ use arbiter_proto::proto::{
|
||||
request::Payload as SdkClientRequestPayload,
|
||||
response::Payload as SdkClientResponsePayload,
|
||||
},
|
||||
user_agent_response::Payload as UserAgentResponsePayload,
|
||||
operator_response::Payload as OperatorResponsePayload,
|
||||
},
|
||||
};
|
||||
|
||||
@@ -32,13 +32,13 @@ use kameo::actor::ActorRef;
|
||||
use tonic::Status;
|
||||
use tracing::{info, warn};
|
||||
|
||||
const fn wrap_sdk_client_response(payload: SdkClientResponsePayload) -> UserAgentResponsePayload {
|
||||
UserAgentResponsePayload::SdkClient(proto_sdk_client::Response {
|
||||
const fn wrap_sdk_client_response(payload: SdkClientResponsePayload) -> OperatorResponsePayload {
|
||||
OperatorResponsePayload::SdkClient(proto_sdk_client::Response {
|
||||
payload: Some(payload),
|
||||
})
|
||||
}
|
||||
|
||||
pub(super) fn out_of_band_payload(oob: OutOfBand) -> UserAgentResponsePayload {
|
||||
pub(super) fn out_of_band_payload(oob: OutOfBand) -> OperatorResponsePayload {
|
||||
match oob {
|
||||
OutOfBand::ClientConnectionRequest { profile } => wrap_sdk_client_response(
|
||||
SdkClientResponsePayload::ConnectionRequest(ProtoSdkClientConnectionRequest {
|
||||
@@ -59,9 +59,9 @@ pub(super) fn out_of_band_payload(oob: OutOfBand) -> UserAgentResponsePayload {
|
||||
}
|
||||
|
||||
pub(super) async fn dispatch(
|
||||
actor: &ActorRef<UserAgentSession>,
|
||||
actor: &ActorRef<OperatorSession>,
|
||||
req: proto_sdk_client::Request,
|
||||
) -> Result<Option<UserAgentResponsePayload>, Status> {
|
||||
) -> Result<Option<OperatorResponsePayload>, Status> {
|
||||
let Some(payload) = req.payload else {
|
||||
return Err(Status::invalid_argument(
|
||||
"Missing SDK client request payload",
|
||||
@@ -87,9 +87,9 @@ pub(super) async fn dispatch(
|
||||
}
|
||||
|
||||
async fn handle_connection_response(
|
||||
actor: &ActorRef<UserAgentSession>,
|
||||
actor: &ActorRef<OperatorSession>,
|
||||
resp: ProtoSdkClientConnectionResponse,
|
||||
) -> Result<Option<UserAgentResponsePayload>, Status> {
|
||||
) -> Result<Option<OperatorResponsePayload>, Status> {
|
||||
let pubkey = authn::PublicKey::try_from(resp.pubkey.as_slice())
|
||||
.map_err(|()| Status::invalid_argument("Invalid ML-DSA public key"))?;
|
||||
|
||||
@@ -108,8 +108,8 @@ async fn handle_connection_response(
|
||||
}
|
||||
|
||||
async fn handle_list(
|
||||
actor: &ActorRef<UserAgentSession>,
|
||||
) -> Result<Option<UserAgentResponsePayload>, Status> {
|
||||
actor: &ActorRef<OperatorSession>,
|
||||
) -> Result<Option<OperatorResponsePayload>, Status> {
|
||||
let result = match actor.ask(HandleSdkClientList {}).await {
|
||||
Ok(clients) => ProtoSdkClientListResult::Clients(ProtoSdkClientList {
|
||||
clients: clients
|
||||
@@ -144,9 +144,9 @@ async fn handle_list(
|
||||
}
|
||||
|
||||
async fn handle_grant_wallet_access(
|
||||
actor: &ActorRef<UserAgentSession>,
|
||||
actor: &ActorRef<OperatorSession>,
|
||||
req: ProtoSdkClientGrantWalletAccess,
|
||||
) -> Result<Option<UserAgentResponsePayload>, Status> {
|
||||
) -> Result<Option<OperatorResponsePayload>, Status> {
|
||||
let entries: Vec<NewEvmWalletAccess> = req.accesses.into_iter().map(Convert::convert).collect();
|
||||
match actor.ask(HandleGrantEvmWalletAccess { entries }).await {
|
||||
Ok(()) => {
|
||||
@@ -161,9 +161,9 @@ async fn handle_grant_wallet_access(
|
||||
}
|
||||
|
||||
async fn handle_revoke_wallet_access(
|
||||
actor: &ActorRef<UserAgentSession>,
|
||||
actor: &ActorRef<OperatorSession>,
|
||||
req: ProtoSdkClientRevokeWalletAccess,
|
||||
) -> Result<Option<UserAgentResponsePayload>, Status> {
|
||||
) -> Result<Option<OperatorResponsePayload>, Status> {
|
||||
match actor
|
||||
.ask(HandleRevokeEvmWalletAccess {
|
||||
entries: req.accesses,
|
||||
@@ -182,8 +182,8 @@ async fn handle_revoke_wallet_access(
|
||||
}
|
||||
|
||||
async fn handle_list_wallet_access(
|
||||
actor: &ActorRef<UserAgentSession>,
|
||||
) -> Result<Option<UserAgentResponsePayload>, Status> {
|
||||
actor: &ActorRef<OperatorSession>,
|
||||
) -> Result<Option<OperatorResponsePayload>, Status> {
|
||||
match actor.ask(HandleListWalletAccess {}).await {
|
||||
Ok(accesses) => Ok(Some(wrap_sdk_client_response(
|
||||
SdkClientResponsePayload::ListWalletAccess(ListWalletAccessResponse {
|
||||
@@ -1,11 +1,11 @@
|
||||
use crate::{
|
||||
actors::vault::VaultState,
|
||||
peers::user_agent::{UserAgentSession, session::handlers::HandleQueryVaultState},
|
||||
peers::operator::{OperatorSession, session::handlers::HandleQueryVaultState},
|
||||
};
|
||||
use arbiter_proto::{
|
||||
proto::shared::VaultState as ProtoVaultState,
|
||||
proto::user_agent::{
|
||||
user_agent_response::Payload as UserAgentResponsePayload,
|
||||
proto::operator::{
|
||||
operator_response::Payload as OperatorResponsePayload,
|
||||
vault::{
|
||||
self as proto_vault, request::Payload as VaultRequestPayload,
|
||||
response::Payload as VaultResponsePayload,
|
||||
@@ -17,16 +17,16 @@ use kameo::actor::ActorRef;
|
||||
use tonic::Status;
|
||||
use tracing::warn;
|
||||
|
||||
const fn wrap_vault_response(payload: VaultResponsePayload) -> UserAgentResponsePayload {
|
||||
UserAgentResponsePayload::Vault(proto_vault::Response {
|
||||
const fn wrap_vault_response(payload: VaultResponsePayload) -> OperatorResponsePayload {
|
||||
OperatorResponsePayload::Vault(proto_vault::Response {
|
||||
payload: Some(payload),
|
||||
})
|
||||
}
|
||||
|
||||
pub(super) async fn dispatch(
|
||||
actor: &ActorRef<UserAgentSession>,
|
||||
actor: &ActorRef<OperatorSession>,
|
||||
req: proto_vault::Request,
|
||||
) -> Result<Option<UserAgentResponsePayload>, Status> {
|
||||
) -> Result<Option<OperatorResponsePayload>, Status> {
|
||||
let Some(payload) = req.payload else {
|
||||
return Err(Status::invalid_argument("Missing vault request payload"));
|
||||
};
|
||||
@@ -42,8 +42,8 @@ pub(super) async fn dispatch(
|
||||
}
|
||||
|
||||
async fn handle_query_vault_state(
|
||||
actor: &ActorRef<UserAgentSession>,
|
||||
) -> Result<Option<UserAgentResponsePayload>, Status> {
|
||||
actor: &ActorRef<OperatorSession>,
|
||||
) -> Result<Option<OperatorResponsePayload>, Status> {
|
||||
let state = match actor.ask(HandleQueryVaultState {}).await {
|
||||
Ok(VaultState::Unbootstrapped) => ProtoVaultState::Unbootstrapped,
|
||||
Ok(VaultState::Sealed) => ProtoVaultState::Sealed,
|
||||
@@ -1,7 +1,7 @@
|
||||
use super::auth::AuthTransportAdapter;
|
||||
use crate::{
|
||||
grpc::TryConvert,
|
||||
peers::user_agent::vault_gate::{self as vault_gate},
|
||||
peers::operator::vault_gate::{self as vault_gate},
|
||||
};
|
||||
use arbiter_proto::transport::{Bi, Error as TransportError, Receiver, Sender};
|
||||
|
||||
@@ -20,7 +20,7 @@ impl Receiver<vault_gate::Inbound> for AuthTransportAdapter<'_> {
|
||||
Err(error) => {
|
||||
warn!(
|
||||
?error,
|
||||
"Failed to receive user agent request during vault gate"
|
||||
"Failed to receive operator request during vault gate"
|
||||
);
|
||||
return None;
|
||||
}
|
||||
@@ -1,11 +1,11 @@
|
||||
use crate::{
|
||||
grpc::{Convert, TryConvert},
|
||||
peers::user_agent::vault_gate::{
|
||||
peers::operator::vault_gate::{
|
||||
self as vault_gate, HandleBootstrapEncryptedKey, HandleHandshake, HandleUnsealEncryptedKey,
|
||||
},
|
||||
};
|
||||
use arbiter_proto::proto::user_agent::{
|
||||
user_agent_request::Payload as UserAgentRequestPayload,
|
||||
use arbiter_proto::proto::operator::{
|
||||
operator_request::Payload as OperatorRequestPayload,
|
||||
vault::{
|
||||
self as proto_vault,
|
||||
bootstrap::{self as proto_bootstrap},
|
||||
@@ -16,7 +16,7 @@ use arbiter_proto::proto::user_agent::{
|
||||
|
||||
use tonic::Status;
|
||||
|
||||
impl TryConvert for UserAgentRequestPayload {
|
||||
impl TryConvert for OperatorRequestPayload {
|
||||
type Output = vault_gate::Inbound;
|
||||
type Error = Status;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
use crate::{
|
||||
actors::vault::VaultState,
|
||||
grpc::{Convert, TryConvert},
|
||||
peers::user_agent::vault_gate::{self as vault_gate},
|
||||
peers::operator::vault_gate::{self as vault_gate},
|
||||
};
|
||||
use arbiter_proto::proto::{
|
||||
shared::VaultState as ProtoVaultState,
|
||||
user_agent::{
|
||||
user_agent_response::Payload as UserAgentResponsePayload,
|
||||
operator::{
|
||||
operator_response::Payload as OperatorResponsePayload,
|
||||
vault::{
|
||||
self as proto_vault,
|
||||
bootstrap::{self as proto_bootstrap, BootstrapResult as ProtoBootstrapResult},
|
||||
@@ -22,28 +22,28 @@ use arbiter_proto::proto::{
|
||||
use tonic::Status;
|
||||
use tracing::warn;
|
||||
|
||||
const fn wrap_vault_response(payload: VaultResponsePayload) -> UserAgentResponsePayload {
|
||||
UserAgentResponsePayload::Vault(proto_vault::Response {
|
||||
const fn wrap_vault_response(payload: VaultResponsePayload) -> OperatorResponsePayload {
|
||||
OperatorResponsePayload::Vault(proto_vault::Response {
|
||||
payload: Some(payload),
|
||||
})
|
||||
}
|
||||
|
||||
const fn wrap_unseal_response(payload: UnsealResponsePayload) -> UserAgentResponsePayload {
|
||||
const fn wrap_unseal_response(payload: UnsealResponsePayload) -> OperatorResponsePayload {
|
||||
wrap_vault_response(VaultResponsePayload::Unseal(proto_unseal::Response {
|
||||
payload: Some(payload),
|
||||
}))
|
||||
}
|
||||
|
||||
fn wrap_bootstrap_response(result: ProtoBootstrapResult) -> UserAgentResponsePayload {
|
||||
fn wrap_bootstrap_response(result: ProtoBootstrapResult) -> OperatorResponsePayload {
|
||||
wrap_vault_response(VaultResponsePayload::Bootstrap(proto_bootstrap::Response {
|
||||
result: result.into(),
|
||||
}))
|
||||
}
|
||||
|
||||
impl Convert for VaultState {
|
||||
type Output = UserAgentResponsePayload;
|
||||
type Output = OperatorResponsePayload;
|
||||
|
||||
fn convert(self) -> UserAgentResponsePayload {
|
||||
fn convert(self) -> OperatorResponsePayload {
|
||||
let proto_state = match self {
|
||||
Self::Unbootstrapped => ProtoVaultState::Unbootstrapped,
|
||||
Self::Sealed => ProtoVaultState::Sealed,
|
||||
@@ -54,9 +54,9 @@ impl Convert for VaultState {
|
||||
}
|
||||
|
||||
impl Convert for vault_gate::HandshakeResponse {
|
||||
type Output = UserAgentResponsePayload;
|
||||
type Output = OperatorResponsePayload;
|
||||
|
||||
fn convert(self) -> UserAgentResponsePayload {
|
||||
fn convert(self) -> OperatorResponsePayload {
|
||||
wrap_unseal_response(UnsealResponsePayload::Start(
|
||||
proto_unseal::UnsealStartResponse {
|
||||
server_pubkey: self.server_pubkey.as_bytes().to_vec(),
|
||||
@@ -66,10 +66,10 @@ impl Convert for vault_gate::HandshakeResponse {
|
||||
}
|
||||
|
||||
impl TryConvert for vault_gate::Outbound {
|
||||
type Output = UserAgentResponsePayload;
|
||||
type Output = OperatorResponsePayload;
|
||||
type Error = Status;
|
||||
|
||||
fn try_convert(self) -> Result<UserAgentResponsePayload, Status> {
|
||||
fn try_convert(self) -> Result<OperatorResponsePayload, Status> {
|
||||
match self {
|
||||
Self::HandleVaultState(result) => result
|
||||
.map_err(|err| {
|
||||
Reference in New Issue
Block a user