diff --git a/agents/node/vcxagent-core/demo/alice.js b/agents/node/vcxagent-core/demo/alice.js index 88add09da9..5b3b0df949 100644 --- a/agents/node/vcxagent-core/demo/alice.js +++ b/agents/node/vcxagent-core/demo/alice.js @@ -41,7 +41,7 @@ async function getInvitationString (fetchInviteUrl) { } async function runAlice (options) { - logger.info('Starting.') + logger.info('Starting alice.') initRustLogger(process.env.RUST_LOG || 'vcx=error') const agentName = `alice-${uuid.v4()}` diff --git a/agents/node/vcxagent-core/demo/faber.js b/agents/node/vcxagent-core/demo/faber.js index 5b85336563..8a03749fc4 100644 --- a/agents/node/vcxagent-core/demo/faber.js +++ b/agents/node/vcxagent-core/demo/faber.js @@ -17,7 +17,7 @@ const { testTailsUrl, initRustLogger } = require('../src') const tailsDir = '/tmp/tails' async function runFaber (options) { - logger.info(`Starting. Revocation enabled=${options.revocation}`) + logger.info(`Starting Faber. Revocation enabled=${options.revocation}`) initRustLogger(process.env.RUST_LOG || 'vcx=error') let faberServer @@ -84,7 +84,9 @@ async function runFaber (options) { const schemaAttrs = getAliceSchemaAttrs() await vcxAgent.serviceCredIssuer.sendOfferAndCredential(issuerCredId, revRegId, connectionId, credDefId, schemaAttrs) if (options.revocation === true) { + logger.info('Faber is revoking issued credential') await vcxAgent.serviceCredIssuer.revokeCredentialLocal(issuerCredId) + logger.info('Faber is publishing revocation') await revReg.publishRevocations() } diff --git a/agents/node/vcxagent-core/demo/logger.js b/agents/node/vcxagent-core/demo/logger.js index 1968ec8903..c4441099ec 100644 --- a/agents/node/vcxagent-core/demo/logger.js +++ b/agents/node/vcxagent-core/demo/logger.js @@ -5,7 +5,7 @@ const prettyFormatter = format.combine( format.printf( msg => { const extras = (global.expect) ? `${global.expect.getState().currentTestName}` : '' - return `[${msg.timestamp}] [${msg.filename}] [${msg.level}] ${extras}: ${msg.message}` + return `[${msg.timestamp}] [${msg.filename}] [${msg.label}] [${msg.level}] ${extras}: ${msg.message}` } ) ) @@ -14,6 +14,7 @@ module.exports = loggerLabel => { return createLogger({ level: 'debug', format: format.combine( + format.label({ label: loggerLabel }), format.timestamp({ format: 'YYYY-MM-DD HH:mm:ss.SSS' }), diff --git a/agents/node/vcxagent-core/src/services/service-cred-issuer.js b/agents/node/vcxagent-core/src/services/service-cred-issuer.js index 635c4140d8..b9ad7b9ddb 100644 --- a/agents/node/vcxagent-core/src/services/service-cred-issuer.js +++ b/agents/node/vcxagent-core/src/services/service-cred-issuer.js @@ -19,10 +19,7 @@ module.exports.createServiceCredIssuer = function createServiceCredIssuer ({ log }) const state1 = await issuerCred.getState() assert.equal(state1, IssuerStateType.OfferSet) - const credOfferMsg = await issuerCred.getCredentialOfferMsg() - await issuerCred.markCredentialOfferMsgSent() - const state2 = await issuerCred.getState() - assert.equal(state2, IssuerStateType.OfferSent) + const credOfferMsg = issuerCred.getCredentialOfferMsg() await saveIssuerCredential(issuerCredId, issuerCred) return credOfferMsg @@ -44,8 +41,6 @@ module.exports.createServiceCredIssuer = function createServiceCredIssuer ({ log const state1 = await issuerCred.getState() assert.equal(state1, IssuerStateType.OfferSet) await issuerCred.sendOfferV2(connection) - const state2 = await issuerCred.getState() - assert.equal(state2, IssuerStateType.OfferSent) await saveIssuerCredential(issuerCredId, issuerCred) } @@ -108,9 +103,11 @@ module.exports.createServiceCredIssuer = function createServiceCredIssuer ({ log async function _progressIssuerCredentialToState (issuerCredential, connection, credentialStateTarget, attemptsThreshold, timeoutMs) { async function progressToAcceptedState () { - if (await issuerCredential.updateStateV2(connection) !== credentialStateTarget) { + const currentState = await issuerCredential.updateStateV2(connection) + if (currentState !== credentialStateTarget) { return { result: undefined, isFinished: false } } else { + logger.debug(`Cred issuer: _progressIssuerCredentialToState, currentState: ${currentState}, credentialStateTarget: ${credentialStateTarget}`) return { result: null, isFinished: true } } } diff --git a/agents/rust/aries-vcx-agent/src/services/holder.rs b/agents/rust/aries-vcx-agent/src/services/holder.rs index 822ceefb72..cfb91fcbc2 100644 --- a/agents/rust/aries-vcx-agent/src/services/holder.rs +++ b/agents/rust/aries-vcx-agent/src/services/holder.rs @@ -57,17 +57,16 @@ impl ServiceCredentialsHolder { pub async fn send_credential_proposal( &self, connection_id: &str, - proposal_data: ProposeCredential, + propose_credential: ProposeCredential, ) -> AgentResult { let connection = self.service_connections.get_by_id(connection_id)?; let wallet = self.profile.inject_wallet(); - let send_closure: SendClosure = Box::new(|msg: AriesMessage| { - Box::pin(async move { connection.send_message(&wallet, &msg, &HttpClient).await }) - }); - let mut holder = Holder::create("")?; - holder.send_proposal(proposal_data, send_closure).await?; + holder.set_proposal(propose_credential.clone())?; + connection + .send_message(&wallet, &propose_credential.into(), &HttpClient) + .await?; self.creds_holder .insert(&holder.get_thread_id()?, HolderWrapper::new(holder, connection_id)) @@ -98,37 +97,44 @@ impl ServiceCredentialsHolder { let send_closure: SendClosure = Box::new(|msg: AriesMessage| { Box::pin(async move { connection.send_message(&wallet, &msg, &HttpClient).await }) }); - - holder - .send_request( + let msg_response = holder + .prepare_credential_request( &self.profile.inject_anoncreds_ledger_read(), &self.profile.inject_anoncreds(), pw_did, - send_closure, ) .await?; + send_closure(msg_response).await?; self.creds_holder .insert(&holder.get_thread_id()?, HolderWrapper::new(holder, &connection_id)) } - pub async fn process_credential(&self, thread_id: &str, credential: IssueCredential) -> AgentResult { + pub async fn process_credential( + &self, + thread_id: &str, + msg_issue_credential: IssueCredential, + ) -> AgentResult { let mut holder = self.get_holder(thread_id)?; let connection_id = self.get_connection_id(thread_id)?; let connection = self.service_connections.get_by_id(&connection_id)?; let wallet = self.profile.inject_wallet(); - let send_closure: SendClosure = Box::new(|msg: AriesMessage| { - Box::pin(async move { connection.send_message(&wallet, &msg, &HttpClient).await }) - }); - holder .process_credential( &self.profile.inject_anoncreds_ledger_read(), &self.profile.inject_anoncreds(), - credential, - send_closure, + msg_issue_credential.clone(), ) .await?; + match holder.get_final_message()? { + None => {} + Some(msg_response) => { + let send_closure: SendClosure = Box::new(|msg: AriesMessage| { + Box::pin(async move { connection.send_message(&wallet, &msg, &HttpClient).await }) + }); + send_closure(msg_response).await?; + } + } self.creds_holder .insert(&holder.get_thread_id()?, HolderWrapper::new(holder, &connection_id)) } diff --git a/agents/rust/aries-vcx-agent/src/services/issuer.rs b/agents/rust/aries-vcx-agent/src/services/issuer.rs index f997f75c9b..78b515cdb1 100644 --- a/agents/rust/aries-vcx-agent/src/services/issuer.rs +++ b/agents/rust/aries-vcx-agent/src/services/issuer.rs @@ -84,7 +84,8 @@ impl ServiceCredentialsIssuer { Box::pin(async move { connection.send_message(&wallet, &msg, &HttpClient).await }) }); - issuer.send_credential_offer(send_closure).await?; + let credential_offer = issuer.get_credential_offer_msg()?; + send_closure(credential_offer).await?; self.creds_issuer .insert(&issuer.get_thread_id()?, IssuerWrapper::new(issuer, &connection_id)) } @@ -124,9 +125,17 @@ impl ServiceCredentialsIssuer { Box::pin(async move { connection.send_message(&wallet, &msg, &HttpClient).await }) }); - issuer - .send_credential(&self.profile.inject_anoncreds(), send_closure) - .await?; + issuer.build_credential(&self.profile.inject_anoncreds()).await?; + match issuer.get_state() { + IssuerState::Failed => { + let problem_report = issuer.get_problem_report()?; + send_closure(problem_report.into()).await?; + } + _ => { + let msg_issue_credential = issuer.get_msg_issue_credential()?; + send_closure(msg_issue_credential.into()).await?; + } + } self.creds_issuer .insert(&issuer.get_thread_id()?, IssuerWrapper::new(issuer, &connection_id))?; Ok(()) diff --git a/aries_vcx/src/handlers/issuance/holder.rs b/aries_vcx/src/handlers/issuance/holder.rs index 662e700b27..b5e167915c 100644 --- a/aries_vcx/src/handlers/issuance/holder.rs +++ b/aries_vcx/src/handlers/issuance/holder.rs @@ -1,12 +1,20 @@ +use chrono::Utc; use std::sync::Arc; +use uuid::Uuid; use aries_vcx_core::anoncreds::base_anoncreds::BaseAnonCreds; use aries_vcx_core::ledger::base_ledger::AnoncredsLedgerRead; use aries_vcx_core::wallet::base_wallet::BaseWallet; +use messages::decorators::thread::Thread; +use messages::decorators::timing::Timing; +use messages::msg_fields::protocols::cred_issuance::ack::{AckCredential, AckCredentialContent}; use messages::msg_fields::protocols::cred_issuance::issue_credential::IssueCredential; use messages::msg_fields::protocols::cred_issuance::offer_credential::OfferCredential; use messages::msg_fields::protocols::cred_issuance::propose_credential::ProposeCredential; +use messages::msg_fields::protocols::cred_issuance::request_credential::RequestCredential; use messages::msg_fields::protocols::cred_issuance::CredentialIssuance; +use messages::msg_fields::protocols::notification::ack::{AckDecorators, AckStatus}; +use messages::msg_fields::protocols::report_problem::ProblemReport; use messages::msg_fields::protocols::revocation::revoke::Revoke; use messages::AriesMessage; @@ -14,8 +22,17 @@ use crate::common::credentials::get_cred_rev_id; use crate::errors::error::prelude::*; use crate::handlers::connection::mediated_connection::MediatedConnection; use crate::handlers::revocation_notification::receiver::RevocationNotificationReceiver; -use crate::protocols::issuance::holder::state_machine::{HolderSM, HolderState}; -use crate::protocols::SendClosure; +use crate::protocols::issuance::holder::state_machine::{HolderFullState, HolderSM, HolderState}; + +fn build_credential_ack(thread_id: &str) -> AckCredential { + let content = AckCredentialContent::new(AckStatus::Ok); + let mut decorators = AckDecorators::new(Thread::new(thread_id.to_owned())); + let mut timing = Timing::default(); + timing.out_time = Some(Utc::now()); + decorators.timing = Some(timing); + + AckCredential::with_decorators(Uuid::new_v4().to_string(), content, decorators) +} #[derive(Serialize, Deserialize, Debug, Clone)] pub struct Holder { @@ -29,6 +46,16 @@ impl Holder { Ok(Holder { holder_sm }) } + pub fn create_with_proposal(source_id: &str, propose_credential: ProposeCredential) -> VcxResult { + trace!( + "Holder::create_with_proposal >>> source_id: {:?}, propose_credential: {:?}", + source_id, + propose_credential + ); + let holder_sm = HolderSM::with_proposal(propose_credential, source_id.to_string()); + Ok(Holder { holder_sm }) + } + pub fn create_from_offer(source_id: &str, credential_offer: OfferCredential) -> VcxResult { trace!( "Holder::create_from_offer >>> source_id: {:?}, credential_offer: {:?}", @@ -39,41 +66,51 @@ impl Holder { Ok(Holder { holder_sm }) } - pub async fn send_proposal( - &mut self, - credential_proposal: ProposeCredential, - send_message: SendClosure, - ) -> VcxResult<()> { - self.holder_sm = self - .holder_sm - .clone() - .send_proposal(credential_proposal, send_message) - .await?; + pub fn set_proposal(&mut self, credential_proposal: ProposeCredential) -> VcxResult<()> { + self.holder_sm = self.holder_sm.clone().set_proposal(credential_proposal)?; Ok(()) } - pub async fn send_request( + pub async fn prepare_credential_request( &mut self, ledger: &Arc, anoncreds: &Arc, my_pw_did: String, - send_message: SendClosure, - ) -> VcxResult<()> { + ) -> VcxResult { self.holder_sm = self .holder_sm .clone() - .send_request(ledger, anoncreds, my_pw_did, send_message) + .prepare_credential_request(ledger, anoncreds, my_pw_did) .await?; - Ok(()) + match self.get_state() { + HolderState::Failed => { + Ok(self.get_problem_report()?.into()) + } + HolderState::RequestSet => { + Ok(self.get_msg_credential_request()?.into()) + } + _ => { + Err(AriesVcxError::from_msg(AriesVcxErrorKind::InvalidState, "Holder::prepare_credential_request >> reached unexpected state after calling prepare_credential_request")) + } + } } - pub async fn decline_offer<'a>(&'a mut self, comment: Option<&'a str>, send_message: SendClosure) -> VcxResult<()> { - self.holder_sm = self - .holder_sm - .clone() - .decline_offer(comment.map(String::from), send_message) - .await?; - Ok(()) + pub fn get_msg_credential_request(&self) -> VcxResult { + match self.holder_sm.state { + HolderFullState::RequestSet(ref state) => { + let mut msg: RequestCredential = state.msg_credential_request.clone().into(); + let mut timing = Timing::default(); + timing.out_time = Some(Utc::now()); + msg.decorators.timing = Some(timing); + Ok(msg) + } + _ => Err(AriesVcxError::from_msg(AriesVcxErrorKind::NotReady, "Invalid action")), + } + } + + pub fn decline_offer<'a>(&'a mut self, comment: Option<&'a str>) -> VcxResult { + self.holder_sm = self.holder_sm.clone().decline_offer(comment.map(String::from))?; + self.get_problem_report() } pub async fn process_credential( @@ -81,12 +118,11 @@ impl Holder { ledger: &Arc, anoncreds: &Arc, credential: IssueCredential, - send_message: SendClosure, ) -> VcxResult<()> { self.holder_sm = self .holder_sm .clone() - .receive_credential(ledger, anoncreds, credential, send_message) + .receive_credential(ledger, anoncreds, credential) .await?; Ok(()) } @@ -186,25 +222,25 @@ impl Holder { } } + pub fn get_problem_report(&self) -> VcxResult { + self.holder_sm.get_problem_report() + } + + // todo 0109: send ack/problem-report in upper layer pub async fn process_aries_msg( &mut self, ledger: &Arc, anoncreds: &Arc, message: AriesMessage, - send_message: Option, ) -> VcxResult<()> { let holder_sm = match message { AriesMessage::CredentialIssuance(CredentialIssuance::OfferCredential(offer)) => { self.holder_sm.clone().receive_offer(offer)? } AriesMessage::CredentialIssuance(CredentialIssuance::IssueCredential(credential)) => { - let send_message = send_message.ok_or(AriesVcxError::from_msg( - AriesVcxErrorKind::InvalidState, - "Attempted to call undefined send_message callback", - ))?; self.holder_sm .clone() - .receive_credential(ledger, anoncreds, credential, send_message) + .receive_credential(ledger, anoncreds, credential) .await? } AriesMessage::ReportProblem(report) => self.holder_sm.clone().receive_problem_report(report)?, @@ -213,4 +249,19 @@ impl Holder { self.holder_sm = holder_sm; Ok(()) } + + pub fn get_final_message(&self) -> VcxResult> { + match &self.holder_sm.state { + HolderFullState::Finished(state) => { + if let Some(ack_requested) = state.ack_requested { + if ack_requested { + let ack_msg = build_credential_ack(&self.get_thread_id()?); + return Ok(Some(ack_msg.into())); + } + } + } + _ => {} + }; + return Ok(None); + } } diff --git a/aries_vcx/src/handlers/issuance/issuer.rs b/aries_vcx/src/handlers/issuance/issuer.rs index 5723abcb23..0acffcc48f 100644 --- a/aries_vcx/src/handlers/issuance/issuer.rs +++ b/aries_vcx/src/handlers/issuance/issuer.rs @@ -1,6 +1,3 @@ -use std::collections::HashMap; - -use messages::decorators::please_ack::AckOn; use messages::misc::MimeType; use messages::msg_fields::protocols::cred_issuance::ack::AckCredential; use messages::msg_fields::protocols::cred_issuance::propose_credential::ProposeCredential; @@ -11,16 +8,14 @@ use std::sync::Arc; use aries_vcx_core::anoncreds::base_anoncreds::BaseAnonCreds; use aries_vcx_core::ledger::base_ledger::AnoncredsLedgerRead; +use messages::msg_fields::protocols::cred_issuance::issue_credential::IssueCredential; use messages::msg_fields::protocols::notification::Notification; use messages::msg_fields::protocols::report_problem::ProblemReport; use messages::msg_parts::MsgParts; use crate::errors::error::prelude::*; -use crate::handlers::revocation_notification::sender::RevocationNotificationSender; use crate::handlers::util::OfferInfo; use crate::protocols::issuance::issuer::state_machine::{IssuerSM, IssuerState, RevocationInfoV1}; -use crate::protocols::revocation_notification::sender::state_machine::SenderConfigBuilder; -use crate::protocols::SendClosure; #[derive(Serialize, Deserialize, Debug, Clone, Default)] pub struct Issuer { @@ -151,16 +146,6 @@ impl Issuer { Ok(offer.into()) } - pub fn mark_credential_offer_msg_sent(&mut self) -> VcxResult<()> { - self.issuer_sm = self.issuer_sm.clone().mark_credential_offer_msg_sent()?; - Ok(()) - } - - pub async fn send_credential_offer(&mut self, send_message: SendClosure) -> VcxResult<()> { - self.issuer_sm = self.issuer_sm.clone().send_credential_offer(send_message).await?; - Ok(()) - } - pub fn process_credential_request(&mut self, request: RequestCredential) -> VcxResult<()> { self.issuer_sm = self.issuer_sm.clone().receive_request(request)?; Ok(()) @@ -171,43 +156,13 @@ impl Issuer { Ok(()) } - pub async fn send_credential( - &mut self, - anoncreds: &Arc, - send_message: SendClosure, - ) -> VcxResult<()> { - self.issuer_sm = self.issuer_sm.clone().send_credential(anoncreds, send_message).await?; + pub async fn build_credential(&mut self, anoncreds: &Arc) -> VcxResult<()> { + self.issuer_sm = self.issuer_sm.clone().build_credential(anoncreds).await?; Ok(()) } - pub async fn send_revocation_notification( - &mut self, - ack_on: Vec, - comment: Option, - send_message: SendClosure, - ) -> VcxResult<()> { - // TODO: Check if actually revoked - if self.issuer_sm.is_revokable() { - // TODO: Store to allow checking not. status (sent, acked) - let config = SenderConfigBuilder::default() - .rev_reg_id(self.get_rev_reg_id()?) - .cred_rev_id(self.get_rev_id()?) - .comment(comment) - .ack_on(ack_on) - .build()?; - RevocationNotificationSender::build() - .send_revocation_notification(config, send_message) - .await?; - Ok(()) - } else { - Err(AriesVcxError::from_msg( - AriesVcxErrorKind::InvalidState, - format!( - "Can't send revocation notification in state {:?}, credential is not revokable", - self.issuer_sm.get_state() - ), - )) - } + pub fn get_msg_issue_credential(&mut self) -> VcxResult { + self.issuer_sm.clone().get_msg_issue_credential() } pub fn get_state(&self) -> IssuerState { @@ -306,6 +261,10 @@ impl Issuer { Ok(()) } + pub fn get_problem_report(&self) -> VcxResult { + self.issuer_sm.get_problem_report() + } + // todo: will ultimately end up in generic SM layer pub async fn process_aries_msg(&mut self, msg: AriesMessage) -> VcxResult<()> { let issuer_sm = match msg { diff --git a/aries_vcx/src/handlers/issuance/mediated_holder.rs b/aries_vcx/src/handlers/issuance/mediated_holder.rs index af892739ea..b45e5cae57 100644 --- a/aries_vcx/src/handlers/issuance/mediated_holder.rs +++ b/aries_vcx/src/handlers/issuance/mediated_holder.rs @@ -16,14 +16,14 @@ pub fn holder_find_message_to_handle( trace!("holder_find_message_to_handle >>>"); for (uid, message) in messages { match sm.get_state() { - HolderState::ProposalSent => { + HolderState::ProposalSet => { if let AriesMessage::CredentialIssuance(CredentialIssuance::OfferCredential(offer)) = &message { if matches_opt_thread_id!(offer, sm.get_thread_id().unwrap().as_str()) { return Some((uid, message)); } } } - HolderState::RequestSent => match &message { + HolderState::RequestSet => match &message { AriesMessage::CredentialIssuance(CredentialIssuance::IssueCredential(credential)) => { if matches_thread_id!(credential, sm.get_thread_id().unwrap().as_str()) { return Some((uid, message)); diff --git a/aries_vcx/src/handlers/issuance/mediated_issuer.rs b/aries_vcx/src/handlers/issuance/mediated_issuer.rs index a819d97e22..7edf21b963 100644 --- a/aries_vcx/src/handlers/issuance/mediated_issuer.rs +++ b/aries_vcx/src/handlers/issuance/mediated_issuer.rs @@ -23,39 +23,48 @@ pub fn issuer_find_message_to_handle( match sm.get_state() { IssuerState::Initial => { if let AriesMessage::CredentialIssuance(CredentialIssuance::ProposeCredential(_)) = &message { + info!("In state IssuerState::OfferSet, found matching message ProposeCredential"); return Some((uid, message)); } } - IssuerState::OfferSent => match &message { + IssuerState::OfferSet => match &message { AriesMessage::CredentialIssuance(CredentialIssuance::RequestCredential(msg)) => { + info!("In state IssuerState::OfferSet, found potentially matching message RequestCredential"); + warn!("Matching for {}", sm.get_thread_id().unwrap().as_str()); // todo: the state machine has "test" thid, and doesnt match msg + warn!("Msg: {msg:?}"); if matches_opt_thread_id!(msg, sm.get_thread_id().unwrap().as_str()) { return Some((uid, message)); } } AriesMessage::CredentialIssuance(CredentialIssuance::ProposeCredential(msg)) => { + info!("In state IssuerState::OfferSet, found potentially matching message ProposeCredential"); if matches_opt_thread_id!(msg, sm.get_thread_id().unwrap().as_str()) { return Some((uid, message)); } } AriesMessage::ReportProblem(msg) => { + info!("In state IssuerState::OfferSet, found matching message ReportProblem"); if matches_opt_thread_id!(msg, sm.get_thread_id().unwrap().as_str()) { return Some((uid, message)); } } _ => {} }, - IssuerState::CredentialSent => match &message { + IssuerState::CredentialSet => match &message { AriesMessage::CredentialIssuance(CredentialIssuance::Ack(msg)) => { + info!("In state IssuerState::CredentialSet, found matching message CredentialIssuance::Ack"); if matches_thread_id!(msg, sm.get_thread_id().unwrap().as_str()) { return Some((uid, message)); } } AriesMessage::Notification(Notification::Ack(msg)) => { + info!("In state IssuerState::CredentialSet, found matching message Notification::Ack"); if matches_thread_id!(msg, sm.get_thread_id().unwrap().as_str()) { return Some((uid, message)); } } AriesMessage::ReportProblem(msg) => { + info!("In state IssuerState::CredentialSet, found matching message ReportProblem"); if matches_opt_thread_id!(msg, sm.get_thread_id().unwrap().as_str()) { return Some((uid, message)); } diff --git a/aries_vcx/src/handlers/mod.rs b/aries_vcx/src/handlers/mod.rs index 065865dd8e..dda90f09b7 100644 --- a/aries_vcx/src/handlers/mod.rs +++ b/aries_vcx/src/handlers/mod.rs @@ -40,9 +40,9 @@ impl From for u32 { fn from(state: HolderState) -> u32 { match state { HolderState::Initial => 0, - HolderState::ProposalSent => 1, + HolderState::ProposalSet => 1, HolderState::OfferReceived => 2, - HolderState::RequestSent => 3, + HolderState::RequestSet => 3, HolderState::Finished => 4, HolderState::Failed => 5, } @@ -55,9 +55,8 @@ impl From for u32 { IssuerState::Initial => 0, IssuerState::ProposalReceived => 1, IssuerState::OfferSet => 2, - IssuerState::OfferSent => 3, IssuerState::RequestReceived => 4, - IssuerState::CredentialSent => 5, + IssuerState::CredentialSet => 5, IssuerState::Finished => 6, IssuerState::Failed => 7, } diff --git a/aries_vcx/src/handlers/revocation_notification/mod.rs b/aries_vcx/src/handlers/revocation_notification/mod.rs index 19e5c09918..3ade2da98c 100644 --- a/aries_vcx/src/handlers/revocation_notification/mod.rs +++ b/aries_vcx/src/handlers/revocation_notification/mod.rs @@ -1,6 +1,43 @@ +use crate::errors::error::{AriesVcxError, AriesVcxErrorKind, VcxResult}; +use crate::handlers::issuance::issuer::Issuer; +use crate::handlers::revocation_notification::sender::RevocationNotificationSender; +use crate::protocols::revocation_notification::sender::state_machine::SenderConfigBuilder; +use crate::protocols::SendClosure; +use messages::decorators::please_ack::AckOn; + pub mod receiver; pub mod sender; +pub async fn send_revocation_notification( + issuer: &Issuer, + ack_on: Vec, + comment: Option, + send_message: SendClosure, +) -> VcxResult<()> { + // TODO: Check if actually revoked + if issuer.is_revokable() { + // TODO: Store to allow checking not. status (sent, acked) + let config = SenderConfigBuilder::default() + .rev_reg_id(issuer.get_rev_reg_id()?) + .cred_rev_id(issuer.get_rev_id()?) + .comment(comment) + .ack_on(ack_on) + .build()?; + RevocationNotificationSender::build() + .send_revocation_notification(config, send_message) + .await?; + Ok(()) + } else { + Err(AriesVcxError::from_msg( + AriesVcxErrorKind::InvalidState, + format!( + "Can't send revocation notification in state {:?}, credential is not revokable", + issuer.get_state() + ), + )) + } +} + pub mod test_utils { use agency_client::agency_client::AgencyClient; use messages::msg_fields::protocols::revocation::ack::AckRevoke; diff --git a/aries_vcx/src/protocols/issuance/holder/state_machine.rs b/aries_vcx/src/protocols/issuance/holder/state_machine.rs index 55bd861c8b..3e7b5cfb79 100644 --- a/aries_vcx/src/protocols/issuance/holder/state_machine.rs +++ b/aries_vcx/src/protocols/issuance/holder/state_machine.rs @@ -1,4 +1,3 @@ -use std::collections::HashMap; use std::fmt; use std::sync::Arc; @@ -28,25 +27,24 @@ use crate::protocols::common::build_problem_report_msg; use crate::protocols::issuance::holder::states::finished::FinishedHolderState; use crate::protocols::issuance::holder::states::initial::InitialHolderState; use crate::protocols::issuance::holder::states::offer_received::OfferReceivedState; -use crate::protocols::issuance::holder::states::proposal_sent::ProposalSentState; -use crate::protocols::issuance::holder::states::request_sent::RequestSentState; -use crate::protocols::SendClosure; +use crate::protocols::issuance::holder::states::proposal_set::ProposalSetState; +use crate::protocols::issuance::holder::states::request_set::RequestSetState; #[derive(Serialize, Deserialize, Debug, Clone)] pub enum HolderFullState { Initial(InitialHolderState), - ProposalSent(ProposalSentState), + ProposalSet(ProposalSetState), OfferReceived(OfferReceivedState), - RequestSent(RequestSentState), + RequestSet(RequestSetState), Finished(FinishedHolderState), } #[derive(Debug, PartialEq, Eq)] pub enum HolderState { Initial, - ProposalSent, + ProposalSet, OfferReceived, - RequestSent, + RequestSet, Finished, Failed, } @@ -62,15 +60,15 @@ impl fmt::Display for HolderFullState { fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> { match *self { HolderFullState::Initial(_) => f.write_str("Initial"), - HolderFullState::ProposalSent(_) => f.write_str("ProposalSent"), + HolderFullState::ProposalSet(_) => f.write_str("ProposalSet"), HolderFullState::OfferReceived(_) => f.write_str("OfferReceived"), - HolderFullState::RequestSent(_) => f.write_str("RequestSent"), + HolderFullState::RequestSet(_) => f.write_str("RequestSet"), HolderFullState::Finished(_) => f.write_str("Finished"), } } } -fn build_credential_request_msg(credential_request_attach: String, thread_id: &str) -> VcxResult { +fn _build_credential_request_msg(credential_request_attach: String, thread_id: &str) -> RequestCredential { let content = RequestCredentialContent::new(vec![make_attach_from_str!( &credential_request_attach, AttachmentId::CredentialRequest.as_ref().to_string() @@ -85,21 +83,7 @@ fn build_credential_request_msg(credential_request_attach: String, thread_id: &s decorators.thread = Some(thread); decorators.timing = Some(timing); - Ok(RequestCredential::with_decorators( - Uuid::new_v4().to_string(), - content, - decorators, - )) -} - -fn build_credential_ack(thread_id: &str) -> AckCredential { - let content = AckCredentialContent::new(AckStatus::Ok); - let mut decorators = AckDecorators::new(Thread::new(thread_id.to_owned())); - let mut timing = Timing::default(); - timing.out_time = Some(Utc::now()); - decorators.timing = Some(timing); - - AckCredential::with_decorators(Uuid::new_v4().to_string(), content, decorators) + RequestCredential::with_decorators(Uuid::new_v4().to_string(), content, decorators) } impl HolderSM { @@ -119,6 +103,14 @@ impl HolderSM { } } + pub fn with_proposal(propose_credential: ProposeCredential, source_id: String) -> Self { + HolderSM { + thread_id: propose_credential.id.clone(), + state: HolderFullState::ProposalSet(ProposalSetState::new(propose_credential)), + source_id, + } + } + pub fn get_source_id(&self) -> String { self.source_id.clone() } @@ -126,9 +118,9 @@ impl HolderSM { pub fn get_state(&self) -> HolderState { match self.state { HolderFullState::Initial(_) => HolderState::Initial, - HolderFullState::ProposalSent(_) => HolderState::ProposalSent, + HolderFullState::ProposalSet(_) => HolderState::ProposalSet, HolderFullState::OfferReceived(_) => HolderState::OfferReceived, - HolderFullState::RequestSent(_) => HolderState::RequestSent, + HolderFullState::RequestSet(_) => HolderState::RequestSet, HolderFullState::Finished(ref status) => match status.status { Status::Success => HolderState::Finished, _ => HolderState::Failed, @@ -139,7 +131,7 @@ impl HolderSM { #[allow(dead_code)] pub fn get_proposal(&self) -> VcxResult { match &self.state { - HolderFullState::ProposalSent(state) => Ok(state.credential_proposal.clone()), + HolderFullState::ProposalSet(state) => Ok(state.credential_proposal.clone()), _ => Err(AriesVcxError::from_msg( AriesVcxErrorKind::InvalidState, "Proposal not available in this state", @@ -147,7 +139,8 @@ impl HolderSM { } } - pub async fn send_proposal(self, proposal: ProposeCredential, send_message: SendClosure) -> VcxResult { + pub fn set_proposal(self, proposal: ProposeCredential) -> VcxResult { + trace!("HolderSM::set_proposal >>"); verify_thread_id( &self.thread_id, &AriesMessage::CredentialIssuance(CredentialIssuance::ProposeCredential(proposal.clone())), @@ -156,17 +149,15 @@ impl HolderSM { HolderFullState::Initial(_) => { let mut proposal = proposal; proposal.id = self.thread_id.clone(); - send_message(proposal.clone().into()).await?; - HolderFullState::ProposalSent(ProposalSentState::new(proposal)) + HolderFullState::ProposalSet(ProposalSetState::new(proposal)) } HolderFullState::OfferReceived(_) => { let mut proposal = proposal; proposal.id = self.thread_id.clone(); - send_message(proposal.clone().into()).await?; - HolderFullState::ProposalSent(ProposalSentState::new(proposal)) + HolderFullState::ProposalSet(ProposalSetState::new(proposal)) } s => { - warn!("Unable to send credential proposal in state {}", s); + warn!("Unable to set credential proposal in state {}", s); s } }; @@ -174,12 +165,13 @@ impl HolderSM { } pub fn receive_offer(self, offer: OfferCredential) -> VcxResult { + trace!("HolderSM::receive_offer >>"); verify_thread_id( &self.thread_id, &AriesMessage::CredentialIssuance(CredentialIssuance::OfferCredential(offer.clone())), )?; let state = match self.state { - HolderFullState::ProposalSent(_) => HolderFullState::OfferReceived(OfferReceivedState::new(offer)), + HolderFullState::ProposalSet(_) => HolderFullState::OfferReceived(OfferReceivedState::new(offer)), s => { warn!("Unable to receive credential offer in state {}", s); s @@ -188,47 +180,55 @@ impl HolderSM { Ok(Self { state, ..self }) } - pub async fn send_request<'a>( + pub async fn prepare_credential_request<'a>( self, ledger: &'a Arc, anoncreds: &'a Arc, my_pw_did: String, - send_message: SendClosure, ) -> VcxResult { + trace!("HolderSM::prepare_credential_request >>"); let state = match self.state { HolderFullState::OfferReceived(state_data) => { - match _make_credential_request(ledger, anoncreds, self.thread_id.clone(), my_pw_did, &state_data.offer) - .await + match build_credential_request_msg( + ledger, + anoncreds, + self.thread_id.clone(), + my_pw_did, + &state_data.offer, + ) + .await { - Ok((cred_request, req_meta, cred_def_json)) => { - send_message(cred_request.into()).await?; - HolderFullState::RequestSent((state_data, req_meta, cred_def_json).into()) + Ok((msg_credential_request, req_meta, cred_def_json)) => { + HolderFullState::RequestSet(RequestSetState { + msg_credential_request, + req_meta, + cred_def_json, + }) } Err(err) => { let problem_report = build_problem_report_msg(Some(err.to_string()), &self.thread_id); error!( - "Failed to create credential request, sending problem report: {:?}", + "Failed to create credential request, generating problem report: {:?}", problem_report ); - send_message(problem_report.clone().into()).await?; - HolderFullState::Finished(problem_report.into()) + HolderFullState::Finished(FinishedHolderState::new(problem_report)) } } } s => { - warn!("Unable to send credential request in state {}", s); + warn!("Unable to set credential request in state {}", s); s } }; Ok(Self { state, ..self }) } - pub async fn decline_offer(self, comment: Option, send_message: SendClosure) -> VcxResult { + pub fn decline_offer(self, comment: Option) -> VcxResult { + trace!("HolderSM::decline_offer >>"); let state = match self.state { HolderFullState::OfferReceived(_) => { let problem_report = build_problem_report_msg(comment, &self.thread_id); - send_message(problem_report.clone().into()).await?; - HolderFullState::Finished(problem_report.into()) + HolderFullState::Finished(FinishedHolderState::new(problem_report)) } s => { warn!("Unable to decline credential offer in state {}", s); @@ -243,10 +243,10 @@ impl HolderSM { ledger: &'a Arc, anoncreds: &'a Arc, credential: IssueCredential, - send_message: SendClosure, ) -> VcxResult { + trace!("HolderSM::receive_credential >>"); let state = match self.state { - HolderFullState::RequestSent(state_data) => { + HolderFullState::RequestSet(state_data) => { match _store_credential( ledger, anoncreds, @@ -257,20 +257,12 @@ impl HolderSM { .await { Ok((cred_id, rev_reg_def_json)) => { - if credential.decorators.please_ack.is_some() { - let ack = build_credential_ack(&self.thread_id); - send_message(ack.into()).await?; - } HolderFullState::Finished((state_data, cred_id, credential, rev_reg_def_json).into()) } Err(err) => { let problem_report = build_problem_report_msg(Some(err.to_string()), &self.thread_id); - error!( - "Failed to process or save received credential, sending problem report: {:?}", - problem_report - ); - send_message(problem_report.clone().into()).await?; - HolderFullState::Finished(problem_report.into()) + error!("Failed to process or save received credential: {problem_report:?}"); + HolderFullState::Finished(FinishedHolderState::new(problem_report)) } } } @@ -283,9 +275,10 @@ impl HolderSM { } pub fn receive_problem_report(self, problem_report: ProblemReport) -> VcxResult { + warn!("HolderSM::receive_problem_report >> problem_report: {problem_report:?}"); let state = match self.state { - HolderFullState::ProposalSent(_) | HolderFullState::RequestSent(_) => { - HolderFullState::Finished(problem_report.into()) + HolderFullState::ProposalSet(_) | HolderFullState::RequestSet(_) => { + HolderFullState::Finished(FinishedHolderState::new(problem_report)) } s => { warn!("Unable to receive problem report in state {}", s); @@ -405,9 +398,9 @@ impl HolderSM { pub async fn is_revokable(&self, ledger: &Arc) -> VcxResult { match self.state { HolderFullState::Initial(ref state) => state.is_revokable(), - HolderFullState::ProposalSent(ref state) => state.is_revokable(ledger).await, + HolderFullState::ProposalSet(ref state) => state.is_revokable(ledger).await, HolderFullState::OfferReceived(ref state) => state.is_revokable(ledger).await, - HolderFullState::RequestSent(ref state) => state.is_revokable(), + HolderFullState::RequestSet(ref state) => state.is_revokable(), HolderFullState::Finished(ref state) => state.is_revokable(), } } @@ -439,7 +432,10 @@ impl HolderSM { AriesVcxErrorKind::InvalidState, "Cannot get credential: credential id not found", ))?; - _delete_credential(anoncreds, &cred_id).await + anoncreds + .prover_delete_credential(&cred_id) + .await + .map_err(|err| err.into()) } _ => Err(AriesVcxError::from_msg( AriesVcxErrorKind::NotReady, @@ -447,6 +443,23 @@ impl HolderSM { )), } } + + pub fn get_problem_report(&self) -> VcxResult { + match self.state { + HolderFullState::Finished(ref state) => match &state.status { + Status::Failed(problem_report) => Ok(problem_report.clone()), + Status::Declined(problem_report) => Ok(problem_report.clone()), + _ => Err(AriesVcxError::from_msg( + AriesVcxErrorKind::NotReady, + "No problem report available in current state", + )), + }, + _ => Err(AriesVcxError::from_msg( + AriesVcxErrorKind::NotReady, + "No problem report available in current state", + )), + } + } } pub fn parse_cred_def_id_from_cred_offer(cred_offer: &str) -> VcxResult { @@ -524,16 +537,7 @@ async fn _store_credential( Ok((cred_id, rev_reg_def_json)) } -async fn _delete_credential(anoncreds: &Arc, cred_id: &str) -> VcxResult<()> { - trace!("Holder::_delete_credential >>> cred_id: {}", cred_id); - - anoncreds - .prover_delete_credential(cred_id) - .await - .map_err(|err| err.into()) -} - -pub async fn create_credential_request( +pub async fn create_anoncreds_credential_request( ledger: &Arc, anoncreds: &Arc, cred_def_id: &str, @@ -551,7 +555,7 @@ pub async fn create_credential_request( .map_err(|err| err.into()) } -async fn _make_credential_request( +async fn build_credential_request_msg( ledger: &Arc, anoncreds: &Arc, thread_id: String, @@ -569,8 +573,8 @@ async fn _make_credential_request( trace!("Parsed cred offer attachment: {}", cred_offer); let cred_def_id = parse_cred_def_id_from_cred_offer(&cred_offer)?; let (req, req_meta, _cred_def_id, cred_def_json) = - create_credential_request(ledger, anoncreds, &cred_def_id, &my_pw_did, &cred_offer).await?; + create_anoncreds_credential_request(ledger, anoncreds, &cred_def_id, &my_pw_did, &cred_offer).await?; trace!("Created cred def json: {}", cred_def_json); - let credential_request_msg = build_credential_request_msg(req, &thread_id)?; + let credential_request_msg = _build_credential_request_msg(req, &thread_id); Ok((credential_request_msg, req_meta, cred_def_json)) } diff --git a/aries_vcx/src/protocols/issuance/holder/states/finished.rs b/aries_vcx/src/protocols/issuance/holder/states/finished.rs index afddb52035..35e75308ed 100644 --- a/aries_vcx/src/protocols/issuance/holder/states/finished.rs +++ b/aries_vcx/src/protocols/issuance/holder/states/finished.rs @@ -10,6 +10,7 @@ pub struct FinishedHolderState { pub credential: Option, pub status: Status, pub rev_reg_def_json: Option, + pub ack_requested: Option, } impl FinishedHolderState { @@ -142,10 +143,11 @@ impl FinishedHolderState { } } -impl From for FinishedHolderState { - fn from(problem_report: ProblemReport) -> Self { +impl FinishedHolderState { + pub fn new(problem_report: ProblemReport) -> Self { trace!("SM is now in Finished state"); FinishedHolderState { + ack_requested: None, cred_id: None, credential: None, status: Status::Failed(problem_report), diff --git a/aries_vcx/src/protocols/issuance/holder/states/mod.rs b/aries_vcx/src/protocols/issuance/holder/states/mod.rs index b9dfdb227d..4c8f63598c 100644 --- a/aries_vcx/src/protocols/issuance/holder/states/mod.rs +++ b/aries_vcx/src/protocols/issuance/holder/states/mod.rs @@ -1,5 +1,5 @@ pub(super) mod finished; pub(super) mod initial; pub(super) mod offer_received; -pub(super) mod proposal_sent; -pub(super) mod request_sent; +pub(super) mod proposal_set; +pub(super) mod request_set; diff --git a/aries_vcx/src/protocols/issuance/holder/states/offer_received.rs b/aries_vcx/src/protocols/issuance/holder/states/offer_received.rs index 5c876bbc41..e42e54d8f2 100644 --- a/aries_vcx/src/protocols/issuance/holder/states/offer_received.rs +++ b/aries_vcx/src/protocols/issuance/holder/states/offer_received.rs @@ -4,7 +4,6 @@ use std::sync::Arc; use crate::errors::error::prelude::*; use crate::handlers::util::get_attach_as_string; use crate::protocols::issuance::holder::state_machine::parse_cred_def_id_from_cred_offer; -use crate::protocols::issuance::holder::states::request_sent::RequestSentState; use crate::protocols::issuance::is_cred_def_revokable; use messages::msg_fields::protocols::cred_issuance::offer_credential::OfferCredential; @@ -13,17 +12,6 @@ pub struct OfferReceivedState { pub offer: OfferCredential, } -impl From<(OfferReceivedState, String, String)> for RequestSentState { - fn from((_state, req_meta, cred_def_json): (OfferReceivedState, String, String)) -> Self { - trace!("SM is now in RequestSent state"); - trace!("cred_def_json={:?}", cred_def_json); - RequestSentState { - req_meta, - cred_def_json, - } - } -} - impl OfferReceivedState { pub fn new(offer: OfferCredential) -> Self { OfferReceivedState { offer } diff --git a/aries_vcx/src/protocols/issuance/holder/states/proposal_sent.rs b/aries_vcx/src/protocols/issuance/holder/states/proposal_set.rs similarity index 92% rename from aries_vcx/src/protocols/issuance/holder/states/proposal_sent.rs rename to aries_vcx/src/protocols/issuance/holder/states/proposal_set.rs index 484e1b89ad..8e55b4df3f 100644 --- a/aries_vcx/src/protocols/issuance/holder/states/proposal_sent.rs +++ b/aries_vcx/src/protocols/issuance/holder/states/proposal_set.rs @@ -7,11 +7,11 @@ use crate::errors::error::prelude::*; use crate::protocols::issuance::is_cred_def_revokable; #[derive(Serialize, Deserialize, Debug, Clone)] -pub struct ProposalSentState { +pub struct ProposalSetState { pub credential_proposal: ProposeCredential, } -impl ProposalSentState { +impl ProposalSetState { pub fn new(credential_proposal: ProposeCredential) -> Self { Self { credential_proposal } } diff --git a/aries_vcx/src/protocols/issuance/holder/states/request_sent.rs b/aries_vcx/src/protocols/issuance/holder/states/request_set.rs similarity index 67% rename from aries_vcx/src/protocols/issuance/holder/states/request_sent.rs rename to aries_vcx/src/protocols/issuance/holder/states/request_set.rs index e24ec7bfff..fe2293f087 100644 --- a/aries_vcx/src/protocols/issuance/holder/states/request_sent.rs +++ b/aries_vcx/src/protocols/issuance/holder/states/request_set.rs @@ -1,30 +1,33 @@ use messages::msg_fields::protocols::cred_issuance::issue_credential::IssueCredential; +use messages::msg_fields::protocols::cred_issuance::request_credential::RequestCredential; use crate::errors::error::prelude::*; use crate::handlers::util::Status; use crate::protocols::issuance::holder::states::finished::FinishedHolderState; #[derive(Serialize, Deserialize, Debug, Clone)] -pub struct RequestSentState { +pub struct RequestSetState { pub req_meta: String, pub cred_def_json: String, + pub msg_credential_request: RequestCredential, } -impl From<(RequestSentState, String, IssueCredential, Option)> for FinishedHolderState { +impl From<(RequestSetState, String, IssueCredential, Option)> for FinishedHolderState { fn from( - (_, cred_id, credential, rev_reg_def_json): (RequestSentState, String, IssueCredential, Option), + (_, cred_id, credential, rev_reg_def_json): (RequestSetState, String, IssueCredential, Option), ) -> Self { - trace!("SM is now in Finished state"); + let ack_requested = credential.decorators.please_ack.is_some(); FinishedHolderState { cred_id: Some(cred_id), credential: Some(credential), status: Status::Success, rev_reg_def_json, + ack_requested: Some(ack_requested), } } } -impl RequestSentState { +impl RequestSetState { pub fn is_revokable(&self) -> VcxResult { let parsed_cred_def: serde_json::Value = serde_json::from_str(&self.cred_def_json).map_err(|err| { AriesVcxError::from_msg( diff --git a/aries_vcx/src/protocols/issuance/issuer/state_machine.rs b/aries_vcx/src/protocols/issuance/issuer/state_machine.rs index 4a9cead2cd..54f2c7d737 100644 --- a/aries_vcx/src/protocols/issuance/issuer/state_machine.rs +++ b/aries_vcx/src/protocols/issuance/issuer/state_machine.rs @@ -29,23 +29,20 @@ use crate::common::credentials::encoding::encode_attributes; use crate::common::credentials::is_cred_revoked; use crate::errors::error::{AriesVcxError, AriesVcxErrorKind, VcxResult}; use crate::protocols::common::build_problem_report_msg; -use crate::protocols::issuance::issuer::states::credential_sent::CredentialSentState; +use crate::protocols::issuance::issuer::states::credential_set::CredentialSetState; use crate::protocols::issuance::issuer::states::finished::FinishedState; use crate::protocols::issuance::issuer::states::initial::InitialIssuerState; -use crate::protocols::issuance::issuer::states::offer_sent::OfferSentState; use crate::protocols::issuance::issuer::states::offer_set::OfferSetState; use crate::protocols::issuance::issuer::states::proposal_received::ProposalReceivedState; use crate::protocols::issuance::issuer::states::requested_received::RequestReceivedState; -use crate::protocols::SendClosure; #[derive(Serialize, Deserialize, Debug, Clone)] pub enum IssuerFullState { Initial(InitialIssuerState), OfferSet(OfferSetState), ProposalReceived(ProposalReceivedState), - OfferSent(OfferSentState), RequestReceived(RequestReceivedState), - CredentialSent(CredentialSentState), + CredentialSet(CredentialSetState), Finished(FinishedState), } @@ -54,9 +51,8 @@ pub enum IssuerState { Initial, OfferSet, ProposalReceived, - OfferSent, RequestReceived, - CredentialSent, + CredentialSet, Finished, Failed, } @@ -68,9 +64,8 @@ impl Display for IssuerFullState { IssuerFullState::Initial(_) => f.write_str("Initial"), IssuerFullState::OfferSet(_) => f.write_str("OfferSet"), IssuerFullState::ProposalReceived(_) => f.write_str("ProposalReceived"), - IssuerFullState::OfferSent(_) => f.write_str("OfferSent"), IssuerFullState::RequestReceived(_) => f.write_str("RequestReceived"), - IssuerFullState::CredentialSent(_) => f.write_str("CredentialSent"), + IssuerFullState::CredentialSet(_) => f.write_str("CredentialSet"), IssuerFullState::Finished(_) => f.write_str("Finished"), } } @@ -96,7 +91,7 @@ pub struct IssuerSM { pub(crate) state: IssuerFullState, } -fn build_credential_message(libindy_credential: String) -> VcxResult { +fn build_credential_message(libindy_credential: String, thread_id: String) -> IssueCredential { let id = Uuid::new_v4().to_string(); let content = IssueCredentialContent::new(vec![make_attach_from_str!( @@ -104,12 +99,10 @@ fn build_credential_message(libindy_credential: String) -> VcxResult Option { match &self.state { - IssuerFullState::CredentialSent(state) => state.revocation_info_v1.clone(), + IssuerFullState::CredentialSet(state) => state.revocation_info_v1.clone(), IssuerFullState::Finished(state) => state.revocation_info_v1.clone(), _ => None, } @@ -180,7 +173,7 @@ impl IssuerSM { "No revocation info found - is this credential revokable?", ); let rev_id = match &self.state { - IssuerFullState::CredentialSent(state) => state.revocation_info_v1.as_ref().ok_or(err)?.cred_rev_id.clone(), + IssuerFullState::CredentialSet(state) => state.revocation_info_v1.as_ref().ok_or(err)?.cred_rev_id.clone(), IssuerFullState::Finished(state) => state.revocation_info_v1.as_ref().ok_or(err)?.cred_rev_id.clone(), _ => None, }; @@ -203,9 +196,8 @@ impl IssuerSM { Some(offer_info) => offer_info.rev_reg_id.clone(), _ => None, }, - IssuerFullState::OfferSent(state) => state.rev_reg_id.clone(), IssuerFullState::RequestReceived(state) => state.rev_reg_id.clone(), - IssuerFullState::CredentialSent(state) => { + IssuerFullState::CredentialSet(state) => { state .revocation_info_v1 .clone() @@ -240,7 +232,7 @@ impl IssuerSM { } } match &self.state { - IssuerFullState::CredentialSent(state) => _is_revokable(&state.revocation_info_v1), + IssuerFullState::CredentialSet(state) => _is_revokable(&state.revocation_info_v1), IssuerFullState::Finished(state) => _is_revokable(&state.revocation_info_v1), _ => false, } @@ -264,9 +256,8 @@ impl IssuerSM { IssuerFullState::Initial(_) => IssuerState::Initial, IssuerFullState::ProposalReceived(_) => IssuerState::ProposalReceived, IssuerFullState::OfferSet(_) => IssuerState::OfferSet, - IssuerFullState::OfferSent(_) => IssuerState::OfferSent, IssuerFullState::RequestReceived(_) => IssuerState::RequestReceived, - IssuerFullState::CredentialSent(_) => IssuerState::CredentialSent, + IssuerFullState::CredentialSet(_) => IssuerState::CredentialSet, IssuerFullState::Finished(ref status) => match status.status { Status::Success => IssuerState::Finished, _ => IssuerState::Failed, @@ -296,6 +287,7 @@ impl IssuerSM { source_id, thread_id, } = self; + warn!("IssuerSM::build_credential_offer_msg >>> thread_id: {thread_id}"); let state = match state { IssuerFullState::Initial(_) | IssuerFullState::OfferSet(_) | IssuerFullState::ProposalReceived(_) => { let cred_offer_msg = build_credential_offer(&thread_id, credential_offer, credential_preview, comment)?; @@ -320,7 +312,6 @@ impl IssuerSM { pub fn get_credential_offer_msg(&self) -> VcxResult { match &self.state { IssuerFullState::OfferSet(state) => Ok(state.offer.clone()), - IssuerFullState::OfferSent(state) => Ok(state.offer.clone()), _ => Err(AriesVcxError::from_msg( AriesVcxErrorKind::InvalidState, format!("Can not get_credential_offer in current state {}.", self.state), @@ -328,25 +319,6 @@ impl IssuerSM { } } - pub fn mark_credential_offer_msg_sent(self) -> VcxResult { - let Self { - state, - source_id, - thread_id, - } = self; - let state = match state { - IssuerFullState::OfferSet(state) => IssuerFullState::OfferSent(state.into()), - IssuerFullState::OfferSent(state) => IssuerFullState::OfferSent(state), - _ => { - return Err(AriesVcxError::from_msg( - AriesVcxErrorKind::InvalidState, - format!("Can not mark_as_offer_sent in current state {}.", state), - )) - } - }; - Ok(Self::step(source_id, thread_id, state)) - } - pub fn receive_proposal(self, proposal: ProposeCredential) -> VcxResult { verify_thread_id( &self.thread_id, @@ -358,7 +330,7 @@ impl IssuerSM { let state = IssuerFullState::ProposalReceived(ProposalReceivedState::new(proposal, None)); (state, thread_id) } - IssuerFullState::OfferSent(_) => { + IssuerFullState::OfferSet(_) => { let state = IssuerFullState::ProposalReceived(ProposalReceivedState::new(proposal, None)); (state, self.thread_id.clone()) } @@ -374,26 +346,15 @@ impl IssuerSM { }) } - pub async fn send_credential_offer(self, send_message: SendClosure) -> VcxResult { - Ok(match self.state { - IssuerFullState::OfferSet(ref state_data) => { - let cred_offer_msg = state_data.offer.clone().into(); - send_message(cred_offer_msg).await?; - self.mark_credential_offer_msg_sent()? - } - _ => { - return Err(AriesVcxError::from_msg(AriesVcxErrorKind::NotReady, "Invalid action")); - } - }) - } - pub fn receive_request(self, request: RequestCredential) -> VcxResult { verify_thread_id( &self.thread_id, &AriesMessage::CredentialIssuance(CredentialIssuance::RequestCredential(request.clone())), )?; let state = match self.state { - IssuerFullState::OfferSent(state_data) => IssuerFullState::RequestReceived((state_data, request).into()), + IssuerFullState::OfferSet(state_data) => { + IssuerFullState::RequestReceived(RequestReceivedState::from_offer_set_and_request(state_data, request)) + } s => { warn!("Unable to receive credential request in state {}", s); s @@ -402,39 +363,37 @@ impl IssuerSM { Ok(Self { state, ..self }) } - pub async fn send_credential( - self, - anoncreds: &Arc, - send_message: SendClosure, - ) -> VcxResult { + pub async fn build_credential(self, anoncreds: &Arc) -> VcxResult { let state = match self.state { IssuerFullState::RequestReceived(state_data) => { - match _create_credential( + match create_credential( anoncreds, &state_data.request, &state_data.rev_reg_id, &state_data.tails_file, &state_data.offer, &state_data.cred_data, - &self.thread_id, + self.thread_id.clone(), ) .await { - Ok((mut credential_msg, cred_rev_id)) => { - credential_msg.decorators.thread.thid = self.thread_id.clone(); - credential_msg.decorators.please_ack = Some(PleaseAck::new(vec![])); // ask_for_ack sets this to an empty vec - - send_message(credential_msg.into()).await?; - IssuerFullState::CredentialSent((state_data, cred_rev_id).into()) + Ok((mut msg_issue_credential, cred_rev_id)) => { + // todo: have constructor for this + IssuerFullState::CredentialSet(CredentialSetState { + msg_issue_credential, + revocation_info_v1: Some(RevocationInfoV1 { + cred_rev_id, + rev_reg_id: state_data.rev_reg_id, + tails_file: state_data.tails_file, + }), + }) } + // todo: 1. Don't transition, throw error, add to_failed transition() api which SM consumer can call + // 2. Also create separate "Failed" state Err(err) => { let problem_report = build_problem_report_msg(Some(err.to_string()), &self.thread_id); - error!( - "Failed to create credential, sending problem report {:?}", - problem_report - ); - send_message(problem_report.clone().into()).await?; - IssuerFullState::Finished((state_data, problem_report).into()) + error!("Failed to create credential, generated problem report {problem_report:?}",); + IssuerFullState::Finished(FinishedState::from_request_and_error(state_data, problem_report)) } } } @@ -445,13 +404,28 @@ impl IssuerSM { Ok(Self { state, ..self }) } + pub fn get_msg_issue_credential(self) -> VcxResult { + match self.state { + IssuerFullState::CredentialSet(ref state_data) => { + let mut msg_issue_credential: IssueCredential = state_data.msg_issue_credential.clone().into(); + let mut timing = Timing::default(); + timing.out_time = Some(Utc::now()); + msg_issue_credential.decorators.timing = Some(timing); + Ok(msg_issue_credential) + } + _ => Err(AriesVcxError::from_msg(AriesVcxErrorKind::NotReady, "Invalid action")), + } + } + pub fn receive_ack(self, ack: AckCredential) -> VcxResult { verify_thread_id( &self.thread_id, &AriesMessage::CredentialIssuance(CredentialIssuance::Ack(ack.clone())), )?; let state = match self.state { - IssuerFullState::CredentialSent(state_data) => IssuerFullState::Finished(state_data.into()), + IssuerFullState::CredentialSet(state_data) => { + IssuerFullState::Finished(FinishedState::from_credential_set_state(state_data)) + } s => { warn!("Unable to receive credential ack in state {}", s); s @@ -463,8 +437,12 @@ impl IssuerSM { pub fn receive_problem_report(self, problem_report: ProblemReport) -> VcxResult { verify_thread_id(&self.thread_id, &AriesMessage::ReportProblem(problem_report.clone()))?; let state = match self.state { - IssuerFullState::OfferSent(state_data) => IssuerFullState::Finished((state_data, problem_report).into()), - IssuerFullState::CredentialSent(state_data) => IssuerFullState::Finished((state_data).into()), + IssuerFullState::OfferSet(state_data) => { + IssuerFullState::Finished(FinishedState::from_offer_set_and_error(state_data, problem_report)) + } + IssuerFullState::CredentialSet(state_data) => { + IssuerFullState::Finished(FinishedState::from_credential_set_state(state_data)) + } s => { warn!("Unable to receive credential ack in state {}", s); s @@ -489,21 +467,38 @@ impl IssuerSM { pub fn thread_id(&self) -> VcxResult { Ok(self.thread_id.clone()) } + + pub fn get_problem_report(&self) -> VcxResult { + match self.state { + IssuerFullState::Finished(ref state) => match &state.status { + Status::Failed(problem_report) => Ok(problem_report.clone()), + Status::Declined(problem_report) => Ok(problem_report.clone()), + _ => Err(AriesVcxError::from_msg( + AriesVcxErrorKind::NotReady, + "No problem report available in current state", + )), + }, + _ => Err(AriesVcxError::from_msg( + AriesVcxErrorKind::NotReady, + "No problem report available in current state", + )), + } + } } -async fn _create_credential( +async fn create_credential( anoncreds: &Arc, request: &RequestCredential, rev_reg_id: &Option, tails_file: &Option, offer: &OfferCredential, cred_data: &str, - thread_id: &str, + thread_id: String, ) -> VcxResult<(IssueCredential, Option)> { let offer = get_attach_as_string!(&offer.content.offers_attach); trace!("Issuer::_create_credential >>> request: {:?}, rev_reg_id: {:?}, tails_file: {:?}, offer: {}, cred_data: {}, thread_id: {}", request, rev_reg_id, tails_file, offer, cred_data, thread_id); - if !matches_opt_thread_id!(request, thread_id) { + if !matches_opt_thread_id!(request, thread_id.as_str()) { return Err(AriesVcxError::from_msg( AriesVcxErrorKind::InvalidJson, format!("Cannot handle credential request: thread id does not match"), @@ -516,6 +511,6 @@ async fn _create_credential( let (libindy_credential, cred_rev_id, _) = anoncreds .issuer_create_credential(&offer, &request, &cred_data, rev_reg_id.clone(), tails_file.clone()) .await?; - let credential = build_credential_message(libindy_credential)?; - Ok((credential, cred_rev_id)) + let msg_issue_credential = build_credential_message(libindy_credential, thread_id); + Ok((msg_issue_credential, cred_rev_id)) } diff --git a/aries_vcx/src/protocols/issuance/issuer/states/credential_sent.rs b/aries_vcx/src/protocols/issuance/issuer/states/credential_set.rs similarity index 65% rename from aries_vcx/src/protocols/issuance/issuer/states/credential_sent.rs rename to aries_vcx/src/protocols/issuance/issuer/states/credential_set.rs index c204495fbc..50ffe42f9e 100644 --- a/aries_vcx/src/protocols/issuance/issuer/states/credential_sent.rs +++ b/aries_vcx/src/protocols/issuance/issuer/states/credential_set.rs @@ -1,14 +1,16 @@ use crate::handlers::util::Status; use crate::protocols::issuance::issuer::state_machine::RevocationInfoV1; use crate::protocols::issuance::issuer::states::finished::FinishedState; +use messages::msg_fields::protocols::cred_issuance::issue_credential::IssueCredential; #[derive(Serialize, Deserialize, Debug, Clone)] -pub struct CredentialSentState { +pub struct CredentialSetState { pub revocation_info_v1: Option, + pub msg_issue_credential: IssueCredential, } -impl From for FinishedState { - fn from(state: CredentialSentState) -> Self { +impl FinishedState { + pub fn from_credential_set_state(state: CredentialSetState) -> Self { trace!("SM is now in Finished state"); FinishedState { cred_id: None, diff --git a/aries_vcx/src/protocols/issuance/issuer/states/initial.rs b/aries_vcx/src/protocols/issuance/issuer/states/initial.rs index ef4972ebda..6c45a9c4a3 100644 --- a/aries_vcx/src/protocols/issuance/issuer/states/initial.rs +++ b/aries_vcx/src/protocols/issuance/issuer/states/initial.rs @@ -1,18 +1,2 @@ -use messages::msg_fields::protocols::cred_issuance::offer_credential::OfferCredential; - -use crate::{handlers::util::OfferInfo, protocols::issuance::issuer::states::offer_sent::OfferSentState}; - #[derive(Serialize, Deserialize, Default, Debug, Clone, PartialEq, Eq)] pub struct InitialIssuerState {} - -impl From<(OfferInfo, OfferCredential)> for OfferSentState { - fn from((offer_info, offer): (OfferInfo, OfferCredential)) -> Self { - trace!("SM is now in OfferSent state"); - OfferSentState { - offer, - cred_data: offer_info.credential_json, - rev_reg_id: offer_info.rev_reg_id, - tails_file: offer_info.tails_file, - } - } -} diff --git a/aries_vcx/src/protocols/issuance/issuer/states/mod.rs b/aries_vcx/src/protocols/issuance/issuer/states/mod.rs index b64b310427..bea3523aa2 100644 --- a/aries_vcx/src/protocols/issuance/issuer/states/mod.rs +++ b/aries_vcx/src/protocols/issuance/issuer/states/mod.rs @@ -1,7 +1,6 @@ -pub(super) mod credential_sent; +pub(super) mod credential_set; pub(super) mod finished; pub(super) mod initial; -pub(super) mod offer_sent; pub(super) mod offer_set; pub(super) mod proposal_received; pub(super) mod requested_received; diff --git a/aries_vcx/src/protocols/issuance/issuer/states/offer_sent.rs b/aries_vcx/src/protocols/issuance/issuer/states/offer_sent.rs deleted file mode 100644 index cb51e5013c..0000000000 --- a/aries_vcx/src/protocols/issuance/issuer/states/offer_sent.rs +++ /dev/null @@ -1,59 +0,0 @@ -use messages::msg_fields::protocols::cred_issuance::offer_credential::OfferCredential; -use messages::msg_fields::protocols::cred_issuance::request_credential::RequestCredential; -use messages::msg_fields::protocols::report_problem::ProblemReport; - -use crate::handlers::util::Status; -use crate::protocols::issuance::issuer::state_machine::RevocationInfoV1; -use crate::protocols::issuance::issuer::states::finished::FinishedState; -use crate::protocols::issuance::issuer::states::requested_received::RequestReceivedState; - -#[derive(Serialize, Deserialize, Debug, Clone)] -pub struct OfferSentState { - pub offer: OfferCredential, - pub cred_data: String, - pub rev_reg_id: Option, - pub tails_file: Option, -} - -impl From for FinishedState { - fn from(state: OfferSentState) -> Self { - trace!("SM is now in Finished state"); - FinishedState { - cred_id: None, - revocation_info_v1: Some(RevocationInfoV1 { - cred_rev_id: None, - rev_reg_id: state.rev_reg_id, - tails_file: state.tails_file, - }), - status: Status::Undefined, - } - } -} - -impl From<(OfferSentState, RequestCredential)> for RequestReceivedState { - fn from((state, request): (OfferSentState, RequestCredential)) -> Self { - trace!("SM is now in Request Received state"); - RequestReceivedState { - offer: state.offer, - cred_data: state.cred_data, - rev_reg_id: state.rev_reg_id, - tails_file: state.tails_file, - request, - } - } -} - -impl From<(OfferSentState, ProblemReport)> for FinishedState { - fn from((state, err): (OfferSentState, ProblemReport)) -> Self { - trace!("SM is now in Finished state"); - FinishedState { - cred_id: None, - revocation_info_v1: Some(RevocationInfoV1 { - cred_rev_id: None, - rev_reg_id: state.rev_reg_id, - tails_file: state.tails_file, - }), - status: Status::Failed(err), - } - } -} diff --git a/aries_vcx/src/protocols/issuance/issuer/states/offer_set.rs b/aries_vcx/src/protocols/issuance/issuer/states/offer_set.rs index e3d2c395a2..e3597efdf6 100644 --- a/aries_vcx/src/protocols/issuance/issuer/states/offer_set.rs +++ b/aries_vcx/src/protocols/issuance/issuer/states/offer_set.rs @@ -1,5 +1,11 @@ -use crate::protocols::issuance::issuer::states::offer_sent::OfferSentState; use messages::msg_fields::protocols::cred_issuance::offer_credential::OfferCredential; +use messages::msg_fields::protocols::cred_issuance::request_credential::RequestCredential; +use messages::msg_fields::protocols::report_problem::ProblemReport; + +use crate::handlers::util::Status; +use crate::protocols::issuance::issuer::state_machine::RevocationInfoV1; +use crate::protocols::issuance::issuer::states::finished::FinishedState; +use crate::protocols::issuance::issuer::states::requested_received::RequestReceivedState; #[derive(Serialize, Deserialize, Debug, Clone)] pub struct OfferSetState { @@ -28,14 +34,30 @@ impl OfferSetState { } } -impl From for OfferSentState { - fn from(state: OfferSetState) -> Self { - trace!("SM is now in OfferSent state"); - OfferSentState { +impl RequestReceivedState { + pub fn from_offer_set_and_request(state: OfferSetState, request: RequestCredential) -> Self { + trace!("SM is now in Request Received state"); + RequestReceivedState { offer: state.offer, cred_data: state.credential_json, rev_reg_id: state.rev_reg_id, tails_file: state.tails_file, + request, + } + } +} + +impl FinishedState { + pub fn from_offer_set_and_error(state: OfferSetState, err: ProblemReport) -> Self { + trace!("SM is now in Finished state"); + FinishedState { + cred_id: None, + revocation_info_v1: Some(RevocationInfoV1 { + cred_rev_id: None, + rev_reg_id: state.rev_reg_id, + tails_file: state.tails_file, + }), + status: Status::Failed(err), } } } diff --git a/aries_vcx/src/protocols/issuance/issuer/states/proposal_received.rs b/aries_vcx/src/protocols/issuance/issuer/states/proposal_received.rs index 84c0202072..cf79ec3633 100644 --- a/aries_vcx/src/protocols/issuance/issuer/states/proposal_received.rs +++ b/aries_vcx/src/protocols/issuance/issuer/states/proposal_received.rs @@ -1,7 +1,5 @@ -use crate::{handlers::util::OfferInfo, protocols::issuance::issuer::states::offer_sent::OfferSentState}; -use messages::msg_fields::protocols::cred_issuance::{ - offer_credential::OfferCredential, propose_credential::ProposeCredential, -}; +use crate::handlers::util::OfferInfo; +use messages::msg_fields::protocols::cred_issuance::propose_credential::ProposeCredential; #[derive(Serialize, Deserialize, Debug, Clone)] pub struct ProposalReceivedState { @@ -17,15 +15,3 @@ impl ProposalReceivedState { } } } - -impl From<(OfferCredential, OfferInfo)> for OfferSentState { - fn from((offer, offer_info): (OfferCredential, OfferInfo)) -> Self { - trace!("SM is now in OfferSent state"); - OfferSentState { - offer, - cred_data: offer_info.credential_json, - rev_reg_id: offer_info.rev_reg_id, - tails_file: offer_info.tails_file, - } - } -} diff --git a/aries_vcx/src/protocols/issuance/issuer/states/requested_received.rs b/aries_vcx/src/protocols/issuance/issuer/states/requested_received.rs index 9ceb593e8b..ec021c301e 100644 --- a/aries_vcx/src/protocols/issuance/issuer/states/requested_received.rs +++ b/aries_vcx/src/protocols/issuance/issuer/states/requested_received.rs @@ -1,7 +1,8 @@ use crate::handlers::util::Status; use crate::protocols::issuance::issuer::state_machine::RevocationInfoV1; -use crate::protocols::issuance::issuer::states::credential_sent::CredentialSentState; +use crate::protocols::issuance::issuer::states::credential_set::CredentialSetState; use crate::protocols::issuance::issuer::states::finished::FinishedState; +use messages::msg_fields::protocols::cred_issuance::issue_credential::IssueCredential; use messages::msg_fields::protocols::cred_issuance::offer_credential::OfferCredential; use messages::msg_fields::protocols::cred_issuance::request_credential::RequestCredential; use messages::msg_fields::protocols::report_problem::ProblemReport; @@ -16,36 +17,8 @@ pub struct RequestReceivedState { pub request: RequestCredential, } -impl From<(RequestReceivedState, Option)> for CredentialSentState { - fn from((state, cred_rev_id): (RequestReceivedState, Option)) -> Self { - trace!("SM is now in CredentialSent state"); - CredentialSentState { - revocation_info_v1: Some(RevocationInfoV1 { - cred_rev_id, - rev_reg_id: state.rev_reg_id, - tails_file: state.tails_file, - }), - } - } -} - -impl From<(RequestReceivedState, Option)> for FinishedState { - fn from((state, cred_rev_id): (RequestReceivedState, Option)) -> Self { - trace!("SM is now in Finished state"); - FinishedState { - cred_id: None, - revocation_info_v1: Some(RevocationInfoV1 { - cred_rev_id, - rev_reg_id: state.rev_reg_id, - tails_file: state.tails_file, - }), - status: Status::Success, - } - } -} - -impl From<(RequestReceivedState, ProblemReport)> for FinishedState { - fn from((state, err): (RequestReceivedState, ProblemReport)) -> Self { +impl FinishedState { + pub fn from_request_and_error(state: RequestReceivedState, err: ProblemReport) -> Self { trace!("SM is now in Finished state"); FinishedState { cred_id: None, diff --git a/aries_vcx/src/utils/mockdata/mockdata_credex.rs b/aries_vcx/src/utils/mockdata/mockdata_credex.rs index efd626b68e..f377e75657 100644 --- a/aries_vcx/src/utils/mockdata/mockdata_credex.rs +++ b/aries_vcx/src/utils/mockdata/mockdata_credex.rs @@ -1,22 +1,3 @@ -// Faber creates instance of issuerCredential -pub const CREDENTIAL_ISSUER_SM_INITIAL: &str = r#" -{ - "version": "2.0", - "data": { - "issuer_sm": { - "state": { - "Initial": { - "cred_def_id": "V4SGRU86Z58d6TV7PBUe6f:3:CL:67:tag1", - "credential_json": "{\"name\":\"alice\",\"last_name\":\"clark\",\"sex\":\"female\",\"date\":\"05-2018\",\"degree\":\"maths\",\"age\":\"25\"}", - "rev_reg_id": "V4SGRU86Z58d6TV7PBUe6f:4:V4SGRU86Z58d6TV7PBUe6f:3:CL:67:tag1:CL_ACCUM:tag1", - "tails_file": "/tmp/tails" - } - }, - "source_id": "alice_degree" - } - } -}"#; - // Faber send Cred offer to Alice pub const ARIES_CREDENTIAL_OFFER: &str = r#"{ "@id": "57b3f85d-7673-4e6f-bb09-cc27cf2653c0", @@ -142,139 +123,6 @@ pub const ARIES_CREDENTIAL_OFFER_JSON_FORMAT: &str = r#"{ ] }"#; -// Alice receives offer, serialzied credential object -pub const CREDENTIAL_SM_OFFER_RECEIVED: &str = r#" -{ - "version": "2.0", - "data": { - "holder_sm": { - "state": { - "OfferReceived": { - "offer": { - "@id": "0a794e24-c6b4-46bc-93b6-642b6dc98c98", - "credential_preview": { - "@type": "https://didcomm.org/issue-credential/1.0/credential-preview", - "attributes": [ - { - "name": "age", - "value": "25" - }, - { - "name": "date", - "value": "05-2018" - }, - { - "name": "degree", - "value": "maths" - }, - { - "name": "last_name", - "value": "clark" - }, - { - "name": "name", - "value": "alice" - }, - { - "name": "sex", - "value": "female" - } - ] - }, - "offers~attach": [ - { - "mime-type": "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gxMjEyODc2NDM3NjYxMzEyNzk0MDAyMDM1MTczMzk1Nzg3Mjk2OTgyNTkzNTQyOTA0ODI5NjUxNTkxMjQ2Mzk1NTMzMDEzNDk1NzYyMzQwMzEyOTI2MDgxMTAyODQzMjcyMTgzNjIxMjA3MzEzMjI0MDY1NTU3MTMxMzI4MjIwNjY0NDg5MzM0NjM5MzQxNzUwOTMxNTAzNzE1Mjc1NjY0NzU1NDczMjYwOTk2NzcyMjU5OTM0Nzc5OTc2OTkwODQ2NjMwOTMxNzE0MzQyNzY1NjgwNTY2MjY3MTc2Nzk1ODEyNjM4OTUxNjE0NjM4NTQ2NjY2MzAwMzEyOTcxNzU2OTUwMjUxODQ2ODUyNzA3NzE4ODQyNTQxNDY3NjIwNDc4NTk1NDkxNDAzNzg1NTk5Nzk1MjE2MzQ5ODEzMzUwNjExNzM5ODQ4MTkwNzIxNjE4ODkxMjMzMzEwMDEwNzI0NTk5NDM3NjY2NTY3OTMxMTU3NjIyMDY3Mjc5Njk5MDI2NTUwODM5NTAyMTM2MDk4MDkzNTc1ODcyMTAxMzY5NjAxNzEwMjU0NzYxOTQ2MzI5OTk4MjQyMzcxMzU1MTg0ODk0OTMzODcwMjMzMTE1NDAxNDA0NDIwMzI0NzkxNDkxNzkxOTYxNjE1Nzg1MzE3MDcyNDUzNjk1MDA4NDIzOTkzODA2MzMzMDAxNjExNjc4MTI2NzQwNTI5OTMzMzc1MjM1OTIwNTQwODEwMDMwNTUzMzM3Il1dfSwibm9uY2UiOiIxMDQzMTE5ODcwMzg3MDQxNTUxNTI2NDcyIn0=" - } - } - ] - } - } - }, - "source_id": "credential", - "thread_id": "0a794e24-c6b4-46bc-93b6-642b6dc98c98" - } - } -}"#; - -pub const CREDENTIAL_ISSUER_SM_OFFER_SENT: &str = r#" -{ - "version": "2.0", - "data": { - "issuer_sm": { - "state": { - "OfferSent": { - "offer": "{\"schema_id\":\"V4SGRU86Z58d6TV7PBUe6f:2:FaberVcx:100.3.17\",\"cred_def_id\":\"V4SGRU86Z58d6TV7PBUe6f:3:CL:67:tag1\",\"key_correctness_proof\":{\"c\":\"8864890146079819966843507607084507466996537773103100015242104458151801570147\",\"xz_cap\":\"132525977827223287463967996367791660611753643437831026132133978673362652175979984960395345604117823033598843515772650970092042194998708471287667293473933602487387266144588495415616944811466910171746306576756067299147133996120610987778643167551472370650860706707489981250143016648216131940192067689731780997063617467994952948231164359737543271754978573745054322784594786983471195078199401393059600773630351754818811358191747218637239772879872305744584957954699837168611724572351569162034269703375267029483298772550673848980515525208224290008214955022684486373727968367957793088244529707858992758609642436424671530098100234617862130269644024376059636705980574590863518613785371479037964460747863\",\"xr_cap\":[[\"sex\",\"10212475160245231594800549040854372303290684256380918488632371037657339014806534940588554673668923103318206077059720668699192425379203595724258495955879134394690009722954264613493392981950745274150217838513814119475945408576517435232754189101061228937866890554581232132629336860287803380692900588369878654635587851842134163193490231540390456176691587533437539107704274260898642873639033821396021194012480721319148344547889691150132409707206905753961160393652003190095671994228552653431323771123633018647062857864156055033625475204728594378221420414003488928212382342146710978259261234513132305926681193895163367723096054346113318440172548126164414333781531199766980234151045186446173389250750\"],[\"degree\",\"181856742283453418473947649595643839643070259478938494473584568220469415234003101214923568013389712089002329509118010979819585255765334238653117932153907089227645576208149810056409291168266428333261231854714933689106351331306816560842818860955234224247467640283042193459845731039690242246162523419565162139381433436933425221922323252396259800586021811741002612505633393087999348487119018329907231223385144479615810153697792611768280290272847820566343166477570068876099556872349244742948210464728021063596957911336342418328102789261913866759741499940584934272174291759174216727901817778811694981504735794125209427214071854022871460401400559698149515333154883748572389272770720317560040712463897\"],[\"last_name\",\"43412293567073349102112370943795877043603069152786756498774529064165953390534477439420146649598887449303789243003836468145767558140820442230844681934242970120831621453186179743368507180242146094550439741968410170425735458888264171137616733641994947577653377853741974230587834360530942891162312983451291321340293070667444620919832965237004751459565905919070707692222664425077116273747444134874197630342511594972069999241272389020918350223302366912905038256257556690157536705279199282258870150174840775692849251725897411119789553994274891144344912923909296194371393823491152500258183683169146109761023058311487837541072813281306532733667848057503262367757201118550813992265344590262271483166483\"],[\"age\",\"68342866294164011784068034274328072729841816986472440793547517786819950247342073166125571525944766248482144768406472174708352715021161116977703459457196044671553753789562125231630111971572509052286957232826269542683452777397984820513540182019167192724561725096668080555141395762042804963579418584382415603000719514263625675792935811436862337394717705375498597054528271873897333941942675196453346888442959900889587403191435514572804420548366858537668848441873376613896206538002439203362350139060639241117668758869032773776414496608576676647828858037464226698788774683675796572388678801019435860058662641742186926934144365911980113050833169032386925668167616423998641959714326637643554532217927\"],[\"master_secret\",\"60004873604256882440837669482238000425353856673067906457286010426208332163294126128885588581808791972508689907661578422431435118216751145826744523616784738075865102182509689742359261285611551353667639554970046746807004041010623030438482125350153333189623356909573083022944384078323987456778721331893146299446171287036574645093201976492734355689314716208371556221655298694091873959850260058791477223797014501706197365726012893398404127387368852187102516338509783310599108227670748363371954452847108084863174642336130498792917539274492599601833452527856405146246277807281210276550206074749962019132159548975746780957482296723374263390806203268708835298174905777660267160424797736483014387864683\"],[\"date\",\"147342231503793263080838729926386421141753550322051739532890945800316221161473286924260404683208240537601816578975559097476493354445488636446930836424043194706973028057749444613329339999021747905965142733819319720303415509712171707205991530386667705361036306405728793380171364485013423072936004131892503597639074001977913486938956159872339293493930826077346851599196644812195740522922688159437382767733592015471466588476394412816911141620857591622245384369269230628756557778440089022685454958567766134358991022569505345783113088026211541418945735300261241258177732630669365390732700156680264076945134895046668269614083784528392573721268626040969213510380794408409764469331606990221467663106853\"],[\"name\",\"46402350507976620716083395016692554430921101058383359733469226024696002199385956892242058194593743795002035073758889854136413733934944023450686279086986421612064353302873838723273555536096043190932778102533172724397365106365130372069705599082758437270547570970026575560880601324063760607196158943453986432582265650934901685192243880872480587151034169399609684173921326513947204955133660721836876002637382143169397664542931310323878715494117950078756837048067536655534046663594626819353508083548306536346359549874088950193043473994946248616534386837224123826810232926853785332232969433958536376898849373637169605881974490269433669642934641299039638695661096758953398028200825360695660802669816\"]]},\"nonce\":\"69188538184527788000509\"}", - "cred_data": "{\"name\":\"alice\",\"last_name\":\"clark\",\"sex\":\"female\",\"date\":\"05-2018\",\"degree\":\"maths\",\"age\":\"25\"}", - "rev_reg_id": "V4SGRU86Z58d6TV7PBUe6f:4:V4SGRU86Z58d6TV7PBUe6f:3:CL:67:tag1:CL_ACCUM:tag1", - "tails_file": "/tmp/tails", - "connection_handle": 12002013, - "thread_id": "cb54e2f9-ee17-488c-9bc7-d70c29cff802" - } - }, - "source_id": "alice_degree" - } - } -}"#; - -// Alice creates credential object from offer and serializes it -pub const SERIALIZED_CREDENTIAL_V2_OFFER_RECEIVED: &str = r#"{ - "version": "2.0", - "data": { - "holder_sm": { - "state": { - "OfferReceived": { - "offer": { - "@id": "e314d535-6996-4c97-baab-d778d498f349", - "credential_preview": { - "@type": "https://didcomm.org/issue-credential/1.0/credential-preview", - "attributes": [ - { - "name": "age", - "value": "25" - }, - { - "name": "date", - "value": "05-2018" - }, - { - "name": "degree", - "value": "maths" - }, - { - "name": "last_name", - "value": "clark" - }, - { - "name": "name", - "value": "alice" - }, - { - "name": "sex", - "value": "female" - } - ] - }, - "offers~attach": [ - { - "mime-type": "application/json", - "@id": "libindy-cred-offer-0", - "data": { - "base64": "eyJzY2hlbWFfaWQiOiJWNFNHUlU4Nlo1OGQ2VFY3UEJVZTZmOjI6RmFiZXJWY3g6MjcuNC42MSIsImNyZWRfZGVmX2lkIjoiVjRTR1JVODZaNThkNlRWN1BCVWU2ZjozOkNMOjE5OnRhZzEiLCJrZXlfY29ycmVjdG5lc3NfcHJvb2YiOnsiYyI6Ijg0MzkyNzU0MDI2MjE4OTgwMTYyNTM0OTIyMjA2NjI3MTYzMzA5NzA3OTI0MTAzMzQzODU1NjAxMTQ2NDIzMDMyNjM0NDMyMDI5NTk4IiwieHpfY2FwIjoiMTM1NzI0NjMxNTE1OTEyMjQwMTE3NDk4NjgwNDQ0Mzk3Mzg1MDk1NzIxMDc3MjQ4MzU3MTE3OTAwNzM0NTY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zNTA3MTI0NDMxODE2ODM5MDQzNzA3MzM4Nzg1OTg4MzA2ODI4OTg3MzcwNDE5MjkyMjE0MTQ0ODk4MTM0MDQ5MTI1NDc0MTE0ODk1MTIxNjIyMTQ5ODU5Nzk1MzE4MDYwMTgxNTM4OTUyNDA2OTcxODQwNjE4MjMyMTcxNDU2MDE0NzUyNjkyODg4MjE2NzQ3NTIxNTY1ODY1OTM1NDQ5MjIzNTExNjExMzI1NTE0NDU4MzAxNjk3MzA0OTI4NDMwMDI5ODAxNDM2NjE1Nzc0NzY0NDQwNjQwMTUyMjY5NTY0NjU4Njk3MjU4OTI2NSJdXX0sIm5vbmNlIjoiMTE5MTg2NjQyNTc4MzYxODg5MDk2OTI0In0=" - } - } - ] - } - } - }, - "source_id": "credential", - "thread_id": "57b3f85d-7673-4e6f-bb09-cc27cf2653c0" - } - } -}"#; - // Alice sends credential request to Faber pub const ARIES_CREDENTIAL_REQUEST: &str = r#" { @@ -296,45 +144,6 @@ pub const ARIES_CREDENTIAL_REQUEST: &str = r#" } }"#; -// CredentialIssuer (Faber) has received credential request -pub const CREDENTIAL_ISSUER_SM_REQUEST_RECEIVED: &str = r#" -{ - "version": "2.0", - "data": { - "issuer_sm": { - "state": { - "RequestReceived": { - "offer": "{\"schema_id\":\"V4SGRU86Z58d6TV7PBUe6f:2:FaberVcx:100.3.17\",\"cred_def_id\":\"V4SGRU86Z58d6TV7PBUe6f:3:CL:67:tag1\",\"key_correctness_proof\":{\"c\":\"8864890146079819966843507607084507466996537773103100015242104458151801570147\",\"xz_cap\":\"132525977827223287463967996367791660611753643437831026132133978673362652175979984960395345604117823033598843515772650970092042194998708471287667293473933602487387266144588495415616944811466910171746306576756067299147133996120610987778643167551472370650860706707489981250143016648216131940192067689731780997063617467994952948231164359737543271754978573745054322784594786983471195078199401393059600773630351754818811358191747218637239772879872305744584957954699837168611724572351569162034269703375267029483298772550673848980515525208224290008214955022684486373727968367957793088244529707858992758609642436424671530098100234617862130269644024376059636705980574590863518613785371479037964460747863\",\"xr_cap\":[[\"sex\",\"10212475160245231594800549040854372303290684256380918488632371037657339014806534940588554673668923103318206077059720668699192425379203595724258495955879134394690009722954264613493392981950745274150217838513814119475945408576517435232754189101061228937866890554581232132629336860287803380692900588369878654635587851842134163193490231540390456176691587533437539107704274260898642873639033821396021194012480721319148344547889691150132409707206905753961160393652003190095671994228552653431323771123633018647062857864156055033625475204728594378221420414003488928212382342146710978259261234513132305926681193895163367723096054346113318440172548126164414333781531199766980234151045186446173389250750\"],[\"degree\",\"181856742283453418473947649595643839643070259478938494473584568220469415234003101214923568013389712089002329509118010979819585255765334238653117932153907089227645576208149810056409291168266428333261231854714933689106351331306816560842818860955234224247467640283042193459845731039690242246162523419565162139381433436933425221922323252396259800586021811741002612505633393087999348487119018329907231223385144479615810153697792611768280290272847820566343166477570068876099556872349244742948210464728021063596957911336342418328102789261913866759741499940584934272174291759174216727901817778811694981504735794125209427214071854022871460401400559698149515333154883748572389272770720317560040712463897\"],[\"last_name\",\"43412293567073349102112370943795877043603069152786756498774529064165953390534477439420146649598887449303789243003836468145767558140820442230844681934242970120831621453186179743368507180242146094550439741968410170425735458888264171137616733641994947577653377853741974230587834360530942891162312983451291321340293070667444620919832965237004751459565905919070707692222664425077116273747444134874197630342511594972069999241272389020918350223302366912905038256257556690157536705279199282258870150174840775692849251725897411119789553994274891144344912923909296194371393823491152500258183683169146109761023058311487837541072813281306532733667848057503262367757201118550813992265344590262271483166483\"],[\"age\",\"68342866294164011784068034274328072729841816986472440793547517786819950247342073166125571525944766248482144768406472174708352715021161116977703459457196044671553753789562125231630111971572509052286957232826269542683452777397984820513540182019167192724561725096668080555141395762042804963579418584382415603000719514263625675792935811436862337394717705375498597054528271873897333941942675196453346888442959900889587403191435514572804420548366858537668848441873376613896206538002439203362350139060639241117668758869032773776414496608576676647828858037464226698788774683675796572388678801019435860058662641742186926934144365911980113050833169032386925668167616423998641959714326637643554532217927\"],[\"master_secret\",\"60004873604256882440837669482238000425353856673067906457286010426208332163294126128885588581808791972508689907661578422431435118216751145826744523616784738075865102182509689742359261285611551353667639554970046746807004041010623030438482125350153333189623356909573083022944384078323987456778721331893146299446171287036574645093201976492734355689314716208371556221655298694091873959850260058791477223797014501706197365726012893398404127387368852187102516338509783310599108227670748363371954452847108084863174642336130498792917539274492599601833452527856405146246277807281210276550206074749962019132159548975746780957482296723374263390806203268708835298174905777660267160424797736483014387864683\"],[\"date\",\"147342231503793263080838729926386421141753550322051739532890945800316221161473286924260404683208240537601816578975559097476493354445488636446930836424043194706973028057749444613329339999021747905965142733819319720303415509712171707205991530386667705361036306405728793380171364485013423072936004131892503597639074001977913486938956159872339293493930826077346851599196644812195740522922688159437382767733592015471466588476394412816911141620857591622245384369269230628756557778440089022685454958567766134358991022569505345783113088026211541418945735300261241258177732630669365390732700156680264076945134895046668269614083784528392573721268626040969213510380794408409764469331606990221467663106853\"],[\"name\",\"46402350507976620716083395016692554430921101058383359733469226024696002199385956892242058194593743795002035073758889854136413733934944023450686279086986421612064353302873838723273555536096043190932778102533172724397365106365130372069705599082758437270547570970026575560880601324063760607196158943453986432582265650934901685192243880872480587151034169399609684173921326513947204955133660721836876002637382143169397664542931310323878715494117950078756837048067536655534046663594626819353508083548306536346359549874088950193043473994946248616534386837224123826810232926853785332232969433958536376898849373637169605881974490269433669642934641299039638695661096758953398028200825360695660802669816\"]]},\"nonce\":\"69188538184527788000509\"}", - "cred_data": "{\"name\":\"alice\",\"last_name\":\"clark\",\"sex\":\"female\",\"date\":\"05-2018\",\"degree\":\"maths\",\"age\":\"25\"}", - "rev_reg_id": "V4SGRU86Z58d6TV7PBUe6f:4:V4SGRU86Z58d6TV7PBUe6f:3:CL:67:tag1:CL_ACCUM:tag1", - "tails_file": "/tmp/tails", - "connection_handle": 12002013, - "request": { - "@id": "cee5849d-7dd9-4747-b31f-9030956420a0", - "requests~attach": [ - { - "mime-type": "application/json", - "@id": "libindy-cred-request-0", - "data": { - "base64": "eyJwcm92ZXJfZGlkIjoiS0M2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jM1NjE2OTM5Mzk0NjgyNjU4NDQxMDgzODg1MTM1NDk1MzQ3NzEwMTkwMTgyMzMxOTQ3NTIyNTQ0Nzg1ODIxNjQ1NDQzNzU4NjEyNTUzMzcwMjk3ODQyNjQ1MjIxNzA3OTc5NTYzMjgwNTU1Nzg4NDkwMjIyMDg2NzE5ODMyMDE3MDQxMDMxMDEzODYzNTE3MTU0Mjk5NjM3NTY5Mjk2ODM4ODQ1Mjk3ODA4NzQ5NTA5MDQ4ODU0MDA3MTM3NDk4NTYyMjcxNzUzMDg2ODAwMTU0ODIzODAxMzE4MTQxNTc1NzgxMTI3Mzc1NDIxNTE2NjIxNDgxMjQ3NTg1MDQxNzc3NDk4ODcwNTgwNTc1OTE0MjAzMzYzMzY2MDU3ODY0MTA1Mzk5NjIzMzg2IiwibV9jYXBzIjp7Im1hc3Rlcl9zZWNyZXQiOiIxODc0MDE4ODkxMzYxNjgwNjU0ODU3NjI4NjA5MjgyNjI1NDM4Njk4NzA4MzkxNzcxNjM3NDA0NzA4MTk5MjA3NDE4MjkxNjk2OTQ5NzExOTEwNTk2ODM3NTI3ODMzOTMyNTQ0NTQyNjU0MDEwNDIwMzIzMTczNjg5NDc0ODgxNjAxNDkxNDAxNDY0MjE4MDg5MTA0OTAwODk4NDM3MTk4NzgxMTYyNTAxOTY3OTYwNTU3NiJ9LCJyX2NhcHMiOnt9fSwibm9uY2UiOiIxMTg3MDMxODY0NTA1MjA0NTkxNjIxNjYwIn0=" - } - } - ], - "~thread": { - "thid": "cb54e2f9-ee17-488c-9bc7-d70c29cff802", - "sender_order": 0, - "received_orders": {} - } - }, - "thread_id": "cb54e2f9-ee17-488c-9bc7-d70c29cff802" - } - }, - "source_id": "alice_degree" - } - } -} -"#; - // Faber sends credential pub const ARIES_CREDENTIAL_RESPONSE: &str = r#"{ "@id": "e5b39a25-36fe-49df-9534-3e486bfb6fb8", @@ -391,30 +200,5 @@ pub const CREDENTIAL_SM_FINISHED: &str = r#" } }"#; -// CredentialIssuer (Faber) has issued credential -pub const CREDENTIAL_ISSUER_SM_FINISHED: &str = r#" -{ - "version": "2.0", - "data": { - "issuer_sm": { - "state": { - "Finished": { - "cred_id": null, - "thread_id": "cb54e2f9-ee17-488c-9bc7-d70c29cff802", - "revocation_info_v1": { - "cred_rev_id": "1", - "rev_reg_id": "V4SGRU86Z58d6TV7PBUe6f:4:V4SGRU86Z58d6TV7PBUe6f:3:CL:67:tag1:CL_ACCUM:tag1", - "tails_file": "/tmp/tails" - }, - "status": "Success" - } - }, - "source_id": "alice_degree", - "thread_id": "0a794e24-c6b4-46bc-93b6-642b6dc98c98" - } - } -} -"#; - pub const OFFERED_ATTRIBUTES: &str = r#"{"sex":"female","date":"05-2018","last_name":"clark","degree":"maths","age":"25","name":"alice"}"#; diff --git a/aries_vcx/src/utils/mockdata/profile/mock_anoncreds.rs b/aries_vcx/src/utils/mockdata/profile/mock_anoncreds.rs index aba2a23f1a..5fb2719225 100644 --- a/aries_vcx/src/utils/mockdata/profile/mock_anoncreds.rs +++ b/aries_vcx/src/utils/mockdata/profile/mock_anoncreds.rs @@ -119,6 +119,7 @@ impl BaseAnonCreds for MockAnoncreds { } } + // todo: change _prover_did argument, see: https://github.com/hyperledger/aries-vcx/issues/950 async fn prover_create_credential_req( &self, _prover_did: &str, diff --git a/aries_vcx/tests/test_creds_proofs.rs b/aries_vcx/tests/test_creds_proofs.rs index c530a0b591..a2d2745563 100644 --- a/aries_vcx/tests/test_creds_proofs.rs +++ b/aries_vcx/tests/test_creds_proofs.rs @@ -1407,7 +1407,7 @@ mod tests { let mut issuer = accept_cred_proposal(&mut institution, &institution_to_consumer, rev_reg_id, Some(tails_dir)).await; decline_offer(&mut consumer, &consumer_to_institution, &mut holder).await; - assert_eq!(IssuerState::OfferSent, issuer.get_state()); + assert_eq!(IssuerState::OfferSet, issuer.get_state()); tokio::time::sleep(Duration::from_millis(1000)).await; issuer_update_with_mediator(&mut issuer, &institution.agency_client, &institution_to_consumer) .await @@ -1704,21 +1704,22 @@ mod tests { alice.credential = Holder::create_from_offer("test", cred_offer).unwrap(); let pw_did = alice.connection.pairwise_info().pw_did.to_string(); - alice + let send_closure = alice + .connection + .send_message_closure(alice.profile.inject_wallet()) + .await + .unwrap(); + let msg_response = alice .credential - .send_request( + .prepare_credential_request( &alice.profile.inject_anoncreds_ledger_read(), &alice.profile.inject_anoncreds(), pw_did, - alice - .connection - .send_message_closure(alice.profile.inject_wallet()) - .await - .unwrap(), ) .await .unwrap(); - assert_eq!(HolderState::RequestSent, alice.credential.get_state()); + send_closure(msg_response).await.unwrap(); + assert_eq!(HolderState::RequestSet, alice.credential.get_state()); } #[cfg(feature = "migration")] @@ -1811,22 +1812,23 @@ mod tests { .await .unwrap(); + let send_closure = alice + .connection + .send_message_closure(alice.profile.inject_wallet()) + .await + .unwrap(); let pw_did = alice.connection.pairwise_info().pw_did.to_string(); - alice + let msg_response = alice .credential - .send_request( + .prepare_credential_request( &alice.profile.inject_anoncreds_ledger_read(), &alice.profile.inject_anoncreds(), pw_did, - alice - .connection - .send_message_closure(alice.profile.inject_wallet()) - .await - .unwrap(), ) .await .unwrap(); - assert_eq!(HolderState::RequestSent, alice.credential.get_state()); + send_closure(msg_response).await.unwrap(); + assert_eq!(HolderState::RequestSet, alice.credential.get_state()); } faber.send_credential().await; diff --git a/aries_vcx/tests/utils/devsetup_alice.rs b/aries_vcx/tests/utils/devsetup_alice.rs index c820e5e1ae..505fcda3a0 100644 --- a/aries_vcx/tests/utils/devsetup_alice.rs +++ b/aries_vcx/tests/utils/devsetup_alice.rs @@ -176,20 +176,24 @@ impl Alice { self.credential = Holder::create_from_offer("degree", cred_offer).unwrap(); assert_eq!(HolderState::OfferReceived, self.credential.get_state()); + let send_closure = self + .connection + .send_message_closure(self.profile.inject_wallet()) + .await + .unwrap(); + let pw_did = self.connection.pairwise_info().pw_did.to_string(); - self.credential - .send_request( + let msg_response = self + .credential + .prepare_credential_request( &self.profile.inject_anoncreds_ledger_read(), &self.profile.inject_anoncreds(), pw_did, - self.connection - .send_message_closure(self.profile.inject_wallet()) - .await - .unwrap(), ) .await .unwrap(); - assert_eq!(HolderState::RequestSent, self.credential.get_state()); + send_closure(msg_response).await.unwrap(); + assert_eq!(HolderState::RequestSet, self.credential.get_state()); } pub async fn accept_credential(&mut self) { diff --git a/aries_vcx/tests/utils/devsetup_faber.rs b/aries_vcx/tests/utils/devsetup_faber.rs index 901dd886cc..b0e52dfd09 100644 --- a/aries_vcx/tests/utils/devsetup_faber.rs +++ b/aries_vcx/tests/utils/devsetup_faber.rs @@ -291,19 +291,17 @@ impl Faber { .build_credential_offer_msg(&self.profile.inject_anoncreds(), offer_info, None) .await .unwrap(); - self.issuer_credential - .send_credential_offer( - self.connection - .send_message_closure(self.profile.inject_wallet()) - .await - .unwrap(), - ) + let send_message = self + .connection + .send_message_closure(self.profile.inject_wallet()) .await .unwrap(); + let credential_offer = self.issuer_credential.get_credential_offer_msg().unwrap(); + send_message(credential_offer).await.unwrap(); issuer_update_with_mediator(&mut self.issuer_credential, &self.agency_client, &self.connection) .await .unwrap(); - assert_eq!(IssuerState::OfferSent, self.issuer_credential.get_state()); + assert_eq!(IssuerState::OfferSet, self.issuer_credential.get_state()); } pub async fn send_credential(&mut self) { @@ -313,19 +311,20 @@ impl Faber { assert_eq!(IssuerState::RequestReceived, self.issuer_credential.get_state()); self.issuer_credential - .send_credential( - &self.profile.inject_anoncreds(), - self.connection - .send_message_closure(self.profile.inject_wallet()) - .await - .unwrap(), - ) + .build_credential(&self.profile.inject_anoncreds()) + .await + .unwrap(); + let send_closure = self + .connection + .send_message_closure(self.profile.inject_wallet()) .await .unwrap(); + let msg_issue_credential = self.issuer_credential.get_msg_issue_credential().unwrap(); + send_closure(msg_issue_credential.into()).await.unwrap(); issuer_update_with_mediator(&mut self.issuer_credential, &self.agency_client, &self.connection) .await .unwrap(); - assert_eq!(IssuerState::CredentialSent, self.issuer_credential.get_state()); + assert_eq!(IssuerState::CredentialSet, self.issuer_credential.get_state()); } pub async fn request_presentation(&mut self) { diff --git a/aries_vcx/tests/utils/devsetup_util.rs b/aries_vcx/tests/utils/devsetup_util.rs index 69bbb11255..6a99f8fd42 100644 --- a/aries_vcx/tests/utils/devsetup_util.rs +++ b/aries_vcx/tests/utils/devsetup_util.rs @@ -161,13 +161,17 @@ pub async fn holder_update_with_mediator( if sm.is_terminal_state() { return Ok(sm.get_state()); } - let send_message = connection.send_message_closure(Arc::clone(wallet)).await?; - let messages = connection.get_messages(agency_client).await?; if let Some((uid, msg)) = mediated_holder::holder_find_message_to_handle(sm, messages) { - sm.process_aries_msg(ledger, anoncreds, msg.into(), Some(send_message)) - .await?; + sm.process_aries_msg(ledger, anoncreds, msg.clone()).await?; connection.update_message_status(&uid, agency_client).await?; + match sm.get_final_message()? { + None => {} + Some(msg_response) => { + let send_message = connection.send_message_closure(Arc::clone(wallet)).await?; + send_message(msg_response).await?; + } + } } Ok(sm.get_state()) } diff --git a/aries_vcx/tests/utils/scenarios.rs b/aries_vcx/tests/utils/scenarios.rs index d42eda39f5..ae9ef44b69 100644 --- a/aries_vcx/tests/utils/scenarios.rs +++ b/aries_vcx/tests/utils/scenarios.rs @@ -201,15 +201,13 @@ pub mod test_utils { .build_credential_offer_msg(&faber.profile.inject_anoncreds(), offer_info, comment.map(String::from)) .await .unwrap(); - issuer - .send_credential_offer( - connection - .send_message_closure(faber.profile.inject_wallet()) - .await - .unwrap(), - ) + let send_closure = connection + .send_message_closure(faber.profile.inject_wallet()) .await .unwrap(); + let credential_offer = issuer.get_credential_offer_msg().unwrap(); + send_closure(credential_offer).await.unwrap(); + info!("create_and_send_nonrevocable_cred_offer :: credential offer was sent"); tokio::time::sleep(Duration::from_millis(1000)).await; issuer @@ -235,15 +233,12 @@ pub mod test_utils { .build_credential_offer_msg(&faber.profile.inject_anoncreds(), offer_info, comment.map(String::from)) .await .unwrap(); - issuer - .send_credential_offer( - connection - .send_message_closure(faber.profile.inject_wallet()) - .await - .unwrap(), - ) + let send_closure = connection + .send_message_closure(faber.profile.inject_wallet()) .await .unwrap(); + let credential_offer = issuer.get_credential_offer_msg().unwrap(); + send_closure(credential_offer).await.unwrap(); info!("create_and_send_cred_offer :: credential offer was sent"); tokio::time::sleep(Duration::from_millis(1000)).await; issuer @@ -276,18 +271,19 @@ pub mod test_utils { assert_eq!(HolderState::OfferReceived, holder.get_state()); info!("send_cred_req :: sending credential request"); let my_pw_did = connection.pairwise_info().pw_did.to_string(); - holder - .send_request( + let send_closure = connection + .send_message_closure(alice.profile.inject_wallet()) + .await + .unwrap(); + let msg_response = holder + .prepare_credential_request( &alice.profile.inject_anoncreds_ledger_read(), &alice.profile.inject_anoncreds(), my_pw_did, - connection - .send_message_closure(alice.profile.inject_wallet()) - .await - .unwrap(), ) .await .unwrap(); + send_closure(msg_response).await.unwrap(); tokio::time::sleep(Duration::from_millis(1000)).await; holder } @@ -300,7 +296,6 @@ pub mod test_utils { comment: &str, ) -> Holder { let (address1, address2, city, state, zip) = attr_names(); - let id = "test".to_owned(); let mut attrs = Vec::new(); let mut attr = CredentialAttr::new(address1, "123 Main Str".to_owned()); @@ -329,20 +324,14 @@ pub mod test_utils { let decorators = ProposeCredentialDecorators::default(); + let id = "test".to_owned(); let proposal = ProposeCredential::with_decorators(id, content, decorators); - let mut holder = Holder::create("TEST_CREDENTIAL").unwrap(); - assert_eq!(HolderState::Initial, holder.get_state()); - holder - .send_proposal( - proposal, - connection - .send_message_closure(alice.profile.inject_wallet()) - .await - .unwrap(), - ) + let mut holder = Holder::create_with_proposal("TEST_CREDENTIAL", proposal.clone()).unwrap(); + assert_eq!(HolderState::ProposalSet, holder.get_state()); + connection + .send_a2a_message(&alice.profile.inject_wallet(), &proposal.into()) .await .unwrap(); - assert_eq!(HolderState::ProposalSent, holder.get_state()); tokio::time::sleep(Duration::from_millis(1000)).await; holder } @@ -398,17 +387,12 @@ pub mod test_utils { let decorators = ProposeCredentialDecorators::default(); let proposal = ProposeCredential::with_decorators(id, content, decorators); - holder - .send_proposal( - proposal, - connection - .send_message_closure(alice.profile.inject_wallet()) - .await - .unwrap(), - ) + holder.set_proposal(proposal.clone()).unwrap(); + assert_eq!(HolderState::ProposalSet, holder.get_state()); + connection + .send_a2a_message(&alice.profile.inject_wallet(), &proposal.into()) .await .unwrap(); - assert_eq!(HolderState::ProposalSent, holder.get_state()); tokio::time::sleep(Duration::from_millis(1000)).await; } @@ -429,6 +413,7 @@ pub mod test_utils { .await .unwrap(); let mut issuer = Issuer::create_from_proposal("TEST_CREDENTIAL", proposal).unwrap(); + assert_eq!(proposal.id, issuer.get_thread_id().unwrap()); assert_eq!(IssuerState::ProposalReceived, issuer.get_state()); assert_eq!(proposal.clone(), issuer.get_proposal().unwrap()); let offer_info = OfferInfo { @@ -441,16 +426,14 @@ pub mod test_utils { .build_credential_offer_msg(&faber.profile.inject_anoncreds(), offer_info, Some("comment".into())) .await .unwrap(); - issuer - .send_credential_offer( - connection - .send_message_closure(faber.profile.inject_wallet()) - .await - .unwrap(), - ) + let send_closure = connection + .send_message_closure(faber.profile.inject_wallet()) .await .unwrap(); - assert_eq!(IssuerState::OfferSent, issuer.get_state()); + let credential_offer = issuer.get_credential_offer_msg().unwrap(); + send_closure(credential_offer).await.unwrap(); + + assert_eq!(IssuerState::OfferSet, issuer.get_state()); tokio::time::sleep(Duration::from_millis(1000)).await; issuer } @@ -462,7 +445,7 @@ pub mod test_utils { rev_reg_id: Option, tails_dir: Option, ) { - assert_eq!(IssuerState::OfferSent, issuer.get_state()); + assert_eq!(IssuerState::OfferSet, issuer.get_state()); issuer_update_with_mediator(issuer, &faber.agency_client, connection) .await .unwrap(); @@ -478,16 +461,14 @@ pub mod test_utils { .build_credential_offer_msg(&faber.profile.inject_anoncreds(), offer_info, Some("comment".into())) .await .unwrap(); - issuer - .send_credential_offer( - connection - .send_message_closure(faber.profile.inject_wallet()) - .await - .unwrap(), - ) + let send_closure = connection + .send_message_closure(faber.profile.inject_wallet()) .await .unwrap(); - assert_eq!(IssuerState::OfferSent, issuer.get_state()); + let credential_offer = issuer.get_credential_offer_msg().unwrap(); + send_closure(credential_offer).await.unwrap(); + + assert_eq!(IssuerState::OfferSet, issuer.get_state()); tokio::time::sleep(Duration::from_millis(1000)).await; } @@ -505,19 +486,20 @@ pub mod test_utils { assert_eq!(HolderState::OfferReceived, holder.get_state()); assert!(holder.get_offer().is_ok()); let my_pw_did = connection.pairwise_info().pw_did.to_string(); - holder - .send_request( + let send_closure = connection + .send_message_closure(alice.profile.inject_wallet()) + .await + .unwrap(); + let msg_response = holder + .prepare_credential_request( &alice.profile.inject_anoncreds_ledger_read(), &alice.profile.inject_anoncreds(), my_pw_did, - connection - .send_message_closure(alice.profile.inject_wallet()) - .await - .unwrap(), ) .await .unwrap(); - assert_eq!(HolderState::RequestSent, holder.get_state()); + send_closure(msg_response).await.unwrap(); + assert_eq!(HolderState::RequestSet, holder.get_state()); } pub async fn decline_offer(alice: &mut Alice, connection: &MediatedConnection, holder: &mut Holder) { @@ -532,16 +514,12 @@ pub mod test_utils { .await .unwrap(); assert_eq!(HolderState::OfferReceived, holder.get_state()); - holder - .decline_offer( - Some("Have a nice day"), - connection - .send_message_closure(alice.profile.inject_wallet()) - .await - .unwrap(), - ) + let send_message = connection + .send_message_closure(alice.profile.inject_wallet()) .await .unwrap(); + let problem_report = holder.decline_offer(Some("Have a nice day")).unwrap(); + send_message(problem_report.into()).await.unwrap(); assert_eq!(HolderState::Failed, holder.get_state()); } @@ -556,7 +534,7 @@ pub mod test_utils { ) { info!("send_credential >>> getting offers"); let thread_id = issuer_credential.get_thread_id().unwrap(); - assert_eq!(IssuerState::OfferSent, issuer_credential.get_state()); + assert_eq!(IssuerState::OfferSet, issuer_credential.get_state()); assert!(!issuer_credential.is_revokable()); issuer_update_with_mediator(issuer_credential, &faber.agency_client, issuer_to_consumer) @@ -568,15 +546,15 @@ pub mod test_utils { info!("send_credential >>> sending credential"); issuer_credential - .send_credential( - &faber.profile.inject_anoncreds(), - issuer_to_consumer - .send_message_closure(faber.profile.inject_wallet()) - .await - .unwrap(), - ) + .build_credential(&faber.profile.inject_anoncreds()) + .await + .unwrap(); + let send_closure = issuer_to_consumer + .send_message_closure(faber.profile.inject_wallet()) .await .unwrap(); + let msg_issue_credential = issuer_credential.get_msg_issue_credential().unwrap(); + send_closure(msg_issue_credential.into()).await.unwrap(); tokio::time::sleep(Duration::from_millis(1000)).await; assert_eq!(thread_id, issuer_credential.get_thread_id().unwrap()); diff --git a/libvcx_core/src/api_vcx/api_handle/credential.rs b/libvcx_core/src/api_vcx/api_handle/credential.rs index bcd49f9cf0..13e320e69e 100644 --- a/libvcx_core/src/api_vcx/api_handle/credential.rs +++ b/libvcx_core/src/api_vcx/api_handle/credential.rs @@ -6,6 +6,7 @@ use serde_json; use aries_vcx::agency_client::testing::mocking::AgencyMockDecrypted; use aries_vcx::handlers::issuance::holder::Holder; use aries_vcx::handlers::issuance::mediated_holder::holder_find_message_to_handle; +use aries_vcx::protocols::issuance::holder::state_machine::HolderState; use aries_vcx::utils::constants::GET_MESSAGES_DECRYPTED_RESPONSE; use aries_vcx::{global::settings::indy_mocks_enabled, utils::mockdata::mockdata_credex::ARIES_CREDENTIAL_OFFER}; @@ -117,41 +118,49 @@ pub async fn credential_create_with_msgid( pub async fn update_state(credential_handle: u32, message: Option<&str>, connection_handle: u32) -> LibvcxResult { let mut credential = HANDLE_MAP.get_cloned(credential_handle)?; - let profile = get_main_profile(); trace!("credential::update_state >>> "); if credential.is_terminal_state() { return Ok(credential.get_state().into()); } - let send_message = mediated_connection::send_message_closure(connection_handle).await?; - - if let Some(message) = message { + let (mediator_uid, aries_msg) = if let Some(message) = message { let message: AriesMessage = serde_json::from_str(message).map_err(|err| { LibvcxError::from_msg( LibvcxErrorKind::InvalidOption, format!("Cannot update state: Message deserialization failed: {:?}", err), ) })?; - credential - .process_aries_msg( - &get_main_anoncreds_ledger_read()?, - &get_main_anoncreds()?, - message.into(), - Some(send_message), - ) - .await?; + (None, Some(message)) } else { let messages = mediated_connection::get_messages(connection_handle).await?; - if let Some((uid, msg)) = holder_find_message_to_handle(&credential, messages) { + match holder_find_message_to_handle(&credential, messages) { + None => (None, None), + Some((uid, msg)) => (Some(uid), Some(msg)), + } + }; + match aries_msg { + None => { + trace!("credential::update_state >>> no suitable messages found to progress the protocol"); + } + Some(aries_msg) => { credential .process_aries_msg( &get_main_anoncreds_ledger_read()?, &get_main_anoncreds()?, - msg.into(), - Some(send_message), + aries_msg.clone(), ) .await?; - mediated_connection::update_message_status(connection_handle, &uid).await?; + if let Some(uid) = mediator_uid { + trace!("credential::update_state >>> updating messages status in mediator"); + mediated_connection::update_message_status(connection_handle, &uid).await?; + } + match credential.get_final_message()? { + None => {} + Some(msg_response) => { + let send_message = mediated_connection::send_message_closure(connection_handle).await?; + send_message(msg_response).await?; + } + } } } let state = credential.get_state().into(); @@ -231,14 +240,10 @@ pub async fn send_credential_request(handle: u32, connection_handle: u32) -> Lib let mut credential = HANDLE_MAP.get_cloned(handle)?; let my_pw_did = mediated_connection::get_pw_did(connection_handle)?; let send_message = mediated_connection::send_message_closure(connection_handle).await?; - credential - .send_request( - &get_main_anoncreds_ledger_read()?, - &get_main_anoncreds()?, - my_pw_did, - send_message, - ) + let msg_response = credential + .prepare_credential_request(&get_main_anoncreds_ledger_read()?, &get_main_anoncreds()?, my_pw_did) .await?; + send_message(msg_response).await?; HANDLE_MAP.insert(handle, credential) } @@ -358,7 +363,8 @@ pub fn get_thread_id(handle: u32) -> LibvcxResult { pub async fn decline_offer(handle: u32, connection_handle: u32, comment: Option<&str>) -> LibvcxResult<()> { let mut credential = HANDLE_MAP.get_cloned(handle)?; let send_message = mediated_connection::send_message_closure(connection_handle).await?; - credential.decline_offer(comment, send_message).await?; + let problem_report = credential.decline_offer(comment)?; + send_message(problem_report.into()).await?; HANDLE_MAP.insert(handle, credential) } @@ -473,7 +479,7 @@ pub mod tests { info!("full_credential_test:: going to send_credential_request"); send_credential_request(handle_cred, handle_conn).await.unwrap(); - assert_eq!(HolderState::RequestSent as u32, get_state(handle_cred).unwrap()); + assert_eq!(HolderState::RequestSet as u32, get_state(handle_cred).unwrap()); AgencyMockDecrypted::set_next_decrypted_response(GET_MESSAGES_DECRYPTED_RESPONSE); AgencyMockDecrypted::set_next_decrypted_message(ARIES_CREDENTIAL_RESPONSE); diff --git a/libvcx_core/src/api_vcx/api_handle/issuer_credential.rs b/libvcx_core/src/api_vcx/api_handle/issuer_credential.rs index cd8a939607..172e0916e7 100644 --- a/libvcx_core/src/api_vcx/api_handle/issuer_credential.rs +++ b/libvcx_core/src/api_vcx/api_handle/issuer_credential.rs @@ -1,10 +1,12 @@ use aries_vcx::handlers::util::OfferInfo; use aries_vcx::messages::AriesMessage; use aries_vcx::protocols::SendClosure; +use libc::send; use serde_json; use aries_vcx::handlers::issuance::issuer::Issuer; use aries_vcx::handlers::issuance::mediated_issuer::issuer_find_message_to_handle; +use aries_vcx::protocols::issuance::issuer::state_machine::IssuerState; use crate::api_vcx::api_global::profile::{get_main_anoncreds, get_main_wallet}; use crate::api_vcx::api_handle::connection; @@ -183,20 +185,15 @@ pub async fn build_credential_offer_msg_v2( ISSUER_CREDENTIAL_MAP.insert(credential_handle, credential) } -pub fn mark_credential_offer_msg_sent(handle: u32) -> LibvcxResult<()> { - let mut credential = ISSUER_CREDENTIAL_MAP.get_cloned(handle)?; - credential.mark_credential_offer_msg_sent()?; - ISSUER_CREDENTIAL_MAP.insert(handle, credential) -} - pub fn get_credential_offer_msg(handle: u32) -> LibvcxResult { ISSUER_CREDENTIAL_MAP.get(handle, |credential| Ok(credential.get_credential_offer_msg()?)) } pub async fn send_credential_offer_v2(credential_handle: u32, connection_handle: u32) -> LibvcxResult<()> { let mut credential = ISSUER_CREDENTIAL_MAP.get_cloned(credential_handle)?; - let send_message = mediated_connection::send_message_closure(connection_handle).await?; - credential.send_credential_offer(send_message).await?; + let send_closure = mediated_connection::send_message_closure(connection_handle).await?; + let credential_offer = credential.get_credential_offer_msg()?; + send_closure(credential_offer).await?; ISSUER_CREDENTIAL_MAP.insert(credential_handle, credential)?; Ok(()) } @@ -209,20 +206,27 @@ pub async fn send_credential_offer_nonmediated(credential_handle: u32, connectio let send_message: SendClosure = Box::new(|msg: AriesMessage| Box::pin(async move { con.send_message(&wallet, &msg, &HttpClient).await })); + let credential_offer = credential.get_credential_offer_msg()?; + send_message(credential_offer).await?; - credential.send_credential_offer(send_message).await?; ISSUER_CREDENTIAL_MAP.insert(credential_handle, credential)?; Ok(()) } pub async fn send_credential(handle: u32, connection_handle: u32) -> LibvcxResult { let mut credential = ISSUER_CREDENTIAL_MAP.get_cloned(handle)?; - credential - .send_credential( - &get_main_anoncreds()?, - mediated_connection::send_message_closure(connection_handle).await?, - ) - .await?; + credential.build_credential(&get_main_anoncreds()?).await?; + let send_closure = mediated_connection::send_message_closure(connection_handle).await?; + match credential.get_state() { + IssuerState::Failed => { + let problem_report = credential.get_problem_report()?; + send_closure(problem_report.into()).await?; + } + _ => { + let msg_issue_credential = credential.get_msg_issue_credential()?; + send_closure(msg_issue_credential.into()).await?; + } + } let state: u32 = credential.get_state().into(); ISSUER_CREDENTIAL_MAP.insert(handle, credential)?; Ok(state) @@ -232,11 +236,19 @@ pub async fn send_credential_nonmediated(handle: u32, connection_handle: u32) -> let mut credential = ISSUER_CREDENTIAL_MAP.get_cloned(handle)?; let con = connection::get_cloned_generic_connection(&connection_handle)?; let wallet = get_main_wallet()?; - - let send_message: SendClosure = + let send_closure: SendClosure = Box::new(|msg: AriesMessage| Box::pin(async move { con.send_message(&wallet, &msg, &HttpClient).await })); - - credential.send_credential(&get_main_anoncreds()?, send_message).await?; + credential.build_credential(&get_main_anoncreds()?).await?; + match credential.get_state() { + IssuerState::Failed => { + let problem_report = credential.get_problem_report()?; + send_closure(problem_report.into()).await?; + } + _ => { + let msg_issue_credential = credential.get_msg_issue_credential()?; + send_closure(msg_issue_credential.into()).await?; + } + } let state: u32 = credential.get_state().into(); ISSUER_CREDENTIAL_MAP.insert(handle, credential)?; Ok(state) @@ -280,7 +292,6 @@ pub mod tests { #[cfg(test)] use crate::api_vcx::api_handle::mediated_connection::test_utils::build_test_connection_inviter_requested; use crate::aries_vcx::protocols::issuance::issuer::state_machine::IssuerState; - use crate::errors::error; use aries_vcx::utils::constants::V3_OBJECT_SERIALIZE_VERSION; use aries_vcx::utils::devsetup::SetupMocks; use aries_vcx::utils::mockdata::mockdata_credex::ARIES_CREDENTIAL_REQUEST; @@ -336,7 +347,7 @@ pub mod tests { send_credential_offer_v2(credential_handle, connection_handle) .await .unwrap(); - assert_eq!(get_state(credential_handle).unwrap(), u32::from(IssuerState::OfferSent)); + assert_eq!(get_state(credential_handle).unwrap(), u32::from(IssuerState::OfferSet)); } #[tokio::test] @@ -371,7 +382,7 @@ pub mod tests { send_credential_offer_v2(credential_handle, connection_handle) .await .unwrap(); - assert_eq!(get_state(credential_handle).unwrap(), u32::from(IssuerState::OfferSent)); + assert_eq!(get_state(credential_handle).unwrap(), u32::from(IssuerState::OfferSet)); update_state(credential_handle, Some(ARIES_CREDENTIAL_REQUEST), connection_handle) .await @@ -393,12 +404,12 @@ pub mod tests { .await .unwrap(); send_credential_offer_v2(handle_cred, handle_conn).await.unwrap(); - assert_eq!(get_state(handle_cred).unwrap(), u32::from(IssuerState::OfferSent)); + assert_eq!(get_state(handle_cred).unwrap(), u32::from(IssuerState::OfferSet)); // try to update state with nonsense message let result = update_state(handle_cred, Some(ARIES_CONNECTION_ACK), handle_conn).await; assert!(result.is_ok()); // todo: maybe we should rather return error if update_state doesn't progress state - assert_eq!(get_state(handle_cred).unwrap(), u32::from(IssuerState::OfferSent)); + assert_eq!(get_state(handle_cred).unwrap(), u32::from(IssuerState::OfferSet)); } #[tokio::test] diff --git a/wrappers/node/src/api/common.ts b/wrappers/node/src/api/common.ts index a746ef92ac..81c8742502 100644 --- a/wrappers/node/src/api/common.ts +++ b/wrappers/node/src/api/common.ts @@ -145,7 +145,6 @@ export enum IssuerStateType { Initial = 0, ProposalReceived = 1, OfferSet = 2, - OfferSent = 3, RequestReceived = 4, CredentialSent = 5, Finished = 6, diff --git a/wrappers/node/src/api/issuer-credential.ts b/wrappers/node/src/api/issuer-credential.ts index d94d617ac0..6c5cabcf44 100644 --- a/wrappers/node/src/api/issuer-credential.ts +++ b/wrappers/node/src/api/issuer-credential.ts @@ -99,14 +99,6 @@ export class IssuerCredential extends VcxBaseWithState { - try { - return ffi.issuerCredentialMarkOfferMsgSent(this.handle); - } catch (err: any) { - throw new VCXInternalError(err); - } - } - public async buildCredentialOfferMsgV2({ credDef, attr, diff --git a/wrappers/node/test/suite1/ariesvcx-issuer-credential.test.ts b/wrappers/node/test/suite1/ariesvcx-issuer-credential.test.ts index 5ebbb61f13..3630100142 100644 --- a/wrappers/node/test/suite1/ariesvcx-issuer-credential.test.ts +++ b/wrappers/node/test/suite1/ariesvcx-issuer-credential.test.ts @@ -81,7 +81,6 @@ describe('IssuerCredential:', () => { assert.equal(await issuerCredential.getState(), IssuerStateType.OfferSet); const connection = await createConnectionInviterRequested(); await issuerCredential.sendOfferV2(connection); - assert.equal(await issuerCredential.getState(), IssuerStateType.OfferSent); }); it('build offer and mark as sent', async () => { @@ -96,9 +95,6 @@ describe('IssuerCredential:', () => { offer.credential_preview['@type'], 'https://didcomm.org/issue-credential/1.0/credential-preview', ); - - await issuerCredential.markCredentialOfferMsgSent(); - assert.equal(await issuerCredential.getState(), IssuerStateType.OfferSent); }); it('throws: not initialized', async () => { diff --git a/wrappers/vcx-napi-rs/index.d.ts b/wrappers/vcx-napi-rs/index.d.ts index ab6cdc8d90..97496b9c71 100644 --- a/wrappers/vcx-napi-rs/index.d.ts +++ b/wrappers/vcx-napi-rs/index.d.ts @@ -85,7 +85,6 @@ export function issuerCredentialSendCredential(handleCredential: number, handleC export function issuerCredentialSendCredentialNonmediated(handleCredential: number, handleConnection: number): Promise export function issuerCredentialSendOfferV2(handleCredential: number, handleConnection: number): Promise export function issuerCredentialSendOfferNonmediated(handleCredential: number, handleConnection: number): Promise -export function issuerCredentialMarkOfferMsgSent(handleCredential: number): void export function issuerCredentialBuildOfferMsgV2(credentialHandle: number, credDefHandle: number, revRegHandle: number, credentialJson: string, comment?: string | undefined | null): Promise export function issuerCredentialGetOfferMsg(credentialHandle: number): string export function issuerCredentialRelease(credentialHandle: number): void diff --git a/wrappers/vcx-napi-rs/index.js b/wrappers/vcx-napi-rs/index.js index 9f50de75ce..3f9ec9a979 100644 --- a/wrappers/vcx-napi-rs/index.js +++ b/wrappers/vcx-napi-rs/index.js @@ -252,7 +252,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, issuerCredentialGetRevocationId, issuerCredentialSendCredential, issuerCredentialSendCredentialNonmediated, issuerCredentialSendOfferV2, issuerCredentialSendOfferNonmediated, issuerCredentialMarkOfferMsgSent, issuerCredentialBuildOfferMsgV2, issuerCredentialGetOfferMsg, issuerCredentialRelease, issuerCredentialGetThreadId, getLedgerAuthorAgreement, setActiveTxnAuthorAgreementMeta, createService, createServiceV2, getServiceFromLedger, getAttrFromLedger, clearAttrFromLedger, writeEndorserDid, 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, createAndStoreDid, 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, issuerCredentialGetRevocationId, issuerCredentialSendCredential, issuerCredentialSendCredentialNonmediated, issuerCredentialSendOfferV2, issuerCredentialSendOfferNonmediated, issuerCredentialBuildOfferMsgV2, issuerCredentialGetOfferMsg, issuerCredentialRelease, issuerCredentialGetThreadId, getLedgerAuthorAgreement, setActiveTxnAuthorAgreementMeta, createService, createServiceV2, getServiceFromLedger, getAttrFromLedger, clearAttrFromLedger, writeEndorserDid, 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, createAndStoreDid, walletImport, walletExport, getVerkeyFromWallet, rotateVerkey, rotateVerkeyStart, rotateVerkeyApply } = nativeBinding module.exports.updateWebhookUrl = updateWebhookUrl module.exports.createAgencyClientForMainWallet = createAgencyClientForMainWallet @@ -336,7 +336,6 @@ module.exports.issuerCredentialSendCredential = issuerCredentialSendCredential module.exports.issuerCredentialSendCredentialNonmediated = issuerCredentialSendCredentialNonmediated module.exports.issuerCredentialSendOfferV2 = issuerCredentialSendOfferV2 module.exports.issuerCredentialSendOfferNonmediated = issuerCredentialSendOfferNonmediated -module.exports.issuerCredentialMarkOfferMsgSent = issuerCredentialMarkOfferMsgSent module.exports.issuerCredentialBuildOfferMsgV2 = issuerCredentialBuildOfferMsgV2 module.exports.issuerCredentialGetOfferMsg = issuerCredentialGetOfferMsg module.exports.issuerCredentialRelease = issuerCredentialRelease diff --git a/wrappers/vcx-napi-rs/src/api/issuer_credential.rs b/wrappers/vcx-napi-rs/src/api/issuer_credential.rs index 4e3fe57b7a..a0c8783635 100644 --- a/wrappers/vcx-napi-rs/src/api/issuer_credential.rs +++ b/wrappers/vcx-napi-rs/src/api/issuer_credential.rs @@ -108,11 +108,6 @@ async fn issuer_credential_send_offer_nonmediated(handle_credential: u32, handle Ok(()) } -#[napi] -fn issuer_credential_mark_offer_msg_sent(handle_credential: u32) -> napi::Result<()> { - issuer_credential::mark_credential_offer_msg_sent(handle_credential).map_err(to_napi_err) -} - #[napi] async fn issuer_credential_build_offer_msg_v2( credential_handle: u32,