async def handle(self, context: RequestContext, responder: BaseResponder): """Handle received presentation request request.""" connection_id = str(context.message.connection_id) try: connection_record = await ConnectionRecord.retrieve_by_id( context, connection_id ) except StorageNotFoundError: report = ProblemReport( explain_ltxt='Connection not found.', who_retries='none' ) report.assign_thread_from(context.message) await responder.send_reply(report) return if not connection_record.is_ready: report = ProblemReport( explain_ltxt='Connection invalid.', who_retries='none' ) report.assign_thread_from(context.message) await responder.send_reply(report) return comment = context.message.comment indy_proof_request = context.message.proof_request if not indy_proof_request.get('nonce'): indy_proof_request['nonce'] = str(uuid4().int) presentation_request_message = PresentationRequest( comment=comment, request_presentations_attach=[ AttachDecorator.from_indy_dict(indy_proof_request) ] ) presentation_manager = PresentationManager(context) presentation_exchange_record = ( await presentation_manager.create_exchange_for_request( connection_id=connection_id, presentation_request_message=presentation_request_message ) ) await responder.send( presentation_request_message, connection_id=connection_id ) pres_exchange = IssuerPresExchange(**presentation_exchange_record.serialize()) pres_exchange.assign_thread_from(context.message) await responder.send_reply(pres_exchange)
async def handle(self, context: RequestContext, responder: BaseResponder): """Handle received send presentation proposal request.""" connection_id = str(context.message.connection_id) try: connection_record = await ConnectionRecord.retrieve_by_id( context, connection_id ) except StorageNotFoundError: report = ProblemReport( explain_ltxt='Connection not found.', who_retries='none' ) report.assign_thread_from(context.message) await responder.send_reply(report) return if not connection_record.is_ready: report = ProblemReport( explain_ltxt='Connection invalid.', who_retries='none' ) report.assign_thread_from(context.message) await responder.send_reply(report) return comment = context.message.comment # Aries#0037 calls it a proposal in the proposal struct but it's of type preview presentation_proposal = PresentationProposal( comment=comment, presentation_proposal=context.message.presentation_proposal ) auto_present = ( context.message.auto_present or context.settings.get("debug.auto_respond_presentation_request") ) presentation_manager = PresentationManager(context) presentation_exchange_record = ( await presentation_manager.create_exchange_for_proposal( connection_id=connection_id, presentation_proposal_message=presentation_proposal, auto_present=auto_present ) ) await responder.send(presentation_proposal, connection_id=connection_id) pres_exchange = PresExchange(**presentation_exchange_record.serialize()) pres_exchange.assign_thread_from(context.message) await responder.send_reply(pres_exchange)