Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/protocols problem report #840

Merged
merged 4 commits into from
May 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions aries_vcx/src/handlers/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ pub fn verify_thread_id(thread_id: &str, message: &AriesMessage) -> VcxResult<()
AriesMessage::CredentialIssuance(CredentialIssuance::RequestCredential(msg)) => {
matches_opt_thread_id!(msg, thread_id)
}
AriesMessage::CredentialIssuance(CredentialIssuance::ProblemReport(msg)) => {
matches_opt_thread_id!(msg, thread_id)
}
AriesMessage::DiscoverFeatures(DiscoverFeatures::Query(msg)) => msg.id == thread_id,
AriesMessage::DiscoverFeatures(DiscoverFeatures::Disclose(msg)) => matches_thread_id!(msg, thread_id),
AriesMessage::Notification(Notification::Ack(msg)) => matches_thread_id!(msg, thread_id),
Expand All @@ -109,6 +112,7 @@ pub fn verify_thread_id(thread_id: &str, message: &AriesMessage) -> VcxResult<()
AriesMessage::PresentProof(PresentProof::Presentation(msg)) => matches_thread_id!(msg, thread_id),
AriesMessage::PresentProof(PresentProof::ProposePresentation(msg)) => matches_opt_thread_id!(msg, thread_id),
AriesMessage::PresentProof(PresentProof::RequestPresentation(msg)) => matches_opt_thread_id!(msg, thread_id),
AriesMessage::PresentProof(PresentProof::ProblemReport(msg)) => matches_opt_thread_id!(msg, thread_id),
AriesMessage::ReportProblem(msg) => matches_opt_thread_id!(msg, thread_id),
AriesMessage::Revocation(Revocation::Revoke(msg)) => matches_opt_thread_id!(msg, thread_id),
AriesMessage::Revocation(Revocation::Ack(msg)) => matches_thread_id!(msg, thread_id),
Expand Down
9 changes: 9 additions & 0 deletions aries_vcx/src/protocols/issuance/actions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,15 @@ impl From<AriesMessage> for CredentialIssuanceAction {
let report = ProblemReport::with_decorators(id, content.0, decorators);
CredentialIssuanceAction::ProblemReport(report)
}
AriesMessage::CredentialIssuance(CredentialIssuance::ProblemReport(report)) => {
let MsgParts {
id,
content,
decorators,
} = report;
let report = ProblemReport::with_decorators(id, content.0, decorators);
CredentialIssuanceAction::ProblemReport(report)
}
_ => CredentialIssuanceAction::Unknown,
}
}
Expand Down
5 changes: 5 additions & 0 deletions aries_vcx/src/protocols/issuance/holder/state_machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,11 @@ impl HolderSM {
return Some((uid, message));
}
}
AriesMessage::CredentialIssuance(CredentialIssuance::ProblemReport(problem_report)) => {
if matches_opt_thread_id!(problem_report, self.thread_id.as_str()) {
return Some((uid, message));
}
}
AriesMessage::ReportProblem(problem_report) => {
if matches_opt_thread_id!(problem_report, self.thread_id.as_str()) {
return Some((uid, message));
Expand Down
13 changes: 11 additions & 2 deletions aries_vcx/src/protocols/proof_presentation/prover/messages.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,9 @@ impl From<AriesMessage> for ProverMessages {
ProverMessages::PresentationAckReceived(ack)
}
AriesMessage::PresentProof(PresentProof::Ack(ack)) => ProverMessages::PresentationAckReceived(ack),
AriesMessage::PresentProof(PresentProof::RequestPresentation(request)) => {
ProverMessages::PresentationRequestReceived(request)
}
AriesMessage::ReportProblem(report) => ProverMessages::PresentationRejectReceived(report),
AriesMessage::Notification(Notification::ProblemReport(report)) => {
let MsgParts {
Expand All @@ -64,8 +67,14 @@ impl From<AriesMessage> for ProverMessages {
let report = ProblemReport::with_decorators(id, content.0, decorators);
ProverMessages::PresentationRejectReceived(report)
}
AriesMessage::PresentProof(PresentProof::RequestPresentation(request)) => {
ProverMessages::PresentationRequestReceived(request)
AriesMessage::PresentProof(PresentProof::ProblemReport(report)) => {
let MsgParts {
id,
content,
decorators,
} = report;
let report = ProblemReport::with_decorators(id, content.0, decorators);
ProverMessages::PresentationRejectReceived(report)
}
_ => ProverMessages::Unknown,
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -324,6 +324,11 @@ impl ProverSM {
return Some((uid, message));
}
}
AriesMessage::PresentProof(PresentProof::ProblemReport(msg)) => {
if matches_opt_thread_id!(msg, self.thread_id.as_str()) {
return Some((uid, message));
}
}
_ => {}
},
_ => {}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,15 @@ impl From<AriesMessage> for VerifierMessages {
let report = ProblemReport::with_decorators(id, content.0, decorators);
VerifierMessages::PresentationRejectReceived(report)
}
AriesMessage::PresentProof(PresentProof::ProblemReport(report)) => {
let MsgParts {
id,
content,
decorators,
} = report;
let report = ProblemReport::with_decorators(id, content.0, decorators);
VerifierMessages::PresentationRejectReceived(report)
}
_ => VerifierMessages::Unknown,
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ use chrono::Utc;
use messages::decorators::thread::Thread;
use messages::decorators::timing::Timing;
use messages::msg_fields::protocols::notification::ack::{AckDecorators, AckStatus};
use messages::msg_fields::protocols::notification::problem_report::{
NotificationProblemReport, NotificationProblemReportContent,
};
use messages::msg_fields::protocols::present_proof::ack::{AckPresentation, AckPresentationContent};
use messages::msg_fields::protocols::present_proof::problem_report::{
PresentProofProblemReport, PresentProofProblemReportContent,
};
use messages::msg_fields::protocols::present_proof::request::{
RequestPresentation, RequestPresentationContent, RequestPresentationDecorators,
};
Expand Down Expand Up @@ -257,9 +257,9 @@ impl VerifierSM {
decorators,
} = problem_report;

let problem_report = NotificationProblemReport::with_decorators(
let problem_report = PresentProofProblemReport::with_decorators(
id,
NotificationProblemReportContent(content),
PresentProofProblemReportContent(content),
decorators,
);

Expand Down
2 changes: 1 addition & 1 deletion ci/libvcx.dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ RUN cp /usr/share/zoneinfo/UTC /etc/localtime && echo UTC > /etc/timezone
ENV TZ=UTC

RUN echo 'https://dl-cdn.alpinelinux.org/alpine/v3.17/main' >> /etc/apk/repositories
RUN apk add --no-cache nodejs=18.14.2-r0
RUN apk add --no-cache nodejs~=18

USER node
14 changes: 13 additions & 1 deletion messages/src/msg_fields/protocols/cred_issuance/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
pub mod ack;
pub mod issue_credential;
pub mod offer_credential;
pub mod problem_report;
pub mod propose_credential;
pub mod request_credential;

Expand All @@ -16,10 +17,11 @@ use self::{
ack::{AckCredential, AckCredentialContent},
issue_credential::{IssueCredential, IssueCredentialContent, IssueCredentialDecorators},
offer_credential::{OfferCredential, OfferCredentialContent, OfferCredentialDecorators},
problem_report::{CredIssuanceProblemReport, CredIssuanceProblemReportContent},
propose_credential::{ProposeCredential, ProposeCredentialContent, ProposeCredentialDecorators},
request_credential::{RequestCredential, RequestCredentialContent, RequestCredentialDecorators},
};
use super::notification::ack::AckDecorators;
use super::{notification::ack::AckDecorators, report_problem::ProblemReportDecorators};
use crate::{
misc::{
utils::{self, into_msg_with_type, transit_to_aries_msg},
Expand All @@ -42,6 +44,7 @@ pub enum CredentialIssuance {
RequestCredential(RequestCredential),
IssueCredential(IssueCredential),
Ack(AckCredential),
ProblemReport(CredIssuanceProblemReport),
}

impl DelayedSerde for CredentialIssuance {
Expand All @@ -66,6 +69,9 @@ impl DelayedSerde for CredentialIssuance {
}
CredentialIssuanceTypeV1_0::IssueCredential => IssueCredential::deserialize(deserializer).map(From::from),
CredentialIssuanceTypeV1_0::Ack => AckCredential::deserialize(deserializer).map(From::from),
CredentialIssuanceTypeV1_0::ProblemReport => {
CredIssuanceProblemReport::deserialize(deserializer).map(From::from)
}
CredentialIssuanceTypeV1_0::CredentialPreview => Err(utils::not_standalone_msg::<D>(kind_str)),
}
}
Expand All @@ -80,6 +86,7 @@ impl DelayedSerde for CredentialIssuance {
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),
}
}
}
Expand Down Expand Up @@ -174,9 +181,14 @@ transit_to_aries_msg!(
);
transit_to_aries_msg!(IssueCredentialContent: IssueCredentialDecorators, CredentialIssuance);
transit_to_aries_msg!(AckCredentialContent: AckDecorators, CredentialIssuance);
transit_to_aries_msg!(
CredIssuanceProblemReportContent: ProblemReportDecorators,
CredentialIssuance
);

into_msg_with_type!(OfferCredential, CredentialIssuanceTypeV1_0, OfferCredential);
into_msg_with_type!(ProposeCredential, CredentialIssuanceTypeV1_0, ProposeCredential);
into_msg_with_type!(RequestCredential, CredentialIssuanceTypeV1_0, RequestCredential);
into_msg_with_type!(IssueCredential, CredentialIssuanceTypeV1_0, IssueCredential);
into_msg_with_type!(AckCredential, CredentialIssuanceTypeV1_0, Ack);
into_msg_with_type!(CredIssuanceProblemReport, CredentialIssuanceTypeV1_0, ProblemReport);
18 changes: 18 additions & 0 deletions messages/src/msg_fields/protocols/cred_issuance/problem_report.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
use serde::{Deserialize, Serialize};

use crate::{
msg_fields::protocols::report_problem::{ProblemReportContent, ProblemReportDecorators},
msg_parts::MsgParts,
};

pub type CredIssuanceProblemReport = MsgParts<CredIssuanceProblemReportContent, ProblemReportDecorators>;

#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
#[serde(transparent)]
pub struct CredIssuanceProblemReportContent(pub ProblemReportContent);

impl CredIssuanceProblemReportContent {
pub fn new(code: String) -> Self {
Self(ProblemReportContent::new(code))
}
}
9 changes: 8 additions & 1 deletion messages/src/msg_fields/protocols/present_proof/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

pub mod ack;
pub mod present;
pub mod problem_report;
pub mod propose;
pub mod request;

Expand All @@ -11,10 +12,11 @@ use serde::{de::Error, Deserialize, Deserializer, Serialize, Serializer};
use self::{
ack::{AckPresentation, AckPresentationContent},
present::{Presentation, PresentationContent, PresentationDecorators},
problem_report::{PresentProofProblemReport, PresentProofProblemReportContent},
propose::{ProposePresentation, ProposePresentationContent, ProposePresentationDecorators},
request::{RequestPresentation, RequestPresentationContent, RequestPresentationDecorators},
};
use super::notification::ack::AckDecorators;
use super::{notification::ack::AckDecorators, report_problem::ProblemReportDecorators};
use crate::{
misc::utils::{self, into_msg_with_type, transit_to_aries_msg},
msg_fields::traits::DelayedSerde,
Expand All @@ -30,6 +32,7 @@ pub enum PresentProof {
RequestPresentation(RequestPresentation),
Presentation(Presentation),
Ack(AckPresentation),
ProblemReport(PresentProofProblemReport),
}

impl DelayedSerde for PresentProof {
Expand All @@ -50,6 +53,7 @@ impl DelayedSerde for PresentProof {
PresentProofTypeV1_0::RequestPresentation => RequestPresentation::deserialize(deserializer).map(From::from),
PresentProofTypeV1_0::Presentation => Presentation::deserialize(deserializer).map(From::from),
PresentProofTypeV1_0::Ack => AckPresentation::deserialize(deserializer).map(From::from),
PresentProofTypeV1_0::ProblemReport => PresentProofProblemReport::deserialize(deserializer).map(From::from),
PresentProofTypeV1_0::PresentationPreview => Err(utils::not_standalone_msg::<D>(kind_str)),
}
}
Expand All @@ -63,6 +67,7 @@ impl DelayedSerde for PresentProof {
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),
}
}
}
Expand All @@ -71,8 +76,10 @@ transit_to_aries_msg!(ProposePresentationContent: ProposePresentationDecorators,
transit_to_aries_msg!(RequestPresentationContent: RequestPresentationDecorators, PresentProof);
transit_to_aries_msg!(PresentationContent: PresentationDecorators, PresentProof);
transit_to_aries_msg!(AckPresentationContent: AckDecorators, PresentProof);
transit_to_aries_msg!(PresentProofProblemReportContent: ProblemReportDecorators, PresentProof);

into_msg_with_type!(ProposePresentation, PresentProofTypeV1_0, ProposePresentation);
into_msg_with_type!(RequestPresentation, PresentProofTypeV1_0, RequestPresentation);
into_msg_with_type!(Presentation, PresentProofTypeV1_0, Presentation);
into_msg_with_type!(AckPresentation, PresentProofTypeV1_0, Ack);
into_msg_with_type!(PresentProofProblemReport, PresentProofTypeV1_0, ProblemReport);
18 changes: 18 additions & 0 deletions messages/src/msg_fields/protocols/present_proof/problem_report.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
use serde::{Deserialize, Serialize};

use crate::{
msg_fields::protocols::report_problem::{ProblemReportContent, ProblemReportDecorators},
msg_parts::MsgParts,
};

pub type PresentProofProblemReport = MsgParts<PresentProofProblemReportContent, ProblemReportDecorators>;

#[derive(Clone, Debug, Deserialize, Serialize, PartialEq)]
#[serde(transparent)]
pub struct PresentProofProblemReportContent(pub ProblemReportContent);

impl PresentProofProblemReportContent {
pub fn new(code: String) -> Self {
Self(ProblemReportContent::new(code))
}
}
1 change: 1 addition & 0 deletions messages/src/msg_types/protocols/cred_issuance.rs
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ pub enum CredentialIssuanceTypeV1_0 {
IssueCredential,
CredentialPreview,
Ack,
ProblemReport,
}

#[cfg(test)]
Expand Down
1 change: 1 addition & 0 deletions messages/src/msg_types/protocols/present_proof.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ pub enum PresentProofTypeV1_0 {
Presentation,
PresentationPreview,
Ack,
ProblemReport,
}

#[cfg(test)]
Expand Down