@@ -36,6 +36,8 @@ import com.credman.cmwallet.openid4vci.data.CredentialConfigurationMDoc
36
36
import com.credman.cmwallet.openid4vci.data.CredentialConfigurationSdJwtVc
37
37
import com.credman.cmwallet.openid4vci.data.CredentialConfigurationUnknownFormat
38
38
import com.credman.cmwallet.openid4vp.OpenId4VP
39
+ import com.credman.cmwallet.openid4vp.OpenId4VP.Companion.IDENTIFIERS_1_0
40
+ import com.credman.cmwallet.openid4vp.OpenId4VP.Companion.IDENTIFIER_DRAFT_24
39
41
import com.credman.cmwallet.openid4vp.OpenId4VPMatchedCredential
40
42
import com.credman.cmwallet.openid4vp.OpenId4VPMatchedMDocClaims
41
43
import com.credman.cmwallet.openid4vp.OpenId4VPMatchedSdJwtClaims
@@ -44,6 +46,7 @@ import com.credman.cmwallet.sdjwt.SdJwt
44
46
import com.credman.cmwallet.toBase64UrlNoPadding
45
47
import com.google.android.gms.identitycredentials.Credential
46
48
import com.google.android.gms.identitycredentials.IntentHelper
49
+ import org.json.JSONArray
47
50
import org.json.JSONObject
48
51
49
52
@@ -57,6 +60,7 @@ fun createOpenID4VPResponse(
57
60
var authenticationSubtitle: CharSequence? = null
58
61
// Create the response
59
62
val vpToken = JSONObject ()
63
+ var credentialResponse: String? = null
60
64
when (selectedCredential.config) {
61
65
is CredentialConfigurationSdJwtVc -> {
62
66
val claims =
@@ -65,14 +69,12 @@ fun createOpenID4VPResponse(
65
69
selectedCredential.credentials.first().credential,
66
70
(selectedCredential.credentials.first().key as CredentialKeySoftware ).privateKey
67
71
)
68
- vpToken.put(
69
- matchedCredential.dcqlId,
72
+ credentialResponse =
70
73
sdJwtVc.present(
71
74
claims,
72
75
nonce = openId4VPRequest.nonce,
73
76
aud = openId4VPRequest.getSdJwtKbAud(origin)
74
77
)
75
- )
76
78
}
77
79
is CredentialConfigurationMDoc -> {
78
80
val matchedClaims =
@@ -115,13 +117,20 @@ fun createOpenID4VPResponse(
115
117
deviceNamespaces = deviceNamespaces
116
118
117
119
)
118
- val encodedDeviceResponse = deviceResponse.toBase64UrlNoPadding()
119
- vpToken.put(matchedCredential.dcqlId, encodedDeviceResponse)
120
+ credentialResponse = deviceResponse.toBase64UrlNoPadding()
120
121
}
121
122
122
123
is CredentialConfigurationUnknownFormat -> TODO ()
123
124
}
124
125
126
+ vpToken.put(
127
+ matchedCredential.dcqlId,
128
+ when (openId4VPRequest.protocolIdentifier) {
129
+ IDENTIFIER_DRAFT_24 -> credentialResponse
130
+ in IDENTIFIERS_1_0 -> JSONArray ().put(credentialResponse)
131
+ else -> throw UnsupportedOperationException (" Invalid protocol identifier" )
132
+ }
133
+ )
125
134
// Create the openid4vp result
126
135
val response = openId4VPRequest.generateResponse(vpToken)
127
136
Log .d(TAG , " Returning $response " )
0 commit comments