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

Commit e290a6c

Browse files
authored
fix: did service endpoint bug. (#3449)
Signed-off-by: Volodymyr Kubiv <[email protected]> Signed-off-by: Volodymyr Kubiv <[email protected]>
1 parent 89ac465 commit e290a6c

File tree

3 files changed

+15
-3
lines changed

3 files changed

+15
-3
lines changed

pkg/doc/did/doc.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -698,9 +698,7 @@ func populateServices(didID, baseURI string, rawServices []map[string]interface{
698698
}
699699
coreServices, ok := epEntry.(map[string]interface{}) // DID Core
700700
if ok && len(coreServices) > 0 {
701-
instances := stringArray(coreServices["instances"])
702-
origins := stringArray(coreServices["origins"])
703-
sp = model.NewDIDCoreEndpoint(append(instances, origins...))
701+
sp = model.NewDIDCoreEndpoint(coreServices)
704702
}
705703
}
706704
}

pkg/doc/did/doc_test.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ var (
6969
validDocV011 string
7070
//go:embed testdata/valid_doc_with_base.jsonld
7171
validDocWithBase string
72+
//go:embed testdata/valid_doc_with_service_endpoint.jsonld
73+
validDocWithServiceEndpoint string
7274
)
7375

7476
func TestParseOfNull(t *testing.T) {
@@ -205,6 +207,17 @@ func TestDocResolution(t *testing.T) {
205207
require.Error(t, err)
206208
require.Contains(t, err.Error(), ErrDIDDocumentNotExist.Error())
207209
})
210+
211+
t.Run("Parse serialize then parse", func(t *testing.T) {
212+
d, err := ParseDocumentResolution([]byte(validDocWithServiceEndpoint))
213+
require.NoError(t, err)
214+
215+
serialized, err := d.JSONBytes()
216+
require.NoError(t, err)
217+
218+
_, err = ParseDocumentResolution(serialized)
219+
require.NoError(t, err)
220+
})
208221
}
209222

210223
func TestContextVariations(t *testing.T) {
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{"@context":"https://w3id.org/did-resolution/v1","didDocument":{"@context":["https://www.w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UUh6OU1EWnZKX0ZON2Fnblh2UlVKT1pucGFOOTNCUk9PUDlXbDFRIn0sInR5cGUiOiJjcmVhdGUifQ","service":[{"id":"#LinkedDomains","serviceEndpoint":{"origins":["http://vcs.webhook.example.com:8180/"]},"type":"LinkedDomains"}],"verificationMethod":[{"controller":"did:ion:EiAwKfUCtz4_Dw6d6XhRwtftkyuFgkC6BfJfng3R8HBbAA:eyJkZWx0YSI6eyJwYXRjaGVzIjpbeyJhY3Rpb24iOiJhZGQtcHVibGljLWtleXMiLCJwdWJsaWNLZXlzIjpbeyJpZCI6IjE2YmE2YjM4LTE0YjMtNDNjYy1hMGNjLTIyYjdhMTFiOTBmZCIsInB1YmxpY0tleUp3ayI6eyJjcnYiOiJzZWNwMjU2azEiLCJrdHkiOiJFQyIsIngiOiJydGVTVnFIX2pJT3BvNVBseUJDTko2TnhpZjNjM0VPbVB6WWp2Ynp3ajdBIiwieSI6InVFSF9wZGlBOEVRX3phYzhJTS1nSDNCS2ZlQ3FOeUtGM0ppeFFmWnFlX28ifSwicHVycG9zZXMiOlsiYXV0aGVudGljYXRpb24iLCJhc3NlcnRpb25NZXRob2QiXSwidHlwZSI6IkVjZHNhU2VjcDI1NmsxVmVyaWZpY2F0aW9uS2V5MjAxOSJ9XX0seyJhY3Rpb24iOiJhZGQtc2VydmljZXMiLCJzZXJ2aWNlcyI6W3siaWQiOiJMaW5rZWREb21haW5zIiwic2VydmljZUVuZHBvaW50Ijp7Im9yaWdpbnMiOlsiaHR0cDovL3Zjcy53ZWJob29rLmV4YW1wbGUuY29tOjgxODAvIl19LCJ0eXBlIjoiTGlua2VkRG9tYWlucyJ9XX1dLCJ1cGRhdGVDb21taXRtZW50IjoiRWlEYkdDeHFpMWpETW8wUFN1UVp5blVfSy12TmxYZ2RiX0RCbzFXZVQ5aHU4dyJ9LCJzdWZmaXhEYXRhIjp7ImRlbHRhSGFzaCI6IkVpQ01qTEIxY1NZNEEtcHpmWEt6Y2g2WDE5VU5xQmE0UndWQVFkRENDd2hDZmciLCJyZWNvdmVyeUNvbW1pdG1lbnQiOiJFaUF5Y1Z0UUh6OU1EWnZKX0ZON2Fnblh2UlVKT1pucGFOOTNCUk9PUDlXbDFRIn0sInR5cGUiOiJjcmVhdGUifQ","id":"#16ba6b38-14b3-43cc-a0cc-22b7a11b90fd","publicKeyJwk":{"crv":"secp256k1","kty":"EC","x":"rteSVqH_jIOpo5PlyBCNJ6Nxif3c3EOmPzYjvbzwj7A","y":"uEH_pdiA8EQ_zac8IM-gH3BKfeCqNyKF3JixQfZqe_o"},"type":"EcdsaSecp256k1VerificationKey2019"}]},"didDocumentMetadata":{"equivalentId":["did:ion:EiAwKfUCtz4_Dw6d6XhRwtftkyuFgkC6BfJfng3R8HBbAA"],"method":{"published":false,"recoveryCommitment":"EiAycVtQHz9MDZvJ_FN7agnXvRUJOZnpaN93BROOP9Wl1Q","updateCommitment":"EiDbGCxqi1jDMo0PSuQZynU_K-vNlXgdb_DBo1WeT9hu8w"}}}

0 commit comments

Comments
 (0)