Fix audience of VPs in issuance response

This commit is contained in:
sydneymorton 2020-10-16 09:36:46 -07:00
Родитель e2c82b58c3
Коммит bbe4dc3dad
2 изменённых файлов: 8 добавлений и 1 удалений

Просмотреть файл

@ -5,4 +5,5 @@
enum FormatterError: Error {
case noSigningKeyFound
case noAudienceFoundInRequest
}

Просмотреть файл

@ -79,7 +79,13 @@ public class IssuanceResponseFormatter: IssuanceResponseFormatting {
private func createPresentations(from response: IssuanceResponseContainer, usingIdentifier identifier: Identifier, andSignWith key: KeyContainer) throws -> [String: String] {
return try response.requestVCMap.mapValues { verifiableCredential in
let vp = try self.vpFormatter.format(toWrap: verifiableCredential, withAudience: response.contract.input!.credentialIssuer!, withExpiryInSeconds: response.expiryInSeconds, usingIdentifier: identifier, andSignWith: key)
guard let audience = response.contract.input?.issuer else {
throw FormatterError.noAudienceFoundInRequest
}
let vp = try self.vpFormatter.format(toWrap: verifiableCredential, withAudience: audience, withExpiryInSeconds: response.expiryInSeconds, usingIdentifier: identifier, andSignWith: key)
return try vp.serialize()
}
}