Fido

@MainActor
public class Fido : NSObject, ASAuthorizationControllerDelegate, ASAuthorizationControllerPresentationContextProviding

Fido is a class that provides FIDO registration and authentication functionalities.

Fido is single-flight: a registration or authentication ceremony retains state on the instance (window, completion handler, logger, timeout task) until the underlying ASAuthorization delegate callback or timeout fires. Concurrent ceremonies on the same instance will overwrite each other, which is why callers consume it through the Fido.shared singleton serialized by the surrounding workflow.

  • The shared singleton FIDO instance.

    Declaration

    Swift

    @MainActor
    public static let shared: Fido
  • Registers a new FIDO credential.

    Declaration

    Swift

    @MainActor
    public func register(options: [String : Any], window: ASPresentationAnchor, logger: Logger? = nil, completion: @escaping (Result<[String : Any], Error>) -> Void)

    Parameters

    options

    A dictionary containing the registration options.

    window

    The window to present the registration UI in.

    logger

    Optional logger for ceremony state transitions and errors. Pass the workflow logger (e.g. davinci?.config.logger); when nil no log output is produced. Scoped to this call only — overwritten by subsequent ceremonies and cleared in cleanup().

    completion

    A closure to be called with the registration result.

  • Authenticates with an existing FIDO credential.

    Declaration

    Swift

    @MainActor
    public func authenticate(options: [String : Any], window: ASPresentationAnchor, preferImmediatelyAvailableCredentials: Bool = false, logger: Logger? = nil, completion: @escaping (Result<[String : Any], Error>) -> Void)

    Parameters

    options

    A dictionary containing the authentication options.

    window

    The window to present the authentication UI in.

    preferImmediatelyAvailableCredentials

    When true, the ceremony is restricted to platform credentials (passkeys) already present on this device: if a matching passkey exists the system presents the modal sign-in sheet, but if none is available no UI appears and the delegate receives ASAuthorizationError.canceled instead of the QR / nearby-device fallback. In this mode the ceremony is platform-only — no cross-platform security-key request is issued even when allowCredentials is present, since a hardware security key is never immediately available on the local device. When false (the default) the full performRequests() flow is used, including cross-device sign-in and security keys — preserving the pre-existing behavior. Mirrors the legacy FRWebAuthnManager.signInWith(preferImmediatelyAvailableCredentials:) option.

    logger

    Optional logger for ceremony state transitions and errors. Pass the workflow logger (e.g. journey?.config.logger); when nil no log output is produced. Scoped to this call only — overwritten by subsequent ceremonies and cleared in cleanup().

    completion

    A closure to be called with the authentication result.

  • Declaration

    Swift

    @MainActor
    public func presentationAnchor(for controller: ASAuthorizationController) -> ASPresentationAnchor

    Return Value

    The presentation anchor.

  • Handles the successful completion of an authorization request.

    Declaration

    Swift

    @MainActor
    public func authorizationController(controller: ASAuthorizationController, didCompleteWithAuthorization authorization: ASAuthorization)

    Parameters

    controller

    The authorization controller.

    authorization

    The authorization object containing the credential.

  • Handles the completion of an authorization request with an error.

    Declaration

    Swift

    @MainActor
    public func authorizationController(controller: ASAuthorizationController, didCompleteWithError error: Error)

    Parameters

    controller

    The authorization controller.

    error

    The error that occurred.