@@ -709,24 +709,28 @@ public async Task<Validation<AuthorizationRequestCancellation, PresentationReque
709
709
710
710
private static Validation < AuthorizationRequestCancellation , PresentationRequest > ProcessVpTransactionData (
711
711
PresentationRequest presentationRequest ,
712
- IEnumerable < TransactionData > transactionDatas )
712
+ IEnumerable < TransactionData > vpTransactionDatas )
713
713
{
714
714
var result = presentationRequest . Candidates . Match (
715
715
candidates =>
716
716
{
717
- var candidatesValidation = transactionDatas . TraverseAll ( transactionData =>
717
+ var transactionDatas = vpTransactionDatas . ToList ( ) ;
718
+ candidates = candidates . Select ( candidate =>
718
719
{
719
- return candidates . FindCandidateForTransactionData ( transactionData ) . Match (
720
- candidate => candidate . AddTransactionData ( transactionData ) ,
721
- ( ) => ( Validation < PresentationCandidate > ) new InvalidTransactionDataError (
722
- $ "No credentials found that satisfy the transaction data with type { transactionData . GetTransactionDataType ( ) . AsString ( ) } ",
723
- presentationRequest ) ) ;
724
- } ) ;
725
-
726
- return candidatesValidation . OnSuccess ( enumerable => presentationRequest with
727
- {
728
- Candidates = enumerable . ToList ( )
729
- } ) ;
720
+ return candidate . AddTransactionDatas ( transactionDatas . Where ( transactionData => transactionData
721
+ . GetCredentialIds ( ) . Select ( id => id . AsString )
722
+ . Contains ( candidate . Identifier ) ) ) ;
723
+ } ) . ToList ( ) ;
724
+
725
+ var satisfiedTransactionDatas = candidates . Where ( x => x . TransactionData . IsSome )
726
+ . SelectMany ( x => x . TransactionData . UnwrapOrThrow ( ) ) ;
727
+ if ( transactionDatas . Any ( transactionData => ! satisfiedTransactionDatas . Contains ( transactionData ) ) )
728
+ return new InvalidTransactionDataError (
729
+ "Not enough credentials found to satisfy the authorization request with transaction data" ,
730
+ presentationRequest )
731
+ . ToInvalid < PresentationRequest > ( ) ;
732
+
733
+ return presentationRequest with { Candidates = candidates } ;
730
734
} ,
731
735
( ) => new InvalidTransactionDataError (
732
736
"No credentials found that satisfy the authorization request with transaction data" ,
0 commit comments