Skip to content

Commit

Permalink
Fix: Add credential label in the response; Remove SdJwt suffix in dis…
Browse files Browse the repository at this point in the history
…play for discovery

Signed-off-by: George Padayatti <george.padayatti@igrant.io>
  • Loading branch information
georgepadayatti committed May 14, 2024
1 parent aa2e5e1 commit 894e7c9
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 9 deletions.
35 changes: 30 additions & 5 deletions eudi_wallet/ebsi/entry_points/server/routes/v2/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
ListVerificationRequestUsecase,
)
from eudi_wallet.ebsi.entry_points.server.v2_well_known import (
validate_credential_type_based_on_disclosure_mapping
validate_credential_type_based_on_disclosure_mapping,
)

config_routes = web.RouteTableDef()
Expand Down Expand Up @@ -583,7 +583,9 @@ async def handle_post_issue_credential(request: Request, context: V2RequestConte

else:
assert credential.get("type", []) is not None
credential = validate_credential_type_based_on_disclosure_mapping(credential=credential,disclosure_mapping=disclosure_mapping)
credential = validate_credential_type_based_on_disclosure_mapping(
credential=credential, disclosure_mapping=disclosure_mapping
)
credential_offer = await context.legal_entity_service.issue_credential_with_disclosure_mapping(
issuance_mode=issue_credential_req.issuanceMode,
is_pre_authorised=issue_credential_req.isPreAuthorised,
Expand All @@ -597,6 +599,10 @@ async def handle_post_issue_credential(request: Request, context: V2RequestConte
openid_credential_offer_uri = f"openid-credential-offer://?credential_offer_uri={issuer_domain}/organisation/{organisation_id}/service/credential-offer/{credentialExchangeId}"
credential_offer["credentialOffer"] = openid_credential_offer_uri

# FIXME: Dyanmically create credential label from credential type
credential_offer["credentialLabel"] = credential.get("type", [])[
-1
].removesuffix("SdJwt")
return web.json_response(credential_offer, status=201)
except ValidateDataAttributeValuesAgainstDataAttributesError as e:
raise web.HTTPBadRequest(text=str(e))
Expand Down Expand Up @@ -644,7 +650,12 @@ async def handle_service_put_update_credential_offer(
credential=credential,
disclosureMapping=disclosure_mapping,
)

# FIXME: Dyanmically create credential label from credential type
credential_offer["credentialLabel"] = (
credential_offer.get("credential", {})
.get("type", [])[-1]
.removesuffix("SdJwt")
)
return web.json_response(credential_offer)
else:
with context.data_agreement_repository as repo:
Expand Down Expand Up @@ -718,6 +729,13 @@ async def handle_config_get_credential_offer_by_id_and_credential_schema_id(
if credential_offer_entity is None:
raise web.HTTPBadRequest(text="Credential offer not found")

# FIXME: Dyanmically create credential label from credential type
credential_offer_entity["credentialLabel"] = (
credential_offer_entity.get("credential", {})
.get("type", [])[-1]
.removesuffix("SdJwt")
)

return web.json_response(credential_offer_entity.to_dict())


Expand All @@ -742,9 +760,16 @@ async def handle_config_get_all_credential_offers(
credential_offers = await context.legal_entity_service.get_all_credential_offers_by_organisation_id(
organisation_id=organisation_id
)

# FIXME: Dyanmically create credential label from credential type
return web.json_response(
[
credential_offer_entity.to_dict()
{
**credential_offer_entity.to_dict(),
"credentialLabel": credential_offer_entity.get("credential", {})
.get("type", [])[-1]
.removesuffix("SdJwt"),
}
for credential_offer_entity in credential_offers
]
)
Expand Down Expand Up @@ -819,7 +844,7 @@ async def handle_post_create_verification_request(
organisation_id=organisation_id,
presentation_definition=request_body.presentationDefinition,
requestByReference=request_body.requestByReference,
webhook_url=context.legal_entity_service.legal_entity_entity.webhook_url
webhook_url=context.legal_entity_service.legal_entity_entity.webhook_url,
)
return web.json_response(verification_record.to_dict())
except ValidationError as e:
Expand Down
5 changes: 1 addition & 4 deletions eudi_wallet/ebsi/entry_points/server/v2_well_known.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ def service_get_well_known_openid_credential_issuer_config(
assert issue_credential_repository is not None

with issue_credential_repository as credential_repo:

credential_offers = (
credential_repo.get_all_by_organisation_id_and_with_credential(
organisation_id=organisation_id
Expand Down Expand Up @@ -162,7 +161,7 @@ def create_credential_supported_from_credential_offers(credential_offers: list)
"cryptographic_suites_supported": ["ES256"],
"display": [
{
"name": credential_types[-1],
"name": credential_types[-1].removesuffix("SdJwt"),
"locale": "en-GB",
"background_color": "#12107c",
"text_color": "#FFFFFF",
Expand Down Expand Up @@ -192,7 +191,6 @@ def service_get_well_known_openid_credential_issuer_config_v2(
assert issue_credential_repository is not None

with issue_credential_repository as credential_repo:

credential_offers = (
credential_repo.get_all_by_organisation_id_and_with_credential(
organisation_id=organisation_id
Expand Down Expand Up @@ -274,4 +272,3 @@ def service_get_well_known_authn_openid_config_v2(
"attester_signed_id_token",
],
}

0 comments on commit 894e7c9

Please sign in to comment.