From e4555a636af0ffb2bb14d84e91aac5cc78d81110 Mon Sep 17 00:00:00 2001 From: Goncalo Frade Date: Sun, 25 Feb 2024 11:15:26 +0000 Subject: [PATCH] feat(resolver): add agreement and authentication to document --- .../PeerDID/PeerDIDHelper+ResolveAlgo2.swift | 24 +++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/Sources/PeerDID/PeerDID/PeerDIDHelper+ResolveAlgo2.swift b/Sources/PeerDID/PeerDID/PeerDIDHelper+ResolveAlgo2.swift index 967e35d..c07f007 100644 --- a/Sources/PeerDID/PeerDID/PeerDIDHelper+ResolveAlgo2.swift +++ b/Sources/PeerDID/PeerDID/PeerDIDHelper+ResolveAlgo2.swift @@ -27,6 +27,28 @@ extension PeerDIDHelper { return method } + let keyAgreements = verificationMethods.filter { + guard let type = KnownVerificationMaterialType(rawValue: $0.type) else { + return false + } + + if case .agreement = type { + return true + } + return false + }.map(\.id) + + let authenticationAgreements = verificationMethods.filter { + guard let type = KnownVerificationMaterialType(rawValue: $0.type) else { + return false + } + + if case .agreement = type { + return true + } + return false + }.map(\.id) + let documentServices = try services.enumerated().map { try decodedPeerDIDService(did: peerDID.string, serviceString: $0.element, index: $0.offset) } @@ -34,6 +56,8 @@ extension PeerDIDHelper { return DIDDocument( id: peerDID.string, verificationMethods: verificationMethods, + authentication: authenticationAgreements.map { .stringValue($0) }, + keyAgreement: keyAgreements.map { .stringValue($0) }, services: documentServices ) }