Fix crash when parsing JWT and 'name' property is not present in the … (#146)

Co-authored-by: David Perez <david@livefront.com>
This commit is contained in:
Brian Yencho 2023-10-23 13:44:55 -05:00 committed by Álison Fernandes
parent 284cd9ab54
commit 4ebaec7970

View file

@ -2,12 +2,19 @@ package com.x8bit.bitwarden.data.auth.repository.util
import com.x8bit.bitwarden.data.auth.repository.model.JwtTokenDataJson
import com.x8bit.bitwarden.data.platform.datasource.network.util.base64UrlDecodeOrNull
import kotlinx.serialization.ExperimentalSerializationApi
import kotlinx.serialization.json.Json
/**
* Internal, generally basic [Json] instance for JWT parsing purposes.
*/
private val json by lazy { Json { ignoreUnknownKeys = true } }
@OptIn(ExperimentalSerializationApi::class)
private val json: Json by lazy {
Json {
ignoreUnknownKeys = true
explicitNulls = false
}
}
/**
* Parses a [JwtTokenDataJson] from the given [jwtToken], or `null` if this parsing is not possible.