diff --git a/acapy_agent/vc/routes.py b/acapy_agent/vc/routes.py index f25b6f9cfd..e2d14e80fe 100644 --- a/acapy_agent/vc/routes.py +++ b/acapy_agent/vc/routes.py @@ -34,7 +34,11 @@ async def list_credentials_route(request: web.BaseRequest): holder = context.inject(VCHolder) try: search = holder.search_credentials() - records = [record.serialize()["cred_value"] for record in await search.fetch()] + records = { + "results": [ + record.serialize()["cred_value"] for record in await search.fetch() + ] + } return web.json_response(records, status=200) except (StorageError, StorageNotFoundError) as err: return web.json_response({"message": err.roll_up}, status=400) @@ -133,7 +137,7 @@ async def verify_credential_route(request: web.BaseRequest): @docs(tags=["vc-api"], summary="Store a credential") -@request_schema(web_schemas.VerifyCredentialRequest()) +@request_schema(web_schemas.StoreCredentialRequest()) @response_schema(web_schemas.StoreCredentialResponse(), 200, description="") @tenant_authentication async def store_credential_route(request: web.BaseRequest): @@ -156,7 +160,7 @@ async def store_credential_route(request: web.BaseRequest): options = LDProofVCOptions.deserialize(options) await manager.verify_credential(vc) - await manager.store_credential(vc, options, cred_id) + await manager.store_credential(vc, cred_id) return web.json_response({"credentialId": cred_id}, status=200) diff --git a/acapy_agent/vc/vc_ld/manager.py b/acapy_agent/vc/vc_ld/manager.py index d6d4b6809c..bf3fa83bc4 100644 --- a/acapy_agent/vc/vc_ld/manager.py +++ b/acapy_agent/vc/vc_ld/manager.py @@ -405,9 +405,8 @@ async def issue( async def store_credential( self, vc: VerifiableCredential, - options: LDProofVCOptions, cred_id: Optional[str] = None, - ) -> VerifiableCredential: + ) -> VCRecord: """Store a verifiable credential.""" # Saving expanded type as a cred_tag @@ -437,6 +436,8 @@ async def store_credential( await vc_holder.store_credential(vc_record) + return vc_record + async def verify_credential( self, vc: VerifiableCredential ) -> DocumentVerificationResult: diff --git a/acapy_agent/vc/vc_ld/models/web_schemas.py b/acapy_agent/vc/vc_ld/models/web_schemas.py index 3f43f153e9..277c04e872 100644 --- a/acapy_agent/vc/vc_ld/models/web_schemas.py +++ b/acapy_agent/vc/vc_ld/models/web_schemas.py @@ -12,7 +12,7 @@ class ListCredentialsResponse(OpenAPISchema): """Response schema for listing credentials.""" - results = [fields.Nested(VerifiableCredentialSchema)] + results = fields.List(fields.Nested(VerifiableCredentialSchema)) class FetchCredentialResponse(OpenAPISchema): @@ -47,6 +47,12 @@ class VerifyCredentialResponse(OpenAPISchema): results = fields.Nested(PresentationVerificationResultSchema) +class StoreCredentialRequest(OpenAPISchema): + """Request schema for verifying an LDP VP.""" + + verifiableCredential = fields.Nested(VerifiableCredentialSchema) + + class StoreCredentialResponse(OpenAPISchema): """Request schema for verifying an LDP VP.""" diff --git a/acapy_agent/vc/vc_ld/tests/test_manager.py b/acapy_agent/vc/vc_ld/tests/test_manager.py index bc6a5b3d4b..24182f5eda 100644 --- a/acapy_agent/vc/vc_ld/tests/test_manager.py +++ b/acapy_agent/vc/vc_ld/tests/test_manager.py @@ -331,7 +331,7 @@ async def test_store( self.vc.issuer = did.did self.options.proof_type = Ed25519Signature2018.signature_type cred = await self.manager.issue(self.vc, self.options) - await self.manager.store_credential(cred, self.options, TEST_UUID) + await self.manager.store_credential(cred, TEST_UUID) async with self.profile.session() as session: holder = session.inject(VCHolder) record = await holder.retrieve_credential_by_id(record_id=TEST_UUID)