Skip to content

Commit 02a50e6

Browse files
committed
parse subject position
1 parent f5b1b1b commit 02a50e6

File tree

3 files changed

+26
-2
lines changed

3 files changed

+26
-2
lines changed

json-ld/parser.go

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,16 @@ func (p Parser) ParseClaim(credential *verifiable.Iden3Credential, schemaBytes [
9595
if err != nil {
9696
return nil, err
9797
}
98-
claim.SetIndexID(id)
98+
99+
switch credential.SubjectPosition {
100+
case "", utils.SubjectPositionIndex:
101+
claim.SetIndexID(id)
102+
case utils.SubjectPositionValue:
103+
claim.SetValueID(id)
104+
default:
105+
return nil, errors.New("unknown subject position")
106+
}
107+
99108
}
100109

101110
return claim, nil

json/parser.go

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,15 @@ func (s Parser) ParseClaim(credential *verifiable.Iden3Credential, schemaBytes [
6464
if err != nil {
6565
return nil, err
6666
}
67-
claim.SetIndexID(id)
67+
68+
switch credential.SubjectPosition {
69+
case "", utils.SubjectPositionIndex:
70+
claim.SetIndexID(id)
71+
case utils.SubjectPositionValue:
72+
claim.SetValueID(id)
73+
default:
74+
return nil, errors.New("unknown subject position")
75+
}
6876
}
6977

7078
return claim, nil

utils/claims.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@ import (
1111
"github.com/pkg/errors"
1212
)
1313

14+
const (
15+
// SubjectPositionIndex save subject in index part of claim. By default.
16+
SubjectPositionIndex = "index"
17+
// SubjectPositionValue save subject in value part of claim.
18+
SubjectPositionValue = "value"
19+
)
20+
1421
var q *big.Int
1522

1623
//nolint //reason - needed

0 commit comments

Comments
 (0)