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).
- Since:
- 7.0.245
-
Method Summary
Modifier and TypeMethodDescriptioncreatePasskey(String creationOptionsJson) Runs anavigator.credentials.create()ceremony.getPasskey(String requestOptionsJson) Runs anavigator.credentials.get()ceremony.booleantrueif this implementation can actually call the OS authenticator on the current device / OS version.
-
Method Details
-
isSupported
boolean isSupported()trueif this implementation can actually call the OS authenticator on the current device / OS version. Whenfalse,WebAuthnClientfails the ceremony withWebAuthnException.NOT_IMPLEMENTEDso the caller can present a fallback UI (e.g. password sign-in). -
createPasskey
Runs a
navigator.credentials.create()ceremony.creationOptionsJsonmust be a PublicKeyCredentialCreationOptionsJSON document as defined by W3C Credential Management Level 1. Returns a RegistrationResponseJSON string on success, ornullif 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
WebAuthnExceptionwith a code from the constants on that class.- Throws:
WebAuthnException
-
getPasskey
Runs a
navigator.credentials.get()ceremony.requestOptionsJsonmust be a PublicKeyCredentialRequestOptionsJSON document. Returns an AuthenticationResponseJSON string on success, ornullif the user dismissed the sheet.On error, the implementation should throw a
WebAuthnExceptionwith a code from the constants on that class.- Throws:
WebAuthnException
-