Skip to content

Commit

Permalink
Added missing formats field
Browse files Browse the repository at this point in the history
Signed-off-by: Gavin Jaeger-Freeborn <[email protected]>
  • Loading branch information
Gavinok committed Jul 25, 2024
1 parent 6c6c1bc commit 9466e88
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
2 changes: 1 addition & 1 deletion oidc-controller/api/core/aries/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# flake8: noqa

from .present_proof_attachment import PresentProofv10Attachment
from .present_proof_attachment import PresentProofv20Attachment
from .service_decorator import ServiceDecorator, OOBServiceDecorator

from .present_proof_presentation import PresentationRequestMessage
Expand Down
6 changes: 3 additions & 3 deletions oidc-controller/api/core/aries/present_proof_attachment.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,16 +5,16 @@
from pydantic import BaseModel, Field


class PresentProofv10Attachment(BaseModel):
# https://github.com/hyperledger/aries-rfcs/blob/main/features/0037-present-proof/README.md#request-presentation
class PresentProofv20Attachment(BaseModel):
# https://github.com/hyperledger/aries-rfcs/tree/eace815c3e8598d4a8dd7881d8c731fdb2bcc0aa/features/0454-present-proof-v2
id: str = Field(default="libindy-request-presentation-0", alias="@id")
mime_type: str = Field(default="application/json", alias="mime-type")
data: Dict

@classmethod
def build(
cls, presentation_request
) -> "PresentProofv10Attachment": # bundle everything needed for the QR code
) -> "PresentProofv20Attachment": # bundle everything needed for the QR code
return cls(
data={
"base64": base64.b64encode(
Expand Down
7 changes: 4 additions & 3 deletions oidc-controller/api/core/aries/present_proof_presentation.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import json
import base64
from typing import Optional, List
from typing import Optional, List, Dict

from pydantic import BaseModel, ConfigDict, Field
from api.core.aries import PresentProofv10Attachment, ServiceDecorator
from api.core.aries import PresentProofv20Attachment, ServiceDecorator


class PresentationRequestMessage(BaseModel):
Expand All @@ -13,7 +13,8 @@ class PresentationRequestMessage(BaseModel):
"https://didcomm.org/present-proof/2.0/request-presentation",
alias="@type",
)
request: List[PresentProofv10Attachment] = Field(
formats: List[Dict]
request: List[PresentProofv20Attachment] = Field(
alias="request_presentations~attach"
)
comment: Optional[str] = None
Expand Down
11 changes: 10 additions & 1 deletion oidc-controller/api/routers/oidc.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,12 +123,21 @@ async def get_authorize(request: Request, db: Database = Depends(get_db)):
else:
wallet_did = client.get_wallet_did(public=use_public_did)

byo_attachment = PresentProofv10Attachment.build(pres_exch_dict["pres_request"])
byo_attachment = PresentProofv20Attachment(
# As of present proof 2.0 the
data=pres_exch_dict["pres_request"]["request_presentations~attach"][0][
"data"
]
)

s_d = ServiceDecorator(
service_endpoint=client.service_endpoint, recipient_keys=[wallet_did.verkey]
)
msg = PresentationRequestMessage(
id=pres_exch_dict["thread_id"],
formats=[
{"attach_id": byo_attachment.id, "format": "hlindy/[email protected]"}
],
request=[byo_attachment],
service=s_d,
)
Expand Down

0 comments on commit 9466e88

Please sign in to comment.