repo
stringlengths
6
65
file_url
stringlengths
81
311
file_path
stringlengths
6
227
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 15:31:58
2026-01-04 20:25:31
truncated
bool
2 classes
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_types/protocols/trust_ping.rs
aries/messages/src/msg_types/protocols/trust_ping.rs
use derive_more::From; use messages_macros::MessageType; use strum_macros::{AsRefStr, EnumString}; use transitive::Transitive; use super::Protocol; use crate::msg_types::{role::Role, MsgKindType}; #[derive(Copy, Clone, Debug, From, PartialEq, MessageType)] #[msg_type(protocol = "trust_ping")] pub enum TrustPingType { V1(TrustPingTypeV1), } #[derive(Copy, Clone, Debug, From, PartialEq, Transitive, MessageType)] #[transitive(into(TrustPingType, Protocol))] #[msg_type(major = 1)] pub enum TrustPingTypeV1 { #[msg_type(minor = 0, roles = "Role::Sender, Role::Receiver")] V1_0(MsgKindType<TrustPingTypeV1_0>), } #[derive(Copy, Clone, Debug, AsRefStr, EnumString, PartialEq)] #[strum(serialize_all = "kebab-case")] pub enum TrustPingTypeV1_0 { Ping, #[strum(serialize = "ping_response")] PingResponse, } #[cfg(test)] mod tests { use serde_json::json; use super::*; use crate::misc::test_utils; #[test] fn test_protocol_trust_ping() { test_utils::test_serde( Protocol::from(TrustPingTypeV1::new_v1_0()), json!("https://didcomm.org/trust_ping/1.0"), ) } #[test] fn test_version_resolution_trust_ping() { test_utils::test_msg_type_resolution( "https://didcomm.org/trust_ping/1.255", TrustPingTypeV1::new_v1_0(), ) } #[test] #[should_panic] fn test_unsupported_version_trust_ping() { test_utils::test_serde( Protocol::from(TrustPingTypeV1::new_v1_0()), json!("https://didcomm.org/trust_ping/2.0"), ) } #[test] fn test_msg_type_ping() { test_utils::test_msg_type( "https://didcomm.org/trust_ping/1.0", "ping", TrustPingTypeV1::new_v1_0(), ) } #[test] fn test_msg_type_ping_response() { test_utils::test_msg_type( "https://didcomm.org/trust_ping/1.0", "ping_response", TrustPingTypeV1::new_v1_0(), ) } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_types/protocols/discover_features.rs
aries/messages/src/msg_types/protocols/discover_features.rs
use derive_more::From; use messages_macros::MessageType; use strum_macros::{AsRefStr, EnumString}; use transitive::Transitive; use super::Protocol; use crate::msg_types::{role::Role, MsgKindType}; #[derive(Copy, Clone, Debug, From, PartialEq, MessageType)] #[msg_type(protocol = "discover-features")] pub enum DiscoverFeaturesType { V1(DiscoverFeaturesTypeV1), } #[derive(Copy, Clone, Debug, From, PartialEq, Transitive, MessageType)] #[transitive(into(DiscoverFeaturesType, Protocol))] #[msg_type(major = 1)] pub enum DiscoverFeaturesTypeV1 { #[msg_type(minor = 0, roles = "Role::Requester, Role::Responder")] V1_0(MsgKindType<DiscoverFeaturesTypeV1_0>), } #[derive(Copy, Clone, Debug, AsRefStr, EnumString, PartialEq)] #[strum(serialize_all = "kebab-case")] pub enum DiscoverFeaturesTypeV1_0 { Query, Disclose, } #[cfg(test)] mod tests { use serde_json::json; use super::*; use crate::misc::test_utils; #[test] fn test_protocol_discover_features() { test_utils::test_serde( Protocol::from(DiscoverFeaturesTypeV1::new_v1_0()), json!("https://didcomm.org/discover-features/1.0"), ) } #[test] fn test_version_resolution_discover_features() { test_utils::test_msg_type_resolution( "https://didcomm.org/discover-features/1.255", DiscoverFeaturesTypeV1::new_v1_0(), ) } #[test] #[should_panic] fn test_unsupported_version_discover_features() { test_utils::test_serde( Protocol::from(DiscoverFeaturesTypeV1::new_v1_0()), json!("https://didcomm.org/discover-features/2.0"), ) } #[test] fn test_msg_type_query() { test_utils::test_msg_type( "https://didcomm.org/discover-features/1.0", "query", DiscoverFeaturesTypeV1::new_v1_0(), ) } #[test] fn test_msg_type_disclose() { test_utils::test_msg_type( "https://didcomm.org/discover-features/1.0", "disclose", DiscoverFeaturesTypeV1::new_v1_0(), ) } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_types/protocols/out_of_band.rs
aries/messages/src/msg_types/protocols/out_of_band.rs
use derive_more::From; use messages_macros::MessageType; use strum_macros::{AsRefStr, EnumString}; use transitive::Transitive; use super::Protocol; use crate::msg_types::{role::Role, MsgKindType}; #[derive(Copy, Clone, Debug, From, PartialEq, MessageType)] #[msg_type(protocol = "out-of-band")] pub enum OutOfBandType { V1(OutOfBandTypeV1), } #[derive(Copy, Clone, Debug, From, PartialEq, Transitive, MessageType)] #[transitive(into(OutOfBandType, Protocol))] #[msg_type(major = 1)] pub enum OutOfBandTypeV1 { #[msg_type(minor = 1, roles = "Role::Receiver, Role::Sender")] V1_1(MsgKindType<OutOfBandTypeV1_1>), } #[derive(Copy, Clone, Debug, AsRefStr, EnumString, PartialEq)] #[strum(serialize_all = "kebab-case")] pub enum OutOfBandTypeV1_1 { Invitation, HandshakeReuse, HandshakeReuseAccepted, } #[cfg(test)] mod tests { use serde_json::json; use super::*; use crate::misc::test_utils; #[test] fn test_protocol_out_of_band() { test_utils::test_serde( Protocol::from(OutOfBandTypeV1::new_v1_1()), json!("https://didcomm.org/out-of-band/1.1"), ) } #[test] fn test_version_resolution_out_of_band() { test_utils::test_msg_type_resolution( "https://didcomm.org/out-of-band/1.255", OutOfBandTypeV1::new_v1_1(), ) } #[test] #[should_panic] fn test_unsupported_version_out_of_band() { test_utils::test_serde( Protocol::from(OutOfBandTypeV1::new_v1_1()), json!("https://didcomm.org/out-of-band/2.0"), ) } #[test] fn test_msg_type_invitation() { test_utils::test_msg_type( "https://didcomm.org/out-of-band/1.1", "invitation", OutOfBandTypeV1::new_v1_1(), ) } #[test] fn test_msg_type_reuse() { test_utils::test_msg_type( "https://didcomm.org/out-of-band/1.1", "handshake-reuse", OutOfBandTypeV1::new_v1_1(), ) } #[test] fn test_msg_type_reuse_acc() { test_utils::test_msg_type( "https://didcomm.org/out-of-band/1.1", "handshake-reuse-accepted", OutOfBandTypeV1::new_v1_1(), ) } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_types/protocols/pickup.rs
aries/messages/src/msg_types/protocols/pickup.rs
use derive_more::{From, TryInto}; use messages_macros::MessageType; use strum_macros::{AsRefStr, EnumString}; use transitive::Transitive; use super::Protocol; use crate::msg_types::{MsgKindType, Role}; #[derive(Copy, Clone, Debug, From, TryInto, PartialEq, MessageType)] #[msg_type(protocol = "messagepickup")] pub enum PickupType { V2(PickupTypeV2), } #[derive(Copy, Clone, Debug, From, TryInto, PartialEq, Transitive, MessageType)] #[transitive(into(PickupType, Protocol))] #[msg_type(major = 2)] pub enum PickupTypeV2 { #[msg_type(minor = 0, roles = "Role::Mediator, Role::Recipient")] V2_0(MsgKindType<PickupTypeV2_0>), } #[derive(Copy, Clone, Debug, AsRefStr, EnumString, PartialEq)] #[strum(serialize_all = "kebab-case")] pub enum PickupTypeV2_0 { Status, StatusRequest, DeliveryRequest, Delivery, MessagesReceived, LiveDeliveryChange, }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_types/protocols/did_exchange.rs
aries/messages/src/msg_types/protocols/did_exchange.rs
use derive_more::From; use messages_macros::MessageType; use strum_macros::{AsRefStr, EnumString}; use transitive::Transitive; use super::Protocol; use crate::msg_types::{role::Role, MsgKindType}; #[derive(Copy, Clone, Debug, From, PartialEq, MessageType)] #[msg_type(protocol = "didexchange")] pub enum DidExchangeType { V1(DidExchangeTypeV1), } #[derive(Copy, Clone, Debug, From, PartialEq, Transitive, MessageType)] #[transitive(into(DidExchangeType, Protocol))] #[msg_type(major = 1)] pub enum DidExchangeTypeV1 { #[msg_type(minor = 1, roles = "Role::Requester, Role::Responder")] V1_1(MsgKindType<DidExchangeTypeV1_1>), #[msg_type(minor = 0, roles = "Role::Requester, Role::Responder")] V1_0(MsgKindType<DidExchangeTypeV1_0>), } #[derive(Copy, Clone, Debug, AsRefStr, EnumString, PartialEq)] #[strum(serialize_all = "snake_case")] pub enum DidExchangeTypeV1_0 { Request, Response, ProblemReport, Complete, } #[derive(Copy, Clone, Debug, AsRefStr, EnumString, PartialEq)] #[strum(serialize_all = "snake_case")] pub enum DidExchangeTypeV1_1 { Request, Response, ProblemReport, Complete, } impl Default for DidExchangeTypeV1 { fn default() -> Self { Self::new_v1_1() } } #[cfg(test)] mod tests { use serde_json::json; use super::*; use crate::misc::test_utils; #[test] fn test_protocol_didexchange_v1_0() { test_utils::test_serde( Protocol::from(DidExchangeTypeV1::new_v1_0()), json!("https://didcomm.org/didexchange/1.0"), ) } #[test] fn test_protocol_didexchange_v1_1() { test_utils::test_serde( Protocol::from(DidExchangeTypeV1::new_v1_1()), json!("https://didcomm.org/didexchange/1.1"), ) } #[test] fn test_version_resolution_didexchange() { test_utils::test_msg_type_resolution( "https://didcomm.org/didexchange/1.255", DidExchangeTypeV1::new_v1_1(), ) } #[test] #[should_panic] fn test_unsupported_version_didexchange() { test_utils::test_serde( Protocol::from(DidExchangeTypeV1::new_v1_0()), json!("https://didcomm.org/didexchange/2.0"), ) } #[test] fn test_msg_type_request_v1_0() { test_utils::test_msg_type( "https://didcomm.org/didexchange/1.0", "request", DidExchangeTypeV1::new_v1_0(), ) } #[test] fn test_msg_type_response_v1_0() { test_utils::test_msg_type( "https://didcomm.org/didexchange/1.0", "response", DidExchangeTypeV1::new_v1_0(), ) } #[test] fn test_msg_type_complete_v1_0() { test_utils::test_msg_type( "https://didcomm.org/didexchange/1.0", "complete", DidExchangeTypeV1::new_v1_0(), ) } #[test] fn test_msg_type_problem_v1_0() { test_utils::test_msg_type( "https://didcomm.org/didexchange/1.0", "problem_report", DidExchangeTypeV1::new_v1_0(), ) } #[test] fn test_msg_type_request_v1_1() { test_utils::test_msg_type( "https://didcomm.org/didexchange/1.1", "request", DidExchangeTypeV1::new_v1_1(), ) } #[test] fn test_msg_type_response_v1_1() { test_utils::test_msg_type( "https://didcomm.org/didexchange/1.1", "response", DidExchangeTypeV1::new_v1_1(), ) } #[test] fn test_msg_type_complete_v1_1() { test_utils::test_msg_type( "https://didcomm.org/didexchange/1.1", "complete", DidExchangeTypeV1::new_v1_1(), ) } #[test] fn test_msg_type_problem_v1_1() { test_utils::test_msg_type( "https://didcomm.org/didexchange/1.1", "problem_report", DidExchangeTypeV1::new_v1_1(), ) } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_types/protocols/cred_issuance.rs
aries/messages/src/msg_types/protocols/cred_issuance.rs
use derive_more::{From, TryInto}; use messages_macros::MessageType; use strum_macros::{AsRefStr, EnumString}; use transitive::Transitive; use super::Protocol; use crate::msg_types::{role::Role, MsgKindType}; #[derive(Copy, Clone, Debug, From, TryInto, PartialEq, MessageType)] #[msg_type(protocol = "issue-credential")] pub enum CredentialIssuanceType { V1(CredentialIssuanceTypeV1), V2(CredentialIssuanceTypeV2), } #[derive(Copy, Clone, Debug, From, TryInto, PartialEq, Transitive, MessageType)] #[transitive(into(CredentialIssuanceType, Protocol))] #[msg_type(major = 1)] pub enum CredentialIssuanceTypeV1 { #[msg_type(minor = 0, roles = "Role::Holder, Role::Issuer")] V1_0(MsgKindType<CredentialIssuanceTypeV1_0>), } #[derive(Copy, Clone, Debug, From, TryInto, PartialEq, Transitive, MessageType)] #[transitive(into(CredentialIssuanceType, Protocol))] #[msg_type(major = 2)] pub enum CredentialIssuanceTypeV2 { #[msg_type(minor = 0, roles = "Role::Holder, Role::Issuer")] V2_0(MsgKindType<CredentialIssuanceTypeV2_0>), } #[derive(Copy, Clone, Debug, AsRefStr, EnumString, PartialEq)] #[strum(serialize_all = "kebab-case")] pub enum CredentialIssuanceTypeV1_0 { OfferCredential, ProposeCredential, RequestCredential, IssueCredential, CredentialPreview, Ack, ProblemReport, } #[derive(Copy, Clone, Debug, AsRefStr, EnumString, PartialEq)] #[strum(serialize_all = "kebab-case")] pub enum CredentialIssuanceTypeV2_0 { OfferCredential, ProposeCredential, RequestCredential, IssueCredential, CredentialPreview, Ack, ProblemReport, } #[cfg(test)] mod tests { use serde_json::json; use super::*; use crate::misc::test_utils; #[test] fn test_protocol_issue_credential_v1() { test_utils::test_serde( Protocol::from(CredentialIssuanceTypeV1::new_v1_0()), json!("https://didcomm.org/issue-credential/1.0"), ) } #[test] fn test_version_resolution_issue_credential_v1() { test_utils::test_msg_type_resolution( "https://didcomm.org/issue-credential/1.255", CredentialIssuanceTypeV1::new_v1_0(), ) } #[test] #[should_panic] fn test_unsupported_version_issue_credential_v1() { test_utils::test_serde( Protocol::from(CredentialIssuanceTypeV1::new_v1_0()), json!("https://didcomm.org/issue-credential/2.0"), ) } #[test] fn test_msg_type_offer_v1() { test_utils::test_msg_type( "https://didcomm.org/issue-credential/1.0", "offer-credential", CredentialIssuanceTypeV1::new_v1_0(), ) } #[test] fn test_msg_type_propose_v1() { test_utils::test_msg_type( "https://didcomm.org/issue-credential/1.0", "propose-credential", CredentialIssuanceTypeV1::new_v1_0(), ) } #[test] fn test_msg_type_request_v1() { test_utils::test_msg_type( "https://didcomm.org/issue-credential/1.0", "request-credential", CredentialIssuanceTypeV1::new_v1_0(), ) } #[test] fn test_msg_type_issue_v1() { test_utils::test_msg_type( "https://didcomm.org/issue-credential/1.0", "issue-credential", CredentialIssuanceTypeV1::new_v1_0(), ) } #[test] fn test_msg_type_preview_v1() { test_utils::test_msg_type( "https://didcomm.org/issue-credential/1.0", "credential-preview", CredentialIssuanceTypeV1::new_v1_0(), ) } #[test] fn test_msg_type_ack_v1() { test_utils::test_msg_type( "https://didcomm.org/issue-credential/1.0", "ack", CredentialIssuanceTypeV1::new_v1_0(), ) } #[test] fn test_protocol_issue_credential_v2() { test_utils::test_serde( Protocol::from(CredentialIssuanceTypeV2::new_v2_0()), json!("https://didcomm.org/issue-credential/2.0"), ) } #[test] fn test_version_resolution_issue_credential_v2() { test_utils::test_msg_type_resolution( "https://didcomm.org/issue-credential/2.255", CredentialIssuanceTypeV2::new_v2_0(), ) } #[test] #[should_panic] fn test_unsupported_version_issue_credential_v2() { test_utils::test_serde( Protocol::from(CredentialIssuanceTypeV2::new_v2_0()), json!("https://didcomm.org/issue-credential/1.0"), ) } #[test] fn test_msg_type_offer_v2() { test_utils::test_msg_type( "https://didcomm.org/issue-credential/2.0", "offer-credential", CredentialIssuanceTypeV2::new_v2_0(), ) } #[test] fn test_msg_type_propose_v2() { test_utils::test_msg_type( "https://didcomm.org/issue-credential/2.0", "propose-credential", CredentialIssuanceTypeV2::new_v2_0(), ) } #[test] fn test_msg_type_request_v2() { test_utils::test_msg_type( "https://didcomm.org/issue-credential/2.0", "request-credential", CredentialIssuanceTypeV2::new_v2_0(), ) } #[test] fn test_msg_type_issue_v2() { test_utils::test_msg_type( "https://didcomm.org/issue-credential/2.0", "issue-credential", CredentialIssuanceTypeV2::new_v2_0(), ) } #[test] fn test_msg_type_preview_v2() { test_utils::test_msg_type( "https://didcomm.org/issue-credential/2.0", "credential-preview", CredentialIssuanceTypeV2::new_v2_0(), ) } #[test] fn test_msg_type_ack_v2() { test_utils::test_msg_type( "https://didcomm.org/issue-credential/2.0", "ack", CredentialIssuanceTypeV2::new_v2_0(), ) } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_types/protocols/mod.rs
aries/messages/src/msg_types/protocols/mod.rs
use std::{fmt::Display, str::FromStr}; use derive_more::{From, TryInto}; use serde::{Deserialize, Serialize}; use shared::misc::utils::CowStr; use self::{ basic_message::BasicMessageType, connection::ConnectionType, coordinate_mediation::CoordinateMediationType, cred_issuance::CredentialIssuanceType, did_exchange::DidExchangeType, discover_features::DiscoverFeaturesType, notification::NotificationType, out_of_band::OutOfBandType, pickup::PickupType, present_proof::PresentProofType, report_problem::ReportProblemType, revocation::RevocationType, routing::RoutingType, signature::SignatureType, trust_ping::TrustPingType, }; use crate::{ error::{MsgTypeError, MsgTypeResult}, msg_types::traits::ProtocolName, }; pub mod basic_message; pub mod connection; pub mod coordinate_mediation; pub mod cred_issuance; pub mod did_exchange; pub mod discover_features; pub mod notification; pub mod out_of_band; pub mod pickup; pub mod present_proof; pub mod report_problem; pub mod revocation; pub mod routing; pub mod signature; pub mod trust_ping; /// Type representing all protocols that are currently supported. /// /// They are composed from protocol names, protocol major versions and protocol minor versions. /// The protocol message kind types, while linked to their respective protocol minor versions, /// are treated adjacently to this enum. /// /// This way, this type can be used for all of the following: /// - protocol registry /// - message type deserialization /// - discover features protocol /// /// The way a message kind (e.g: `request`) is bound to a [`Protocol`] (e.g: `https://didcomm.org/connections/1.0`) /// is through our internal [`messages_macros::MessageType`] proc_macro. See the docs for that for /// more info. #[derive(Clone, Copy, Debug, From, TryInto, PartialEq, Deserialize)] #[serde(try_from = "CowStr")] pub enum Protocol { RoutingType(RoutingType), ConnectionType(ConnectionType), SignatureType(SignatureType), RevocationType(RevocationType), CredentialIssuanceType(CredentialIssuanceType), ReportProblemType(ReportProblemType), PresentProofType(PresentProofType), TrustPingType(TrustPingType), DiscoverFeaturesType(DiscoverFeaturesType), BasicMessageType(BasicMessageType), OutOfBandType(OutOfBandType), NotificationType(NotificationType), PickupType(PickupType), CoordinateMediationType(CoordinateMediationType), DidExchangeType(DidExchangeType), } /// Utility macro to avoid harder to read and error prone calling /// of the version resolution method on the correct type. macro_rules! match_protocol { ($type:ident, $protocol:expr, $major:expr, $minor:expr) => { if $protocol == $type::PROTOCOL { return Ok(Self::$type($type::try_from_version_parts($major, $minor)?)); } }; } impl Protocol { pub const DID_COM_ORG_PREFIX: &'static str = "https://didcomm.org"; pub const DID_SOV_PREFIX: &'static str = "did:sov:BzCbsNYhMrjHiqZDTUASHg;spec"; /// Tried to construct a [`Protocol`] from parts. /// /// # Errors: /// /// An error is returned if a [`Protocol`] could not be constructed /// from the provided parts. pub fn from_parts(protocol: &str, major: u8, minor: u8) -> MsgTypeResult<Self> { match_protocol!(RoutingType, protocol, major, minor); match_protocol!(ConnectionType, protocol, major, minor); match_protocol!(SignatureType, protocol, major, minor); match_protocol!(RevocationType, protocol, major, minor); match_protocol!(CredentialIssuanceType, protocol, major, minor); match_protocol!(ReportProblemType, protocol, major, minor); match_protocol!(PresentProofType, protocol, major, minor); match_protocol!(TrustPingType, protocol, major, minor); match_protocol!(DiscoverFeaturesType, protocol, major, minor); match_protocol!(BasicMessageType, protocol, major, minor); match_protocol!(OutOfBandType, protocol, major, minor); match_protocol!(NotificationType, protocol, major, minor); match_protocol!(PickupType, protocol, major, minor); match_protocol!(CoordinateMediationType, protocol, major, minor); match_protocol!(DidExchangeType, protocol, major, minor); Err(MsgTypeError::unknown_protocol(protocol.to_owned())) } /// Returns the parts that this [`Protocol`] is comprised of. pub fn as_parts(&self) -> (&'static str, u8, u8) { match &self { Self::RoutingType(v) => v.as_protocol_parts(), Self::ConnectionType(v) => v.as_protocol_parts(), Self::SignatureType(v) => v.as_protocol_parts(), Self::RevocationType(v) => v.as_protocol_parts(), Self::CredentialIssuanceType(v) => v.as_protocol_parts(), Self::ReportProblemType(v) => v.as_protocol_parts(), Self::PresentProofType(v) => v.as_protocol_parts(), Self::TrustPingType(v) => v.as_protocol_parts(), Self::DiscoverFeaturesType(v) => v.as_protocol_parts(), Self::BasicMessageType(v) => v.as_protocol_parts(), Self::OutOfBandType(v) => v.as_protocol_parts(), Self::NotificationType(v) => v.as_protocol_parts(), Self::PickupType(v) => v.as_protocol_parts(), Self::CoordinateMediationType(v) => v.as_protocol_parts(), Self::DidExchangeType(v) => v.as_protocol_parts(), } } /// Steps the provided iterator of parts and returns the string slice element. /// /// # Errors: /// /// Will return an error if the iterator returns [`None`]. pub(crate) fn next_part<'a, I>(iter: &mut I, name: &'static str) -> MsgTypeResult<&'a str> where I: Iterator<Item = &'a str>, { iter.next().ok_or_else(|| MsgTypeError::not_found(name)) } } impl Display for Protocol { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { let prefix = Self::DID_COM_ORG_PREFIX; let (protocol, major, minor) = self.as_parts(); write!(f, "{prefix}/{protocol}/{major}.{minor}") } } impl FromStr for Protocol { type Err = MsgTypeError; fn from_str(s: &str) -> Result<Self, Self::Err> { // The type is segmented by forward slashes, but the HTTPS // prefix includes two as well (https://), so we'll accommodate that // when we skip elements from the split string. // // We always skip at least one element, the prefix itself. let skip_slash = match s { _ if s.starts_with(Self::DID_COM_ORG_PREFIX) => 3, _ if s.starts_with(Self::DID_SOV_PREFIX) => 1, _ => return Err(MsgTypeError::unknown_prefix(s.to_owned())), }; // We'll get the next components in order let mut iter = s.split('/').skip(skip_slash); let protocol_name = Protocol::next_part(&mut iter, "protocol name")?; let version = Protocol::next_part(&mut iter, "protocol version")?; // We'll parse the version to its major and minor parts let mut version_iter = version.split('.'); let major = Protocol::next_part(&mut version_iter, "protocol major version")?.parse()?; let minor = Protocol::next_part(&mut version_iter, "protocol minor version")?.parse()?; Protocol::from_parts(protocol_name, major, minor) } } impl<'a> TryFrom<CowStr<'a>> for Protocol { type Error = MsgTypeError; fn try_from(value: CowStr<'a>) -> Result<Self, Self::Error> { let value = value.0.as_ref(); Self::from_str(value) } } impl Serialize for Protocol { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, { let prefix = Self::DID_COM_ORG_PREFIX; let (protocol, major, minor) = self.as_parts(); format_args!("{prefix}/{protocol}/{major}.{minor}").serialize(serializer) } } #[cfg(test)] mod tests { use serde_json::json; use super::*; #[test] fn test_old_prefix() { let value_old = json!("did:sov:BzCbsNYhMrjHiqZDTUASHg;spec/connections/1.0"); let value_new = json!("https://didcomm.org/connections/1.0"); let protocol_old = Protocol::deserialize(&value_old).unwrap(); let protocol_new = Protocol::deserialize(&value_new).unwrap(); assert_eq!(protocol_old, protocol_new); } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_types/protocols/present_proof.rs
aries/messages/src/msg_types/protocols/present_proof.rs
use derive_more::{From, TryInto}; use messages_macros::MessageType; use strum_macros::{AsRefStr, EnumString}; use transitive::Transitive; use super::Protocol; use crate::msg_types::{role::Role, MsgKindType}; #[derive(Copy, Clone, Debug, From, TryInto, PartialEq, MessageType)] #[msg_type(protocol = "present-proof")] pub enum PresentProofType { V1(PresentProofTypeV1), V2(PresentProofTypeV2), } #[derive(Copy, Clone, Debug, From, TryInto, PartialEq, Transitive, MessageType)] #[transitive(into(PresentProofType, Protocol))] #[msg_type(major = 1)] pub enum PresentProofTypeV1 { #[msg_type(minor = 0, roles = "Role::Prover, Role::Verifier")] V1_0(MsgKindType<PresentProofTypeV1_0>), } #[derive(Copy, Clone, Debug, From, TryInto, PartialEq, Transitive, MessageType)] #[transitive(into(PresentProofType, Protocol))] #[msg_type(major = 2)] pub enum PresentProofTypeV2 { #[msg_type(minor = 0, roles = "Role::Prover, Role::Verifier")] V2_0(MsgKindType<PresentProofTypeV2_0>), } #[derive(Copy, Clone, Debug, AsRefStr, EnumString, PartialEq)] #[strum(serialize_all = "kebab-case")] pub enum PresentProofTypeV1_0 { ProposePresentation, RequestPresentation, Presentation, PresentationPreview, Ack, ProblemReport, } #[derive(Copy, Clone, Debug, AsRefStr, EnumString, PartialEq)] #[strum(serialize_all = "kebab-case")] pub enum PresentProofTypeV2_0 { ProposePresentation, RequestPresentation, Presentation, PresentationPreview, Ack, ProblemReport, } #[cfg(test)] mod tests { use serde_json::json; use super::*; use crate::misc::test_utils; #[test] fn test_protocol_present_proof_v1() { test_utils::test_serde( Protocol::from(PresentProofTypeV1::new_v1_0()), json!("https://didcomm.org/present-proof/1.0"), ) } #[test] fn test_version_resolution_present_proof_v1() { test_utils::test_msg_type_resolution( "https://didcomm.org/present-proof/1.255", PresentProofTypeV1::new_v1_0(), ) } #[test] #[should_panic] fn test_unsupported_version_present_proof_v1() { test_utils::test_serde( Protocol::from(PresentProofTypeV1::new_v1_0()), json!("https://didcomm.org/present-proof/2.0"), ) } #[test] fn test_msg_type_propose_v1() { test_utils::test_msg_type( "https://didcomm.org/present-proof/1.0", "propose-presentation", PresentProofTypeV1::new_v1_0(), ) } #[test] fn test_msg_type_request_v1() { test_utils::test_msg_type( "https://didcomm.org/present-proof/1.0", "request-presentation", PresentProofTypeV1::new_v1_0(), ) } #[test] fn test_msg_type_presentation_v1() { test_utils::test_msg_type( "https://didcomm.org/present-proof/1.0", "presentation", PresentProofTypeV1::new_v1_0(), ) } #[test] fn test_msg_type_preview_v1() { test_utils::test_msg_type( "https://didcomm.org/present-proof/1.0", "presentation-preview", PresentProofTypeV1::new_v1_0(), ) } #[test] fn test_msg_type_ack_v1() { test_utils::test_msg_type( "https://didcomm.org/present-proof/1.0", "ack", PresentProofTypeV1::new_v1_0(), ) } #[test] fn test_protocol_present_proof_v2() { test_utils::test_serde( Protocol::from(PresentProofTypeV2::new_v2_0()), json!("https://didcomm.org/present-proof/2.0"), ) } #[test] fn test_version_resolution_present_proof_v2() { test_utils::test_msg_type_resolution( "https://didcomm.org/present-proof/2.255", PresentProofTypeV2::new_v2_0(), ) } #[test] #[should_panic] fn test_unsupported_version_present_proof_v2() { test_utils::test_serde( Protocol::from(PresentProofTypeV2::new_v2_0()), json!("https://didcomm.org/present-proof/1.0"), ) } #[test] fn test_msg_type_propose_v2() { test_utils::test_msg_type( "https://didcomm.org/present-proof/2.0", "propose-presentation", PresentProofTypeV2::new_v2_0(), ) } #[test] fn test_msg_type_request_v2() { test_utils::test_msg_type( "https://didcomm.org/present-proof/2.0", "request-presentation", PresentProofTypeV2::new_v2_0(), ) } #[test] fn test_msg_type_presentation_v2() { test_utils::test_msg_type( "https://didcomm.org/present-proof/2.0", "presentation", PresentProofTypeV2::new_v2_0(), ) } #[test] fn test_msg_type_preview_v2() { test_utils::test_msg_type( "https://didcomm.org/present-proof/2.0", "presentation-preview", PresentProofTypeV2::new_v2_0(), ) } #[test] fn test_msg_type_ack_v2() { test_utils::test_msg_type( "https://didcomm.org/present-proof/2.0", "ack", PresentProofTypeV2::new_v2_0(), ) } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_types/protocols/report_problem.rs
aries/messages/src/msg_types/protocols/report_problem.rs
use derive_more::From; use messages_macros::MessageType; use strum_macros::{AsRefStr, EnumString}; use transitive::Transitive; use super::Protocol; use crate::msg_types::{role::Role, MsgKindType}; #[derive(Copy, Clone, Debug, From, PartialEq, MessageType)] #[msg_type(protocol = "report-problem")] pub enum ReportProblemType { V1(ReportProblemTypeV1), } #[derive(Copy, Clone, Debug, From, PartialEq, Transitive, MessageType)] #[transitive(into(ReportProblemType, Protocol))] #[msg_type(major = 1)] pub enum ReportProblemTypeV1 { #[msg_type(minor = 0, roles = "Role::Notified, Role::Notifier")] V1_0(MsgKindType<ReportProblemTypeV1_0>), } #[derive(Copy, Clone, Debug, AsRefStr, EnumString, PartialEq)] #[strum(serialize_all = "kebab-case")] pub enum ReportProblemTypeV1_0 { ProblemReport, } #[cfg(test)] mod tests { use serde_json::json; use super::*; use crate::misc::test_utils; #[test] fn test_protocol_report_problem() { test_utils::test_serde( Protocol::from(ReportProblemTypeV1::new_v1_0()), json!("https://didcomm.org/report-problem/1.0"), ) } #[test] fn test_version_resolution_report_problem() { test_utils::test_msg_type_resolution( "https://didcomm.org/report-problem/1.255", ReportProblemTypeV1::new_v1_0(), ) } #[test] #[should_panic] fn test_unsupported_version_report_problem() { test_utils::test_serde( Protocol::from(ReportProblemTypeV1::new_v1_0()), json!("https://didcomm.org/report-problem/2.0"), ) } #[test] fn test_msg_type_problem_report() { test_utils::test_msg_type( "https://didcomm.org/report-problem/1.0", "problem-report", ReportProblemTypeV1::new_v1_0(), ) } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_types/protocols/coordinate_mediation.rs
aries/messages/src/msg_types/protocols/coordinate_mediation.rs
use derive_more::{From, TryInto}; use messages_macros::MessageType; use strum_macros::{AsRefStr, EnumString}; use transitive::Transitive; use super::Protocol; use crate::msg_types::{MsgKindType, Role}; #[derive(Copy, Clone, Debug, From, TryInto, PartialEq, MessageType)] #[msg_type(protocol = "coordinate-mediation")] pub enum CoordinateMediationType { V1(CoordinateMediationTypeV1), } #[derive(Copy, Clone, Debug, From, TryInto, PartialEq, Transitive, MessageType)] #[transitive(into(CoordinateMediationType, Protocol))] #[msg_type(major = 1)] pub enum CoordinateMediationTypeV1 { #[msg_type(minor = 0, roles = "Role::Mediator, Role::Recipient")] V1_0(MsgKindType<CoordinateMediationTypeV1_0>), } #[derive(Copy, Clone, Debug, AsRefStr, EnumString, PartialEq)] #[strum(serialize_all = "kebab-case")] pub enum CoordinateMediationTypeV1_0 { MediateRequest, MediateDeny, MediateGrant, KeylistUpdate, KeylistUpdateResponse, KeylistQuery, Keylist, }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_types/protocols/revocation.rs
aries/messages/src/msg_types/protocols/revocation.rs
use derive_more::From; use messages_macros::MessageType; use strum_macros::{AsRefStr, EnumString}; use transitive::Transitive; use super::Protocol; use crate::msg_types::{role::Role, MsgKindType}; #[derive(Copy, Clone, Debug, From, PartialEq, MessageType)] #[msg_type(protocol = "revocation_notification")] pub enum RevocationType { V2(RevocationTypeV2), } #[derive(Copy, Clone, Debug, From, PartialEq, Transitive, MessageType)] #[transitive(into(RevocationType, Protocol))] #[msg_type(major = 2)] pub enum RevocationTypeV2 { #[msg_type(minor = 0, roles = "Role::Holder, Role::Issuer")] V2_0(MsgKindType<RevocationTypeV2_0>), } #[derive(Copy, Clone, Debug, AsRefStr, EnumString, PartialEq)] #[strum(serialize_all = "kebab-case")] pub enum RevocationTypeV2_0 { Revoke, Ack, } #[cfg(test)] mod tests { use serde_json::json; use super::*; use crate::misc::test_utils; #[test] fn test_protocol_revocation_notification() { test_utils::test_serde( Protocol::from(RevocationTypeV2::new_v2_0()), json!("https://didcomm.org/revocation_notification/2.0"), ) } #[test] fn test_version_resolution_revocation_notification() { test_utils::test_msg_type_resolution( "https://didcomm.org/revocation_notification/2.255", RevocationTypeV2::new_v2_0(), ) } #[test] #[should_panic] fn test_unsupported_version_revocation_notification() { test_utils::test_serde( Protocol::from(RevocationTypeV2::new_v2_0()), json!("https://didcomm.org/revocation_notification/3.0"), ) } #[test] fn test_msg_type_revoke() { test_utils::test_msg_type( "https://didcomm.org/revocation_notification/2.0", "revoke", RevocationTypeV2::new_v2_0(), ) } #[test] fn test_msg_type_ack() { test_utils::test_msg_type( "https://didcomm.org/revocation_notification/2.0", "ack", RevocationTypeV2::new_v2_0(), ) } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/mod.rs
aries/messages/src/msg_fields/mod.rs
//! Module containing the actual messages data structures, apart from the `@type` field which is //! handled through types in [`crate::msg_types`]. pub mod protocols; pub mod traits;
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/traits.rs
aries/messages/src/msg_fields/traits.rs
use serde::{Deserializer, Serializer}; /// Trait used for postponing serialization/deserialization of a message. /// /// It's main purpose is to allow us to navigate through the [`crate::msg_types::Protocol`] /// and message kind to deduce which type we must deserialize to /// or which [`crate::msg_types::Protocol`] + `message kind` we must construct /// for the `@type` field of a particular message. pub(crate) trait DelayedSerde: Sized { /// Long live GAT's! /// /// This allows us to pass a `&str` with /// a generic lifetime so that we can /// parse it later, when the message kind type /// can be determined. type MsgType<'a>; fn delayed_deserialize<'de, D>( msg_type: Self::MsgType<'de>, deserializer: D, ) -> Result<Self, D::Error> where D: Deserializer<'de>; fn delayed_serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: Serializer; }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/routing.rs
aries/messages/src/msg_fields/protocols/routing.rs
//! Module containing the `mediator and relays` messages, as defined in the [RFC](<https://github.com/decentralized-identity/aries-rfcs/blob/main/concepts/0046-mediators-and-relays/README.md>). use serde::{Deserialize, Serialize}; use serde_json::Value; use typed_builder::TypedBuilder; use crate::{ misc::utils::into_msg_with_type, msg_parts::MsgParts, msg_types::protocols::routing::RoutingTypeV1_0, }; pub type Forward = MsgParts<ForwardContent>; #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, TypedBuilder)] pub struct ForwardContent { pub to: String, pub msg: Value, } into_msg_with_type!(Forward, RoutingTypeV1_0, Forward); #[cfg(test)] mod tests { use serde_json::json; // Bind `shared::misc::serde_ignored::SerdeIgnored` type as `NoDecorators`. use shared::misc::serde_ignored::SerdeIgnored as NoDecorators; use super::*; use crate::misc::test_utils; #[test] fn test_minimal_forward() { let content = ForwardContent::builder() .to("test_to".to_owned()) .msg(json!("test_msg")) .build(); let expected = json! ({ "to": content.to, "msg": content.msg }); test_utils::test_msg(content, NoDecorators, RoutingTypeV1_0::Forward, expected); } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/basic_message.rs
aries/messages/src/msg_fields/protocols/basic_message.rs
//! Module containing the `basic message` protocol messages, as defined in the [RFC](<https://github.com/decentralized-identity/aries-rfcs/blob/main/features/0095-basic-message/README.md>). use chrono::{DateTime, Utc}; use serde::{Deserialize, Serialize}; use typed_builder::TypedBuilder; use crate::{ decorators::{localization::MsgLocalization, thread::Thread, timing::Timing}, misc::utils::{self, into_msg_with_type}, msg_parts::MsgParts, msg_types::protocols::basic_message::BasicMessageTypeV1_0, }; pub type BasicMessage = MsgParts<BasicMessageContent, BasicMessageDecorators>; #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, TypedBuilder)] pub struct BasicMessageContent { pub content: String, #[serde(serialize_with = "utils::serialize_datetime")] pub sent_time: DateTime<Utc>, } #[derive(Clone, Debug, Deserialize, Serialize, Default, PartialEq, TypedBuilder)] pub struct BasicMessageDecorators { #[builder(default, setter(strip_option))] #[serde(rename = "~l10n")] #[serde(skip_serializing_if = "Option::is_none")] pub l10n: Option<MsgLocalization>, #[builder(default, setter(strip_option))] #[serde(rename = "~thread")] #[serde(skip_serializing_if = "Option::is_none")] pub thread: Option<Thread>, #[builder(default, setter(strip_option))] #[serde(rename = "~timing")] #[serde(skip_serializing_if = "Option::is_none")] pub timing: Option<Timing>, } into_msg_with_type!(BasicMessage, BasicMessageTypeV1_0, Message); #[cfg(test)] #[allow(clippy::field_reassign_with_default)] mod tests { use serde_json::json; use super::*; use crate::{ decorators::thread::tests::make_extended_thread, misc::test_utils::{self, DateTimeRfc3339}, }; #[test] fn test_minimal_basic_message() { let content = BasicMessageContent::builder() .content("test_content".to_owned()) .sent_time(DateTime::default()) .build(); let decorators = BasicMessageDecorators::default(); let expected = json!({ "sent_time": DateTimeRfc3339(&content.sent_time), "content": content.content }); test_utils::test_msg(content, decorators, BasicMessageTypeV1_0::Message, expected); } #[test] fn test_extended_basic_message() { let content = BasicMessageContent::builder() .content("test_content".to_owned()) .sent_time(DateTime::default()) .build(); let decorators = BasicMessageDecorators::builder() .thread(make_extended_thread()) .build(); let expected = json!({ "sent_time": DateTimeRfc3339(&content.sent_time), "content": content.content, "~thread": decorators.thread }); test_utils::test_msg(content, decorators, BasicMessageTypeV1_0::Message, expected); } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/mod.rs
aries/messages/src/msg_fields/protocols/mod.rs
pub mod basic_message; pub mod common; pub mod connection; pub mod coordinate_mediation; pub mod cred_issuance; pub mod did_exchange; pub mod discover_features; pub mod notification; pub mod out_of_band; pub mod pickup; pub mod present_proof; pub mod report_problem; pub mod revocation; pub mod routing; pub mod trust_ping;
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/report_problem.rs
aries/messages/src/msg_fields/protocols/report_problem.rs
//! Module containing the `report problem` protocol messages, as defined in the [RFC](<https://github.com/decentralized-identity/aries-rfcs/blob/main/features/0035-report-problem/README.md>). use std::{collections::HashMap, fmt::Display}; use serde::{ de::Error as DeError, ser::{Error as SerError, SerializeMap}, Deserialize, Deserializer, Serialize, Serializer, }; use shared::misc::utils::CowStr; use strum_macros::{AsRefStr, EnumString}; use typed_builder::TypedBuilder; use url::Url; use crate::{ decorators::{ localization::{FieldLocalization, Locale}, thread::Thread, timing::Timing, }, misc::utils::into_msg_with_type, msg_parts::MsgParts, msg_types::protocols::report_problem::ReportProblemTypeV1_0, }; pub type ProblemReport = MsgParts<ProblemReportContent, ProblemReportDecorators>; #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, TypedBuilder)] #[builder(build_method(into))] pub struct ProblemReportContent { pub description: Description, #[builder(default, setter(strip_option))] #[serde(skip_serializing_if = "Option::is_none")] pub problem_items: Option<Vec<HashMap<String, String>>>, #[builder(default, setter(strip_option))] #[serde(skip_serializing_if = "Option::is_none")] pub who_retries: Option<WhoRetries>, #[builder(default, setter(strip_option))] #[serde(rename = "fix-hint")] #[serde(skip_serializing_if = "Option::is_none")] pub fix_hint: Option<String>, #[builder(default, setter(strip_option))] #[serde(skip_serializing_if = "Option::is_none")] pub impact: Option<Impact>, #[builder(default, setter(strip_option))] #[serde(rename = "where")] #[serde(skip_serializing_if = "Option::is_none")] pub location: Option<Where>, #[builder(default, setter(strip_option))] #[serde(skip_serializing_if = "Option::is_none")] pub noticed_time: Option<String>, #[serde(rename = "tracking-uri")] #[serde(skip_serializing_if = "Option::is_none")] #[builder(default, setter(strip_option))] pub tracking_uri: Option<Url>, #[builder(default, setter(strip_option))] #[serde(rename = "escalation-uri")] #[serde(skip_serializing_if = "Option::is_none")] pub escalation_uri: Option<Url>, } #[derive(Debug, Clone, Serialize, Deserialize, Default, PartialEq, TypedBuilder)] pub struct ProblemReportDecorators { #[builder(default, setter(strip_option))] #[serde(skip_serializing_if = "Option::is_none")] #[serde(rename = "~thread")] pub thread: Option<Thread>, #[builder(default, setter(strip_option))] #[serde(rename = "~timing")] #[serde(skip_serializing_if = "Option::is_none")] pub timing: Option<Timing>, #[builder(default, setter(strip_option))] #[serde(rename = "description~l10n")] #[serde(skip_serializing_if = "Option::is_none")] pub description_locale: Option<FieldLocalization>, #[builder(default, setter(strip_option))] #[serde(rename = "fix-hint~l10n")] #[serde(skip_serializing_if = "Option::is_none")] pub fix_hint_locale: Option<FieldLocalization>, } #[derive(Debug, Clone, Deserialize, PartialEq, TypedBuilder)] pub struct Description { #[builder(default)] #[serde(flatten)] #[serde(skip_serializing_if = "HashMap::is_empty")] pub translations: HashMap<Locale, String>, pub code: String, } /// Manual implementation because `serde_json` does not support /// non-string map keys. impl Serialize for Description { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: Serializer, { let mut state = Serializer::serialize_map(serializer, None)?; state.serialize_entry("code", &self.code)?; if !HashMap::is_empty(&self.translations) { for (key, value) in &self.translations { let key = <&str>::try_from(key).map_err(S::Error::custom)?; state.serialize_entry(key, value)?; } } SerializeMap::end(state) } } #[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq)] #[serde(rename_all = "lowercase")] pub enum WhoRetries { Me, You, Both, None, } #[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq)] #[serde(rename_all = "lowercase")] pub enum Impact { MessageContent, Thread, Connection, } #[derive(Debug, Clone, PartialEq)] pub struct Where { pub party: WhereParty, pub location: String, } impl Where { pub fn new(party: WhereParty, location: String) -> Self { Self { party, location } } } impl Display for Where { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { write!(f, "{} - {}", self.party.as_ref(), self.location.as_str()) } } impl Serialize for Where { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: Serializer, { self.to_string().serialize(serializer) } } impl<'de> Deserialize<'de> for Where { fn deserialize<D>(deserializer: D) -> Result<Self, D::Error> where D: Deserializer<'de>, { let err_closure = |val: &str| D::Error::custom(format!("invalid where field: {val}")); // Try to avoid allocation if possible let where_str = CowStr::deserialize(deserializer)?.0; // Borrow as &str let where_str = where_str.as_ref(); let mut iter = where_str.split(" - "); let party = iter .next() .ok_or_else(|| err_closure(where_str))? .try_into() .map_err(D::Error::custom)?; let location = iter .next() .ok_or_else(|| err_closure(where_str))? .to_owned(); Ok(Where { party, location }) } } #[derive(AsRefStr, Debug, Copy, Clone, Serialize, Deserialize, EnumString, PartialEq)] #[serde(rename_all = "lowercase")] pub enum WhereParty { Me, You, Other, } into_msg_with_type!(ProblemReport, ReportProblemTypeV1_0, ProblemReport); #[cfg(test)] #[allow(clippy::field_reassign_with_default)] mod tests { use serde_json::json; use super::*; use crate::{ decorators::{ localization::tests::make_extended_field_localization, thread::tests::make_extended_thread, timing::tests::make_extended_timing, }, misc::test_utils, }; #[test] fn test_minimal_problem_report() { let description = Description::builder() .code("test_problem_report_code".to_owned()) .build(); let content: ProblemReportContent = ProblemReportContent::builder() .description(description) .build(); let decorators = ProblemReportDecorators::default(); let expected = json!({ "description": content.description }); test_utils::test_msg( content, decorators, ReportProblemTypeV1_0::ProblemReport, expected, ); } #[test] fn test_extended_problem_report() { let description = Description::builder() .code("test_problem_report_code".to_owned()) .build(); let content: ProblemReportContent = ProblemReportContent::builder() .description(description) .who_retries(WhoRetries::Me) .fix_hint("test_fix_hint".to_owned()) .impact(Impact::Connection) .location(Where::new(WhereParty::Me, "test_location".to_owned())) .noticed_time("test_noticed_time".to_owned()) .tracking_uri("https://dummy.dummy/dummy".parse().unwrap()) .escalation_uri("https://dummy.dummy/dummy".parse().unwrap()) .problem_items(vec![HashMap::from([( "test_prob_item_key".to_owned(), "test_prob_item_value".to_owned(), )])]) .build(); let decorators = ProblemReportDecorators::builder() .thread(make_extended_thread()) .timing(make_extended_timing()) .description_locale(make_extended_field_localization()) .fix_hint_locale(make_extended_field_localization()) .build(); let expected = json!({ "description": content.description, "who_retries": content.who_retries, "fix-hint": content.fix_hint, "impact": content.impact, "where": content.location, "noticed_time": content.noticed_time, "tracking-uri": content.tracking_uri, "escalation-uri": content.escalation_uri, "problem_items": content.problem_items, "~thread": decorators.thread, "~timing": decorators.timing, "description~l10n": decorators.description_locale, "fix-hint~l10n": decorators.fix_hint_locale }); test_utils::test_msg( content, decorators, ReportProblemTypeV1_0::ProblemReport, expected, ); } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/coordinate_mediation/mediate_request.rs
aries/messages/src/msg_fields/protocols/coordinate_mediation/mediate_request.rs
use serde::{Deserialize, Serialize}; use typed_builder::TypedBuilder; use crate::{decorators::thread::Thread, msg_parts::MsgParts}; /// https://github.com/decentralized-identity/aries-rfcs/blob/main/features/0211-route-coordination/README.md#mediation-request pub type MediateRequest = MsgParts<MediateRequestContent>; #[derive(Clone, Debug, Deserialize, Serialize, Default, PartialEq, TypedBuilder)] pub struct MediateRequestContent {} #[derive(Clone, Debug, Deserialize, Serialize, Default, PartialEq, TypedBuilder)] pub struct MediateRequestDecorators { #[builder(default, setter(strip_option))] #[serde(rename = "~thread")] #[serde(skip_serializing_if = "Option::is_none")] pub thread: Option<Thread>, } #[cfg(test)] #[allow(clippy::field_reassign_with_default)] mod tests { use serde_json::json; use shared::misc::serde_ignored::SerdeIgnored as NoDecorators; use super::*; use crate::{ misc::test_utils, msg_types::protocols::coordinate_mediation::CoordinateMediationTypeV1_0, }; #[test] fn test_mediate_request() { let expected = json!( { "@id": "123456781", "@type": "https://didcomm.org/coordinate-mediation/1.0/mediate-request", } ); let content = MediateRequestContent::builder().build(); test_utils::test_msg( content, NoDecorators, CoordinateMediationTypeV1_0::MediateRequest, expected, ); } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/coordinate_mediation/mediate_deny.rs
aries/messages/src/msg_fields/protocols/coordinate_mediation/mediate_deny.rs
use serde::{Deserialize, Serialize}; use typed_builder::TypedBuilder; use crate::{decorators::thread::Thread, msg_parts::MsgParts}; /// https://github.com/decentralized-identity/aries-rfcs/blob/main/features/0211-route-coordination/README.md#mediation-deny pub type MediateDeny = MsgParts<MediateDenyContent, MediateDenyDecorators>; #[derive(Clone, Debug, Deserialize, Serialize, Default, PartialEq, TypedBuilder)] pub struct MediateDenyContent {} #[derive(Clone, Debug, Deserialize, Serialize, Default, PartialEq, TypedBuilder)] pub struct MediateDenyDecorators { #[builder(default, setter(strip_option))] #[serde(rename = "~thread")] #[serde(skip_serializing_if = "Option::is_none")] pub thread: Option<Thread>, } #[cfg(test)] #[allow(clippy::field_reassign_with_default)] mod tests { use serde_json::json; use super::*; use crate::{ misc::test_utils, msg_types::protocols::coordinate_mediation::CoordinateMediationTypeV1_0, }; #[test] fn test_mediate_deny() { let expected = json!( { "@id": "123456781", "@type": "https://didcomm.org/coordinate-mediation/1.0/mediate-deny", } ); let content = MediateDenyContent::builder().build(); let decorators = MediateDenyDecorators::builder().build(); test_utils::test_msg( content, decorators, CoordinateMediationTypeV1_0::MediateDeny, expected, ); } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/coordinate_mediation/mediate_grant.rs
aries/messages/src/msg_fields/protocols/coordinate_mediation/mediate_grant.rs
use serde::{Deserialize, Serialize}; use typed_builder::TypedBuilder; use crate::{decorators::thread::Thread, msg_parts::MsgParts}; /// https://github.com/decentralized-identity/aries-rfcs/blob/main/features/0211-route-coordination/README.md#mediation-grant pub type MediateGrant = MsgParts<MediateGrantContent, MediateGrantDecorators>; #[derive(Clone, Debug, Deserialize, Serialize, Default, PartialEq, TypedBuilder)] pub struct MediateGrantContent { pub endpoint: String, pub routing_keys: Vec<String>, } #[derive(Clone, Debug, Deserialize, Serialize, Default, PartialEq, TypedBuilder)] pub struct MediateGrantDecorators { #[builder(default, setter(strip_option))] #[serde(rename = "~thread")] #[serde(skip_serializing_if = "Option::is_none")] pub thread: Option<Thread>, } #[cfg(test)] #[allow(clippy::field_reassign_with_default)] mod tests { use serde_json::json; use super::*; use crate::{ misc::test_utils, msg_types::protocols::coordinate_mediation::CoordinateMediationTypeV1_0, }; #[test] fn test_mediate_grant() { let expected = json!( { "@id": "123456781", "@type": "https://didcomm.org/coordinate-mediation/1.0/mediate-grant", "endpoint": "http://mediators-r-us.com", "routing_keys": ["did:key:z6Mkfriq1MqLBoPWecGoDLjguo1sB9brj6wT3qZ5BxkKpuP6"] } ); let content = MediateGrantContent::builder() .endpoint("http://mediators-r-us.com".to_owned()) .routing_keys(vec![ "did:key:z6Mkfriq1MqLBoPWecGoDLjguo1sB9brj6wT3qZ5BxkKpuP6".to_owned(), ]) .build(); let decorators = MediateGrantDecorators::builder().build(); test_utils::test_msg( content, decorators, CoordinateMediationTypeV1_0::MediateGrant, expected, ); } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/coordinate_mediation/keylist_update_response.rs
aries/messages/src/msg_fields/protocols/coordinate_mediation/keylist_update_response.rs
use serde::{Deserialize, Serialize}; use typed_builder::TypedBuilder; use super::keylist_update::KeylistUpdateItemAction; use crate::{decorators::thread::Thread, msg_parts::MsgParts}; /// https://github.com/decentralized-identity/aries-rfcs/blob/main/features/0211-route-coordination/README.md#keylist-update-response pub type KeylistUpdateResponse = MsgParts<KeylistUpdateResponseContent, KeylistUpdateResponseDecorators>; #[derive(Clone, Debug, Deserialize, Serialize, Default, PartialEq, TypedBuilder)] pub struct KeylistUpdateResponseContent { pub updated: Vec<KeylistUpdateResponseItem>, } #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, TypedBuilder)] pub struct KeylistUpdateResponseItem { pub recipient_key: String, pub action: KeylistUpdateItemAction, pub result: KeylistUpdateItemResult, } #[derive(Clone, Debug, Deserialize, Serialize, PartialEq)] pub enum KeylistUpdateItemResult { #[serde(rename = "client_error")] ClientError, #[serde(rename = "server_error")] ServerError, #[serde(rename = "no_change")] NoChange, #[serde(rename = "success")] Success, } #[derive(Clone, Debug, Deserialize, Serialize, Default, PartialEq, TypedBuilder)] pub struct KeylistUpdateResponseDecorators { #[builder(default, setter(strip_option))] #[serde(rename = "~thread")] #[serde(skip_serializing_if = "Option::is_none")] pub thread: Option<Thread>, } #[cfg(test)] #[allow(clippy::field_reassign_with_default)] mod tests { use serde_json::json; use super::*; use crate::{ misc::test_utils, msg_types::protocols::coordinate_mediation::CoordinateMediationTypeV1_0, }; #[test] fn test_keylist_update_response() { let expected = json!( { "@id": "123456781", "@type": "https://didcomm.org/coordinate-mediation/1.0/keylist-update-response", "updated": [ { "recipient_key": "did:key:z6MkpTHR8VNsBxYAAWHut2Geadd9jSwuBV8xRoAnwWsdvktH", "action": "add", // "add" or "remove" "result": "client_error" // [client_error | server_error | no_change | success] } ] } ); let update_item1 = KeylistUpdateResponseItem::builder() .recipient_key("did:key:z6MkpTHR8VNsBxYAAWHut2Geadd9jSwuBV8xRoAnwWsdvktH".to_owned()) .action(KeylistUpdateItemAction::Add) .result(KeylistUpdateItemResult::ClientError) .build(); let content = KeylistUpdateResponseContent::builder() .updated(vec![update_item1]) .build(); let decorators = KeylistUpdateResponseDecorators::builder().build(); test_utils::test_msg( content, decorators, CoordinateMediationTypeV1_0::KeylistUpdateResponse, expected, ); } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/coordinate_mediation/keylist_query.rs
aries/messages/src/msg_fields/protocols/coordinate_mediation/keylist_query.rs
use serde::{Deserialize, Serialize}; use typed_builder::TypedBuilder; use crate::{decorators::thread::Thread, msg_parts::MsgParts}; /// https://github.com/decentralized-identity/aries-rfcs/blob/main/features/0211-route-coordination/README.md#key-list-query pub type KeylistQuery = MsgParts<KeylistQueryContent>; #[derive(Clone, Debug, Deserialize, Serialize, Default, PartialEq, TypedBuilder)] pub struct KeylistQueryContent { #[builder(default, setter(strip_option))] #[serde(skip_serializing_if = "Option::is_none")] paginate: Option<KeylistQueryPaginateParams>, } #[derive(Clone, Debug, Deserialize, Serialize, Default, PartialEq, TypedBuilder)] pub struct KeylistQueryPaginateParams { #[builder(default, setter(strip_option))] #[serde(skip_serializing_if = "Option::is_none")] limit: Option<u64>, #[builder(default, setter(strip_option))] #[serde(skip_serializing_if = "Option::is_none")] offset: Option<u64>, } #[derive(Clone, Debug, Deserialize, Serialize, Default, PartialEq, TypedBuilder)] pub struct KeylistQueryDecorators { #[builder(default, setter(strip_option))] #[serde(rename = "~thread")] #[serde(skip_serializing_if = "Option::is_none")] pub thread: Option<Thread>, } #[cfg(test)] #[allow(clippy::field_reassign_with_default)] mod tests { use serde_json::json; use shared::misc::serde_ignored::SerdeIgnored as NoDecorators; use super::*; use crate::{ misc::test_utils, msg_types::protocols::coordinate_mediation::CoordinateMediationTypeV1_0, }; #[test] fn test_keylist_query() { let expected = json!( { "@id": "123456781", "@type": "https://didcomm.org/coordinate-mediation/1.0/keylist-query", "paginate": { "limit": 30, "offset": 0 } } ); let paginate_params = KeylistQueryPaginateParams::builder() .limit(30) .offset(0) .build(); let content = KeylistQueryContent::builder() .paginate(paginate_params) .build(); test_utils::test_msg( content, NoDecorators, CoordinateMediationTypeV1_0::KeylistQuery, expected, ); } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/coordinate_mediation/keylist_update.rs
aries/messages/src/msg_fields/protocols/coordinate_mediation/keylist_update.rs
use serde::{Deserialize, Serialize}; use typed_builder::TypedBuilder; use crate::{decorators::thread::Thread, msg_parts::MsgParts}; /// https://github.com/decentralized-identity/aries-rfcs/blob/main/features/0211-route-coordination/README.md#keylist-update pub type KeylistUpdate = MsgParts<KeylistUpdateContent>; #[derive(Clone, Debug, Deserialize, Serialize, Default, PartialEq, TypedBuilder)] pub struct KeylistUpdateContent { pub updates: Vec<KeylistUpdateItem>, } #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, TypedBuilder)] pub struct KeylistUpdateItem { pub recipient_key: String, pub action: KeylistUpdateItemAction, } #[derive(Clone, Debug, Deserialize, Serialize, PartialEq)] pub enum KeylistUpdateItemAction { #[serde(rename = "add")] Add, #[serde(rename = "remove")] Remove, } #[derive(Clone, Debug, Deserialize, Serialize, Default, PartialEq, TypedBuilder)] pub struct KeylistUpdateDecorators { #[builder(default, setter(strip_option))] #[serde(rename = "~thread")] #[serde(skip_serializing_if = "Option::is_none")] pub thread: Option<Thread>, } #[cfg(test)] #[allow(clippy::field_reassign_with_default)] mod tests { use serde_json::json; use shared::misc::serde_ignored::SerdeIgnored as NoDecorators; use super::*; use crate::{ misc::test_utils, msg_types::protocols::coordinate_mediation::CoordinateMediationTypeV1_0, }; #[test] fn test_key_list_update() { let expected = json!( { "@id": "123456781", "@type": "https://didcomm.org/coordinate-mediation/1.0/keylist-update", "updates":[ { "recipient_key": "did:key:z6MkpTHR8VNsBxYAAWHut2Geadd9jSwuBV8xRoAnwWsdvktH", "action": "add" } ] } ); let update_item1 = KeylistUpdateItem::builder() .recipient_key("did:key:z6MkpTHR8VNsBxYAAWHut2Geadd9jSwuBV8xRoAnwWsdvktH".to_owned()) .action(KeylistUpdateItemAction::Add) .build(); let content = KeylistUpdateContent::builder() .updates(vec![update_item1]) .build(); test_utils::test_msg( content, NoDecorators, CoordinateMediationTypeV1_0::KeylistUpdate, expected, ); } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/coordinate_mediation/mod.rs
aries/messages/src/msg_fields/protocols/coordinate_mediation/mod.rs
pub mod keylist; pub mod keylist_query; pub mod keylist_update; pub mod keylist_update_response; mod mediate_deny; mod mediate_grant; mod mediate_request; use derive_more::From; use serde::{de::Error, Deserialize, Deserializer, Serialize, Serializer}; pub use self::{ keylist::{Keylist, KeylistContent, KeylistDecorators}, keylist_query::{KeylistQuery, KeylistQueryContent, KeylistQueryDecorators}, keylist_update::{KeylistUpdate, KeylistUpdateContent, KeylistUpdateDecorators}, keylist_update_response::{ KeylistUpdateResponse, KeylistUpdateResponseContent, KeylistUpdateResponseDecorators, }, mediate_deny::{MediateDeny, MediateDenyContent, MediateDenyDecorators}, mediate_grant::{MediateGrant, MediateGrantContent, MediateGrantDecorators}, mediate_request::{MediateRequest, MediateRequestContent, MediateRequestDecorators}, }; use crate::{ misc::utils::{into_msg_with_type, transit_to_aries_msg}, msg_fields::traits::DelayedSerde, msg_types::{ protocols::coordinate_mediation::{ CoordinateMediationType, CoordinateMediationTypeV1, CoordinateMediationTypeV1_0, }, MsgWithType, }, }; #[derive(Clone, Debug, From, PartialEq)] pub enum CoordinateMediation { MediateRequest(MediateRequest), MediateDeny(MediateDeny), MediateGrant(MediateGrant), KeylistUpdate(KeylistUpdate), KeylistUpdateResponse(KeylistUpdateResponse), KeylistQuery(KeylistQuery), Keylist(Keylist), } impl DelayedSerde for CoordinateMediation { type MsgType<'a> = (CoordinateMediationType, &'a str); fn delayed_deserialize<'de, D>( msg_type: Self::MsgType<'de>, deserializer: D, ) -> Result<Self, D::Error> where D: Deserializer<'de>, { let (protocol, kind_str) = msg_type; let kind = match protocol { CoordinateMediationType::V1(CoordinateMediationTypeV1::V1_0(kind)) => { kind.kind_from_str(kind_str) } }; match kind.map_err(D::Error::custom)? { CoordinateMediationTypeV1_0::MediateRequest => { MediateRequest::deserialize(deserializer).map(From::from) } CoordinateMediationTypeV1_0::MediateDeny => { MediateDeny::deserialize(deserializer).map(From::from) } CoordinateMediationTypeV1_0::MediateGrant => { MediateGrant::deserialize(deserializer).map(From::from) } CoordinateMediationTypeV1_0::KeylistUpdate => { KeylistUpdate::deserialize(deserializer).map(From::from) } CoordinateMediationTypeV1_0::KeylistUpdateResponse => { KeylistUpdateResponse::deserialize(deserializer).map(From::from) } CoordinateMediationTypeV1_0::KeylistQuery => { KeylistQuery::deserialize(deserializer).map(From::from) } CoordinateMediationTypeV1_0::Keylist => { Keylist::deserialize(deserializer).map(From::from) } } } fn delayed_serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: Serializer, { match self { Self::MediateRequest(v) => MsgWithType::from(v).serialize(serializer), Self::MediateDeny(v) => MsgWithType::from(v).serialize(serializer), Self::MediateGrant(v) => MsgWithType::from(v).serialize(serializer), Self::KeylistUpdate(v) => MsgWithType::from(v).serialize(serializer), Self::KeylistUpdateResponse(v) => MsgWithType::from(v).serialize(serializer), Self::KeylistQuery(v) => MsgWithType::from(v).serialize(serializer), Self::Keylist(v) => MsgWithType::from(v).serialize(serializer), } } } transit_to_aries_msg!(MediateRequestContent, CoordinateMediation); transit_to_aries_msg!(MediateDenyContent: MediateDenyDecorators, CoordinateMediation); transit_to_aries_msg!(MediateGrantContent: MediateGrantDecorators, CoordinateMediation); transit_to_aries_msg!(KeylistUpdateContent, CoordinateMediation); transit_to_aries_msg!(KeylistUpdateResponseContent: KeylistUpdateResponseDecorators, CoordinateMediation); transit_to_aries_msg!(KeylistQueryContent, CoordinateMediation); transit_to_aries_msg!(KeylistContent: KeylistDecorators, CoordinateMediation); into_msg_with_type!(MediateRequest, CoordinateMediationTypeV1_0, MediateRequest); into_msg_with_type!(MediateDeny, CoordinateMediationTypeV1_0, MediateDeny); into_msg_with_type!(MediateGrant, CoordinateMediationTypeV1_0, MediateGrant); into_msg_with_type!(KeylistUpdate, CoordinateMediationTypeV1_0, KeylistUpdate); into_msg_with_type!( KeylistUpdateResponse, CoordinateMediationTypeV1_0, KeylistUpdateResponse ); into_msg_with_type!(KeylistQuery, CoordinateMediationTypeV1_0, KeylistQuery); into_msg_with_type!(Keylist, CoordinateMediationTypeV1_0, Keylist);
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/coordinate_mediation/keylist.rs
aries/messages/src/msg_fields/protocols/coordinate_mediation/keylist.rs
use serde::{Deserialize, Serialize}; use typed_builder::TypedBuilder; use crate::{decorators::thread::Thread, msg_parts::MsgParts}; /// https://github.com/decentralized-identity/aries-rfcs/blob/main/features/0211-route-coordination/README.md#key-list pub type Keylist = MsgParts<KeylistContent, KeylistDecorators>; #[derive(Clone, Debug, Deserialize, Serialize, Default, PartialEq, TypedBuilder)] pub struct KeylistContent { pub keys: Vec<KeylistItem>, #[builder(default, setter(strip_option))] #[serde(skip_serializing_if = "Option::is_none")] pub pagination: Option<KeylistPagination>, } #[derive(Clone, Debug, Deserialize, Serialize, Default, PartialEq, TypedBuilder)] pub struct KeylistItem { pub recipient_key: String, } #[derive(Clone, Debug, Deserialize, Serialize, Default, PartialEq, TypedBuilder)] pub struct KeylistPagination { count: u64, offset: u64, remaining: u64, } #[derive(Clone, Debug, Deserialize, Serialize, Default, PartialEq, TypedBuilder)] pub struct KeylistDecorators { #[builder(default, setter(strip_option))] #[serde(rename = "~thread")] #[serde(skip_serializing_if = "Option::is_none")] pub thread: Option<Thread>, } #[cfg(test)] #[allow(clippy::field_reassign_with_default)] mod tests { use serde_json::json; use super::*; use crate::{ misc::test_utils, msg_types::protocols::coordinate_mediation::CoordinateMediationTypeV1_0, }; #[test] fn test_keylist() { let expected = json!( { "@id": "123456781", "@type": "https://didcomm.org/coordinate-mediation/1.0/keylist", "keys": [ { "recipient_key": "did:key:z6MkpTHR8VNsBxYAAWHut2Geadd9jSwuBV8xRoAnwWsdvktH" } ], "pagination": { "count": 30, "offset": 30, "remaining": 100 } } ); let key_item = KeylistItem::builder() .recipient_key("did:key:z6MkpTHR8VNsBxYAAWHut2Geadd9jSwuBV8xRoAnwWsdvktH".to_owned()) .build(); let pagination_state = KeylistPagination::builder() .count(30) .offset(30) .remaining(100) .build(); let content = KeylistContent::builder() .pagination(pagination_state) .keys(vec![key_item]) .build(); let decorators = KeylistDecorators::builder().build(); test_utils::test_msg( content, decorators, CoordinateMediationTypeV1_0::Keylist, expected, ); } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/discover_features/disclose.rs
aries/messages/src/msg_fields/protocols/discover_features/disclose.rs
use serde::{Deserialize, Serialize}; use shared::maybe_known::MaybeKnown; use typed_builder::TypedBuilder; use super::ProtocolDescriptor; use crate::{ decorators::{thread::Thread, timing::Timing}, msg_parts::MsgParts, msg_types::registry::PROTOCOL_REGISTRY, }; pub type Disclose = MsgParts<DiscloseContent, DiscloseDecorators>; #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, TypedBuilder)] pub struct DiscloseContent { pub protocols: Vec<ProtocolDescriptor>, } impl Default for DiscloseContent { fn default() -> Self { let mut protocols = Vec::new(); for entries in PROTOCOL_REGISTRY.clone().into_values() { for entry in entries { let pd = ProtocolDescriptor::builder() .pid(MaybeKnown::Known(entry.protocol)) .roles(entry.roles) .build(); protocols.push(pd); } } Self { protocols } } } #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, TypedBuilder)] pub struct DiscloseDecorators { #[serde(rename = "~thread")] pub thread: Thread, #[builder(default, setter(strip_option))] #[serde(rename = "~timing")] #[serde(skip_serializing_if = "Option::is_none")] pub timing: Option<Timing>, } #[cfg(test)] #[allow(clippy::field_reassign_with_default)] mod tests { use serde_json::json; use shared::maybe_known::MaybeKnown; use super::*; use crate::{ decorators::{thread::tests::make_extended_thread, timing::tests::make_extended_timing}, misc::test_utils, msg_types::discover_features::DiscoverFeaturesTypeV1_0, }; #[test] fn test_minimal_disclose() { let content = DiscloseContent::default(); let decorators = DiscloseDecorators::builder() .thread(make_extended_thread()) .build(); let expected = json!({ "protocols": content.protocols, "~thread": decorators.thread }); test_utils::test_msg( content, decorators, DiscoverFeaturesTypeV1_0::Disclose, expected, ); } #[test] fn test_extended_disclose() { let mut content = DiscloseContent::default(); content.protocols.pop(); content.protocols.pop(); content.protocols.pop(); let dummy_protocol_descriptor = ProtocolDescriptor::builder() .pid(MaybeKnown::Unknown("test_dummy_pid".to_owned())) .build(); content.protocols.push(dummy_protocol_descriptor); let decorators = DiscloseDecorators::builder() .thread(make_extended_thread()) .timing(make_extended_timing()) .build(); let expected = json!({ "protocols": content.protocols, "~thread": decorators.thread, "~timing": decorators.timing }); test_utils::test_msg( content, decorators, DiscoverFeaturesTypeV1_0::Disclose, expected, ); } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/discover_features/mod.rs
aries/messages/src/msg_fields/protocols/discover_features/mod.rs
//! Module containing the `discover features` protocol messages, as defined in the [RFC](<https://github.com/decentralized-identity/aries-rfcs/blob/main/features/0031-discover-features/README.md>). pub mod disclose; pub mod query; use derive_more::From; use serde::{de::Error, Deserialize, Deserializer, Serialize, Serializer}; use shared::maybe_known::MaybeKnown; use typed_builder::TypedBuilder; use self::{ disclose::{Disclose, DiscloseContent, DiscloseDecorators}, query::{Query, QueryContent, QueryDecorators}, }; use crate::{ misc::utils::{into_msg_with_type, transit_to_aries_msg}, msg_fields::traits::DelayedSerde, msg_types::{ protocols::discover_features::{ DiscoverFeaturesType as DiscoverFeaturesKind, DiscoverFeaturesTypeV1, DiscoverFeaturesTypeV1_0, }, MsgWithType, Protocol, Role, }, }; #[derive(Clone, Debug, From, PartialEq)] pub enum DiscoverFeatures { Query(Query), Disclose(Disclose), } impl DelayedSerde for DiscoverFeatures { type MsgType<'a> = (DiscoverFeaturesKind, &'a str); fn delayed_deserialize<'de, D>( msg_type: Self::MsgType<'de>, deserializer: D, ) -> Result<Self, D::Error> where D: Deserializer<'de>, { let (protocol, kind_str) = msg_type; let kind = match protocol { DiscoverFeaturesKind::V1(DiscoverFeaturesTypeV1::V1_0(kind)) => { kind.kind_from_str(kind_str) } }; match kind.map_err(D::Error::custom)? { DiscoverFeaturesTypeV1_0::Query => Query::deserialize(deserializer).map(From::from), DiscoverFeaturesTypeV1_0::Disclose => { Disclose::deserialize(deserializer).map(From::from) } } } fn delayed_serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: Serializer, { match self { Self::Query(v) => MsgWithType::from(v).serialize(serializer), Self::Disclose(v) => MsgWithType::from(v).serialize(serializer), } } } #[derive(Debug, Clone, Deserialize, Serialize, PartialEq, TypedBuilder)] pub struct ProtocolDescriptor { pub pid: MaybeKnown<Protocol>, #[builder(default, setter(strip_option))] #[serde(skip_serializing_if = "Option::is_none")] pub roles: Option<Vec<MaybeKnown<Role>>>, } transit_to_aries_msg!(QueryContent: QueryDecorators, DiscoverFeatures); transit_to_aries_msg!(DiscloseContent: DiscloseDecorators, DiscoverFeatures); into_msg_with_type!(Query, DiscoverFeaturesTypeV1_0, Query); into_msg_with_type!(Disclose, DiscoverFeaturesTypeV1_0, Disclose);
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/discover_features/query.rs
aries/messages/src/msg_fields/protocols/discover_features/query.rs
use serde::{Deserialize, Serialize}; use shared::maybe_known::MaybeKnown; use typed_builder::TypedBuilder; use super::ProtocolDescriptor; use crate::{ decorators::timing::Timing, msg_parts::MsgParts, msg_types::registry::PROTOCOL_REGISTRY, }; pub type Query = MsgParts<QueryContent, QueryDecorators>; #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, TypedBuilder)] pub struct QueryContent { pub query: String, #[builder(default, setter(strip_option))] #[serde(skip_serializing_if = "Option::is_none")] pub comment: Option<String>, } impl QueryContent { /// Looks up into the [`PROTOCOL_REGISTRY`] and returns a [`Vec<ProtocolDescriptor`] matching /// the inner query. pub fn lookup(&self) -> Vec<ProtocolDescriptor> { let mut protocols = Vec::new(); let query = self .query .split('*') .next() .expect("query must have at least an empty string before *"); for entries in PROTOCOL_REGISTRY.values() { for entry in entries { if entry.str_pid.starts_with(query) { let pd = ProtocolDescriptor::builder() .pid(MaybeKnown::Known(entry.protocol)) .roles(entry.roles.clone()) .build(); protocols.push(pd); } } } protocols } } #[derive(Clone, Debug, Deserialize, Serialize, Default, PartialEq, TypedBuilder)] pub struct QueryDecorators { #[builder(default, setter(strip_option))] #[serde(rename = "~timing")] #[serde(skip_serializing_if = "Option::is_none")] pub timing: Option<Timing>, } #[cfg(test)] #[allow(clippy::field_reassign_with_default)] mod tests { use serde_json::json; use super::*; use crate::{ decorators::timing::tests::make_extended_timing, misc::test_utils, msg_types::{ discover_features::DiscoverFeaturesTypeV1_0, protocols::connection::ConnectionTypeV1, traits::ProtocolVersion, }, }; #[test] fn test_minimal_query() { let content = QueryContent::builder().query("*".to_owned()).build(); let decorators = QueryDecorators::default(); let expected = json!({ "query": content.query }); test_utils::test_msg( content, decorators, DiscoverFeaturesTypeV1_0::Query, expected, ); } #[test] fn test_extended_query() { let content = QueryContent::builder() .query("*".to_owned()) .comment("test_comment".to_owned()) .build(); let decorators = QueryDecorators::builder() .timing(make_extended_timing()) .build(); let expected = json!({ "query": content.query, "comment": content.comment, "~timing": decorators.timing }); test_utils::test_msg( content, decorators, DiscoverFeaturesTypeV1_0::Query, expected, ); } #[test] fn test_lookup_match_all() { let matched_all = QueryContent::builder() .query("*".to_owned()) .build() .lookup(); let mut protocols = Vec::new(); for entries in PROTOCOL_REGISTRY.values() { for entry in entries { let pid = MaybeKnown::Known(entry.protocol); let pd = ProtocolDescriptor::builder() .pid(pid) .roles(entry.roles.clone()) .build(); protocols.push(pd); } } assert_eq!(protocols, matched_all); } #[test] fn test_lookup_match_protocol() { let matched_protocol = QueryContent::builder() .query("https://didcomm.org/connections/*".to_owned()) .build() .lookup(); let pid = ConnectionTypeV1::new_v1_0(); let roles = pid.roles(); let pd = ProtocolDescriptor::builder() .pid(MaybeKnown::Known(pid.into())) .roles(roles) .build(); let protocols = vec![pd]; assert_eq!(protocols, matched_protocol); } #[test] fn test_lookup_match_version() { let matched_protocol = QueryContent::builder() .query("https://didcomm.org/connections/1.*".to_owned()) .build() .lookup(); let pid = ConnectionTypeV1::new_v1_0(); let pd = ProtocolDescriptor::builder() .pid(MaybeKnown::Known(pid.into())) .roles(pid.roles()) .build(); let protocols = vec![pd]; assert_eq!(protocols, matched_protocol); } #[test] fn test_lookup_match_none() { let matched_protocol = QueryContent::builder() .query("https://didcomm.org/non-existent/*".to_owned()) .build() .lookup(); let protocols = Vec::<ProtocolDescriptor>::new(); assert_eq!(protocols, matched_protocol); } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/pickup/delivery_request.rs
aries/messages/src/msg_fields/protocols/pickup/delivery_request.rs
use serde::{Deserialize, Serialize}; use typed_builder::TypedBuilder; use crate::{ decorators::{thread::Thread, transport::Transport}, msg_parts::MsgParts, }; pub type DeliveryRequest = MsgParts<DeliveryRequestContent, DeliveryRequestDecorators>; #[derive(Clone, Debug, Deserialize, Serialize, Default, PartialEq, TypedBuilder)] pub struct DeliveryRequestContent { pub limit: u32, #[builder(default, setter(strip_option))] #[serde(skip_serializing_if = "Option::is_none")] pub recipient_key: Option<String>, } #[derive(Clone, Debug, Deserialize, Serialize, Default, PartialEq, TypedBuilder)] pub struct DeliveryRequestDecorators { #[builder(default, setter(strip_option))] #[serde(rename = "~thread")] #[serde(skip_serializing_if = "Option::is_none")] pub thread: Option<Thread>, #[builder(default, setter(strip_option))] #[serde(rename = "~transport")] #[serde(skip_serializing_if = "Option::is_none")] pub transport: Option<Transport>, } #[cfg(test)] #[allow(clippy::field_reassign_with_default)] mod tests { use serde_json::json; use super::*; use crate::{misc::test_utils, msg_types::protocols::pickup::PickupTypeV2_0}; #[test] fn test_delivery_request() { let expected = json!( { "@id": "123456781", "@type": "https://didcomm.org/messagepickup/2.0/delivery-request", "limit": 10, "recipient_key": "<key for messages>" } ); let content = DeliveryRequestContent::builder() .recipient_key("<key for messages>".to_owned()) .limit(10) .build(); let decorators = DeliveryRequestDecorators::builder().build(); test_utils::test_msg( content, decorators, PickupTypeV2_0::DeliveryRequest, expected, ); } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/pickup/messages_received.rs
aries/messages/src/msg_fields/protocols/pickup/messages_received.rs
use serde::{Deserialize, Serialize}; use typed_builder::TypedBuilder; use crate::{ decorators::{thread::Thread, transport::Transport}, msg_parts::MsgParts, }; pub type MessagesReceived = MsgParts<MessagesReceivedContent, MessagesReceivedDecorators>; #[derive(Clone, Debug, Deserialize, Serialize, Default, PartialEq, TypedBuilder)] pub struct MessagesReceivedContent { pub message_id_list: Vec<String>, } #[derive(Clone, Debug, Deserialize, Serialize, Default, PartialEq, TypedBuilder)] pub struct MessagesReceivedDecorators { #[builder(default, setter(strip_option))] #[serde(rename = "~transport")] #[serde(skip_serializing_if = "Option::is_none")] pub transport: Option<Transport>, #[builder(default, setter(strip_option))] #[serde(rename = "~thread")] #[serde(skip_serializing_if = "Option::is_none")] pub thread: Option<Thread>, } #[cfg(test)] #[allow(clippy::field_reassign_with_default)] mod tests { use serde_json::json; use super::*; use crate::{misc::test_utils, msg_types::protocols::pickup::PickupTypeV2_0}; #[test] fn test_messages_received() { let expected = json!( { "@type": "https://didcomm.org/messagepickup/2.0/messages-received", "message_id_list": ["123","456"] } ); let content = MessagesReceivedContent::builder() .message_id_list(vec!["123".to_string(), "456".to_string()]) .build(); let decorators = MessagesReceivedDecorators::builder().build(); test_utils::test_msg( content, decorators, PickupTypeV2_0::MessagesReceived, expected, ); } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/pickup/status.rs
aries/messages/src/msg_fields/protocols/pickup/status.rs
use serde::{Deserialize, Serialize}; use typed_builder::TypedBuilder; use crate::{ decorators::{thread::Thread, transport::Transport}, msg_parts::MsgParts, }; pub type Status = MsgParts<StatusContent, StatusDecorators>; #[derive(Clone, Debug, Deserialize, Serialize, Default, PartialEq, TypedBuilder)] pub struct StatusContent { pub message_count: u32, #[builder(default, setter(strip_option))] #[serde(skip_serializing_if = "Option::is_none")] pub recipient_key: Option<String>, } #[derive(Clone, Debug, Deserialize, Serialize, Default, PartialEq, TypedBuilder)] pub struct StatusDecorators { #[builder(default, setter(strip_option))] #[serde(rename = "~transport")] #[serde(skip_serializing_if = "Option::is_none")] pub transport: Option<Transport>, #[builder(default, setter(strip_option))] #[serde(rename = "~thread")] #[serde(skip_serializing_if = "Option::is_none")] pub thread: Option<Thread>, } #[cfg(test)] #[allow(clippy::field_reassign_with_default)] mod tests { use serde_json::json; use super::*; use crate::{misc::test_utils, msg_types::protocols::pickup::PickupTypeV2_0}; #[test] fn test_status() { let expected = json!( { "@id": "123456781", "@type": "https://didcomm.org/messagepickup/2.0/status", "recipient_key": "<key for messages>", "message_count": 7, } ); let content = StatusContent::builder() .recipient_key("<key for messages>".to_owned()) .message_count(7) .build(); let decorators = StatusDecorators::builder().build(); test_utils::test_msg(content, decorators, PickupTypeV2_0::Status, expected); } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/pickup/delivery.rs
aries/messages/src/msg_fields/protocols/pickup/delivery.rs
use serde::{Deserialize, Serialize}; use typed_builder::TypedBuilder; use crate::{ decorators::{attachment::Attachment, thread::Thread, transport::Transport}, msg_parts::MsgParts, }; pub type Delivery = MsgParts<DeliveryContent, DeliveryDecorators>; #[derive(Clone, Debug, Deserialize, Serialize, Default, PartialEq, TypedBuilder)] pub struct DeliveryContent { #[builder(default, setter(strip_option))] #[serde(skip_serializing_if = "Option::is_none")] pub recipient_key: Option<String>, #[serde(rename = "~attach")] pub attach: Vec<Attachment>, } #[derive(Clone, Debug, Deserialize, Serialize, Default, PartialEq, TypedBuilder)] pub struct DeliveryDecorators { #[builder(default, setter(strip_option))] #[serde(rename = "~transport")] #[serde(skip_serializing_if = "Option::is_none")] pub transport: Option<Transport>, #[builder(default, setter(strip_option))] #[serde(rename = "~thread")] #[serde(skip_serializing_if = "Option::is_none")] pub thread: Option<Thread>, } #[cfg(test)] #[allow(clippy::field_reassign_with_default)] mod tests { use serde_json::json; use super::*; use crate::{ decorators::{ attachment::{AttachmentData, AttachmentType}, thread::Thread, }, misc::test_utils, msg_types::protocols::pickup::PickupTypeV2_0, }; #[test] fn test_delivery() { let expected = json!( { "@id": "123456781", "~thread": { "thid": "<message id of delivery-request message>" }, "@type": "https://didcomm.org/messagepickup/2.0/delivery", "recipient_key": "<key for messages>", "~attach": [{ "@id": "<messageid>", "data": { "base64": "" } }] } ); let attach = Attachment::builder() .id("<messageid>".to_owned()) .data( AttachmentData::builder() .content(AttachmentType::Base64("".into())) .build(), ) .build(); let content = DeliveryContent::builder() .recipient_key("<key for messages>".to_owned()) .attach(vec![attach]) .build(); let decorators = DeliveryDecorators::builder() .thread( Thread::builder() .thid("<message id of delivery-request message>".to_owned()) .build(), ) .build(); test_utils::test_msg(content, decorators, PickupTypeV2_0::Delivery, expected); } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/pickup/status_request.rs
aries/messages/src/msg_fields/protocols/pickup/status_request.rs
use serde::{Deserialize, Serialize}; use typed_builder::TypedBuilder; use crate::{ decorators::{thread::Thread, transport::Transport}, msg_parts::MsgParts, }; pub type StatusRequest = MsgParts<StatusRequestContent, StatusRequestDecorators>; #[derive(Clone, Debug, Deserialize, Serialize, Default, PartialEq, TypedBuilder)] pub struct StatusRequestContent { #[builder(default, setter(strip_option))] #[serde(skip_serializing_if = "Option::is_none")] pub recipient_key: Option<String>, } #[derive(Clone, Debug, Deserialize, Serialize, Default, PartialEq, TypedBuilder)] pub struct StatusRequestDecorators { #[builder(default, setter(strip_option))] #[serde(rename = "~transport")] #[serde(skip_serializing_if = "Option::is_none")] pub transport: Option<Transport>, #[builder(default, setter(strip_option))] #[serde(rename = "~thread")] #[serde(skip_serializing_if = "Option::is_none")] pub thread: Option<Thread>, } #[cfg(test)] #[allow(clippy::field_reassign_with_default)] mod tests { use serde_json::json; use super::*; use crate::{misc::test_utils, msg_types::protocols::pickup::PickupTypeV2_0}; #[test] fn test_status_request() { let expected = json!( { "@id": "123456781", "@type": "https://didcomm.org/messagepickup/2.0/status-request", "recipient_key": "<key for messages>" } ); let content = StatusRequestContent::builder() .recipient_key("<key for messages>".to_owned()) .build(); let decorators = StatusRequestDecorators::builder().build(); test_utils::test_msg(content, decorators, PickupTypeV2_0::StatusRequest, expected); } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/pickup/mod.rs
aries/messages/src/msg_fields/protocols/pickup/mod.rs
mod delivery; mod delivery_request; mod live_delivery_change; mod messages_received; mod status; mod status_request; use derive_more::From; use serde::{de::Error, Deserialize, Deserializer, Serialize, Serializer}; pub use self::{ delivery::{Delivery, DeliveryContent, DeliveryDecorators}, delivery_request::{DeliveryRequest, DeliveryRequestContent, DeliveryRequestDecorators}, live_delivery_change::{ LiveDeliveryChange, LiveDeliveryChangeContent, LiveDeliveryChangeDecorators, }, messages_received::{MessagesReceived, MessagesReceivedContent, MessagesReceivedDecorators}, status::{Status, StatusContent, StatusDecorators}, status_request::{StatusRequest, StatusRequestContent, StatusRequestDecorators}, }; use crate::{ misc::utils::{into_msg_with_type, transit_to_aries_msg}, msg_fields::traits::DelayedSerde, msg_types::{ protocols::pickup::{PickupType, PickupTypeV2, PickupTypeV2_0}, MsgWithType, }, }; #[derive(Clone, Debug, From, PartialEq)] pub enum Pickup { Status(Status), StatusRequest(StatusRequest), DeliveryRequest(DeliveryRequest), Delivery(Delivery), MessagesReceived(MessagesReceived), LiveDeliveryChange(LiveDeliveryChange), } impl DelayedSerde for Pickup { type MsgType<'a> = (PickupType, &'a str); fn delayed_deserialize<'de, D>( msg_type: Self::MsgType<'de>, deserializer: D, ) -> Result<Self, D::Error> where D: Deserializer<'de>, { let (protocol, kind_str) = msg_type; let kind = match protocol { PickupType::V2(PickupTypeV2::V2_0(kind)) => kind.kind_from_str(kind_str), }; match kind.map_err(D::Error::custom)? { PickupTypeV2_0::StatusRequest => { StatusRequest::deserialize(deserializer).map(From::from) } PickupTypeV2_0::Status => Status::deserialize(deserializer).map(From::from), PickupTypeV2_0::DeliveryRequest => { DeliveryRequest::deserialize(deserializer).map(From::from) } PickupTypeV2_0::Delivery => Delivery::deserialize(deserializer).map(From::from), PickupTypeV2_0::MessagesReceived => { MessagesReceived::deserialize(deserializer).map(From::from) } PickupTypeV2_0::LiveDeliveryChange => { LiveDeliveryChange::deserialize(deserializer).map(From::from) } } } fn delayed_serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: Serializer, { match self { Self::Status(v) => MsgWithType::from(v).serialize(serializer), Self::StatusRequest(v) => MsgWithType::from(v).serialize(serializer), Self::Delivery(v) => MsgWithType::from(v).serialize(serializer), Self::DeliveryRequest(v) => MsgWithType::from(v).serialize(serializer), Self::MessagesReceived(v) => MsgWithType::from(v).serialize(serializer), Self::LiveDeliveryChange(v) => MsgWithType::from(v).serialize(serializer), } } } transit_to_aries_msg!(StatusContent: StatusDecorators, Pickup); transit_to_aries_msg!(StatusRequestContent: StatusRequestDecorators, Pickup); transit_to_aries_msg!(DeliveryContent: DeliveryDecorators, Pickup); transit_to_aries_msg!(DeliveryRequestContent: DeliveryRequestDecorators, Pickup); transit_to_aries_msg!(MessagesReceivedContent: MessagesReceivedDecorators, Pickup); transit_to_aries_msg!(LiveDeliveryChangeContent: LiveDeliveryChangeDecorators, Pickup); into_msg_with_type!(Status, PickupTypeV2_0, Status); into_msg_with_type!(StatusRequest, PickupTypeV2_0, StatusRequest); into_msg_with_type!(Delivery, PickupTypeV2_0, Delivery); into_msg_with_type!(DeliveryRequest, PickupTypeV2_0, DeliveryRequest); into_msg_with_type!(MessagesReceived, PickupTypeV2_0, MessagesReceived); into_msg_with_type!(LiveDeliveryChange, PickupTypeV2_0, LiveDeliveryChange);
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/pickup/live_delivery_change.rs
aries/messages/src/msg_fields/protocols/pickup/live_delivery_change.rs
use serde::{Deserialize, Serialize}; use typed_builder::TypedBuilder; use crate::{ decorators::{thread::Thread, transport::Transport}, msg_parts::MsgParts, }; pub type LiveDeliveryChange = MsgParts<LiveDeliveryChangeContent, LiveDeliveryChangeDecorators>; #[derive(Clone, Debug, Deserialize, Serialize, Default, PartialEq, TypedBuilder)] pub struct LiveDeliveryChangeContent { pub live_delivery: bool, } #[derive(Clone, Debug, Deserialize, Serialize, Default, PartialEq, TypedBuilder)] pub struct LiveDeliveryChangeDecorators { #[builder(default, setter(strip_option))] #[serde(rename = "~transport")] #[serde(skip_serializing_if = "Option::is_none")] pub transport: Option<Transport>, #[builder(default, setter(strip_option))] #[serde(rename = "~thread")] #[serde(skip_serializing_if = "Option::is_none")] pub thread: Option<Thread>, } #[cfg(test)] #[allow(clippy::field_reassign_with_default)] mod tests { use serde_json::json; use super::*; use crate::{misc::test_utils, msg_types::protocols::pickup::PickupTypeV2_0}; #[test] fn test_live_delivery_change() { let expected = json!( { "@type": "https://didcomm.org/messagepickup/2.0/live-delivery-change", "live_delivery": true } ); let content = LiveDeliveryChangeContent::builder() .live_delivery(true) .build(); let decorators = LiveDeliveryChangeDecorators::builder().build(); test_utils::test_msg( content, decorators, PickupTypeV2_0::LiveDeliveryChange, expected, ); } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/trust_ping/ping.rs
aries/messages/src/msg_fields/protocols/trust_ping/ping.rs
use serde::{Deserialize, Serialize}; use typed_builder::TypedBuilder; use crate::{ decorators::{thread::Thread, timing::Timing}, msg_parts::MsgParts, }; pub type Ping = MsgParts<PingContent, PingDecorators>; #[derive(Clone, Debug, Deserialize, Serialize, Default, PartialEq, TypedBuilder)] pub struct PingContent { #[builder(default)] #[serde(default)] pub response_requested: bool, #[builder(default, setter(strip_option))] #[serde(skip_serializing_if = "Option::is_none")] pub comment: Option<String>, } #[derive(Clone, Debug, Deserialize, Serialize, Default, PartialEq, TypedBuilder)] pub struct PingDecorators { #[builder(default, setter(strip_option))] #[serde(rename = "~thread")] #[serde(skip_serializing_if = "Option::is_none")] pub thread: Option<Thread>, #[builder(default, setter(strip_option))] #[serde(rename = "~timing")] #[serde(skip_serializing_if = "Option::is_none")] pub timing: Option<Timing>, } #[cfg(test)] #[allow(clippy::field_reassign_with_default)] mod tests { use serde_json::json; use super::*; use crate::{ decorators::thread::tests::make_extended_thread, misc::test_utils, msg_types::trust_ping::TrustPingTypeV1_0, }; #[test] fn test_minimal_ping() { let content = PingContent::default(); let decorators = PingDecorators::default(); let expected = json!({ "response_requested": false, }); test_utils::test_msg(content, decorators, TrustPingTypeV1_0::Ping, expected); } #[test] fn test_extended_ping() { let content = PingContent::builder() .comment("test_comment".to_owned()) .build(); let decorators = PingDecorators::builder() .thread(make_extended_thread()) .build(); let expected = json!({ "response_requested": false, "comment": content.comment, "~thread": decorators.thread }); test_utils::test_msg(content, decorators, TrustPingTypeV1_0::Ping, expected); } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/trust_ping/ping_response.rs
aries/messages/src/msg_fields/protocols/trust_ping/ping_response.rs
use serde::{Deserialize, Serialize}; use typed_builder::TypedBuilder; use crate::{ decorators::{thread::Thread, timing::Timing}, msg_parts::MsgParts, }; pub type PingResponse = MsgParts<PingResponseContent, PingResponseDecorators>; #[derive(Clone, Debug, Deserialize, Serialize, Default, PartialEq, TypedBuilder)] pub struct PingResponseContent { #[builder(default, setter(strip_option))] #[serde(skip_serializing_if = "Option::is_none")] pub comment: Option<String>, } #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, TypedBuilder)] pub struct PingResponseDecorators { #[serde(rename = "~thread")] pub thread: Thread, #[builder(default, setter(strip_option))] #[serde(rename = "~timing")] #[serde(skip_serializing_if = "Option::is_none")] pub timing: Option<Timing>, } #[cfg(test)] #[allow(clippy::field_reassign_with_default)] mod tests { use serde_json::json; use super::*; use crate::{ decorators::{thread::tests::make_extended_thread, timing::tests::make_extended_timing}, misc::test_utils, msg_types::trust_ping::TrustPingTypeV1_0, }; #[test] fn test_minimal_ping_response() { let content = PingResponseContent::default(); let decorators = PingResponseDecorators::builder() .thread(make_extended_thread()) .build(); let expected = json!({ "~thread": decorators.thread }); test_utils::test_msg( content, decorators, TrustPingTypeV1_0::PingResponse, expected, ); } #[test] fn test_extended_ping_response() { let content = PingResponseContent::builder() .comment("test_comment".to_owned()) .build(); let decorators = PingResponseDecorators::builder() .thread(make_extended_thread()) .timing(make_extended_timing()) .build(); let expected = json!({ "comment": content.comment, "~thread": decorators.thread, "~timing": decorators.timing }); test_utils::test_msg( content, decorators, TrustPingTypeV1_0::PingResponse, expected, ); } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/trust_ping/mod.rs
aries/messages/src/msg_fields/protocols/trust_ping/mod.rs
//! Module containing the `trust ping` protocol messages, as defined in the [RFC](<https://github.com/decentralized-identity/aries-rfcs/blob/main/features/0048-trust-ping/README.md>). pub mod ping; pub mod ping_response; use derive_more::From; use serde::{de::Error, Deserialize, Deserializer, Serialize, Serializer}; use self::{ ping::{Ping, PingContent, PingDecorators}, ping_response::{PingResponse, PingResponseContent, PingResponseDecorators}, }; use crate::{ misc::utils::{into_msg_with_type, transit_to_aries_msg}, msg_fields::traits::DelayedSerde, msg_types::{ protocols::trust_ping::{ TrustPingType as TrustPingKind, TrustPingTypeV1, TrustPingTypeV1_0, }, MsgWithType, }, }; #[derive(Clone, Debug, From, PartialEq)] pub enum TrustPing { Ping(Ping), PingResponse(PingResponse), } impl DelayedSerde for TrustPing { type MsgType<'a> = (TrustPingKind, &'a str); fn delayed_deserialize<'de, D>( msg_type: Self::MsgType<'de>, deserializer: D, ) -> Result<Self, D::Error> where D: Deserializer<'de>, { let (protocol, kind_str) = msg_type; let kind = match protocol { TrustPingKind::V1(TrustPingTypeV1::V1_0(kind)) => kind.kind_from_str(kind_str), }; match kind.map_err(D::Error::custom)? { TrustPingTypeV1_0::Ping => Ping::deserialize(deserializer).map(From::from), TrustPingTypeV1_0::PingResponse => { PingResponse::deserialize(deserializer).map(From::from) } } } fn delayed_serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: Serializer, { match self { Self::Ping(v) => MsgWithType::from(v).serialize(serializer), Self::PingResponse(v) => MsgWithType::from(v).serialize(serializer), } } } transit_to_aries_msg!(PingContent: PingDecorators, TrustPing); transit_to_aries_msg!(PingResponseContent: PingResponseDecorators, TrustPing); into_msg_with_type!(Ping, TrustPingTypeV1_0, Ping); into_msg_with_type!(PingResponse, TrustPingTypeV1_0, PingResponse);
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/notification/problem_report.rs
aries/messages/src/msg_fields/protocols/notification/problem_report.rs
use serde::{Deserialize, Serialize}; use typed_builder::TypedBuilder; use crate::{ msg_fields::protocols::report_problem::{ ProblemReport, ProblemReportContent, ProblemReportDecorators, }, msg_parts::MsgParts, }; pub type NotificationProblemReport = MsgParts<NotificationProblemReportContent, ProblemReportDecorators>; #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, TypedBuilder)] #[serde(transparent)] pub struct NotificationProblemReportContent { pub inner: ProblemReportContent, } impl From<ProblemReportContent> for NotificationProblemReportContent { fn from(value: ProblemReportContent) -> Self { Self { inner: value } } } impl From<NotificationProblemReport> for ProblemReport { fn from(value: NotificationProblemReport) -> Self { Self::builder() .id(value.id) .content(value.content.inner) .decorators(value.decorators) .build() } } #[cfg(test)] #[allow(clippy::field_reassign_with_default)] mod tests { use std::collections::HashMap; use serde_json::json; use super::*; use crate::{ decorators::{ localization::tests::make_extended_field_localization, thread::tests::make_extended_thread, timing::tests::make_extended_timing, }, misc::test_utils, msg_fields::protocols::report_problem::{ Description, Impact, Where, WhereParty, WhoRetries, }, msg_types::notification::NotificationTypeV1_0, }; #[test] fn test_minimal_problem_report() { let description = Description::builder() .code("test_problem_report_code".to_owned()) .build(); let content: NotificationProblemReportContent = ProblemReportContent::builder() .description(description) .build(); let decorators = ProblemReportDecorators::default(); let expected = json!({ "description": content.inner.description }); test_utils::test_msg( content, decorators, NotificationTypeV1_0::ProblemReport, expected, ); } #[test] fn test_extended_problem_report() { let description = Description::builder() .code("test_problem_report_code".to_owned()) .build(); let content: ProblemReportContent = ProblemReportContent::builder() .description(description) .who_retries(WhoRetries::Me) .fix_hint("test_fix_hint".to_owned()) .impact(Impact::Connection) .location(Where::new(WhereParty::Me, "test_location".to_owned())) .noticed_time("test_noticed_time".to_owned()) .tracking_uri("https://dummy.dummy/dummy".parse().unwrap()) .escalation_uri("https://dummy.dummy/dummy".parse().unwrap()) .problem_items(vec![HashMap::from([( "test_prob_item_key".to_owned(), "test_prob_item_value".to_owned(), )])]) .build(); let decorators = ProblemReportDecorators::builder() .thread(make_extended_thread()) .timing(make_extended_timing()) .description_locale(make_extended_field_localization()) .fix_hint_locale(make_extended_field_localization()) .build(); let expected = json!({ "description": content.description, "who_retries": content.who_retries, "fix-hint": content.fix_hint, "impact": content.impact, "where": content.location, "noticed_time": content.noticed_time, "tracking-uri": content.tracking_uri, "escalation-uri": content.escalation_uri, "problem_items": content.problem_items, "~thread": decorators.thread, "~timing": decorators.timing, "description~l10n": decorators.description_locale, "fix-hint~l10n": decorators.fix_hint_locale }); let content = NotificationProblemReportContent::builder() .inner(content) .build(); test_utils::test_msg( content, decorators, NotificationTypeV1_0::ProblemReport, expected, ); } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/notification/ack.rs
aries/messages/src/msg_fields/protocols/notification/ack.rs
use serde::{Deserialize, Serialize}; use typed_builder::TypedBuilder; use crate::{ decorators::{thread::Thread, timing::Timing}, msg_parts::MsgParts, }; pub type Ack = MsgParts<AckContent, AckDecorators>; #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, TypedBuilder)] #[builder(build_method(into))] pub struct AckContent { pub status: AckStatus, } #[derive(Debug, Clone, Copy, Serialize, Deserialize, PartialEq)] #[serde(rename_all = "UPPERCASE")] pub enum AckStatus { Ok, Pending, } #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, TypedBuilder)] pub struct AckDecorators { #[serde(rename = "~thread")] pub thread: Thread, #[builder(default, setter(strip_option))] #[serde(rename = "~timing")] #[serde(skip_serializing_if = "Option::is_none")] pub timing: Option<Timing>, } #[cfg(test)] #[allow(clippy::field_reassign_with_default)] mod tests { use serde_json::json; use super::*; use crate::{ decorators::{thread::tests::make_extended_thread, timing::tests::make_extended_timing}, misc::test_utils, msg_types::notification::NotificationTypeV1_0, }; #[test] fn test_minimal_ack() { let content: AckContent = AckContent::builder().status(AckStatus::Ok).build(); let decorators = AckDecorators::builder() .thread(make_extended_thread()) .build(); let expected = json!({ "status": content.status, "~thread": decorators.thread }); test_utils::test_msg(content, decorators, NotificationTypeV1_0::Ack, expected); } #[test] fn test_extended_ack() { let content: AckContent = AckContent::builder().status(AckStatus::Ok).build(); let decorators = AckDecorators::builder() .thread(make_extended_thread()) .timing(make_extended_timing()) .build(); let expected = json!({ "status": content.status, "~thread": decorators.thread, "~timing": decorators.timing }); test_utils::test_msg(content, decorators, NotificationTypeV1_0::Ack, expected); } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/notification/mod.rs
aries/messages/src/msg_fields/protocols/notification/mod.rs
//! Module containing the `acks` messages, as defined in the [RFC](<https://github.com/decentralized-identity/aries-rfcs/blob/main/features/0015-acks/README.md>). pub mod ack; pub mod problem_report; use derive_more::From; use serde::{de::Error, Deserialize, Deserializer, Serialize, Serializer}; use self::{ ack::{Ack, AckContent, AckDecorators}, problem_report::{NotificationProblemReport, NotificationProblemReportContent}, }; use super::report_problem::ProblemReportDecorators; use crate::{ misc::utils::{into_msg_with_type, transit_to_aries_msg}, msg_fields::traits::DelayedSerde, msg_types::{ notification::{NotificationType, NotificationTypeV1, NotificationTypeV1_0}, MsgWithType, }, }; #[derive(Clone, Debug, From, PartialEq)] pub enum Notification { Ack(Ack), ProblemReport(NotificationProblemReport), } impl DelayedSerde for Notification { type MsgType<'a> = (NotificationType, &'a str); fn delayed_deserialize<'de, D>( msg_type: Self::MsgType<'de>, deserializer: D, ) -> Result<Self, D::Error> where D: Deserializer<'de>, { let (protocol, kind_str) = msg_type; let kind = match protocol { NotificationType::V1(NotificationTypeV1::V1_0(kind)) => kind.kind_from_str(kind_str), }; match kind.map_err(D::Error::custom)? { NotificationTypeV1_0::Ack => Ack::deserialize(deserializer).map(From::from), NotificationTypeV1_0::ProblemReport => { NotificationProblemReport::deserialize(deserializer).map(From::from) } } } fn delayed_serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: Serializer, { match self { Self::Ack(v) => MsgWithType::from(v).serialize(serializer), Self::ProblemReport(v) => MsgWithType::from(v).serialize(serializer), } } } transit_to_aries_msg!(AckContent: AckDecorators, Notification); transit_to_aries_msg!( NotificationProblemReportContent: ProblemReportDecorators, Notification ); into_msg_with_type!(Ack, NotificationTypeV1_0, Ack); into_msg_with_type!( NotificationProblemReport, NotificationTypeV1_0, ProblemReport );
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/connection/response.rs
aries/messages/src/msg_fields/protocols/connection/response.rs
use serde::{Deserialize, Serialize}; use shared::misc::utils::CowStr; use typed_builder::TypedBuilder; use crate::{ decorators::{please_ack::PleaseAck, thread::Thread, timing::Timing}, msg_parts::MsgParts, msg_types::{ protocols::signature::{SignatureType, SignatureTypeV1, SignatureTypeV1_0}, traits::MessageKind, MessageType, Protocol, }, }; pub type Response = MsgParts<ResponseContent, ResponseDecorators>; #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, TypedBuilder)] pub struct ResponseContent { #[serde(rename = "connection~sig")] pub connection_sig: ConnectionSignature, } #[derive(Debug, Deserialize, Serialize, Clone, PartialEq)] pub struct ConnectionSignature { #[serde(rename = "@type")] msg_type: SigEd25519Sha512Single, pub signature: String, pub sig_data: String, pub signer: String, } impl ConnectionSignature { pub fn new(signature: String, sig_data: String, signer: String) -> Self { Self { msg_type: SigEd25519Sha512Single, signature, sig_data, signer, } } } #[derive(Debug, Deserialize, Serialize, Clone, PartialEq, TypedBuilder)] pub struct ResponseDecorators { #[serde(rename = "~thread")] pub thread: Thread, #[builder(default, setter(strip_option))] #[serde(rename = "~please_ack")] #[serde(skip_serializing_if = "Option::is_none")] pub please_ack: Option<PleaseAck>, #[builder(default, setter(strip_option))] #[serde(rename = "~timing")] #[serde(skip_serializing_if = "Option::is_none")] pub timing: Option<Timing>, } /// Non-standalone message type. /// This is only encountered as part of an existent message. /// It is not a message on it's own. #[derive(Copy, Clone, Debug, Deserialize, Default, PartialEq)] #[serde(try_from = "CowStr")] struct SigEd25519Sha512Single; impl<'a> From<&'a SigEd25519Sha512Single> for SignatureTypeV1_0 { fn from(_value: &'a SigEd25519Sha512Single) -> Self { SignatureTypeV1_0::Ed25519Sha512Single } } impl<'a> TryFrom<CowStr<'a>> for SigEd25519Sha512Single { type Error = String; fn try_from(value: CowStr<'a>) -> Result<Self, Self::Error> { let value = MessageType::try_from(value.0.as_ref())?; if let Protocol::SignatureType(SignatureType::V1(SignatureTypeV1::V1_0(kind))) = value.protocol { if let Ok(SignatureTypeV1_0::Ed25519Sha512Single) = kind.kind_from_str(value.kind) { return Ok(SigEd25519Sha512Single); } } Err(format!("message kind is not {}", value.kind)) } } impl Serialize for SigEd25519Sha512Single { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, { let protocol = Protocol::from(SignatureTypeV1_0::parent()); let kind = SignatureTypeV1_0::from(self); format_args!("{protocol}/{}", kind.as_ref()).serialize(serializer) } } #[cfg(test)] #[allow(clippy::field_reassign_with_default)] mod tests { use serde_json::json; use super::*; use crate::{ decorators::{ please_ack::tests::make_minimal_please_ack, thread::tests::make_extended_thread, timing::tests::make_extended_timing, }, misc::test_utils, msg_types::connection::ConnectionTypeV1_0, }; #[test] fn test_minimal_conn_response() { let conn_sig = ConnectionSignature::new( "test_signature".to_owned(), "test_sig_data".to_owned(), "test_signer".to_owned(), ); let content = ResponseContent::builder().connection_sig(conn_sig).build(); let decorators = ResponseDecorators::builder() .thread(make_extended_thread()) .build(); let expected = json!({ "connection~sig": content.connection_sig, "~thread": decorators.thread }); test_utils::test_msg(content, decorators, ConnectionTypeV1_0::Response, expected); } #[test] fn test_extended_conn_response() { let conn_sig = ConnectionSignature::new( "test_signature".to_owned(), "test_sig_data".to_owned(), "test_signer".to_owned(), ); let content = ResponseContent::builder().connection_sig(conn_sig).build(); let decorators = ResponseDecorators::builder() .thread(make_extended_thread()) .timing(make_extended_timing()) .please_ack(make_minimal_please_ack()) .build(); let expected = json!({ "connection~sig": content.connection_sig, "~thread": decorators.thread, "~timing": decorators.timing, "~please_ack": decorators.please_ack }); test_utils::test_msg(content, decorators, ConnectionTypeV1_0::Response, expected); } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/connection/problem_report.rs
aries/messages/src/msg_fields/protocols/connection/problem_report.rs
use serde::{Deserialize, Serialize}; use typed_builder::TypedBuilder; use crate::{ decorators::{localization::MsgLocalization, thread::Thread, timing::Timing}, msg_parts::MsgParts, }; pub type ProblemReport = MsgParts<ProblemReportContent, ProblemReportDecorators>; #[derive(Clone, Debug, Deserialize, Serialize, Default, PartialEq, TypedBuilder)] pub struct ProblemReportContent { #[builder(default, setter(strip_option))] #[serde(rename = "problem-code")] #[serde(skip_serializing_if = "Option::is_none")] pub problem_code: Option<ProblemCode>, #[builder(default, setter(strip_option))] #[serde(skip_serializing_if = "Option::is_none")] pub explain: Option<String>, } #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] #[serde(rename_all = "snake_case")] pub enum ProblemCode { RequestNotAccepted, RequestProcessingError, ResponseNotAccepted, ResponseProcessingError, } #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, TypedBuilder)] pub struct ProblemReportDecorators { #[serde(rename = "~thread")] pub thread: Thread, #[builder(default, setter(strip_option))] #[serde(rename = "~l10n")] #[serde(skip_serializing_if = "Option::is_none")] pub localization: Option<MsgLocalization>, #[builder(default, setter(strip_option))] #[serde(rename = "~timing")] #[serde(skip_serializing_if = "Option::is_none")] pub timing: Option<Timing>, } #[cfg(test)] #[allow(clippy::field_reassign_with_default)] mod tests { use serde_json::json; use super::*; use crate::{ decorators::{ localization::tests::make_extended_msg_localization, thread::tests::make_extended_thread, timing::tests::make_extended_timing, }, misc::test_utils, msg_types::connection::ConnectionTypeV1_0, }; #[test] fn test_minimal_conn_problem_report() { let content = ProblemReportContent::default(); let decorators = ProblemReportDecorators::builder() .thread(make_extended_thread()) .build(); let expected = json!({ "~thread": decorators.thread }); test_utils::test_msg( content, decorators, ConnectionTypeV1_0::ProblemReport, expected, ); } #[test] fn test_extended_conn_problem_report() { let content = ProblemReportContent::builder() .problem_code(ProblemCode::RequestNotAccepted) .explain("test_conn_problem_report_explain".to_owned()) .build(); let decorators = ProblemReportDecorators::builder() .thread(make_extended_thread()) .timing(make_extended_timing()) .localization(make_extended_msg_localization()) .build(); let expected = json!({ "problem-code": content.problem_code, "explain": content.explain, "~thread": decorators.thread, "~timing": decorators.timing, "~l10n": decorators.localization }); test_utils::test_msg( content, decorators, ConnectionTypeV1_0::ProblemReport, expected, ); } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/connection/mod.rs
aries/messages/src/msg_fields/protocols/connection/mod.rs
//! Module containing the `connection` protocol messages, as defined in the [RFC](<https://github.com/decentralized-identity/aries-rfcs/blob/main/features/0160-connection-protocol/README.md>). pub mod invitation; pub mod problem_report; pub mod request; pub mod response; use derive_more::From; use diddoc_legacy::aries::diddoc::AriesDidDoc; use serde::{de::Error, Deserialize, Deserializer, Serialize, Serializer}; use self::{ invitation::{Invitation, InvitationContent, InvitationDecorators}, problem_report::{ProblemReport, ProblemReportContent, ProblemReportDecorators}, request::{Request, RequestContent, RequestDecorators}, response::{Response, ResponseContent, ResponseDecorators}, }; use crate::{ misc::utils::{into_msg_with_type, transit_to_aries_msg}, msg_fields::traits::DelayedSerde, msg_types::{ protocols::connection::{ ConnectionType as ConnectionKind, ConnectionTypeV1, ConnectionTypeV1_0, }, MsgWithType, }, }; #[derive(Clone, Debug, From, PartialEq)] pub enum Connection { Invitation(Invitation), Request(Request), Response(Response), ProblemReport(ProblemReport), } impl DelayedSerde for Connection { type MsgType<'a> = (ConnectionKind, &'a str); fn delayed_deserialize<'de, D>( msg_type: Self::MsgType<'de>, deserializer: D, ) -> Result<Self, D::Error> where D: Deserializer<'de>, { let (protocol, kind_str) = msg_type; let kind = match protocol { ConnectionKind::V1(ConnectionTypeV1::V1_0(kind)) => kind.kind_from_str(kind_str), }; match kind.map_err(D::Error::custom)? { ConnectionTypeV1_0::Invitation => Invitation::deserialize(deserializer).map(From::from), ConnectionTypeV1_0::Request => Request::deserialize(deserializer).map(From::from), ConnectionTypeV1_0::Response => Response::deserialize(deserializer).map(From::from), ConnectionTypeV1_0::ProblemReport => { ProblemReport::deserialize(deserializer).map(From::from) } } } fn delayed_serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: Serializer, { match self { Self::Invitation(v) => MsgWithType::from(v).serialize(serializer), Self::Request(v) => MsgWithType::from(v).serialize(serializer), Self::Response(v) => MsgWithType::from(v).serialize(serializer), Self::ProblemReport(v) => MsgWithType::from(v).serialize(serializer), } } } #[derive(Debug, Deserialize, Serialize, Clone, PartialEq)] pub struct ConnectionData { #[serde(rename = "DID")] pub did: String, #[serde(rename = "DIDDoc")] pub did_doc: AriesDidDoc, } impl ConnectionData { pub fn new(did: String, did_doc: AriesDidDoc) -> Self { Self { did, did_doc } } } transit_to_aries_msg!(InvitationContent: InvitationDecorators, Connection); transit_to_aries_msg!(RequestContent: RequestDecorators, Connection); transit_to_aries_msg!(ResponseContent: ResponseDecorators, Connection); transit_to_aries_msg!(ProblemReportContent: ProblemReportDecorators, Connection); into_msg_with_type!(Invitation, ConnectionTypeV1_0, Invitation); into_msg_with_type!(Request, ConnectionTypeV1_0, Request); into_msg_with_type!(Response, ConnectionTypeV1_0, Response); into_msg_with_type!(ProblemReport, ConnectionTypeV1_0, ProblemReport);
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/connection/request.rs
aries/messages/src/msg_fields/protocols/connection/request.rs
use serde::{Deserialize, Serialize}; use typed_builder::TypedBuilder; use super::ConnectionData; use crate::{ decorators::{thread::Thread, timing::Timing}, msg_parts::MsgParts, }; pub type Request = MsgParts<RequestContent, RequestDecorators>; #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, TypedBuilder)] pub struct RequestContent { pub label: String, pub connection: ConnectionData, } #[derive(Clone, Debug, Deserialize, Serialize, Default, PartialEq, TypedBuilder)] pub struct RequestDecorators { #[builder(default, setter(strip_option))] #[serde(rename = "~thread")] #[serde(skip_serializing_if = "Option::is_none")] pub thread: Option<Thread>, #[builder(default, setter(strip_option))] #[serde(rename = "~timing")] #[serde(skip_serializing_if = "Option::is_none")] pub timing: Option<Timing>, } #[cfg(test)] #[allow(clippy::field_reassign_with_default)] mod tests { use diddoc_legacy::aries::diddoc::AriesDidDoc; use serde_json::json; use super::*; use crate::{ decorators::{thread::tests::make_extended_thread, timing::tests::make_extended_timing}, misc::test_utils, msg_types::connection::ConnectionTypeV1_0, }; #[test] fn test_minimal_conn_request() { let did_doc = AriesDidDoc::default(); // We really need to improve this creation. let conn_data = ConnectionData::new("test_did".to_owned(), did_doc); let content = RequestContent::builder() .label("test_request_label".to_owned()) .connection(conn_data) .build(); let decorators = RequestDecorators::default(); let expected = json!({ "label": content.label, "connection": content.connection }); test_utils::test_msg(content, decorators, ConnectionTypeV1_0::Request, expected); } #[test] fn test_extended_conn_request() { let did_doc = AriesDidDoc::default(); // We really need to improve this creation. let conn_data = ConnectionData::new("test_did".to_owned(), did_doc); let content = RequestContent::builder() .label("test_request_label".to_owned()) .connection(conn_data) .build(); let decorators = RequestDecorators::builder() .thread(make_extended_thread()) .timing(make_extended_timing()) .build(); let expected = json!({ "label": content.label, "connection": content.connection, "~thread": decorators.thread, "~timing": decorators.timing }); test_utils::test_msg(content, decorators, ConnectionTypeV1_0::Request, expected); } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/connection/invitation/pairwise.rs
aries/messages/src/msg_fields/protocols/connection/invitation/pairwise.rs
use did_parser_nom::Did; use serde::{Deserialize, Serialize}; use typed_builder::TypedBuilder; use url::Url; use super::InvitationContent; pub type PairwiseInvitationContent = PwInvitationContent<Url>; pub type PairwiseDidInvitationContent = PwInvitationContent<Did>; #[derive(Debug, Clone, Deserialize, Serialize, PartialEq, TypedBuilder)] #[serde(rename_all = "camelCase")] #[builder(build_method(vis="", name=__build))] #[builder(builder_type(vis = "pub"))] pub struct PwInvitationContent<T> { pub label: String, pub recipient_keys: Vec<String>, #[builder(default)] #[serde(default)] pub routing_keys: Vec<String>, pub service_endpoint: T, } #[allow(dead_code, non_camel_case_types, missing_docs)] impl<T, __routing_keys: ::typed_builder::Optional<Vec<String>>> PwInvitationContentBuilder<T, ((String,), (Vec<String>,), __routing_keys, (T,))> where PwInvitationContent<T>: Into<InvitationContent>, { #[allow(clippy::default_trait_access)] pub fn build(self) -> InvitationContent { self.__build().into() } } #[cfg(test)] #[allow(clippy::field_reassign_with_default)] mod tests { use serde_json::json; use super::*; use crate::{ decorators::timing::tests::make_extended_timing, misc::test_utils, msg_fields::protocols::connection::invitation::InvitationDecorators, msg_types::connection::ConnectionTypeV1_0, }; #[test] fn test_minimal_conn_invite_pw() { let label = "test_pw_invite_label"; let recipient_keys = vec!["test_recipient_key".to_owned()]; let service_endpoint = "https://dummy.dummy/dummy"; let content = InvitationContent::builder_pairwise() .label(label.to_owned()) .recipient_keys(recipient_keys.clone()) .service_endpoint(service_endpoint.parse().unwrap()) .build(); let decorators = InvitationDecorators::default(); let expected = json!({ "label": label, "recipientKeys": recipient_keys, "routingKeys": [], "serviceEndpoint": service_endpoint, }); test_utils::test_msg( content, decorators, ConnectionTypeV1_0::Invitation, expected, ); } #[test] fn test_extended_conn_invite_pw() { let label = "test_pw_invite_label"; let recipient_keys = vec!["test_recipient_key".to_owned()]; let routing_keys = vec!["test_routing_key".to_owned()]; let service_endpoint = "https://dummy.dummy/dummy"; let content = InvitationContent::builder_pairwise() .label(label.to_owned()) .recipient_keys(recipient_keys.clone()) .routing_keys(routing_keys.clone()) .service_endpoint(service_endpoint.parse().unwrap()) .build(); let decorators = InvitationDecorators::builder() .timing(make_extended_timing()) .build(); let expected = json!({ "label": label, "recipientKeys": recipient_keys, "routingKeys": routing_keys, "serviceEndpoint": service_endpoint, "~timing": decorators.timing }); test_utils::test_msg( content, decorators, ConnectionTypeV1_0::Invitation, expected, ); } #[test] fn test_minimal_conn_invite_pw_did() { let label = "test_pw_invite_label"; let recipient_keys = vec!["test_recipient_key".to_owned()]; let service_endpoint = "did:sov:123456789abcdefghi1234"; let content = InvitationContent::builder_pairwise_did() .label(label.to_owned()) .recipient_keys(recipient_keys.clone()) .service_endpoint(service_endpoint.parse().unwrap()) .build(); let decorators = InvitationDecorators::default(); let expected = json!({ "label": label, "recipientKeys": recipient_keys, "routingKeys": [], "serviceEndpoint": service_endpoint, }); test_utils::test_msg( content, decorators, ConnectionTypeV1_0::Invitation, expected, ); } #[test] fn test_extended_conn_invite_pw_did() { let label = "test_pw_invite_label"; let recipient_keys = vec!["test_recipient_key".to_owned()]; let routing_keys = vec!["test_routing_key".to_owned()]; let service_endpoint = "did:sov:123456789abcdefghi1234"; let content = InvitationContent::builder_pairwise_did() .label(label.to_owned()) .recipient_keys(recipient_keys.clone()) .routing_keys(routing_keys.clone()) .service_endpoint(service_endpoint.parse().unwrap()) .build(); let decorators = InvitationDecorators::builder() .timing(make_extended_timing()) .build(); let expected = json!({ "label": label, "recipientKeys": recipient_keys, "routingKeys": routing_keys, "serviceEndpoint": service_endpoint, "~timing": decorators.timing }); test_utils::test_msg( content, decorators, ConnectionTypeV1_0::Invitation, expected, ); } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/connection/invitation/mod.rs
aries/messages/src/msg_fields/protocols/connection/invitation/mod.rs
pub mod pairwise; pub mod public; use derive_more::From; use did_parser_nom::Did; use serde::{Deserialize, Serialize}; use typed_builder::TypedBuilder; use url::Url; use self::{pairwise::PwInvitationContentBuilder, public::PublicInvitationContentBuilder}; pub use self::{ pairwise::{PairwiseDidInvitationContent, PairwiseInvitationContent}, public::PublicInvitationContent, }; use crate::{decorators::timing::Timing, msg_parts::MsgParts}; pub type Invitation = MsgParts<InvitationContent, InvitationDecorators>; /// We need another level of enum nesting since /// an invitation can have multiple forms, and this way we /// take advantage of `untagged` deserialization. #[derive(Debug, Clone, From, Deserialize, Serialize, PartialEq)] #[serde(untagged)] pub enum InvitationContent { Public(PublicInvitationContent), PairwiseDID(PairwiseDidInvitationContent), Pairwise(PairwiseInvitationContent), } impl InvitationContent { pub fn builder_public() -> PublicInvitationContentBuilder { PublicInvitationContent::builder() } pub fn builder_pairwise() -> PwInvitationContentBuilder<Url> { PairwiseInvitationContent::builder() } pub fn builder_pairwise_did() -> PwInvitationContentBuilder<Did> { PairwiseDidInvitationContent::builder() } } #[derive(Debug, Clone, Deserialize, Serialize, Default, PartialEq, TypedBuilder)] pub struct InvitationDecorators { #[builder(default, setter(strip_option))] #[serde(rename = "~timing")] #[serde(skip_serializing_if = "Option::is_none")] pub timing: Option<Timing>, }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/connection/invitation/public.rs
aries/messages/src/msg_fields/protocols/connection/invitation/public.rs
use serde::{Deserialize, Serialize}; use typed_builder::TypedBuilder; use super::InvitationContent; #[derive(Debug, Clone, Deserialize, Serialize, PartialEq, TypedBuilder)] #[builder(build_method(into = InvitationContent))] pub struct PublicInvitationContent { pub label: String, pub did: String, } #[cfg(test)] #[allow(clippy::field_reassign_with_default)] mod tests { use serde_json::json; use super::*; use crate::{ decorators::timing::tests::make_extended_timing, misc::test_utils, msg_fields::protocols::connection::invitation::InvitationDecorators, msg_types::connection::ConnectionTypeV1_0, }; #[test] fn test_minimal_conn_invite_public() { let label = "test_label"; let did = "test_did"; let content = InvitationContent::builder_public() .label(label.to_owned()) .did(did.to_owned()) .build(); let expected = json!({ "label": label, "did": did }); let decorators = InvitationDecorators::default(); test_utils::test_msg( content, decorators, ConnectionTypeV1_0::Invitation, expected, ); } #[test] fn test_extended_conn_invite_public() { let label = "test_label"; let did = "test_did"; let content = InvitationContent::builder_public() .label(label.to_owned()) .did(did.to_owned()) .build(); let decorators = InvitationDecorators::builder() .timing(make_extended_timing()) .build(); let expected = json!({ "label": label, "did": did, "~timing": decorators.timing }); test_utils::test_msg( content, decorators, ConnectionTypeV1_0::Invitation, expected, ); } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/common/mod.rs
aries/messages/src/msg_fields/protocols/common/mod.rs
pub mod attachment_format_specifier;
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/common/attachment_format_specifier.rs
aries/messages/src/msg_fields/protocols/common/attachment_format_specifier.rs
use serde::{Deserialize, Serialize}; use shared::maybe_known::MaybeKnown; use typed_builder::TypedBuilder; /// Specifies that a particular Attachment, with the id of `attach_id`, has the format of `format`. #[derive(Debug, Serialize, Deserialize, Clone, PartialEq, TypedBuilder)] #[serde(rename_all = "snake_case")] pub struct AttachmentFormatSpecifier<F> { pub attach_id: String, pub format: MaybeKnown<F>, } /// If `attach_id` is not [None], this specifies that a particular Attachment, with the id of /// `attach_id`, has the format of `format`. If `attach_id` is [None], this structure is used to /// indicate that a particular attachment `format` is supported by the sender of the message. #[derive(Debug, Serialize, Deserialize, Clone, PartialEq, TypedBuilder)] #[serde(rename_all = "snake_case")] pub struct OptionalIdAttachmentFormatSpecifier<F> { #[builder(default)] #[serde(skip_serializing_if = "Option::is_none")] pub attach_id: Option<String>, pub format: MaybeKnown<F>, }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/present_proof/mod.rs
aries/messages/src/msg_fields/protocols/present_proof/mod.rs
use derive_more::From; use self::{v1::PresentProofV1, v2::PresentProofV2}; pub mod v1; pub mod v2; #[derive(Clone, Debug, From, PartialEq)] pub enum PresentProof { V1(PresentProofV1), V2(PresentProofV2), }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/present_proof/v1/propose.rs
aries/messages/src/msg_fields/protocols/present_proof/v1/propose.rs
use std::str::FromStr; use serde::{Deserialize, Serialize}; use shared::misc::utils::CowStr; use typed_builder::TypedBuilder; use crate::{ decorators::{thread::Thread, timing::Timing}, misc::MimeType, msg_parts::MsgParts, msg_types::{ protocols::present_proof::{PresentProofType, PresentProofTypeV1, PresentProofTypeV1_0}, traits::MessageKind, MessageType, Protocol, }, }; pub type ProposePresentationV1 = MsgParts<ProposePresentationV1Content, ProposePresentationV1Decorators>; #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, TypedBuilder)] pub struct ProposePresentationV1Content { #[builder(default, setter(strip_option))] #[serde(skip_serializing_if = "Option::is_none")] pub comment: Option<String>, pub presentation_proposal: PresentationPreview, } #[derive(Clone, Debug, Deserialize, Serialize, Default, PartialEq, TypedBuilder)] pub struct ProposePresentationV1Decorators { #[builder(default, setter(strip_option))] #[serde(rename = "~thread")] #[serde(skip_serializing_if = "Option::is_none")] pub thread: Option<Thread>, #[builder(default, setter(strip_option))] #[serde(rename = "~timing")] #[serde(skip_serializing_if = "Option::is_none")] pub timing: Option<Timing>, } #[derive(Debug, Deserialize, Serialize, Clone, PartialEq)] pub struct PresentationPreview { #[serde(rename = "@type")] msg_type: PresentationPreviewMsgType, pub attributes: Vec<PresentationAttr>, pub predicates: Vec<Predicate>, } impl PresentationPreview { pub fn new(attributes: Vec<PresentationAttr>, predicates: Vec<Predicate>) -> Self { Self { msg_type: PresentationPreviewMsgType, attributes, predicates, } } } /// Non-standalone message type. /// This is only encountered as part of an existent message. /// It is not a message on it's own. #[derive(Copy, Clone, Debug, Default, Deserialize, PartialEq)] #[serde(try_from = "CowStr")] struct PresentationPreviewMsgType; impl<'a> From<&'a PresentationPreviewMsgType> for PresentProofTypeV1_0 { fn from(_value: &'a PresentationPreviewMsgType) -> Self { PresentProofTypeV1_0::PresentationPreview } } impl<'a> TryFrom<CowStr<'a>> for PresentationPreviewMsgType { type Error = String; fn try_from(value: CowStr<'a>) -> Result<Self, Self::Error> { let value = MessageType::try_from(value.0.as_ref())?; if let Protocol::PresentProofType(PresentProofType::V1(PresentProofTypeV1::V1_0(_))) = value.protocol { if let Ok(PresentProofTypeV1_0::PresentationPreview) = PresentProofTypeV1_0::from_str(value.kind) { return Ok(PresentationPreviewMsgType); } } Err(format!("message kind is not {}", value.kind)) } } impl Serialize for PresentationPreviewMsgType { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, { let protocol = Protocol::from(PresentProofTypeV1_0::parent()); let kind = PresentProofTypeV1_0::from(self); format_args!("{protocol}/{}", kind.as_ref()).serialize(serializer) } } #[derive(Debug, Deserialize, Serialize, Clone, PartialEq, TypedBuilder)] pub struct PresentationAttr { pub name: String, #[builder(default, setter(strip_option))] #[serde(skip_serializing_if = "Option::is_none")] pub cred_def_id: Option<String>, #[builder(default, setter(strip_option))] #[serde(skip_serializing_if = "Option::is_none")] #[serde(rename = "mime-type")] pub mime_type: Option<MimeType>, #[builder(default, setter(strip_option))] #[serde(skip_serializing_if = "Option::is_none")] pub value: Option<String>, #[builder(default, setter(strip_option))] #[serde(skip_serializing_if = "Option::is_none")] pub referent: Option<String>, } #[derive(Debug, Deserialize, Serialize, Clone, PartialEq, TypedBuilder)] pub struct Predicate { pub name: String, pub predicate: PredicateOperator, pub threshold: i64, #[builder(default, setter(strip_option))] #[serde(flatten)] pub referent: Option<Referent>, } #[derive(Debug, Deserialize, Serialize, Clone, PartialEq)] pub struct Referent { pub cred_def_id: String, pub referent: String, } impl Referent { pub fn new(cred_def_id: String, referent: String) -> Self { Self { cred_def_id, referent, } } } #[derive(Debug, Deserialize, Serialize, Clone, PartialEq)] pub enum PredicateOperator { #[serde(rename = ">=")] GreaterOrEqual, #[serde(rename = "<=")] LessOrEqual, #[serde(rename = ">")] GreterThan, #[serde(rename = "<")] LessThan, } #[cfg(test)] #[allow(clippy::field_reassign_with_default)] mod tests { use serde_json::json; use super::*; use crate::{ decorators::{thread::tests::make_extended_thread, timing::tests::make_extended_timing}, misc::test_utils, }; #[test] fn test_minimal_propose_proof() { let attribute = PresentationAttr::builder() .name("test_attribute_name".to_owned()) .build(); let predicate = Predicate::builder() .name("test_predicate_name".to_owned()) .predicate(PredicateOperator::GreaterOrEqual) .threshold(1000) .build(); let preview = PresentationPreview::new(vec![attribute], vec![predicate]); let content = ProposePresentationV1Content::builder() .presentation_proposal(preview) .build(); let decorators = ProposePresentationV1Decorators::default(); let expected = json!({ "presentation_proposal": content.presentation_proposal }); test_utils::test_msg( content, decorators, PresentProofTypeV1_0::ProposePresentation, expected, ); } #[test] fn test_extended_propose_proof() { let attribute = PresentationAttr::builder() .name("test_attribute_name".to_owned()) .build(); let predicate = Predicate::builder() .name("test_predicate_name".to_owned()) .predicate(PredicateOperator::GreaterOrEqual) .threshold(1000) .build(); let preview = PresentationPreview::new(vec![attribute], vec![predicate]); let content = ProposePresentationV1Content::builder() .presentation_proposal(preview) .comment("test_comment".to_owned()) .build(); let decorators = ProposePresentationV1Decorators::builder() .thread(make_extended_thread()) .timing(make_extended_timing()) .build(); let expected = json!({ "comment": content.comment, "presentation_proposal": content.presentation_proposal, "~thread": decorators.thread, "~timing": decorators.timing }); test_utils::test_msg( content, decorators, PresentProofTypeV1_0::ProposePresentation, expected, ); } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/present_proof/v1/problem_report.rs
aries/messages/src/msg_fields/protocols/present_proof/v1/problem_report.rs
use serde::{Deserialize, Serialize}; use typed_builder::TypedBuilder; use crate::{ msg_fields::protocols::report_problem::{ ProblemReport, ProblemReportContent, ProblemReportDecorators, }, msg_parts::MsgParts, }; pub type PresentProofV1ProblemReport = MsgParts<PresentProofV1ProblemReportContent, ProblemReportDecorators>; #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, TypedBuilder)] #[serde(transparent)] pub struct PresentProofV1ProblemReportContent { pub inner: ProblemReportContent, } impl From<ProblemReportContent> for PresentProofV1ProblemReportContent { fn from(value: ProblemReportContent) -> Self { Self { inner: value } } } impl From<PresentProofV1ProblemReport> for ProblemReport { fn from(value: PresentProofV1ProblemReport) -> Self { Self::builder() .id(value.id) .content(value.content.inner) .decorators(value.decorators) .build() } } #[cfg(test)] #[allow(clippy::field_reassign_with_default)] mod tests { use std::collections::HashMap; use serde_json::json; use super::*; use crate::{ decorators::{ localization::tests::make_extended_field_localization, thread::tests::make_extended_thread, timing::tests::make_extended_timing, }, misc::test_utils, msg_fields::protocols::report_problem::{ Description, Impact, Where, WhereParty, WhoRetries, }, msg_types::present_proof::PresentProofTypeV1_0, }; #[test] fn test_minimal_problem_report() { let description = Description::builder() .code("test_problem_report_code".to_owned()) .build(); let content: ProblemReportContent = ProblemReportContent::builder() .description(description) .build(); let decorators = ProblemReportDecorators::default(); let expected = json!({ "description": content.description }); let content = PresentProofV1ProblemReportContent::builder() .inner(content) .build(); test_utils::test_msg( content, decorators, PresentProofTypeV1_0::ProblemReport, expected, ); } #[test] fn test_extended_problem_report() { let description = Description::builder() .code("test_problem_report_code".to_owned()) .build(); let content: ProblemReportContent = ProblemReportContent::builder() .description(description) .who_retries(WhoRetries::Me) .fix_hint("test_fix_hint".to_owned()) .impact(Impact::Connection) .location(Where::new(WhereParty::Me, "test_location".to_owned())) .noticed_time("test_noticed_time".to_owned()) .tracking_uri("https://dummy.dummy/dummy".parse().unwrap()) .escalation_uri("https://dummy.dummy/dummy".parse().unwrap()) .problem_items(vec![HashMap::from([( "test_prob_item_key".to_owned(), "test_prob_item_value".to_owned(), )])]) .build(); let decorators = ProblemReportDecorators::builder() .thread(make_extended_thread()) .timing(make_extended_timing()) .description_locale(make_extended_field_localization()) .fix_hint_locale(make_extended_field_localization()) .build(); let expected = json!({ "description": content.description, "who_retries": content.who_retries, "fix-hint": content.fix_hint, "impact": content.impact, "where": content.location, "noticed_time": content.noticed_time, "tracking-uri": content.tracking_uri, "escalation-uri": content.escalation_uri, "problem_items": content.problem_items, "~thread": decorators.thread, "~timing": decorators.timing, "description~l10n": decorators.description_locale, "fix-hint~l10n": decorators.fix_hint_locale }); let content = PresentProofV1ProblemReportContent::builder() .inner(content) .build(); test_utils::test_msg( content, decorators, PresentProofTypeV1_0::ProblemReport, expected, ); } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/present_proof/v1/ack.rs
aries/messages/src/msg_fields/protocols/present_proof/v1/ack.rs
use serde::{Deserialize, Serialize}; use typed_builder::TypedBuilder; use crate::{ msg_fields::protocols::notification::ack::{Ack, AckContent, AckDecorators}, msg_parts::MsgParts, }; pub type AckPresentationV1 = MsgParts<AckPresentationV1Content, AckDecorators>; #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, TypedBuilder)] #[serde(transparent)] pub struct AckPresentationV1Content { pub inner: AckContent, } impl From<AckContent> for AckPresentationV1Content { fn from(value: AckContent) -> Self { Self { inner: value } } } impl From<AckPresentationV1> for Ack { fn from(value: AckPresentationV1) -> Self { Self::builder() .id(value.id) .content(value.content.inner) .decorators(value.decorators) .build() } } #[cfg(test)] #[allow(clippy::field_reassign_with_default)] mod tests { use serde_json::json; use super::*; use crate::{ decorators::{thread::tests::make_extended_thread, timing::tests::make_extended_timing}, misc::test_utils, msg_fields::protocols::notification::ack::AckStatus, msg_types::present_proof::PresentProofTypeV1_0, }; #[test] fn test_minimal_ack_proof() { let content: AckPresentationV1Content = AckContent::builder().status(AckStatus::Ok).build(); let decorators = AckDecorators::builder() .thread(make_extended_thread()) .build(); let expected = json!({ "status": content.inner.status, "~thread": decorators.thread }); test_utils::test_msg(content, decorators, PresentProofTypeV1_0::Ack, expected); } #[test] fn test_extended_ack_proof() { let content: AckPresentationV1Content = AckContent::builder().status(AckStatus::Ok).build(); let decorators = AckDecorators::builder() .thread(make_extended_thread()) .timing(make_extended_timing()) .build(); let expected = json!({ "status": content.inner.status, "~thread": decorators.thread, "~timing": decorators.timing }); test_utils::test_msg(content, decorators, PresentProofTypeV1_0::Ack, expected); } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/present_proof/v1/mod.rs
aries/messages/src/msg_fields/protocols/present_proof/v1/mod.rs
//! Module containing the `present proof` protocol messages, as defined in the [RFC](<https://github.com/decentralized-identity/aries-rfcs/blob/main/features/0037-present-proof/README.md>). pub mod ack; pub mod present; pub mod problem_report; pub mod propose; pub mod request; use derive_more::From; use serde::{de::Error, Deserialize, Deserializer, Serialize, Serializer}; use self::{ ack::{AckPresentationV1, AckPresentationV1Content}, present::{PresentationV1, PresentationV1Content, PresentationV1Decorators}, problem_report::{PresentProofV1ProblemReport, PresentProofV1ProblemReportContent}, propose::{ ProposePresentationV1, ProposePresentationV1Content, ProposePresentationV1Decorators, }, request::{ RequestPresentationV1, RequestPresentationV1Content, RequestPresentationV1Decorators, }, }; use super::PresentProof; use crate::{ misc::utils::{self, into_msg_with_type, transit_to_aries_msg}, msg_fields::{ protocols::{notification::ack::AckDecorators, report_problem::ProblemReportDecorators}, traits::DelayedSerde, }, msg_types::{ protocols::present_proof::{PresentProofType, PresentProofTypeV1, PresentProofTypeV1_0}, MsgWithType, }, }; #[derive(Clone, Debug, From, PartialEq)] pub enum PresentProofV1 { ProposePresentation(ProposePresentationV1), RequestPresentation(RequestPresentationV1), Presentation(PresentationV1), Ack(AckPresentationV1), ProblemReport(PresentProofV1ProblemReport), } impl DelayedSerde for PresentProofV1 { type MsgType<'a> = (PresentProofType, &'a str); fn delayed_deserialize<'de, D>( msg_type: Self::MsgType<'de>, deserializer: D, ) -> Result<Self, D::Error> where D: Deserializer<'de>, { let (protocol, kind_str) = msg_type; let kind = match protocol { PresentProofType::V1(PresentProofTypeV1::V1_0(kind)) => kind.kind_from_str(kind_str), PresentProofType::V2(_) => { return Err(D::Error::custom( "Cannot deserialize present-proof-v2 message type into present-proof-v1", )) } }; match kind.map_err(D::Error::custom)? { PresentProofTypeV1_0::ProposePresentation => { ProposePresentationV1::deserialize(deserializer).map(From::from) } PresentProofTypeV1_0::RequestPresentation => { RequestPresentationV1::deserialize(deserializer).map(From::from) } PresentProofTypeV1_0::Presentation => { PresentationV1::deserialize(deserializer).map(From::from) } PresentProofTypeV1_0::Ack => { AckPresentationV1::deserialize(deserializer).map(From::from) } PresentProofTypeV1_0::ProblemReport => { PresentProofV1ProblemReport::deserialize(deserializer).map(From::from) } PresentProofTypeV1_0::PresentationPreview => { Err(utils::not_standalone_msg::<D>(kind_str)) } } } fn delayed_serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: Serializer, { match self { Self::ProposePresentation(v) => MsgWithType::from(v).serialize(serializer), Self::RequestPresentation(v) => MsgWithType::from(v).serialize(serializer), Self::Presentation(v) => MsgWithType::from(v).serialize(serializer), Self::Ack(v) => MsgWithType::from(v).serialize(serializer), Self::ProblemReport(v) => MsgWithType::from(v).serialize(serializer), } } } transit_to_aries_msg!( ProposePresentationV1Content: ProposePresentationV1Decorators, PresentProofV1, PresentProof ); transit_to_aries_msg!( RequestPresentationV1Content: RequestPresentationV1Decorators, PresentProofV1, PresentProof ); transit_to_aries_msg!(PresentationV1Content: PresentationV1Decorators, PresentProofV1, PresentProof); transit_to_aries_msg!(AckPresentationV1Content: AckDecorators, PresentProofV1, PresentProof); transit_to_aries_msg!( PresentProofV1ProblemReportContent: ProblemReportDecorators, PresentProofV1, PresentProof ); into_msg_with_type!( ProposePresentationV1, PresentProofTypeV1_0, ProposePresentation ); into_msg_with_type!( RequestPresentationV1, PresentProofTypeV1_0, RequestPresentation ); into_msg_with_type!(PresentationV1, PresentProofTypeV1_0, Presentation); into_msg_with_type!(AckPresentationV1, PresentProofTypeV1_0, Ack); into_msg_with_type!( PresentProofV1ProblemReport, PresentProofTypeV1_0, ProblemReport );
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/present_proof/v1/request.rs
aries/messages/src/msg_fields/protocols/present_proof/v1/request.rs
use serde::{Deserialize, Serialize}; use typed_builder::TypedBuilder; use crate::{ decorators::{attachment::Attachment, thread::Thread, timing::Timing}, msg_parts::MsgParts, }; pub type RequestPresentationV1 = MsgParts<RequestPresentationV1Content, RequestPresentationV1Decorators>; #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, TypedBuilder)] pub struct RequestPresentationV1Content { #[builder(default, setter(strip_option))] #[serde(skip_serializing_if = "Option::is_none")] pub comment: Option<String>, #[serde(rename = "request_presentations~attach")] pub request_presentations_attach: Vec<Attachment>, } #[derive(Clone, Debug, Deserialize, Serialize, Default, PartialEq, TypedBuilder)] pub struct RequestPresentationV1Decorators { #[builder(default, setter(strip_option))] #[serde(rename = "~thread")] #[serde(skip_serializing_if = "Option::is_none")] pub thread: Option<Thread>, #[builder(default, setter(strip_option))] #[serde(rename = "~timing")] #[serde(skip_serializing_if = "Option::is_none")] pub timing: Option<Timing>, } #[cfg(test)] #[allow(clippy::field_reassign_with_default)] mod tests { use serde_json::json; use super::*; use crate::{ decorators::{ attachment::tests::make_extended_attachment, thread::tests::make_extended_thread, timing::tests::make_extended_timing, }, misc::test_utils, msg_types::present_proof::PresentProofTypeV1_0, }; #[test] fn test_minimal_request_proof() { let content = RequestPresentationV1Content::builder() .request_presentations_attach(vec![make_extended_attachment()]) .build(); let decorators = RequestPresentationV1Decorators::default(); let expected = json!({ "request_presentations~attach": content.request_presentations_attach, }); test_utils::test_msg( content, decorators, PresentProofTypeV1_0::RequestPresentation, expected, ); } #[test] fn test_extended_request_proof() { let content = RequestPresentationV1Content::builder() .request_presentations_attach(vec![make_extended_attachment()]) .comment("test_comment".to_owned()) .build(); let decorators = RequestPresentationV1Decorators::builder() .thread(make_extended_thread()) .timing(make_extended_timing()) .build(); let expected = json!({ "request_presentations~attach": content.request_presentations_attach, "comment": content.comment, "~thread": decorators.thread, "~timing": decorators.timing }); test_utils::test_msg( content, decorators, PresentProofTypeV1_0::RequestPresentation, expected, ); } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/present_proof/v1/present.rs
aries/messages/src/msg_fields/protocols/present_proof/v1/present.rs
use serde::{Deserialize, Serialize}; use typed_builder::TypedBuilder; use crate::{ decorators::{attachment::Attachment, please_ack::PleaseAck, thread::Thread, timing::Timing}, msg_parts::MsgParts, }; pub type PresentationV1 = MsgParts<PresentationV1Content, PresentationV1Decorators>; #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, TypedBuilder)] pub struct PresentationV1Content { #[builder(default, setter(strip_option))] #[serde(skip_serializing_if = "Option::is_none")] pub comment: Option<String>, #[serde(rename = "presentations~attach")] pub presentations_attach: Vec<Attachment>, } #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, TypedBuilder)] pub struct PresentationV1Decorators { #[serde(rename = "~thread")] pub thread: Thread, #[builder(default, setter(strip_option))] #[serde(rename = "~please_ack")] #[serde(skip_serializing_if = "Option::is_none")] pub please_ack: Option<PleaseAck>, #[builder(default, setter(strip_option))] #[serde(rename = "~timing")] #[serde(skip_serializing_if = "Option::is_none")] pub timing: Option<Timing>, } #[cfg(test)] #[allow(clippy::field_reassign_with_default)] mod tests { use serde_json::json; use super::*; use crate::{ decorators::{ attachment::tests::make_extended_attachment, please_ack::tests::make_minimal_please_ack, thread::tests::make_extended_thread, timing::tests::make_extended_timing, }, misc::test_utils, msg_types::present_proof::PresentProofTypeV1_0, }; #[test] fn test_minimal_present_proof() { let content = PresentationV1Content::builder() .presentations_attach(vec![make_extended_attachment()]) .build(); let decorators = PresentationV1Decorators::builder() .thread(make_extended_thread()) .build(); let expected = json!({ "presentations~attach": content.presentations_attach, "~thread": decorators.thread }); test_utils::test_msg( content, decorators, PresentProofTypeV1_0::Presentation, expected, ); } #[test] fn test_extended_present_proof() { let content = PresentationV1Content::builder() .presentations_attach(vec![make_extended_attachment()]) .comment("test_comment".to_owned()) .build(); let decorators = PresentationV1Decorators::builder() .thread(make_extended_thread()) .timing(make_extended_timing()) .please_ack(make_minimal_please_ack()) .build(); let expected = json!({ "comment": content.comment, "presentations~attach": content.presentations_attach, "~thread": decorators.thread, "~timing": decorators.timing, "~please_ack": decorators.please_ack }); test_utils::test_msg( content, decorators, PresentProofTypeV1_0::Presentation, expected, ); } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/present_proof/v2/propose.rs
aries/messages/src/msg_fields/protocols/present_proof/v2/propose.rs
use serde::{Deserialize, Serialize}; use typed_builder::TypedBuilder; use crate::{ decorators::{attachment::Attachment, thread::Thread, timing::Timing}, msg_fields::protocols::common::attachment_format_specifier::OptionalIdAttachmentFormatSpecifier, msg_parts::MsgParts, }; pub type ProposePresentationV2 = MsgParts<ProposePresentationV2Content, ProposePresentationV2Decorators>; #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, TypedBuilder)] pub struct ProposePresentationV2Content { #[builder(default)] #[serde(skip_serializing_if = "Option::is_none")] pub goal_code: Option<String>, // TODO - spec does not specify what goal codes to use.. #[builder(default)] #[serde(skip_serializing_if = "Option::is_none")] pub comment: Option<String>, pub formats: Vec<OptionalIdAttachmentFormatSpecifier<ProposePresentationAttachmentFormatType>>, #[serde(rename = "proposals~attach", skip_serializing_if = "Option::is_none")] pub proposals_attach: Option<Vec<Attachment>>, } #[derive(Clone, Debug, Deserialize, Serialize, Default, PartialEq, TypedBuilder)] pub struct ProposePresentationV2Decorators { #[builder(default)] #[serde(rename = "~thread")] #[serde(skip_serializing_if = "Option::is_none")] pub thread: Option<Thread>, #[builder(default)] #[serde(rename = "~timing")] #[serde(skip_serializing_if = "Option::is_none")] pub timing: Option<Timing>, } /// Format types derived from Aries RFC Registry: /// https://github.com/decentralized-identity/aries-rfcs/tree/b3a3942ef052039e73cd23d847f42947f8287da2/features/0454-present-proof-v2#propose-attachment-registry #[derive(Clone, Debug, Deserialize, Serialize, PartialEq)] pub enum ProposePresentationAttachmentFormatType { #[serde(rename = "dif/presentation-exchange/definitions@v1.0")] DifPresentationExchangeDefinitions1_0, #[serde(rename = "hlindy/proof-req@v2.0")] HyperledgerIndyProofRequest2_0, #[serde(rename = "anoncreds/proof-request@v1.0")] AnoncredsProofRequest1_0, } #[cfg(test)] #[allow(clippy::field_reassign_with_default)] mod tests { use serde_json::json; use shared::maybe_known::MaybeKnown; use super::*; use crate::{ decorators::{ attachment::tests::make_extended_attachment, thread::tests::make_extended_thread, timing::tests::make_extended_timing, }, misc::test_utils, msg_types::present_proof::PresentProofTypeV2_0, }; #[test] fn test_minimal_propose_proof() { let content = ProposePresentationV2Content::builder() .formats(vec![OptionalIdAttachmentFormatSpecifier { attach_id: None, format: MaybeKnown::Known( ProposePresentationAttachmentFormatType::HyperledgerIndyProofRequest2_0, ), }]) .proposals_attach(None) .build(); let decorators = ProposePresentationV2Decorators::default(); let expected = json!({ "formats": content.formats }); test_utils::test_msg( content, decorators, PresentProofTypeV2_0::ProposePresentation, expected, ); } #[test] fn test_extended_propose_proof() { let content = ProposePresentationV2Content::builder() .formats(vec![OptionalIdAttachmentFormatSpecifier { attach_id: Some("1".to_owned()), format: MaybeKnown::Known( ProposePresentationAttachmentFormatType::HyperledgerIndyProofRequest2_0, ), }]) .proposals_attach(Some(vec![make_extended_attachment()])) .goal_code(Some("goal.goal".to_owned())) .comment(Some("test_comment".to_owned())) .build(); let decorators = ProposePresentationV2Decorators::builder() .thread(Some(make_extended_thread())) .timing(Some(make_extended_timing())) .build(); let expected = json!({ "comment": content.comment, "goal_code": content.goal_code, "formats": content.formats, "proposals~attach": content.proposals_attach, "~thread": decorators.thread, "~timing": decorators.timing }); test_utils::test_msg( content, decorators, PresentProofTypeV2_0::ProposePresentation, expected, ); } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/present_proof/v2/problem_report.rs
aries/messages/src/msg_fields/protocols/present_proof/v2/problem_report.rs
use serde::{Deserialize, Serialize}; use typed_builder::TypedBuilder; use crate::{ msg_fields::protocols::report_problem::{ ProblemReport, ProblemReportContent, ProblemReportDecorators, }, msg_parts::MsgParts, }; pub type PresentProofV2ProblemReport = MsgParts<PresentProofV2ProblemReportContent, ProblemReportDecorators>; #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, TypedBuilder)] #[serde(transparent)] pub struct PresentProofV2ProblemReportContent { pub inner: ProblemReportContent, } impl From<ProblemReportContent> for PresentProofV2ProblemReportContent { fn from(value: ProblemReportContent) -> Self { Self { inner: value } } } impl From<PresentProofV2ProblemReport> for ProblemReport { fn from(value: PresentProofV2ProblemReport) -> Self { Self::builder() .id(value.id) .content(value.content.inner) .decorators(value.decorators) .build() } } #[cfg(test)] #[allow(clippy::field_reassign_with_default)] mod tests { use std::collections::HashMap; use serde_json::json; use super::*; use crate::{ decorators::{ localization::tests::make_extended_field_localization, thread::tests::make_extended_thread, timing::tests::make_extended_timing, }, misc::test_utils, msg_fields::protocols::report_problem::{ Description, Impact, Where, WhereParty, WhoRetries, }, msg_types::present_proof::PresentProofTypeV2_0, }; #[test] fn test_minimal_problem_report() { let description = Description::builder() .code("test_problem_report_code".to_owned()) .build(); let content: ProblemReportContent = ProblemReportContent::builder() .description(description) .build(); let decorators = ProblemReportDecorators::default(); let expected = json!({ "description": content.description }); let content = PresentProofV2ProblemReportContent::builder() .inner(content) .build(); test_utils::test_msg( content, decorators, PresentProofTypeV2_0::ProblemReport, expected, ); } #[test] fn test_extended_problem_report() { let description = Description::builder() .code("test_problem_report_code".to_owned()) .build(); let content: ProblemReportContent = ProblemReportContent::builder() .description(description) .who_retries(WhoRetries::Me) .fix_hint("test_fix_hint".to_owned()) .impact(Impact::Connection) .location(Where::new(WhereParty::Me, "test_location".to_owned())) .noticed_time("test_noticed_time".to_owned()) .tracking_uri("https://dummy.dummy/dummy".parse().unwrap()) .escalation_uri("https://dummy.dummy/dummy".parse().unwrap()) .problem_items(vec![HashMap::from([( "test_prob_item_key".to_owned(), "test_prob_item_value".to_owned(), )])]) .build(); let decorators = ProblemReportDecorators::builder() .thread(make_extended_thread()) .timing(make_extended_timing()) .description_locale(make_extended_field_localization()) .fix_hint_locale(make_extended_field_localization()) .build(); let expected = json!({ "description": content.description, "who_retries": content.who_retries, "fix-hint": content.fix_hint, "impact": content.impact, "where": content.location, "noticed_time": content.noticed_time, "tracking-uri": content.tracking_uri, "escalation-uri": content.escalation_uri, "problem_items": content.problem_items, "~thread": decorators.thread, "~timing": decorators.timing, "description~l10n": decorators.description_locale, "fix-hint~l10n": decorators.fix_hint_locale }); let content = PresentProofV2ProblemReportContent::builder() .inner(content) .build(); test_utils::test_msg( content, decorators, PresentProofTypeV2_0::ProblemReport, expected, ); } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/present_proof/v2/ack.rs
aries/messages/src/msg_fields/protocols/present_proof/v2/ack.rs
use serde::{Deserialize, Serialize}; use typed_builder::TypedBuilder; use crate::{ msg_fields::protocols::notification::ack::{Ack, AckContent, AckDecorators}, msg_parts::MsgParts, }; pub type AckPresentationV2 = MsgParts<AckPresentationV2Content, AckDecorators>; #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, TypedBuilder)] #[serde(transparent)] pub struct AckPresentationV2Content { pub inner: AckContent, } impl From<AckContent> for AckPresentationV2Content { fn from(value: AckContent) -> Self { Self { inner: value } } } impl From<AckPresentationV2> for Ack { fn from(value: AckPresentationV2) -> Self { Self::builder() .id(value.id) .content(value.content.inner) .decorators(value.decorators) .build() } } #[cfg(test)] #[allow(clippy::field_reassign_with_default)] mod tests { use serde_json::json; use super::*; use crate::{ decorators::{thread::tests::make_extended_thread, timing::tests::make_extended_timing}, misc::test_utils, msg_fields::protocols::notification::ack::AckStatus, msg_types::present_proof::PresentProofTypeV2_0, }; #[test] fn test_minimal_ack_proof() { let content: AckPresentationV2Content = AckContent::builder().status(AckStatus::Ok).build(); let decorators = AckDecorators::builder() .thread(make_extended_thread()) .build(); let expected = json!({ "status": content.inner.status, "~thread": decorators.thread }); test_utils::test_msg(content, decorators, PresentProofTypeV2_0::Ack, expected); } #[test] fn test_extended_ack_proof() { let content: AckPresentationV2Content = AckContent::builder().status(AckStatus::Ok).build(); let decorators = AckDecorators::builder() .thread(make_extended_thread()) .timing(make_extended_timing()) .build(); let expected = json!({ "status": content.inner.status, "~thread": decorators.thread, "~timing": decorators.timing }); test_utils::test_msg(content, decorators, PresentProofTypeV2_0::Ack, expected); } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/present_proof/v2/mod.rs
aries/messages/src/msg_fields/protocols/present_proof/v2/mod.rs
//! Module containing the `present proof` protocol messages, as defined in the [RFC](<https://github.com/decentralized-identity/aries-rfcs/blob/main/features/0037-present-proof/README.md>). pub mod ack; pub mod present; pub mod problem_report; pub mod propose; pub mod request; use derive_more::From; use serde::{de::Error, Deserialize, Deserializer, Serialize, Serializer}; use self::{ ack::{AckPresentationV2, AckPresentationV2Content}, present::{PresentationV2, PresentationV2Content, PresentationV2Decorators}, problem_report::{PresentProofV2ProblemReport, PresentProofV2ProblemReportContent}, propose::{ ProposePresentationV2, ProposePresentationV2Content, ProposePresentationV2Decorators, }, request::{ RequestPresentationV2, RequestPresentationV2Content, RequestPresentationV2Decorators, }, }; use super::PresentProof; use crate::{ misc::utils::{self, into_msg_with_type, transit_to_aries_msg}, msg_fields::{ protocols::{notification::ack::AckDecorators, report_problem::ProblemReportDecorators}, traits::DelayedSerde, }, msg_types::{ present_proof::{PresentProofTypeV2, PresentProofTypeV2_0}, protocols::present_proof::PresentProofType, MsgWithType, }, }; #[derive(Clone, Debug, From, PartialEq)] pub enum PresentProofV2 { ProposePresentation(ProposePresentationV2), RequestPresentation(RequestPresentationV2), Presentation(PresentationV2), Ack(AckPresentationV2), ProblemReport(PresentProofV2ProblemReport), } impl DelayedSerde for PresentProofV2 { type MsgType<'a> = (PresentProofType, &'a str); fn delayed_deserialize<'de, D>( msg_type: Self::MsgType<'de>, deserializer: D, ) -> Result<Self, D::Error> where D: Deserializer<'de>, { let (protocol, kind_str) = msg_type; let kind = match protocol { PresentProofType::V2(PresentProofTypeV2::V2_0(kind)) => kind.kind_from_str(kind_str), PresentProofType::V1(_) => { return Err(D::Error::custom( "Cannot deserialize present-proof-v1 message type into present-proof-v2", )) } }; match kind.map_err(D::Error::custom)? { PresentProofTypeV2_0::ProposePresentation => { ProposePresentationV2::deserialize(deserializer).map(From::from) } PresentProofTypeV2_0::RequestPresentation => { RequestPresentationV2::deserialize(deserializer).map(From::from) } PresentProofTypeV2_0::Presentation => { PresentationV2::deserialize(deserializer).map(From::from) } PresentProofTypeV2_0::Ack => { AckPresentationV2::deserialize(deserializer).map(From::from) } PresentProofTypeV2_0::ProblemReport => { PresentProofV2ProblemReport::deserialize(deserializer).map(From::from) } PresentProofTypeV2_0::PresentationPreview => { Err(utils::not_standalone_msg::<D>(kind_str)) } } } fn delayed_serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: Serializer, { match self { Self::ProposePresentation(v) => MsgWithType::from(v).serialize(serializer), Self::RequestPresentation(v) => MsgWithType::from(v).serialize(serializer), Self::Presentation(v) => MsgWithType::from(v).serialize(serializer), Self::Ack(v) => MsgWithType::from(v).serialize(serializer), Self::ProblemReport(v) => MsgWithType::from(v).serialize(serializer), } } } transit_to_aries_msg!( ProposePresentationV2Content: ProposePresentationV2Decorators, PresentProofV2, PresentProof ); transit_to_aries_msg!( RequestPresentationV2Content: RequestPresentationV2Decorators, PresentProofV2, PresentProof ); transit_to_aries_msg!(PresentationV2Content: PresentationV2Decorators, PresentProofV2, PresentProof); transit_to_aries_msg!(AckPresentationV2Content: AckDecorators, PresentProofV2, PresentProof); transit_to_aries_msg!( PresentProofV2ProblemReportContent: ProblemReportDecorators, PresentProofV2, PresentProof ); into_msg_with_type!( ProposePresentationV2, PresentProofTypeV2_0, ProposePresentation ); into_msg_with_type!( RequestPresentationV2, PresentProofTypeV2_0, RequestPresentation ); into_msg_with_type!(PresentationV2, PresentProofTypeV2_0, Presentation); into_msg_with_type!(AckPresentationV2, PresentProofTypeV2_0, Ack); into_msg_with_type!( PresentProofV2ProblemReport, PresentProofTypeV2_0, ProblemReport );
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/present_proof/v2/request.rs
aries/messages/src/msg_fields/protocols/present_proof/v2/request.rs
use serde::{Deserialize, Serialize}; use typed_builder::TypedBuilder; use crate::{ decorators::{attachment::Attachment, thread::Thread, timing::Timing}, msg_fields::protocols::common::attachment_format_specifier::AttachmentFormatSpecifier, msg_parts::MsgParts, }; pub type RequestPresentationV2 = MsgParts<RequestPresentationV2Content, RequestPresentationV2Decorators>; #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, TypedBuilder)] pub struct RequestPresentationV2Content { #[builder(default)] #[serde(skip_serializing_if = "Option::is_none")] pub goal_code: Option<String>, // TODO - spec does not specify what goal codes to use.. #[builder(default)] #[serde(skip_serializing_if = "Option::is_none")] pub comment: Option<String>, #[builder(default)] #[serde(skip_serializing_if = "Option::is_none")] pub will_confirm: Option<bool>, pub formats: Vec<AttachmentFormatSpecifier<PresentationRequestAttachmentFormatType>>, #[serde(rename = "request_presentations~attach")] pub request_presentations_attach: Vec<Attachment>, } #[derive(Clone, Debug, Deserialize, Serialize, Default, PartialEq, TypedBuilder)] pub struct RequestPresentationV2Decorators { #[builder(default)] #[serde(rename = "~thread")] #[serde(skip_serializing_if = "Option::is_none")] pub thread: Option<Thread>, #[builder(default)] #[serde(rename = "~timing")] #[serde(skip_serializing_if = "Option::is_none")] pub timing: Option<Timing>, } /// Format types derived from Aries RFC Registry: /// https://github.com/decentralized-identity/aries-rfcs/tree/b3a3942ef052039e73cd23d847f42947f8287da2/features/0454-present-proof-v2#presentation-request-attachment-registry #[derive(Clone, Debug, Deserialize, Serialize, PartialEq)] pub enum PresentationRequestAttachmentFormatType { #[serde(rename = "hlindy/proof-req@v2.0")] HyperledgerIndyProofRequest2_0, #[serde(rename = "anoncreds/proof-request@v1.0")] AnoncredsProofRequest1_0, #[serde(rename = "dif/presentation-exchange/definitions@v1.0")] DifPresentationExchangeDefinitions1_0, } #[cfg(test)] #[allow(clippy::field_reassign_with_default)] mod tests { use serde_json::json; use shared::maybe_known::MaybeKnown; use super::*; use crate::{ decorators::{ attachment::tests::make_extended_attachment, thread::tests::make_extended_thread, timing::tests::make_extended_timing, }, misc::test_utils, msg_types::present_proof::PresentProofTypeV2_0, }; #[test] fn test_minimal_request_proof() { let content = RequestPresentationV2Content::builder() .formats(vec![AttachmentFormatSpecifier { attach_id: "1".to_owned(), format: MaybeKnown::Known( PresentationRequestAttachmentFormatType::HyperledgerIndyProofRequest2_0, ), }]) .request_presentations_attach(vec![make_extended_attachment()]) .build(); let decorators = RequestPresentationV2Decorators::default(); let expected = json!({ "formats": content.formats, "request_presentations~attach": content.request_presentations_attach, }); test_utils::test_msg( content, decorators, PresentProofTypeV2_0::RequestPresentation, expected, ); } #[test] fn test_extended_request_proof() { let content = RequestPresentationV2Content::builder() .formats(vec![AttachmentFormatSpecifier { attach_id: "1".to_owned(), format: MaybeKnown::Known( PresentationRequestAttachmentFormatType::HyperledgerIndyProofRequest2_0, ), }]) .request_presentations_attach(vec![make_extended_attachment()]) .goal_code(Some("goal.goal".to_owned())) .comment(Some("test_comment".to_owned())) .will_confirm(Some(true)) .build(); let decorators = RequestPresentationV2Decorators::builder() .thread(Some(make_extended_thread())) .timing(Some(make_extended_timing())) .build(); let expected = json!({ "formats": content.formats, "request_presentations~attach": content.request_presentations_attach, "goal_code": content.goal_code, "comment": content.comment, "will_confirm": content.will_confirm, "~thread": decorators.thread, "~timing": decorators.timing }); test_utils::test_msg( content, decorators, PresentProofTypeV2_0::RequestPresentation, expected, ); } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/present_proof/v2/present.rs
aries/messages/src/msg_fields/protocols/present_proof/v2/present.rs
use serde::{Deserialize, Serialize}; use typed_builder::TypedBuilder; use crate::{ decorators::{attachment::Attachment, please_ack::PleaseAck, thread::Thread, timing::Timing}, msg_fields::protocols::common::attachment_format_specifier::AttachmentFormatSpecifier, msg_parts::MsgParts, }; pub type PresentationV2 = MsgParts<PresentationV2Content, PresentationV2Decorators>; #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, TypedBuilder)] pub struct PresentationV2Content { #[builder(default)] #[serde(skip_serializing_if = "Option::is_none")] pub comment: Option<String>, #[builder(default)] #[serde(skip_serializing_if = "Option::is_none")] pub goal_code: Option<String>, pub formats: Vec<AttachmentFormatSpecifier<PresentationAttachmentFormatType>>, #[serde(rename = "presentations~attach")] pub presentations_attach: Vec<Attachment>, } #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, TypedBuilder)] pub struct PresentationV2Decorators { #[serde(rename = "~thread")] pub thread: Thread, #[builder(default, setter(strip_option))] #[serde(rename = "~please_ack")] #[serde(skip_serializing_if = "Option::is_none")] pub please_ack: Option<PleaseAck>, #[builder(default, setter(strip_option))] #[serde(rename = "~timing")] #[serde(skip_serializing_if = "Option::is_none")] pub timing: Option<Timing>, } /// Format types derived from Aries RFC Registry: /// https://github.com/decentralized-identity/aries-rfcs/tree/b3a3942ef052039e73cd23d847f42947f8287da2/features/0454-present-proof-v2#presentations-attachment-registry #[derive(Clone, Debug, Deserialize, Serialize, PartialEq)] pub enum PresentationAttachmentFormatType { #[serde(rename = "hlindy/proof@v2.0")] HyperledgerIndyProof2_0, #[serde(rename = "anoncreds/proof@v1.0")] AnoncredsProof1_0, #[serde(rename = "dif/presentation-exchange/submission@v1.0")] DifPresentationExchangeSubmission1_0, } #[cfg(test)] #[allow(clippy::field_reassign_with_default)] mod tests { use serde_json::json; use shared::maybe_known::MaybeKnown; use super::*; use crate::{ decorators::{ attachment::tests::make_extended_attachment, please_ack::tests::make_minimal_please_ack, thread::tests::make_extended_thread, timing::tests::make_extended_timing, }, misc::test_utils, msg_types::present_proof::PresentProofTypeV2_0, }; #[test] fn test_minimal_present_proof() { let content = PresentationV2Content::builder() .formats(vec![AttachmentFormatSpecifier { attach_id: "1".to_owned(), format: MaybeKnown::Known( PresentationAttachmentFormatType::HyperledgerIndyProof2_0, ), }]) .presentations_attach(vec![make_extended_attachment()]) .build(); let decorators = PresentationV2Decorators::builder() .thread(make_extended_thread()) .build(); let expected = json!({ "formats": content.formats, "presentations~attach": content.presentations_attach, "~thread": decorators.thread }); test_utils::test_msg( content, decorators, PresentProofTypeV2_0::Presentation, expected, ); } #[test] fn test_extended_present_proof() { let content = PresentationV2Content::builder() .formats(vec![AttachmentFormatSpecifier { attach_id: "1".to_owned(), format: MaybeKnown::Known( PresentationAttachmentFormatType::HyperledgerIndyProof2_0, ), }]) .presentations_attach(vec![make_extended_attachment()]) .comment(Some("test_comment".to_owned())) .goal_code(Some("goal.goal".to_owned())) .build(); let decorators = PresentationV2Decorators::builder() .thread(make_extended_thread()) .timing(make_extended_timing()) .please_ack(make_minimal_please_ack()) .build(); let expected = json!({ "comment": content.comment, "goal_code": content.goal_code, "formats": content.formats, "presentations~attach": content.presentations_attach, "~thread": decorators.thread, "~timing": decorators.timing, "~please_ack": decorators.please_ack }); test_utils::test_msg( content, decorators, PresentProofTypeV2_0::Presentation, expected, ); } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/revocation/revoke.rs
aries/messages/src/msg_fields/protocols/revocation/revoke.rs
use serde::{Deserialize, Serialize}; use shared::maybe_known::MaybeKnown; use typed_builder::TypedBuilder; use crate::{ decorators::{please_ack::PleaseAck, thread::Thread, timing::Timing}, msg_parts::MsgParts, }; pub type Revoke = MsgParts<RevokeContent, RevokeDecorators>; #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, TypedBuilder)] pub struct RevokeContent { pub credential_id: String, pub revocation_format: MaybeKnown<RevocationFormat>, #[builder(default, setter(strip_option))] #[serde(skip_serializing_if = "Option::is_none")] pub comment: Option<String>, } #[derive(Clone, Debug, Default, Deserialize, Serialize, PartialEq, TypedBuilder)] pub struct RevokeDecorators { #[builder(default, setter(strip_option))] #[serde(rename = "~please_ack")] #[serde(skip_serializing_if = "Option::is_none")] pub please_ack: Option<PleaseAck>, #[builder(default, setter(strip_option))] #[serde(rename = "~timing")] #[serde(skip_serializing_if = "Option::is_none")] pub timing: Option<Timing>, #[builder(default, setter(strip_option))] #[serde(rename = "~thread")] #[serde(skip_serializing_if = "Option::is_none")] pub thread: Option<Thread>, } #[derive(Debug, Serialize, Deserialize, PartialEq, Clone, Copy)] #[serde(rename_all = "kebab-case")] pub enum RevocationFormat { IndyAnoncreds, } #[cfg(test)] #[allow(clippy::field_reassign_with_default)] mod tests { use serde_json::json; use super::*; use crate::{ decorators::thread::tests::make_extended_thread, misc::test_utils, msg_types::revocation::RevocationTypeV2_0, }; #[test] fn test_minimal_revoke() { let content = RevokeContent::builder() .credential_id("test_credential_id".to_owned()) .revocation_format(MaybeKnown::Known(RevocationFormat::IndyAnoncreds)) .build(); let decorators = RevokeDecorators::default(); let expected = json!({ "credential_id": content.credential_id, "revocation_format": content.revocation_format }); test_utils::test_msg(content, decorators, RevocationTypeV2_0::Revoke, expected); } #[test] fn test_extended_revoke() { let content = RevokeContent::builder() .credential_id("test_credential_id".to_owned()) .revocation_format(MaybeKnown::Known(RevocationFormat::IndyAnoncreds)) .comment("test_comment".to_owned()) .build(); let decorators = RevokeDecorators::builder() .thread(make_extended_thread()) .build(); let expected = json!({ "credential_id": content.credential_id, "revocation_format": content.revocation_format, "comment": content.comment, "~thread": decorators.thread }); test_utils::test_msg(content, decorators, RevocationTypeV2_0::Revoke, expected); } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/revocation/ack.rs
aries/messages/src/msg_fields/protocols/revocation/ack.rs
use serde::{Deserialize, Serialize}; use typed_builder::TypedBuilder; use crate::{ msg_fields::protocols::notification::ack::{Ack, AckContent, AckDecorators}, msg_parts::MsgParts, }; pub type AckRevoke = MsgParts<AckRevokeContent, AckDecorators>; #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, TypedBuilder)] #[serde(transparent)] pub struct AckRevokeContent { pub inner: AckContent, } impl From<AckContent> for AckRevokeContent { fn from(value: AckContent) -> Self { Self { inner: value } } } impl From<AckRevoke> for Ack { fn from(value: AckRevoke) -> Self { Self::builder() .id(value.id) .content(value.content.inner) .decorators(value.decorators) .build() } } #[cfg(test)] #[allow(clippy::field_reassign_with_default)] mod tests { use serde_json::json; use super::*; use crate::{ decorators::{thread::tests::make_extended_thread, timing::tests::make_extended_timing}, misc::test_utils, msg_fields::protocols::notification::ack::AckStatus, msg_types::revocation::RevocationTypeV2_0, }; #[test] fn test_minimal_ack_revoke() { let content: AckRevokeContent = AckContent::builder().status(AckStatus::Ok).build(); let decorators = AckDecorators::builder() .thread(make_extended_thread()) .build(); let expected = json!({ "status": content.inner.status, "~thread": decorators.thread }); test_utils::test_msg(content, decorators, RevocationTypeV2_0::Ack, expected); } #[test] fn test_extended_ack_revoke() { let content: AckRevokeContent = AckContent::builder().status(AckStatus::Ok).build(); let decorators = AckDecorators::builder() .thread(make_extended_thread()) .timing(make_extended_timing()) .build(); let expected = json!({ "status": content.inner.status, "~thread": decorators.thread, "~timing": decorators.timing }); test_utils::test_msg(content, decorators, RevocationTypeV2_0::Ack, expected); } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/revocation/mod.rs
aries/messages/src/msg_fields/protocols/revocation/mod.rs
//! Module containing the `revocation notification` protocol messages, as defined in the [RFC](<https://github.com/decentralized-identity/aries-rfcs/blob/main/features/0721-revocation-notification-v2/README.md>). pub mod ack; pub mod revoke; use derive_more::From; use serde::{de::Error, Deserialize, Deserializer, Serialize, Serializer}; use self::{ ack::{AckRevoke, AckRevokeContent}, revoke::{Revoke, RevokeContent, RevokeDecorators}, }; use super::notification::ack::AckDecorators; use crate::{ misc::utils::{into_msg_with_type, transit_to_aries_msg}, msg_fields::traits::DelayedSerde, msg_types::{ protocols::revocation::{ RevocationType as RevocationKind, RevocationTypeV2, RevocationTypeV2_0, }, MsgWithType, }, }; #[derive(Clone, Debug, From, PartialEq)] pub enum Revocation { Revoke(Revoke), Ack(AckRevoke), } impl DelayedSerde for Revocation { type MsgType<'a> = (RevocationKind, &'a str); fn delayed_deserialize<'de, D>( msg_type: Self::MsgType<'de>, deserializer: D, ) -> Result<Self, D::Error> where D: Deserializer<'de>, { let (protocol, kind_str) = msg_type; let kind = match protocol { RevocationKind::V2(RevocationTypeV2::V2_0(kind)) => kind.kind_from_str(kind_str), }; match kind.map_err(D::Error::custom)? { RevocationTypeV2_0::Revoke => Revoke::deserialize(deserializer).map(From::from), RevocationTypeV2_0::Ack => AckRevoke::deserialize(deserializer).map(From::from), } } fn delayed_serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: Serializer, { match self { Self::Revoke(v) => MsgWithType::from(v).serialize(serializer), Self::Ack(v) => MsgWithType::from(v).serialize(serializer), } } } transit_to_aries_msg!(RevokeContent: RevokeDecorators, Revocation); transit_to_aries_msg!(AckRevokeContent: AckDecorators, Revocation); into_msg_with_type!(Revoke, RevocationTypeV2_0, Revoke); into_msg_with_type!(AckRevoke, RevocationTypeV2_0, Ack);
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/did_exchange/mod.rs
aries/messages/src/msg_fields/protocols/did_exchange/mod.rs
use derive_more::From; use v1_0::DidExchangeV1_0; use v1_1::DidExchangeV1_1; pub mod v1_0; pub mod v1_1; pub mod v1_x; #[derive(Clone, Debug, From, PartialEq)] pub enum DidExchange { V1_0(DidExchangeV1_0), V1_1(DidExchangeV1_1), }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/did_exchange/v1_0/complete.rs
aries/messages/src/msg_fields/protocols/did_exchange/v1_0/complete.rs
use shared::misc::serde_ignored::SerdeIgnored as NoContent; use crate::{ msg_fields::protocols::did_exchange::v1_x::complete::CompleteDecorators, msg_parts::MsgParts, }; /// Alias type for DIDExchange v1.0 Complete message. /// Note that since this inherits from the V1.X message, the direct serialization /// of this message type is not recommended, as it will be indistinguisable from V1.1. /// Instead, this type should be converted to/from an AriesMessage pub type Complete = MsgParts<NoContent, CompleteDecorators>; #[cfg(test)] #[allow(clippy::unwrap_used)] #[allow(clippy::field_reassign_with_default)] mod tests { use serde_json::json; use super::*; use crate::{ decorators::{ thread::tests::{make_extended_thread, make_minimal_thread}, timing::tests::make_extended_timing, }, misc::test_utils, msg_fields::protocols::did_exchange::v1_x::complete::AnyComplete, msg_types::protocols::did_exchange::DidExchangeTypeV1_0, }; #[test] fn test_minimal_complete_message() { let thread = make_minimal_thread(); let expected = json!({ "~thread": { "thid": thread.thid } }); let decorators = CompleteDecorators::builder().thread(thread).build(); let msg = AnyComplete::V1_0( Complete::builder() .id("test".to_owned()) .content(NoContent) .decorators(decorators) .build(), ); test_utils::test_constructed_msg(msg, DidExchangeTypeV1_0::Complete, expected); } #[test] fn test_extended_complete_message() { let decorators = CompleteDecorators { thread: make_extended_thread(), timing: Some(make_extended_timing()), }; let expected = json!({ "~thread": serde_json::to_value(make_extended_thread()).unwrap(), "~timing": serde_json::to_value(make_extended_timing()).unwrap() }); let msg = AnyComplete::V1_0( Complete::builder() .id("test".to_owned()) .content(NoContent) .decorators(decorators) .build(), ); test_utils::test_constructed_msg(msg, DidExchangeTypeV1_0::Complete, expected); } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/did_exchange/v1_0/response.rs
aries/messages/src/msg_fields/protocols/did_exchange/v1_0/response.rs
use serde::{Deserialize, Serialize}; use typed_builder::TypedBuilder; use crate::{ decorators::attachment::Attachment, msg_fields::protocols::did_exchange::v1_x::response::ResponseDecorators, msg_parts::MsgParts, }; pub type Response = MsgParts<ResponseContent, ResponseDecorators>; #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, TypedBuilder)] pub struct ResponseContent { pub did: String, // TODO: Use Did #[serde(rename = "did_doc~attach", skip_serializing_if = "Option::is_none")] pub did_doc: Option<Attachment>, } #[cfg(test)] #[allow(clippy::unwrap_used)] #[allow(clippy::field_reassign_with_default)] mod tests { use diddoc_legacy::aries::diddoc::AriesDidDoc; use serde_json::json; use super::*; use crate::{ decorators::{ attachment::{AttachmentData, AttachmentType}, thread::tests::make_extended_thread, timing::tests::make_extended_timing, }, misc::test_utils, msg_types::protocols::did_exchange::DidExchangeTypeV1_0, }; fn response_content() -> ResponseContent { let did_doc = AriesDidDoc::default(); ResponseContent { did: did_doc.id.clone(), did_doc: Some( Attachment::builder() .data( AttachmentData::builder() .content(AttachmentType::Json( serde_json::to_value(&did_doc).unwrap(), )) .build(), ) .build(), ), } } #[test] fn test_minimal_conn_response() { let content = response_content(); let decorators = ResponseDecorators { thread: make_extended_thread(), timing: None, }; let expected = json!({ "did": content.did, "did_doc~attach": content.did_doc, "~thread": decorators.thread }); test_utils::test_msg(content, decorators, DidExchangeTypeV1_0::Response, expected); } #[test] fn test_extended_conn_response() { let content = response_content(); let decorators = ResponseDecorators { thread: make_extended_thread(), timing: Some(make_extended_timing()), }; let expected = json!({ "did": content.did, "did_doc~attach": content.did_doc, "~thread": decorators.thread, "~timing": decorators.timing }); test_utils::test_msg(content, decorators, DidExchangeTypeV1_0::Response, expected); } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/did_exchange/v1_0/problem_report.rs
aries/messages/src/msg_fields/protocols/did_exchange/v1_0/problem_report.rs
use crate::{ msg_fields::protocols::did_exchange::v1_x::problem_report::{ ProblemReportContent, ProblemReportDecorators, }, msg_parts::MsgParts, }; /// Alias type for DIDExchange v1.0 Problem Report message. /// Note that since this inherits from the V1.X message, the direct serialization /// of this message type is not recommended, as version metadata will be lost. /// Instead, this type should be converted to/from an AriesMessage pub type ProblemReport = MsgParts<ProblemReportContent, ProblemReportDecorators>; #[cfg(test)] #[allow(clippy::unwrap_used)] #[allow(clippy::field_reassign_with_default)] mod tests { use serde_json::json; use super::*; use crate::{ decorators::{ localization::tests::make_extended_msg_localization, thread::tests::make_extended_thread, timing::tests::make_extended_timing, }, misc::test_utils, msg_fields::protocols::did_exchange::v1_x::problem_report::{ AnyProblemReport, ProblemCode, }, msg_types::protocols::did_exchange::DidExchangeTypeV1_0, }; #[test] fn test_minimal_conn_problem_report() { let content = ProblemReportContent::builder() .problem_code(None) .explain(None) .build(); let decorators = ProblemReportDecorators::new(make_extended_thread()); let expected = json!({ "~thread": decorators.thread }); let msg = AnyProblemReport::V1_0( ProblemReport::builder() .id("test".to_owned()) .content(content) .decorators(decorators) .build(), ); test_utils::test_constructed_msg(msg, DidExchangeTypeV1_0::ProblemReport, expected); } #[test] fn test_extended_conn_problem_report() { let content = ProblemReportContent::builder() .problem_code(Some(ProblemCode::RequestNotAccepted)) .explain(Some("test_conn_problem_report_explain".to_owned())) .build(); let mut decorators = ProblemReportDecorators::new(make_extended_thread()); decorators.timing = Some(make_extended_timing()); decorators.localization = Some(make_extended_msg_localization()); let expected = json!({ "problem-code": content.problem_code, "explain": content.explain, "~thread": decorators.thread, "~timing": decorators.timing, "~l10n": decorators.localization }); let msg = AnyProblemReport::V1_0( ProblemReport::builder() .id("test".to_owned()) .content(content) .decorators(decorators) .build(), ); test_utils::test_constructed_msg(msg, DidExchangeTypeV1_0::ProblemReport, expected); } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/did_exchange/v1_0/mod.rs
aries/messages/src/msg_fields/protocols/did_exchange/v1_0/mod.rs
pub mod complete; pub mod problem_report; pub mod request; pub mod response; use derive_more::From; use serde::{de::Error, Deserialize, Serialize}; use self::{ complete::Complete, problem_report::ProblemReport, request::Request, response::{Response, ResponseContent}, }; use super::{v1_x::response::ResponseDecorators, DidExchange}; use crate::{ misc::utils::{into_msg_with_type, transit_to_aries_msg}, msg_fields::traits::DelayedSerde, msg_types::{protocols::did_exchange::DidExchangeTypeV1_0, MsgKindType, MsgWithType}, }; #[derive(Clone, Debug, From, PartialEq)] pub enum DidExchangeV1_0 { Request(Request), Response(Response), ProblemReport(ProblemReport), Complete(Complete), } impl DelayedSerde for DidExchangeV1_0 { type MsgType<'a> = (MsgKindType<DidExchangeTypeV1_0>, &'a str); fn delayed_deserialize<'de, D>( msg_type: Self::MsgType<'de>, deserializer: D, ) -> Result<Self, D::Error> where D: serde::Deserializer<'de>, { let (protocol, kind_str) = msg_type; let kind = protocol.kind_from_str(kind_str); match kind.map_err(D::Error::custom)? { DidExchangeTypeV1_0::Request => Request::deserialize(deserializer).map(From::from), DidExchangeTypeV1_0::Response => Response::deserialize(deserializer).map(From::from), DidExchangeTypeV1_0::ProblemReport => { ProblemReport::deserialize(deserializer).map(From::from) } DidExchangeTypeV1_0::Complete => Complete::deserialize(deserializer).map(From::from), } } fn delayed_serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, { match self { Self::Request(v) => { MsgWithType::<_, DidExchangeTypeV1_0>::from(v).serialize(serializer) } Self::Response(v) => MsgWithType::from(v).serialize(serializer), Self::ProblemReport(v) => { MsgWithType::<_, DidExchangeTypeV1_0>::from(v).serialize(serializer) } Self::Complete(v) => { MsgWithType::<_, DidExchangeTypeV1_0>::from(v).serialize(serializer) } } } } transit_to_aries_msg!(ResponseContent: ResponseDecorators, DidExchangeV1_0, DidExchange); into_msg_with_type!(Request, DidExchangeTypeV1_0, Request); into_msg_with_type!(Response, DidExchangeTypeV1_0, Response); into_msg_with_type!(ProblemReport, DidExchangeTypeV1_0, ProblemReport); into_msg_with_type!(Complete, DidExchangeTypeV1_0, Complete);
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/did_exchange/v1_0/request.rs
aries/messages/src/msg_fields/protocols/did_exchange/v1_0/request.rs
use crate::{ msg_fields::protocols::did_exchange::v1_x::request::{RequestContent, RequestDecorators}, msg_parts::MsgParts, }; /// Alias type for DIDExchange v1.0 Request message. /// Note that since this inherits from the V1.X message, the direct serialization /// of this Request is not recommended, as it will be indistinguisable from Request V1.1. /// Instead, this type should be converted to/from an AriesMessage pub type Request = MsgParts<RequestContent, RequestDecorators>; #[cfg(test)] #[allow(clippy::unwrap_used)] #[allow(clippy::field_reassign_with_default)] mod tests { use diddoc_legacy::aries::diddoc::AriesDidDoc; use serde_json::json; use shared::maybe_known::MaybeKnown; use super::*; use crate::{ decorators::{ attachment::{Attachment, AttachmentData, AttachmentType}, thread::{tests::make_extended_thread, ThreadGoalCode}, timing::tests::make_extended_timing, }, misc::test_utils, msg_fields::protocols::did_exchange::{ v1_0::request::{Request, RequestDecorators}, v1_x::request::AnyRequest, }, msg_types::protocols::did_exchange::DidExchangeTypeV1_0, }; pub fn request_content() -> RequestContent { let did_doc = AriesDidDoc::default(); RequestContent { label: "test_request_label".to_owned(), goal_code: Some(MaybeKnown::Known(ThreadGoalCode::AriesRelBuild)), goal: Some("test_goal".to_owned()), did: did_doc.id.clone(), did_doc: Some( Attachment::builder() .data( AttachmentData::builder() .content(AttachmentType::Json( serde_json::to_value(&did_doc).unwrap(), )) .build(), ) .build(), ), } } #[test] fn test_print_message() { let msg: Request = Request::builder() .id("test_id".to_owned()) .content(request_content()) .decorators(RequestDecorators::default()) .build(); let printed_json = format!("{msg}"); let parsed_request: Request = serde_json::from_str(&printed_json).unwrap(); assert_eq!(msg, parsed_request); } #[test] fn test_minimal_didexchange_request() { let content = request_content(); let expected = json!({ "label": content.label, "goal_code": content.goal_code, "goal": content.goal, "did": content.did, "did_doc~attach": content.did_doc, }); let msg = AnyRequest::V1_0( Request::builder() .id("test".to_owned()) .content(content) .decorators(RequestDecorators::default()) .build(), ); test_utils::test_constructed_msg(msg, DidExchangeTypeV1_0::Request, expected); } #[test] fn test_extended_didexchange_request() { let content = request_content(); let mut decorators = RequestDecorators::default(); decorators.thread = Some(make_extended_thread()); decorators.timing = Some(make_extended_timing()); let expected = json!({ "label": content.label, "goal_code": content.goal_code, "goal": content.goal, "did": content.did, "did_doc~attach": content.did_doc, "~thread": decorators.thread, "~timing": decorators.timing }); let msg = AnyRequest::V1_0( Request::builder() .id("test".to_owned()) .content(content) .decorators(decorators) .build(), ); test_utils::test_constructed_msg(msg, DidExchangeTypeV1_0::Request, expected); } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/did_exchange/v1_x/complete.rs
aries/messages/src/msg_fields/protocols/did_exchange/v1_x/complete.rs
use serde::{Deserialize, Serialize}; use shared::misc::serde_ignored::SerdeIgnored as NoContent; use typed_builder::TypedBuilder; use super::DidExchangeV1MessageVariant; use crate::{ decorators::{thread::Thread, timing::Timing}, msg_parts::MsgParts, }; /// Alias type for the shared DIDExchange v1.X complete message type. /// Note the direct serialization of this message type is not recommended, /// as it will be indistinguisable between V1.1 & V1.0. /// Instead, this type should be converted to/from an AriesMessage pub type Complete = MsgParts<NoContent, CompleteDecorators>; // TODO: Pthid is mandatory in this case! #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, TypedBuilder)] pub struct CompleteDecorators { #[serde(rename = "~thread")] pub thread: Thread, #[builder(default, setter(strip_option))] #[serde(rename = "~timing")] #[serde(skip_serializing_if = "Option::is_none")] pub timing: Option<Timing>, } pub type AnyComplete = DidExchangeV1MessageVariant<Complete, Complete>;
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/did_exchange/v1_x/response.rs
aries/messages/src/msg_fields/protocols/did_exchange/v1_x/response.rs
use serde::{Deserialize, Serialize}; use typed_builder::TypedBuilder; use super::DidExchangeV1MessageVariant; use crate::{ decorators::{thread::Thread, timing::Timing}, msg_fields::protocols::did_exchange::{ v1_0::response::Response as ResponseV1_0, v1_1::response::{Response as ResponseV1_1, ResponseContent as ResponseV1_1Content}, }, }; pub type AnyResponse = DidExchangeV1MessageVariant<ResponseV1_0, ResponseV1_1>; impl AnyResponse { pub fn into_v1_1(self) -> ResponseV1_1 { match self { AnyResponse::V1_0(r) => r.into_v1_1(), AnyResponse::V1_1(r) => r, } } } impl ResponseV1_0 { pub fn into_v1_1(self) -> ResponseV1_1 { ResponseV1_1 { id: self.id, decorators: self.decorators, content: ResponseV1_1Content { did: self.content.did, did_doc: self.content.did_doc, did_rotate: None, }, } } } impl From<ResponseV1_0> for AnyResponse { fn from(value: ResponseV1_0) -> Self { Self::V1_0(value) } } impl From<ResponseV1_1> for AnyResponse { fn from(value: ResponseV1_1) -> Self { Self::V1_1(value) } } #[derive(Debug, Deserialize, Serialize, Clone, PartialEq, TypedBuilder)] pub struct ResponseDecorators { #[serde(rename = "~thread")] pub thread: Thread, #[builder(default, setter(strip_option))] #[serde(rename = "~timing")] #[serde(skip_serializing_if = "Option::is_none")] pub timing: Option<Timing>, }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/did_exchange/v1_x/problem_report.rs
aries/messages/src/msg_fields/protocols/did_exchange/v1_x/problem_report.rs
use serde::{Deserialize, Serialize}; use typed_builder::TypedBuilder; use super::DidExchangeV1MessageVariant; use crate::{ decorators::{localization::MsgLocalization, thread::Thread, timing::Timing}, msg_parts::MsgParts, }; /// Alias type for the shared DIDExchange v1.X problem report message type. /// Note the direct serialization of this message type is not recommended, /// as version metadata will be lost. /// Instead, this type should be converted to/from an AriesMessage pub type ProblemReport = MsgParts<ProblemReportContent, ProblemReportDecorators>; #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, TypedBuilder)] pub struct ProblemReportContent { #[serde(rename = "problem-code")] #[serde(skip_serializing_if = "Option::is_none")] pub problem_code: Option<ProblemCode>, #[serde(skip_serializing_if = "Option::is_none")] pub explain: Option<String>, } #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] #[serde(rename_all = "snake_case")] pub enum ProblemCode { RequestNotAccepted, RequestProcessingError, ResponseNotAccepted, ResponseProcessingError, } #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, TypedBuilder)] pub struct ProblemReportDecorators { #[serde(rename = "~thread")] pub thread: Thread, #[builder(default, setter(strip_option))] #[serde(rename = "~l10n")] #[serde(skip_serializing_if = "Option::is_none")] pub localization: Option<MsgLocalization>, #[builder(default, setter(strip_option))] #[serde(rename = "~timing")] #[serde(skip_serializing_if = "Option::is_none")] pub timing: Option<Timing>, } impl ProblemReportDecorators { pub fn new(thread: Thread) -> Self { Self { thread, localization: None, timing: None, } } } pub type AnyProblemReport = DidExchangeV1MessageVariant<ProblemReport, ProblemReport>;
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/did_exchange/v1_x/mod.rs
aries/messages/src/msg_fields/protocols/did_exchange/v1_x/mod.rs
//! Common components for V1.X DIDExchange messages (v1.0 & v1.1). //! Necessary to prevent duplicated code, since most types between v1.0 & v1.1 are identical use serde::Serialize; use super::{v1_0::DidExchangeV1_0, v1_1::DidExchangeV1_1, DidExchange}; use crate::{msg_types::protocols::did_exchange::DidExchangeTypeV1, AriesMessage}; pub mod complete; pub mod problem_report; pub mod request; pub mod response; #[derive(Debug, Clone, Serialize, PartialEq)] #[serde(untagged)] pub enum DidExchangeV1MessageVariant<V1_0, V1_1> { V1_0(V1_0), V1_1(V1_1), } impl<A, B> DidExchangeV1MessageVariant<A, B> { pub fn get_version(&self) -> DidExchangeTypeV1 { match self { DidExchangeV1MessageVariant::V1_0(_) => DidExchangeTypeV1::new_v1_0(), DidExchangeV1MessageVariant::V1_1(_) => DidExchangeTypeV1::new_v1_1(), } } } impl<T> DidExchangeV1MessageVariant<T, T> { pub fn into_inner(self) -> T { match self { DidExchangeV1MessageVariant::V1_0(r) | DidExchangeV1MessageVariant::V1_1(r) => r, } } pub fn inner(&self) -> &T { match self { DidExchangeV1MessageVariant::V1_0(r) | DidExchangeV1MessageVariant::V1_1(r) => r, } } } impl<A, B> From<DidExchangeV1MessageVariant<A, B>> for AriesMessage where A: Into<DidExchangeV1_0>, B: Into<DidExchangeV1_1>, { fn from(value: DidExchangeV1MessageVariant<A, B>) -> Self { match value { DidExchangeV1MessageVariant::V1_0(a) => { AriesMessage::DidExchange(DidExchange::V1_0(a.into())) } DidExchangeV1MessageVariant::V1_1(b) => { AriesMessage::DidExchange(DidExchange::V1_1(b.into())) } } } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/did_exchange/v1_x/request.rs
aries/messages/src/msg_fields/protocols/did_exchange/v1_x/request.rs
use serde::{Deserialize, Serialize}; use shared::maybe_known::MaybeKnown; use typed_builder::TypedBuilder; use super::DidExchangeV1MessageVariant; use crate::{ decorators::{ attachment::Attachment, thread::{Thread, ThreadGoalCode}, timing::Timing, }, msg_parts::MsgParts, }; /// Alias type for the shared DIDExchange v1.X request message type. /// Note the direct serialization of this message type is not recommended, /// as it will be indistinguisable between V1.1 & V1.0. /// Instead, this type should be converted to/from an AriesMessage pub type Request = MsgParts<RequestContent, RequestDecorators>; #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, TypedBuilder)] pub struct RequestContent { pub label: String, #[serde(skip_serializing_if = "Option::is_none")] pub goal_code: Option<MaybeKnown<ThreadGoalCode>>, #[serde(skip_serializing_if = "Option::is_none")] pub goal: Option<String>, pub did: String, // TODO: Use Did #[serde(rename = "did_doc~attach", skip_serializing_if = "Option::is_none")] pub did_doc: Option<Attachment>, } #[derive(Clone, Debug, Deserialize, Serialize, Default, PartialEq, TypedBuilder)] pub struct RequestDecorators { #[serde(rename = "~thread")] #[serde(skip_serializing_if = "Option::is_none")] pub thread: Option<Thread>, #[builder(default, setter(strip_option))] #[serde(rename = "~timing")] #[serde(skip_serializing_if = "Option::is_none")] pub timing: Option<Timing>, } pub type AnyRequest = DidExchangeV1MessageVariant<Request, Request>;
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/did_exchange/v1_1/complete.rs
aries/messages/src/msg_fields/protocols/did_exchange/v1_1/complete.rs
use shared::misc::serde_ignored::SerdeIgnored as NoContent; use crate::{ msg_fields::protocols::did_exchange::v1_x::complete::CompleteDecorators, msg_parts::MsgParts, }; /// Alias type for DIDExchange v1.1 Complete message. /// Note that since this inherits from the V1.X message, the direct serialization /// of this message type is not recommended, as it will be indistinguisable from V1.0. /// Instead, this type should be converted to/from an AriesMessage pub type Complete = MsgParts<NoContent, CompleteDecorators>; #[cfg(test)] #[allow(clippy::unwrap_used)] #[allow(clippy::field_reassign_with_default)] mod tests { use serde_json::json; use super::*; use crate::{ decorators::{ thread::tests::{make_extended_thread, make_minimal_thread}, timing::tests::make_extended_timing, }, misc::test_utils, msg_fields::protocols::did_exchange::v1_x::complete::AnyComplete, msg_types::protocols::did_exchange::DidExchangeTypeV1_1, }; #[test] fn test_minimal_complete_message() { let thread = make_minimal_thread(); let expected = json!({ "~thread": { "thid": thread.thid } }); let decorators = CompleteDecorators::builder().thread(thread).build(); let msg = AnyComplete::V1_1( Complete::builder() .id("test".to_owned()) .content(NoContent) .decorators(decorators) .build(), ); test_utils::test_constructed_msg(msg, DidExchangeTypeV1_1::Complete, expected); } #[test] fn test_extended_complete_message() { let decorators = CompleteDecorators { thread: make_extended_thread(), timing: Some(make_extended_timing()), }; let expected = json!({ "~thread": serde_json::to_value(make_extended_thread()).unwrap(), "~timing": serde_json::to_value(make_extended_timing()).unwrap() }); let msg = AnyComplete::V1_1( Complete::builder() .id("test".to_owned()) .content(NoContent) .decorators(decorators) .build(), ); test_utils::test_constructed_msg(msg, DidExchangeTypeV1_1::Complete, expected); } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/did_exchange/v1_1/response.rs
aries/messages/src/msg_fields/protocols/did_exchange/v1_1/response.rs
use serde::{Deserialize, Serialize}; use typed_builder::TypedBuilder; use crate::{ decorators::attachment::Attachment, msg_fields::protocols::did_exchange::v1_x::response::ResponseDecorators, msg_parts::MsgParts, }; pub type Response = MsgParts<ResponseContent, ResponseDecorators>; #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, TypedBuilder)] pub struct ResponseContent { pub did: String, // TODO: Use Did #[serde(rename = "did_doc~attach", skip_serializing_if = "Option::is_none")] #[builder(default, setter(strip_option))] pub did_doc: Option<Attachment>, #[serde(rename = "did_rotate~attach", skip_serializing_if = "Option::is_none")] #[builder(default, setter(strip_option))] pub did_rotate: Option<Attachment>, } #[cfg(test)] #[allow(clippy::unwrap_used)] #[allow(clippy::field_reassign_with_default)] mod tests { use diddoc_legacy::aries::diddoc::AriesDidDoc; use serde_json::json; use super::*; use crate::{ decorators::{ attachment::{AttachmentData, AttachmentType}, thread::tests::make_extended_thread, timing::tests::make_extended_timing, }, misc::{test_utils, MimeType}, msg_types::protocols::did_exchange::DidExchangeTypeV1_1, }; fn response_content() -> ResponseContent { let did_doc = AriesDidDoc::default(); ResponseContent { did: did_doc.id.clone(), did_doc: Some( Attachment::builder() .data( AttachmentData::builder() .content(AttachmentType::Json( serde_json::to_value(&did_doc).unwrap(), )) .build(), ) .build(), ), did_rotate: Some( Attachment::builder() .data( AttachmentData::builder() .content(AttachmentType::Base64(String::from("Qi5kaWRAQjpB"))) .build(), ) .mime_type(MimeType::Plain) .build(), ), } } #[test] fn test_minimal_conn_response() { let mut content = response_content(); content.did_doc = None; content.did_rotate = None; let decorators = ResponseDecorators { thread: make_extended_thread(), timing: None, }; let expected = json!({ "did": content.did, "~thread": decorators.thread }); test_utils::test_msg(content, decorators, DidExchangeTypeV1_1::Response, expected); } #[test] fn test_extended_conn_response() { let content = response_content(); let decorators = ResponseDecorators { thread: make_extended_thread(), timing: Some(make_extended_timing()), }; let expected = json!({ "did": content.did, "did_doc~attach": content.did_doc, "did_rotate~attach": content.did_rotate, "~thread": decorators.thread, "~timing": decorators.timing }); test_utils::test_msg(content, decorators, DidExchangeTypeV1_1::Response, expected); } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/did_exchange/v1_1/problem_report.rs
aries/messages/src/msg_fields/protocols/did_exchange/v1_1/problem_report.rs
use crate::{ msg_fields::protocols::did_exchange::v1_x::problem_report::{ ProblemReportContent, ProblemReportDecorators, }, msg_parts::MsgParts, }; /// Alias type for DIDExchange v1.1 problem report message. /// Note that since this inherits from the V1.X message, the direct serialization /// of this message type is not recommended, as version metadata will be lost. /// Instead, this type should be converted to/from an AriesMessage pub type ProblemReport = MsgParts<ProblemReportContent, ProblemReportDecorators>; #[cfg(test)] #[allow(clippy::unwrap_used)] #[allow(clippy::field_reassign_with_default)] mod tests { use serde_json::json; use super::*; use crate::{ decorators::{ localization::tests::make_extended_msg_localization, thread::tests::make_extended_thread, timing::tests::make_extended_timing, }, misc::test_utils, msg_fields::protocols::did_exchange::v1_x::problem_report::{ AnyProblemReport, ProblemCode, ProblemReportDecorators, }, msg_types::protocols::did_exchange::DidExchangeTypeV1_1, }; #[test] fn test_minimal_conn_problem_report() { let content = ProblemReportContent::builder() .problem_code(None) .explain(None) .build(); let decorators = ProblemReportDecorators::new(make_extended_thread()); let expected = json!({ "~thread": decorators.thread }); let msg = AnyProblemReport::V1_1( ProblemReport::builder() .id("test".to_owned()) .content(content) .decorators(decorators) .build(), ); test_utils::test_constructed_msg(msg, DidExchangeTypeV1_1::ProblemReport, expected); } #[test] fn test_extended_conn_problem_report() { let content = ProblemReportContent::builder() .problem_code(Some(ProblemCode::RequestNotAccepted)) .explain(Some("test_conn_problem_report_explain".to_owned())) .build(); let mut decorators = ProblemReportDecorators::new(make_extended_thread()); decorators.timing = Some(make_extended_timing()); decorators.localization = Some(make_extended_msg_localization()); let expected = json!({ "problem-code": content.problem_code, "explain": content.explain, "~thread": decorators.thread, "~timing": decorators.timing, "~l10n": decorators.localization }); let msg = AnyProblemReport::V1_1( ProblemReport::builder() .id("test".to_owned()) .content(content) .decorators(decorators) .build(), ); test_utils::test_constructed_msg(msg, DidExchangeTypeV1_1::ProblemReport, expected); } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/did_exchange/v1_1/mod.rs
aries/messages/src/msg_fields/protocols/did_exchange/v1_1/mod.rs
pub mod complete; pub mod problem_report; pub mod request; pub mod response; use derive_more::From; use serde::{de::Error, Deserialize, Serialize}; use self::{ complete::Complete, problem_report::ProblemReport, request::Request, response::{Response, ResponseContent}, }; use super::{v1_x::response::ResponseDecorators, DidExchange}; use crate::{ misc::utils::{into_msg_with_type, transit_to_aries_msg}, msg_fields::traits::DelayedSerde, msg_types::{protocols::did_exchange::DidExchangeTypeV1_1, MsgKindType, MsgWithType}, }; #[derive(Clone, Debug, From, PartialEq)] pub enum DidExchangeV1_1 { Request(Request), Response(Response), ProblemReport(ProblemReport), Complete(Complete), } impl DelayedSerde for DidExchangeV1_1 { type MsgType<'a> = (MsgKindType<DidExchangeTypeV1_1>, &'a str); fn delayed_deserialize<'de, D>( msg_type: Self::MsgType<'de>, deserializer: D, ) -> Result<Self, D::Error> where D: serde::Deserializer<'de>, { let (protocol, kind_str) = msg_type; let kind = protocol.kind_from_str(kind_str); match kind.map_err(D::Error::custom)? { DidExchangeTypeV1_1::Request => Request::deserialize(deserializer).map(From::from), DidExchangeTypeV1_1::Response => Response::deserialize(deserializer).map(From::from), DidExchangeTypeV1_1::ProblemReport => { ProblemReport::deserialize(deserializer).map(From::from) } DidExchangeTypeV1_1::Complete => Complete::deserialize(deserializer).map(From::from), } } fn delayed_serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, { match self { Self::Request(v) => { MsgWithType::<_, DidExchangeTypeV1_1>::from(v).serialize(serializer) } Self::Response(v) => MsgWithType::from(v).serialize(serializer), Self::ProblemReport(v) => { MsgWithType::<_, DidExchangeTypeV1_1>::from(v).serialize(serializer) } Self::Complete(v) => { MsgWithType::<_, DidExchangeTypeV1_1>::from(v).serialize(serializer) } } } } transit_to_aries_msg!(ResponseContent: ResponseDecorators, DidExchangeV1_1, DidExchange); into_msg_with_type!(Request, DidExchangeTypeV1_1, Request); into_msg_with_type!(Response, DidExchangeTypeV1_1, Response); into_msg_with_type!(ProblemReport, DidExchangeTypeV1_1, ProblemReport); into_msg_with_type!(Complete, DidExchangeTypeV1_1, Complete);
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/did_exchange/v1_1/request.rs
aries/messages/src/msg_fields/protocols/did_exchange/v1_1/request.rs
use crate::{ msg_fields::protocols::did_exchange::v1_x::request::{RequestContent, RequestDecorators}, msg_parts::MsgParts, }; /// Alias type for DIDExchange v1.1 request message. /// Note that since this inherits from the V1.X message, the direct serialization /// of this message type is not recommended, as it will be indistinguisable from Request V1.0. /// Instead, this type should be converted to/from an AriesMessage pub type Request = MsgParts<RequestContent, RequestDecorators>; #[cfg(test)] #[allow(clippy::unwrap_used)] #[allow(clippy::field_reassign_with_default)] mod tests { use diddoc_legacy::aries::diddoc::AriesDidDoc; use serde_json::json; use shared::maybe_known::MaybeKnown; use super::*; use crate::{ decorators::{ attachment::{Attachment, AttachmentData, AttachmentType}, thread::{tests::make_extended_thread, ThreadGoalCode}, timing::tests::make_extended_timing, }, misc::test_utils, msg_fields::protocols::did_exchange::{ v1_1::request::{Request, RequestDecorators}, v1_x::request::AnyRequest, }, msg_types::protocols::did_exchange::DidExchangeTypeV1_1, }; pub fn request_content() -> RequestContent { let did_doc = AriesDidDoc::default(); RequestContent { label: "test_request_label".to_owned(), goal_code: Some(MaybeKnown::Known(ThreadGoalCode::AriesRelBuild)), goal: Some("test_goal".to_owned()), did: did_doc.id.clone(), did_doc: Some( Attachment::builder() .data( AttachmentData::builder() .content(AttachmentType::Json( serde_json::to_value(&did_doc).unwrap(), )) .build(), ) .build(), ), } } #[test] fn test_print_message() { let msg: Request = Request::builder() .id("test_id".to_owned()) .content(request_content()) .decorators(RequestDecorators::default()) .build(); let printed_json = format!("{msg}"); let parsed_request: Request = serde_json::from_str(&printed_json).unwrap(); assert_eq!(msg, parsed_request); } #[test] fn test_minimal_didexchange_request() { let content = request_content(); let expected = json!({ "label": content.label, "goal_code": content.goal_code, "goal": content.goal, "did": content.did, "did_doc~attach": content.did_doc, }); let msg = AnyRequest::V1_1( Request::builder() .id("test".to_owned()) .content(content) .decorators(RequestDecorators::default()) .build(), ); test_utils::test_constructed_msg(msg, DidExchangeTypeV1_1::Request, expected); } #[test] fn test_extended_didexchange_request() { let content = request_content(); let mut decorators = RequestDecorators::default(); decorators.thread = Some(make_extended_thread()); decorators.timing = Some(make_extended_timing()); let expected = json!({ "label": content.label, "goal_code": content.goal_code, "goal": content.goal, "did": content.did, "did_doc~attach": content.did_doc, "~thread": decorators.thread, "~timing": decorators.timing }); let msg = AnyRequest::V1_1( Request::builder() .id("test".to_owned()) .content(content) .decorators(decorators) .build(), ); test_utils::test_constructed_msg(msg, DidExchangeTypeV1_1::Request, expected); } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/cred_issuance/mod.rs
aries/messages/src/msg_fields/protocols/cred_issuance/mod.rs
use derive_more::From; use self::{v1::CredentialIssuanceV1, v2::CredentialIssuanceV2}; pub mod common; pub mod v1; pub mod v2; #[derive(Clone, Debug, From, PartialEq)] pub enum CredentialIssuance { V1(CredentialIssuanceV1), V2(CredentialIssuanceV2), }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/cred_issuance/v1/problem_report.rs
aries/messages/src/msg_fields/protocols/cred_issuance/v1/problem_report.rs
use serde::{Deserialize, Serialize}; use typed_builder::TypedBuilder; use crate::{ msg_fields::protocols::report_problem::{ ProblemReport, ProblemReportContent, ProblemReportDecorators, }, msg_parts::MsgParts, }; pub type CredIssuanceV1ProblemReport = MsgParts<CredIssuanceV1ProblemReportContent, ProblemReportDecorators>; #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, TypedBuilder)] #[serde(transparent)] pub struct CredIssuanceV1ProblemReportContent { pub inner: ProblemReportContent, } impl From<ProblemReportContent> for CredIssuanceV1ProblemReportContent { fn from(value: ProblemReportContent) -> Self { Self { inner: value } } } impl From<CredIssuanceV1ProblemReport> for ProblemReport { fn from(value: CredIssuanceV1ProblemReport) -> Self { Self::builder() .id(value.id) .content(value.content.inner) .decorators(value.decorators) .build() } } #[cfg(test)] #[allow(clippy::field_reassign_with_default)] mod tests { use std::collections::HashMap; use serde_json::json; use super::*; use crate::{ decorators::{ localization::tests::make_extended_field_localization, thread::tests::make_extended_thread, timing::tests::make_extended_timing, }, misc::test_utils, msg_fields::protocols::report_problem::{ Description, Impact, Where, WhereParty, WhoRetries, }, msg_types::cred_issuance::CredentialIssuanceTypeV1_0, }; #[test] fn test_minimal_problem_report() { let description = Description::builder() .code("test_problem_report_code".to_owned()) .build(); let content: CredIssuanceV1ProblemReportContent = ProblemReportContent::builder() .description(description) .build(); let decorators = ProblemReportDecorators::default(); let expected = json!({ "description": content.inner.description }); test_utils::test_msg( content, decorators, CredentialIssuanceTypeV1_0::ProblemReport, expected, ); } #[test] fn test_extended_problem_report() { let description = Description::builder() .code("test_problem_report_code".to_owned()) .build(); let content: ProblemReportContent = ProblemReportContent::builder() .description(description) .who_retries(WhoRetries::Me) .fix_hint("test_fix_hint".to_owned()) .impact(Impact::Connection) .location(Where::new(WhereParty::Me, "test_location".to_owned())) .noticed_time("test_noticed_time".to_owned()) .tracking_uri("https://dummy.dummy/dummy".parse().unwrap()) .escalation_uri("https://dummy.dummy/dummy".parse().unwrap()) .problem_items(vec![HashMap::from([( "test_prob_item_key".to_owned(), "test_prob_item_value".to_owned(), )])]) .build(); let decorators = ProblemReportDecorators::builder() .thread(make_extended_thread()) .timing(make_extended_timing()) .description_locale(make_extended_field_localization()) .fix_hint_locale(make_extended_field_localization()) .build(); let expected = json!({ "description": content.description, "who_retries": content.who_retries, "fix-hint": content.fix_hint, "impact": content.impact, "where": content.location, "noticed_time": content.noticed_time, "tracking-uri": content.tracking_uri, "escalation-uri": content.escalation_uri, "problem_items": content.problem_items, "~thread": decorators.thread, "~timing": decorators.timing, "description~l10n": decorators.description_locale, "fix-hint~l10n": decorators.fix_hint_locale }); let content = CredIssuanceV1ProblemReportContent::builder() .inner(content) .build(); test_utils::test_msg( content, decorators, CredentialIssuanceTypeV1_0::ProblemReport, expected, ); } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/cred_issuance/v1/request_credential.rs
aries/messages/src/msg_fields/protocols/cred_issuance/v1/request_credential.rs
use serde::{Deserialize, Serialize}; use typed_builder::TypedBuilder; use crate::{ decorators::{attachment::Attachment, thread::Thread, timing::Timing}, msg_parts::MsgParts, }; pub type RequestCredentialV1 = MsgParts<RequestCredentialV1Content, RequestCredentialV1Decorators>; #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, TypedBuilder)] pub struct RequestCredentialV1Content { #[builder(default, setter(strip_option))] #[serde(skip_serializing_if = "Option::is_none")] pub comment: Option<String>, #[serde(rename = "requests~attach")] pub requests_attach: Vec<Attachment>, } #[derive(Clone, Debug, Deserialize, Serialize, Default, PartialEq, TypedBuilder)] pub struct RequestCredentialV1Decorators { #[builder(default, setter(strip_option))] #[serde(rename = "~thread")] #[serde(skip_serializing_if = "Option::is_none")] pub thread: Option<Thread>, #[builder(default, setter(strip_option))] #[serde(rename = "~timing")] #[serde(skip_serializing_if = "Option::is_none")] pub timing: Option<Timing>, } #[cfg(test)] #[allow(clippy::field_reassign_with_default)] mod tests { use serde_json::json; use super::*; use crate::{ decorators::{ attachment::tests::make_extended_attachment, thread::tests::make_extended_thread, }, misc::test_utils, msg_types::cred_issuance::CredentialIssuanceTypeV1_0, }; #[test] fn test_minimal_request_cred() { let content = RequestCredentialV1Content::builder() .requests_attach(vec![make_extended_attachment()]) .build(); let decorators = RequestCredentialV1Decorators::default(); let expected = json!({ "requests~attach": content.requests_attach, }); test_utils::test_msg( content, decorators, CredentialIssuanceTypeV1_0::RequestCredential, expected, ); } #[test] fn test_extended_request_cred() { let content = RequestCredentialV1Content::builder() .requests_attach(vec![make_extended_attachment()]) .comment("test_comment".to_owned()) .build(); let decorators = RequestCredentialV1Decorators::builder() .thread(make_extended_thread()) .build(); let expected = json!({ "requests~attach": content.requests_attach, "comment": content.comment, "~thread": decorators.thread }); test_utils::test_msg( content, decorators, CredentialIssuanceTypeV1_0::RequestCredential, expected, ); } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/cred_issuance/v1/ack.rs
aries/messages/src/msg_fields/protocols/cred_issuance/v1/ack.rs
use serde::{Deserialize, Serialize}; use typed_builder::TypedBuilder; use crate::{ msg_fields::protocols::notification::ack::{Ack, AckContent, AckDecorators}, msg_parts::MsgParts, }; pub type AckCredentialV1 = MsgParts<AckCredentialV1Content, AckDecorators>; #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, TypedBuilder)] #[serde(transparent)] pub struct AckCredentialV1Content { pub inner: AckContent, } impl From<AckContent> for AckCredentialV1Content { fn from(value: AckContent) -> Self { Self { inner: value } } } impl From<AckCredentialV1> for Ack { fn from(value: AckCredentialV1) -> Self { Self::builder() .id(value.id) .content(value.content.inner) .decorators(value.decorators) .build() } } #[cfg(test)] #[allow(clippy::field_reassign_with_default)] mod tests { use serde_json::json; use super::*; use crate::{ decorators::{thread::tests::make_extended_thread, timing::tests::make_extended_timing}, misc::test_utils, msg_fields::protocols::notification::ack::AckStatus, msg_types::cred_issuance::CredentialIssuanceTypeV1_0, }; #[test] fn test_minimal_ack_cred() { let content: AckCredentialV1Content = AckContent::builder().status(AckStatus::Ok).build(); let decorators = AckDecorators::builder() .thread(make_extended_thread()) .build(); let expected = json!({ "status": content.inner.status, "~thread": decorators.thread }); test_utils::test_msg( content, decorators, CredentialIssuanceTypeV1_0::Ack, expected, ); } #[test] fn test_extended_ack_cred() { let content: AckCredentialV1Content = AckContent::builder().status(AckStatus::Ok).build(); let decorators = AckDecorators::builder() .thread(make_extended_thread()) .timing(make_extended_timing()) .build(); let expected = json!({ "status": content.inner.status, "~thread": decorators.thread, "~timing": decorators.timing }); test_utils::test_msg( content, decorators, CredentialIssuanceTypeV1_0::Ack, expected, ); } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/cred_issuance/v1/issue_credential.rs
aries/messages/src/msg_fields/protocols/cred_issuance/v1/issue_credential.rs
use serde::{Deserialize, Serialize}; use typed_builder::TypedBuilder; use crate::{ decorators::{attachment::Attachment, please_ack::PleaseAck, thread::Thread, timing::Timing}, msg_parts::MsgParts, }; pub type IssueCredentialV1 = MsgParts<IssueCredentialV1Content, IssueCredentialV1Decorators>; #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, TypedBuilder)] pub struct IssueCredentialV1Content { #[builder(default, setter(strip_option))] #[serde(skip_serializing_if = "Option::is_none")] pub comment: Option<String>, #[serde(rename = "credentials~attach")] pub credentials_attach: Vec<Attachment>, } #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, TypedBuilder)] pub struct IssueCredentialV1Decorators { #[serde(rename = "~thread")] pub thread: Thread, #[builder(default, setter(strip_option))] #[serde(rename = "~please_ack")] #[serde(skip_serializing_if = "Option::is_none")] pub please_ack: Option<PleaseAck>, #[builder(default, setter(strip_option))] #[serde(rename = "~timing")] #[serde(skip_serializing_if = "Option::is_none")] pub timing: Option<Timing>, } #[cfg(test)] #[allow(clippy::field_reassign_with_default)] mod tests { use serde_json::json; use super::*; use crate::{ decorators::{ attachment::tests::make_extended_attachment, please_ack::tests::make_minimal_please_ack, thread::tests::make_extended_thread, timing::tests::make_extended_timing, }, misc::test_utils, msg_types::cred_issuance::CredentialIssuanceTypeV1_0, }; #[test] fn test_minimal_issue_cred() { let content = IssueCredentialV1Content::builder() .credentials_attach(vec![make_extended_attachment()]) .build(); let decorators = IssueCredentialV1Decorators::builder() .thread(make_extended_thread()) .build(); let expected = json!({ "credentials~attach": content.credentials_attach, "~thread": decorators.thread }); test_utils::test_msg( content, decorators, CredentialIssuanceTypeV1_0::IssueCredential, expected, ); } #[test] fn test_extended_issue_cred() { let content = IssueCredentialV1Content::builder() .credentials_attach(vec![make_extended_attachment()]) .comment("test_comment".to_owned()) .build(); let decorators = IssueCredentialV1Decorators::builder() .thread(make_extended_thread()) .timing(make_extended_timing()) .please_ack(make_minimal_please_ack()) .build(); let expected = json!({ "credentials~attach": content.credentials_attach, "comment": content.comment, "~thread": decorators.thread, "~timing": decorators.timing, "~please_ack": decorators.please_ack }); test_utils::test_msg( content, decorators, CredentialIssuanceTypeV1_0::IssueCredential, expected, ); } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/cred_issuance/v1/offer_credential.rs
aries/messages/src/msg_fields/protocols/cred_issuance/v1/offer_credential.rs
use serde::{Deserialize, Serialize}; use typed_builder::TypedBuilder; use super::CredentialPreviewV1; use crate::{ decorators::{attachment::Attachment, thread::Thread, timing::Timing}, msg_parts::MsgParts, }; pub type OfferCredentialV1 = MsgParts<OfferCredentialV1Content, OfferCredentialV1Decorators>; #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, TypedBuilder)] pub struct OfferCredentialV1Content { #[builder(default, setter(strip_option))] #[serde(skip_serializing_if = "Option::is_none")] pub comment: Option<String>, pub credential_preview: CredentialPreviewV1, #[serde(rename = "offers~attach")] pub offers_attach: Vec<Attachment>, } #[derive(Clone, Debug, Deserialize, Serialize, Default, PartialEq, TypedBuilder)] pub struct OfferCredentialV1Decorators { #[builder(default, setter(strip_option))] #[serde(skip_serializing_if = "Option::is_none")] #[serde(rename = "~thread")] pub thread: Option<Thread>, #[builder(default, setter(strip_option))] #[serde(rename = "~timing")] #[serde(skip_serializing_if = "Option::is_none")] pub timing: Option<Timing>, } #[cfg(test)] #[allow(clippy::field_reassign_with_default)] mod tests { use serde_json::json; use super::*; use crate::{ decorators::{ attachment::tests::make_extended_attachment, thread::tests::make_extended_thread, timing::tests::make_extended_timing, }, misc::test_utils, msg_fields::protocols::cred_issuance::v1::CredentialAttr, msg_types::cred_issuance::CredentialIssuanceTypeV1_0, }; #[test] fn test_minimal_offer_cred() { let attribute = CredentialAttr::builder() .name("test_attribute_name".to_owned()) .value("test_attribute_value".to_owned()) .build(); let preview = CredentialPreviewV1::new(vec![attribute]); let content = OfferCredentialV1Content::builder() .credential_preview(preview) .offers_attach(vec![make_extended_attachment()]) .build(); let decorators = OfferCredentialV1Decorators::default(); let expected = json!({ "offers~attach": content.offers_attach, "credential_preview": content.credential_preview, }); test_utils::test_msg( content, decorators, CredentialIssuanceTypeV1_0::OfferCredential, expected, ); } #[test] fn test_extended_offer_cred() { let attribute = CredentialAttr::builder() .name("test_attribute_name".to_owned()) .value("test_attribute_value".to_owned()) .build(); let preview = CredentialPreviewV1::new(vec![attribute]); let content = OfferCredentialV1Content::builder() .credential_preview(preview) .offers_attach(vec![make_extended_attachment()]) .comment("test_comment".to_owned()) .build(); let decorators = OfferCredentialV1Decorators::builder() .thread(make_extended_thread()) .timing(make_extended_timing()) .build(); let expected = json!({ "offers~attach": content.offers_attach, "credential_preview": content.credential_preview, "comment": content.comment, "~thread": decorators.thread, "~timing": decorators.timing }); test_utils::test_msg( content, decorators, CredentialIssuanceTypeV1_0::OfferCredential, expected, ); } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/cred_issuance/v1/mod.rs
aries/messages/src/msg_fields/protocols/cred_issuance/v1/mod.rs
//! Module containing the `issue credential` protocol messages, as defined in the [RFC](<https://github.com/decentralized-identity/aries-rfcs/blob/main/features/0036-issue-credential/README.md>). pub mod ack; pub mod issue_credential; pub mod offer_credential; pub mod problem_report; pub mod propose_credential; pub mod request_credential; use std::str::FromStr; use derive_more::From; use serde::{de::Error, Deserialize, Deserializer, Serialize, Serializer}; use shared::misc::utils::CowStr; use self::{ ack::{AckCredentialV1, AckCredentialV1Content}, issue_credential::{IssueCredentialV1, IssueCredentialV1Content, IssueCredentialV1Decorators}, offer_credential::{OfferCredentialV1, OfferCredentialV1Content, OfferCredentialV1Decorators}, problem_report::{CredIssuanceV1ProblemReport, CredIssuanceV1ProblemReportContent}, propose_credential::{ ProposeCredentialV1, ProposeCredentialV1Content, ProposeCredentialV1Decorators, }, request_credential::{ RequestCredentialV1, RequestCredentialV1Content, RequestCredentialV1Decorators, }, }; use super::{common::CredentialAttr, CredentialIssuance}; use crate::{ misc::utils::{self, into_msg_with_type, transit_to_aries_msg}, msg_fields::{ protocols::{notification::ack::AckDecorators, report_problem::ProblemReportDecorators}, traits::DelayedSerde, }, msg_types::{ protocols::cred_issuance::{ CredentialIssuanceType as CredentialIssuanceKind, CredentialIssuanceTypeV1, CredentialIssuanceTypeV1_0, }, traits::MessageKind, MessageType, MsgWithType, Protocol, }, }; #[derive(Clone, Debug, From, PartialEq)] pub enum CredentialIssuanceV1 { OfferCredential(OfferCredentialV1), ProposeCredential(ProposeCredentialV1), RequestCredential(RequestCredentialV1), IssueCredential(IssueCredentialV1), Ack(AckCredentialV1), ProblemReport(CredIssuanceV1ProblemReport), } impl DelayedSerde for CredentialIssuanceV1 { type MsgType<'a> = (CredentialIssuanceKind, &'a str); fn delayed_deserialize<'de, D>( msg_type: Self::MsgType<'de>, deserializer: D, ) -> Result<Self, D::Error> where D: Deserializer<'de>, { let (protocol, kind_str) = msg_type; let kind = match protocol { CredentialIssuanceKind::V1(CredentialIssuanceTypeV1::V1_0(kind)) => { kind.kind_from_str(kind_str) } CredentialIssuanceKind::V2(_) => return Err(D::Error::custom( "Cannot deserialize issue-credential-v2 message type into issue-credential-v1", )), }; match kind.map_err(D::Error::custom)? { CredentialIssuanceTypeV1_0::OfferCredential => { OfferCredentialV1::deserialize(deserializer).map(From::from) } CredentialIssuanceTypeV1_0::ProposeCredential => { ProposeCredentialV1::deserialize(deserializer).map(From::from) } CredentialIssuanceTypeV1_0::RequestCredential => { RequestCredentialV1::deserialize(deserializer).map(From::from) } CredentialIssuanceTypeV1_0::IssueCredential => { IssueCredentialV1::deserialize(deserializer).map(From::from) } CredentialIssuanceTypeV1_0::Ack => { AckCredentialV1::deserialize(deserializer).map(From::from) } CredentialIssuanceTypeV1_0::ProblemReport => { CredIssuanceV1ProblemReport::deserialize(deserializer).map(From::from) } CredentialIssuanceTypeV1_0::CredentialPreview => { Err(utils::not_standalone_msg::<D>(kind_str)) } } } fn delayed_serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: Serializer, { match self { Self::OfferCredential(v) => MsgWithType::from(v).serialize(serializer), Self::ProposeCredential(v) => MsgWithType::from(v).serialize(serializer), Self::RequestCredential(v) => MsgWithType::from(v).serialize(serializer), Self::IssueCredential(v) => MsgWithType::from(v).serialize(serializer), Self::Ack(v) => MsgWithType::from(v).serialize(serializer), Self::ProblemReport(v) => MsgWithType::from(v).serialize(serializer), } } } #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] pub struct CredentialPreviewV1 { #[serde(rename = "@type")] msg_type: CredentialPreviewV1MsgType, pub attributes: Vec<CredentialAttr>, } impl CredentialPreviewV1 { pub fn new(attributes: Vec<CredentialAttr>) -> Self { Self { msg_type: CredentialPreviewV1MsgType, attributes, } } } /// Non-standalone message type. /// This is only encountered as part of an existent message. /// It is not a message on it's own. #[derive(Copy, Clone, Debug, Default, Deserialize, PartialEq)] #[serde(try_from = "CowStr")] struct CredentialPreviewV1MsgType; impl<'a> From<&'a CredentialPreviewV1MsgType> for CredentialIssuanceTypeV1_0 { fn from(_value: &'a CredentialPreviewV1MsgType) -> Self { CredentialIssuanceTypeV1_0::CredentialPreview } } impl TryFrom<CowStr<'_>> for CredentialPreviewV1MsgType { type Error = String; fn try_from(value: CowStr) -> Result<Self, Self::Error> { let value = MessageType::try_from(value.0.as_ref())?; if let Protocol::CredentialIssuanceType(CredentialIssuanceKind::V1( CredentialIssuanceTypeV1::V1_0(_), )) = value.protocol { if let Ok(CredentialIssuanceTypeV1_0::CredentialPreview) = CredentialIssuanceTypeV1_0::from_str(value.kind) { return Ok(CredentialPreviewV1MsgType); } } Err(format!("message kind is not {}", value.kind)) } } impl Serialize for CredentialPreviewV1MsgType { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, { let protocol = Protocol::from(CredentialIssuanceTypeV1_0::parent()); let kind = CredentialIssuanceTypeV1_0::from(self); format_args!("{protocol}/{}", kind.as_ref()).serialize(serializer) } } transit_to_aries_msg!( OfferCredentialV1Content: OfferCredentialV1Decorators, CredentialIssuanceV1, CredentialIssuance ); transit_to_aries_msg!( ProposeCredentialV1Content: ProposeCredentialV1Decorators, CredentialIssuanceV1, CredentialIssuance ); transit_to_aries_msg!( RequestCredentialV1Content: RequestCredentialV1Decorators, CredentialIssuanceV1, CredentialIssuance ); transit_to_aries_msg!( IssueCredentialV1Content: IssueCredentialV1Decorators, CredentialIssuanceV1, CredentialIssuance ); transit_to_aries_msg!(AckCredentialV1Content: AckDecorators, CredentialIssuanceV1, CredentialIssuance); transit_to_aries_msg!( CredIssuanceV1ProblemReportContent: ProblemReportDecorators, CredentialIssuanceV1, CredentialIssuance ); into_msg_with_type!( OfferCredentialV1, CredentialIssuanceTypeV1_0, OfferCredential ); into_msg_with_type!( ProposeCredentialV1, CredentialIssuanceTypeV1_0, ProposeCredential ); into_msg_with_type!( RequestCredentialV1, CredentialIssuanceTypeV1_0, RequestCredential ); into_msg_with_type!( IssueCredentialV1, CredentialIssuanceTypeV1_0, IssueCredential ); into_msg_with_type!(AckCredentialV1, CredentialIssuanceTypeV1_0, Ack); into_msg_with_type!( CredIssuanceV1ProblemReport, CredentialIssuanceTypeV1_0, ProblemReport );
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/cred_issuance/v1/propose_credential.rs
aries/messages/src/msg_fields/protocols/cred_issuance/v1/propose_credential.rs
use serde::{Deserialize, Serialize}; use typed_builder::TypedBuilder; use super::CredentialPreviewV1; use crate::{ decorators::{thread::Thread, timing::Timing}, msg_parts::MsgParts, }; pub type ProposeCredentialV1 = MsgParts<ProposeCredentialV1Content, ProposeCredentialV1Decorators>; #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, TypedBuilder)] pub struct ProposeCredentialV1Content { #[builder(default, setter(strip_option))] #[serde(skip_serializing_if = "Option::is_none")] pub comment: Option<String>, pub credential_proposal: CredentialPreviewV1, pub schema_id: String, pub cred_def_id: String, } #[derive(Clone, Debug, Deserialize, Serialize, Default, PartialEq, TypedBuilder)] pub struct ProposeCredentialV1Decorators { #[builder(default, setter(strip_option))] #[serde(skip_serializing_if = "Option::is_none")] #[serde(rename = "~thread")] pub thread: Option<Thread>, #[builder(default, setter(strip_option))] #[serde(rename = "~timing")] #[serde(skip_serializing_if = "Option::is_none")] pub timing: Option<Timing>, } #[cfg(test)] #[allow(clippy::field_reassign_with_default)] mod tests { use serde_json::json; use super::*; use crate::{ decorators::{thread::tests::make_extended_thread, timing::tests::make_extended_timing}, misc::test_utils, msg_fields::protocols::cred_issuance::v1::CredentialAttr, msg_types::cred_issuance::CredentialIssuanceTypeV1_0, }; #[test] fn test_minimal_propose_cred() { let attribute = CredentialAttr::builder() .name("test_attribute_name".to_owned()) .value("test_attribute_value".to_owned()) .build(); let preview = CredentialPreviewV1::new(vec![attribute]); let content = ProposeCredentialV1Content::builder() .credential_proposal(preview) .schema_id("test_schema_id".to_owned()) .cred_def_id("test_cred_def_id".to_owned()) .build(); let decorators = ProposeCredentialV1Decorators::default(); let expected = json!({ "credential_proposal": content.credential_proposal, "schema_id": content.schema_id, "cred_def_id": content.cred_def_id, }); test_utils::test_msg( content, decorators, CredentialIssuanceTypeV1_0::ProposeCredential, expected, ); } #[test] fn test_extended_propose_cred() { let attribute = CredentialAttr::builder() .name("test_attribute_name".to_owned()) .value("test_attribute_value".to_owned()) .build(); let preview = CredentialPreviewV1::new(vec![attribute]); let content = ProposeCredentialV1Content::builder() .credential_proposal(preview) .schema_id("test_schema_id".to_owned()) .cred_def_id("test_cred_def_id".to_owned()) .comment("test_comment".to_owned()) .build(); let decorators = ProposeCredentialV1Decorators::builder() .thread(make_extended_thread()) .timing(make_extended_timing()) .build(); let expected = json!({ "credential_proposal": content.credential_proposal, "schema_id": content.schema_id, "cred_def_id": content.cred_def_id, "comment": content.comment, "~thread": decorators.thread, "~timing": decorators.timing }); test_utils::test_msg( content, decorators, CredentialIssuanceTypeV1_0::ProposeCredential, expected, ); } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/cred_issuance/common/mod.rs
aries/messages/src/msg_fields/protocols/cred_issuance/common/mod.rs
use serde::{Deserialize, Serialize}; use typed_builder::TypedBuilder; use crate::misc::MimeType; #[derive(Debug, Serialize, Deserialize, Clone, PartialEq, TypedBuilder)] #[serde(rename_all = "kebab-case")] pub struct CredentialAttr { pub name: String, pub value: String, #[builder(default, setter(strip_option))] #[serde(skip_serializing_if = "Option::is_none")] #[serde(rename = "mime-type")] pub mime_type: Option<MimeType>, }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/cred_issuance/v2/problem_report.rs
aries/messages/src/msg_fields/protocols/cred_issuance/v2/problem_report.rs
use serde::{Deserialize, Serialize}; use typed_builder::TypedBuilder; use crate::{ msg_fields::protocols::report_problem::{ ProblemReport, ProblemReportContent, ProblemReportDecorators, }, msg_parts::MsgParts, }; pub type CredIssuanceProblemReportV2 = MsgParts<CredIssuanceV2ProblemReportContent, ProblemReportDecorators>; #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, TypedBuilder)] #[serde(transparent)] pub struct CredIssuanceV2ProblemReportContent { pub inner: ProblemReportContent, } impl From<ProblemReportContent> for CredIssuanceV2ProblemReportContent { fn from(value: ProblemReportContent) -> Self { Self { inner: value } } } impl From<CredIssuanceProblemReportV2> for ProblemReport { fn from(value: CredIssuanceProblemReportV2) -> Self { Self::builder() .id(value.id) .content(value.content.inner) .decorators(value.decorators) .build() } } #[cfg(test)] #[allow(clippy::field_reassign_with_default)] mod tests { use std::collections::HashMap; use serde_json::json; use super::*; use crate::{ decorators::{ localization::tests::make_extended_field_localization, thread::tests::make_extended_thread, timing::tests::make_extended_timing, }, misc::test_utils, msg_fields::protocols::report_problem::{ Description, Impact, Where, WhereParty, WhoRetries, }, msg_types::cred_issuance::CredentialIssuanceTypeV2_0, }; #[test] fn test_minimal_problem_report() { let description = Description::builder() .code("test_problem_report_code".to_owned()) .build(); let content: CredIssuanceV2ProblemReportContent = ProblemReportContent::builder() .description(description) .build(); let decorators = ProblemReportDecorators::default(); let expected = json!({ "description": content.inner.description }); test_utils::test_msg( content, decorators, CredentialIssuanceTypeV2_0::ProblemReport, expected, ); } #[test] fn test_extended_problem_report() { let description = Description::builder() .code("test_problem_report_code".to_owned()) .build(); let content: ProblemReportContent = ProblemReportContent::builder() .description(description) .who_retries(WhoRetries::Me) .fix_hint("test_fix_hint".to_owned()) .impact(Impact::Connection) .location(Where::new(WhereParty::Me, "test_location".to_owned())) .noticed_time("test_noticed_time".to_owned()) .tracking_uri("https://dummy.dummy/dummy".parse().unwrap()) .escalation_uri("https://dummy.dummy/dummy".parse().unwrap()) .problem_items(vec![HashMap::from([( "test_prob_item_key".to_owned(), "test_prob_item_value".to_owned(), )])]) .build(); let decorators = ProblemReportDecorators::builder() .thread(make_extended_thread()) .timing(make_extended_timing()) .description_locale(make_extended_field_localization()) .fix_hint_locale(make_extended_field_localization()) .build(); let expected = json!({ "description": content.description, "who_retries": content.who_retries, "fix-hint": content.fix_hint, "impact": content.impact, "where": content.location, "noticed_time": content.noticed_time, "tracking-uri": content.tracking_uri, "escalation-uri": content.escalation_uri, "problem_items": content.problem_items, "~thread": decorators.thread, "~timing": decorators.timing, "description~l10n": decorators.description_locale, "fix-hint~l10n": decorators.fix_hint_locale }); let content = CredIssuanceV2ProblemReportContent::builder() .inner(content) .build(); test_utils::test_msg( content, decorators, CredentialIssuanceTypeV2_0::ProblemReport, expected, ); } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/cred_issuance/v2/request_credential.rs
aries/messages/src/msg_fields/protocols/cred_issuance/v2/request_credential.rs
use serde::{Deserialize, Serialize}; use typed_builder::TypedBuilder; use crate::{ decorators::{attachment::Attachment, thread::Thread, timing::Timing}, msg_fields::protocols::common::attachment_format_specifier::AttachmentFormatSpecifier, msg_parts::MsgParts, }; pub type RequestCredentialV2 = MsgParts<RequestCredentialV2Content, RequestCredentialV2Decorators>; #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, TypedBuilder)] pub struct RequestCredentialV2Content { #[builder(default)] #[serde(skip_serializing_if = "Option::is_none")] pub goal_code: Option<String>, #[builder(default)] #[serde(skip_serializing_if = "Option::is_none")] pub comment: Option<String>, pub formats: Vec<AttachmentFormatSpecifier<RequestCredentialAttachmentFormatType>>, #[serde(rename = "requests~attach")] pub requests_attach: Vec<Attachment>, } #[derive(Clone, Debug, Deserialize, Serialize, Default, PartialEq, TypedBuilder)] pub struct RequestCredentialV2Decorators { #[builder(default)] #[serde(rename = "~thread")] #[serde(skip_serializing_if = "Option::is_none")] pub thread: Option<Thread>, #[builder(default)] #[serde(rename = "~timing")] #[serde(skip_serializing_if = "Option::is_none")] pub timing: Option<Timing>, } #[derive(Clone, Debug, Deserialize, Serialize, PartialEq)] pub enum RequestCredentialAttachmentFormatType { #[serde(rename = "dif/credential-manifest@v1.0")] DifCredentialManifest1_0, #[serde(rename = "hlindy/cred-req@v2.0")] HyperledgerIndyCredentialRequest2_0, #[serde(rename = "anoncreds/credential-request@v1.0")] AnoncredsCredentialRequest1_0, #[serde(rename = "aries/ld-proof-vc-detail@v1.0")] AriesLdProofVcDetail1_0, } #[cfg(test)] #[allow(clippy::field_reassign_with_default)] mod tests { use serde_json::json; use shared::maybe_known::MaybeKnown; use super::*; use crate::{ decorators::{ attachment::tests::make_extended_attachment, thread::tests::make_extended_thread, }, misc::test_utils, msg_types::cred_issuance::CredentialIssuanceTypeV2_0, }; #[test] fn test_minimal_request_cred() { let content = RequestCredentialV2Content::builder() .requests_attach(vec![make_extended_attachment()]) .formats(vec![AttachmentFormatSpecifier { attach_id: "1".to_owned(), format: MaybeKnown::Known( RequestCredentialAttachmentFormatType::HyperledgerIndyCredentialRequest2_0, ), }]) .build(); let decorators = RequestCredentialV2Decorators::default(); let expected = json!({ "requests~attach": content.requests_attach, "formats": content.formats }); test_utils::test_msg( content, decorators, CredentialIssuanceTypeV2_0::RequestCredential, expected, ); } #[test] fn test_extended_request_cred() { let content = RequestCredentialV2Content::builder() .requests_attach(vec![make_extended_attachment()]) .formats(vec![AttachmentFormatSpecifier { attach_id: "1".to_owned(), format: MaybeKnown::Known( RequestCredentialAttachmentFormatType::HyperledgerIndyCredentialRequest2_0, ), }]) .comment(Some("test_comment".to_owned())) .goal_code(Some("goal.goal".to_owned())) .build(); let decorators = RequestCredentialV2Decorators::builder() .thread(Some(make_extended_thread())) .build(); let expected = json!({ "requests~attach": content.requests_attach, "formats": content.formats, "comment": content.comment, "goal_code": content.goal_code, "~thread": decorators.thread }); test_utils::test_msg( content, decorators, CredentialIssuanceTypeV2_0::RequestCredential, expected, ); } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/cred_issuance/v2/ack.rs
aries/messages/src/msg_fields/protocols/cred_issuance/v2/ack.rs
use serde::{Deserialize, Serialize}; use typed_builder::TypedBuilder; use crate::{ msg_fields::protocols::notification::ack::{Ack, AckContent, AckDecorators}, msg_parts::MsgParts, }; pub type AckCredentialV2 = MsgParts<AckCredentialV2Content, AckDecorators>; #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, TypedBuilder)] #[serde(transparent)] pub struct AckCredentialV2Content { pub inner: AckContent, } impl From<AckContent> for AckCredentialV2Content { fn from(value: AckContent) -> Self { Self { inner: value } } } impl From<AckCredentialV2> for Ack { fn from(value: AckCredentialV2) -> Self { Self::builder() .id(value.id) .content(value.content.inner) .decorators(value.decorators) .build() } } #[cfg(test)] #[allow(clippy::field_reassign_with_default)] mod tests { use serde_json::json; use super::*; use crate::{ decorators::{thread::tests::make_extended_thread, timing::tests::make_extended_timing}, misc::test_utils, msg_fields::protocols::notification::ack::AckStatus, msg_types::cred_issuance::CredentialIssuanceTypeV2_0, }; #[test] fn test_minimal_ack_cred() { let content: AckCredentialV2Content = AckContent::builder().status(AckStatus::Ok).build(); let decorators = AckDecorators::builder() .thread(make_extended_thread()) .build(); let expected = json!({ "status": content.inner.status, "~thread": decorators.thread }); test_utils::test_msg( content, decorators, CredentialIssuanceTypeV2_0::Ack, expected, ); } #[test] fn test_extended_ack_cred() { let content: AckCredentialV2Content = AckContent::builder().status(AckStatus::Ok).build(); let decorators = AckDecorators::builder() .thread(make_extended_thread()) .timing(make_extended_timing()) .build(); let expected = json!({ "status": content.inner.status, "~thread": decorators.thread, "~timing": decorators.timing }); test_utils::test_msg( content, decorators, CredentialIssuanceTypeV2_0::Ack, expected, ); } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/cred_issuance/v2/issue_credential.rs
aries/messages/src/msg_fields/protocols/cred_issuance/v2/issue_credential.rs
use serde::{Deserialize, Serialize}; use typed_builder::TypedBuilder; use crate::{ decorators::{attachment::Attachment, please_ack::PleaseAck, thread::Thread, timing::Timing}, msg_fields::protocols::common::attachment_format_specifier::AttachmentFormatSpecifier, msg_parts::MsgParts, }; pub type IssueCredentialV2 = MsgParts<IssueCredentialV2Content, IssueCredentialV2Decorators>; #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, TypedBuilder)] pub struct IssueCredentialV2Content { #[builder(default)] #[serde(skip_serializing_if = "Option::is_none")] pub goal_code: Option<String>, #[builder(default)] #[serde(skip_serializing_if = "Option::is_none")] pub replacement_id: Option<String>, #[builder(default)] #[serde(skip_serializing_if = "Option::is_none")] pub comment: Option<String>, pub formats: Vec<AttachmentFormatSpecifier<IssueCredentialAttachmentFormatType>>, #[serde(rename = "credentials~attach")] pub credentials_attach: Vec<Attachment>, } #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, TypedBuilder)] pub struct IssueCredentialV2Decorators { #[serde(rename = "~thread")] pub thread: Thread, #[builder(default)] #[serde(rename = "~please_ack")] #[serde(skip_serializing_if = "Option::is_none")] pub please_ack: Option<PleaseAck>, #[builder(default)] #[serde(rename = "~timing")] #[serde(skip_serializing_if = "Option::is_none")] pub timing: Option<Timing>, } #[derive(Clone, Debug, Deserialize, Serialize, PartialEq)] pub enum IssueCredentialAttachmentFormatType { #[serde(rename = "aries/ld-proof-vc@v1.0")] AriesLdProofVc1_0, #[serde(rename = "anoncreds/credential@v1.0")] AnoncredsCredential1_0, #[serde(rename = "hlindy/cred@v2.0")] HyperledgerIndyCredential2_0, } #[cfg(test)] #[allow(clippy::field_reassign_with_default)] mod tests { use serde_json::json; use shared::maybe_known::MaybeKnown; use super::*; use crate::{ decorators::{ attachment::tests::make_extended_attachment, please_ack::tests::make_minimal_please_ack, thread::tests::make_extended_thread, timing::tests::make_extended_timing, }, misc::test_utils, msg_types::cred_issuance::CredentialIssuanceTypeV2_0, }; #[test] fn test_minimal_issue_cred() { let content = IssueCredentialV2Content::builder() .formats(vec![AttachmentFormatSpecifier { attach_id: "1".to_owned(), format: MaybeKnown::Known( IssueCredentialAttachmentFormatType::HyperledgerIndyCredential2_0, ), }]) .credentials_attach(vec![make_extended_attachment()]) .build(); let decorators = IssueCredentialV2Decorators::builder() .thread(make_extended_thread()) .build(); let expected = json!({ "formats": content.formats, "credentials~attach": content.credentials_attach, "~thread": decorators.thread }); test_utils::test_msg( content, decorators, CredentialIssuanceTypeV2_0::IssueCredential, expected, ); } #[test] fn test_extended_issue_cred() { let content = IssueCredentialV2Content::builder() .formats(vec![AttachmentFormatSpecifier { attach_id: "1".to_owned(), format: shared::maybe_known::MaybeKnown::Known( IssueCredentialAttachmentFormatType::HyperledgerIndyCredential2_0, ), }]) .credentials_attach(vec![make_extended_attachment()]) .goal_code(Some("goal.goal".to_owned())) .replacement_id(Some("replacement-123".to_owned())) .comment(Some("test_comment".to_owned())) .build(); let decorators = IssueCredentialV2Decorators::builder() .thread(make_extended_thread()) .timing(Some(make_extended_timing())) .please_ack(Some(make_minimal_please_ack())) .build(); let expected = json!({ "formats": content.formats, "credentials~attach": content.credentials_attach, "goal_code": content.goal_code, "replacement_id": content.replacement_id, "comment": content.comment, "~thread": decorators.thread, "~timing": decorators.timing, "~please_ack": decorators.please_ack }); test_utils::test_msg( content, decorators, CredentialIssuanceTypeV2_0::IssueCredential, expected, ); } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/cred_issuance/v2/offer_credential.rs
aries/messages/src/msg_fields/protocols/cred_issuance/v2/offer_credential.rs
use serde::{Deserialize, Serialize}; use typed_builder::TypedBuilder; use super::CredentialPreviewV2; use crate::{ decorators::{attachment::Attachment, thread::Thread, timing::Timing}, msg_fields::protocols::common::attachment_format_specifier::AttachmentFormatSpecifier, msg_parts::MsgParts, }; pub type OfferCredentialV2 = MsgParts<OfferCredentialV2Content, OfferCredentialV2Decorators>; #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, TypedBuilder)] pub struct OfferCredentialV2Content { #[builder(default)] #[serde(skip_serializing_if = "Option::is_none")] pub goal_code: Option<String>, #[builder(default)] #[serde(skip_serializing_if = "Option::is_none")] pub replacement_id: Option<String>, #[builder(default)] #[serde(skip_serializing_if = "Option::is_none")] pub comment: Option<String>, pub credential_preview: CredentialPreviewV2, pub formats: Vec<AttachmentFormatSpecifier<OfferCredentialAttachmentFormatType>>, #[serde(rename = "offers~attach")] pub offers_attach: Vec<Attachment>, } #[derive(Clone, Debug, Deserialize, Serialize, Default, PartialEq, TypedBuilder)] pub struct OfferCredentialV2Decorators { #[builder(default)] #[serde(skip_serializing_if = "Option::is_none")] #[serde(rename = "~thread")] pub thread: Option<Thread>, #[builder(default)] #[serde(rename = "~timing")] #[serde(skip_serializing_if = "Option::is_none")] pub timing: Option<Timing>, } #[derive(Clone, Debug, Deserialize, Serialize, PartialEq)] pub enum OfferCredentialAttachmentFormatType { #[serde(rename = "dif/credential-manifest@v1.0")] DifCredentialManifest1_0, #[serde(rename = "hlindy/cred-abstract@v2.0")] HyperledgerIndyCredentialAbstract2_0, #[serde(rename = "anoncreds/credential-offer@v1.0")] AnoncredsCredentialOffer1_0, #[serde(rename = "aries/ld-proof-vc-detail@v1.0")] AriesLdProofVcDetail1_0, } #[cfg(test)] #[allow(clippy::field_reassign_with_default)] mod tests { use serde_json::json; use shared::maybe_known::MaybeKnown; use super::*; use crate::{ decorators::{ attachment::tests::make_extended_attachment, thread::tests::make_extended_thread, timing::tests::make_extended_timing, }, misc::test_utils, msg_fields::protocols::cred_issuance::common::CredentialAttr, msg_types::cred_issuance::CredentialIssuanceTypeV2_0, }; #[test] fn test_minimal_offer_cred() { let attribute = CredentialAttr::builder() .name("test_attribute_name".to_owned()) .value("test_attribute_value".to_owned()) .build(); let preview = CredentialPreviewV2::new(vec![attribute]); let content = OfferCredentialV2Content::builder() .credential_preview(preview) .formats(vec![AttachmentFormatSpecifier { attach_id: "1".to_owned(), format: MaybeKnown::Known( OfferCredentialAttachmentFormatType::HyperledgerIndyCredentialAbstract2_0, ), }]) .offers_attach(vec![make_extended_attachment()]) .build(); let decorators = OfferCredentialV2Decorators::default(); let expected = json!({ "formats": content.formats, "offers~attach": content.offers_attach, "credential_preview": content.credential_preview, }); test_utils::test_msg( content, decorators, CredentialIssuanceTypeV2_0::OfferCredential, expected, ); } #[test] fn test_extended_offer_cred() { let attribute = CredentialAttr::builder() .name("test_attribute_name".to_owned()) .value("test_attribute_value".to_owned()) .build(); let preview = CredentialPreviewV2::new(vec![attribute]); let content = OfferCredentialV2Content::builder() .credential_preview(preview) .formats(vec![AttachmentFormatSpecifier { attach_id: "1".to_owned(), format: MaybeKnown::Known( OfferCredentialAttachmentFormatType::HyperledgerIndyCredentialAbstract2_0, ), }]) .offers_attach(vec![make_extended_attachment()]) .comment(Some("test_comment".to_owned())) .replacement_id(Some("replacement_id".to_owned())) .goal_code(Some("goal.goal".to_owned())) .build(); let decorators = OfferCredentialV2Decorators::builder() .thread(Some(make_extended_thread())) .timing(Some(make_extended_timing())) .build(); let expected = json!({ "formats": content.formats, "offers~attach": content.offers_attach, "credential_preview": content.credential_preview, "comment": content.comment, "goal_code": content.goal_code, "replacement_id": content.replacement_id, "~thread": decorators.thread, "~timing": decorators.timing }); test_utils::test_msg( content, decorators, CredentialIssuanceTypeV2_0::OfferCredential, expected, ); } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/cred_issuance/v2/mod.rs
aries/messages/src/msg_fields/protocols/cred_issuance/v2/mod.rs
//! Module containing the `issue credential` protocol messages, as defined in the [RFC](<https://github.com/decentralized-identity/aries-rfcs/blob/main/features/0036-issue-credential/README.md>). pub mod ack; pub mod issue_credential; pub mod offer_credential; pub mod problem_report; pub mod propose_credential; pub mod request_credential; use std::str::FromStr; use derive_more::From; use serde::{de::Error, Deserialize, Deserializer, Serialize, Serializer}; use shared::misc::utils::CowStr; use self::{ ack::{AckCredentialV2, AckCredentialV2Content}, issue_credential::{IssueCredentialV2, IssueCredentialV2Content, IssueCredentialV2Decorators}, offer_credential::{OfferCredentialV2, OfferCredentialV2Content, OfferCredentialV2Decorators}, problem_report::{CredIssuanceProblemReportV2, CredIssuanceV2ProblemReportContent}, propose_credential::{ ProposeCredentialV2, ProposeCredentialV2Content, ProposeCredentialV2Decorators, }, request_credential::{ RequestCredentialV2, RequestCredentialV2Content, RequestCredentialV2Decorators, }, }; use super::{ super::{notification::ack::AckDecorators, report_problem::ProblemReportDecorators}, common::CredentialAttr, CredentialIssuance, }; use crate::{ misc::utils::{self, into_msg_with_type, transit_to_aries_msg}, msg_fields::traits::DelayedSerde, msg_types::{ cred_issuance::{CredentialIssuanceTypeV2, CredentialIssuanceTypeV2_0}, protocols::cred_issuance::CredentialIssuanceType as CredentialIssuanceKind, traits::MessageKind, MessageType, MsgWithType, Protocol, }, }; #[derive(Clone, Debug, From, PartialEq)] pub enum CredentialIssuanceV2 { OfferCredential(OfferCredentialV2), ProposeCredential(ProposeCredentialV2), RequestCredential(RequestCredentialV2), IssueCredential(IssueCredentialV2), Ack(AckCredentialV2), ProblemReport(CredIssuanceProblemReportV2), } impl DelayedSerde for CredentialIssuanceV2 { type MsgType<'a> = (CredentialIssuanceKind, &'a str); fn delayed_deserialize<'de, D>( msg_type: Self::MsgType<'de>, deserializer: D, ) -> Result<Self, D::Error> where D: Deserializer<'de>, { let (protocol, kind_str) = msg_type; let kind = match protocol { CredentialIssuanceKind::V2(CredentialIssuanceTypeV2::V2_0(kind)) => { kind.kind_from_str(kind_str) } CredentialIssuanceKind::V1(_) => return Err(D::Error::custom( "Cannot deserialize issue-credential-v1 message type into issue-credential-v2", )), }; match kind.map_err(D::Error::custom)? { CredentialIssuanceTypeV2_0::OfferCredential => { OfferCredentialV2::deserialize(deserializer).map(From::from) } CredentialIssuanceTypeV2_0::ProposeCredential => { ProposeCredentialV2::deserialize(deserializer).map(From::from) } CredentialIssuanceTypeV2_0::RequestCredential => { RequestCredentialV2::deserialize(deserializer).map(From::from) } CredentialIssuanceTypeV2_0::IssueCredential => { IssueCredentialV2::deserialize(deserializer).map(From::from) } CredentialIssuanceTypeV2_0::Ack => { AckCredentialV2::deserialize(deserializer).map(From::from) } CredentialIssuanceTypeV2_0::ProblemReport => { CredIssuanceProblemReportV2::deserialize(deserializer).map(From::from) } CredentialIssuanceTypeV2_0::CredentialPreview => { Err(utils::not_standalone_msg::<D>(kind_str)) } } } fn delayed_serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: Serializer, { match self { Self::OfferCredential(v) => MsgWithType::from(v).serialize(serializer), Self::ProposeCredential(v) => MsgWithType::from(v).serialize(serializer), Self::RequestCredential(v) => MsgWithType::from(v).serialize(serializer), Self::IssueCredential(v) => MsgWithType::from(v).serialize(serializer), Self::Ack(v) => MsgWithType::from(v).serialize(serializer), Self::ProblemReport(v) => MsgWithType::from(v).serialize(serializer), } } } #[derive(Debug, Serialize, Deserialize, Clone, PartialEq)] pub struct CredentialPreviewV2 { #[serde(rename = "@type")] msg_type: CredentialPreviewV2MsgType, pub attributes: Vec<CredentialAttr>, } impl CredentialPreviewV2 { pub fn new(attributes: Vec<CredentialAttr>) -> Self { Self { msg_type: CredentialPreviewV2MsgType, attributes, } } } /// Non-standalone message type. /// This is only encountered as part of an existent message. /// It is not a message on it's own. #[derive(Copy, Clone, Debug, Default, Deserialize, PartialEq)] #[serde(try_from = "CowStr")] struct CredentialPreviewV2MsgType; impl<'a> From<&'a CredentialPreviewV2MsgType> for CredentialIssuanceTypeV2_0 { fn from(_value: &'a CredentialPreviewV2MsgType) -> Self { CredentialIssuanceTypeV2_0::CredentialPreview } } impl TryFrom<CowStr<'_>> for CredentialPreviewV2MsgType { type Error = String; fn try_from(value: CowStr) -> Result<Self, Self::Error> { let value = MessageType::try_from(value.0.as_ref())?; if let Protocol::CredentialIssuanceType(CredentialIssuanceKind::V2( CredentialIssuanceTypeV2::V2_0(_), )) = value.protocol { if let Ok(CredentialIssuanceTypeV2_0::CredentialPreview) = CredentialIssuanceTypeV2_0::from_str(value.kind) { return Ok(CredentialPreviewV2MsgType); } } Err(format!("message kind is not {}", value.kind)) } } impl Serialize for CredentialPreviewV2MsgType { fn serialize<S>(&self, serializer: S) -> Result<S::Ok, S::Error> where S: serde::Serializer, { let protocol = Protocol::from(CredentialIssuanceTypeV2_0::parent()); let kind = CredentialIssuanceTypeV2_0::from(self); format_args!("{protocol}/{}", kind.as_ref()).serialize(serializer) } } transit_to_aries_msg!( OfferCredentialV2Content: OfferCredentialV2Decorators, CredentialIssuanceV2, CredentialIssuance ); transit_to_aries_msg!( ProposeCredentialV2Content: ProposeCredentialV2Decorators, CredentialIssuanceV2, CredentialIssuance ); transit_to_aries_msg!( RequestCredentialV2Content: RequestCredentialV2Decorators, CredentialIssuanceV2, CredentialIssuance ); transit_to_aries_msg!( IssueCredentialV2Content: IssueCredentialV2Decorators, CredentialIssuanceV2, CredentialIssuance ); transit_to_aries_msg!(AckCredentialV2Content: AckDecorators, CredentialIssuanceV2, CredentialIssuance); transit_to_aries_msg!( CredIssuanceV2ProblemReportContent: ProblemReportDecorators, CredentialIssuanceV2, CredentialIssuance ); into_msg_with_type!( OfferCredentialV2, CredentialIssuanceTypeV2_0, OfferCredential ); into_msg_with_type!( ProposeCredentialV2, CredentialIssuanceTypeV2_0, ProposeCredential ); into_msg_with_type!( RequestCredentialV2, CredentialIssuanceTypeV2_0, RequestCredential ); into_msg_with_type!( IssueCredentialV2, CredentialIssuanceTypeV2_0, IssueCredential ); into_msg_with_type!(AckCredentialV2, CredentialIssuanceTypeV2_0, Ack); into_msg_with_type!( CredIssuanceProblemReportV2, CredentialIssuanceTypeV2_0, ProblemReport );
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/cred_issuance/v2/propose_credential.rs
aries/messages/src/msg_fields/protocols/cred_issuance/v2/propose_credential.rs
use serde::{Deserialize, Serialize}; use typed_builder::TypedBuilder; use super::CredentialPreviewV2; use crate::{ decorators::{attachment::Attachment, thread::Thread, timing::Timing}, msg_fields::protocols::common::attachment_format_specifier::AttachmentFormatSpecifier, msg_parts::MsgParts, }; pub type ProposeCredentialV2 = MsgParts<ProposeCredentialV2Content, ProposeCredentialV2Decorators>; #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, TypedBuilder)] pub struct ProposeCredentialV2Content { #[builder(default)] #[serde(skip_serializing_if = "Option::is_none")] pub goal_code: Option<String>, // TODO - spec does not specify what goal codes to use.. #[builder(default)] #[serde(skip_serializing_if = "Option::is_none")] pub comment: Option<String>, #[builder(default)] #[serde(skip_serializing_if = "Option::is_none")] pub credential_preview: Option<CredentialPreviewV2>, pub formats: Vec<AttachmentFormatSpecifier<ProposeCredentialAttachmentFormatType>>, #[serde(rename = "filters~attach")] pub filters_attach: Vec<Attachment>, } #[derive(Clone, Debug, Deserialize, Serialize, Default, PartialEq, TypedBuilder)] pub struct ProposeCredentialV2Decorators { #[builder(default)] #[serde(skip_serializing_if = "Option::is_none")] #[serde(rename = "~thread")] pub thread: Option<Thread>, #[builder(default)] #[serde(rename = "~timing")] #[serde(skip_serializing_if = "Option::is_none")] pub timing: Option<Timing>, } #[derive(Clone, Debug, Deserialize, Serialize, PartialEq)] pub enum ProposeCredentialAttachmentFormatType { #[serde(rename = "dif/credential-manifest@v1.0")] DifCredentialManifest1_0, #[serde(rename = "aries/ld-proof-vc-detail@v1.0")] AriesLdProofVcDetail1_0, #[serde(rename = "anoncreds/credential-filter@v1.0")] AnoncredCredentialFilter1_0, #[serde(rename = "hlindy/cred-filter@v2.0")] HyperledgerIndyCredentialFilter2_0, } #[cfg(test)] #[allow(clippy::field_reassign_with_default)] mod tests { use serde_json::json; use shared::maybe_known::MaybeKnown; use super::*; use crate::{ decorators::{ attachment::tests::make_extended_attachment, thread::tests::make_extended_thread, timing::tests::make_extended_timing, }, misc::test_utils, msg_fields::protocols::cred_issuance::common::CredentialAttr, msg_types::cred_issuance::CredentialIssuanceTypeV2_0, }; #[test] fn test_minimal_propose_cred() { let content = ProposeCredentialV2Content::builder() .formats(vec![AttachmentFormatSpecifier { attach_id: String::from("1"), format: MaybeKnown::Known( ProposeCredentialAttachmentFormatType::HyperledgerIndyCredentialFilter2_0, ), }]) .filters_attach(vec![make_extended_attachment()]) .build(); let decorators = ProposeCredentialV2Decorators::default(); let expected = json!({ "formats": content.formats, "filters~attach": content.filters_attach, }); test_utils::test_msg( content, decorators, CredentialIssuanceTypeV2_0::ProposeCredential, expected, ); } #[test] fn test_extended_propose_cred() { let attribute = CredentialAttr::builder() .name("test_attribute_name".to_owned()) .value("test_attribute_value".to_owned()) .build(); let preview = CredentialPreviewV2::new(vec![attribute]); let content = ProposeCredentialV2Content::builder() .credential_preview(Some(preview)) .formats(vec![AttachmentFormatSpecifier { attach_id: String::from("1"), format: MaybeKnown::Known( ProposeCredentialAttachmentFormatType::HyperledgerIndyCredentialFilter2_0, ), }]) .filters_attach(vec![make_extended_attachment()]) .comment(Some("test_comment".to_owned())) .goal_code(Some("goal.goal".to_owned())) .build(); let decorators = ProposeCredentialV2Decorators::builder() .thread(Some(make_extended_thread())) .timing(Some(make_extended_timing())) .build(); let expected = json!({ "credential_preview": content.credential_preview, "formats": content.formats, "filters~attach": content.filters_attach, "comment": content.comment, "goal_code": content.goal_code, "~thread": decorators.thread, "~timing": decorators.timing }); test_utils::test_msg( content, decorators, CredentialIssuanceTypeV2_0::ProposeCredential, expected, ); } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/out_of_band/reuse_accepted.rs
aries/messages/src/msg_fields/protocols/out_of_band/reuse_accepted.rs
use serde::{Deserialize, Serialize}; use shared::misc::serde_ignored::SerdeIgnored; use typed_builder::TypedBuilder; use crate::{ decorators::{thread::Thread, timing::Timing}, msg_parts::MsgParts, }; pub type HandshakeReuseAccepted = MsgParts<HandshakeReuseAcceptedContent, HandshakeReuseAcceptedDecorators>; #[derive(Clone, Debug, Deserialize, Serialize, Default, PartialEq, TypedBuilder)] #[serde(transparent)] pub struct HandshakeReuseAcceptedContent { #[builder(default, setter(skip))] inner: SerdeIgnored, } #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, TypedBuilder)] pub struct HandshakeReuseAcceptedDecorators { #[serde(rename = "~thread")] pub thread: Thread, #[builder(default, setter(strip_option))] #[serde(rename = "~timing")] #[serde(skip_serializing_if = "Option::is_none")] pub timing: Option<Timing>, } #[cfg(test)] #[allow(clippy::field_reassign_with_default)] mod tests { use serde_json::json; use super::*; use crate::{ decorators::{thread::tests::make_extended_thread, timing::tests::make_extended_timing}, misc::test_utils, msg_types::out_of_band::OutOfBandTypeV1_1, }; #[test] fn test_minimal_reuse_accepted() { let content = HandshakeReuseAcceptedContent::default(); let decorators = HandshakeReuseAcceptedDecorators::builder() .thread(make_extended_thread()) .build(); let expected = json!({ "~thread": decorators.thread }); test_utils::test_msg( content, decorators, OutOfBandTypeV1_1::HandshakeReuseAccepted, expected, ); } #[test] fn test_extended_reuse_accepted() { let content = HandshakeReuseAcceptedContent::default(); let decorators = HandshakeReuseAcceptedDecorators::builder() .thread(make_extended_thread()) .timing(make_extended_timing()) .build(); let expected = json!({ "~thread": decorators.thread, "~timing": decorators.timing }); test_utils::test_msg( content, decorators, OutOfBandTypeV1_1::HandshakeReuseAccepted, expected, ); } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false
openwallet-foundation/vcx
https://github.com/openwallet-foundation/vcx/blob/2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7/aries/messages/src/msg_fields/protocols/out_of_band/invitation.rs
aries/messages/src/msg_fields/protocols/out_of_band/invitation.rs
use diddoc_legacy::aries::service::AriesService; use serde::{Deserialize, Serialize}; use shared::maybe_known::MaybeKnown; use typed_builder::TypedBuilder; use super::OobGoalCode; use crate::{ decorators::{attachment::Attachment, timing::Timing}, misc::MimeType, msg_parts::MsgParts, msg_types::Protocol, }; pub type Invitation = MsgParts<InvitationContent, InvitationDecorators>; #[derive(Clone, Debug, Deserialize, Serialize, PartialEq, TypedBuilder)] pub struct InvitationContent { #[builder(default, setter(strip_option))] #[serde(skip_serializing_if = "Option::is_none")] pub label: Option<String>, #[builder(default, setter(strip_option))] #[serde(skip_serializing_if = "Option::is_none")] pub goal_code: Option<MaybeKnown<OobGoalCode>>, #[builder(default, setter(strip_option))] #[serde(skip_serializing_if = "Option::is_none")] pub goal: Option<String>, #[builder(default, setter(strip_option))] #[serde(skip_serializing_if = "Option::is_none")] pub accept: Option<Vec<MimeType>>, #[builder(default, setter(strip_option))] #[serde(skip_serializing_if = "Option::is_none")] pub handshake_protocols: Option<Vec<MaybeKnown<Protocol>>>, #[builder(default, setter(strip_option))] #[serde(skip_serializing_if = "Option::is_none")] #[serde(rename = "requests~attach")] pub requests_attach: Option<Vec<Attachment>>, pub services: Vec<OobService>, } #[derive(Clone, Debug, Deserialize, Serialize, Default, PartialEq, TypedBuilder)] pub struct InvitationDecorators { #[builder(default, setter(strip_option))] #[serde(rename = "~timing")] #[serde(skip_serializing_if = "Option::is_none")] pub timing: Option<Timing>, } #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] #[serde(untagged)] pub enum OobService { // TODO: DidCommV2 and AIP2 services don't include recipient keys // and if service id is not a resolvable did (it must be just a URI) // then there is no way to resolve the recipient keys // must be missing something // SovService(ServiceSov), AriesService(AriesService), Did(String), } #[cfg(test)] #[allow(clippy::field_reassign_with_default)] mod tests { use serde_json::json; use super::*; use crate::{ decorators::{ attachment::tests::make_extended_attachment, timing::tests::make_extended_timing, }, misc::test_utils, msg_types::{out_of_band::OutOfBandTypeV1_1, protocols::connection::ConnectionTypeV1}, }; #[test] fn test_minimal_oob_invitation() { let content = InvitationContent::builder() .services(vec![OobService::Did("test_service_did".to_owned())]) .build(); let decorators = InvitationDecorators::default(); let expected = json!({ "services": content.services, }); test_utils::test_msg(content, decorators, OutOfBandTypeV1_1::Invitation, expected); } #[test] fn test_extended_oob_invitation() { let content = InvitationContent::builder() .services(vec![OobService::Did("test_service_did".to_owned())]) .requests_attach(vec![make_extended_attachment()]) .label("test_label".to_owned()) .goal_code(MaybeKnown::Known(OobGoalCode::P2PMessaging)) .goal("test_oob_goal".to_owned()) .accept(vec![MimeType::Json, MimeType::Plain]) .handshake_protocols(vec![MaybeKnown::Known(ConnectionTypeV1::new_v1_0().into())]) .build(); let decorators = InvitationDecorators::builder() .timing(make_extended_timing()) .build(); let expected = json!({ "label": content.label, "goal_code": content.goal_code, "goal": content.goal, "accept": content.accept, "handshake_protocols": content.handshake_protocols, "services": content.services, "requests~attach": content.requests_attach, "~timing": decorators.timing }); test_utils::test_msg(content, decorators, OutOfBandTypeV1_1::Invitation, expected); } }
rust
Apache-2.0
2d3034ed73ba8d49e0f72251b4c7cfb859a1efe7
2026-01-04T20:24:59.602734Z
false