Skip to content

Commit

Permalink
refactor: VeriKey -> VerKey
Browse files Browse the repository at this point in the history
Signed-off-by: Naian <[email protected]>
  • Loading branch information
nain-F49FF806 committed Oct 27, 2023
1 parent a294784 commit 3ca303a
Show file tree
Hide file tree
Showing 6 changed files with 41 additions and 45 deletions.
18 changes: 7 additions & 11 deletions agents/rust/mediator/src/aries_agent/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ use messages::{
use serde_json::json;

use self::transports::AriesTransport;
use crate::utils::{prelude::*, structs::VeriKey};
use crate::utils::{prelude::*, structs::VerKey};

#[cfg(any(test, feature = "client"))]
pub mod client;
Expand Down Expand Up @@ -136,7 +136,7 @@ impl<T: BaseWallet + 'static, P: MediatorPersistence> Agent<T, P> {
pub async fn pack_didcomm(
&self,
message: &[u8],
our_vk: &VeriKey,
our_vk: &VerKey,
their_diddoc: &AriesDidDoc,
) -> Result<EncryptionEnvelope, String> {
EncryptionEnvelope::create(self.wallet.as_ref(), message, Some(our_vk), their_diddoc)
Expand All @@ -146,7 +146,7 @@ impl<T: BaseWallet + 'static, P: MediatorPersistence> Agent<T, P> {
pub async fn pack_and_send_didcomm(
&self,
message: &[u8],
our_vk: &VeriKey,
our_vk: &VerKey,
their_diddoc: &AriesDidDoc,
aries_transport: &mut impl AriesTransport,
) -> Result<(), String> {
Expand All @@ -163,14 +163,10 @@ impl<T: BaseWallet + 'static, P: MediatorPersistence> Agent<T, P> {
.map_err(string_from_std_error)
}

// pub async fn pack_message(&self, message: AriesMessage, recipient_vk: VeriKey, sender_vk:
// VeriKey) -> Value { todo!()
// }
/// Returns account details (account_name, our_signing_key, did_doc)
pub async fn auth_and_get_details(
&self,
sender_verkey: &Option<VeriKey>,
) -> Result<(String, VeriKey, AriesDidDoc), String> {
sender_verkey: &Option<VerKey>,
) -> Result<(String, VerKey, AriesDidDoc), String> {
let auth_pubkey = sender_verkey
.as_deref()
.ok_or("Anonymous sender can't be authenticated")?;
Expand Down Expand Up @@ -238,8 +234,8 @@ impl<T: BaseWallet + 'static, P: MediatorPersistence> Agent<T, P> {

pub async fn create_account(
&self,
their_vk: &VeriKey,
our_vk: &VeriKey,
their_vk: &VerKey,
our_vk: &VerKey,
did_doc: &AriesDidDoc,
) -> Result<(), String> {
self.persistence
Expand Down
6 changes: 3 additions & 3 deletions agents/rust/mediator/src/aries_agent/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@ use messages::{
};
use uuid::Uuid;

use crate::utils::structs::VeriKey;
use crate::utils::structs::VerKey;

pub async fn build_response_content(
wallet: &impl BaseWallet,
thread_id: String,
old_recipient_vk: VeriKey,
old_recipient_vk: VerKey,
new_recipient_did: String,
new_recipient_vk: VeriKey,
new_recipient_vk: VerKey,
new_service_endpoint: url::Url,
new_routing_keys: Vec<String>,
) -> VcxResult<Response> {
Expand Down
2 changes: 1 addition & 1 deletion agents/rust/mediator/src/utils/structs.rs
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pub type VeriKey = String;
pub type VerKey = String;
14 changes: 7 additions & 7 deletions agents/rust/mediator/tests/common/agent_and_transport_utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ use mediator::{
transports::{AriesReqwest, AriesTransport},
Agent,
},
utils::{structs::VeriKey, GenericStringError},
utils::{structs::VerKey, GenericStringError},
};
use messages::msg_fields::protocols::out_of_band::invitation::Invitation as OOBInvitation;
use reqwest::header::ACCEPT;
Expand Down Expand Up @@ -42,11 +42,11 @@ pub async fn didcomm_connection(
Ok(state)
}

/// Returns agent, aries transport for agent, agent's verikey, and mediator's diddoc.
/// Returns agent, aries transport for agent, agent's verkey, and mediator's diddoc.
pub async fn gen_mediator_connected_agent() -> Result<(
Agent<impl BaseWallet + 'static, impl MediatorPersistence>,
impl AriesTransport,
VeriKey,
VerKey,
AriesDidDoc,
)> {
let agent = mediator::aries_agent::AgentBuilder::new_demo_agent().await?;
Expand All @@ -55,21 +55,21 @@ pub async fn gen_mediator_connected_agent() -> Result<(
client: reqwest::Client::new(),
};
let completed_connection = didcomm_connection(&agent, &mut aries_transport).await?;
let our_verikey: VeriKey = completed_connection.pairwise_info().pw_vk.clone();
let our_verkey: VerKey = completed_connection.pairwise_info().pw_vk.clone();
let their_diddoc = completed_connection.their_did_doc().clone();
Ok((agent, aries_transport, our_verikey, their_diddoc))
Ok((agent, aries_transport, our_verkey, their_diddoc))
}

/// Sends message over didcomm connection and returns unpacked response message
pub async fn send_message_and_pop_response_message(
message_bytes: &[u8],
agent: &Agent<impl BaseWallet + 'static, impl MediatorPersistence>,
aries_transport: &mut impl AriesTransport,
our_verikey: &VeriKey,
our_verkey: &VerKey,
their_diddoc: &AriesDidDoc,
) -> Result<String> {
agent
.pack_and_send_didcomm(message_bytes, our_verikey, their_diddoc, aries_transport)
.pack_and_send_didcomm(message_bytes, our_verkey, their_diddoc, aries_transport)
.await
.map_err(|err| GenericStringError { msg: err })?;
// unpack
Expand Down
34 changes: 17 additions & 17 deletions agents/rust/mediator/tests/mediator-coord-protocol.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use mediator::{
transports::{AriesReqwest, AriesTransport},
Agent,
},
utils::{structs::VeriKey, GenericStringError},
utils::{structs::VerKey, GenericStringError},
};
use messages::msg_fields::protocols::out_of_band::invitation::Invitation as OOBInvitation;
use reqwest::header::ACCEPT;
Expand Down Expand Up @@ -62,11 +62,11 @@ async fn didcomm_connection(
Ok(state)
}

/// Returns agent, aries transport for agent, agent's verikey, and mediator's diddoc.
/// Returns agent, aries transport for agent, agent's verkey, and mediator's diddoc.
async fn gen_mediator_connected_agent() -> Result<(
Agent<impl BaseWallet + 'static, impl MediatorPersistence>,
impl AriesTransport,
VeriKey,
VerKey,
AriesDidDoc,
)> {
let agent = mediator::aries_agent::AgentBuilder::new_demo_agent().await?;
Expand All @@ -75,21 +75,21 @@ async fn gen_mediator_connected_agent() -> Result<(
client: reqwest::Client::new(),
};
let completed_connection = didcomm_connection(&agent, &mut aries_transport).await?;
let our_verikey: VeriKey = completed_connection.pairwise_info().pw_vk.clone();
let our_verkey: VerKey = completed_connection.pairwise_info().pw_vk.clone();
let their_diddoc = completed_connection.their_did_doc().clone();
Ok((agent, aries_transport, our_verikey, their_diddoc))
Ok((agent, aries_transport, our_verkey, their_diddoc))
}

/// Sends message over didcomm connection and returns unpacked response message
async fn send_message_and_pop_response_message(
message_bytes: &[u8],
agent: &Agent<impl BaseWallet + 'static, impl MediatorPersistence>,
aries_transport: &mut impl AriesTransport,
our_verikey: &VeriKey,
our_verkey: &VerKey,
their_diddoc: &AriesDidDoc,
) -> Result<String> {
agent
.pack_and_send_didcomm(message_bytes, our_verikey, their_diddoc, aries_transport)
.pack_and_send_didcomm(message_bytes, our_verkey, their_diddoc, aries_transport)
.await
.map_err(|err| GenericStringError { msg: err })?;
// unpack
Expand Down Expand Up @@ -120,7 +120,7 @@ async fn test_init() {
async fn test_mediate_grant() -> Result<()> {
TestSetupAries.init();
// prepare connection parameters
let (agent, mut aries_transport, our_verikey, their_diddoc) =
let (agent, mut aries_transport, our_verkey, their_diddoc) =
gen_mediator_connected_agent().await?;
// prepare request message
let message = MediatorCoordMsgEnum::MediateRequest;
Expand All @@ -130,7 +130,7 @@ async fn test_mediate_grant() -> Result<()> {
&message_bytes,
&agent,
&mut aries_transport,
&our_verikey,
&our_verkey,
&their_diddoc,
)
.await?;
Expand All @@ -157,7 +157,7 @@ async fn test_mediate_grant() -> Result<()> {
async fn test_mediate_keylist_update_add() -> Result<()> {
TestSetupAries.init();
// prepare connection parameters
let (agent, mut aries_transport, our_verikey, their_diddoc) =
let (agent, mut aries_transport, our_verkey, their_diddoc) =
gen_mediator_connected_agent().await?;
// prepare request message
let (_, new_vk) = agent
Expand All @@ -178,7 +178,7 @@ async fn test_mediate_keylist_update_add() -> Result<()> {
&message_bytes,
&agent,
&mut aries_transport,
&our_verikey,
&our_verkey,
&their_diddoc,
)
.await?;
Expand All @@ -201,7 +201,7 @@ async fn test_mediate_keylist_update_add() -> Result<()> {
async fn test_mediate_keylist_query() -> Result<()> {
TestSetupAries.init();
// prepare connection parameters
let (agent, mut aries_transport, our_verikey, their_diddoc) =
let (agent, mut aries_transport, our_verkey, their_diddoc) =
gen_mediator_connected_agent().await?;
// prepare request message: add key
let (_, new_vk) = agent
Expand All @@ -221,7 +221,7 @@ async fn test_mediate_keylist_query() -> Result<()> {
&message_bytes,
&agent,
&mut aries_transport,
&our_verikey,
&our_verkey,
&their_diddoc,
)
.await?;
Expand All @@ -235,7 +235,7 @@ async fn test_mediate_keylist_query() -> Result<()> {
&message_bytes,
&agent,
&mut aries_transport,
&our_verikey,
&our_verkey,
&their_diddoc,
)
.await?;
Expand All @@ -258,7 +258,7 @@ async fn test_mediate_keylist_query() -> Result<()> {
async fn test_mediate_keylist_update_remove() -> Result<()> {
TestSetupAries.init();
// prepare connection parameters
let (agent, mut aries_transport, our_verikey, their_diddoc) =
let (agent, mut aries_transport, our_verkey, their_diddoc) =
gen_mediator_connected_agent().await?;
// prepare request message: add key
let (_, new_vk) = agent
Expand All @@ -278,7 +278,7 @@ async fn test_mediate_keylist_update_remove() -> Result<()> {
&message_bytes,
&agent,
&mut aries_transport,
&our_verikey,
&our_verkey,
&their_diddoc,
)
.await?;
Expand All @@ -298,7 +298,7 @@ async fn test_mediate_keylist_update_remove() -> Result<()> {
&message_bytes,
&agent,
&mut aries_transport,
&our_verikey,
&our_verkey,
&their_diddoc,
)
.await?;
Expand Down
12 changes: 6 additions & 6 deletions agents/rust/mediator/tests/mediator-routing-forward.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ use mediator::{
utils::oob2did,
Agent,
},
utils::{structs::VeriKey, GenericStringError},
utils::{structs::VerKey, GenericStringError},
};
use messages::msg_fields::protocols::{
basic_message::{BasicMessage, BasicMessageContent, BasicMessageDecorators},
Expand Down Expand Up @@ -50,7 +50,7 @@ impl OneTimeInit for TestSetupAries {
async fn get_mediator_grant_data(
agent: &Agent<impl BaseWallet + 'static, impl MediatorPersistence>,
agent_aries_transport: &mut impl AriesTransport,
agent_verikey: &VeriKey,
agent_verkey: &VerKey,
mediator_diddoc: &AriesDidDoc,
) -> MediateGrantData {
// prepare request message
Expand All @@ -61,7 +61,7 @@ async fn get_mediator_grant_data(
&message_bytes,
agent,
agent_aries_transport,
agent_verikey,
agent_verkey,
mediator_diddoc,
)
.await
Expand All @@ -85,13 +85,13 @@ async fn get_mediator_grant_data(
async fn test_forward_flow() -> Result<()> {
TestSetupAries.init();
// prepare receiver connection parameters
let (mut agent, mut agent_aries_transport, agent_verikey, mediator_diddoc) =
let (mut agent, mut agent_aries_transport, agent_verkey, mediator_diddoc) =
gen_mediator_connected_agent().await?;
// setup receiver routing
let grant_data = get_mediator_grant_data(
&agent,
&mut agent_aries_transport,
&agent_verikey,
&agent_verkey,
&mediator_diddoc,
)
.await;
Expand Down Expand Up @@ -122,7 +122,7 @@ async fn test_forward_flow() -> Result<()> {
&message_bytes,
&agent,
&mut agent_aries_transport,
&agent_verikey,
&agent_verkey,
&mediator_diddoc,
)
.await?;
Expand Down

0 comments on commit 3ca303a

Please sign in to comment.