diff --git a/aries_cloudagent/protocols/didexchange/v1_0/manager.py b/aries_cloudagent/protocols/didexchange/v1_0/manager.py index b209114b01..58a03d4a2c 100644 --- a/aries_cloudagent/protocols/didexchange/v1_0/manager.py +++ b/aries_cloudagent/protocols/didexchange/v1_0/manager.py @@ -183,6 +183,8 @@ async def create_request_implicit( mediation_id: str = None, use_public_did: bool = False, alias: str = None, + goal_code: str = None, + goal: str = None, ) -> ConnRecord: """ Create and send a request against a public DID only (no explicit invitation). @@ -193,6 +195,8 @@ async def create_request_implicit( my_endpoint: my endpoint mediation_id: record id for mediation with routing_keys, service endpoint use_public_did: use my public DID for this connection + goal_code: Optional self-attested code for sharing intent of connection + goal: Optional self-attested string for sharing intent of connection Returns: The new `ConnRecord` instance @@ -225,6 +229,8 @@ async def create_request_implicit( my_label=my_label, my_endpoint=my_endpoint, mediation_id=mediation_id, + goal_code=goal_code, + goal=goal, ) conn_rec.request_id = request._id conn_rec.state = ConnRecord.State.REQUEST.rfc23 @@ -242,6 +248,8 @@ async def create_request( my_label: str = None, my_endpoint: str = None, mediation_id: str = None, + goal_code: str = None, + goal: str = None, ) -> DIDXRequest: """ Create a new connection request for a previously-received invitation. @@ -252,7 +260,8 @@ async def create_request( my_endpoint: My endpoint mediation_id: The record id for mediation that contains routing_keys and service endpoint - + goal_code: Optional self-attested code for sharing intent of connection + goal: Optional self-attested string for sharing intent of connection Returns: A new `DIDXRequest` message to send to the other agent @@ -327,6 +336,8 @@ async def create_request( label=my_label, did=conn_rec.my_did, did_doc_attach=attach, + goal_code=goal_code, + goal=goal, ) request.assign_thread_id(thid=request._id, pthid=pthid) diff --git a/aries_cloudagent/protocols/didexchange/v1_0/messages/request.py b/aries_cloudagent/protocols/didexchange/v1_0/messages/request.py index f6fbc19976..cbf465a59d 100644 --- a/aries_cloudagent/protocols/didexchange/v1_0/messages/request.py +++ b/aries_cloudagent/protocols/didexchange/v1_0/messages/request.py @@ -30,6 +30,8 @@ def __init__( label: str = None, did: str = None, did_doc_attach: AttachDecorator = None, + goal_code: str = None, + goal: str = None, **kwargs, ): """ @@ -39,11 +41,20 @@ def __init__( label: Label for this request did: DID for this request did_doc_attach: signed DID doc attachment + goal_code: (optional) is a self-attested code the receiver may want to + display to the user or use in automatically deciding what to do with + the request message. The goal code might be used particularly when the + request is sent to a resolvable DID without reference to a specfic + invitation. + goal: (optional) is a self-attested string that the receiver may want to + display to the user about the context-specific goal of the request message. """ super().__init__(**kwargs) self.label = label self.did = did self.did_doc_attach = did_doc_attach + self.goal_code = goal_code + self.goal = goal class DIDXRequestSchema(AgentMessageSchema): @@ -67,3 +78,15 @@ class Meta: description="As signed attachment, DID Doc associated with DID", data_key="did_doc~attach", ) + goal_code = fields.Str( + required=False, + description="A self-attested code the receiver may want to display to the user " + "or use in automatically deciding what to do with the out-of-band message", + example="issue-vc", + ) + goal = fields.Str( + required=False, + description="A self-attested string that the receiver may want to display to the " + "user about the context-specific goal of the out-of-band message", + example="To issue a Faber College Graduate credential", + ) diff --git a/aries_cloudagent/protocols/didexchange/v1_0/messages/tests/test_request.py b/aries_cloudagent/protocols/didexchange/v1_0/messages/tests/test_request.py index dc4c8b189e..098e343762 100644 --- a/aries_cloudagent/protocols/didexchange/v1_0/messages/tests/test_request.py +++ b/aries_cloudagent/protocols/didexchange/v1_0/messages/tests/test_request.py @@ -18,6 +18,8 @@ class TestConfig: test_verkey = "3Dn1SJNPaCXcvvJvSbsFWP2xaCjMom3can8CQNhWrTRx" test_label = "Label" test_endpoint = "http://localhost" + goal_code = "pytest" + goal = "pass pytest" def make_did_doc(self): doc = DIDDoc(did=self.test_did) @@ -64,12 +66,16 @@ async def setUp(self): label=TestConfig.test_label, did=TestConfig.test_did, did_doc_attach=did_doc_attach, + goal_code=TestConfig.goal_code, + goal=TestConfig.goal, ) def test_init(self): """Test initialization.""" assert self.request.label == TestConfig.test_label assert self.request.did == TestConfig.test_did + assert self.request.goal_code == TestConfig.goal_code + assert self.request.goal == TestConfig.goal def test_type(self): """Test type.""" @@ -123,6 +129,8 @@ async def setUp(self): label=TestConfig.test_label, did=TestConfig.test_did, did_doc_attach=did_doc_attach, + goal_code="pytest", + goal="pass pytest", ) async def test_make_model(self): diff --git a/aries_cloudagent/protocols/didexchange/v1_0/routes.py b/aries_cloudagent/protocols/didexchange/v1_0/routes.py index 83de695dc5..4a22aa357e 100644 --- a/aries_cloudagent/protocols/didexchange/v1_0/routes.py +++ b/aries_cloudagent/protocols/didexchange/v1_0/routes.py @@ -62,6 +62,18 @@ class DIDXCreateRequestImplicitQueryStringSchema(OpenAPISchema): required=False, description="Use public DID for this connection", ) + goal_code = fields.Str( + required=False, + description="A self-attested code the receiver may want to display to the user " + "or use in automatically deciding what to do with the out-of-band message", + example="issue-vc", + ) + goal = fields.Str( + required=False, + description="A self-attested string that the receiver may want to display to the " + "user about the context-specific goal of the out-of-band message", + example="To issue a Faber College Graduate credential", + ) class DIDXReceiveRequestImplicitQueryStringSchema(OpenAPISchema): @@ -190,6 +202,8 @@ async def didx_create_request_implicit(request: web.BaseRequest): mediation_id = request.query.get("mediation_id") or None alias = request.query.get("alias") or None use_public_did = json.loads(request.query.get("use_public_did", "null")) + goal_code = request.query.get("goal_code") or None + goal = request.query.get("goal") or None profile = context.profile didx_mgr = DIDXManager(profile) @@ -201,6 +215,8 @@ async def didx_create_request_implicit(request: web.BaseRequest): mediation_id=mediation_id, use_public_did=use_public_did, alias=alias, + goal_code=goal_code, + goal=goal, ) except StorageNotFoundError as err: raise web.HTTPNotFound(reason=err.roll_up) from err diff --git a/aries_cloudagent/protocols/out_of_band/v1_0/routes.py b/aries_cloudagent/protocols/out_of_band/v1_0/routes.py index 9e30e1f813..910f4913c7 100644 --- a/aries_cloudagent/protocols/out_of_band/v1_0/routes.py +++ b/aries_cloudagent/protocols/out_of_band/v1_0/routes.py @@ -118,12 +118,14 @@ class AttachmentDefSchema(OpenAPISchema): ) goal_code = fields.Str( required=False, - description="A self-attested code the receiver may want to display to the user or use in automatically deciding what to do with the out-of-band message", + description="A self-attested code the receiver may want to display to the user " + "or use in automatically deciding what to do with the out-of-band message", example="issue-vc", ) goal = fields.Str( required=False, - description="A self-attested string that the receiver may want to display to the user about the context-specific goal of the out-of-band message", + description="A self-attested string that the receiver may want to display to the " + "user about the context-specific goal of the out-of-band message", example="To issue a Faber College Graduate credential", )