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 20, 2024
1 parent 5366a31 commit e5e5e85
Showing 1 changed file with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,8 @@ class OpenID4VPPresentationActivity : FragmentActivity() {
inputDescriptor: JsonObject
): Pair<String, List<String>> {
val requestedClaims = mutableListOf<String>()
val vct = EUPersonalID.EUPID_VCT // TODO: extract from `inputDescriptor`
// Set the default vct if we don't detect it below.
var vct = EUPersonalID.EUPID_VCT

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

if (path == "\"\$.vct\"") {
val filter = fieldObj["filter"]!!.jsonObject
vct = filter["const"]!!.toString().run { substring(1, this.length - 1) }
}
}
return Pair(vct, requestedClaims)
}
Expand Down Expand Up @@ -490,18 +496,10 @@ 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}")
Logger.d(TAG, "Error: Expected input descriptor field is missing: ${e.message}")
""
}
}
Expand Down

0 comments on commit e5e5e85

Please sign in to comment.