From 2ccc9dee65f4502cec21d32712215f7650e13d74 Mon Sep 17 00:00:00 2001 From: "Colton Wolkins (Laptop)" Date: Fri, 1 Dec 2023 06:55:21 -0700 Subject: [PATCH] fix: correctly parse multiple service blocks Signed-off-by: Colton Wolkins (Laptop) --- src/lib/peer2.ts | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/src/lib/peer2.ts b/src/lib/peer2.ts index 23a677a..7058865 100644 --- a/src/lib/peer2.ts +++ b/src/lib/peer2.ts @@ -157,7 +157,9 @@ export default class DIDPeer { const doc: any = { "@context": "https://www.w3.org/ns/did/v1", id: did, + service: [], } + let serviceIndex = 0; elements.forEach(element => { const purposeCode = element.charAt(0) @@ -229,13 +231,14 @@ export default class DIDPeer { .map((service: any) => { // TODO This is a bandaid! Mediator should include id in services. if (!("id" in service)) { - service.id = "#service" + let suffix = serviceIndex++ > 0 ? "" : `-${serviceIndex}` + service.id = `#service${suffix}` } return service }) .map(DIDPeer.transformOldServiceStyleToNew) - doc.service = services + doc.service.push(...services) break }