Skip to content

Commit

Permalink
Fix the detected vct when parsing the input detector for claim descri…
Browse files Browse the repository at this point in the history
…ptions.

This fixes a bug where the new naturalization_date field wasn't showing its
display name correctly because we weren't detecting the credential type
correctly.

Tested by:
- Manual testing.
- ./gradlew check

Signed-off-by: Kevin Deus <[email protected]>
  • Loading branch information
kdeus committed Nov 19, 2024
1 parent 5366a31 commit a1273e4
Showing 1 changed file with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,7 @@ class OpenID4VPPresentationActivity : FragmentActivity() {
inputDescriptor: JsonObject
): Pair<String, List<String>> {
val requestedClaims = mutableListOf<String>()
val vct = EUPersonalID.EUPID_VCT // TODO: extract from `inputDescriptor`
var vct = EUPersonalID.EUPID_VCT

val constraints = inputDescriptor["constraints"]!!.jsonObject
val fields = constraints["fields"]!!.jsonArray
Expand All @@ -453,6 +453,12 @@ class OpenID4VPPresentationActivity : FragmentActivity() {
val parsed = parsePathItem(path)
val claimName = parsed.second
requestedClaims.add(claimName)

if (field.jsonObject["path"]!!.jsonArray[0].toString() == "\"\$.vct\"") {
val vctField = field.jsonObject
val filter = vctField["filter"]!!.jsonObject
vct = filter["const"]!!.toString().run { substring(1, this.length - 1) }
}
}
return Pair(vct, requestedClaims)
}
Expand Down Expand Up @@ -490,15 +496,7 @@ class OpenID4VPPresentationActivity : FragmentActivity() {
inputDescriptorObj["id"]!!.toString().run { substring(1, this.length - 1) }
} else {
try {
var vct = ""
val constraints = inputDescriptorObj["constraints"]!!.jsonObject
for (field in constraints["fields"]!!.jsonArray) {
if (field.jsonObject["path"]!!.jsonArray[0].toString() == "\"\$.vct\"") {
val vctField = field.jsonObject
val filter = vctField["filter"]!!.jsonObject
vct = filter["const"]!!.toString().run { substring(1, this.length - 1) }
}
}
val (vct, _) = parseInputDescriptorForVc(inputDescriptorObj)
vct
} catch (e: NullPointerException) {
Logger.d(TAG, "Error: Could not find const filter field: ${e.message}")
Expand Down

0 comments on commit a1273e4

Please sign in to comment.