-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Restore did-exchange * Address code review
- Loading branch information
1 parent
dcd987c
commit 23e2b0f
Showing
71 changed files
with
1,232 additions
and
1,177 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
use aries_vcx::{ | ||
did_doc_sov::{service::ServiceSov, DidDocumentSov}, | ||
messages::AriesMessage, | ||
utils::{encryption_envelope::EncryptionEnvelope, from_did_doc_sov_to_legacy}, | ||
}; | ||
use aries_vcx_core::wallet::base_wallet::BaseWallet; | ||
use serde_json::json; | ||
use url::Url; | ||
|
||
use crate::{AgentError, AgentErrorKind, AgentResult}; | ||
|
||
pub fn get_their_endpoint(did_document: &DidDocumentSov) -> AgentResult<Url> { | ||
let service = did_document.service().first().ok_or(AgentError::from_msg( | ||
AgentErrorKind::InvalidState, | ||
"No service found", | ||
))?; | ||
// todo: will get cleaned up after service is de-generified | ||
let url: String = match service { | ||
ServiceSov::Legacy(d) => d.service_endpoint().to_string(), | ||
ServiceSov::AIP1(d) => d.service_endpoint().to_string(), | ||
ServiceSov::DIDCommV1(d) => d.service_endpoint().to_string(), | ||
ServiceSov::DIDCommV2(d) => d.service_endpoint().to_string(), | ||
}; | ||
Url::parse(&url).map_err(|err| { | ||
AgentError::from_msg( | ||
AgentErrorKind::InvalidState, | ||
&format!("Failed to parse url found in did document due: {:?}", err), | ||
) | ||
}) | ||
} | ||
|
||
pub async fn pairwise_encrypt( | ||
our_did_doc: &DidDocumentSov, | ||
their_did_doc: &DidDocumentSov, | ||
wallet: &impl BaseWallet, | ||
message: &AriesMessage, | ||
) -> AgentResult<EncryptionEnvelope> { | ||
let sender_verkey = our_did_doc | ||
.resolved_key_agreement() | ||
.next() | ||
.ok_or_else(|| { | ||
AgentError::from_msg( | ||
AgentErrorKind::InvalidState, | ||
"No key agreement method found in our did document", | ||
) | ||
})? | ||
.public_key()? | ||
.base58(); | ||
EncryptionEnvelope::create( | ||
wallet, | ||
json!(message).to_string().as_bytes(), | ||
Some(&sender_verkey), | ||
&from_did_doc_sov_to_legacy(their_did_doc.clone())?, | ||
) | ||
.await | ||
.map_err(|err| err.into()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,6 +9,7 @@ extern crate uuid; | |
|
||
mod agent; | ||
mod error; | ||
pub mod helper; | ||
mod http; | ||
mod services; | ||
mod storage; | ||
|
Oops, something went wrong.