WebAuthnAllowCredential

public struct WebAuthnAllowCredential : Equatable, Hashable, Sendable

A credential descriptor pairing a credential ID with optional transport hints.

Used in WebAuthnProvider.authenticate to constrain which passkeys the authenticator offers and to indicate how the client can reach the authenticator (e.g., internal, hybrid, usb, ble, nfc). Including transport hints enables cross-device authentication flows such as QR-code scanning.

When transports is nil, the authenticator uses its default transport selection. Unknown transport strings are passed through without validation — the OS ignores values it does not recognize.

Equality compares the id byte content (not reference identity) so two descriptors built from independently allocated Data values with the same bytes compare equal.

Example:

let cred = WebAuthnAllowCredential(id: credentialIdData, transports: ["internal", "hybrid"])
let result = try await provider.authenticate(challenge: challenge, allowCredentials: [cred])
  • id

    The raw credential ID bytes.

    Declaration

    Swift

    public let id: Data
  • Optional list of transport hints (e.g., internal, hybrid, usb, ble, nfc).

    Declaration

    Swift

    public let transports: [String]?
  • Creates a WebAuthnAllowCredential with the given credential ID and optional transports.

    Declaration

    Swift

    public init(id: Data, transports: [String]? = nil)

    Parameters

    id

    Raw credential ID bytes.

    transports

    Optional list of WebAuthn transport hints. nil lets the authenticator select a transport.

  • Undocumented

    Declaration

    Swift

    public static func fromId(_ id: Data) -> WebAuthnAllowCredential
  • Undocumented

    Declaration

    Swift

    public static func fromIds(_ ids: [Data]) -> [WebAuthnAllowCredential]