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
optionsA dictionary containing the registration options.
windowThe window to present the registration UI in.
loggerOptional logger for ceremony state transitions and errors. Pass the workflow logger (e.g.
davinci?.config.logger); whennilno log output is produced. Scoped to this call only — overwritten by subsequent ceremonies and cleared incleanup().completionA 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
optionsA dictionary containing the authentication options.
windowThe window to present the authentication UI in.
preferImmediatelyAvailableCredentialsWhen
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 receivesASAuthorizationError.canceledinstead of the QR / nearby-device fallback. In this mode the ceremony is platform-only — no cross-platform security-key request is issued even whenallowCredentialsis present, since a hardware security key is never immediately available on the local device. Whenfalse(the default) the fullperformRequests()flow is used, including cross-device sign-in and security keys — preserving the pre-existing behavior. Mirrors the legacyFRWebAuthnManager.signInWith(preferImmediatelyAvailableCredentials:)option.loggerOptional logger for ceremony state transitions and errors. Pass the workflow logger (e.g.
journey?.config.logger); whennilno log output is produced. Scoped to this call only — overwritten by subsequent ceremonies and cleared incleanup().completionA closure to be called with the authentication result.
-
Declaration
Swift
@MainActor public func presentationAnchor(for controller: ASAuthorizationController) -> ASPresentationAnchorReturn Value
The presentation anchor.
-
Handles the successful completion of an authorization request.
Declaration
Swift
@MainActor public func authorizationController(controller: ASAuthorizationController, didCompleteWithAuthorization authorization: ASAuthorization)Parameters
controllerThe authorization controller.
authorizationThe 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
controllerThe authorization controller.
errorThe error that occurred.
View on GitHub