From 9466e88fa991160898cc1e26748a9ff31f75759e Mon Sep 17 00:00:00 2001 From: Gavin Jaeger-Freeborn Date: Thu, 25 Jul 2024 13:58:59 -0700 Subject: [PATCH] Added missing formats field Signed-off-by: Gavin Jaeger-Freeborn --- oidc-controller/api/core/aries/__init__.py | 2 +- .../api/core/aries/present_proof_attachment.py | 6 +++--- .../api/core/aries/present_proof_presentation.py | 7 ++++--- oidc-controller/api/routers/oidc.py | 11 ++++++++++- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/oidc-controller/api/core/aries/__init__.py b/oidc-controller/api/core/aries/__init__.py index 28d321c5..935f52ff 100644 --- a/oidc-controller/api/core/aries/__init__.py +++ b/oidc-controller/api/core/aries/__init__.py @@ -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 diff --git a/oidc-controller/api/core/aries/present_proof_attachment.py b/oidc-controller/api/core/aries/present_proof_attachment.py index d27c6c23..f77bf079 100644 --- a/oidc-controller/api/core/aries/present_proof_attachment.py +++ b/oidc-controller/api/core/aries/present_proof_attachment.py @@ -5,8 +5,8 @@ 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 @@ -14,7 +14,7 @@ class PresentProofv10Attachment(BaseModel): @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( diff --git a/oidc-controller/api/core/aries/present_proof_presentation.py b/oidc-controller/api/core/aries/present_proof_presentation.py index 1eb37afa..ffe49b0c 100644 --- a/oidc-controller/api/core/aries/present_proof_presentation.py +++ b/oidc-controller/api/core/aries/present_proof_presentation.py @@ -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): @@ -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 diff --git a/oidc-controller/api/routers/oidc.py b/oidc-controller/api/routers/oidc.py index 1dc02a44..a79e7f68 100644 --- a/oidc-controller/api/routers/oidc.py +++ b/oidc-controller/api/routers/oidc.py @@ -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/proof-req@v2.0"} + ], request=[byo_attachment], service=s_d, )