AndroidWebAuthnProvider

class AndroidWebAuthnProvider(context: Context, rpId: String, rpName: String, timeout: Long = OZConstants.WEBAUTHN_TIMEOUT_MS, authenticatorAttachment: String? = null) : WebAuthnProvider

Android implementation of WebAuthnProvider using the Credential Manager API.

Uses androidx.credentials.CredentialManager to interact with platform authenticators (biometric, screen lock, security keys) for passkey registration and authentication. The Credential Manager API is available on Android API 28+ (Android 9.0 Pie).

This provider creates FIDO2/WebAuthn credentials using the secp256r1 (P-256) algorithm with the ES256 signature scheme, as required by Stellar smart account contracts.

Usage:

// In an Activity or Fragment
val provider = AndroidWebAuthnProvider(
context = this, // Activity context required
rpId = "example.com",
rpName = "My Stellar App"
)

// Register a new passkey
val registration = provider.register(
challenge = challengeBytes,
userId = userIdBytes,
userName = "user@example.com"
)

// Authenticate with existing passkey
val authentication = provider.authenticate(
challenge = authChallengeBytes
)

Throws

if the device runs Android API level < 28

Constructors

Link copied to clipboard
constructor(context: Context, rpId: String, rpName: String, timeout: Long = OZConstants.WEBAUTHN_TIMEOUT_MS, authenticatorAttachment: String? = null)

Types

Link copied to clipboard
object Companion

Functions

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

Authenticates with an existing WebAuthn credential (passkey) using the Android Credential Manager.

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

Registers a new WebAuthn credential (passkey) using the Android Credential Manager.