-
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.
Sign response attachment and other updates
Signed-off-by: Miroslav Kovar <miroslav.kovar@absa.africa>
- Loading branch information
Showing
14 changed files
with
71 additions
and
75 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
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 |
---|---|---|
@@ -1,3 +1,42 @@ | ||
use std::sync::Arc; | ||
|
||
use did_doc_sov::extra_fields::KeyKind; | ||
use did_resolver::traits::resolvable::resolution_output::DidResolutionOutput; | ||
use did_resolver_registry::ResolverRegistry; | ||
use messages::msg_fields::protocols::out_of_band::invitation::{Invitation as OobInvitation, OobService}; | ||
use public_key::{Key, KeyType}; | ||
|
||
use crate::errors::error::{AriesVcxError, AriesVcxErrorKind}; | ||
|
||
pub mod state_machine; | ||
pub mod states; | ||
pub mod transition; | ||
|
||
pub async fn resolve_key_from_invitation( | ||
invitation: &OobInvitation, | ||
resolver_registry: &Arc<ResolverRegistry>, | ||
) -> Result<Key, AriesVcxError> { | ||
match invitation.content.services.get(0).unwrap() { | ||
OobService::SovService(service) => match service.extra().first_recipient_key()? { | ||
KeyKind::DidKey(did_key) => Ok(did_key.key().to_owned()), | ||
KeyKind::Value(value) => Ok(Key::from_base58(value, KeyType::Ed25519)?), | ||
KeyKind::Reference(reference) => Err(AriesVcxError::from_msg( | ||
AriesVcxErrorKind::InvalidInput, | ||
format!("Cannot resolve the reference {reference} without a did document"), | ||
)), | ||
}, | ||
OobService::Did(did) => { | ||
let DidResolutionOutput { did_document, .. } = resolver_registry | ||
.resolve(&did.clone().try_into()?, &Default::default()) | ||
.await | ||
.map_err(|err| { | ||
AriesVcxError::from_msg(AriesVcxErrorKind::InvalidDid, format!("DID resolution failed: {err}")) | ||
})?; | ||
Ok(did_document.verification_method().first().unwrap().public_key()?) | ||
} | ||
OobService::AriesService(service) => Ok(Key::from_base58( | ||
service.recipient_keys.first().unwrap(), | ||
KeyType::Ed25519, | ||
)?), | ||
} | ||
} |
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
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