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

Commit 247f044

Browse files
aholovkoFiras Qutishat
andauthored
fix: parse generic ServicePoint (#3409)
Signed-off-by: Firas Qutishat <firas.qutishat@securekey.com> Signed-off-by: Andrii Holovko <andriy.holovko@gmail.com> Signed-off-by: Firas Qutishat <firas.qutishat@securekey.com> Signed-off-by: Andrii Holovko <andriy.holovko@gmail.com> Co-authored-by: Firas Qutishat <firas.qutishat@securekey.com>
1 parent 2b9ca43 commit 247f044

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

pkg/doc/did/doc.go

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1317,7 +1317,7 @@ func (r *didKeyResolver) Resolve(id string) (*verifier.PublicKey, error) {
13171317
// ErrKeyNotFound is returned when key is not found.
13181318
var ErrKeyNotFound = errors.New("key not found")
13191319

1320-
// nolint:funlen,gocognit,gocyclo
1320+
// nolint:funlen,gocognit,gocyclo,nestif
13211321
func populateRawServices(services []Service, didID, baseURI string) []map[string]interface{} {
13221322
var rawServices []map[string]interface{}
13231323

@@ -1389,7 +1389,7 @@ func populateRawServices(services []Service, didID, baseURI string) []map[string
13891389

13901390
rawService[jsonldType] = services[i].Type
13911391

1392-
if services[i].ServiceEndpoint.Type() == model.DIDCommV2 { // DIDComm V2
1392+
if services[i].ServiceEndpoint.Type() == model.DIDCommV2 { //nolint: gocritic
13931393
serviceEndpointMap := []map[string]interface{}{{"uri": sepURI}}
13941394
if len(sepAccept) > 0 {
13951395
serviceEndpointMap[0]["accept"] = sepAccept
@@ -1400,8 +1400,15 @@ func populateRawServices(services []Service, didID, baseURI string) []map[string
14001400
}
14011401

14021402
rawService[jsonldServicePoint] = serviceEndpointMap
1403-
} else { // DIDComm V1, default is generic endpoint as string URI
1403+
} else if services[i].ServiceEndpoint.Type() == model.DIDCommV1 {
14041404
rawService[jsonldServicePoint] = sepURI
1405+
} else {
1406+
bytes, err := services[i].ServiceEndpoint.MarshalJSON()
1407+
if err != nil {
1408+
logger.Warnf(err.Error())
1409+
}
1410+
1411+
rawService[jsonldServicePoint] = json.RawMessage(bytes)
14051412
}
14061413

14071414
rawService[jsonldPriority] = services[i].Priority

0 commit comments

Comments
 (0)