fix: [WLEO-439] Changed behavior of evaluateInputDescriptor helper functions to throw on no match #238
+24
−14
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR changes the behavior of the
evaluateInputDescriptorForMdoc
andevaluateInputDescriptorForSdJwt4VC
methods to solve a bug regarding presentations containing only optional values.List of Changes
src/credential/presentation/__tests__/07-evaluate-input-descriptor.test.ts
,src/credential/presentation/__tests__/07-evaluate-input-descriptor.ts
: made the methodsevaluateInputDescriptorFor*
has been changed to throw in case no matches are found for a credential, optional or not. Tests have been modified accordingly.Motivation and Context
The
findCredentialSdJwt
andfindCredentialMdoc
use their correspondingevaluateInputDescriptorFor*
methods' logic to handle matching of the input descriptor with a credential's claims, more precisely they switch to the next credential upon the method throwing an error, and return its matches upon successful invocation.Before this change, this function returned at the first credential in case an input descriptor with zero required disclosures and optional disclosures was passed, thus stopping the credentials' parsing process.
This has led to the following unwanted scenario:
[A,B]
.evaluateInputDescriptor
method succeeds, and credential B is not searched, so thefindCredential*
method returns that no match has been found, despite the claims being present in credential B.To fix this, now the
evaluateInputDescriptorFor*
methods throw an error if zero matches, optional or not, are found, too.How Has This Been Tested?
Screenshots (if appropriate):
Checklist: