Skip to content

Commit

Permalink
feat(resolver): add agreement and authentication to document (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
beatt83 authored Feb 25, 2024
1 parent 083b8fd commit 36afa08
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions Sources/PeerDID/PeerDID/PeerDIDHelper+ResolveAlgo2.swift
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,37 @@ 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)
}

return DIDDocument(
id: peerDID.string,
verificationMethods: verificationMethods,
authentication: authenticationAgreements.map { .stringValue($0) },
keyAgreement: keyAgreements.map { .stringValue($0) },
services: documentServices
)
}
Expand Down

0 comments on commit 36afa08

Please sign in to comment.