From df7d6dfb07d287f36d7bdaa6acd1d5d04456490d Mon Sep 17 00:00:00 2001 From: Daniel Bluhm Date: Tue, 15 Dec 2020 15:01:20 -0500 Subject: [PATCH 01/19] fix: update version, fix startup parameters Signed-off-by: Daniel Bluhm --- requirements.txt | 4 ++-- startup.sh | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/requirements.txt b/requirements.txt index 046adcdb..c1ff27ab 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -aries-cloudagent[indy]@git+https://github.com/hyperledger/aries-cloudagent-python@0.5.3 -marshmallow==3.0.0 +aries-cloudagent[indy]@git+https://github.com/dbluhm/aries-cloudagent-python@feature/assign-metadata-to-invite +marshmallow==3.5.1 flake8 python-dateutil diff --git a/startup.sh b/startup.sh index 40f6ee3c..1633d5ad 100644 --- a/startup.sh +++ b/startup.sh @@ -7,9 +7,9 @@ aca-py start \ --auto-respond-credential-proposal --auto-respond-credential-offer --auto-respond-credential-request --auto-store-credential \ --auto-respond-presentation-proposal --auto-respond-presentation-request --auto-verify-presentation \ --preserve-exchange-records \ - --invite --invite-role admin --invite-label "$AGENT_NAME (admin)" \ + --invite --invite-metadata-json '{"group": "admin"}' --invite-label "$AGENT_NAME (admin)" \ --genesis-url https://raw.githubusercontent.com/sovrin-foundation/sovrin/master/sovrin/pool_transactions_sandbox_genesis \ - --wallet-type indy \ + --wallet-type indy --wallet-name "$AGENT_NAME" --wallet-key "insecure" --auto-provision \ --plugin acapy_plugin_toolbox \ --admin 0.0.0.0 $ADMIN_PORT --admin-insecure-mode \ --debug-connections \ From a43030260cec627f2495ebd952a94eae054dbaaa Mon Sep 17 00:00:00 2001 From: Daniel Bluhm Date: Tue, 15 Dec 2020 15:14:02 -0500 Subject: [PATCH 02/19] fix: make startup.sh executable Signed-off-by: Daniel Bluhm --- startup.sh | 0 1 file changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 startup.sh diff --git a/startup.sh b/startup.sh old mode 100644 new mode 100755 From 8e97971ae1039eb256a73e204b54a6c7d334d8f3 Mon Sep 17 00:00:00 2001 From: Daniel Bluhm Date: Tue, 15 Dec 2020 15:15:15 -0500 Subject: [PATCH 03/19] fix: connection_record -> conn_record Signed-off-by: Daniel Bluhm --- acapy_plugin_toolbox/basicmessage.py | 8 ++++---- acapy_plugin_toolbox/connections.py | 14 +++++++------- acapy_plugin_toolbox/holder.py | 10 +++++----- acapy_plugin_toolbox/invitations.py | 14 +++++++------- acapy_plugin_toolbox/issuer.py | 10 +++++----- acapy_plugin_toolbox/mediator.py | 2 +- acapy_plugin_toolbox/routing.py | 4 ++-- acapy_plugin_toolbox/static_connections.py | 14 +++++++------- 8 files changed, 38 insertions(+), 38 deletions(-) diff --git a/acapy_plugin_toolbox/basicmessage.py b/acapy_plugin_toolbox/basicmessage.py index 9b0acf04..27267fbf 100644 --- a/acapy_plugin_toolbox/basicmessage.py +++ b/acapy_plugin_toolbox/basicmessage.py @@ -8,8 +8,8 @@ from aries_cloudagent.config.injection_context import InjectionContext from aries_cloudagent.core.protocol_registry import ProtocolRegistry -from aries_cloudagent.connections.models.connection_record import ( - ConnectionRecord +from aries_cloudagent.connections.models.conn_record import ( + ConnRecord ) from aries_cloudagent.messaging.base_handler import ( BaseHandler, BaseResponder, RequestContext @@ -237,7 +237,7 @@ async def handle(self, context: RequestContext, responder: BaseResponder): ) connection_mgr = ConnectionManager(context) - admins = await ConnectionRecord.query( + admins = await ConnRecord.query( context, post_filter_positive={'their_role': 'admin'} ) @@ -376,7 +376,7 @@ async def handle(self, context: RequestContext, responder: BaseResponder): """Handle received send requests.""" # pylint: disable=protected-access try: - connection = await ConnectionRecord.retrieve_by_id( + connection = await ConnRecord.retrieve_by_id( context, context.message.connection_id ) except StorageNotFoundError: diff --git a/acapy_plugin_toolbox/connections.py b/acapy_plugin_toolbox/connections.py index 3be02e9b..bf64c769 100644 --- a/acapy_plugin_toolbox/connections.py +++ b/acapy_plugin_toolbox/connections.py @@ -11,8 +11,8 @@ from aries_cloudagent.core.protocol_registry import ProtocolRegistry from aries_cloudagent.messaging.base_handler import BaseHandler, BaseResponder, RequestContext from aries_cloudagent.protocols.connections.v1_0.manager import ConnectionManager -from aries_cloudagent.connections.models.connection_record import ( - ConnectionRecord +from aries_cloudagent.connections.models.conn_record import ( + ConnRecord ) from aries_cloudagent.protocols.connections.v1_0.messages.connection_invitation import ( ConnectionInvitation, @@ -87,8 +87,8 @@ async def setup( ) -def conn_record_to_message_repr(conn: ConnectionRecord) -> Dict[str, Any]: - """Map ConnectionRecord onto Connection.""" +def conn_record_to_message_repr(conn: ConnRecord) -> Dict[str, Any]: + """Map ConnRecord onto Connection.""" def _state_map(state: str) -> str: if state in ('active', 'response'): return 'active' @@ -160,7 +160,7 @@ async def handle(self, context: RequestContext, responder: BaseResponder): }.items() )) # TODO: Filter on state (needs mapping back to ACA-Py connection states) - records = await ConnectionRecord.query( + records = await ConnRecord.query( context, tag_filter, post_filter_positive ) results = [ @@ -191,7 +191,7 @@ class UpdateHandler(BaseHandler): async def handle(self, context: RequestContext, responder: BaseResponder): """Handle update connection request.""" try: - connection = await ConnectionRecord.retrieve_by_id( + connection = await ConnRecord.retrieve_by_id( context, context.message.connection_id ) @@ -252,7 +252,7 @@ async def handle(self, context: RequestContext, responder: BaseResponder): return try: - connection = await ConnectionRecord.retrieve_by_id( + connection = await ConnRecord.retrieve_by_id( context, context.message.connection_id ) diff --git a/acapy_plugin_toolbox/holder.py b/acapy_plugin_toolbox/holder.py index 0912e354..56282831 100644 --- a/acapy_plugin_toolbox/holder.py +++ b/acapy_plugin_toolbox/holder.py @@ -36,7 +36,7 @@ ) from aries_cloudagent.protocols.present_proof.v1_0.manager import PresentationManager -from aries_cloudagent.connections.models.connection_record import ConnectionRecord +from aries_cloudagent.connections.models.conn_record import ConnRecord from aries_cloudagent.storage.error import StorageNotFoundError from aries_cloudagent.protocols.problem_report.v1_0.message import ProblemReport @@ -108,7 +108,7 @@ async def handle(self, context: RequestContext, responder: BaseResponder): credential_manager = CredentialManager(context) try: - connection_record = await ConnectionRecord.retrieve_by_id( + conn_record = await ConnRecord.retrieve_by_id( context, connection_id ) @@ -121,7 +121,7 @@ async def handle(self, context: RequestContext, responder: BaseResponder): await responder.send_reply(report) return - if not connection_record.is_ready: + if not conn_record.is_ready: report = ProblemReport( explain_ltxt='Connection invalid.', who_retries='none' @@ -174,7 +174,7 @@ async def handle(self, context: RequestContext, responder: BaseResponder): connection_id = str(context.message.connection_id) try: - connection_record = await ConnectionRecord.retrieve_by_id( + conn_record = await ConnRecord.retrieve_by_id( context, connection_id ) @@ -187,7 +187,7 @@ async def handle(self, context: RequestContext, responder: BaseResponder): await responder.send_reply(report) return - if not connection_record.is_ready: + if not conn_record.is_ready: report = ProblemReport( explain_ltxt='Connection invalid.', who_retries='none' diff --git a/acapy_plugin_toolbox/invitations.py b/acapy_plugin_toolbox/invitations.py index 5087a160..d75eae07 100644 --- a/acapy_plugin_toolbox/invitations.py +++ b/acapy_plugin_toolbox/invitations.py @@ -11,8 +11,8 @@ BaseHandler, BaseResponder, RequestContext ) from aries_cloudagent.protocols.connections.v1_0.manager import ConnectionManager -from aries_cloudagent.connections.models.connection_record import ( - ConnectionRecord +from aries_cloudagent.connections.models.conn_record import ( + ConnRecord ) # ProblemReport will probably be needed when a delete message is implemented # from aries_cloudagent.protocols.problem_report.v1_0.message import ProblemReport @@ -133,10 +133,10 @@ async def handle(self, context: RequestContext, responder: BaseResponder): label=invitation.label, alias=connection.alias, role=connection.their_role, - auto_accept=connection.accept == ConnectionRecord.ACCEPT_AUTO, + auto_accept=connection.accept == ConnRecord.ACCEPT_AUTO, multi_use=( connection.invitation_mode == - ConnectionRecord.INVITATION_MODE_MULTI + ConnRecord.INVITATION_MODE_MULTI ), invitation_url=invitation.to_url(), created_date=connection.created_at, @@ -169,7 +169,7 @@ async def handle(self, context: RequestContext, responder: BaseResponder): # 'their_role': context.message.their_role }.items() )) - records = await ConnectionRecord.query( + records = await ConnRecord.query( context, tag_filter, post_filter_positive ) results = [] @@ -185,11 +185,11 @@ async def handle(self, context: RequestContext, responder: BaseResponder): 'alias': connection.alias, 'role': connection.their_role, 'auto_accept': ( - connection.accept == ConnectionRecord.ACCEPT_AUTO + connection.accept == ConnRecord.ACCEPT_AUTO ), 'multi_use': ( connection.invitation_mode == - ConnectionRecord.INVITATION_MODE_MULTI + ConnRecord.INVITATION_MODE_MULTI ), 'invitation_url': invitation.to_url(), 'created_date': connection.created_at, diff --git a/acapy_plugin_toolbox/issuer.py b/acapy_plugin_toolbox/issuer.py index 75d40edf..fe09876b 100644 --- a/acapy_plugin_toolbox/issuer.py +++ b/acapy_plugin_toolbox/issuer.py @@ -39,7 +39,7 @@ from aries_cloudagent.protocols.present_proof.v1_0.messages.presentation_request import PresentationRequest from aries_cloudagent.protocols.present_proof.v1_0.manager import PresentationManager from aries_cloudagent.protocols.issue_credential.v1_0.manager import CredentialManager -from aries_cloudagent.connections.models.connection_record import ConnectionRecord +from aries_cloudagent.connections.models.conn_record import ConnRecord from aries_cloudagent.storage.error import StorageNotFoundError from aries_cloudagent.protocols.problem_report.v1_0.message import ProblemReport @@ -108,7 +108,7 @@ async def handle(self, context: RequestContext, responder: BaseResponder): preview_spec = context.message.credential_proposal try: - connection_record = await ConnectionRecord.retrieve_by_id( + conn_record = await ConnRecord.retrieve_by_id( context, connection_id ) @@ -121,7 +121,7 @@ async def handle(self, context: RequestContext, responder: BaseResponder): await responder.send_reply(report) return - if not connection_record.is_ready: + if not conn_record.is_ready: report = ProblemReport( explain_ltxt='Connection invalid.', who_retries='none' @@ -180,7 +180,7 @@ async def handle(self, context: RequestContext, responder: BaseResponder): connection_id = str(context.message.connection_id) try: - connection_record = await ConnectionRecord.retrieve_by_id( + conn_record = await ConnRecord.retrieve_by_id( context, connection_id ) @@ -193,7 +193,7 @@ async def handle(self, context: RequestContext, responder: BaseResponder): await responder.send_reply(report) return - if not connection_record.is_ready: + if not conn_record.is_ready: report = ProblemReport( explain_ltxt='Connection invalid.', who_retries='none' diff --git a/acapy_plugin_toolbox/mediator.py b/acapy_plugin_toolbox/mediator.py index ae827af4..cdd6422d 100644 --- a/acapy_plugin_toolbox/mediator.py +++ b/acapy_plugin_toolbox/mediator.py @@ -16,7 +16,7 @@ from aries_cloudagent.protocols.routing.v1_0.manager import RoutingManager from aries_cloudagent.protocols.routing.v1_0.models.route_record import RouteRecord, RouteRecordSchema -from aries_cloudagent.connections.models.connection_record import ConnectionRecord +from aries_cloudagent.connections.models.con import ConnectionRecord from aries_cloudagent.storage.error import StorageNotFoundError from aries_cloudagent.protocols.problem_report.v1_0.message import ProblemReport diff --git a/acapy_plugin_toolbox/routing.py b/acapy_plugin_toolbox/routing.py index f62dee68..d446c699 100644 --- a/acapy_plugin_toolbox/routing.py +++ b/acapy_plugin_toolbox/routing.py @@ -8,8 +8,8 @@ from aries_cloudagent.config.injection_context import InjectionContext from aries_cloudagent.core.protocol_registry import ProtocolRegistry -from aries_cloudagent.connections.models.connection_record import ( - ConnectionRecord +from aries_cloudagent.connections.models.conn_record import ( + ConnRecord ) from aries_cloudagent.messaging.base_handler import ( BaseHandler, BaseResponder, RequestContext diff --git a/acapy_plugin_toolbox/static_connections.py b/acapy_plugin_toolbox/static_connections.py index 1f61e4b6..4178ad79 100644 --- a/acapy_plugin_toolbox/static_connections.py +++ b/acapy_plugin_toolbox/static_connections.py @@ -10,7 +10,7 @@ from aries_cloudagent.wallet.base import BaseWallet from aries_cloudagent.messaging.base_handler import BaseHandler, BaseResponder, RequestContext from aries_cloudagent.protocols.connections.v1_0.manager import ConnectionManager -from aries_cloudagent.connections.models.connection_record import ConnectionRecord +from aries_cloudagent.connections.models.conn_record import ConnRecord from aries_cloudagent.connections.models.diddoc import ( DIDDoc, PublicKey, PublicKeyType, Service ) @@ -97,14 +97,14 @@ async def handle(self, context: RequestContext, responder: BaseResponder): my_info = await wallet.create_local_did() # Create connection record - connection = ConnectionRecord( - initiator=ConnectionRecord.INITIATOR_SELF, + connection = ConnRecord( + initiator=ConnRecord.INITIATOR_SELF, my_did=my_info.did, their_did=context.message.static_did, their_label=context.message.label, their_role=context.message.role if context.message.role else None, - state=ConnectionRecord.STATE_ACTIVE, - invitation_mode=ConnectionRecord.INVITATION_MODE_STATIC + state=ConnRecord.STATE_ACTIVE, + invitation_mode=ConnRecord.INVITATION_MODE_STATIC ) # Construct their did doc from the basic components in message @@ -205,11 +205,11 @@ async def handle(self, context: RequestContext, responder: BaseResponder): filter(lambda item: item[1] is not None, { 'initiator': context.message.initiator, 'invitation_key': context.message.invitation_key, - 'invitation_mode': ConnectionRecord.INVITATION_MODE_STATIC, + 'invitation_mode': ConnRecord.INVITATION_MODE_STATIC, 'their_role': context.message.their_role }.items()) ) - records = await ConnectionRecord.query(context, tag_filter, post_filter_positive) + records = await ConnRecord.query(context, tag_filter, post_filter_positive) except StorageNotFoundError: report = ProblemReport( explain_ltxt='Connection not found.', From 578feb17d12dec194b582183158e405fc399a1f9 Mon Sep 17 00:00:00 2001 From: Daniel Bluhm Date: Tue, 15 Dec 2020 15:22:12 -0500 Subject: [PATCH 04/19] fix: base issuer -> indy issuer Signed-off-by: Daniel Bluhm --- acapy_plugin_toolbox/credential_definitions.py | 4 ++-- acapy_plugin_toolbox/schemas.py | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/acapy_plugin_toolbox/credential_definitions.py b/acapy_plugin_toolbox/credential_definitions.py index eb026dc7..aced4261 100644 --- a/acapy_plugin_toolbox/credential_definitions.py +++ b/acapy_plugin_toolbox/credential_definitions.py @@ -13,7 +13,7 @@ from aries_cloudagent.messaging.models.base_record import BaseRecord, BaseRecordSchema from aries_cloudagent.protocols.problem_report.v1_0.message import ProblemReport from aries_cloudagent.ledger.base import BaseLedger -from aries_cloudagent.issuer.base import BaseIssuer +from aries_cloudagent.indy.issuer import IndyIssuer from aries_cloudagent.storage.error import StorageNotFoundError from aries_cloudagent.config.injection_context import InjectionContext from aries_cloudagent.messaging.util import canon @@ -169,7 +169,7 @@ class SendCredDefHandler(BaseHandler): async def handle(self, context: RequestContext, responder: BaseResponder): """Handle received send cred def request.""" ledger: BaseLedger = await context.inject(BaseLedger) - issuer: BaseIssuer = await context.inject(BaseIssuer) + issuer: IndyIssuer = await context.inject(IndyIssuer) # If no schema record, make one try: schema_record = await SchemaRecord.retrieve_by_schema_id( diff --git a/acapy_plugin_toolbox/schemas.py b/acapy_plugin_toolbox/schemas.py index 6b1d7048..964ac358 100644 --- a/acapy_plugin_toolbox/schemas.py +++ b/acapy_plugin_toolbox/schemas.py @@ -12,7 +12,7 @@ from aries_cloudagent.messaging.base_handler import BaseHandler, BaseResponder, RequestContext from aries_cloudagent.messaging.models.base_record import BaseRecord, BaseRecordSchema from aries_cloudagent.ledger.base import BaseLedger -from aries_cloudagent.issuer.base import BaseIssuer +from aries_cloudagent.indy.issuer import IndyIssuer from aries_cloudagent.storage.error import StorageNotFoundError from aries_cloudagent.config.injection_context import InjectionContext @@ -180,7 +180,7 @@ class SendSchemaHandler(BaseHandler): async def handle(self, context: RequestContext, responder: BaseResponder): """Handle received send schema request.""" ledger: BaseLedger = await context.inject(BaseLedger) - issuer: BaseIssuer = await context.inject(BaseIssuer) + issuer: IndyIssuer = await context.inject(IndyIssuer) async with ledger: schema_id, schema_def = await shield( ledger.create_and_send_schema( From 7db1f4aeffa56cdb5755ee18d854b524d44b47c1 Mon Sep 17 00:00:00 2001 From: Daniel Bluhm Date: Tue, 15 Dec 2020 15:27:47 -0500 Subject: [PATCH 05/19] fix: base holder -> indy holder Signed-off-by: Daniel Bluhm --- acapy_plugin_toolbox/holder.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/acapy_plugin_toolbox/holder.py b/acapy_plugin_toolbox/holder.py index 56282831..66c9a6e2 100644 --- a/acapy_plugin_toolbox/holder.py +++ b/acapy_plugin_toolbox/holder.py @@ -8,7 +8,7 @@ from aries_cloudagent.config.injection_context import InjectionContext from aries_cloudagent.core.protocol_registry import ProtocolRegistry -from aries_cloudagent.holder.base import BaseHolder +from aries_cloudagent.indy.holder import IndyHolder from aries_cloudagent.messaging.base_handler import BaseHandler, BaseResponder, RequestContext from aries_cloudagent.protocols.issue_credential.v1_0.routes import ( V10CredentialExchangeListResultSchema, @@ -268,7 +268,7 @@ async def handle(self, context: RequestContext, responder: BaseResponder): #start = int(start) if isinstance(start, str) else 0 #count = int(count) if isinstance(count, str) else 10 - holder: BaseHolder = await context.inject(BaseHolder) + holder: IndyHolder = await context.inject(IndyHolder) credentials = await holder.get_credentials(start, count, wql) # post_filter_positive = dict( From 2e5145bccf38e4ee16dfbda2461946bb34ab45c6 Mon Sep 17 00:00:00 2001 From: Daniel Bluhm Date: Tue, 15 Dec 2020 15:28:03 -0500 Subject: [PATCH 06/19] fix: mediator conn_record typo Signed-off-by: Daniel Bluhm --- acapy_plugin_toolbox/mediator.py | 1 - 1 file changed, 1 deletion(-) diff --git a/acapy_plugin_toolbox/mediator.py b/acapy_plugin_toolbox/mediator.py index cdd6422d..e304a2a4 100644 --- a/acapy_plugin_toolbox/mediator.py +++ b/acapy_plugin_toolbox/mediator.py @@ -16,7 +16,6 @@ from aries_cloudagent.protocols.routing.v1_0.manager import RoutingManager from aries_cloudagent.protocols.routing.v1_0.models.route_record import RouteRecord, RouteRecordSchema -from aries_cloudagent.connections.models.con import ConnectionRecord from aries_cloudagent.storage.error import StorageNotFoundError from aries_cloudagent.protocols.problem_report.v1_0.message import ProblemReport From f924191cea74f15f1d47419e9d3de263642497b2 Mon Sep 17 00:00:00 2001 From: Daniel Bluhm Date: Tue, 15 Dec 2020 15:50:29 -0500 Subject: [PATCH 07/19] fix: replace context with session in plugin setup Signed-off-by: Daniel Bluhm --- acapy_plugin_toolbox/basicmessage.py | 10 +++--- acapy_plugin_toolbox/connections.py | 6 ++-- .../credential_definitions.py | 6 ++-- acapy_plugin_toolbox/dids.py | 6 ++-- acapy_plugin_toolbox/group/all.py | 32 +++++++++---------- acapy_plugin_toolbox/group/connections.py | 12 +++---- acapy_plugin_toolbox/group/holder.py | 10 +++--- acapy_plugin_toolbox/group/issuance.py | 14 ++++---- acapy_plugin_toolbox/holder.py | 6 ++-- acapy_plugin_toolbox/invitations.py | 6 ++-- acapy_plugin_toolbox/issuer.py | 6 ++-- acapy_plugin_toolbox/mediator.py | 6 ++-- acapy_plugin_toolbox/payments.py | 6 ++-- acapy_plugin_toolbox/routing.py | 6 ++-- acapy_plugin_toolbox/schemas.py | 6 ++-- acapy_plugin_toolbox/static_connections.py | 6 ++-- acapy_plugin_toolbox/taa.py | 6 ++-- 17 files changed, 75 insertions(+), 75 deletions(-) diff --git a/acapy_plugin_toolbox/basicmessage.py b/acapy_plugin_toolbox/basicmessage.py index 27267fbf..f9dd2df5 100644 --- a/acapy_plugin_toolbox/basicmessage.py +++ b/acapy_plugin_toolbox/basicmessage.py @@ -6,7 +6,7 @@ from marshmallow import fields -from aries_cloudagent.config.injection_context import InjectionContext +from aries_cloudagent.core.profile import ProfileSession from aries_cloudagent.core.protocol_registry import ProtocolRegistry from aries_cloudagent.connections.models.conn_record import ( ConnRecord @@ -48,12 +48,12 @@ async def setup( - context: InjectionContext, + session: ProfileSession, protocol_registry: ProblemReport = None ): """Setup the basicmessage plugin.""" if not protocol_registry: - protocol_registry = await context.inject(ProtocolRegistry) + protocol_registry = session.inject(ProtocolRegistry) protocol_registry.register_message_types( MESSAGE_TYPES ) @@ -122,11 +122,11 @@ def record_tags(self) -> dict: @classmethod async def retrieve_by_message_id( cls, - context: InjectionContext, + session: ProfileSession, message_id: str) -> "BasicMessageRecord": """Retrieve a basic message record by message id.""" return await cls.retrieve_by_tag_filter( - context, + session, {'message_id': message_id} ) diff --git a/acapy_plugin_toolbox/connections.py b/acapy_plugin_toolbox/connections.py index bf64c769..64dad94d 100644 --- a/acapy_plugin_toolbox/connections.py +++ b/acapy_plugin_toolbox/connections.py @@ -7,7 +7,7 @@ from marshmallow import Schema, fields, validate -from aries_cloudagent.config.injection_context import InjectionContext +from aries_cloudagent.core.profile import ProfileSession from aries_cloudagent.core.protocol_registry import ProtocolRegistry from aries_cloudagent.messaging.base_handler import BaseHandler, BaseResponder, RequestContext from aries_cloudagent.protocols.connections.v1_0.manager import ConnectionManager @@ -50,12 +50,12 @@ async def setup( - context: InjectionContext, + session: ProfileSession, protocol_registry: ProtocolRegistry = None ): """Setup the connections plugin.""" if not protocol_registry: - protocol_registry = await context.inject(ProtocolRegistry) + protocol_registry = session.inject(ProtocolRegistry) protocol_registry.register_message_types( MESSAGE_TYPES diff --git a/acapy_plugin_toolbox/credential_definitions.py b/acapy_plugin_toolbox/credential_definitions.py index aced4261..f62b1dc6 100644 --- a/acapy_plugin_toolbox/credential_definitions.py +++ b/acapy_plugin_toolbox/credential_definitions.py @@ -7,7 +7,7 @@ from marshmallow import fields -from aries_cloudagent.config.injection_context import InjectionContext +from aries_cloudagent.core.profile import ProfileSession from aries_cloudagent.core.protocol_registry import ProtocolRegistry from aries_cloudagent.messaging.base_handler import BaseHandler, BaseResponder, RequestContext from aries_cloudagent.messaging.models.base_record import BaseRecord, BaseRecordSchema @@ -48,12 +48,12 @@ async def setup( - context: InjectionContext, + session: ProfileSession, protocol_registry: ProblemReport = None ): """Setup the cred def plugin.""" if not protocol_registry: - protocol_registry = await context.inject(ProtocolRegistry) + protocol_registry = session.inject(ProtocolRegistry) protocol_registry.register_message_types( MESSAGE_TYPES ) diff --git a/acapy_plugin_toolbox/dids.py b/acapy_plugin_toolbox/dids.py index bb0929af..70948869 100644 --- a/acapy_plugin_toolbox/dids.py +++ b/acapy_plugin_toolbox/dids.py @@ -6,7 +6,7 @@ from typing import Dict from marshmallow import fields -from aries_cloudagent.config.injection_context import InjectionContext +from aries_cloudagent.core.profile import ProfileSession from aries_cloudagent.core.protocol_registry import ProtocolRegistry from aries_cloudagent.messaging.base_handler import BaseHandler, BaseResponder, RequestContext from aries_cloudagent.messaging.models.base_record import BaseRecord, BaseRecordSchema @@ -62,12 +62,12 @@ async def setup( - context: InjectionContext, + session: ProfileSession, protocol_registry: ProtocolRegistry = None ): """Setup the dids plugin.""" if not protocol_registry: - protocol_registry = await context.inject(ProtocolRegistry) + protocol_registry = session.inject(ProtocolRegistry) protocol_registry.register_message_types( MESSAGE_TYPES ) diff --git a/acapy_plugin_toolbox/group/all.py b/acapy_plugin_toolbox/group/all.py index ccc23ddb..cece6344 100644 --- a/acapy_plugin_toolbox/group/all.py +++ b/acapy_plugin_toolbox/group/all.py @@ -1,6 +1,6 @@ """Load all plugins.""" -from aries_cloudagent.config.injection_context import InjectionContext +from aries_cloudagent.core.profile import ProfileSession from aries_cloudagent.core.protocol_registry import ProtocolRegistry from ..connections import setup as connection_setup @@ -17,19 +17,19 @@ from ..mediator import setup as mediator_setup from ..routing import setup as routing_setup -async def setup(context: InjectionContext): +async def setup(session: ProfileSession): """Setup Toolbox Plugin.""" - protocol_registry = await context.inject(ProtocolRegistry) - await connection_setup(context, protocol_registry) - await cred_def_setup(context, protocol_registry) - await schema_setup(context, protocol_registry) - await did_setup(context, protocol_registry) - await static_conn_setup(context, protocol_registry) - await holder_setup(context, protocol_registry) - await issuer_setup(context, protocol_registry) - await basic_message_setup(context, protocol_registry) - await taa_setup(context, protocol_registry) -# await payment_setup(context, protocol_registry) - await invitations_setup(context, protocol_registry) - await mediator_setup(context, protocol_registry) - await routing_setup(context, protocol_registry) + protocol_registry = session.inject(ProtocolRegistry) + await connection_setup(session, protocol_registry) + await cred_def_setup(session, protocol_registry) + await schema_setup(session, protocol_registry) + await did_setup(session, protocol_registry) + await static_conn_setup(session, protocol_registry) + await holder_setup(session, protocol_registry) + await issuer_setup(session, protocol_registry) + await basic_message_setup(session, protocol_registry) + await taa_setup(session, protocol_registry) +# await payment_setup(session, protocol_registry) + await invitations_setup(session, protocol_registry) + await mediator_setup(session, protocol_registry) + await routing_setup(session, protocol_registry) diff --git a/acapy_plugin_toolbox/group/connections.py b/acapy_plugin_toolbox/group/connections.py index 3a1c8b82..a7377d8a 100644 --- a/acapy_plugin_toolbox/group/connections.py +++ b/acapy_plugin_toolbox/group/connections.py @@ -1,15 +1,15 @@ """Load connections plugins.""" -from aries_cloudagent.config.injection_context import InjectionContext +from aries_cloudagent.core.profile import ProfileSession from aries_cloudagent.core.protocol_registry import ProtocolRegistry from ..connections import setup as connection_setup from ..static_connections import setup as static_conn_setup from ..invitations import setup as invitations_setup -async def setup(context: InjectionContext): +async def setup(session: ProfileSession): """Setup Toolbox Plugin.""" - protocol_registry = await context.inject(ProtocolRegistry) - await connection_setup(context, protocol_registry) - await static_conn_setup(context, protocol_registry) - await invitations_setup(context, protocol_registry) \ No newline at end of file + protocol_registry = session.inject(ProtocolRegistry) + await connection_setup(session, protocol_registry) + await static_conn_setup(session, protocol_registry) + await invitations_setup(session, protocol_registry) diff --git a/acapy_plugin_toolbox/group/holder.py b/acapy_plugin_toolbox/group/holder.py index 0323f621..506b82ec 100644 --- a/acapy_plugin_toolbox/group/holder.py +++ b/acapy_plugin_toolbox/group/holder.py @@ -1,14 +1,14 @@ """Load holder plugins.""" -from aries_cloudagent.config.injection_context import InjectionContext +from aries_cloudagent.core.profile import ProfileSession from aries_cloudagent.core.protocol_registry import ProtocolRegistry from ..credential_definitions import setup as cred_def_setup from ..holder import setup as holder_setup -async def setup(context: InjectionContext): +async def setup(session: ProfileSession): """Setup Toolbox Plugin.""" - protocol_registry = await context.inject(ProtocolRegistry) - await cred_def_setup(context, protocol_registry) - await holder_setup(context, protocol_registry) + protocol_registry = session.inject(ProtocolRegistry) + await cred_def_setup(session, protocol_registry) + await holder_setup(session, protocol_registry) diff --git a/acapy_plugin_toolbox/group/issuance.py b/acapy_plugin_toolbox/group/issuance.py index 5be1aefc..6cbb76d5 100644 --- a/acapy_plugin_toolbox/group/issuance.py +++ b/acapy_plugin_toolbox/group/issuance.py @@ -1,6 +1,6 @@ """Load issuance plugins.""" -from aries_cloudagent.config.injection_context import InjectionContext +from aries_cloudagent.core.profile import ProfileSession from aries_cloudagent.core.protocol_registry import ProtocolRegistry from ..credential_definitions import setup as cred_def_setup @@ -9,10 +9,10 @@ from ..issuer import setup as issuer_setup -async def setup(context: InjectionContext): +async def setup(session: ProfileSession): """Setup Toolbox Plugin.""" - protocol_registry = await context.inject(ProtocolRegistry) - await cred_def_setup(context, protocol_registry) - await schema_setup(context, protocol_registry) - await did_setup(context, protocol_registry) - await issuer_setup(context, protocol_registry) + protocol_registry = session.inject(ProtocolRegistry) + await cred_def_setup(session, protocol_registry) + await schema_setup(session, protocol_registry) + await did_setup(session, protocol_registry) + await issuer_setup(session, protocol_registry) diff --git a/acapy_plugin_toolbox/holder.py b/acapy_plugin_toolbox/holder.py index 66c9a6e2..ee9d3acd 100644 --- a/acapy_plugin_toolbox/holder.py +++ b/acapy_plugin_toolbox/holder.py @@ -6,7 +6,7 @@ from marshmallow import fields import json -from aries_cloudagent.config.injection_context import InjectionContext +from aries_cloudagent.core.profile import ProfileSession from aries_cloudagent.core.protocol_registry import ProtocolRegistry from aries_cloudagent.indy.holder import IndyHolder from aries_cloudagent.messaging.base_handler import BaseHandler, BaseResponder, RequestContext @@ -69,12 +69,12 @@ async def setup( - context: InjectionContext, + session: ProfileSession, protocol_registry: ProblemReport = None ): """Setup the holder plugin.""" if not protocol_registry: - protocol_registry = await context.inject(ProtocolRegistry) + protocol_registry = session.inject(ProtocolRegistry) protocol_registry.register_message_types( MESSAGE_TYPES ) diff --git a/acapy_plugin_toolbox/invitations.py b/acapy_plugin_toolbox/invitations.py index d75eae07..a1715193 100644 --- a/acapy_plugin_toolbox/invitations.py +++ b/acapy_plugin_toolbox/invitations.py @@ -5,7 +5,7 @@ from marshmallow import Schema, fields -from aries_cloudagent.config.injection_context import InjectionContext +from aries_cloudagent.core.profile import ProfileSession from aries_cloudagent.core.protocol_registry import ProtocolRegistry from aries_cloudagent.messaging.base_handler import ( BaseHandler, BaseResponder, RequestContext @@ -47,12 +47,12 @@ async def setup( - context: InjectionContext, + session: ProfileSession, protocol_registry: ProtocolRegistry = None ): """Setup the connections plugin.""" if not protocol_registry: - protocol_registry = await context.inject(ProtocolRegistry) + protocol_registry = session.inject(ProtocolRegistry) protocol_registry.register_message_types( MESSAGE_TYPES diff --git a/acapy_plugin_toolbox/issuer.py b/acapy_plugin_toolbox/issuer.py index fe09876b..1df7b375 100644 --- a/acapy_plugin_toolbox/issuer.py +++ b/acapy_plugin_toolbox/issuer.py @@ -8,7 +8,7 @@ from marshmallow import fields -from aries_cloudagent.config.injection_context import InjectionContext +from aries_cloudagent.core.profile import ProfileSession from aries_cloudagent.core.protocol_registry import ProtocolRegistry from aries_cloudagent.messaging.base_handler import BaseHandler, BaseResponder, RequestContext from aries_cloudagent.messaging.decorators.attach_decorator import AttachDecorator @@ -72,12 +72,12 @@ async def setup( - context: InjectionContext, + session: ProfileSession, protocol_registry: ProblemReport = None ): """Setup the issuer plugin.""" if not protocol_registry: - protocol_registry = await context.inject(ProtocolRegistry) + protocol_registry = session.inject(ProtocolRegistry) protocol_registry.register_message_types( MESSAGE_TYPES ) diff --git a/acapy_plugin_toolbox/mediator.py b/acapy_plugin_toolbox/mediator.py index e304a2a4..733118dd 100644 --- a/acapy_plugin_toolbox/mediator.py +++ b/acapy_plugin_toolbox/mediator.py @@ -8,7 +8,7 @@ from marshmallow import fields -from aries_cloudagent.config.injection_context import InjectionContext +from aries_cloudagent.core.profile import ProfileSession from aries_cloudagent.core.protocol_registry import ProtocolRegistry from aries_cloudagent.messaging.base_handler import BaseHandler, BaseResponder, RequestContext from aries_cloudagent.messaging.decorators.attach_decorator import AttachDecorator @@ -32,12 +32,12 @@ async def setup( - context: InjectionContext, + session: ProfileSession, protocol_registry: ProblemReport = None ): """Setup the issuer plugin.""" if not protocol_registry: - protocol_registry = await context.inject(ProtocolRegistry) + protocol_registry = session.inject(ProtocolRegistry) protocol_registry.register_message_types( MESSAGE_TYPES ) diff --git a/acapy_plugin_toolbox/payments.py b/acapy_plugin_toolbox/payments.py index f08ba2b6..2681a1d8 100644 --- a/acapy_plugin_toolbox/payments.py +++ b/acapy_plugin_toolbox/payments.py @@ -16,7 +16,7 @@ from aries_cloudagent.ledger.base import BaseLedger from aries_cloudagent.ledger.error import LedgerError from aries_cloudagent.ledger.indy import IndyErrorHandler -from aries_cloudagent.config.injection_context import InjectionContext +from aries_cloudagent.core.profile import ProfileSession from aries_cloudagent.core.protocol_registry import ProtocolRegistry from aries_cloudagent.messaging.base_handler import ( BaseHandler, BaseResponder, RequestContext @@ -69,7 +69,7 @@ def file_ext(): async def setup( - context: InjectionContext, + session: ProfileSession, protocol_registry: ProblemReport = None ): """Load plugin.""" @@ -78,7 +78,7 @@ async def setup( cdll.LoadLibrary(LIBRARY).sovtoken_init() if not protocol_registry: - protocol_registry = await context.inject(ProtocolRegistry) + protocol_registry = session.inject(ProtocolRegistry) protocol_registry.register_message_types( MESSAGE_TYPES ) diff --git a/acapy_plugin_toolbox/routing.py b/acapy_plugin_toolbox/routing.py index d446c699..7b3b63a6 100644 --- a/acapy_plugin_toolbox/routing.py +++ b/acapy_plugin_toolbox/routing.py @@ -6,7 +6,7 @@ from marshmallow import fields -from aries_cloudagent.config.injection_context import InjectionContext +from aries_cloudagent.core.profile import ProfileSession from aries_cloudagent.core.protocol_registry import ProtocolRegistry from aries_cloudagent.connections.models.conn_record import ( ConnRecord @@ -43,12 +43,12 @@ async def setup( - context: InjectionContext, + session: ProfileSession, protocol_registry: ProblemReport = None ): """Setup the basicmessage plugin.""" if not protocol_registry: - protocol_registry = await context.inject(ProtocolRegistry) + protocol_registry = session.inject(ProtocolRegistry) protocol_registry.register_message_types( MESSAGE_TYPES ) diff --git a/acapy_plugin_toolbox/schemas.py b/acapy_plugin_toolbox/schemas.py index 964ac358..50540f16 100644 --- a/acapy_plugin_toolbox/schemas.py +++ b/acapy_plugin_toolbox/schemas.py @@ -7,7 +7,7 @@ from marshmallow import fields -from aries_cloudagent.config.injection_context import InjectionContext +from aries_cloudagent.core.profile import ProfileSession from aries_cloudagent.core.protocol_registry import ProtocolRegistry from aries_cloudagent.messaging.base_handler import BaseHandler, BaseResponder, RequestContext from aries_cloudagent.messaging.models.base_record import BaseRecord, BaseRecordSchema @@ -50,12 +50,12 @@ async def setup( - context: InjectionContext, + session: ProfileSession, protocol_registry: ProtocolRegistry = None ): """Setup the schemas plugin.""" if not protocol_registry: - protocol_registry = await context.inject(ProtocolRegistry) + protocol_registry = session.inject(ProtocolRegistry) protocol_registry.register_message_types( MESSAGE_TYPES ) diff --git a/acapy_plugin_toolbox/static_connections.py b/acapy_plugin_toolbox/static_connections.py index 4178ad79..6ca93e23 100644 --- a/acapy_plugin_toolbox/static_connections.py +++ b/acapy_plugin_toolbox/static_connections.py @@ -5,7 +5,7 @@ from marshmallow import fields, validate -from aries_cloudagent.config.injection_context import InjectionContext +from aries_cloudagent.core.profile import ProfileSession from aries_cloudagent.core.protocol_registry import ProtocolRegistry from aries_cloudagent.wallet.base import BaseWallet from aries_cloudagent.messaging.base_handler import BaseHandler, BaseResponder, RequestContext @@ -45,12 +45,12 @@ async def setup( - context: InjectionContext, + session: ProfileSession, protocol_registry: ProblemReport = None ): """Setup the basicmessage plugin.""" if not protocol_registry: - protocol_registry = await context.inject(ProtocolRegistry) + protocol_registry = session.inject(ProtocolRegistry) protocol_registry.register_message_types( MESSAGE_TYPES ) diff --git a/acapy_plugin_toolbox/taa.py b/acapy_plugin_toolbox/taa.py index 36688068..579fd245 100644 --- a/acapy_plugin_toolbox/taa.py +++ b/acapy_plugin_toolbox/taa.py @@ -1,7 +1,7 @@ """Transaction Author Agreement acceptance plugin.""" # pylint: disable=invalid-name, too-few-public-methods -from aries_cloudagent.config.injection_context import InjectionContext +from aries_cloudagent.core.profile import ProfileSession from aries_cloudagent.core.protocol_registry import ProtocolRegistry from marshmallow import fields from aries_cloudagent.messaging.base_handler import ( @@ -33,12 +33,12 @@ async def setup( - context: InjectionContext, + session: ProfileSession, protocol_registry: ProblemReport = None ): """Setup the basicmessage plugin.""" if not protocol_registry: - protocol_registry = await context.inject(ProtocolRegistry) + protocol_registry = session.inject(ProtocolRegistry) protocol_registry.register_message_types( MESSAGE_TYPES ) From 91f82bd7f8821b10fe978713aba3a45d4cdfa7c1 Mon Sep 17 00:00:00 2001 From: Daniel Bluhm Date: Wed, 16 Dec 2020 14:28:07 -0500 Subject: [PATCH 08/19] fix: use metadata "group" for permissioning Signed-off-by: Daniel Bluhm --- acapy_plugin_toolbox/util.py | 32 ++++++++++++++++++-------------- startup.sh | 2 +- 2 files changed, 19 insertions(+), 15 deletions(-) diff --git a/acapy_plugin_toolbox/util.py b/acapy_plugin_toolbox/util.py index 66752092..859735d1 100644 --- a/acapy_plugin_toolbox/util.py +++ b/acapy_plugin_toolbox/util.py @@ -49,22 +49,26 @@ def require_role(role): def _require_role(func): @functools.wraps(func) async def _wrapped( - handler, - context: RequestContext, - responder: BaseResponder): - - if not context.connection_record \ - or context.connection_record.their_role != role: - report = ProblemReport( - explain_ltxt='This connection is not authorized to perform' - ' the requested action.', - who_retries='none' + handler, + context: RequestContext, + responder: BaseResponder + ): + if context.connection_record: + session = await context.session() + group = await context.connection_record.metadata_get( + session, 'group' ) - report.assign_thread_from(context.message) - await responder.send_reply(report) - return + if group == role: + return await func(handler, context, responder) + + report = ProblemReport( + explain_ltxt='This connection is not authorized to perform' + ' the requested action.', + who_retries='none' + ) + report.assign_thread_from(context.message) + await responder.send_reply(report) - return await func(handler, context, responder) return _wrapped return _require_role diff --git a/startup.sh b/startup.sh index 1633d5ad..e06bdde5 100755 --- a/startup.sh +++ b/startup.sh @@ -7,7 +7,7 @@ aca-py start \ --auto-respond-credential-proposal --auto-respond-credential-offer --auto-respond-credential-request --auto-store-credential \ --auto-respond-presentation-proposal --auto-respond-presentation-request --auto-verify-presentation \ --preserve-exchange-records \ - --invite --invite-metadata-json '{"group": "admin"}' --invite-label "$AGENT_NAME (admin)" \ + --connections-invite --invite-metadata-json '{"group": "admin"}' --invite-label "$AGENT_NAME (admin)" \ --genesis-url https://raw.githubusercontent.com/sovrin-foundation/sovrin/master/sovrin/pool_transactions_sandbox_genesis \ --wallet-type indy --wallet-name "$AGENT_NAME" --wallet-key "insecure" --auto-provision \ --plugin acapy_plugin_toolbox \ From 251de7e6d95273009bb5640dff2ad9bda16d97e1 Mon Sep 17 00:00:00 2001 From: Daniel Bluhm Date: Wed, 16 Dec 2020 14:40:45 -0500 Subject: [PATCH 09/19] fix: connections context to session Signed-off-by: Daniel Bluhm --- acapy_plugin_toolbox/connections.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/acapy_plugin_toolbox/connections.py b/acapy_plugin_toolbox/connections.py index 64dad94d..dd4cba02 100644 --- a/acapy_plugin_toolbox/connections.py +++ b/acapy_plugin_toolbox/connections.py @@ -147,6 +147,7 @@ class GetListHandler(BaseHandler): async def handle(self, context: RequestContext, responder: BaseResponder): """Handle get connection list request.""" + session = await context.session() tag_filter = dict( filter(lambda item: item[1] is not None, { 'my_did': context.message.my_did, @@ -161,7 +162,7 @@ async def handle(self, context: RequestContext, responder: BaseResponder): )) # TODO: Filter on state (needs mapping back to ACA-Py connection states) records = await ConnRecord.query( - context, tag_filter, post_filter_positive + session, tag_filter, post_filter_positive=post_filter_positive ) results = [ Connection(**conn_record_to_message_repr(record)) @@ -190,9 +191,10 @@ class UpdateHandler(BaseHandler): @admin_only async def handle(self, context: RequestContext, responder: BaseResponder): """Handle update connection request.""" + session = await context.session() try: connection = await ConnRecord.retrieve_by_id( - context, + session, context.message.connection_id ) except StorageNotFoundError: @@ -251,9 +253,10 @@ async def handle(self, context: RequestContext, responder: BaseResponder): await responder.send_reply(report) return + session = await context.session() try: connection = await ConnRecord.retrieve_by_id( - context, + session, context.message.connection_id ) except StorageNotFoundError: From 6fe0cecc6d9e424d1fdbd0069b638eca08acea12 Mon Sep 17 00:00:00 2001 From: Daniel Bluhm Date: Wed, 16 Dec 2020 15:01:43 -0500 Subject: [PATCH 10/19] fix: context.inject -> session.inject Signed-off-by: Daniel Bluhm --- acapy_plugin_toolbox/credential_definitions.py | 8 +++++--- acapy_plugin_toolbox/dids.py | 15 ++++++++++----- acapy_plugin_toolbox/holder.py | 3 ++- acapy_plugin_toolbox/payments.py | 14 +++++++++----- acapy_plugin_toolbox/schemas.py | 8 +++++--- acapy_plugin_toolbox/static_connections.py | 6 ++++-- acapy_plugin_toolbox/taa.py | 9 ++++++--- 7 files changed, 41 insertions(+), 22 deletions(-) diff --git a/acapy_plugin_toolbox/credential_definitions.py b/acapy_plugin_toolbox/credential_definitions.py index f62b1dc6..3fda113f 100644 --- a/acapy_plugin_toolbox/credential_definitions.py +++ b/acapy_plugin_toolbox/credential_definitions.py @@ -168,8 +168,9 @@ class SendCredDefHandler(BaseHandler): @admin_only async def handle(self, context: RequestContext, responder: BaseResponder): """Handle received send cred def request.""" - ledger: BaseLedger = await context.inject(BaseLedger) - issuer: IndyIssuer = await context.inject(IndyIssuer) + session = await context.session() + ledger: BaseLedger = session.inject(BaseLedger) + issuer: IndyIssuer = session.inject(IndyIssuer) # If no schema record, make one try: schema_record = await SchemaRecord.retrieve_by_schema_id( @@ -267,7 +268,8 @@ async def handle(self, context: RequestContext, responder: BaseResponder): except StorageNotFoundError: pass - ledger: BaseLedger = await context.inject(BaseLedger) + session = await context.session() + ledger: BaseLedger = session.inject(BaseLedger) async with ledger: credential_definition = await ledger.get_credential_definition( context.message.cred_def_id diff --git a/acapy_plugin_toolbox/dids.py b/acapy_plugin_toolbox/dids.py index 70948869..b600e2a6 100644 --- a/acapy_plugin_toolbox/dids.py +++ b/acapy_plugin_toolbox/dids.py @@ -226,7 +226,8 @@ class CreateDidHandler(BaseHandler): @admin_only async def handle(self, context: RequestContext, responder: BaseResponder): - wallet: BaseWallet = await context.inject(BaseWallet) + session = await context.session() + wallet: BaseWallet = session.inject(BaseWallet) did = context.message.did if context.message.did else None seed = context.message.seed if context.message.seed else None @@ -244,7 +245,8 @@ class ListDidHandler(BaseHandler): @admin_only async def handle(self, context: RequestContext, responder: BaseResponder): - wallet: BaseWallet = await context.inject(BaseWallet) + session = await context.session() + wallet: BaseWallet = session.inject(BaseWallet) # Get list of all DIDs in the wallet results = [] @@ -273,7 +275,8 @@ class GetPublicDidHandler(BaseHandler): @admin_only async def handle(self, context: RequestContext, responder: BaseResponder): """Look for the public DID""" - wallet: BaseWallet = await context.inject(BaseWallet) + session = await context.session() + wallet: BaseWallet = session.inject(BaseWallet) did_info = await wallet.get_public_did() result = get_reply_did(did_info) @@ -287,7 +290,8 @@ class SetPublicDidHandler(BaseHandler): @admin_only async def handle(self, context: RequestContext, responder: BaseResponder): """"Set the public DID""" - wallet: BaseWallet = await context.inject(BaseWallet) + session = await context.session() + wallet: BaseWallet = session.inject(BaseWallet) await wallet.set_public_did(context.message.did) did_info = await wallet.get_public_did() @@ -302,7 +306,8 @@ class SetDidMetadataHandler(BaseHandler): @admin_only async def handle(self, context: RequestContext, responder: BaseResponder): """"Set the metadata""" - wallet: BaseWallet = await context.inject(BaseWallet) + session = await context.session() + wallet: BaseWallet = session.inject(BaseWallet) await wallet.replace_local_did_metadata(context.message.did, context.message.metadata if context.message.metadata else None) diff --git a/acapy_plugin_toolbox/holder.py b/acapy_plugin_toolbox/holder.py index ee9d3acd..418082ff 100644 --- a/acapy_plugin_toolbox/holder.py +++ b/acapy_plugin_toolbox/holder.py @@ -268,7 +268,8 @@ async def handle(self, context: RequestContext, responder: BaseResponder): #start = int(start) if isinstance(start, str) else 0 #count = int(count) if isinstance(count, str) else 10 - holder: IndyHolder = await context.inject(IndyHolder) + session = await context.session() + holder: IndyHolder = session.inject(IndyHolder) credentials = await holder.get_credentials(start, count, wql) # post_filter_positive = dict( diff --git a/acapy_plugin_toolbox/payments.py b/acapy_plugin_toolbox/payments.py index 2681a1d8..1e344c56 100644 --- a/acapy_plugin_toolbox/payments.py +++ b/acapy_plugin_toolbox/payments.py @@ -179,7 +179,8 @@ async def handle(self, context: RequestContext, responder: BaseResponder): await responder.send_reply(report) return - ledger: BaseLedger = await context.inject(BaseLedger) + session = await context.session() + ledger: BaseLedger = session.inject(BaseLedger) try: addresses = json.loads( await payment.list_payment_addresses(ledger.wallet.handle) @@ -250,8 +251,9 @@ class CreateAddressHandler(BaseHandler): @admin_only async def handle(self, context: RequestContext, responder: BaseResponder): """Handle received create address requests.""" - wallet: BaseWallet = await context.inject(BaseWallet) - ledger: BaseLedger = await context.inject(BaseLedger) + session = await context.session() + wallet: BaseWallet = session.inject(BaseWallet) + ledger: BaseLedger = session.inject(BaseLedger) if context.message.method != SOV_METHOD: report = ProblemReport( explain_ltxt=( @@ -404,7 +406,8 @@ class GetFeesHandler(BaseHandler): @admin_only async def handle(self, context: RequestContext, responder: BaseResponder): """Handle get fees.""" - ledger: BaseLedger = await context.inject(BaseLedger) + session = await context.session() + ledger: BaseLedger = session.inject(BaseLedger) if context.message.method != SOV_METHOD: report = ProblemReport( explain_ltxt=( @@ -605,7 +608,8 @@ class TransferHandler(BaseHandler): @admin_only async def handle(self, context: RequestContext, responder: BaseResponder): """Handle payment""" - ledger: BaseLedger = await context.inject(BaseLedger) + session = await context.session() + ledger: BaseLedger = session.inject(BaseLedger) if context.message.method != SOV_METHOD: report = ProblemReport( explain_ltxt=( diff --git a/acapy_plugin_toolbox/schemas.py b/acapy_plugin_toolbox/schemas.py index 50540f16..28e971f8 100644 --- a/acapy_plugin_toolbox/schemas.py +++ b/acapy_plugin_toolbox/schemas.py @@ -179,8 +179,9 @@ class SendSchemaHandler(BaseHandler): @admin_only async def handle(self, context: RequestContext, responder: BaseResponder): """Handle received send schema request.""" - ledger: BaseLedger = await context.inject(BaseLedger) - issuer: IndyIssuer = await context.inject(IndyIssuer) + session = await context.session() + ledger: BaseLedger = session.inject(BaseLedger) + issuer: IndyIssuer = session.inject(IndyIssuer) async with ledger: schema_id, schema_def = await shield( ledger.create_and_send_schema( @@ -240,7 +241,8 @@ async def handle(self, context: RequestContext, responder: BaseResponder): except StorageNotFoundError: pass - ledger: BaseLedger = await context.inject(BaseLedger) + session = await context.session() + ledger: BaseLedger = session.inject(BaseLedger) async with ledger: schema = await ledger.get_schema(context.message.schema_id) diff --git a/acapy_plugin_toolbox/static_connections.py b/acapy_plugin_toolbox/static_connections.py index 6ca93e23..18c90a0c 100644 --- a/acapy_plugin_toolbox/static_connections.py +++ b/acapy_plugin_toolbox/static_connections.py @@ -91,7 +91,8 @@ async def handle(self, context: RequestContext, responder: BaseResponder): """Handle static connection creation request.""" connection_mgr = ConnectionManager(context) - wallet: BaseWallet = await context.inject(BaseWallet) + session = await context.session() + wallet: BaseWallet = session.inject(BaseWallet) # Make our info for the connection my_info = await wallet.create_local_did() @@ -193,7 +194,8 @@ class StaticConnectionGetListHandler(BaseHandler): async def handle(self, context: RequestContext, responder: BaseResponder): """Handle static connection get list request.""" connection_mgr = ConnectionManager(context) - wallet: BaseWallet = await context.inject(BaseWallet) + session = await context.session() + wallet: BaseWallet = session.inject(BaseWallet) try: tag_filter = dict( filter(lambda item: item[1] is not None, { diff --git a/acapy_plugin_toolbox/taa.py b/acapy_plugin_toolbox/taa.py index 579fd245..e9fff118 100644 --- a/acapy_plugin_toolbox/taa.py +++ b/acapy_plugin_toolbox/taa.py @@ -79,7 +79,8 @@ class GetHandler(BaseHandler): @admin_only async def handle(self, context: RequestContext, responder: BaseResponder): """Handle received get request.""" - ledger: BaseLedger = await context.inject(BaseLedger, required=False) + session = await context.session() + ledger: BaseLedger = session.inject(BaseLedger, required=False) if not ledger or ledger.LEDGER_TYPE != 'indy': report = ProblemReport( explain_ltxt='Invalid ledger.', @@ -143,7 +144,8 @@ class AcceptHandler(BaseHandler): @admin_only async def handle(self, context: RequestContext, responder: BaseResponder): """Handle taa acceptance messages.""" - ledger: BaseLedger = await context.inject(BaseLedger, required=False) + session = await context.session() + ledger: BaseLedger = session.inject(BaseLedger, required=False) if not ledger or ledger.LEDGER_TYPE != 'indy': report = ProblemReport( explain_ltxt='Invalid ledger.', @@ -221,7 +223,8 @@ class GetAcceptanceHandler(BaseHandler): @admin_only async def handle(self, context: RequestContext, responder: BaseResponder): """Handle received get acceptance request.""" - ledger: BaseLedger = await context.inject(BaseLedger, required=False) + session = await context.session() + ledger: BaseLedger = session.inject(BaseLedger, required=False) if not ledger or ledger.LEDGER_TYPE != 'indy': report = ProblemReport( explain_ltxt='Invalid ledger.', From c7196216095383d4f2a757f0517bd6ac899694fc Mon Sep 17 00:00:00 2001 From: Daniel Bluhm Date: Wed, 16 Dec 2020 15:06:37 -0500 Subject: [PATCH 11/19] fix: taa checking Ledger is Indy Signed-off-by: Daniel Bluhm --- acapy_plugin_toolbox/taa.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/acapy_plugin_toolbox/taa.py b/acapy_plugin_toolbox/taa.py index e9fff118..2bdcfb22 100644 --- a/acapy_plugin_toolbox/taa.py +++ b/acapy_plugin_toolbox/taa.py @@ -81,7 +81,7 @@ async def handle(self, context: RequestContext, responder: BaseResponder): """Handle received get request.""" session = await context.session() ledger: BaseLedger = session.inject(BaseLedger, required=False) - if not ledger or ledger.LEDGER_TYPE != 'indy': + if not ledger or ledger.BACKEND_NAME != 'indy': report = ProblemReport( explain_ltxt='Invalid ledger.', who_retries='none' @@ -146,7 +146,7 @@ async def handle(self, context: RequestContext, responder: BaseResponder): """Handle taa acceptance messages.""" session = await context.session() ledger: BaseLedger = session.inject(BaseLedger, required=False) - if not ledger or ledger.LEDGER_TYPE != 'indy': + if not ledger or ledger.BACKEND_NAME != 'indy': report = ProblemReport( explain_ltxt='Invalid ledger.', who_retries='none' @@ -225,7 +225,7 @@ async def handle(self, context: RequestContext, responder: BaseResponder): """Handle received get acceptance request.""" session = await context.session() ledger: BaseLedger = session.inject(BaseLedger, required=False) - if not ledger or ledger.LEDGER_TYPE != 'indy': + if not ledger or ledger.BACKEND_NAME != 'indy': report = ProblemReport( explain_ltxt='Invalid ledger.', who_retries='none' From 6126a9d2baa3e8d8d0177bc2258d8aa791cca45a Mon Sep 17 00:00:00 2001 From: Daniel Bluhm Date: Wed, 16 Dec 2020 15:11:42 -0500 Subject: [PATCH 12/19] fix: context vs session in record queries and post_filter fixes Signed-off-by: Daniel Bluhm --- acapy_plugin_toolbox/basicmessage.py | 9 ++++++--- acapy_plugin_toolbox/credential_definitions.py | 3 ++- acapy_plugin_toolbox/holder.py | 5 ++++- acapy_plugin_toolbox/invitations.py | 3 ++- acapy_plugin_toolbox/issuer.py | 10 ++++++++-- acapy_plugin_toolbox/schemas.py | 3 ++- acapy_plugin_toolbox/static_connections.py | 4 +++- 7 files changed, 27 insertions(+), 10 deletions(-) diff --git a/acapy_plugin_toolbox/basicmessage.py b/acapy_plugin_toolbox/basicmessage.py index f9dd2df5..5bc87df8 100644 --- a/acapy_plugin_toolbox/basicmessage.py +++ b/acapy_plugin_toolbox/basicmessage.py @@ -237,8 +237,9 @@ async def handle(self, context: RequestContext, responder: BaseResponder): ) connection_mgr = ConnectionManager(context) + session = await context.session() admins = await ConnRecord.query( - context, post_filter_positive={'their_role': 'admin'} + session, post_filter_positive={'their_role': 'admin'} ) if not admins: @@ -301,12 +302,13 @@ class GetHandler(BaseHandler): @admin_only async def handle(self, context: RequestContext, responder: BaseResponder): """Handle received get requests.""" + session = await context.session() tag_filter = dict(filter(lambda item: item[1] is not None, { 'connection_id': context.message.connection_id, }.items())) msgs = sorted( await BasicMessageRecord.query( - context, + session, tag_filter ), key=lambda msg: datetime_from_iso(msg.sent_time), @@ -442,12 +444,13 @@ class DeleteHandler(BaseHandler): @admin_only async def handle(self, context: RequestContext, responder: BaseResponder): """Handle received delete requests.""" + session = await context.session() tag_filter = dict(filter(lambda item: item[1] is not None, { 'connection_id': context.message.connection_id, 'message_id': context.message.message_id, }.items())) msgs = await BasicMessageRecord.query( - context, + session, tag_filter ) if context.message.before_date: diff --git a/acapy_plugin_toolbox/credential_definitions.py b/acapy_plugin_toolbox/credential_definitions.py index 3fda113f..f0ef97eb 100644 --- a/acapy_plugin_toolbox/credential_definitions.py +++ b/acapy_plugin_toolbox/credential_definitions.py @@ -343,7 +343,8 @@ class CredDefGetListHandler(BaseHandler): @admin_only async def handle(self, context: RequestContext, responder: BaseResponder): """Handle get schema list request.""" - records = await CredDefRecord.query(context, {}) + session = await context.session() + records = await CredDefRecord.query(session, {}) cred_def_list = CredDefList(results=records) cred_def_list.assign_thread_from(context.message) await responder.send_reply(cred_def_list) diff --git a/acapy_plugin_toolbox/holder.py b/acapy_plugin_toolbox/holder.py index 418082ff..a9d687a2 100644 --- a/acapy_plugin_toolbox/holder.py +++ b/acapy_plugin_toolbox/holder.py @@ -314,6 +314,7 @@ class PresGetListHandler(BaseHandler): async def handle(self, context: RequestContext, responder: BaseResponder): """Handle received get cred list request.""" + session = await context.session() post_filter_positive = dict( filter(lambda item: item[1] is not None, { # 'state': V10PresentialExchange.STATE_CREDENTIAL_RECEIVED, @@ -322,6 +323,8 @@ async def handle(self, context: RequestContext, responder: BaseResponder): 'verified': context.message.verified, }.items()) ) - records = await V10PresentationExchange.query(context, {}, post_filter_positive) + records = await V10PresentationExchange.query( + session, {}, post_filter_positive=post_filter_positive + ) cred_list = PresList(results=records) await responder.send_reply(cred_list) diff --git a/acapy_plugin_toolbox/invitations.py b/acapy_plugin_toolbox/invitations.py index a1715193..19d08900 100644 --- a/acapy_plugin_toolbox/invitations.py +++ b/acapy_plugin_toolbox/invitations.py @@ -169,8 +169,9 @@ async def handle(self, context: RequestContext, responder: BaseResponder): # 'their_role': context.message.their_role }.items() )) + session = await context.session() records = await ConnRecord.query( - context, tag_filter, post_filter_positive + session, tag_filter, post_filter_positive=post_filter_positive ) results = [] for connection in records: diff --git a/acapy_plugin_toolbox/issuer.py b/acapy_plugin_toolbox/issuer.py index 1df7b375..5872f775 100644 --- a/acapy_plugin_toolbox/issuer.py +++ b/acapy_plugin_toolbox/issuer.py @@ -269,7 +269,10 @@ async def handle(self, context: RequestContext, responder: BaseResponder): 'schema_id': context.message.schema_id }.items()) ) - records = await V10CredentialExchange.query(context, {}, post_filter_positive) + session = await context.session() + records = await V10CredentialExchange.query( + session, {}, post_filter_positive=post_filter_positive + ) cred_list = CredList(results=records) await responder.send_reply(cred_list) @@ -310,6 +313,9 @@ async def handle(self, context: RequestContext, responder: BaseResponder): 'verified': context.message.verified, }.items()) ) - records = await V10PresentationExchange.query(context, {}, post_filter_positive) + session = await context.session() + records = await V10PresentationExchange.query( + session, {}, post_filter_positive=post_filter_positive + ) cred_list = PresList(results=records) await responder.send_reply(cred_list) diff --git a/acapy_plugin_toolbox/schemas.py b/acapy_plugin_toolbox/schemas.py index 28e971f8..a1bc1fe2 100644 --- a/acapy_plugin_toolbox/schemas.py +++ b/acapy_plugin_toolbox/schemas.py @@ -287,7 +287,8 @@ class SchemaGetListHandler(BaseHandler): @admin_only async def handle(self, context: RequestContext, responder: BaseResponder): """Handle get schema list request.""" - records = await SchemaRecord.query(context, {}) + session = await context.session(0) + records = await SchemaRecord.query(session, {}) schema_list = SchemaList(results=records) schema_list.assign_thread_from(context.message) await responder.send_reply(schema_list) diff --git a/acapy_plugin_toolbox/static_connections.py b/acapy_plugin_toolbox/static_connections.py index 18c90a0c..87ef36c2 100644 --- a/acapy_plugin_toolbox/static_connections.py +++ b/acapy_plugin_toolbox/static_connections.py @@ -211,7 +211,9 @@ async def handle(self, context: RequestContext, responder: BaseResponder): 'their_role': context.message.their_role }.items()) ) - records = await ConnRecord.query(context, tag_filter, post_filter_positive) + records = await ConnRecord.query( + session, tag_filter, post_filter_positive=post_filter_positive + ) except StorageNotFoundError: report = ProblemReport( explain_ltxt='Connection not found.', From af2e2142bd6ad0e141b0621f49642fb7f0fc0f77 Mon Sep 17 00:00:00 2001 From: Daniel Bluhm Date: Wed, 16 Dec 2020 15:14:52 -0500 Subject: [PATCH 13/19] fix: context vs session in invite retrieval Signed-off-by: Daniel Bluhm --- acapy_plugin_toolbox/invitations.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/acapy_plugin_toolbox/invitations.py b/acapy_plugin_toolbox/invitations.py index 19d08900..42ac5a34 100644 --- a/acapy_plugin_toolbox/invitations.py +++ b/acapy_plugin_toolbox/invitations.py @@ -176,7 +176,7 @@ async def handle(self, context: RequestContext, responder: BaseResponder): results = [] for connection in records: try: - invitation = await connection.retrieve_invitation(context) + invitation = await connection.retrieve_invitation(session) except StorageNotFoundError: continue From 605193f8f4a8ab2d527d87391dbd4e46b3d299ba Mon Sep 17 00:00:00 2001 From: Daniel Bluhm Date: Wed, 16 Dec 2020 15:15:12 -0500 Subject: [PATCH 14/19] fix: correct typo in session retrieval Signed-off-by: Daniel Bluhm --- acapy_plugin_toolbox/schemas.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/acapy_plugin_toolbox/schemas.py b/acapy_plugin_toolbox/schemas.py index a1bc1fe2..04025f41 100644 --- a/acapy_plugin_toolbox/schemas.py +++ b/acapy_plugin_toolbox/schemas.py @@ -287,7 +287,7 @@ class SchemaGetListHandler(BaseHandler): @admin_only async def handle(self, context: RequestContext, responder: BaseResponder): """Handle get schema list request.""" - session = await context.session(0) + session = await context.session() records = await SchemaRecord.query(session, {}) schema_list = SchemaList(results=records) schema_list.assign_thread_from(context.message) From c98ab1af4852cd70b44f965682fe8033a148acf0 Mon Sep 17 00:00:00 2001 From: Daniel Bluhm Date: Wed, 16 Dec 2020 15:30:14 -0500 Subject: [PATCH 15/19] chore: point to branch with additional fixes Signed-off-by: Daniel Bluhm --- requirements.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/requirements.txt b/requirements.txt index c1ff27ab..f34bb7a9 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,4 +1,4 @@ -aries-cloudagent[indy]@git+https://github.com/dbluhm/aries-cloudagent-python@feature/assign-metadata-to-invite +aries-cloudagent[indy]@git+https://github.com/dbluhm/aries-cloudagent-python@toolbox-updating marshmallow==3.5.1 flake8 python-dateutil From 92b7fff77d774c8353b6f0745ee297750c1d4dd0 Mon Sep 17 00:00:00 2001 From: Daniel Bluhm Date: Fri, 18 Dec 2020 09:34:09 -0500 Subject: [PATCH 16/19] fix: remove role from connections admin messages Signed-off-by: Daniel Bluhm --- acapy_plugin_toolbox/connections.py | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/acapy_plugin_toolbox/connections.py b/acapy_plugin_toolbox/connections.py index dd4cba02..67599023 100644 --- a/acapy_plugin_toolbox/connections.py +++ b/acapy_plugin_toolbox/connections.py @@ -75,7 +75,6 @@ async def setup( required=True ), 'their_did': fields.Str(required=False), # May be missing if pending - 'role': fields.Str(required=False), 'raw_repr': fields.Dict(required=False) }) @@ -101,7 +100,6 @@ def _state_map(state: str) -> str: 'my_did': conn.my_did, 'their_did': conn.their_did, 'state': _state_map(conn.state), - 'role': conn.their_role, 'connection_id': conn.connection_id, 'raw_repr': conn.serialize() } @@ -122,7 +120,6 @@ def _state_map(state: str) -> str: required=False ), 'their_did': fields.Str(required=False), - 'role': fields.Str(required=False) } ) @@ -154,15 +151,9 @@ async def handle(self, context: RequestContext, responder: BaseResponder): 'their_did': context.message.their_did, }.items()) ) - post_filter_positive = dict(filter( - lambda item: item[1] is not None, - { - 'their_role': context.message.role - }.items() - )) # TODO: Filter on state (needs mapping back to ACA-Py connection states) records = await ConnRecord.query( - session, tag_filter, post_filter_positive=post_filter_positive + session, tag_filter ) results = [ Connection(**conn_record_to_message_repr(record)) @@ -180,7 +171,6 @@ async def handle(self, context: RequestContext, responder: BaseResponder): schema={ 'connection_id': fields.Str(required=True), 'label': fields.Str(required=False), - 'role': fields.Str(required=False) } ) @@ -207,8 +197,6 @@ async def handle(self, context: RequestContext, responder: BaseResponder): new_label = context.message.label or connection.their_label connection.their_label = new_label - new_role = context.message.role or connection.their_role - connection.their_role = new_role await connection.save(context, reason="Update request received.") conn_response = Connection( **conn_record_to_message_repr(connection) From 4376eef0a1fefed818424597e9a375e453fa00e0 Mon Sep 17 00:00:00 2001 From: Daniel Bluhm Date: Fri, 18 Dec 2020 09:34:34 -0500 Subject: [PATCH 17/19] fix: unused imports Signed-off-by: Daniel Bluhm --- acapy_plugin_toolbox/mediator.py | 21 ++++++++------------- acapy_plugin_toolbox/routing.py | 29 +++++++++-------------------- 2 files changed, 17 insertions(+), 33 deletions(-) diff --git a/acapy_plugin_toolbox/mediator.py b/acapy_plugin_toolbox/mediator.py index 733118dd..360155ea 100644 --- a/acapy_plugin_toolbox/mediator.py +++ b/acapy_plugin_toolbox/mediator.py @@ -2,24 +2,19 @@ # pylint: disable=invalid-name # pylint: disable=too-few-public-methods -import asyncio - -from uuid import uuid4 - -from marshmallow import fields - from aries_cloudagent.core.profile import ProfileSession from aries_cloudagent.core.protocol_registry import ProtocolRegistry -from aries_cloudagent.messaging.base_handler import BaseHandler, BaseResponder, RequestContext -from aries_cloudagent.messaging.decorators.attach_decorator import AttachDecorator -from aries_cloudagent.messaging.credential_definitions.util import CRED_DEF_TAGS +from aries_cloudagent.messaging.base_handler import ( + BaseHandler, BaseResponder, RequestContext +) +from aries_cloudagent.protocols.problem_report.v1_0.message import ( + ProblemReport +) from aries_cloudagent.protocols.routing.v1_0.manager import RoutingManager -from aries_cloudagent.protocols.routing.v1_0.models.route_record import RouteRecord, RouteRecordSchema +from marshmallow import fields -from aries_cloudagent.storage.error import StorageNotFoundError -from aries_cloudagent.protocols.problem_report.v1_0.message import ProblemReport +from .util import admin_only, generate_model_schema -from .util import generate_model_schema, admin_only PROTOCOL = 'https://github.com/hyperledger/aries-toolbox/tree/master/docs/admin-mediator/0.1' ROUTES_LIST_GET = '{}/routes_list_get'.format(PROTOCOL) diff --git a/acapy_plugin_toolbox/routing.py b/acapy_plugin_toolbox/routing.py index 7b3b63a6..c9b9ecfd 100644 --- a/acapy_plugin_toolbox/routing.py +++ b/acapy_plugin_toolbox/routing.py @@ -1,36 +1,25 @@ """BasicMessage Plugin.""" # pylint: disable=invalid-name, too-few-public-methods -from typing import Union -from datetime import datetime - -from marshmallow import fields from aries_cloudagent.core.profile import ProfileSession from aries_cloudagent.core.protocol_registry import ProtocolRegistry -from aries_cloudagent.connections.models.conn_record import ( - ConnRecord -) from aries_cloudagent.messaging.base_handler import ( BaseHandler, BaseResponder, RequestContext ) -from aries_cloudagent.messaging.decorators.localization_decorator import ( - LocalizationDecorator +from aries_cloudagent.protocols.problem_report.v1_0.message import ( + ProblemReport ) -from aries_cloudagent.messaging.models.base_record import ( - BaseRecord, BaseRecordSchema +from aries_cloudagent.protocols.routing.v1_0.messages.route_update_request import ( + RouteUpdateRequest ) -from aries_cloudagent.messaging.valid import INDY_ISO8601_DATETIME -from aries_cloudagent.protocols.connections.v1_0.manager import ConnectionManager -from aries_cloudagent.protocols.problem_report.v1_0.message import ProblemReport -from aries_cloudagent.storage.error import StorageNotFoundError - -from aries_cloudagent.protocols.routing.v1_0.messages.route_update_request import RouteUpdateRequest -from aries_cloudagent.protocols.routing.v1_0.models.route_update import RouteUpdate -from aries_cloudagent.protocols.routing.v1_0.messages.route_query_request import RouteQueryRequest +from aries_cloudagent.protocols.routing.v1_0.models.route_update import ( + RouteUpdate +) +from marshmallow import fields from .util import ( - generate_model_schema, admin_only, timestamp_utc_iso, datetime_from_iso + admin_only, generate_model_schema ) ADMIN_PROTOCOL_URI = "https://github.com/hyperledger/" \ From 775ba442f3c4645b012fad94ac42978342d5d9e1 Mon Sep 17 00:00:00 2001 From: Daniel Bluhm Date: Fri, 18 Dec 2020 09:52:21 -0500 Subject: [PATCH 18/19] docs: add versioning note to README Signed-off-by: Daniel Bluhm --- README.md | 21 +++++++++++++++------ 1 file changed, 15 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 794f7819..8a610022 100644 --- a/README.md +++ b/README.md @@ -54,13 +54,19 @@ Quickstart Guide - Running locally Requirements: - Python 3.6 or higher -- ACA-Py @ master +- ACA-Py -> **Note:** This plugin is currently compatible only with the master branch of -> ACA-Py. Once a release including the new plugin interface is published to -> PyPI, these instructions will be updated accordingly. +### ACA-Py Version Compatibility -> TODO: Add instructions for payment plugin loading +To avoid a confusing pseudo-lock-step release, this plugin is +versioned independent of ACA-Py. Plugin releases will follow standard +[semver](semver.org) but each release will also be tagged with a mapping to an +ACA-Py version with the format `acapy-X.Y.Z-J` where `X.Y.Z` corresponds to the +ACA-Py version supported and `J` is an incrementing number for each new plugin +release that targets the same version of ACA-Py. + +You should look for the most recent release tagged with the version of ACA-Py +you are using (with the highest value for `J`). ### Setup Aries Cloud Agent - Python @@ -93,9 +99,12 @@ $ pip install -e .[indy] Install this plugin into the virtual environment: ```sh -$ pip install git+https://github.com/hyperledger/aries-acapy-plugin-toolbox.git@master#egg=acapy-plugin-toolbox +$ pip install git+https://github.com/hyperledger/aries-acapy-plugin-toolbox.git@master#egg=acapy_plugin_toolbox ``` +**Note:** Depending on your version of `pip`, you may need to drop the +`#egg=...` to install the plugin with the above command. + ### Plugin Loading Start up ACA-Py with the plugin parameter: ```sh From 0188a96204b28a2ec6e3b972fc6a8620c55cf881 Mon Sep 17 00:00:00 2001 From: Daniel Bluhm Date: Fri, 18 Dec 2020 09:53:09 -0500 Subject: [PATCH 19/19] fix: remove their_role from invitations Signed-off-by: Daniel Bluhm --- acapy_plugin_toolbox/invitations.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/acapy_plugin_toolbox/invitations.py b/acapy_plugin_toolbox/invitations.py index 42ac5a34..29b39d4b 100644 --- a/acapy_plugin_toolbox/invitations.py +++ b/acapy_plugin_toolbox/invitations.py @@ -122,7 +122,6 @@ async def handle(self, context: RequestContext, responder: BaseResponder): connection_mgr = ConnectionManager(context) connection, invitation = await connection_mgr.create_invitation( my_label=context.message.label, - their_role=context.message.role, auto_accept=context.message.auto_accept, multi_use=bool(context.message.multi_use), public=False, @@ -132,7 +131,6 @@ async def handle(self, context: RequestContext, responder: BaseResponder): id=connection.connection_id, label=invitation.label, alias=connection.alias, - role=connection.their_role, auto_accept=connection.accept == ConnRecord.ACCEPT_AUTO, multi_use=( connection.invitation_mode == @@ -166,7 +164,6 @@ async def handle(self, context: RequestContext, responder: BaseResponder): { 'state': 'invitation', # 'initiator': context.message.initiator, - # 'their_role': context.message.their_role }.items() )) session = await context.session() @@ -184,7 +181,6 @@ async def handle(self, context: RequestContext, responder: BaseResponder): 'id': connection.connection_id, 'label': invitation.label, 'alias': connection.alias, - 'role': connection.their_role, 'auto_accept': ( connection.accept == ConnRecord.ACCEPT_AUTO ),