Skip to content

Commit

Permalink
Process problem report
Browse files Browse the repository at this point in the history
Signed-off-by: Miroslav Kovar <miroslav.kovar@absa.africa>
  • Loading branch information
mirgee committed Feb 1, 2023
1 parent ba02432 commit 6449e67
Show file tree
Hide file tree
Showing 6 changed files with 45 additions and 2 deletions.
19 changes: 18 additions & 1 deletion aries_vcx/src/handlers/connection/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};

Expand Down Expand Up @@ -113,7 +114,7 @@ impl Connection {

pub fn bootstrap_did_doc(&self) -> Option<AriesDidDoc> {
match &self.connection_sm {
SmConnection::Inviter(sm_inviter) => None,
SmConnection::Inviter(_sm_inviter) => None,
SmConnection::Invitee(sm_invitee) => sm_invitee.bootstrap_did_doc(),
}
}
Expand Down Expand Up @@ -215,6 +216,22 @@ impl Connection {
Ok(Self { connection_sm })
}

pub fn process_problem_report(self, problem_report: ProblemReport) -> VcxResult<Self> {
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,
Expand Down
10 changes: 10 additions & 0 deletions libvcx/src/api_vcx/api_handle/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
8 changes: 8 additions & 0 deletions wrappers/node/src/api/connection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,14 @@ export class NonmediatedConnection extends VcxBaseWithState<INonmeditatedConnect
}
}

public processProblemReport(problemReport: string): void {
try {
ffiNapi.connectionProcessProblemReport(this.handle, problemReport);
} catch (err: any) {
throw new VCXInternalError(err);
}
}

public async sendResponse(): Promise<void> {
try {
await ffiNapi.connectionSendResponse(this.handle);
Expand Down
1 change: 1 addition & 0 deletions wrappers/vcx-napi-rs/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export function connectionProcessInvite(handle: number, invitation: string): voi
export function connectionProcessRequest(handle: number, request: string, serviceEndpoint: string, routingKeys: Array<string>): Promise<void>
export function connectionProcessResponse(handle: number, response: string): Promise<void>
export function connectionProcessAck(handle: number, message: string): Promise<void>
export function connectionProcessProblemReport(handle: number, problemReport: string): void
export function connectionSendResponse(handle: number): Promise<void>
export function connectionSendRequest(handle: number, serviceEndpoint: string, routingKeys: Array<string>): Promise<void>
export function connectionSendAck(handle: number): Promise<void>
Expand Down
3 changes: 2 additions & 1 deletion wrappers/vcx-napi-rs/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 6 additions & 0 deletions wrappers/vcx-napi-rs/src/api/connection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 6449e67

Please sign in to comment.