From 5806f5cb1b02dbb94e27e86a15673a231e3960e4 Mon Sep 17 00:00:00 2001 From: jamshale <31809382+jamshale@users.noreply.github.com> Date: Thu, 5 Dec 2024 11:58:35 -0800 Subject: [PATCH 1/2] Update anoncreds format names (#3374) * Update anoncreds format names Signed-off-by: jamshale * Add a unit test Signed-off-by: jamshale --------- Signed-off-by: jamshale --- .../issue_credential/v2_0/message_types.py | 8 +++--- .../protocols/issue_credential/v2_0/routes.py | 25 +++++++++++++++---- .../v2_0/tests/test_routes.py | 23 +++++++++++++++++ .../present_proof/v2_0/message_types.py | 6 ++--- 4 files changed, 50 insertions(+), 12 deletions(-) diff --git a/acapy_agent/protocols/issue_credential/v2_0/message_types.py b/acapy_agent/protocols/issue_credential/v2_0/message_types.py index e34ce0385d..80e56d2309 100644 --- a/acapy_agent/protocols/issue_credential/v2_0/message_types.py +++ b/acapy_agent/protocols/issue_credential/v2_0/message_types.py @@ -37,25 +37,25 @@ # Format specifications ATTACHMENT_FORMAT = { CRED_20_PROPOSAL: { - V20CredFormat.Format.ANONCREDS.api: "anoncreds/cred-filter@v2.0", + V20CredFormat.Format.ANONCREDS.api: "anoncreds/credential-filter@v1.0", V20CredFormat.Format.INDY.api: "hlindy/cred-filter@v2.0", V20CredFormat.Format.LD_PROOF.api: "aries/ld-proof-vc-detail@v1.0", V20CredFormat.Format.VC_DI.api: "didcomm/w3c-di-vc@v0.1", }, CRED_20_OFFER: { - V20CredFormat.Format.ANONCREDS.api: "anoncreds/cred-abstract@v2.0", + V20CredFormat.Format.ANONCREDS.api: "anoncreds/credential-offer@v1.0", V20CredFormat.Format.INDY.api: "hlindy/cred-abstract@v2.0", V20CredFormat.Format.LD_PROOF.api: "aries/ld-proof-vc-detail@v1.0", V20CredFormat.Format.VC_DI.api: "didcomm/w3c-di-vc-offer@v0.1", }, CRED_20_REQUEST: { - V20CredFormat.Format.ANONCREDS.api: "anoncreds/cred-req@v2.0", + V20CredFormat.Format.ANONCREDS.api: "anoncreds/credential-request@v1.0", V20CredFormat.Format.INDY.api: "hlindy/cred-req@v2.0", V20CredFormat.Format.LD_PROOF.api: "aries/ld-proof-vc-detail@v1.0", V20CredFormat.Format.VC_DI.api: "didcomm/w3c-di-vc-request@v0.1", }, CRED_20_ISSUE: { - V20CredFormat.Format.ANONCREDS.api: "anoncreds/cred@v2.0", + V20CredFormat.Format.ANONCREDS.api: "anoncreds/credential@v1.0", V20CredFormat.Format.INDY.api: "hlindy/cred@v2.0", V20CredFormat.Format.LD_PROOF.api: "aries/ld-proof-vc@v1.0", V20CredFormat.Format.VC_DI.api: "didcomm/w3c-di-vc@v0.1", diff --git a/acapy_agent/protocols/issue_credential/v2_0/routes.py b/acapy_agent/protocols/issue_credential/v2_0/routes.py index 9128f7aeac..de7c61f2e0 100644 --- a/acapy_agent/protocols/issue_credential/v2_0/routes.py +++ b/acapy_agent/protocols/issue_credential/v2_0/routes.py @@ -28,6 +28,7 @@ from ....messaging.models.openapi import OpenAPISchema from ....messaging.models.paginated_query import PaginatedQuerySchema, get_limit_offset from ....messaging.valid import ( + ANONCREDS_CRED_DEF_ID_EXAMPLE, ANONCREDS_DID_EXAMPLE, ANONCREDS_SCHEMA_ID_EXAMPLE, INDY_CRED_DEF_ID_EXAMPLE, @@ -137,13 +138,24 @@ class V20CredStoreRequestSchema(OpenAPISchema): class V20CredFilterAnoncredsSchema(OpenAPISchema): """Anoncreds credential filtration criteria.""" - cred_def_id = fields.Str( + schema_issuer_id = fields.Str( required=False, metadata={ - "description": "Credential definition identifier", + "description": "Schema issuer ID", "example": ANONCREDS_DID_EXAMPLE, }, ) + schema_name = fields.Str( + required=False, + metadata={"description": "Schema name", "example": "preferences"}, + ) + schema_version = fields.Str( + required=False, + metadata={ + "description": "Schema version", + "example": MAJOR_MINOR_VERSION_EXAMPLE, + }, + ) schema_id = fields.Str( required=False, metadata={ @@ -154,13 +166,16 @@ class V20CredFilterAnoncredsSchema(OpenAPISchema): issuer_id = fields.Str( required=False, metadata={ - "description": "Credential issuer DID", + "description": "Credential issuer ID", "example": ANONCREDS_DID_EXAMPLE, }, ) - epoch = fields.Str( + cred_def_id = fields.Str( required=False, - metadata={"description": "Credential epoch time", "example": "2021-08-24"}, + metadata={ + "description": "Credential definition identifier", + "example": ANONCREDS_CRED_DEF_ID_EXAMPLE, + }, ) diff --git a/acapy_agent/protocols/issue_credential/v2_0/tests/test_routes.py b/acapy_agent/protocols/issue_credential/v2_0/tests/test_routes.py index 9e3663d5ed..8691862f0d 100644 --- a/acapy_agent/protocols/issue_credential/v2_0/tests/test_routes.py +++ b/acapy_agent/protocols/issue_credential/v2_0/tests/test_routes.py @@ -61,6 +61,29 @@ async def test_validate_cred_filter_schema(self): with self.assertRaises(test_module.ValidationError): schema.validate_fields({"veres-one": {"no": "support"}}) + async def test_validate_cred_filter_anoncreds_schema(self): + schema = test_module.V20CredFilterSchema() + schema.validate_fields({"anoncreds": {"issuer_id": TEST_DID}}) + schema.validate_fields( + {"anoncreds": {"issuer_id": TEST_DID, "schema_version": "1.0"}} + ) + schema.validate_fields( + { + "anoncreds": {"issuer_id": TEST_DID}, + } + ) + schema.validate_fields( + { + "anoncreds": {}, + } + ) + with self.assertRaises(test_module.ValidationError): + schema.validate_fields({}) + with self.assertRaises(test_module.ValidationError): + schema.validate_fields(["hopeless", "stop"]) + with self.assertRaises(test_module.ValidationError): + schema.validate_fields({"veres-one": {"no": "support"}}) + async def test_validate_create_schema(self): schema = test_module.V20IssueCredSchemaCore() schema.validate( diff --git a/acapy_agent/protocols/present_proof/v2_0/message_types.py b/acapy_agent/protocols/present_proof/v2_0/message_types.py index 5654ef7d42..3c24ef7d72 100644 --- a/acapy_agent/protocols/present_proof/v2_0/message_types.py +++ b/acapy_agent/protocols/present_proof/v2_0/message_types.py @@ -32,17 +32,17 @@ # Format specifications ATTACHMENT_FORMAT = { PRES_20_PROPOSAL: { - V20PresFormat.Format.ANONCREDS.api: "anoncreds/proof-req@v2.0", + V20PresFormat.Format.ANONCREDS.api: "anoncreds/proof-proposal@v1.0", V20PresFormat.Format.INDY.api: "hlindy/proof-req@v2.0", V20PresFormat.Format.DIF.api: "dif/presentation-exchange/definitions@v1.0", }, PRES_20_REQUEST: { - V20PresFormat.Format.ANONCREDS.api: "anoncreds/proof-req@v2.0", + V20PresFormat.Format.ANONCREDS.api: "anoncreds/proof-request@v1.0", V20PresFormat.Format.INDY.api: "hlindy/proof-req@v2.0", V20PresFormat.Format.DIF.api: "dif/presentation-exchange/definitions@v1.0", }, PRES_20: { - V20PresFormat.Format.ANONCREDS.api: "anoncreds/proof@v2.0", + V20PresFormat.Format.ANONCREDS.api: "anoncreds/proof@v1.0", V20PresFormat.Format.INDY.api: "hlindy/proof@v2.0", V20PresFormat.Format.DIF.api: "dif/presentation-exchange/submission@v1.0", }, From 6ddb592c9929be4a76b329aeaeb874b76316ee24 Mon Sep 17 00:00:00 2001 From: Mourits de Beer <31511766+ff137@users.noreply.github.com> Date: Thu, 5 Dec 2024 23:23:29 +0200 Subject: [PATCH 2/2] :art: Fix model name for consistency (#3382) From Anoncred to Anoncreds Signed-off-by: ff137 Co-authored-by: jamshale <31809382+jamshale@users.noreply.github.com> --- acapy_agent/anoncreds/models/presentation_request.py | 2 +- open-api/openapi.json | 4 ++-- open-api/swagger.json | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/acapy_agent/anoncreds/models/presentation_request.py b/acapy_agent/anoncreds/models/presentation_request.py index 05881dfdc8..12855e1ee6 100644 --- a/acapy_agent/anoncreds/models/presentation_request.py +++ b/acapy_agent/anoncreds/models/presentation_request.py @@ -299,7 +299,7 @@ class Meta: }, ), }, - name="AnoncredPresentationRequestNonRevokedSchema", + name="AnoncredsPresentationRequestNonRevokedSchema", ), allow_none=True, required=False, diff --git a/open-api/openapi.json b/open-api/openapi.json index 97913e91f2..07c228d3a8 100644 --- a/open-api/openapi.json +++ b/open-api/openapi.json @@ -7763,7 +7763,7 @@ }, "type" : "object" }, - "AnoncredPresentationRequestNonRevoked" : { + "AnoncredsPresentationRequestNonRevoked" : { "properties" : { "from" : { "description" : "Earliest time of interest in non-revocation interval", @@ -7895,7 +7895,7 @@ "type" : "string" }, "non_revoked" : { - "$ref" : "#/components/schemas/AnoncredPresentationRequestNonRevoked" + "$ref" : "#/components/schemas/AnoncredsPresentationRequestNonRevoked" }, "nonce" : { "description" : "Nonce", diff --git a/open-api/swagger.json b/open-api/swagger.json index fd4823dd48..c49ae1134d 100644 --- a/open-api/swagger.json +++ b/open-api/swagger.json @@ -6396,7 +6396,7 @@ } } }, - "AnoncredPresentationRequestNonRevoked" : { + "AnoncredsPresentationRequestNonRevoked" : { "type" : "object", "properties" : { "from" : { @@ -6530,7 +6530,7 @@ "description" : "Proof request name" }, "non_revoked" : { - "$ref" : "#/definitions/AnoncredPresentationRequestNonRevoked" + "$ref" : "#/definitions/AnoncredsPresentationRequestNonRevoked" }, "nonce" : { "type" : "string",