remove extension method from Map<>

This commit is contained in:
Adam Velebil 2024-03-11 16:12:07 +01:00
parent 000f0d83ac
commit a9a5532067
No known key found for this signature in database
GPG Key ID: C9B1E4A3CBBD2E10

View File

@ -28,16 +28,21 @@ data class Options(
val credentialMgmtPreview: Boolean, val credentialMgmtPreview: Boolean,
val bioEnroll: Boolean?, val bioEnroll: Boolean?,
val alwaysUv: Boolean val alwaysUv: Boolean
) ) {
constructor(infoData: InfoData) : this(
infoData.getOptionsBoolean("clientPin") ?: false,
infoData.getOptionsBoolean("credMgmt") ?: false,
infoData.getOptionsBoolean("credentialMgmtPreview") ?: false,
infoData.getOptionsBoolean("bioEnroll"),
infoData.getOptionsBoolean("alwaysUv") ?: false,
)
fun Map<String, Any?>.getBoolean( companion object {
key: String, private fun InfoData.getOptionsBoolean(
default: Boolean = false key: String
): Boolean = get(key) as? Boolean ?: default ): Boolean? = options[key] as? Boolean?
}
fun Map<String, Any?>.getOptionalBoolean( }
key: String
): Boolean? = get(key) as? Boolean
@Serializable @Serializable
data class SessionInfo( data class SessionInfo(
@ -49,13 +54,7 @@ data class SessionInfo(
val forcePinChange: Boolean val forcePinChange: Boolean
) { ) {
constructor(infoData: InfoData) : this( constructor(infoData: InfoData) : this(
Options( Options(infoData),
infoData.options.getBoolean("clientPin"),
infoData.options.getBoolean("credMgmt"),
infoData.options.getBoolean("credentialMgmtPreview"),
infoData.options.getOptionalBoolean("bioEnroll"),
infoData.options.getBoolean("alwaysUv")
),
infoData.aaguid, infoData.aaguid,
infoData.minPinLength, infoData.minPinLength,
infoData.forcePinChange infoData.forcePinChange