Skip to content

Commit

Permalink
Fix L3-iGrant/api#652: Ensure full support for W3C VC
Browse files Browse the repository at this point in the history
  • Loading branch information
albinpa authored and georgepadayatti committed Oct 22, 2024
1 parent f4687a2 commit f83c744
Showing 1 changed file with 26 additions and 5 deletions.
31 changes: 26 additions & 5 deletions sdjwt/pex.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,17 @@ class InputDescriptor(BaseModel):
name: Optional[str] = None
purpose: Optional[str] = None
constraints: Dict[str, Union[str, List[Field]]]
format: Optional[Dict[str, Union[Dict[str, List[str]], Dict[str, List[str]]]]] = None
format: Optional[Dict[str, Union[Dict[str, List[str]], Dict[str, List[str]]]]] = (
None
)


class PresentationDefinition(BaseModel):
id: str
input_descriptors: List[InputDescriptor]
format: Optional[Dict[str, Union[Dict[str, List[str]], Dict[str, List[str]]]]] = None
format: Optional[Dict[str, Union[Dict[str, List[str]], Dict[str, List[str]]]]] = (
None
)


PresentationDefinitionJsonSchema = {
Expand Down Expand Up @@ -105,7 +109,18 @@ class PresentationDefinition(BaseModel):
"items": {"type": "string", "enum": ["ES256"]},
}
},
}
},
"^(jwt|jwt_vc|jwt_vc_json|jwt_vp|vp\+sd-jwt|vc\+sd-jwt|sd-jwt)$": {
"type": "object",
"additionalProperties": False,
"properties": {
"alg": {
"type": "array",
"minItems": 1,
"items": {"type": "string"},
}
},
},
},
},
"constraints": {
Expand Down Expand Up @@ -777,10 +792,16 @@ def validate_vp_token(
input_descriptors = json.loads(presentation_definition).get(
"input_descriptors"
)
format_info = json.loads(presentation_definition).get("format")
for input_descriptor in input_descriptors:
credential_format = input_descriptor.get("format")
if not credential_format:
credential_format = format_info
if input_descriptor.get("id") == id:
limit_disclosure = input_descriptor.get("constraints").get("limit_disclosure",None)
if limit_disclosure and limit_disclosure == "required":
limit_disclosure = input_descriptor.get("constraints").get(
"limit_disclosure", None
)
if "vc+sd-jwt" in credential_format:
matches = match_credentials(
json.dumps(input_descriptor),
credentials=[json.dumps(vc_claims)],
Expand Down

0 comments on commit f83c744

Please sign in to comment.