What's New / Privacy, Security & Identity

What's new in AuthenticationServices

+16 New−1 RemovediOS · macOS

AuthenticationServices handles sign-in and credential flows, including password and federated identity providers, AutoFill credential extensions, and verification-code handling on iOS and macOS.

The 27 SDK adds 16 APIs and removes 1, with none deprecated. New verification-code types include ASVerificationCode, DeliveredVerificationCodesManager, ASDeliveredVerificationCodesManager.VerificationError with a nested Code, and the EnvironmentValues.deliveredVerificationCodesManager accessor. ASAuthorizationProviderExtensionLoginConfiguration.FederationType gains openID and dynamicOpenID cases plus fallbackFederationType and authorizationURL. ASPasswordCredential is removed.

New

16
extension

ASDeliveredVerificationCodesManager.VerificationError

NewiOSmacOS
extension ASDeliveredVerificationCodesManager.VerificationError
Declaration
extension ASDeliveredVerificationCodesManager.VerificationError {

    public static var failed: ASDeliveredVerificationCodesManager.VerificationError.Code { get }

    public static var userPermissionDenied: ASDeliveredVerificationCodesManager.VerificationError.Code { get }

    public static var appIsNotEnabledCredentialProvider: ASDeliveredVerificationCodesManager.VerificationError.Code { get }
}
extension

ASDeliveredVerificationCodesManager.VerificationError.Code

NewiOSmacOS
extension ASDeliveredVerificationCodesManager.VerificationError.Code : RawRepresentable
Declaration
extension ASDeliveredVerificationCodesManager.VerificationError.Code : RawRepresentable {
}
struct

ASVerificationCode

NewiOSmacOS
public struct ASVerificationCode : Sendable, Equatable, Identifiable, Codable

This is an instance of a verification code.

It represents a code at a specific point in time.

Declaration
public struct ASVerificationCode : Sendable, Equatable, Identifiable, Codable {

    /// The stable identity of the entity associated with this instance.
    public var id: UUID

    /// The system’s best understanding of the code that can be used for verification purposes.
    ///
    /// This code may be detected from heuristics or parsed from a well-known format.
    public var code: String

    /// Date when the message was received by the device.
    public var timestamp: Date

    /// The domain associated with the code, if one exists.
    /// - SeeAlso: https://github.com/WICG/sms-one-time-codes
    public var domain: String?

    /// Embedded page or frame domains. For domain-bound codes, this array contains all the domains specified after the code field.
    /// - SeeAlso: https://github.com/WICG/sms-one-time-codes
    public var embeddedDomains: [String]

    public init(code: String, timestamp: Date, domain: String? = nil, embeddedDomains: [String] = [], id: UUID = UUID())

    /// Returns a Boolean value indicating whether two values are equal.
    ///
    /// Equality is the inverse of inequality. For any values `a` and `b`,
    /// `a == b` implies that `a != b` is `false`.
    ///
    /// - Parameters:
    ///   - lhs: A value to compare.
    ///   - rhs: Another value to compare.
    public static func == (a: ASVerificationCode, b: ASVerificationCode) -> Bool

    /// A type representing the stable identity of the entity associated with
    /// an instance.
    @available(macOS 27.0, iOS 27.0, *)
    @available(tvOS, unavailable)
    @available(watchOS, unavailable)
    public typealias ID = UUID

    /// Encodes this value into the given encoder.
    ///
    /// If the value fails to encode anything, `encoder` will encode an empty
    /// keyed container in its place.
    ///
    /// This function throws an error if any values are invalid for the given
    /// encoder's format.
    ///
    /// - Parameter encoder: The encoder to write data to.
    public func encode(to encoder: any Encoder) throws

    /// Creates a new instance by decoding from the given decoder.
    ///
    /// This initializer throws an error if reading from the decoder fails, or
    /// if the data read is corrupted or otherwise invalid.
    ///
    /// - Parameter decoder: The decoder to read data from.
    public init(from decoder: any Decoder) throws
}
var

authorizationURL

NewmacOS
open var authorizationURL: URL
var

authorizationURLKeypath

NewmacOS
open var authorizationURLKeypath: String
struct

DeliveredVerificationCodesManager

NewiOSmacOS
public struct DeliveredVerificationCodesManager
Declaration
@MainActor public struct DeliveredVerificationCodesManager {

    public typealias VerificationError = ASDeliveredVerificationCodesManager.VerificationError

    /// Stream one-time codes received by the system.
    ///
    /// When requested, the user may decide whether your app may receive one-time codes.
    /// This stream will automatically disconnect after a period of time.
    ///
    /// - Parameters:
    ///     - preferredDuration: How long the stream should ideally remain connected. This duration is not guaranteed and defaults to 10 minutes.
    /// - Throws: `DeliveredVerificationCodesManager.VerificationError` if one-time codes can not be delivered.
    /// - Note: Only enabled credential providers may call this method.
    @MainActor public func oneTimeCodes(preferredDuration: TimeInterval = 600) async throws -> some AsyncSequence<ASVerificationCode, any Error>


    /// Mark a one-time code as "consumed" by the current process.
    ///
    /// A code should only be marked as consumed if it was submitted to a service for the purposes of authentication.
    ///
    /// Consuming a code will mark a code's containing message as read in the Messages and Mail apps.
    /// Depending on the user's preference, this may also delete the code's containing message.
    ///
    /// - Parameters:
    ///     - oneTimeCode: The code to mark as consumed.
    /// - Throws: `DeliveredVerificationCodesManager.VerificationError` if the system failed to accept the update.
    /// - Note: Only consume codes that you submit to a service. You should make a best effort to ensure it is accepted before calling this.
    @MainActor public func consumeOneTimeCode(_ oneTimeCode: ASVerificationCode) async throws
}
extension

DeliveredVerificationCodesManager

NewiOSmacOS
extension DeliveredVerificationCodesManager : Sendable
Declaration
extension DeliveredVerificationCodesManager : Sendable {
}
var

fallbackFederationType

NewmacOS
open var fallbackFederationType: ASAuthorizationProviderExtensionLoginConfiguration.FederationType
case

ASAuthorizationProviderExtensionAuthenticationMethod.openID

NewmacOS
case openID = 5
case

ASAuthorizationProviderExtensionLoginConfiguration.FederationType.dynamicOpenID

NewmacOS
case dynamicOpenID = 4
case

ASAuthorizationProviderExtensionLoginConfiguration.FederationType.openID

NewmacOS
case openID = 3
var

ASAuthorizationProviderExtensionSupportedGrantTypes.tokenExchange

NewmacOS
public static var tokenExchange: ASAuthorizationProviderExtensionSupportedGrantTypes { get }
struct

ASDeliveredVerificationCodesManager.VerificationError

NewiOSmacOS
public struct VerificationError : CustomNSError
Declaration
public struct VerificationError : CustomNSError {

    public enum Code : Int, Hashable, Sendable {

        case failed

        /// This error signals that the user had denied the requested operation.
        case userPermissionDenied

        /// This error signals that the app is not actively enabled as a credential provider.
        case appIsNotEnabledCredentialProvider

        public static func ~= (pattern: ASDeliveredVerificationCodesManager.VerificationError.Code, value: any Error) -> Bool

        /// Creates a new instance with the specified raw value.
        ///
        /// If there is no value of the type that corresponds with the specified raw
        /// value, this initializer returns `nil`. For example:
        ///
        ///     enum PaperSize: String {
        ///         case A4, A5, Letter, Legal
        ///     }
        ///
        ///     print(PaperSize(rawValue: "Legal"))
        ///     // Prints "Optional(PaperSize.Legal)"
        ///
        ///     print(PaperSize(rawValue: "Tabloid"))
        ///     // Prints "nil"
        ///
        /// - Parameter rawValue: The raw value to use for the new instance.
        public init?(rawValue: Int)

        /// The raw type that can be used to represent all values of the conforming
        /// type.
        ///
        /// Every distinct value of the conforming type has a corresponding unique
        /// value of the `RawValue` type, but there may be values of the `RawValue`
        /// type that don't have a corresponding value of the conforming type.
        @available(macOS 27.0, iOS 27.0, *)
        @available(tvOS, unavailable)
        @available(watchOS, unavailable)
        public typealias RawValue = Int

        /// The corresponding value of the raw type.
        ///
        /// A new instance initialized with `rawValue` will be equivalent to this
        /// instance. For example:
        ///
        ///     enum PaperSize: String {
        ///         case A4, A5, Letter, Legal
        ///     }
        ///
        ///     let selectedSize = PaperSize.Letter
        ///     print(selectedSize.rawValue)
        ///     // Prints "Letter"
        ///
        ///     print(selectedSize == PaperSize(rawValue: selectedSize.rawValue)!)
        ///     // Prints "true"
        public var rawValue: Int { get }
    }

    /// The domain of the error.
    public static var errorDomain: String { get }

    /// The error code within the given domain.
    public var errorCode: Int { get }

    public let code: ASDeliveredVerificationCodesManager.VerificationError.Code

    /// The user-info dictionary.
    public let errorUserInfo: [String : Any]

    public init(_ code: ASDeliveredVerificationCodesManager.VerificationError.Code, userInfo: [String : Any] = [:])
}
typealias

ASDeliveredVerificationCodesManager.VerificationError.Code.RawValue

NewiOSmacOS
public typealias RawValue = Int

The raw type that can be used to represent all values of the conforming type.

Every distinct value of the conforming type has a corresponding unique value of the RawValue type, but there may be values of the RawValue type that don't have a corresponding value of the conforming type.

typealias

ASVerificationCode.ID

NewiOSmacOS
public typealias ID = UUID

A type representing the stable identity of the entity associated with an instance.

var

EnvironmentValues.deliveredVerificationCodesManager

NewiOSmacOS
public var deliveredVerificationCodesManager: DeliveredVerificationCodesManager { get }

This environment variable is for SwiftUI clients of the ASDeliveredVerificationCodesManager API. An example usage might look like:

struct DeliveredVerificationCodesManagerExample: View {
    @Environment(\.deliveredVerificationCodesManager) private var deliveredVerificationCodesManager

    var body: some View {
        Button("Listen for Codes") {
            Task {
                do {
                    let codes = try deliveredVerificationCodesManager.oneTimeCodes()
                    for try await code in codes {
                        handle(code: code)
                    }
                } catch DeliveredVerificationCodesManager.VerificationError.userPermissionDenied {
                    // Explaining why OTCs are needed or try without codes
                } catch DeliveredVerificationCodesManager.VerificationError.appIsNotEnabledCredentialProvider {
                    // Show UI explaining how to turn on the app as a Password Manager
                } catch {
                    // code to handle the save error
                }
            }
        }
    }
}

Removed

1
extension

ASPasswordCredential

RemovediOSmacOS
extension ASPasswordCredential : @unchecked Sendable
RemovedAbsent from the 27 SDK interface. Declaration shown is from the 26 SDK.
Declaration
extension ASPasswordCredential : @unchecked Sendable {
}

No APIs match your filter.

← More in Privacy, Security & Identity