From 36afa080c885ca7a06a6c50a37db2da865811267 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Gon=C3=A7alo=20Frade?= <106541307+beatt83@users.noreply.github.com> Date: Sun, 25 Feb 2024 11:20:46 +0000 Subject: [PATCH] feat(resolver): add agreement and authentication to document (#6) --- .../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 ) }