commonMain.at.asitplus.wallet.lib.oidvci.NonceService.kt Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of vck-openid Show documentation
Show all versions of vck-openid Show documentation
Kotlin Multiplatform library implementing the W3C VC Data Model, with OpenId protocol implementations
The newest version!
package at.asitplus.wallet.lib.oidvci
import com.benasher44.uuid.uuid4
interface NonceService {
fun provideNonce(): String
fun verifyAndRemoveNonce(it: String): Boolean
}
class DefaultNonceService : NonceService {
private val validNonces = mutableListOf()
override fun provideNonce(): String {
return uuid4().toString().also { validNonces += it }
}
override fun verifyAndRemoveNonce(it: String): Boolean {
return validNonces.remove(it)
}
}