Skip to content

Commit

Permalink
Merge branch 'main' into feat/vc-di
Browse files Browse the repository at this point in the history
  • Loading branch information
ianco authored Apr 3, 2024
2 parents 88a7094 + 7d75760 commit d9e9ce4
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 104 deletions.
7 changes: 5 additions & 2 deletions aries_cloudagent/core/oob_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,14 +57,17 @@ async def clean_finished_oob_record(self, profile: Profile, message: AgentMessag
{"role": OobRecord.ROLE_SENDER},
)

# emit the "done" event for OOB invitations
if not oob_record.invitation.requests_attach:
oob_record.state = OobRecord.STATE_DONE
await oob_record.emit_event(session)

# If the oob record is not multi use and it doesn't contain any
# attachments, we can now safely remove the oob record
if (
not oob_record.multi_use
and not oob_record.invitation.requests_attach
):
oob_record.state = OobRecord.STATE_DONE
await oob_record.emit_event(session)
await oob_record.delete_record(session)
except StorageNotFoundError:
# It is fine if no oob record is found, Only retrieved for cleanup
Expand Down
2 changes: 1 addition & 1 deletion aries_cloudagent/core/tests/test_oob_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ async def test_clean_finished_oob_record_multi_use(self):
self.profile, test_message
)

mock_oob.emit_event.assert_not_called()
mock_oob.emit_event.assert_called_once()
mock_oob.delete_record.assert_not_called()

mock_retrieve_oob.assert_called_once_with(
Expand Down
10 changes: 2 additions & 8 deletions aries_cloudagent/vc/routes.py
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ async def issue_credential_route(request: web.BaseRequest):
options = {} if "options" not in body else body["options"]

# We derive the proofType from the issuer DID if not provided in options
if not options.get("type", None) and not options.get("proofType", None):
if not options.get("proofType", None):
issuer = credential["issuer"]
did = issuer if isinstance(issuer, str) else issuer["id"]
async with context.session() as session:
Expand All @@ -93,10 +93,6 @@ async def issue_credential_route(request: web.BaseRequest):
options["proofType"] = "Ed25519Signature2020"
elif key_type == "bls12381g2":
options["proofType"] = "BbsBlsSignature2020"
else:
options["proofType"] = (
options.pop("type") if "type" in options else options["proofType"]
)

credential = VerifiableCredential.deserialize(credential)
options = LDProofVCOptions.deserialize(options)
Expand Down Expand Up @@ -190,7 +186,7 @@ async def prove_presentation_route(request: web.BaseRequest):
options = {} if "options" not in body else body["options"]

# We derive the proofType from the holder DID if not provided in options
if not options.get("type", None):
if not options.get("proofType", None):
holder = presentation["holder"]
did = holder if isinstance(holder, str) else holder["id"]
async with context.session() as session:
Expand All @@ -202,8 +198,6 @@ async def prove_presentation_route(request: web.BaseRequest):
options["proofType"] = "Ed25519Signature2020"
elif key_type == "bls12381g2":
options["proofType"] = "BbsBlsSignature2020"
else:
options["proofType"] = options.pop("type")

presentation = VerifiablePresentation.deserialize(presentation)
options = LDProofVCOptions.deserialize(options)
Expand Down
25 changes: 3 additions & 22 deletions aries_cloudagent/vc/vc_ld/models/web_schemas.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,8 @@
"""VC-API routes web requests schemas."""

from marshmallow import fields, Schema
from marshmallow import fields
from ....messaging.models.openapi import OpenAPISchema

from ....messaging.valid import (
RFC3339_DATETIME_EXAMPLE,
UUID4_EXAMPLE,
)
from ..validation_result import (
PresentationVerificationResultSchema,
)
Expand All @@ -21,21 +17,6 @@
)


class IssuanceOptionsSchema(Schema):
"""Linked data proof verifiable credential options schema."""

type = fields.Str(required=False, metadata={"example": "Ed25519Signature2020"})
created = fields.Str(required=False, metadata={"example": RFC3339_DATETIME_EXAMPLE})
domain = fields.Str(required=False, metadata={"example": "website.example"})
challenge = fields.Str(required=False, metadata={"example": UUID4_EXAMPLE})
# TODO, implement status list publication through a plugin
# credential_status = fields.Dict(
# data_key="credentialStatus",
# required=False,
# metadata={"example": {"type": "StatusList2021"}},
# )


class ListCredentialsResponse(OpenAPISchema):
"""Response schema for listing credentials."""

Expand All @@ -52,7 +33,7 @@ class IssueCredentialRequest(OpenAPISchema):
"""Request schema for issuing a credential."""

credential = fields.Nested(CredentialSchema)
options = fields.Nested(IssuanceOptionsSchema)
options = fields.Nested(LDProofVCOptionsSchema)


class IssueCredentialResponse(OpenAPISchema):
Expand All @@ -78,7 +59,7 @@ class ProvePresentationRequest(OpenAPISchema):
"""Request schema for proving a presentation."""

presentation = fields.Nested(PresentationSchema)
options = fields.Nested(IssuanceOptionsSchema)
options = fields.Nested(LDProofVCOptionsSchema)


class ProvePresentationResponse(OpenAPISchema):
Expand Down
Loading

0 comments on commit d9e9ce4

Please sign in to comment.