public interface WebAuthnNative
Service-provider interface that WebAuthnClient uses to dispatch a passkey
ceremony through the OS’s public-key credential API
(ASAuthorizationPlatformPublicKeyCredentialProvider on iOS 16+,
androidx.credentials.CredentialManager on Android API 28+).
The platform port supplies an implementation named
com.codename1.io.webauthn.WebAuthnNativeImpl; WebAuthnClient loads it
via WebAuthnClient.setProvider(WebAuthnNative) which the port calls at
app startup. Cn1lib authors who want to plug in their own implementation
(for example, a USB-HID security-key driver) can declare a subtype and
register it the same way.
The data interchange is intentionally JSON in, JSON out – both sides
of the W3C navigator.credentials.create() / .get() call have a
well-defined JSON serialisation (PublicKeyCredentialCreationOptionsJSON /
PublicKeyCredentialRequestOptionsJSON, RegistrationResponseJSON /
AuthenticationResponseJSON). Passing strings keeps the native border narrow
and lets the implementation forward the JSON straight to the OS API (both
platforms accept JSON-shaped inputs in their modern APIs).
Methods
public abstract boolean isSupported() | true if this implementation can actually call the OS authenticator on the current device / OS version. |
public abstract String createPasskey(String creationOptionsJson)
throws WebAuthnException | Runs a navigator.credentials.create() ceremony. |
public abstract String getPasskey(String requestOptionsJson)
throws WebAuthnException | Runs a navigator.credentials.get() ceremony. |
Method details
isSupported
public abstract boolean isSupported()true if this implementation can actually call the OS authenticator
on the current device / OS version. When false, WebAuthnClient
fails the ceremony with WebAuthnException.NOT_IMPLEMENTED so the
caller can present a fallback UI (e.g. password sign-in).createPasskey
public abstract String createPasskey(String creationOptionsJson)
throws WebAuthnExceptionRuns a navigator.credentials.create() ceremony.
creationOptionsJson must be a PublicKeyCredentialCreationOptionsJSON
document as defined by W3C Credential Management Level 1. Returns a
RegistrationResponseJSON string on success, or null if the user
dismissed the sheet.
Implementations are expected to be blocking: the caller is on a worker thread and waits for the result.
On error, the implementation should throw a WebAuthnException with
a code from the constants on that class.
Throws
getPasskey
public abstract String getPasskey(String requestOptionsJson)
throws WebAuthnExceptionRuns a navigator.credentials.get() ceremony.
requestOptionsJson must be a PublicKeyCredentialRequestOptionsJSON
document. Returns an AuthenticationResponseJSON string on success, or
null if the user dismissed the sheet.
On error, the implementation should throw a WebAuthnException with
a code from the constants on that class.