Skip to content

Commit

Permalink
Fix: Trim double quotes from disclosures
Browse files Browse the repository at this point in the history
  • Loading branch information
josmilan authored Nov 4, 2024
1 parent 124ea12 commit abe85c0
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ package com.ewc.eudi_wallet_oidc_android.models
import com.google.gson.annotations.SerializedName
data class VPTokenResponse(
@SerializedName("location") var location: String? = null,
@SerializedName("redirect_uri") var redirectUri: String? = null
)

data class WrappedVpTokenResponse(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,19 +295,25 @@ class SDJWTService : SDJWTServiceInterface {
disclosures[index],
Base64.URL_SAFE
).toString(charset("UTF-8"))
// Extract key-value pair from the encodedString
val (decodedKey, decodedValue) = extractKeyValue(disclosure)
// Add key-value pair to jsonObject
// Check if decodedValue is an object
// Convert decodedValue to string first
val decodedValueStr = decodedValue.toString()

// Check if the string has extra quotes and trim
val trimmedValue = if (decodedValueStr.startsWith("\"") && decodedValueStr.endsWith("\"")) {
decodedValueStr.trim('"')
} else {
decodedValueStr // Keep it as is if no extra quotes
}
if (decodedValue is JsonObject) {
// If it's an object, add it directly
jsonObject.add(decodedKey, decodedValue)
} else if (decodedValue is JsonArray) {
// If it's an object, add it directly
// If it's an array, add it directly
jsonObject.add(decodedKey, decodedValue)
} else {
// Otherwise, add it as a property
jsonObject.addProperty(decodedKey, decodedValue.toString())
jsonObject.addProperty(decodedKey, trimmedValue)
}
} catch (e: IllegalArgumentException) {
// Handle invalid base64-encoded strings
Expand Down

0 comments on commit abe85c0

Please sign in to comment.