Skip to content

Commit

Permalink
parse subject position
Browse files Browse the repository at this point in the history
  • Loading branch information
ilya-korotya committed May 12, 2022
1 parent f5b1b1b commit 02a50e6
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
11 changes: 10 additions & 1 deletion json-ld/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,16 @@ func (p Parser) ParseClaim(credential *verifiable.Iden3Credential, schemaBytes [
if err != nil {
return nil, err
}
claim.SetIndexID(id)

switch credential.SubjectPosition {
case "", utils.SubjectPositionIndex:
claim.SetIndexID(id)
case utils.SubjectPositionValue:
claim.SetValueID(id)
default:
return nil, errors.New("unknown subject position")
}

}

return claim, nil
Expand Down
10 changes: 9 additions & 1 deletion json/parser.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,15 @@ func (s Parser) ParseClaim(credential *verifiable.Iden3Credential, schemaBytes [
if err != nil {
return nil, err
}
claim.SetIndexID(id)

switch credential.SubjectPosition {
case "", utils.SubjectPositionIndex:
claim.SetIndexID(id)
case utils.SubjectPositionValue:
claim.SetValueID(id)
default:
return nil, errors.New("unknown subject position")
}
}

return claim, nil
Expand Down
7 changes: 7 additions & 0 deletions utils/claims.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,13 @@ import (
"github.com/pkg/errors"
)

const (
// SubjectPositionIndex save subject in index part of claim. By default.
SubjectPositionIndex = "index"
// SubjectPositionValue save subject in value part of claim.
SubjectPositionValue = "value"
)

var q *big.Int

//nolint //reason - needed
Expand Down

0 comments on commit 02a50e6

Please sign in to comment.