Skip to content
This repository has been archived by the owner on Mar 27, 2024. It is now read-only.

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: invalid creds IDs returned from get submission requirements.
Browse files Browse the repository at this point in the history
Signed-off-by: Volodymyr Kubiv <volodymyr.kubiv@euristiq.com>
vkubiv committed May 1, 2023

Verified

This commit was signed with the committer’s verified signature.
vkubiv Volodymyr Kubiv
1 parent 88e3cdc commit 66a5ebd
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 7 additions & 1 deletion pkg/doc/presexch/definition.go
Original file line number Diff line number Diff line change
@@ -545,7 +545,7 @@ func (pd *PresentationDefinition) MatchSubmissionRequirement(credentials []*veri
// ErrNoCredentials when any credentials do not satisfy requirements.
var ErrNoCredentials = errors.New("credentials do not satisfy requirements")

// nolint: funlen
// nolint: funlen,gocyclo
func (pd *PresentationDefinition) matchRequirement(req *requirement, creds []*verifiable.Credential,
documentLoader ld.DocumentLoader, opts *matchRequirementsOpts) (*MatchedSubmissionRequirement, error) {
matchedReq := &MatchedSubmissionRequirement{
@@ -584,6 +584,12 @@ func (pd *PresentationDefinition) matchRequirement(req *requirement, creds []*ve
if err != nil {
return nil, err
}

// TODO: remove this workaround after refactoring "merge" function to get rid of
// TODO: the trick with the modification of credential id.
for _, cred := range matchedVCs {
cred.ID = trimTmpID(cred.ID)
}
} else {
for _, credRes := range filtered {
matchedVCs = append(matchedVCs, credRes.credential)
2 changes: 2 additions & 0 deletions pkg/doc/presexch/match_submission_requirements_test.go
Original file line number Diff line number Diff line change
@@ -238,6 +238,8 @@ func TestInstance_GetSubmissionRequirements(t *testing.T) {

matchedVC := matched[0].Descriptors[0].MatchedVCs[0]

require.Equal(t, vc.ID, matchedVC.ID)

subject := matchedVC.Subject.([]verifiable.Subject)[0]
degree := subject.CustomFields["degree"]
require.NotNil(t, degree)

0 comments on commit 66a5ebd

Please sign in to comment.