From 26c1cbe61ac8fcefdb882c42c967194a0bd05349 Mon Sep 17 00:00:00 2001 From: Patrik Date: Tue, 21 Mar 2023 16:55:38 +0100 Subject: [PATCH] Changed Proof (Verifier) API for checking presentation status (#770) * Remove Verifier's Proof method get_presentation_status(...) Signed-off-by: Patrik Stas * Rename get_revocation_status to get_presentation_verification_status, rename enum variants Signed-off-by: Patrik Stas * Use new enum PresentationVerificationStatus instead of RevocationStatus Signed-off-by: Patrik Stas * Modify libvcx api get_proof_msg to only return presentation msg (removed proofStatus from result set) Signed-off-by: Patrik Stas * Fix test in libvcx_core Signed-off-by: Patrik Stas * Fix test compile errs Signed-off-by: Patrik Stas * Fix unit test Signed-off-by: Patrik Stas * Fix integration test Signed-off-by: Patrik Stas * Make unimplemented mock logs more explicit Signed-off-by: Patrik Stas * Reformat Signed-off-by: Patrik Stas * Fix libvcx ios header file Signed-off-by: Patrik Stas * Rename field revocation_status->verification_status, sync up nodejs wrapper, unify method names Signed-off-by: Patrik Stas * Fix nodejs vcxagent-core Signed-off-by: Patrik Stas * Fix ci Signed-off-by: Patrik Stas * Fix formatting Signed-off-by: Patrik Stas * Fix libvcx java wrapper Signed-off-by: Patrik Stas * Address code review Signed-off-by: Patrik Stas * Optimize deserialization Signed-off-by: Patrik Stas * Address code review Signed-off-by: Patrik Stas * Address code review Signed-off-by: Patrik Stas * Fix deserialization case when verification_status/revocation_status is undefined Signed-off-by: Patrik Stas --------- Signed-off-by: Patrik Stas --- agents/node/vcxagent-core/demo/faber.js | 14 +- .../src/services/service-verifier.js | 8 +- .../vcxagent-core/test/issue-verify.spec.js | 25 +-- agents/node/vcxagent-core/test/utils/faber.js | 6 +- .../aries-vcx-agent/src/services/verifier.rs | 5 +- .../handlers/proof_presentation/verifier.rs | 11 +- .../proof_presentation/verifier/mod.rs | 1 + .../verifier/state_machine.rs | 77 ++++---- .../verifier/states/finished.rs | 170 +++++++++++++++++- .../states/presentation_request_sent.rs | 20 ++- .../verifier/verification_status.rs | 50 ++++++ .../src/utils/mockdata/mockdata_proof.rs | 2 +- .../utils/mockdata/profile/mock_anoncreds.rs | 16 +- .../src/utils/mockdata/profile/mock_ledger.rs | 4 +- .../src/utils/mockdata/profile/mock_wallet.rs | 2 +- aries_vcx/tests/test_creds_proofs.rs | 54 +++--- .../tests/test_creds_proofs_revocations.rs | 111 ++++++------ aries_vcx/tests/utils/devsetup_agent.rs | 12 +- aries_vcx/tests/utils/scenarios.rs | 5 +- libvcx/src/api_c/protocols/proof.rs | 18 +- libvcx_core/src/api_vcx/api_handle/proof.rs | 50 +++--- wrappers/ios/vcx/VcxAPI.h | 2 +- wrappers/ios/vcx/VcxAPI.m | 6 +- wrappers/ios/vcx/include/libvcx.h | 2 +- .../evernym/sdk/vcx/proof/GetProofResult.java | 15 +- .../com/evernym/sdk/vcx/proof/ProofApi.java | 6 +- wrappers/node/src/api/proof.ts | 22 +-- wrappers/vcx-napi-rs/index.d.ts | 3 +- wrappers/vcx-napi-rs/index.js | 5 +- wrappers/vcx-napi-rs/src/api/proof.rs | 9 +- 30 files changed, 453 insertions(+), 278 deletions(-) create mode 100644 aries_vcx/src/protocols/proof_presentation/verifier/verification_status.rs diff --git a/agents/node/vcxagent-core/demo/faber.js b/agents/node/vcxagent-core/demo/faber.js index a0ff1d8749..5b85336563 100644 --- a/agents/node/vcxagent-core/demo/faber.js +++ b/agents/node/vcxagent-core/demo/faber.js @@ -112,22 +112,22 @@ async function runFaber (options) { logger.info('#27 Process the proof provided by alice.') const presentation = vcxProof.getPresentationMsg() - const verificationState = vcxProof.getPresentationVerificationStatus() - logger.info(`#27 Proof: proofVerificationStatus=${verificationState}, proof=${presentation}`) - assert(verificationState) + const verificationStatus = vcxProof.getVerificationStatus() + logger.info(`#27 Proof: proofVerificationStatus=${verificationStatus}, proof=${presentation}`) + assert(verificationStatus) assert(presentation) logger.info(`Proof protocol state = ${JSON.stringify(proofProtocolState)}`) - logger.info(`Proof verification state =${verificationState}`) + logger.info(`Proof verification state =${verificationStatus}`) logger.debug(`Proof presentation = ${JSON.stringify(presentation, null, 2)}`) logger.debug(`Serialized Proof state machine ${JSON.stringify(await vcxProof.serialize())}`) - if (verificationState === ProofVerificationStatus.Verified) { + if (verificationStatus === ProofVerificationStatus.Valid) { if (options.revocation) { throw Error('Proof was verified, but was expected to be invalid, because revocation was enabled.') } else { logger.info('Proof was verified.') } - } else if (verificationState === ProofVerificationStatus.Invalid) { + } else if (verificationStatus === ProofVerificationStatus.Invalid) { if (options.revocation) { logger.info('Proof was determined as invalid, which was expected because the used credential was revoked.') } else { @@ -135,7 +135,7 @@ async function runFaber (options) { } await sleepPromise(1000) } else { - logger.error(`Unexpected proof state '${verificationState}'.`) + logger.error(`Unexpected proof state '${verificationStatus}'.`) process.exit(-1) } diff --git a/agents/node/vcxagent-core/src/services/service-verifier.js b/agents/node/vcxagent-core/src/services/service-verifier.js index 7d69f74f06..3393314393 100644 --- a/agents/node/vcxagent-core/src/services/service-verifier.js +++ b/agents/node/vcxagent-core/src/services/service-verifier.js @@ -67,14 +67,14 @@ module.exports.createServiceVerifier = function createServiceVerifier ({ logger, return JSON.parse(proof.getPresentationRequestAttachment()) } - async function getPresentationVerificationStatus (proofId) { + async function getVerificationStatus (proofId) { const proof = await loadProof(proofId) - return proof.getPresentationVerificationStatus() + return proof.getVerificationStatus() } async function getRevocationStatus (proofId) { const proof = await loadProof(proofId) - return proof.getPresentationVerificationStatus() + return proof.getVerificationStatus() } async function listIds () { @@ -107,7 +107,7 @@ module.exports.createServiceVerifier = function createServiceVerifier ({ logger, getPresentationMsg, getPresentationAttachment, getPresentationRequestAttachment, - getPresentationVerificationStatus, + getVerificationStatus, getRevocationStatus } } diff --git a/agents/node/vcxagent-core/test/issue-verify.spec.js b/agents/node/vcxagent-core/test/issue-verify.spec.js index 1f02f7c65d..78458c0a12 100644 --- a/agents/node/vcxagent-core/test/issue-verify.spec.js +++ b/agents/node/vcxagent-core/test/issue-verify.spec.js @@ -6,8 +6,7 @@ const { HolderStateType, ProverStateType, VerifierStateType, - ProofVerificationStatus, - ProofRevocationStatus + ProofVerificationStatus } = require('@hyperledger/node-vcx-wrapper') const sleep = require('sleep-promise') const { initRustLogger } = require('../src') @@ -43,13 +42,11 @@ describe('test update state', () => { await faber.updateStateVerifierProof(VerifierStateType.Finished) await alice.updateStateHolderProof(ProverStateType.Finished) const { - presentationVerificationState, + presentationVerificationStatus, presentationAttachment, - presentationRequestAttachment, - revocationStatus + presentationRequestAttachment } = await faber.getPresentationInfo() - expect(revocationStatus).toBe(ProofRevocationStatus.NonRevoked) - expect(presentationVerificationState).toBe(ProofVerificationStatus.Verified) + expect(presentationVerificationStatus).toBe(ProofVerificationStatus.Valid) expect(presentationRequestAttachment.requested_attributes).toStrictEqual({ attribute_0: { names: [ @@ -143,11 +140,9 @@ describe('test update state', () => { await faber.updateStateVerifierProof(VerifierStateType.Finished) await alice.updateStateHolderProof(ProverStateType.Finished) const { - presentationVerificationState, - revocationStatus + presentationVerificationStatus } = await faber.getPresentationInfo() - expect(revocationStatus).toBe(ProofRevocationStatus.Revoked) - expect(presentationVerificationState).toBe(ProofVerificationStatus.Invalid) + expect(presentationVerificationStatus).toBe(ProofVerificationStatus.Invalid) }) it('Faber should verify proof with self attestation', async () => { @@ -157,13 +152,11 @@ describe('test update state', () => { await faber.updateStateVerifierProof(VerifierStateType.Finished) await alice.updateStateHolderProof(ProverStateType.Finished) const { - presentationVerificationState, + presentationVerificationStatus, presentationAttachment, - presentationRequestAttachment, - revocationStatus + presentationRequestAttachment } = await faber.getPresentationInfo() - expect(revocationStatus).toBe(ProofRevocationStatus.NonRevoked) - expect(presentationVerificationState).toBe(ProofVerificationStatus.Verified) + expect(presentationVerificationStatus).toBe(ProofVerificationStatus.Valid) expect(presentationAttachment.requested_proof).toStrictEqual({ revealed_attrs: {}, self_attested_attrs: { diff --git a/agents/node/vcxagent-core/test/utils/faber.js b/agents/node/vcxagent-core/test/utils/faber.js index 0d53fbcb9f..876196859f 100644 --- a/agents/node/vcxagent-core/test/utils/faber.js +++ b/agents/node/vcxagent-core/test/utils/faber.js @@ -401,18 +401,16 @@ module.exports.createFaber = async function createFaber (serviceEndpoint = 'http logger.info('Faber is gather info about received presentation') await vcxAgent.agentInitVcx() const presentationMsg = await vcxAgent.serviceVerifier.getPresentationMsg(proofId) - const presentationVerificationState = await vcxAgent.serviceVerifier.getPresentationVerificationStatus(proofId) + const presentationVerificationStatus = await vcxAgent.serviceVerifier.getVerificationStatus(proofId) const presentationAttachment = await vcxAgent.serviceVerifier.getPresentationAttachment(proofId) const presentationRequestAttachment = await vcxAgent.serviceVerifier.getPresentationRequestAttachment(proofId) - const revocationStatus = await vcxAgent.serviceVerifier.getRevocationStatus(proofId) await vcxAgent.agentShutdownVcx() return { presentationMsg, - presentationVerificationState, + presentationVerificationStatus, presentationAttachment, presentationRequestAttachment, - revocationStatus } } diff --git a/agents/rust/aries-vcx-agent/src/services/verifier.rs b/agents/rust/aries-vcx-agent/src/services/verifier.rs index f74559ef8c..3b55bd9d7a 100644 --- a/agents/rust/aries-vcx-agent/src/services/verifier.rs +++ b/agents/rust/aries-vcx-agent/src/services/verifier.rs @@ -12,6 +12,7 @@ use aries_vcx::messages::protocols::proof_presentation::presentation::Presentati use aries_vcx::messages::protocols::proof_presentation::presentation_proposal::PresentationProposal; use aries_vcx::messages::status::Status; use aries_vcx::protocols::proof_presentation::verifier::state_machine::VerifierState; +use aries_vcx::protocols::proof_presentation::verifier::verification_status::PresentationVerificationStatus; use aries_vcx::protocols::SendClosure; use super::connection::ServiceConnections; @@ -72,9 +73,9 @@ impl ServiceVerifier { ) } - pub fn get_presentation_status(&self, thread_id: &str) -> AgentResult { + pub fn get_presentation_status(&self, thread_id: &str) -> AgentResult { let VerifierWrapper { verifier, .. } = self.verifiers.get(thread_id)?; - Ok(verifier.get_presentation_status()) + Ok(verifier.get_verification_status()) } pub async fn verify_presentation(&self, thread_id: &str, presentation: Presentation) -> AgentResult<()> { diff --git a/aries_vcx/src/handlers/proof_presentation/verifier.rs b/aries_vcx/src/handlers/proof_presentation/verifier.rs index 8e0656def5..9c7f96c6f6 100644 --- a/aries_vcx/src/handlers/proof_presentation/verifier.rs +++ b/aries_vcx/src/handlers/proof_presentation/verifier.rs @@ -11,7 +11,8 @@ use crate::core::profile::profile::Profile; use crate::errors::error::prelude::*; use crate::handlers::connection::mediated_connection::MediatedConnection; use crate::protocols::proof_presentation::verifier::messages::VerifierMessages; -use crate::protocols::proof_presentation::verifier::state_machine::{RevocationStatus, VerifierSM, VerifierState}; +use crate::protocols::proof_presentation::verifier::state_machine::{VerifierSM, VerifierState}; +use crate::protocols::proof_presentation::verifier::verification_status::PresentationVerificationStatus; use crate::protocols::SendClosure; use messages::a2a::A2AMessage; use messages::protocols::proof_presentation::presentation_proposal::PresentationProposal; @@ -144,12 +145,8 @@ impl Verifier { self.verifier_sm.get_presentation_msg() } - pub fn get_presentation_status(&self) -> Status { - self.verifier_sm.presentation_status() - } - - pub fn get_revocation_status(&self) -> Option { - self.verifier_sm.get_revocation_status() + pub fn get_verification_status(&self) -> PresentationVerificationStatus { + self.verifier_sm.get_verification_status() } pub fn get_presentation_attachment(&self) -> VcxResult { diff --git a/aries_vcx/src/protocols/proof_presentation/verifier/mod.rs b/aries_vcx/src/protocols/proof_presentation/verifier/mod.rs index ac0dab44b0..03d300e4a9 100644 --- a/aries_vcx/src/protocols/proof_presentation/verifier/mod.rs +++ b/aries_vcx/src/protocols/proof_presentation/verifier/mod.rs @@ -5,6 +5,7 @@ use crate::protocols::proof_presentation::verifier::messages::VerifierMessages; pub mod messages; pub mod state_machine; pub mod states; +pub mod verification_status; pub fn verify_thread_id(thread_id: &str, message: &VerifierMessages) -> VcxResult<()> { if !settings::indy_mocks_enabled() && !message.thread_id_matches(thread_id) { diff --git a/aries_vcx/src/protocols/proof_presentation/verifier/state_machine.rs b/aries_vcx/src/protocols/proof_presentation/verifier/state_machine.rs index bb85e3853e..135eb9f845 100644 --- a/aries_vcx/src/protocols/proof_presentation/verifier/state_machine.rs +++ b/aries_vcx/src/protocols/proof_presentation/verifier/state_machine.rs @@ -12,6 +12,7 @@ use crate::protocols::proof_presentation::verifier::states::initial::InitialVeri use crate::protocols::proof_presentation::verifier::states::presentation_proposal_received::PresentationProposalReceivedState; use crate::protocols::proof_presentation::verifier::states::presentation_request_sent::PresentationRequestSentState; use crate::protocols::proof_presentation::verifier::states::presentation_request_set::PresentationRequestSetState; +use crate::protocols::proof_presentation::verifier::verification_status::PresentationVerificationStatus; use crate::protocols::proof_presentation::verifier::verify_thread_id; use crate::protocols::SendClosure; use messages::a2a::{A2AMessage, MessageId}; @@ -21,6 +22,7 @@ use messages::protocols::proof_presentation::presentation_ack::PresentationAck; use messages::protocols::proof_presentation::presentation_proposal::PresentationProposal; use messages::protocols::proof_presentation::presentation_request::PresentationRequest; use messages::status::Status; +use strum_macros::{AsRefStr, EnumString}; #[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Default)] pub struct VerifierSM { @@ -66,12 +68,6 @@ impl Default for VerifierFullState { } } -#[derive(Debug, Clone, Serialize, Deserialize, PartialEq, Eq)] -pub enum RevocationStatus { - NonRevoked, - Revoked, -} - fn build_verification_ack(thread_id: &str) -> PresentationAck { PresentationAck::create().set_thread_id(thread_id).set_out_time() } @@ -220,11 +216,13 @@ impl VerifierSM { let ack = build_verification_ack(&self.thread_id); send_message(A2AMessage::PresentationAck(ack)).await?; match verification_result { - Ok(()) => VerifierFullState::Finished((state, presentation, RevocationStatus::NonRevoked).into()), + Ok(()) => { + VerifierFullState::Finished((state, presentation, PresentationVerificationStatus::Valid).into()) + } Err(err) => match err.kind() { - AriesVcxErrorKind::InvalidProof => { - VerifierFullState::Finished((state, presentation, RevocationStatus::Revoked).into()) - } + AriesVcxErrorKind::InvalidProof => VerifierFullState::Finished( + (state, presentation, PresentationVerificationStatus::Invalid).into(), + ), _ => { let problem_report = build_problem_report_msg(Some(err.to_string()), &self.thread_id); VerifierFullState::Finished((state, problem_report).into()) @@ -394,6 +392,7 @@ impl VerifierSM { } pub fn get_state(&self) -> VerifierState { + warn!("get_state >>> {:?}", self.state); match self.state { VerifierFullState::Initial(_) => VerifierState::Initial, VerifierFullState::PresentationRequestSet(_) => VerifierState::PresentationRequestSet, @@ -416,32 +415,10 @@ impl VerifierSM { } } - pub fn presentation_status(&self) -> Status { - match self.state { - VerifierFullState::Finished(ref state) => { - match &state.status { - Status::Success => { - match state.revocation_status { - Some(RevocationStatus::NonRevoked) => Status::Success, - None => Status::Success, // for backward compatibility - Some(RevocationStatus::Revoked) => { - let problem_report = ProblemReport::create() - .set_comment(Some(String::from("Revoked credential was used."))); - Status::Failed(problem_report) - } - } - } - _ => state.status.clone(), - } - } - _ => Status::Undefined, - } - } - - pub fn get_revocation_status(&self) -> Option { + pub fn get_verification_status(&self) -> PresentationVerificationStatus { match self.state { - VerifierFullState::Finished(ref state) => state.revocation_status.clone(), - _ => None, + VerifierFullState::Finished(ref state) => state.verification_status.clone(), + _ => PresentationVerificationStatus::Unavailable, } } @@ -494,6 +471,8 @@ impl VerifierSM { #[cfg(test)] #[cfg(feature = "general_test")] pub mod unit_tests { + use std::str::FromStr; + use crate::common::proofs::proof_request::test_utils::_presentation_request_data; use crate::common::test_utils::mock_profile; use crate::test::source_id; @@ -788,8 +767,11 @@ pub mod unit_tests { .await .unwrap(); - assert_match!(VerifierFullState::Finished(_), verifier_sm.state); - assert_match!(Status::Declined(_), verifier_sm.presentation_status()); + assert_match!(VerifierState::Failed, verifier_sm.get_state()); + assert_match!( + PresentationVerificationStatus::Unavailable, + verifier_sm.get_verification_status() + ); } #[tokio::test] @@ -839,7 +821,10 @@ pub mod unit_tests { .unwrap(); assert_match!(VerifierFullState::Finished(_), verifier_sm.state); - assert_eq!(Status::Success, verifier_sm.presentation_status()); + assert_eq!( + PresentationVerificationStatus::Valid, + verifier_sm.get_verification_status() + ); } #[tokio::test] @@ -859,9 +844,11 @@ pub mod unit_tests { .await .unwrap(); - assert_match!(VerifierFullState::Finished(_), verifier_sm.state); - assert_eq!(VerifierState::Finished, verifier_sm.get_state()); - assert_match!(Status::Failed(_), verifier_sm.presentation_status()); + assert_match!(VerifierState::Finished, verifier_sm.get_state()); + assert_match!( + PresentationVerificationStatus::Invalid, + verifier_sm.get_verification_status() + ); } #[tokio::test] @@ -918,14 +905,14 @@ pub mod unit_tests { .await .unwrap(); - assert_match!(VerifierFullState::Finished(_), verifier_sm.state); - assert_eq!(Status::Failed(_problem_report()), verifier_sm.presentation_status()); + assert_match!(VerifierState::Failed, verifier_sm.get_state()); } #[tokio::test] #[cfg(feature = "general_test")] async fn test_prover_handle_messages_from_presentation_finished_state() { let _setup = SetupMocks::init(); + let _mock_builder = MockBuilder::init().set_mock_result_for_validate_indy_proof(Ok(true)); let mut verifier_sm = _verifier_sm_from_request(); verifier_sm = verifier_sm.mark_presentation_request_msg_sent().unwrap(); @@ -946,7 +933,7 @@ pub mod unit_tests { ) .await .unwrap(); - assert_match!(VerifierFullState::Finished(_), verifier_sm.state); + assert_match!(VerifierState::Finished, verifier_sm.get_state()); verifier_sm = verifier_sm .step( @@ -956,7 +943,7 @@ pub mod unit_tests { ) .await .unwrap(); - assert_match!(VerifierFullState::Finished(_), verifier_sm.state); + assert_match!(VerifierState::Finished, verifier_sm.get_state()); } } diff --git a/aries_vcx/src/protocols/proof_presentation/verifier/states/finished.rs b/aries_vcx/src/protocols/proof_presentation/verifier/states/finished.rs index 63ac82b3ef..2fa1b59427 100644 --- a/aries_vcx/src/protocols/proof_presentation/verifier/states/finished.rs +++ b/aries_vcx/src/protocols/proof_presentation/verifier/states/finished.rs @@ -1,15 +1,35 @@ -use crate::protocols::proof_presentation::verifier::state_machine::RevocationStatus; +use serde::{Deserialize, Deserializer}; + use messages::concepts::problem_report::ProblemReport; use messages::protocols::proof_presentation::presentation::Presentation; use messages::protocols::proof_presentation::presentation_request::PresentationRequest; use messages::status::Status; +use crate::protocols::proof_presentation::verifier::verification_status::PresentationVerificationStatus; + #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] pub struct FinishedState { pub presentation_request: Option, pub presentation: Option, pub status: Status, - pub revocation_status: Option, + #[serde(default = "verification_status_unavailable")] // todo: to be removed in 0.54.0, this supports legacy serialization when the field was undefined + #[serde(deserialize_with = "null_to_unavailable")] // todo: to be removed in 0.54.0, this supports legacy serialization when the field was 'null' + #[serde(alias = "revocation_status")] + // todo: to be removed in 0.54.0, this supports legacy serialization when the field was named 'revocation_status' + pub verification_status: PresentationVerificationStatus, +} + +fn verification_status_unavailable() -> PresentationVerificationStatus { + PresentationVerificationStatus::Unavailable +} + +// todo: to be removed in 0.54.0, if "revocation_status / verification_status" is null, we deserialize as Unavailable +fn null_to_unavailable<'de, D>(deserializer: D) -> Result +where + D: Deserializer<'de>, +{ + let opt = Option::deserialize(deserializer)?; + Ok(opt.unwrap_or(PresentationVerificationStatus::Unavailable)) } impl FinishedState { @@ -19,7 +39,151 @@ impl FinishedState { presentation_request: None, presentation: None, status: Status::Declined(problem_report), - revocation_status: None, + verification_status: PresentationVerificationStatus::Unavailable, + } + } +} + +#[cfg(test)] +#[cfg(feature = "general_test")] +pub mod unit_tests { + use std::str::FromStr; + + use messages::protocols::proof_presentation::presentation::test_utils::{_presentation, _presentation_1}; + use messages::protocols::proof_presentation::presentation_proposal::test_utils::_presentation_proposal; + use messages::protocols::proof_presentation::presentation_request::test_utils::_presentation_request; + use messages::protocols::proof_presentation::test_utils::{_ack, _problem_report}; + + use crate::common::test_utils::mock_profile; + use crate::test::source_id; + use crate::utils::devsetup::{SetupEmpty, SetupMocks}; + + use super::*; + + #[test] + fn test_verifier_state_finished_ser_deser_valid() { + let state = FinishedState { + presentation_request: None, + presentation: None, + status: Status::Success, + verification_status: PresentationVerificationStatus::Valid, + }; + let serialized = serde_json::to_string(&state).unwrap(); + let expected = + r#"{"presentation_request":null,"presentation":null,"status":"Success","verification_status":"Valid"}"#; + assert_eq!(serialized, expected); + let deserialized: FinishedState = serde_json::from_str(&serialized).unwrap(); + assert_eq!(state, deserialized) + } + + #[test] + fn test_verifier_state_finished_ser_deser_unavailable() { + let state = FinishedState { + presentation_request: None, + presentation: None, + status: Status::Success, + verification_status: PresentationVerificationStatus::Unavailable, + }; + let serialized = serde_json::to_string(&state).unwrap(); + let expected = r#"{"presentation_request":null,"presentation":null,"status":"Success","verification_status":"Unavailable"}"#; + assert_eq!(serialized, expected); + let deserialized: FinishedState = serde_json::from_str(&serialized).unwrap(); + assert_eq!(state, deserialized) + } + + #[test] + fn test_verifier_state_finished_ser_deser_invalid() { + let state = FinishedState { + presentation_request: None, + presentation: None, + status: Status::Success, + verification_status: PresentationVerificationStatus::Invalid, + }; + let serialized = serde_json::to_string(&state).unwrap(); + let expected = + r#"{"presentation_request":null,"presentation":null,"status":"Success","verification_status":"Invalid"}"#; + assert_eq!(serialized, expected); + let deserialized: FinishedState = serde_json::from_str(&serialized).unwrap(); + assert_eq!(state, deserialized) + } + + #[test] + fn test_verifier_state_finished_deser() { + { + let serialized = + r#"{"presentation":null,"presentation_request":null,"status":"Success","revocation_status":"Invalid"}"#; + let deserialized: FinishedState = serde_json::from_str(serialized).unwrap(); + assert_eq!( + deserialized.verification_status, + PresentationVerificationStatus::Invalid + ) + } + { + let serialized = + r#"{"presentation":null,"presentation_request":null,"status":"Success","revocation_status":"Valid"}"#; + let deserialized: FinishedState = serde_json::from_str(serialized).unwrap(); + assert_eq!(deserialized.verification_status, PresentationVerificationStatus::Valid) + } + } + + #[test] + fn test_verifier_state_finished_deser_legacy_values_verification_status() { + { + let serialized = r#"{"presentation":null,"presentation_request":null,"status":"Success"}"#; + let deserialized: FinishedState = serde_json::from_str(serialized).unwrap(); + assert_eq!( + deserialized.verification_status, + PresentationVerificationStatus::Unavailable + ) + } + { + let serialized = + r#"{"presentation":null,"presentation_request":null,"status":"Success","verification_status":null}"#; + let deserialized: FinishedState = serde_json::from_str(serialized).unwrap(); + assert_eq!( + deserialized.verification_status, + PresentationVerificationStatus::Unavailable + ) + } + { + let serialized = r#"{"presentation":null,"presentation_request":null,"status":"Success","verification_status":"Revoked"}"#; + let deserialized: FinishedState = serde_json::from_str(serialized).unwrap(); + assert_eq!( + deserialized.verification_status, + PresentationVerificationStatus::Invalid + ) + } + { + let serialized = r#"{"presentation":null,"presentation_request":null,"status":"Success","verification_status":"NonRevoked"}"#; + let deserialized: FinishedState = serde_json::from_str(serialized).unwrap(); + assert_eq!(deserialized.verification_status, PresentationVerificationStatus::Valid) + } + } + + #[test] + fn test_verifier_state_finished_deser_legacy_values_revocation_status() { + { + let serialized = + r#"{"presentation":null,"presentation_request":null,"status":"Success","revocation_status":null}"#; + let deserialized: FinishedState = serde_json::from_str(serialized).unwrap(); + assert_eq!( + deserialized.verification_status, + PresentationVerificationStatus::Unavailable + ) + } + { + let serialized = + r#"{"presentation":null,"presentation_request":null,"status":"Success","revocation_status":"Revoked"}"#; + let deserialized: FinishedState = serde_json::from_str(serialized).unwrap(); + assert_eq!( + deserialized.verification_status, + PresentationVerificationStatus::Invalid + ) + } + { + let serialized = r#"{"presentation":null,"presentation_request":null,"status":"Success","revocation_status":"NonRevoked"}"#; + let deserialized: FinishedState = serde_json::from_str(serialized).unwrap(); + assert_eq!(deserialized.verification_status, PresentationVerificationStatus::Valid) } } } diff --git a/aries_vcx/src/protocols/proof_presentation/verifier/states/presentation_request_sent.rs b/aries_vcx/src/protocols/proof_presentation/verifier/states/presentation_request_sent.rs index 88ba39ccc7..c4239ec7ca 100644 --- a/aries_vcx/src/protocols/proof_presentation/verifier/states/presentation_request_sent.rs +++ b/aries_vcx/src/protocols/proof_presentation/verifier/states/presentation_request_sent.rs @@ -4,8 +4,8 @@ use crate::common::proofs::verifier::verifier::validate_indy_proof; use crate::core::profile::profile::Profile; use crate::errors::error::{AriesVcxError, AriesVcxErrorKind, VcxResult}; use crate::global::settings; -use crate::protocols::proof_presentation::verifier::state_machine::RevocationStatus; use crate::protocols::proof_presentation::verifier::states::finished::FinishedState; +use crate::protocols::proof_presentation::verifier::verification_status::PresentationVerificationStatus; use messages::concepts::problem_report::ProblemReport; use messages::protocols::proof_presentation::presentation::Presentation; use messages::protocols::proof_presentation::presentation_request::PresentationRequest; @@ -51,16 +51,26 @@ impl PresentationRequestSentState { } } -impl From<(PresentationRequestSentState, Presentation, RevocationStatus)> for FinishedState { +impl + From<( + PresentationRequestSentState, + Presentation, + PresentationVerificationStatus, + )> for FinishedState +{ fn from( - (state, presentation, was_revoked): (PresentationRequestSentState, Presentation, RevocationStatus), + (state, presentation, verification_status): ( + PresentationRequestSentState, + Presentation, + PresentationVerificationStatus, + ), ) -> Self { trace!("transit state from PresentationRequestSentState to FinishedState"); FinishedState { presentation_request: Some(state.presentation_request), presentation: Some(presentation), status: Status::Success, - revocation_status: Some(was_revoked), + verification_status: verification_status, } } } @@ -72,7 +82,7 @@ impl From<(PresentationRequestSentState, ProblemReport)> for FinishedState { presentation_request: Some(state.presentation_request), presentation: None, status: Status::Failed(problem_report), - revocation_status: None, + verification_status: PresentationVerificationStatus::Unavailable, } } } diff --git a/aries_vcx/src/protocols/proof_presentation/verifier/verification_status.rs b/aries_vcx/src/protocols/proof_presentation/verifier/verification_status.rs new file mode 100644 index 0000000000..edbb5cac1c --- /dev/null +++ b/aries_vcx/src/protocols/proof_presentation/verifier/verification_status.rs @@ -0,0 +1,50 @@ +#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq)] +pub enum PresentationVerificationStatus { + #[serde(alias = "NonRevoked")] + // todo: to be removed in 0.54.0, supports legacy serialization when the enum had values "Revoked" and "NotRevoked" + Valid, + #[serde(alias = "Revoked")] + Invalid, + Unavailable, +} + +#[cfg(test)] +#[cfg(feature = "general_test")] +pub mod unit_tests { + use std::str::FromStr; + + use crate::common::proofs::proof_request::test_utils::_presentation_request_data; + use crate::common::test_utils::mock_profile; + use crate::test::source_id; + use crate::utils::devsetup::{SetupEmpty, SetupMocks}; + use messages::protocols::proof_presentation::presentation::test_utils::{_presentation, _presentation_1}; + use messages::protocols::proof_presentation::presentation_proposal::test_utils::_presentation_proposal; + use messages::protocols::proof_presentation::presentation_request::test_utils::_presentation_request; + use messages::protocols::proof_presentation::test_utils::{_ack, _problem_report}; + + use super::*; + + #[test] + fn test_presentation_status_ser_deser() { + assert_eq!( + PresentationVerificationStatus::Valid, + serde_json::from_str("\"Valid\"").unwrap() + ); + assert_eq!( + PresentationVerificationStatus::Valid, + serde_json::from_str("\"NonRevoked\"").unwrap() + ); + assert_eq!( + PresentationVerificationStatus::Invalid, + serde_json::from_str("\"Invalid\"").unwrap() + ); + assert_eq!( + PresentationVerificationStatus::Invalid, + serde_json::from_str("\"Revoked\"").unwrap() + ); + assert_eq!( + PresentationVerificationStatus::Unavailable, + serde_json::from_str("\"Unavailable\"").unwrap() + ); + } +} diff --git a/aries_vcx/src/utils/mockdata/mockdata_proof.rs b/aries_vcx/src/utils/mockdata/mockdata_proof.rs index 7f09b9cef2..874f72648f 100644 --- a/aries_vcx/src/utils/mockdata/mockdata_proof.rs +++ b/aries_vcx/src/utils/mockdata/mockdata_proof.rs @@ -307,7 +307,7 @@ pub static SERIALIZIED_PROOF_REVOKED: &str = r#" "~please_ack": {} }, "status": "Success", - "revocation_status": "Revoked" + "verification_status": "Revoked" } } } diff --git a/aries_vcx/src/utils/mockdata/profile/mock_anoncreds.rs b/aries_vcx/src/utils/mockdata/profile/mock_anoncreds.rs index b23ea8fe3e..cb1ddb948a 100644 --- a/aries_vcx/src/utils/mockdata/profile/mock_anoncreds.rs +++ b/aries_vcx/src/utils/mockdata/profile/mock_anoncreds.rs @@ -30,7 +30,7 @@ impl BaseAnonCreds for MockAnoncreds { ) -> VcxResult { Err(AriesVcxError::from_msg( AriesVcxErrorKind::UnimplementedFeature, - "unimplemented mock method", + "unimplemented mock method: verifier_verify_proof", )) } @@ -45,7 +45,7 @@ impl BaseAnonCreds for MockAnoncreds { // not needed yet Err(AriesVcxError::from_msg( AriesVcxErrorKind::UnimplementedFeature, - "unimplemented mock method", + "unimplemented mock method: issuer_create_and_store_revoc_reg", )) } @@ -60,7 +60,7 @@ impl BaseAnonCreds for MockAnoncreds { // not needed yet Err(AriesVcxError::from_msg( AriesVcxErrorKind::UnimplementedFeature, - "unimplemented mock method", + "unimplemented mock method: issuer_create_and_store_credential_def", )) } @@ -69,7 +69,7 @@ impl BaseAnonCreds for MockAnoncreds { if rc != 0 { return Err(AriesVcxError::from_msg( AriesVcxErrorKind::InvalidState, - "Mocked error result of issuer_create_credential_offer", + "Mocked error result of issuer_create_credential_offer: issuer_create_credential_offer", )); }; Ok(LIBINDY_CRED_OFFER.to_string()) @@ -102,7 +102,7 @@ impl BaseAnonCreds for MockAnoncreds { // not needed yet Err(AriesVcxError::from_msg( AriesVcxErrorKind::UnimplementedFeature, - "unimplemented mock method", + "unimplemented mock method: prover_get_credential", )) } @@ -110,7 +110,7 @@ impl BaseAnonCreds for MockAnoncreds { // not needed yet Err(AriesVcxError::from_msg( AriesVcxErrorKind::UnimplementedFeature, - "unimplemented mock method", + "unimplemented mock method: prover_get_credentials", )) } @@ -163,7 +163,7 @@ impl BaseAnonCreds for MockAnoncreds { // not needed yet Err(AriesVcxError::from_msg( AriesVcxErrorKind::UnimplementedFeature, - "unimplemented mock method", + "unimplemented mock method: prover_delete_credential", )) } @@ -181,7 +181,7 @@ impl BaseAnonCreds for MockAnoncreds { // not needed yet Err(AriesVcxError::from_msg( AriesVcxErrorKind::UnimplementedFeature, - "unimplemented mock method", + "unimplemented mock method: issuer_create_schema", )) } diff --git a/aries_vcx/src/utils/mockdata/profile/mock_ledger.rs b/aries_vcx/src/utils/mockdata/profile/mock_ledger.rs index 96aa04639e..9d384bac60 100644 --- a/aries_vcx/src/utils/mockdata/profile/mock_ledger.rs +++ b/aries_vcx/src/utils/mockdata/profile/mock_ledger.rs @@ -29,7 +29,7 @@ impl BaseLedger for MockLedger { // not needed yet Err(AriesVcxError::from_msg( AriesVcxErrorKind::UnimplementedFeature, - "unimplemented mock method", + "unimplemented mock method: submit_request", )) } @@ -49,7 +49,7 @@ impl BaseLedger for MockLedger { // not needed yet Err(AriesVcxError::from_msg( AriesVcxErrorKind::UnimplementedFeature, - "unimplemented mock method", + "unimplemented mock method: get_nym", )) } diff --git a/aries_vcx/src/utils/mockdata/profile/mock_wallet.rs b/aries_vcx/src/utils/mockdata/profile/mock_wallet.rs index 0894788853..413fe4e5bc 100644 --- a/aries_vcx/src/utils/mockdata/profile/mock_wallet.rs +++ b/aries_vcx/src/utils/mockdata/profile/mock_wallet.rs @@ -72,7 +72,7 @@ impl BaseWallet for MockWallet { // not needed yet Err(AriesVcxError::from_msg( AriesVcxErrorKind::UnimplementedFeature, - "unimplemented mock method", + "unimplemented mock method: iterate_wallet_records", )) } diff --git a/aries_vcx/tests/test_creds_proofs.rs b/aries_vcx/tests/test_creds_proofs.rs index 67384f4789..472693c1c1 100644 --- a/aries_vcx/tests/test_creds_proofs.rs +++ b/aries_vcx/tests/test_creds_proofs.rs @@ -18,6 +18,7 @@ mod integration_tests { use aries_vcx::handlers::proof_presentation::prover::Prover; use aries_vcx::handlers::proof_presentation::verifier::Verifier; use aries_vcx::messages::protocols::proof_presentation::presentation_request::PresentationRequest; + use aries_vcx::protocols::proof_presentation::verifier::verification_status::PresentationVerificationStatus; use aries_vcx::utils::constants::{DEFAULT_SCHEMA_ATTRS, TAILS_DIR}; use aries_vcx::utils::devsetup::{init_holder_setup_in_indy_context, SetupProfile}; use aries_vcx::utils::get_temp_dir_path; @@ -364,8 +365,10 @@ mod integration_tests { .await .unwrap(); - let status = verifier.get_presentation_status(); - assert_eq!(status, Status::Success); + assert_eq!( + verifier.get_verification_status(), + PresentationVerificationStatus::Valid + ); }) .await; } @@ -385,7 +388,7 @@ mod tests { use aries_vcx::protocols::issuance::holder::state_machine::HolderState; use aries_vcx::protocols::issuance::issuer::state_machine::IssuerState; use aries_vcx::protocols::proof_presentation::prover::state_machine::ProverState; - use aries_vcx::protocols::proof_presentation::verifier::state_machine::RevocationStatus; + use aries_vcx::protocols::proof_presentation::verifier::verification_status::PresentationVerificationStatus; use aries_vcx::utils::devsetup::*; use crate::utils::devsetup_agent::test_utils::{create_test_alice_instance, Faber, PayloadKinds}; @@ -456,10 +459,9 @@ mod tests { .await .unwrap(); assert_eq!( - ProofStateType::from(verifier.get_presentation_status()), - ProofStateType::ProofValidated + verifier.get_verification_status(), + PresentationVerificationStatus::Valid ); - assert_eq!(verifier.get_revocation_status(), Some(RevocationStatus::NonRevoked)); }) .await; } @@ -513,8 +515,8 @@ mod tests { .await .unwrap(); assert_eq!( - ProofStateType::from(verifier.get_presentation_status()), - ProofStateType::ProofValidated + verifier.get_verification_status(), + PresentationVerificationStatus::Valid ); info!( "test_proof_with_predicates_should_be_validated :: verifier received presentation!: {}", @@ -627,8 +629,8 @@ mod tests { .await .unwrap(); assert_eq!( - ProofStateType::from(proof_verifier.get_presentation_status()), - ProofStateType::ProofValidated + proof_verifier.get_verification_status(), + PresentationVerificationStatus::Valid ); let request_name2 = Some("request2"); @@ -646,8 +648,8 @@ mod tests { .await .unwrap(); assert_eq!( - ProofStateType::from(proof_verifier.get_presentation_status()), - ProofStateType::ProofValidated + proof_verifier.get_verification_status(), + PresentationVerificationStatus::Valid ); }).await; } @@ -681,8 +683,8 @@ mod tests { .await .unwrap(); assert_eq!( - ProofStateType::from(proof_verifier.get_presentation_status()), - ProofStateType::ProofValidated + proof_verifier.get_verification_status(), + PresentationVerificationStatus::Valid ); let request_name2 = Some("request2"); @@ -700,8 +702,8 @@ mod tests { .await .unwrap(); assert_eq!( - ProofStateType::from(proof_verifier.get_presentation_status()), - ProofStateType::ProofValidated + proof_verifier.get_verification_status(), + PresentationVerificationStatus::Valid ); }) .await; @@ -751,8 +753,8 @@ mod tests { .await .unwrap(); assert_eq!( - ProofStateType::from(verifier.get_presentation_status()), - ProofStateType::ProofValidated + verifier.get_verification_status(), + PresentationVerificationStatus::Valid ); let request_name2 = Some("request2"); @@ -774,8 +776,8 @@ mod tests { .await .unwrap(); assert_eq!( - ProofStateType::from(verifier.get_presentation_status()), - ProofStateType::ProofValidated + verifier.get_verification_status(), + PresentationVerificationStatus::Valid ); }).await; } @@ -892,8 +894,8 @@ mod tests { .await .unwrap(); assert_eq!( - ProofStateType::from(verifier.get_presentation_status()), - ProofStateType::ProofValidated + verifier.get_verification_status(), + PresentationVerificationStatus::Valid ); assert_eq!(presentation_thread_id, verifier.get_thread_id().unwrap()); }) @@ -955,8 +957,8 @@ mod tests { .await .unwrap(); assert_eq!( - ProofStateType::from(proof_verifier.get_presentation_status()), - ProofStateType::ProofValidated + proof_verifier.get_verification_status(), + PresentationVerificationStatus::Valid ); let mut proof_verifier = verifier_create_proof_and_send_request( @@ -974,8 +976,8 @@ mod tests { .await .unwrap(); assert_eq!( - ProofStateType::from(proof_verifier.get_presentation_status()), - ProofStateType::ProofValidated + proof_verifier.get_verification_status(), + PresentationVerificationStatus::Valid ); }).await; } diff --git a/aries_vcx/tests/test_creds_proofs_revocations.rs b/aries_vcx/tests/test_creds_proofs_revocations.rs index a090feb10c..0c9c5545ee 100644 --- a/aries_vcx/tests/test_creds_proofs_revocations.rs +++ b/aries_vcx/tests/test_creds_proofs_revocations.rs @@ -12,7 +12,8 @@ mod integration_tests { use std::time::Duration; use aries_vcx::protocols::proof_presentation::prover::state_machine::ProverState; - use aries_vcx::protocols::proof_presentation::verifier::state_machine::RevocationStatus; + use aries_vcx::protocols::proof_presentation::verifier::state_machine::VerifierState; + use aries_vcx::protocols::proof_presentation::verifier::verification_status::PresentationVerificationStatus; use aries_vcx::utils::devsetup::*; use crate::utils::devsetup_agent::test_utils::{create_test_alice_instance, Faber}; @@ -89,11 +90,11 @@ mod integration_tests { ) .await .unwrap(); + assert_eq!(verifier.get_state(), VerifierState::Finished); assert_eq!( - ProofStateType::from(verifier.get_presentation_status()), - ProofStateType::ProofInvalid + verifier.get_verification_status(), + PresentationVerificationStatus::Invalid ); - assert_eq!(verifier.get_revocation_status(), Some(RevocationStatus::Revoked)); }) .await; } @@ -195,9 +196,10 @@ mod integration_tests { ) .await .unwrap(); + assert_eq!(verifier.get_state(), VerifierState::Finished); assert_eq!( - ProofStateType::from(verifier.get_presentation_status()), - ProofStateType::ProofValidated + verifier.get_verification_status(), + PresentationVerificationStatus::Valid ); assert!(!issuer_credential.is_revoked(&institution.profile).await.unwrap()); @@ -223,9 +225,10 @@ mod integration_tests { ) .await .unwrap(); + assert_eq!(verifier.get_state(), VerifierState::Finished); assert_eq!( - ProofStateType::from(verifier.get_presentation_status()), - ProofStateType::ProofInvalid + verifier.get_verification_status(), + PresentationVerificationStatus::Invalid ); assert!(issuer_credential.is_revoked(&institution.profile).await.unwrap()); @@ -350,18 +353,18 @@ mod integration_tests { ) .await .unwrap(); - assert_eq!( - ProofStateType::from(verifier1.get_presentation_status()), - ProofStateType::ProofValidated - ); - assert_eq!( - ProofStateType::from(verifier2.get_presentation_status()), - ProofStateType::ProofValidated - ); - assert_eq!( - ProofStateType::from(verifier3.get_presentation_status()), - ProofStateType::ProofValidated - ); + assert_eq!( + verifier1.get_verification_status(), + PresentationVerificationStatus::Valid + ); + assert_eq!( + verifier2.get_verification_status(), + PresentationVerificationStatus::Valid + ); + assert_eq!( + verifier3.get_verification_status(), + PresentationVerificationStatus::Valid + ); // Publish revocations and verify the two are invalid, third still valid publish_revocation(&mut institution, rev_reg_id.clone().unwrap()).await; @@ -428,16 +431,18 @@ mod integration_tests { .await .unwrap(); assert_eq!( - ProofStateType::from(verifier1.get_presentation_status()), - ProofStateType::ProofInvalid + verifier1.get_verification_status(), + PresentationVerificationStatus::Invalid ); + assert_eq!( - ProofStateType::from(verifier2.get_presentation_status()), - ProofStateType::ProofInvalid + verifier2.get_verification_status(), + PresentationVerificationStatus::Invalid ); + assert_eq!( - ProofStateType::from(verifier3.get_presentation_status()), - ProofStateType::ProofValidated + verifier3.get_verification_status(), + PresentationVerificationStatus::Valid ); }).await; } @@ -528,9 +533,10 @@ mod integration_tests { ) .await .unwrap(); + assert_eq!(verifier.get_state(), VerifierState::Finished); assert_eq!( - ProofStateType::from(verifier.get_presentation_status()), - ProofStateType::ProofValidated + verifier.get_verification_status(), + PresentationVerificationStatus::Valid ); }) .await; @@ -596,10 +602,14 @@ mod integration_tests { .update_state(&verifier.profile, &verifier.agency_client, &verifier_to_consumer) .await .unwrap(); - assert_eq!( - ProofStateType::from(proof_verifier.get_presentation_status()), - ProofStateType::ProofInvalid - ); + assert_eq!( + proof_verifier.get_state(), + VerifierState::Finished + ); + assert_eq!( + proof_verifier.get_verification_status(), + PresentationVerificationStatus::Invalid + ); let mut proof_verifier = verifier_create_proof_and_send_request( &mut verifier, @@ -616,8 +626,8 @@ mod integration_tests { .await .unwrap(); assert_eq!( - ProofStateType::from(proof_verifier.get_presentation_status()), - ProofStateType::ProofValidated + proof_verifier.get_verification_status(), + PresentationVerificationStatus::Valid ); assert!(issuer_credential1.is_revoked(&issuer.profile).await.unwrap()); @@ -686,8 +696,8 @@ mod integration_tests { .await .unwrap(); assert_eq!( - ProofStateType::from(proof_verifier.get_presentation_status()), - ProofStateType::ProofValidated + proof_verifier.get_verification_status(), + PresentationVerificationStatus::Valid ); let mut proof_verifier = verifier_create_proof_and_send_request( @@ -705,8 +715,8 @@ mod integration_tests { .await .unwrap(); assert_eq!( - ProofStateType::from(proof_verifier.get_presentation_status()), - ProofStateType::ProofInvalid + proof_verifier.get_verification_status(), + PresentationVerificationStatus::Invalid ); assert!(!issuer_credential1.is_revoked(&issuer.profile).await.unwrap()); @@ -771,10 +781,11 @@ mod integration_tests { .await .unwrap(); assert_eq!( - ProofStateType::from(proof_verifier.get_presentation_status()), - ProofStateType::ProofValidated + proof_verifier.get_verification_status(), + PresentationVerificationStatus::Valid ); + let mut proof_verifier = verifier_create_proof_and_send_request( &mut verifier, &verifier_to_consumer, @@ -790,8 +801,8 @@ mod integration_tests { .await .unwrap(); assert_eq!( - ProofStateType::from(proof_verifier.get_presentation_status()), - ProofStateType::ProofValidated + proof_verifier.get_verification_status(), + PresentationVerificationStatus::Valid ); assert!(!issuer_credential1.is_revoked(&issuer.profile).await.unwrap()); @@ -861,8 +872,8 @@ mod integration_tests { .await .unwrap(); assert_eq!( - ProofStateType::from(proof_verifier.get_presentation_status()), - ProofStateType::ProofInvalid + proof_verifier.get_verification_status(), + PresentationVerificationStatus::Invalid ); let mut proof_verifier = verifier_create_proof_and_send_request( @@ -880,8 +891,8 @@ mod integration_tests { .await .unwrap(); assert_eq!( - ProofStateType::from(proof_verifier.get_presentation_status()), - ProofStateType::ProofValidated + proof_verifier.get_verification_status(), + PresentationVerificationStatus::Valid ); assert!(issuer_credential1.is_revoked(&issuer.profile).await.unwrap()); @@ -951,8 +962,8 @@ mod integration_tests { .await .unwrap(); assert_eq!( - ProofStateType::from(proof_verifier.get_presentation_status()), - ProofStateType::ProofValidated + proof_verifier.get_verification_status(), + PresentationVerificationStatus::Valid ); let mut proof_verifier = verifier_create_proof_and_send_request( @@ -970,8 +981,8 @@ mod integration_tests { .await .unwrap(); assert_eq!( - ProofStateType::from(proof_verifier.get_presentation_status()), - ProofStateType::ProofInvalid + proof_verifier.get_verification_status(), + PresentationVerificationStatus::Invalid ); assert!(!issuer_credential1.is_revoked(&issuer.profile).await.unwrap()); diff --git a/aries_vcx/tests/utils/devsetup_agent.rs b/aries_vcx/tests/utils/devsetup_agent.rs index 33bb282f0b..1d2278d9d1 100644 --- a/aries_vcx/tests/utils/devsetup_agent.rs +++ b/aries_vcx/tests/utils/devsetup_agent.rs @@ -54,6 +54,7 @@ pub mod test_utils { use aries_vcx::protocols::mediated_connection::inviter::state_machine::InviterState; use aries_vcx::protocols::proof_presentation::prover::state_machine::ProverState; use aries_vcx::protocols::proof_presentation::verifier::state_machine::VerifierState; + use aries_vcx::protocols::proof_presentation::verifier::verification_status::PresentationVerificationStatus; use aries_vcx::utils::devsetup::*; use aries_vcx::utils::provision::provision_cloud_agent; use vdrtools::{PoolHandle, WalletHandle}; @@ -386,16 +387,21 @@ pub mod test_utils { } pub async fn verify_presentation(&mut self) { - self.update_proof_state(VerifierState::Finished, Status::Success).await + self.update_proof_state(VerifierState::Finished, PresentationVerificationStatus::Valid) + .await } - pub async fn update_proof_state(&mut self, expected_state: VerifierState, expected_status: Status) { + pub async fn update_proof_state( + &mut self, + expected_state: VerifierState, + expected_verification_status: PresentationVerificationStatus, + ) { self.verifier .update_state(&self.profile, &self.agency_client, &self.connection) .await .unwrap(); assert_eq!(expected_state, self.verifier.get_state()); - assert_eq!(expected_status, self.verifier.get_presentation_status()); + assert_eq!(expected_verification_status, self.verifier.get_verification_status()); } pub async fn send_revocation_notification(&mut self, ack_on: Vec) { diff --git a/aries_vcx/tests/utils/scenarios.rs b/aries_vcx/tests/utils/scenarios.rs index e481937bbc..7d087d9a34 100644 --- a/aries_vcx/tests/utils/scenarios.rs +++ b/aries_vcx/tests/utils/scenarios.rs @@ -41,6 +41,7 @@ pub mod test_utils { use aries_vcx::protocols::mediated_connection::inviter::state_machine::InviterState; use aries_vcx::protocols::proof_presentation::prover::state_machine::ProverState; use aries_vcx::protocols::proof_presentation::verifier::state_machine::VerifierState; + use aries_vcx::protocols::proof_presentation::verifier::verification_status::PresentationVerificationStatus; use aries_vcx::utils::constants::{DEFAULT_PROOF_NAME, TAILS_DIR, TEST_TAILS_URL}; use aries_vcx::utils::filters::{filter_credential_offers_by_comment, filter_proof_requests_by_name}; use aries_vcx::utils::get_temp_dir_path; @@ -684,8 +685,8 @@ pub mod test_utils { .unwrap(); assert_eq!(verifier.get_state(), VerifierState::Finished); assert_eq!( - ProofStateType::from(verifier.get_presentation_status()), - ProofStateType::ProofValidated + verifier.get_verification_status(), + PresentationVerificationStatus::Valid ); } diff --git a/libvcx/src/api_c/protocols/proof.rs b/libvcx/src/api_c/protocols/proof.rs index 84e4f4fbdd..7c33a5f024 100644 --- a/libvcx/src/api_c/protocols/proof.rs +++ b/libvcx/src/api_c/protocols/proof.rs @@ -643,7 +643,7 @@ pub extern "C" fn vcx_proof_get_request_msg( pub extern "C" fn vcx_get_proof_msg( command_handle: CommandHandle, proof_handle: u32, - cb: Option, + cb: Option, ) -> u32 { info!("vcx_get_proof_msg >>>"); @@ -669,12 +669,7 @@ pub extern "C" fn vcx_get_proof_msg( source_id ); let msg = CStringUtils::string_to_cstring(proof_msg); - cb( - command_handle, - SUCCESS_ERR_CODE, - proof::get_presentation_verification_status(proof_handle).unwrap_or(0), - msg.as_ptr(), - ); + cb(command_handle, SUCCESS_ERR_CODE, msg.as_ptr()); } Err(err) => { set_current_error_vcx(&err); @@ -682,12 +677,7 @@ pub extern "C" fn vcx_get_proof_msg( "vcx_get_proof_cb(command_handle: {}, proof_handle: {}, rc: {}, proof: {}) source_id: {}", command_handle, proof_handle, err, "null", source_id ); - cb( - command_handle, - err.into(), - proof::get_presentation_verification_status(proof_handle).unwrap_or(0), - ptr::null_mut(), - ); + cb(command_handle, err.into(), ptr::null_mut()); } }; Ok(()) @@ -984,7 +974,7 @@ mod tests { let proof_handle = create_proof_util().unwrap(); - let cb = return_types_u32::Return_U32_U32_STR::new().unwrap(); + let cb = return_types_u32::Return_U32_STR::new().unwrap(); assert_eq!( vcx_get_proof_msg(cb.command_handle, proof_handle, Some(cb.get_callback())), SUCCESS_ERR_CODE diff --git a/libvcx_core/src/api_vcx/api_handle/proof.rs b/libvcx_core/src/api_vcx/api_handle/proof.rs index debc81fd5c..9aea7117bd 100644 --- a/libvcx_core/src/api_vcx/api_handle/proof.rs +++ b/libvcx_core/src/api_vcx/api_handle/proof.rs @@ -1,17 +1,16 @@ -use aries_vcx::protocols::SendClosure; use serde_json; use aries_vcx::common::proofs::proof_request::PresentationRequestData; use aries_vcx::handlers::proof_presentation::verifier::Verifier; use aries_vcx::messages::a2a::A2AMessage; -use aries_vcx::protocols::proof_presentation::verifier::state_machine::RevocationStatus; +use aries_vcx::protocols::proof_presentation::verifier::verification_status::PresentationVerificationStatus; +use aries_vcx::protocols::SendClosure; use crate::api_vcx::api_global::profile::get_main_profile; use crate::api_vcx::api_handle::connection::HttpClient; use crate::api_vcx::api_handle::object_cache::ObjectCache; use crate::api_vcx::api_handle::out_of_band::to_a2a_message; use crate::api_vcx::api_handle::{connection, mediated_connection}; - use crate::errors::error::{LibvcxError, LibvcxErrorKind, LibvcxResult}; lazy_static! { @@ -209,6 +208,7 @@ pub fn get_presentation_request_msg(handle: u32) -> LibvcxResult { Ok(json!(msg).to_string()) }) } + // --- Presentation --- pub fn get_presentation_msg(handle: u32) -> LibvcxResult { PROOF_MAP.get(handle, |proof| { @@ -223,42 +223,37 @@ pub fn get_presentation_attachment(handle: u32) -> LibvcxResult { }) } -pub fn get_presentation_verification_status(handle: u32) -> LibvcxResult { - PROOF_MAP.get(handle, |proof| Ok(proof.get_presentation_status().code())) +pub fn get_verification_status(handle: u32) -> LibvcxResult { + PROOF_MAP.get(handle, |proof| Ok(proof.get_verification_status().into())) } -pub enum VcxRevocationStatus { - NonRevoked, - Revoked, - Undefined, +#[derive(Debug, PartialEq, Eq)] +pub enum VcxPresentationVerificationStatus { + Valid, + Invalid, + Unavailable, } -impl VcxRevocationStatus { +impl VcxPresentationVerificationStatus { pub fn code(&self) -> u32 { match self { - VcxRevocationStatus::Undefined => 0, - VcxRevocationStatus::NonRevoked => 1, - VcxRevocationStatus::Revoked => 2, + VcxPresentationVerificationStatus::Unavailable => 0, + VcxPresentationVerificationStatus::Valid => 1, + VcxPresentationVerificationStatus::Invalid => 2, } } } -impl From> for VcxRevocationStatus { - fn from(status: Option) -> Self { - match status { - None => VcxRevocationStatus::Undefined, - Some(revocation_status) => match revocation_status { - RevocationStatus::NonRevoked => VcxRevocationStatus::NonRevoked, - RevocationStatus::Revoked => VcxRevocationStatus::Revoked, - }, +impl From for VcxPresentationVerificationStatus { + fn from(verification_status: PresentationVerificationStatus) -> Self { + match verification_status { + PresentationVerificationStatus::Valid => VcxPresentationVerificationStatus::Valid, + PresentationVerificationStatus::Invalid => VcxPresentationVerificationStatus::Invalid, + PresentationVerificationStatus::Unavailable => VcxPresentationVerificationStatus::Unavailable, } } } -pub fn get_revocation_status(handle: u32) -> LibvcxResult { - PROOF_MAP.get(handle, |proof| Ok(proof.get_revocation_status().into())) -} - // --- General --- pub fn get_thread_id(handle: u32) -> LibvcxResult { PROOF_MAP.get(handle, |proof| proof.get_thread_id().map_err(|err| err.into())) @@ -642,7 +637,10 @@ pub mod tests { send_proof_request(bad_handle, handle_conn).await.unwrap_err().kind(), LibvcxErrorKind::InvalidHandle ); - assert_eq!(get_presentation_verification_status(handle_proof).unwrap(), 0); + assert_eq!( + get_verification_status(handle_proof).unwrap(), + VcxPresentationVerificationStatus::Unavailable + ); assert_eq!( create_proof( "my source id".to_string(), diff --git a/wrappers/ios/vcx/VcxAPI.h b/wrappers/ios/vcx/VcxAPI.h index b297e8f160..ca519fa812 100644 --- a/wrappers/ios/vcx/VcxAPI.h +++ b/wrappers/ios/vcx/VcxAPI.h @@ -541,7 +541,7 @@ completion:(void (^)(NSError *error))completion; - (void)verifierGetProofMessage:(NSNumber *)proofHandle - completion:(void (^)(NSError *error, NSNumber * state, NSString *responseData))completion; + completion:(void (^)(NSError *error, NSString *responseData))completion; - (void)verifierProofGetRequestMessage:(NSNumber *)proofHandle completion:(void (^)(NSError *error, NSString *message))completion; diff --git a/wrappers/ios/vcx/VcxAPI.m b/wrappers/ios/vcx/VcxAPI.m index 6b39f19982..b78c979004 100644 --- a/wrappers/ios/vcx/VcxAPI.m +++ b/wrappers/ios/vcx/VcxAPI.m @@ -2229,18 +2229,18 @@ - (void)verifierProofSendRequest:(NSNumber *)proofHandle } - (void)verifierGetProofMessage:(NSNumber *)proofHandle - completion:(void (^)(NSError *, NSNumber *, NSString *))completion { + completion:(void (^)(NSError *, NSString *))completion { vcx_command_handle_t handle = [[VcxCallbacks sharedInstance] createCommandHandleFor:completion]; vcx_error_t ret = vcx_get_proof_msg( handle, proofHandle.unsignedIntValue, - &VcxWrapperCbResponseUnsignedIntAndString + &VcxWrapperCbResponseString ); checkErrorAndComplete(ret, handle, ^{ - completion([NSError errorFromVcxError:ret], ERROR_RESPONSE_NUMBER, ERROR_RESPONSE_STRING); + completion([NSError errorFromVcxError:ret], ERROR_RESPONSE_STRING); }); } diff --git a/wrappers/ios/vcx/include/libvcx.h b/wrappers/ios/vcx/include/libvcx.h index 7def18f960..d9e0c22ef9 100644 --- a/wrappers/ios/vcx/include/libvcx.h +++ b/wrappers/ios/vcx/include/libvcx.h @@ -762,7 +762,7 @@ vcx_error_t vcx_proof_send_request( vcx_error_t vcx_get_proof_msg( vcx_command_handle_t command_handle, vcx_proof_handle_t proof_handle, - void (*cb)(vcx_command_handle_t xcommand_handle, vcx_error_t err, vcx_state_t proof_state, const char *response_data) + void (*cb)(vcx_command_handle_t xcommand_handle, vcx_error_t err, const char *response_data) ); vcx_error_t vcx_proof_get_request_msg( diff --git a/wrappers/java/src/main/java/com/evernym/sdk/vcx/proof/GetProofResult.java b/wrappers/java/src/main/java/com/evernym/sdk/vcx/proof/GetProofResult.java index 9b8ba1a192..75e44e02b9 100644 --- a/wrappers/java/src/main/java/com/evernym/sdk/vcx/proof/GetProofResult.java +++ b/wrappers/java/src/main/java/com/evernym/sdk/vcx/proof/GetProofResult.java @@ -5,23 +5,10 @@ */ public class GetProofResult { - public GetProofResult( - int proof_state, - String response_data) { - this.proof_state = proof_state; + public GetProofResult(String response_data) { this.response_data = response_data; } - public int getProof_state() { - return proof_state; - } - - public void setProof_state(int proof_state) { - this.proof_state = proof_state; - } - - private int proof_state; - private String response_data; public String getResponse_data() { diff --git a/wrappers/java/src/main/java/com/evernym/sdk/vcx/proof/ProofApi.java b/wrappers/java/src/main/java/com/evernym/sdk/vcx/proof/ProofApi.java index 99d8c7cd97..8a0e2471a1 100644 --- a/wrappers/java/src/main/java/com/evernym/sdk/vcx/proof/ProofApi.java +++ b/wrappers/java/src/main/java/com/evernym/sdk/vcx/proof/ProofApi.java @@ -98,11 +98,11 @@ public static CompletableFuture proofGetRequestMsg( } private static Callback vcxGetProofCB = new Callback() { - public void callback(int commandHandle, int err, int proofState, String responseData){ - logger.debug("callback() called with: commandHandle = [" + commandHandle + "], err = [" + err + "], proofState = [" + proofState + "], responseData = [****]"); + public void callback(int commandHandle, int err, String presentationMsg){ + logger.debug("callback() called with: commandHandle = [" + commandHandle + "], err = [" + err + "], responseData = [****]"); CompletableFuture future = (CompletableFuture) removeFuture(commandHandle); if(!checkCallback(future,err)) return; - GetProofResult result = new GetProofResult(proofState,responseData); + GetProofResult result = new GetProofResult(presentationMsg); future.complete(result); } }; diff --git a/wrappers/node/src/api/proof.ts b/wrappers/node/src/api/proof.ts index d0e074dc9f..7565fdc690 100644 --- a/wrappers/node/src/api/proof.ts +++ b/wrappers/node/src/api/proof.ts @@ -63,17 +63,11 @@ export interface IFilter { } export enum ProofVerificationStatus { - Undefined = 0, - Verified = 1, + Unavailable = 0, + Valid = 1, Invalid = 2, } -export enum ProofRevocationStatus { - Undefined = 0, - NonRevoked = 1, - Revoked = 2, -} - export interface IProofPredicate { name: string; p_type: string; @@ -199,9 +193,9 @@ export class Proof extends VcxBaseWithState { } } - public getPresentationVerificationStatus(): ProofVerificationStatus { + public getVerificationStatus(): ProofVerificationStatus { try { - return ffi.proofGetPresentationVerificationStatus(this.handle); + return ffi.proofGetVerificationStatus(this.handle); } catch (err: any) { throw new VCXInternalError(err); } @@ -222,12 +216,4 @@ export class Proof extends VcxBaseWithState { throw new VCXInternalError(err); } } - - public getRevocationStatus(): ProofRevocationStatus { - try { - return ffi.proofGetRevocationStatus(this.handle); - } catch (err: any) { - throw new VCXInternalError(err); - } - } } diff --git a/wrappers/vcx-napi-rs/index.d.ts b/wrappers/vcx-napi-rs/index.d.ts index a1b083d6e2..23f7f25594 100644 --- a/wrappers/vcx-napi-rs/index.d.ts +++ b/wrappers/vcx-napi-rs/index.d.ts @@ -160,8 +160,7 @@ export function v2ProofUpdateState(handleProof: number, connectionHandle: number export function v2ProofUpdateStateWithMessage(handleProof: number, message: string, connectionHandle: number): Promise export function proofUpdateStateWithMessageNonmediated(handleProof: number, connectionHandle: number, message: string): Promise export function proofGetState(handle: number): number -export function proofGetPresentationVerificationStatus(handle: number): number -export function proofGetRevocationStatus(handle: number): number +export function proofGetVerificationStatus(handle: number): number export function proofGetThreadId(handle: number): string export function markPresentationRequestMsgSent(handle: number): void export function revocationRegistryCreate(config: string): Promise diff --git a/wrappers/vcx-napi-rs/index.js b/wrappers/vcx-napi-rs/index.js index 3a4075ba4e..cb315baf7e 100644 --- a/wrappers/vcx-napi-rs/index.js +++ b/wrappers/vcx-napi-rs/index.js @@ -246,7 +246,7 @@ if (!nativeBinding) { throw new Error(`Failed to load native binding`) } -const { updateWebhookUrl, createAgencyClientForMainWallet, provisionCloudAgent, messagesUpdateStatus, generatePublicInvitation, connectionCreateInviter, connectionCreateInvitee, connectionGetThreadId, connectionGetPairwiseInfo, connectionGetRemoteDid, connectionGetRemoteVk, connectionGetState, connectionGetInvitation, connectionProcessInvite, connectionProcessRequest, connectionProcessResponse, connectionProcessAck, connectionProcessProblemReport, connectionSendResponse, connectionSendRequest, connectionSendAck, connectionSendGenericMessage, connectionSendAriesMessage, connectionCreateInvite, connectionSerialize, connectionDeserialize, connectionRelease, credentialCreateWithOffer, credentialRelease, credentialSendRequest, credentialDeclineOffer, credentialSerialize, credentialDeserialize, v2CredentialUpdateStateWithMessage, v2CredentialUpdateState, credentialGetState, credentialGetOffers, credentialGetAttributes, credentialGetAttachment, credentialGetTailsLocation, credentialGetTailsHash, credentialGetRevRegId, credentialGetThreadId, credentialdefCreateV2, credentialdefPublish, credentialdefDeserialize, credentialdefRelease, credentialdefSerialize, credentialdefGetCredDefId, credentialdefUpdateState, credentialdefGetState, disclosedProofCreateWithRequest, disclosedProofRelease, disclosedProofSendProof, disclosedProofRejectProof, disclosedProofGetProofMsg, disclosedProofSerialize, disclosedProofDeserialize, v2DisclosedProofUpdateState, v2DisclosedProofUpdateStateWithMessage, disclosedProofGetState, disclosedProofGetRequests, disclosedProofRetrieveCredentials, disclosedProofGetProofRequestAttachment, disclosedProofGenerateProof, disclosedProofDeclinePresentationRequest, disclosedProofGetThreadId, issuerCredentialDeserialize, issuerCredentialSerialize, issuerCredentialUpdateStateV2, issuerCredentialUpdateStateWithMessageV2, issuerCredentialUpdateStateWithMessageNonmediated, issuerCredentialGetState, issuerCredentialGetRevRegId, issuerCredentialCreate, issuerCredentialRevokeLocal, issuerCredentialIsRevokable, issuerCredentialSendCredential, issuerCredentialSendCredentialNonmediated, issuerCredentialSendOfferV2, issuerCredentialSendOfferNonmediated, issuerCredentialMarkOfferMsgSent, issuerCredentialBuildOfferMsgV2, issuerCredentialGetOfferMsg, issuerCredentialRelease, issuerCredentialGetThreadId, getLedgerAuthorAgreement, setActiveTxnAuthorAgreementMeta, createService, createServiceV2, getServiceFromLedger, getAttrFromLedger, clearAttrFromLedger, getVerkeyFromLedger, getLedgerTxn, initDefaultLogger, mediatedConnectionGeneratePublicInvite, mediatedConnectionGetPwDid, mediatedConnectionGetTheirPwDid, mediatedConnectionGetThreadId, mediatedConnectionGetState, mediatedConnectionGetSourceId, mediatedConnectionCreate, mediatedConnectionCreateWithInvite, mediatedConnectionSendMessage, mediatedConnectionCreateWithConnectionRequestV2, mediatedConnectionSendHandshakeReuse, mediatedConnectionUpdateStateWithMessage, mediatedConnectionHandleMessage, mediatedConnectionUpdateState, mediatedConnectionDeleteConnection, mediatedConnectionConnect, mediatedConnectionSerialize, mediatedConnectionDeserialize, mediatedConnectionRelease, mediatedConnectionInviteDetails, mediatedConnectionSendPing, mediatedConnectionSendDiscoveryFeatures, mediatedConnectionInfo, mediatedConnectionMessagesDownload, mediatedConnectionSignData, mediatedConnectionVerifySignature, outOfBandBuildHandshakeReuseAcceptedMsg, outOfBandReceiverCreate, outOfBandReceiverExtractMessage, outOfBandReceiverConnectionExists, outOfBandReceiverNonmediatedConnectionExists, outOfBandReceiverBuildConnection, outOfBandReceiverGetThreadId, outOfBandReceiverSerialize, outOfBandReceiverDeserialize, outOfBandReceiverRelease, outOfBandSenderCreate, outOfBandSenderAppendMessage, outOfBandSenderAppendService, outOfBandSenderAppendServiceDid, outOfBandSenderToMessage, outOfBandSenderGetThreadId, outOfBandSenderSerialize, outOfBandSenderDeserialize, outOfBandSenderRelease, openMainPool, closeMainPool, proofCreate, proofGetPresentationMsg, proofGetPresentationRequestAttachment, proofGetPresentationAttachment, proofRelease, proofSendRequest, proofSendRequestNonmediated, proofGetRequestMsg, proofSerialize, proofDeserialize, v2ProofUpdateState, v2ProofUpdateStateWithMessage, proofUpdateStateWithMessageNonmediated, proofGetState, proofGetPresentationVerificationStatus, proofGetRevocationStatus, proofGetThreadId, markPresentationRequestMsgSent, revocationRegistryCreate, revocationRegistryPublish, revocationRegistryPublishRevocations, revocationRegistryGetRevRegId, revocationRegistryGetTailsHash, revocationRegistrySerialize, revocationRegistryDeserialize, revocationRegistryRelease, schemaGetAttributes, schemaPrepareForEndorser, schemaCreate, schemaGetSchemaId, schemaDeserialize, schemaSerialize, schemaRelease, schemaUpdateState, schemaGetState, enableMocks, trustpingBuildResponseMsg, trustpingBuildPing, shutdown, getVersion, walletOpenAsMain, walletCreateMain, walletCloseMain, vcxInitIssuerConfig, configureIssuerWallet, unpack, createPairwiseInfo, walletImport, walletExport, getVerkeyFromWallet, rotateVerkey, rotateVerkeyStart, rotateVerkeyApply } = nativeBinding +const { updateWebhookUrl, createAgencyClientForMainWallet, provisionCloudAgent, messagesUpdateStatus, generatePublicInvitation, connectionCreateInviter, connectionCreateInvitee, connectionGetThreadId, connectionGetPairwiseInfo, connectionGetRemoteDid, connectionGetRemoteVk, connectionGetState, connectionGetInvitation, connectionProcessInvite, connectionProcessRequest, connectionProcessResponse, connectionProcessAck, connectionProcessProblemReport, connectionSendResponse, connectionSendRequest, connectionSendAck, connectionSendGenericMessage, connectionSendAriesMessage, connectionCreateInvite, connectionSerialize, connectionDeserialize, connectionRelease, credentialCreateWithOffer, credentialRelease, credentialSendRequest, credentialDeclineOffer, credentialSerialize, credentialDeserialize, v2CredentialUpdateStateWithMessage, v2CredentialUpdateState, credentialGetState, credentialGetOffers, credentialGetAttributes, credentialGetAttachment, credentialGetTailsLocation, credentialGetTailsHash, credentialGetRevRegId, credentialGetThreadId, credentialdefCreateV2, credentialdefPublish, credentialdefDeserialize, credentialdefRelease, credentialdefSerialize, credentialdefGetCredDefId, credentialdefUpdateState, credentialdefGetState, disclosedProofCreateWithRequest, disclosedProofRelease, disclosedProofSendProof, disclosedProofRejectProof, disclosedProofGetProofMsg, disclosedProofSerialize, disclosedProofDeserialize, v2DisclosedProofUpdateState, v2DisclosedProofUpdateStateWithMessage, disclosedProofGetState, disclosedProofGetRequests, disclosedProofRetrieveCredentials, disclosedProofGetProofRequestAttachment, disclosedProofGenerateProof, disclosedProofDeclinePresentationRequest, disclosedProofGetThreadId, issuerCredentialDeserialize, issuerCredentialSerialize, issuerCredentialUpdateStateV2, issuerCredentialUpdateStateWithMessageV2, issuerCredentialUpdateStateWithMessageNonmediated, issuerCredentialGetState, issuerCredentialGetRevRegId, issuerCredentialCreate, issuerCredentialRevokeLocal, issuerCredentialIsRevokable, issuerCredentialSendCredential, issuerCredentialSendCredentialNonmediated, issuerCredentialSendOfferV2, issuerCredentialSendOfferNonmediated, issuerCredentialMarkOfferMsgSent, issuerCredentialBuildOfferMsgV2, issuerCredentialGetOfferMsg, issuerCredentialRelease, issuerCredentialGetThreadId, getLedgerAuthorAgreement, setActiveTxnAuthorAgreementMeta, createService, createServiceV2, getServiceFromLedger, getAttrFromLedger, clearAttrFromLedger, getVerkeyFromLedger, getLedgerTxn, initDefaultLogger, mediatedConnectionGeneratePublicInvite, mediatedConnectionGetPwDid, mediatedConnectionGetTheirPwDid, mediatedConnectionGetThreadId, mediatedConnectionGetState, mediatedConnectionGetSourceId, mediatedConnectionCreate, mediatedConnectionCreateWithInvite, mediatedConnectionSendMessage, mediatedConnectionCreateWithConnectionRequestV2, mediatedConnectionSendHandshakeReuse, mediatedConnectionUpdateStateWithMessage, mediatedConnectionHandleMessage, mediatedConnectionUpdateState, mediatedConnectionDeleteConnection, mediatedConnectionConnect, mediatedConnectionSerialize, mediatedConnectionDeserialize, mediatedConnectionRelease, mediatedConnectionInviteDetails, mediatedConnectionSendPing, mediatedConnectionSendDiscoveryFeatures, mediatedConnectionInfo, mediatedConnectionMessagesDownload, mediatedConnectionSignData, mediatedConnectionVerifySignature, outOfBandBuildHandshakeReuseAcceptedMsg, outOfBandReceiverCreate, outOfBandReceiverExtractMessage, outOfBandReceiverConnectionExists, outOfBandReceiverNonmediatedConnectionExists, outOfBandReceiverBuildConnection, outOfBandReceiverGetThreadId, outOfBandReceiverSerialize, outOfBandReceiverDeserialize, outOfBandReceiverRelease, outOfBandSenderCreate, outOfBandSenderAppendMessage, outOfBandSenderAppendService, outOfBandSenderAppendServiceDid, outOfBandSenderToMessage, outOfBandSenderGetThreadId, outOfBandSenderSerialize, outOfBandSenderDeserialize, outOfBandSenderRelease, openMainPool, closeMainPool, proofCreate, proofGetPresentationMsg, proofGetPresentationRequestAttachment, proofGetPresentationAttachment, proofRelease, proofSendRequest, proofSendRequestNonmediated, proofGetRequestMsg, proofSerialize, proofDeserialize, v2ProofUpdateState, v2ProofUpdateStateWithMessage, proofUpdateStateWithMessageNonmediated, proofGetState, proofGetVerificationStatus, proofGetThreadId, markPresentationRequestMsgSent, revocationRegistryCreate, revocationRegistryPublish, revocationRegistryPublishRevocations, revocationRegistryGetRevRegId, revocationRegistryGetTailsHash, revocationRegistrySerialize, revocationRegistryDeserialize, revocationRegistryRelease, schemaGetAttributes, schemaPrepareForEndorser, schemaCreate, schemaGetSchemaId, schemaDeserialize, schemaSerialize, schemaRelease, schemaUpdateState, schemaGetState, enableMocks, trustpingBuildResponseMsg, trustpingBuildPing, shutdown, getVersion, walletOpenAsMain, walletCreateMain, walletCloseMain, vcxInitIssuerConfig, configureIssuerWallet, unpack, createPairwiseInfo, walletImport, walletExport, getVerkeyFromWallet, rotateVerkey, rotateVerkeyStart, rotateVerkeyApply } = nativeBinding module.exports.updateWebhookUrl = updateWebhookUrl module.exports.createAgencyClientForMainWallet = createAgencyClientForMainWallet @@ -405,8 +405,7 @@ module.exports.v2ProofUpdateState = v2ProofUpdateState module.exports.v2ProofUpdateStateWithMessage = v2ProofUpdateStateWithMessage module.exports.proofUpdateStateWithMessageNonmediated = proofUpdateStateWithMessageNonmediated module.exports.proofGetState = proofGetState -module.exports.proofGetPresentationVerificationStatus = proofGetPresentationVerificationStatus -module.exports.proofGetRevocationStatus = proofGetRevocationStatus +module.exports.proofGetVerificationStatus = proofGetVerificationStatus module.exports.proofGetThreadId = proofGetThreadId module.exports.markPresentationRequestMsgSent = markPresentationRequestMsgSent module.exports.revocationRegistryCreate = revocationRegistryCreate diff --git a/wrappers/vcx-napi-rs/src/api/proof.rs b/wrappers/vcx-napi-rs/src/api/proof.rs index c89fdd5fa8..810d1aa49b 100644 --- a/wrappers/vcx-napi-rs/src/api/proof.rs +++ b/wrappers/vcx-napi-rs/src/api/proof.rs @@ -108,13 +108,8 @@ fn proof_get_state(handle: u32) -> napi::Result { } #[napi] -fn proof_get_presentation_verification_status(handle: u32) -> napi::Result { - proof::get_presentation_verification_status(handle).map_err(to_napi_err) -} - -#[napi] -fn proof_get_revocation_status(handle: u32) -> napi::Result { - proof::get_revocation_status(handle) +fn proof_get_verification_status(handle: u32) -> napi::Result { + proof::get_verification_status(handle) .map_err(to_napi_err) .map(|status| status.code()) }