-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Implementing satisfiesPresentationDefinition #143
Conversation
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #143 +/- ##
==========================================
+ Coverage 75.25% 76.77% +1.51%
==========================================
Files 25 27 +2
Lines 1568 1804 +236
Branches 196 239 +43
==========================================
+ Hits 1180 1385 +205
- Misses 283 290 +7
- Partials 105 129 +24
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is awesome stuff @nitro-neal !
Some small comments
credentials/src/test/resources/pd_filter_array_multiple_input_descriptors.json
Outdated
Show resolved
Hide resolved
"type": "string", | ||
"const": "StreetCred" | ||
} | ||
"pattern": ".*StreetCred.*" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Curious why this change?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
+1
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was not valid, contains
is used for array
for type
string
its pattern
https://json-schema.org/understanding-json-schema/reference/array
This will be caught and prevented in the next PR with PD validation + test vectors
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I think this was originally expecting the value at the path to be a string array, which is why contains
+ type: string
was used.
"$.vc.type[*]",
"$.type[*]"
If the value at these paths is a single string and not a string array, then yeah we need pattern.
credentials/src/main/kotlin/web5/sdk/credentials/PresentationExchange.kt
Outdated
Show resolved
Hide resolved
credentials/src/main/kotlin/web5/sdk/credentials/PresentationExchange.kt
Outdated
Show resolved
Hide resolved
credentials/src/main/kotlin/web5/sdk/credentials/PresentationExchange.kt
Show resolved
Hide resolved
throw PresentationExchangeError( | ||
"Missing input descriptors: The presentation definition requires " + | ||
"${presentationDefinition.inputDescriptors.size} descriptors, but only " + | ||
"${inputDescriptorToVcMap.size} were found. Check and provide the missing descriptors." | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be incredibly useful if the library would tell the user what input descriptors were missing. What do you think?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you're addressing later, then disregard this comment!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yup addressing in the next PR
@nitro-neal are there any nuances specifically with respect what is/isn't supported for |
one of my gripes with PEX v2 is the conflation of {
"path": [
"$.type[*]"
],
"filter": {
"type": "string",
"pattern": "^StreetCredential$"
}
} vs. {
"path": [
"$.type"
],
"filter": {
"type": "array",
"contains": {
"type": "string",
"const": "StreetCredential"
}
}
} the 1st field constraint makes it such that have we implemented support for both or just one of the two? if the latter, which one do we support? |
-with a small change- It now has support for both cases I added a unit test to make sure its functioning as intended Works for both |
credentials/src/test/kotlin/web5/sdk/credentials/PresentationExchangeTest.kt
Outdated
Show resolved
Hide resolved
credentials/src/test/kotlin/web5/sdk/credentials/PresentationExchangeTest.kt
Outdated
Show resolved
Hide resolved
"type": "string", | ||
"const": "StreetCred" | ||
} | ||
"pattern": ".*StreetCred.*" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I think this was originally expecting the value at the path to be a string array, which is why contains
+ type: string
was used.
"$.vc.type[*]",
"$.type[*]"
If the value at these paths is a single string and not a string array, then yeah we need pattern.
vcJwtList: Iterable<String>, | ||
presentationDefinition: PresentationDefinitionV2 | ||
): Map<InputDescriptorV2, List<String>> { | ||
return presentationDefinition.inputDescriptors.associateWith { inputDescriptor -> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
have not used associateWith
before, cool!
…xchangeTest.kt Co-authored-by: phoebe-lew <[email protected]>
…xchangeTest.kt Co-authored-by: phoebe-lew <[email protected]>
Implementing satisfiesPresentationDefinition function for PEX
Validates a list of Verifiable Credentials (VCs) against a specified Presentation Definition.
This function ensures that the provided VCs meet the criteria defined in the Presentation Definition.
It first checks for the presence of Submission Requirements in the definition and throws an exception if they exist (not supported
It does this by mapping the input descriptors in the presentation definition to the corresponding VCs. If the number of mapped descriptors does not match the required count, an error is thrown.
More detailed error messages are planned for the future with a Results object that will give warnings, and better details for errors