From 20fda889436b91b704acb07ec0481d3d8ac0b4da Mon Sep 17 00:00:00 2001 From: "Colton Wolkins (Indicio work address)" Date: Tue, 5 Oct 2021 11:13:39 -0600 Subject: [PATCH 1/3] feat: return presentation request in presentation-matching-credentials presentation-matching-credentials returned the matching credentials with no way to link them to the requested attributes. Now, the presentation-request tag is also sent back Signed-off-by: Colton Wolkins (Indicio work address) --- .../v0_1/messages/pres_get_matching_credentials.py | 1 + .../holder/v0_1/messages/pres_matching_credentials.py | 9 +++++++++ 2 files changed, 10 insertions(+) diff --git a/acapy_plugin_toolbox/holder/v0_1/messages/pres_get_matching_credentials.py b/acapy_plugin_toolbox/holder/v0_1/messages/pres_get_matching_credentials.py index 7eb005e6..bc493398 100644 --- a/acapy_plugin_toolbox/holder/v0_1/messages/pres_get_matching_credentials.py +++ b/acapy_plugin_toolbox/holder/v0_1/messages/pres_get_matching_credentials.py @@ -62,6 +62,7 @@ async def handle(self, context: RequestContext, responder: BaseResponder): self.paginate.limit, extra_query={}, ), + presentation_request=pres_ex_record.presentation_request, page=Page(count_=self.paginate.limit, offset=self.paginate.offset), ) matches.assign_thread_from(self) diff --git a/acapy_plugin_toolbox/holder/v0_1/messages/pres_matching_credentials.py b/acapy_plugin_toolbox/holder/v0_1/messages/pres_matching_credentials.py index 416bf4e5..8496a25b 100644 --- a/acapy_plugin_toolbox/holder/v0_1/messages/pres_matching_credentials.py +++ b/acapy_plugin_toolbox/holder/v0_1/messages/pres_matching_credentials.py @@ -6,6 +6,9 @@ from ....decorators.pagination import Page from ....util import expand_message_class, with_generic_init from .base import AdminHolderMessage +from aries_cloudagent.protocols.present_proof.v1_0.models.presentation_exchange import ( + V10PresentationExchange as PresExRecord, +) @with_generic_init @@ -21,6 +24,10 @@ class Fields: presentation_exchange_id = fields.Str( required=True, description="Exchange ID for matched credentials." ) + # TODO Use a toolbox PresentationExchangeRepresentation + presentation_request = fields.Mapping( + required=True, description="Presentation Request associated with the Presentation Exchange ID." + ) matching_credentials = fields.Nested( IndyCredPrecisSchema, many=True, description="Matched credentials." ) @@ -33,6 +40,7 @@ class Fields: def __init__( self, presentation_exchange_id: str, + presentation_request: PresExRecord, matching_credentials: Tuple[Any, ...], page: Page = None, **kwargs, @@ -40,5 +48,6 @@ def __init__( """Initialize PresMatchingCredentials""" super().__init__(**kwargs) self.presentation_exchange_id = presentation_exchange_id + self.presentation_request = presentation_request self.matching_credentials = matching_credentials self.page = page From ce1ff8fb2d6c020ec614ac2a5d8377d5bae5a5e6 Mon Sep 17 00:00:00 2001 From: "Colton Wolkins (Indicio work address)" Date: Wed, 6 Oct 2021 15:43:31 -0600 Subject: [PATCH 2/3] chore: Code formatting cleanup Signed-off-by: Colton Wolkins (Indicio work address) --- .../holder/v0_1/messages/pres_matching_credentials.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/acapy_plugin_toolbox/holder/v0_1/messages/pres_matching_credentials.py b/acapy_plugin_toolbox/holder/v0_1/messages/pres_matching_credentials.py index 8496a25b..3993e414 100644 --- a/acapy_plugin_toolbox/holder/v0_1/messages/pres_matching_credentials.py +++ b/acapy_plugin_toolbox/holder/v0_1/messages/pres_matching_credentials.py @@ -26,7 +26,8 @@ class Fields: ) # TODO Use a toolbox PresentationExchangeRepresentation presentation_request = fields.Mapping( - required=True, description="Presentation Request associated with the Presentation Exchange ID." + required=True, + description="Presentation Request associated with the Presentation Exchange ID.", ) matching_credentials = fields.Nested( IndyCredPrecisSchema, many=True, description="Matched credentials." From a5921429e7d888483fb24be42fc032bb936a9852 Mon Sep 17 00:00:00 2001 From: "Colton Wolkins (Indicio work address)" Date: Fri, 8 Oct 2021 09:08:34 -0600 Subject: [PATCH 3/3] fix: presentation-request-received output reformatted `presentation-request-received` had all presentation information included because the raw record information was included. The user of the API should not rely on the raw record, instead, `presentation_exchange_id` and `presentation_request` have been pulled out and are now top-level elements. Similar to the `presentation-get-matching-credentials` API response. Signed-off-by: Colton Wolkins (Indicio work address) --- .../v0_1/messages/pres_request_received.py | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/acapy_plugin_toolbox/holder/v0_1/messages/pres_request_received.py b/acapy_plugin_toolbox/holder/v0_1/messages/pres_request_received.py index 7dd25c21..d3e8bf18 100644 --- a/acapy_plugin_toolbox/holder/v0_1/messages/pres_request_received.py +++ b/acapy_plugin_toolbox/holder/v0_1/messages/pres_request_received.py @@ -27,7 +27,15 @@ class PresRequestReceived(AdminHolderMessage): class Fields: """Fields of Presentation request received message.""" - record = PresExRecordField(required=True, description="Presentation details.") + raw_repr = PresExRecordField(required=True, description="Presentation details.") + presentation_exchange_id = fields.Str( + required=True, description="Exchange ID for matched credentials." + ) + # TODO Use a toolbox PresentationExchangeRepresentation + presentation_request = fields.Mapping( + required=True, + description="Presentation Request associated with the Presentation Exchange ID.", + ) matching_credentials = fields.Nested( IndyCredPrecisSchema, many=True, @@ -39,13 +47,15 @@ class Fields: def __init__(self, record: PresExRecord, **kwargs): super().__init__(**kwargs) - self.record = record + self.raw_repr = record + self.presentation_request = record.presentation_request + self.presentation_exchange_id = record.presentation_exchange_id self.matching_credentials = [] self.page = None async def retrieve_matching_credentials(self, profile: Profile): holder = profile.inject(IndyHolder) - request = self.record.presentation_request + request = self.presentation_request if not (type(request) is dict): request = request.serialize()