From 6449e6743356dd4cd998aac19064569311602838 Mon Sep 17 00:00:00 2001 From: Miroslav Kovar Date: Mon, 30 Jan 2023 22:12:36 +0100 Subject: [PATCH] Process problem report Signed-off-by: Miroslav Kovar --- .../src/handlers/connection/connection.rs | 19 ++++++++++++++++++- libvcx/src/api_vcx/api_handle/connection.rs | 10 ++++++++++ wrappers/node/src/api/connection.ts | 8 ++++++++ wrappers/vcx-napi-rs/index.d.ts | 1 + wrappers/vcx-napi-rs/index.js | 3 ++- wrappers/vcx-napi-rs/src/api/connection.rs | 6 ++++++ 6 files changed, 45 insertions(+), 2 deletions(-) diff --git a/aries_vcx/src/handlers/connection/connection.rs b/aries_vcx/src/handlers/connection/connection.rs index c043768224..5a2adc4713 100644 --- a/aries_vcx/src/handlers/connection/connection.rs +++ b/aries_vcx/src/handlers/connection/connection.rs @@ -3,6 +3,7 @@ use std::sync::Arc; use messages::a2a::A2AMessage; use messages::protocols::basic_message::message::BasicMessage; +use messages::protocols::connection::problem_report::ProblemReport; use messages::protocols::connection::response::SignedResponse; use serde::{Deserialize, Serialize}; @@ -113,7 +114,7 @@ impl Connection { pub fn bootstrap_did_doc(&self) -> Option { match &self.connection_sm { - SmConnection::Inviter(sm_inviter) => None, + SmConnection::Inviter(_sm_inviter) => None, SmConnection::Invitee(sm_invitee) => sm_invitee.bootstrap_did_doc(), } } @@ -215,6 +216,22 @@ impl Connection { Ok(Self { connection_sm }) } + pub fn process_problem_report(self, problem_report: ProblemReport) -> VcxResult { + trace!( + "Connection::process_problem_report >>> problem_report: {:?}", + problem_report + ); + let connection_sm = match &self.connection_sm { + SmConnection::Inviter(sm_inviter) => { + SmConnection::Inviter(sm_inviter.clone().handle_problem_report(problem_report)?) + } + SmConnection::Invitee(sm_invitee) => { + SmConnection::Invitee(sm_invitee.clone().handle_problem_report(problem_report)?) + } + }; + Ok(Self { connection_sm }) + } + // ----------------------------- MSG SENDING ------------------------------------ pub async fn send_response( self, diff --git a/libvcx/src/api_vcx/api_handle/connection.rs b/libvcx/src/api_vcx/api_handle/connection.rs index beb99f200b..eaf5171145 100644 --- a/libvcx/src/api_vcx/api_handle/connection.rs +++ b/libvcx/src/api_vcx/api_handle/connection.rs @@ -148,6 +148,16 @@ pub async fn process_ack(handle: u32, message: &str) -> LibvcxResult<()> { ) } +pub fn process_problem_report(handle: u32, problem_report: &str) -> LibvcxResult<()> { + trace!("process_problem_report >>>"); + CONNECTION_MAP.insert( + handle, + CONNECTION_MAP + .get_cloned(handle)? + .process_problem_report(deserialize(problem_report)?)?, + ) +} + pub async fn send_response(handle: u32) -> LibvcxResult<()> { trace!("send_response >>>"); CONNECTION_MAP.insert( diff --git a/wrappers/node/src/api/connection.ts b/wrappers/node/src/api/connection.ts index 7f49dda628..53f4841e86 100644 --- a/wrappers/node/src/api/connection.ts +++ b/wrappers/node/src/api/connection.ts @@ -99,6 +99,14 @@ export class NonmediatedConnection extends VcxBaseWithState { try { await ffiNapi.connectionSendResponse(this.handle); diff --git a/wrappers/vcx-napi-rs/index.d.ts b/wrappers/vcx-napi-rs/index.d.ts index 05358de289..fbd5fcdac0 100644 --- a/wrappers/vcx-napi-rs/index.d.ts +++ b/wrappers/vcx-napi-rs/index.d.ts @@ -20,6 +20,7 @@ export function connectionProcessInvite(handle: number, invitation: string): voi export function connectionProcessRequest(handle: number, request: string, serviceEndpoint: string, routingKeys: Array): Promise export function connectionProcessResponse(handle: number, response: string): Promise export function connectionProcessAck(handle: number, message: string): Promise +export function connectionProcessProblemReport(handle: number, problemReport: string): void export function connectionSendResponse(handle: number): Promise export function connectionSendRequest(handle: number, serviceEndpoint: string, routingKeys: Array): Promise export function connectionSendAck(handle: number): Promise diff --git a/wrappers/vcx-napi-rs/index.js b/wrappers/vcx-napi-rs/index.js index 9ef281f6c1..0a4f7ecd1d 100644 --- a/wrappers/vcx-napi-rs/index.js +++ b/wrappers/vcx-napi-rs/index.js @@ -246,7 +246,7 @@ if (!nativeBinding) { throw new Error(`Failed to load native binding`) } -const { updateWebhookUrl, createAgencyClientForMainWallet, provisionCloudAgent, messagesUpdateStatus, generatePublicInvitation, connectionCreateInviter, connectionCreateInvitee, connectionGetThreadId, connectionGetPairwiseInfo, connectionGetRemoteDid, connectionGetRemoteVk, connectionGetState, connectionGetInvitation, connectionProcessInvite, connectionProcessRequest, connectionProcessResponse, connectionProcessAck, connectionSendResponse, connectionSendRequest, connectionSendAck, connectionSendGenericMessage, connectionCreateInvite, connectionSerialize, connectionDeserialize, connectionRelease, credentialCreateWithOffer, credentialRelease, credentialSendRequest, credentialDeclineOffer, credentialSerialize, credentialDeserialize, v2CredentialUpdateStateWithMessage, v2CredentialUpdateState, credentialGetState, credentialGetOffers, credentialGetAttributes, credentialGetAttachment, credentialGetTailsLocation, credentialGetTailsHash, credentialGetRevRegId, credentialGetThreadId, credentialdefCreateV2, credentialdefPublish, credentialdefDeserialize, credentialdefRelease, credentialdefSerialize, credentialdefGetCredDefId, credentialdefUpdateState, credentialdefGetState, disclosedProofCreateWithRequest, disclosedProofRelease, disclosedProofSendProof, disclosedProofRejectProof, disclosedProofGetProofMsg, disclosedProofSerialize, disclosedProofDeserialize, v2DisclosedProofUpdateState, v2DisclosedProofUpdateStateWithMessage, disclosedProofGetState, disclosedProofGetRequests, disclosedProofRetrieveCredentials, disclosedProofGetProofRequestAttachment, disclosedProofGenerateProof, disclosedProofDeclinePresentationRequest, disclosedProofGetThreadId, issuerCredentialDeserialize, issuerCredentialSerialize, issuerCredentialUpdateStateV2, issuerCredentialUpdateStateWithMessageV2, issuerCredentialUpdateStateWithMessageNonmediated, issuerCredentialGetState, issuerCredentialGetRevRegId, issuerCredentialCreate, issuerCredentialRevokeLocal, issuerCredentialIsRevokable, issuerCredentialSendCredential, issuerCredentialSendCredentialNonmediated, issuerCredentialSendOfferV2, issuerCredentialSendOfferNonmediated, issuerCredentialMarkOfferMsgSent, issuerCredentialBuildOfferMsgV2, issuerCredentialGetOfferMsg, issuerCredentialRelease, issuerCredentialGetThreadId, getLedgerAuthorAgreement, setActiveTxnAuthorAgreementMeta, createService, getServiceFromLedger, 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, proofGetProofMsg, proofRelease, proofSendRequest, proofSendRequestNonmediated, proofGetRequestMsg, proofSerialize, proofDeserialize, v2ProofUpdateState, v2ProofUpdateStateWithMessage, proofUpdateStateWithMessageNonmediated, proofGetState, proofGetProofState, proofGetThreadId, markPresentationRequestMsgSent, revocationRegistryCreate, revocationRegistryPublish, revocationRegistryPublishRevocations, revocationRegistryGetRevRegId, revocationRegistryGetTailsHash, revocationRegistrySerialize, revocationRegistryDeserialize, revocationRegistryRelease, schemaGetAttributes, schemaPrepareForEndorser, schemaCreate, schemaGetSchemaId, schemaDeserialize, schemaSerialize, schemaRelease, schemaUpdateState, schemaGetState, enableMocks, trustpingBuildResponseMsg, trustpingBuildPing, shutdown, getVersion, walletOpenAsMain, walletCreateMain, walletCloseMain, vcxInitIssuerConfig, configureIssuerWallet, unpack, createPairwiseInfo, walletImport, walletExport, getVerkeyFromWallet, rotateVerkey, rotateVerkeyStart, rotateVerkeyApply } = nativeBinding +const { updateWebhookUrl, createAgencyClientForMainWallet, provisionCloudAgent, messagesUpdateStatus, generatePublicInvitation, connectionCreateInviter, connectionCreateInvitee, connectionGetThreadId, connectionGetPairwiseInfo, connectionGetRemoteDid, connectionGetRemoteVk, connectionGetState, connectionGetInvitation, connectionProcessInvite, connectionProcessRequest, connectionProcessResponse, connectionProcessAck, connectionProcessProblemReport, connectionSendResponse, connectionSendRequest, connectionSendAck, connectionSendGenericMessage, connectionCreateInvite, connectionSerialize, connectionDeserialize, connectionRelease, credentialCreateWithOffer, credentialRelease, credentialSendRequest, credentialDeclineOffer, credentialSerialize, credentialDeserialize, v2CredentialUpdateStateWithMessage, v2CredentialUpdateState, credentialGetState, credentialGetOffers, credentialGetAttributes, credentialGetAttachment, credentialGetTailsLocation, credentialGetTailsHash, credentialGetRevRegId, credentialGetThreadId, credentialdefCreateV2, credentialdefPublish, credentialdefDeserialize, credentialdefRelease, credentialdefSerialize, credentialdefGetCredDefId, credentialdefUpdateState, credentialdefGetState, disclosedProofCreateWithRequest, disclosedProofRelease, disclosedProofSendProof, disclosedProofRejectProof, disclosedProofGetProofMsg, disclosedProofSerialize, disclosedProofDeserialize, v2DisclosedProofUpdateState, v2DisclosedProofUpdateStateWithMessage, disclosedProofGetState, disclosedProofGetRequests, disclosedProofRetrieveCredentials, disclosedProofGetProofRequestAttachment, disclosedProofGenerateProof, disclosedProofDeclinePresentationRequest, disclosedProofGetThreadId, issuerCredentialDeserialize, issuerCredentialSerialize, issuerCredentialUpdateStateV2, issuerCredentialUpdateStateWithMessageV2, issuerCredentialUpdateStateWithMessageNonmediated, issuerCredentialGetState, issuerCredentialGetRevRegId, issuerCredentialCreate, issuerCredentialRevokeLocal, issuerCredentialIsRevokable, issuerCredentialSendCredential, issuerCredentialSendCredentialNonmediated, issuerCredentialSendOfferV2, issuerCredentialSendOfferNonmediated, issuerCredentialMarkOfferMsgSent, issuerCredentialBuildOfferMsgV2, issuerCredentialGetOfferMsg, issuerCredentialRelease, issuerCredentialGetThreadId, getLedgerAuthorAgreement, setActiveTxnAuthorAgreementMeta, createService, getServiceFromLedger, 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, proofGetProofMsg, proofRelease, proofSendRequest, proofSendRequestNonmediated, proofGetRequestMsg, proofSerialize, proofDeserialize, v2ProofUpdateState, v2ProofUpdateStateWithMessage, proofUpdateStateWithMessageNonmediated, proofGetState, proofGetProofState, proofGetThreadId, markPresentationRequestMsgSent, revocationRegistryCreate, revocationRegistryPublish, revocationRegistryPublishRevocations, revocationRegistryGetRevRegId, revocationRegistryGetTailsHash, revocationRegistrySerialize, revocationRegistryDeserialize, revocationRegistryRelease, schemaGetAttributes, schemaPrepareForEndorser, schemaCreate, schemaGetSchemaId, schemaDeserialize, schemaSerialize, schemaRelease, schemaUpdateState, schemaGetState, enableMocks, trustpingBuildResponseMsg, trustpingBuildPing, shutdown, getVersion, walletOpenAsMain, walletCreateMain, walletCloseMain, vcxInitIssuerConfig, configureIssuerWallet, unpack, createPairwiseInfo, walletImport, walletExport, getVerkeyFromWallet, rotateVerkey, rotateVerkeyStart, rotateVerkeyApply } = nativeBinding module.exports.updateWebhookUrl = updateWebhookUrl module.exports.createAgencyClientForMainWallet = createAgencyClientForMainWallet @@ -265,6 +265,7 @@ module.exports.connectionProcessInvite = connectionProcessInvite module.exports.connectionProcessRequest = connectionProcessRequest module.exports.connectionProcessResponse = connectionProcessResponse module.exports.connectionProcessAck = connectionProcessAck +module.exports.connectionProcessProblemReport = connectionProcessProblemReport module.exports.connectionSendResponse = connectionSendResponse module.exports.connectionSendRequest = connectionSendRequest module.exports.connectionSendAck = connectionSendAck diff --git a/wrappers/vcx-napi-rs/src/api/connection.rs b/wrappers/vcx-napi-rs/src/api/connection.rs index 903ea6a5f4..99f20f2dc9 100644 --- a/wrappers/vcx-napi-rs/src/api/connection.rs +++ b/wrappers/vcx-napi-rs/src/api/connection.rs @@ -102,6 +102,12 @@ pub async fn connection_process_ack(handle: u32, message: String) -> napi::Resul connection::process_ack(handle, &message).await.map_err(to_napi_err) } +#[napi] +pub fn connection_process_problem_report(handle: u32, problem_report: String) -> napi::Result<()> { + trace!("connection_process_problem_report >>> handle: {:?}", handle); + connection::process_problem_report(handle, &problem_report).map_err(to_napi_err) +} + #[napi] pub async fn connection_send_response(handle: u32) -> napi::Result<()> { trace!("connection_send_response >>> handle: {:?}", handle);