Skip to content
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

Validate presentaion submission with new validator #208

Merged
merged 3 commits into from
Feb 5, 2024

Conversation

nitro-neal
Copy link
Contributor

@nitro-neal nitro-neal commented Jan 25, 2024

This method performs several checks to ensure the integrity of the presentation submission model object:

    1. Ensures that the presentation submission's ID is not empty.
    1. Validates that the definitionId is not empty.
    1. Validates descriptorMap is a non-empty list.
    1. Verifies the input descriptor mapping ids are the same on all levels of nesting.
    1. Ensures that the path is valid across all levels of nesting

Usage:

try {
  PresentationExchange.validateSubmission(presentationSubmission)
} catch(Exception e) {
  // invalid submission
}

web5-spec vector change - decentralized-identity/web5-spec#109

Copy link

codecov bot commented Jan 25, 2024

Codecov Report

Merging #208 (2d96659) into main (e4b0862) will increase coverage by 0.24%.
Report is 3 commits behind head on main.
The diff coverage is 100.00%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #208      +/-   ##
==========================================
+ Coverage   79.91%   80.16%   +0.24%     
==========================================
  Files          37       37              
  Lines        2166     2193      +27     
  Branches      299      309      +10     
==========================================
+ Hits         1731     1758      +27     
  Misses        297      297              
  Partials      138      138              
Components Coverage Δ
credentials 82.29% <100.00%> (+0.91%) ⬆️
crypto 38.07% <ø> (ø)
dids 89.71% <ø> (ø)
common 80.55% <ø> (ø)

}

if (descriptor.id != id) {
throw PexValidationException("Each descriptor should have one id in it, on all levels")
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

also need to check that descriptor ids are unique within the definition

Copy link
Member

@decentralgabe decentralgabe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm with one comment

* Throws an [PexValidationException] if the provided object does not conform to the Presentation Definition
*/
@Throws(PexValidationException::class)
public fun validateSubmission(presentationSubmission: PresentationSubmission) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should this specify that it's for v2 like the PD one above?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nope there is only one version of submission and honestly we should probably remove the v2 from definition since I think we will only be using v2

@nitro-neal nitro-neal merged commit b4aeea2 into main Feb 5, 2024
8 of 10 checks passed
@nitro-neal nitro-neal deleted the validate-presentation-submission branch February 5, 2024 17:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants