forked from openwallet-foundation/acapy
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Init acknowledgment phase in present-proof, Update responses in issue…
… and present protocols, Add endpoint for swagger retrieval
- Loading branch information
Karol Krzosa
committed
Dec 28, 2020
1 parent
0f2a519
commit 6a7b67f
Showing
13 changed files
with
240 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
aries_cloudagent/protocols/present_proof/v1_1/handlers/acknowledge_proof.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
from .....messaging.base_handler import ( | ||
BaseHandler, | ||
BaseResponder, | ||
HandlerException, | ||
RequestContext, | ||
) | ||
from aries_cloudagent.aathcf.utils import debug_handler | ||
from aries_cloudagent.protocols.present_proof.v1_1.models.presentation_exchange import ( | ||
THCFPresentationExchange, | ||
) | ||
from aries_cloudagent.protocols.present_proof.v1_1.messages.acknowledge_proof import ( | ||
AcknowledgeProof, | ||
) | ||
from aries_cloudagent.verifier.base import BaseVerifier | ||
from ..models.utils import retrieve_exchange_by_thread | ||
import json | ||
from collections import OrderedDict | ||
from aries_cloudagent.aathcf.credentials import raise_exception_invalid_state | ||
|
||
|
||
# TODO Error handling | ||
class AcknowledgeProofHandler(BaseHandler): | ||
""" | ||
Message handler logic for incoming credential presentations / incoming proofs. | ||
""" | ||
|
||
async def handle(self, context: RequestContext, responder: BaseResponder): | ||
debug_handler(self._logger.info, context, AcknowledgeProof) | ||
|
||
exchange_record: THCFPresentationExchange = await retrieve_exchange_by_thread( | ||
context, | ||
responder.connection_id, | ||
context.message._thread_id, | ||
HandlerException, | ||
) | ||
|
||
raise_exception_invalid_state( | ||
exchange_record, | ||
THCFPresentationExchange.STATE_PRESENTATION_SENT, | ||
THCFPresentationExchange.ROLE_PROVER, | ||
HandlerException, | ||
) | ||
|
||
exchange_record.acknowledgment_credential = context.message.credential | ||
exchange_record.state = exchange_record.STATE_ACKNOWLEDGED | ||
await exchange_record.save(context) | ||
|
||
await responder.send_webhook( | ||
"present_proof", | ||
{ | ||
"type": "acknowledge_proof", | ||
"exchange_record_id": exchange_record._id, | ||
"connection_id": responder.connection_id, | ||
}, | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
34 changes: 34 additions & 0 deletions
34
aries_cloudagent/protocols/present_proof/v1_1/messages/acknowledge_proof.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
from marshmallow import fields | ||
from .....messaging.agent_message import AgentMessage, AgentMessageSchema | ||
from ..message_types import ACKNOWLEDGE_PROOF, PROTOCOL_PACKAGE | ||
|
||
HANDLER_CLASS = f"{PROTOCOL_PACKAGE}.handlers.acknowledge_proof.AcknowledgeProofHandler" | ||
|
||
|
||
class AcknowledgeProof(AgentMessage): | ||
class Meta: | ||
handler_class = HANDLER_CLASS | ||
schema_class = "AcknowledgeProofSchema" | ||
message_type = ACKNOWLEDGE_PROOF | ||
|
||
def __init__( | ||
self, | ||
_id: str = None, | ||
*, | ||
credential=None, | ||
**kwargs, | ||
): | ||
"""Initialize credential issue object.""" | ||
super().__init__(_id=_id, **kwargs) | ||
self.credential = credential | ||
|
||
|
||
class AcknowledgeProofSchema(AgentMessageSchema): | ||
"""Credential schema.""" | ||
|
||
class Meta: | ||
"""Credential schema metadata.""" | ||
|
||
model_class = AcknowledgeProof | ||
|
||
credential = fields.Str(required=False) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 0 additions & 3 deletions
3
aries_cloudagent/protocols/present_proof/v1_1/messages/request_proof.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.