WebAuthnProvider

Platform-specific WebAuthn provider interface.

This interface defines the contract for WebAuthn operations across different platforms (JVM, JS browser, iOS, Android). Each platform provides its own implementation using expect/actual declarations.

Implementations must:

  • Trigger platform-specific biometric/security key prompts

  • Handle WebAuthn credential creation and assertion

  • Return properly formatted results with raw byte arrays

Example implementation pattern (expect/actual):

// commonMain
expect class WebAuthnProviderImpl : WebAuthnProvider

// jsMain (browser)
actual class WebAuthnProviderImpl : WebAuthnProvider {
actual suspend fun register(...) { ... navigator.credentials.create ... }
actual suspend fun authenticate(...) { ... navigator.credentials.get ... }
}

// jvmMain
actual class WebAuthnProviderImpl : WebAuthnProvider {
// Placeholder implementation or integration with Java WebAuthn library
}

Usage:

val config = OZSmartAccountConfig(
...
webauthnProvider = WebAuthnProviderImpl()
)

Inheritors

AndroidWebAuthnProvider
JsWebAuthnProvider
AppleWebAuthnProvider

Functions

Link copied to clipboard
abstract suspend fun authenticate(challenge: ByteArray, allowCredentials: List<AllowCredential>? = null): WebAuthnAuthenticationResult

Authenticates with an existing WebAuthn credential (passkey assertion).

Link copied to clipboard
abstract suspend fun register(challenge: ByteArray, userId: ByteArray, userName: String): WebAuthnRegistrationResult

Registers a new WebAuthn credential (passkey creation).