diff --git a/src/main/kotlin/eu/europa/ec/eudi/verifier/endpoint/VerifierContext.kt b/src/main/kotlin/eu/europa/ec/eudi/verifier/endpoint/VerifierContext.kt index 8a7ba137..414d67e2 100644 --- a/src/main/kotlin/eu/europa/ec/eudi/verifier/endpoint/VerifierContext.kt +++ b/src/main/kotlin/eu/europa/ec/eudi/verifier/endpoint/VerifierContext.kt @@ -102,6 +102,7 @@ internal fun beans(clock: Clock) = beans { WalletApi.requestJwtByReference(env.publicUrl()), WalletApi.presentationDefinitionByReference(env.publicUrl()), ref(), + WalletApi.requestZkpKey(env.publicUrl()), ) } @@ -351,11 +352,6 @@ private fun Environment.clientMetaData(publicUrl: String): ClientMetaData { authorizationEncryptedResponseAlg, authorizationEncryptedResponseEnc, ) ?: defaultJarmOption, - zkpOption = WalletApi.requestZkpKey(publicUrl), - vpFormats = mapOf( - "vc+sd-jwt+zkp" to VpFormat(listOf("secp256r1-sha256")), - "mso_mdoc+zkp" to VpFormat(listOf("secp256r1-sha256")), - ), ) } diff --git a/src/main/kotlin/eu/europa/ec/eudi/verifier/endpoint/adapter/out/jose/SignRequestObjectNimbus.kt b/src/main/kotlin/eu/europa/ec/eudi/verifier/endpoint/adapter/out/jose/SignRequestObjectNimbus.kt index 026a3d1a..a8b1d31e 100644 --- a/src/main/kotlin/eu/europa/ec/eudi/verifier/endpoint/adapter/out/jose/SignRequestObjectNimbus.kt +++ b/src/main/kotlin/eu/europa/ec/eudi/verifier/endpoint/adapter/out/jose/SignRequestObjectNimbus.kt @@ -134,8 +134,6 @@ class SignRequestObjectNimbus : SignRequestObject { jwkSet?.let { this.jwkSet = it } jwkSetUri?.let { this.jwkSetURI = it.toURI() } setCustomField("subject_syntax_types_supported", c.subjectSyntaxTypesSupported) - setCustomField("vp_formats", c.vpFormats) - setCustomField("vp_token_zkp_key_uri", (c.zkpOption as ByReference).buildUrl) if ("direct_post.jwt" == responseMode) { c.jarmOption.jwsAlg?.let { setCustomField("authorization_signed_response_alg", it) } diff --git a/src/main/kotlin/eu/europa/ec/eudi/verifier/endpoint/domain/Presentation.kt b/src/main/kotlin/eu/europa/ec/eudi/verifier/endpoint/domain/Presentation.kt index da07e74b..f37f4838 100644 --- a/src/main/kotlin/eu/europa/ec/eudi/verifier/endpoint/domain/Presentation.kt +++ b/src/main/kotlin/eu/europa/ec/eudi/verifier/endpoint/domain/Presentation.kt @@ -138,7 +138,7 @@ sealed interface Presentation { /** * A presentation process that has been just requested */ - class Requested( + data class Requested( override val id: TransactionId, override val initiatedAt: Instant, override val type: PresentationType, @@ -148,6 +148,7 @@ sealed interface Presentation { val responseMode: ResponseModeOption, val presentationDefinitionMode: EmbedOption, val getWalletResponseMethod: GetWalletResponseMethod, + val zkpOption: EmbedOption? = null, ) : Presentation /** diff --git a/src/main/kotlin/eu/europa/ec/eudi/verifier/endpoint/domain/VerifierConfig.kt b/src/main/kotlin/eu/europa/ec/eudi/verifier/endpoint/domain/VerifierConfig.kt index 0df5ccc1..4cf4996b 100644 --- a/src/main/kotlin/eu/europa/ec/eudi/verifier/endpoint/domain/VerifierConfig.kt +++ b/src/main/kotlin/eu/europa/ec/eudi/verifier/endpoint/domain/VerifierConfig.kt @@ -93,8 +93,6 @@ data class ClientMetaData( val idTokenEncryptedResponseEnc: String, val subjectSyntaxTypesSupported: List, val jarmOption: JarmOption, - val zkpOption: EmbedOption, - val vpFormats: Map, ) /** diff --git a/src/main/kotlin/eu/europa/ec/eudi/verifier/endpoint/port/input/InitTransaction.kt b/src/main/kotlin/eu/europa/ec/eudi/verifier/endpoint/port/input/InitTransaction.kt index 793bb52b..5af46222 100644 --- a/src/main/kotlin/eu/europa/ec/eudi/verifier/endpoint/port/input/InitTransaction.kt +++ b/src/main/kotlin/eu/europa/ec/eudi/verifier/endpoint/port/input/InitTransaction.kt @@ -20,6 +20,8 @@ package eu.europa.ec.eudi.verifier.endpoint.port.input import arrow.core.raise.Raise import arrow.core.raise.ensure import arrow.core.raise.ensureNotNull +import com.fasterxml.jackson.databind.JsonNode +import com.fasterxml.jackson.databind.ObjectMapper import eu.europa.ec.eudi.prex.PresentationDefinition import eu.europa.ec.eudi.verifier.endpoint.domain.* import eu.europa.ec.eudi.verifier.endpoint.port.out.cfg.CreateQueryWalletResponseRedirectUri @@ -149,7 +151,7 @@ class InitTransactionLive( private val requestJarByReference: EmbedOption.ByReference, private val presentationDefinitionByReference: EmbedOption.ByReference, private val createQueryWalletResponseRedirectUri: CreateQueryWalletResponseRedirectUri, - + private val zkpOption: EmbedOption.ByReference, ) : InitTransaction { context(Raise) @@ -161,9 +163,8 @@ class InitTransactionLive( val responseMode = responseMode(initTransactionTO) val newEphemeralEcPublicKey = ephemeralEncryptionKeyPair(responseMode) val getWalletResponseMethod = getWalletResponseMethod(initTransactionTO) - // Initialize presentation - val requestedPresentation = Presentation.Requested( + var requestedPresentation = Presentation.Requested( id = generateTransactionId(), initiatedAt = clock.instant(), requestId = generateRequestId(), @@ -174,6 +175,18 @@ class InitTransactionLive( presentationDefinitionMode = presentationDefinitionMode(initTransactionTO), getWalletResponseMethod = getWalletResponseMethod, ) + + initTransactionTO.presentationDefinition?.format?.let { format -> + val objectMapper = ObjectMapper() + val json: JsonNode = objectMapper.valueToTree(format) + + // add the zkp uri to the presentation if zkp is required + if (json.has("vc+sd-jwt+zkp") || json.has("mso_mdoc+zkp")) { + requestedPresentation = requestedPresentation.copy( + zkpOption = zkpOption, + ) + } + } // create request, which may update presentation val (updatedPresentation, request) = createRequest(requestedPresentation, jarMode(initTransactionTO)) diff --git a/src/test/kotlin/eu/europa/ec/eudi/verifier/endpoint/TestContext.kt b/src/test/kotlin/eu/europa/ec/eudi/verifier/endpoint/TestContext.kt index 7685c81a..d7656a06 100644 --- a/src/test/kotlin/eu/europa/ec/eudi/verifier/endpoint/TestContext.kt +++ b/src/test/kotlin/eu/europa/ec/eudi/verifier/endpoint/TestContext.kt @@ -41,10 +41,6 @@ import org.springframework.context.support.GenericApplicationContext import org.springframework.core.annotation.AliasFor import org.springframework.core.io.ClassPathResource import org.springframework.test.context.ContextConfiguration -import java.net.URI -import java.net.URL -import java.net.URLConnection -import java.net.URLStreamHandler import java.security.KeyStore import java.time.Clock import java.time.Instant @@ -69,9 +65,6 @@ object TestContext { } } - class VpFormat - private val vpFormatExample = VpFormat() - private val vpFormats = mapOf("exampleFormat" to vpFormatExample) val clientMetaData = ClientMetaData( jwkOption = ByValue, idTokenSignedResponseAlg = JWSAlgorithm.RS256.name, @@ -79,17 +72,6 @@ object TestContext { idTokenEncryptedResponseEnc = EncryptionMethod.A128CBC_HS256.name, subjectSyntaxTypesSupported = listOf("urn:ietf:params:oauth:jwk-thumbprint", "did:example", "did:key"), jarmOption = ParseJarmOptionNimbus(null, JWEAlgorithm.ECDH_ES.name, "A256GCM")!!, - vpFormats = vpFormats, - zkpOption = EmbedOption.byReference { - URL.of( - URI("tt"), - object : URLStreamHandler() { - override fun openConnection(u: URL?): URLConnection { - TODO("Not yet implemented") - } - }, - ) - }, ) val jarSigningConfig: SigningConfig = SigningConfig(rsaJwk, JWSAlgorithm.RS256) val clientIdScheme = ClientIdScheme.X509SanDns("client-id", jarSigningConfig) @@ -105,6 +87,7 @@ object TestContext { verifierConfig: VerifierConfig, requestJarByReference: EmbedOption.ByReference, presentationDefinitionByReference: EmbedOption.ByReference, + zkpOption: EmbedOption.ByReference, ): InitTransaction = InitTransactionLive( generatedTransactionId, @@ -117,6 +100,8 @@ object TestContext { requestJarByReference, presentationDefinitionByReference, CreateQueryWalletResponseRedirectUri.Simple, + zkpOption, + ) fun getRequestObject(verifierConfig: VerifierConfig, presentationInitiatedAt: Instant): GetRequestObject = diff --git a/src/test/kotlin/eu/europa/ec/eudi/verifier/endpoint/port/input/InitTransactionTest.kt b/src/test/kotlin/eu/europa/ec/eudi/verifier/endpoint/port/input/InitTransactionTest.kt index a275b153..2736e7bc 100644 --- a/src/test/kotlin/eu/europa/ec/eudi/verifier/endpoint/port/input/InitTransactionTest.kt +++ b/src/test/kotlin/eu/europa/ec/eudi/verifier/endpoint/port/input/InitTransactionTest.kt @@ -58,6 +58,7 @@ class InitTransactionTest { verifierConfig, EmbedOption.byReference { _ -> uri }, EmbedOption.byReference { _ -> uri }, + EmbedOption.byReference { _ -> uri }, ) val jwtSecuredAuthorizationRequest = either { useCase(input) }.getOrElse { fail("Unexpected $it") } @@ -93,6 +94,7 @@ class InitTransactionTest { verifierConfig, EmbedOption.byReference { _ -> uri }, EmbedOption.byReference { _ -> uri }, + EmbedOption.byReference { _ -> uri }, ) val jwtSecuredAuthorizationRequest = either { useCase(input) }.getOrElse { fail("Unexpected $it") } @@ -146,6 +148,7 @@ class InitTransactionTest { verifierConfig, EmbedOption.byReference { _ -> uri }, EmbedOption.byReference { _ -> uri }, + EmbedOption.byReference { _ -> uri }, ) val jwtSecuredAuthorizationRequest = either { useCase(input) }.getOrElse { fail("Unexpected $it") } @@ -173,6 +176,7 @@ class InitTransactionTest { verifierConfig, EmbedOption.byReference { _ -> uri }, EmbedOption.byReference { _ -> uri }, + EmbedOption.byReference { _ -> uri }, ) // we expect the Authorization Request to contain a request_uri @@ -200,6 +204,7 @@ class InitTransactionTest { verifierConfig, EmbedOption.byReference { _ -> uri }, EmbedOption.byReference { _ -> uri }, + EmbedOption.byReference { _ -> uri }, ) // we expect the Authorization Request to contain a request that contains a presentation_definition_uri @@ -221,6 +226,7 @@ class InitTransactionTest { verifierConfig, EmbedOption.byReference { _ -> uri }, EmbedOption.byReference { _ -> uri }, + EmbedOption.byReference { _ -> uri }, ) val invalidPlaceHolderInput = InitTransactionTO( @@ -277,6 +283,7 @@ class InitTransactionTest { verifierConfig, EmbedOption.byReference { _ -> uri }, EmbedOption.byReference { _ -> uri }, + EmbedOption.byReference { _ -> uri }, ) either { useCase(input) }.getOrElse { fail("Unexpected $it") } @@ -299,6 +306,7 @@ class InitTransactionTest { verifierConfig, EmbedOption.byReference { _ -> uri }, EmbedOption.byReference { _ -> uri }, + EmbedOption.byReference { _ -> uri }, ) either { useCase(input) }.getOrElse { fail("Unexpected $it") }