From d09f2bdbe98a4931cd94d87be80d686545ce05f0 Mon Sep 17 00:00:00 2001 From: Mykhailo Sizov Date: Tue, 8 Nov 2022 17:21:40 +0200 Subject: [PATCH] feat: add did code support in resolving service endpoints Signed-off-by: Mykhailo Sizov --- pkg/doc/did/doc.go | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/pkg/doc/did/doc.go b/pkg/doc/did/doc.go index 9e30c0133..1bebd9625 100644 --- a/pkg/doc/did/doc.go +++ b/pkg/doc/did/doc.go @@ -686,8 +686,8 @@ func populateServices(didID, baseURI string, rawServices []map[string]interface{ } else if epEntry != nil { // DIDComm V2 format (first valid entry for now). entries, ok := epEntry.([]interface{}) if ok && len(entries) > 0 { - firstEntry, ok := entries[0].(map[string]interface{}) - if ok { + firstEntry, is := entries[0].(map[string]interface{}) + if is { epURI := stringEntry(firstEntry["uri"]) epAccept := stringArray(firstEntry["accept"]) epRoutingKeys := stringArray(firstEntry["routingKeys"]) @@ -696,6 +696,12 @@ func populateServices(didID, baseURI string, rawServices []map[string]interface{ }) } } + coreServices, ok := epEntry.(map[string]interface{}) // DID Core + if ok && len(coreServices) > 0 { + instances := stringArray(coreServices["instances"]) + origins := stringArray(coreServices["origins"]) + sp = model.NewDIDCoreEndpoint(append(instances, origins...)) + } } }