Skip to content

Commit

Permalink
Fix the session transcript - the cbor tag wasn't needed
Browse files Browse the repository at this point in the history
  • Loading branch information
QZHelen committed Feb 12, 2025
1 parent 44e0c69 commit 0c35590
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,10 @@ class CreateCredentialViewModel : ViewModel() {
val grant = openId4VCI.credentialOffer.grants!!.authorizationCode!!
Log.d(TAG, "Grant: $grant")
if (grant.vpRequest != null) {
val openId4VPRequest = OpenId4VP(grant.vpRequest)
val openId4VPRequest = OpenId4VP(
grant.vpRequest,
request.callingAppInfo.getOrigin(CmWalletApplication.credentialRepo.privAppsJson)
)
val selectedCredential = CmWalletApplication.credentialRepo.getCredential("1")
?: throw RuntimeException("Selected credential not found")
val matchedCredential =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,10 @@ class GetCredentialActivity : FragmentActivity() {
val digitalCredentialRequestOptions =
Json.decodeFromString<DigitalCredentialRequestOptions>(it.requestJson)
if (entryId == "ISSUANCE") {
val openId4VPRequest = OpenId4VP(digitalCredentialRequestOptions.providers[0].request)
val openId4VPRequest = OpenId4VP(
digitalCredentialRequestOptions.providers[0].request,
origin
)
startActivityForResult(
Intent(this, CreateCredentialActivity::class.java).apply {
val callingAppInfo = request.callingAppInfo
Expand Down Expand Up @@ -315,7 +318,7 @@ class GetCredentialActivity : FragmentActivity() {
)
when (provider.protocol) {
"openid4vp" -> {
val openId4VPRequest = OpenId4VP(provider.request)
val openId4VPRequest = OpenId4VP(provider.request, origin)
Log.i("GetCredentialActivity", "nonce ${openId4VPRequest.nonce}")
val matchedCredential =
openId4VPRequest.performQueryOnCredential(selectedCredential)
Expand Down
10 changes: 5 additions & 5 deletions app/src/main/java/com/credman/cmwallet/openid4vp/OpenId4VP.kt
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,22 @@ data class TransactionData(
val data: JSONObject
)

class OpenId4VP(val request: String) {
class OpenId4VP(val request: String, origin: String?) {
val requestJson: JSONObject = JSONObject(request)

val nonce: String
val clientId: String // TODO: parse out the scheme
val clientId: String
val dcqlQuery: JSONObject
val transactionData: List<TransactionData>
val issuanceOffer: JSONObject?

init {
// Parse required params
require(requestJson.has("client_id")) { "Authorization Request must contain a client_id" }
// require(requestJson.has("client_id")) { "Authorization Request must contain a client_id" }
clientId = "web-origin:$origin" // TODO: handle native app as origin
require(requestJson.has("nonce")) { "Authorization Request must contain a nonce" }
require(requestJson.has("dcql_query")) { "Authorization Request must contain a dcql_query" }

clientId = requestJson.getString("client_id")
nonce = requestJson.getString("nonce")
dcqlQuery = requestJson.getJSONObject("dcql_query")
issuanceOffer = requestJson.optJSONObject("offer")
Expand Down Expand Up @@ -139,7 +139,7 @@ class OpenId4VP(val request: String) {
val md = MessageDigest.getInstance("SHA-256")
return listOf(
oid4vpHandoverIdentifier,
md.digest(cborEncode(CborTag(24, cborEncode(handoverData))))
md.digest(cborEncode(handoverData))
)
}

Expand Down

0 comments on commit 0c35590

Please sign in to comment.