diff --git a/server/src/main/java/com/android/identity/wallet/server/VerifierServlet.kt b/server/src/main/java/com/android/identity/wallet/server/VerifierServlet.kt index 1c1f8adc4..9ef3ec042 100644 --- a/server/src/main/java/com/android/identity/wallet/server/VerifierServlet.kt +++ b/server/src/main/java/com/android/identity/wallet/server/VerifierServlet.kt @@ -90,6 +90,7 @@ enum class Protocol { PLAIN_OPENID4VP, EUDI_OPENID4VP, MDOC_OPENID4VP, + CUSTOM_OPENID4VP, } @Serializable @@ -98,7 +99,8 @@ private data class OpenID4VPBeginRequest( val docType: String, val requestId: String, val protocol: String, - val origin: String + val origin: String, + val scheme: String ) @Serializable @@ -578,6 +580,7 @@ lrW+vvdmRHBgS+ss56uWyYor6W7ah9ygBwYFK4EEACI= "openid4vp_plain" -> Protocol.PLAIN_OPENID4VP "openid4vp_eudi" -> Protocol.EUDI_OPENID4VP "openid4vp_mdoc" -> Protocol.MDOC_OPENID4VP + "openid4vp_custom" -> Protocol.CUSTOM_OPENID4VP else -> { Logger.w(TAG, "$remoteHost: Unknown protocol '$request.protocol'") resp.status = HttpServletResponse.SC_BAD_REQUEST @@ -766,6 +769,7 @@ lrW+vvdmRHBgS+ss56uWyYor6W7ah9ygBwYFK4EEACI= "openid4vp_plain" -> Protocol.PLAIN_OPENID4VP "openid4vp_eudi" -> Protocol.EUDI_OPENID4VP "openid4vp_mdoc" -> Protocol.MDOC_OPENID4VP + "openid4vp_custom" -> Protocol.CUSTOM_OPENID4VP else -> { Logger.w(TAG, "$remoteHost: Unknown protocol '$request.protocol'") resp.status = HttpServletResponse.SC_BAD_REQUEST @@ -797,6 +801,7 @@ lrW+vvdmRHBgS+ss56uWyYor6W7ah9ygBwYFK4EEACI= Protocol.PLAIN_OPENID4VP -> "openid4vp://" Protocol.EUDI_OPENID4VP -> "eudi-openid4vp://" Protocol.MDOC_OPENID4VP -> "mdoc-openid4vp://" + Protocol.CUSTOM_OPENID4VP -> request.scheme else -> { Logger.w(TAG, "$remoteHost: Unknown protocol '${session.protocol}'") resp.status = HttpServletResponse.SC_BAD_REQUEST diff --git a/server/src/main/webapp/verifier.html b/server/src/main/webapp/verifier.html index cefe4c2ed..4eb1b35f5 100644 --- a/server/src/main/webapp/verifier.html +++ b/server/src/main/webapp/verifier.html @@ -31,9 +31,9 @@

Request Digital Documents

Selected protocol for retrieval: -
+
+
diff --git a/server/src/main/webapp/verifier.js b/server/src/main/webapp/verifier.js index 896edb032..61f2a3f19 100644 --- a/server/src/main/webapp/verifier.js +++ b/server/src/main/webapp/verifier.js @@ -19,10 +19,14 @@ async function onLoad() { selected === 'w3c_dc_arf' || selected === 'openid4vp_plain' || selected === 'openid4vp_eudi' || - selected === 'openid4vp_mdoc') { + selected === 'openid4vp_mdoc' || + selected === 'openid4vp_custom') { selectedProtocol = selected preferredProtocol = selectedProtocol protocolDropdown.innerHTML = target.innerHTML + + const scheme = document.getElementById("scheme-form"); + scheme.hidden = selected !== 'openid4vp_custom'; } }) @@ -141,7 +145,11 @@ function redirectClose() { async function requestDocument(format, docType, requestId) { console.log('requestDocument, format=' + format + ' docType=' + docType + ' requestId=' + requestId + ' protocol=' + selectedProtocol) - if (selectedProtocol.startsWith('openid4vp_')) { + if (selectedProtocol === 'openid4vp_custom') { + if (document.getElementById("scheme-input").value === "") { + alert("You must specify a non-empty scheme when performing a custom OpenID4VP request.") + return + } const response = await callServer( 'openid4vpBegin', { @@ -150,10 +158,25 @@ async function requestDocument(format, docType, requestId) { requestId: requestId, protocol: selectedProtocol, origin: location.origin, + scheme: document.getElementById("scheme-input").value } ) console.log("URI " + response.uri) window.open(response.uri, '_blank').focus() + } else if (selectedProtocol.startsWith('openid4vp_')) { + const response = await callServer( + 'openid4vpBegin', + { + format: format, + docType: docType, + requestId: requestId, + protocol: selectedProtocol, + origin: location.origin, + scheme: "" + } + ) + console.log("URI " + response.uri) + window.open(response.uri, '_blank').focus() } else if (selectedProtocol === "w3c_dc_preview") { try { const response = await callServer( @@ -247,4 +270,4 @@ async function callServer(command, params) { } ) return await response.json() -} +} \ No newline at end of file