diff --git a/Amplify/Categories/Auth/AuthCategory+WebAuthnBehaviour.swift b/Amplify/Categories/Auth/AuthCategory+WebAuthnBehaviour.swift index 1e82dc1ebf..96f5e78f7e 100644 --- a/Amplify/Categories/Auth/AuthCategory+WebAuthnBehaviour.swift +++ b/Amplify/Categories/Auth/AuthCategory+WebAuthnBehaviour.swift @@ -19,6 +19,16 @@ extension AuthCategory: AuthCategoryWebAuthnBehaviour { options: options ) } +#elseif os(visionOS) + public func associateWebAuthnCredential( + presentationAnchor: AuthUIPresentationAnchor, + options: AuthAssociateWebAuthnCredentialRequest.Options? = nil + ) async throws { + try await plugin.associateWebAuthnCredential( + presentationAnchor:presentationAnchor, + options: options + ) + } #endif public func listWebAuthnCredentials( diff --git a/Amplify/Categories/Auth/AuthCategoryWebAuthnBehaviour.swift b/Amplify/Categories/Auth/AuthCategoryWebAuthnBehaviour.swift index 307ecc4cc7..44e281f517 100644 --- a/Amplify/Categories/Auth/AuthCategoryWebAuthnBehaviour.swift +++ b/Amplify/Categories/Auth/AuthCategoryWebAuthnBehaviour.swift @@ -15,6 +15,11 @@ public protocol AuthCategoryWebAuthnBehaviour: AnyObject { presentationAnchor: AuthUIPresentationAnchor?, options: AuthAssociateWebAuthnCredentialRequest.Options? ) async throws +#elseif os(visionOS) + func associateWebAuthnCredential( + presentationAnchor: AuthUIPresentationAnchor, + options: AuthAssociateWebAuthnCredentialRequest.Options? + ) async throws #endif /// - Tag: AuthCategoryWebAuthnBehaviour.list diff --git a/Amplify/Categories/Auth/Models/AuthFactorType.swift b/Amplify/Categories/Auth/Models/AuthFactorType.swift index a1d3d2082e..9dce5a8bfc 100644 --- a/Amplify/Categories/Auth/Models/AuthFactorType.swift +++ b/Amplify/Categories/Auth/Models/AuthFactorType.swift @@ -19,9 +19,9 @@ public enum AuthFactorType: String { /// An auth factor that uses Email OTP case emailOTP -#if os(iOS) || os(macOS) +#if os(iOS) || os(macOS) || os(visionOS) /// An auth factor that uses WebAuthn - @available(iOS 17.4, macOS 13.5, *) + @available(iOS 17.4, macOS 13.5, visionOS 1.0, *) case webAuthn #endif } diff --git a/Amplify/Categories/Auth/Request/AuthAssociateWebAuthnCredentialRequest.swift b/Amplify/Categories/Auth/Request/AuthAssociateWebAuthnCredentialRequest.swift index 50366177ee..de2f4e547b 100644 --- a/Amplify/Categories/Auth/Request/AuthAssociateWebAuthnCredentialRequest.swift +++ b/Amplify/Categories/Auth/Request/AuthAssociateWebAuthnCredentialRequest.swift @@ -5,7 +5,7 @@ // SPDX-License-Identifier: Apache-2.0 // -#if os(iOS) || os(macOS) +#if os(iOS) || os(macOS) || os(visionOS) import Foundation /// Request for creating a new WebAuthn Credential and associating it with the signed in user diff --git a/Amplify/Categories/Auth/Request/AuthConfirmSignInRequest.swift b/Amplify/Categories/Auth/Request/AuthConfirmSignInRequest.swift index 3d51295745..cff8e863dc 100644 --- a/Amplify/Categories/Auth/Request/AuthConfirmSignInRequest.swift +++ b/Amplify/Categories/Auth/Request/AuthConfirmSignInRequest.swift @@ -33,7 +33,7 @@ public extension AuthConfirmSignInRequest { /// key/values public let pluginOptions: Any? -#if os(iOS) || os(macOS) +#if os(iOS) || os(macOS) || os(visionOS) /// Provide a presentation anchor if you are confirming sign in with WebAuthn. The WebAuthn assertion will be presented /// in the presentation anchor provided. public let presentationAnchorForWebAuthn: AuthUIPresentationAnchor? diff --git a/Amplify/Categories/Auth/Request/AuthSignInRequest.swift b/Amplify/Categories/Auth/Request/AuthSignInRequest.swift index 7bd4b0bbf9..057babd76d 100644 --- a/Amplify/Categories/Auth/Request/AuthSignInRequest.swift +++ b/Amplify/Categories/Auth/Request/AuthSignInRequest.swift @@ -35,7 +35,7 @@ public extension AuthSignInRequest { /// key/values public let pluginOptions: Any? -#if os(iOS) || os(macOS) +#if os(iOS) || os(macOS) || os(visionOS) /// Provide a presentation anchor if you are signing in with WebAuthn. The WebAuthn assertion will be presented /// in the presentation anchor provided. public let presentationAnchorForWebAuthn: AuthUIPresentationAnchor? diff --git a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Actions/SignIn/VerifySignInChallenge.swift b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Actions/SignIn/VerifySignInChallenge.swift index 604fb3d43f..c939b6449c 100644 --- a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Actions/SignIn/VerifySignInChallenge.swift +++ b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Actions/SignIn/VerifySignInChallenge.swift @@ -230,7 +230,7 @@ struct VerifySignInChallenge: Action { } private func isWebAuthn(_ factorType: AuthFactorType?) -> Bool { - #if os(iOS) || os(macOS) + #if os(iOS) || os(macOS) || os(visionOS) if #available(iOS 17.4, macOS 13.5, *) { return .webAuthn == factorType } diff --git a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Actions/SignIn/WebAuthn/AssertWebAuthnCredentials.swift b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Actions/SignIn/WebAuthn/AssertWebAuthnCredentials.swift index ea9c779f40..aed5ffd058 100644 --- a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Actions/SignIn/WebAuthn/AssertWebAuthnCredentials.swift +++ b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Actions/SignIn/WebAuthn/AssertWebAuthnCredentials.swift @@ -5,11 +5,11 @@ // SPDX-License-Identifier: Apache-2.0 // -#if os(iOS) || os(macOS) +#if os(iOS) || os(macOS) || os(visionOS) import Amplify import Foundation -@available(iOS 17.4, macOS 13.5, *) +@available(iOS 17.4, macOS 13.5, visionOS 1.0, *) struct AssertWebAuthnCredentials: Action { let identifier = "AssertWebAuthnCredentials" let username: String @@ -75,10 +75,10 @@ struct AssertWebAuthnCredentials: Action { } } -@available(iOS 17.4, macOS 13.5, *) +@available(iOS 17.4, macOS 13.5, visionOS 1.0, *) extension AssertWebAuthnCredentials: DefaultLogger { } -@available(iOS 17.4, macOS 13.5, *) +@available(iOS 17.4, macOS 13.5, visionOS 1.0, *) extension AssertWebAuthnCredentials: CustomDebugDictionaryConvertible { var debugDictionary: [String: Any] { [ @@ -90,7 +90,7 @@ extension AssertWebAuthnCredentials: CustomDebugDictionaryConvertible { } } -@available(iOS 17.4, macOS 13.5, *) +@available(iOS 17.4, macOS 13.5, visionOS 1.0, *) extension AssertWebAuthnCredentials: CustomDebugStringConvertible { var debugDescription: String { debugDictionary.debugDescription diff --git a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Actions/SignIn/WebAuthn/FetchCredentialOptions.swift b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Actions/SignIn/WebAuthn/FetchCredentialOptions.swift index 38f52c6f40..2ea1e468e2 100644 --- a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Actions/SignIn/WebAuthn/FetchCredentialOptions.swift +++ b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Actions/SignIn/WebAuthn/FetchCredentialOptions.swift @@ -5,7 +5,7 @@ // SPDX-License-Identifier: Apache-2.0 // -#if os(iOS) || os(macOS) +#if os(iOS) || os(macOS) || os(visionOS) import Amplify import Foundation import AWSCognitoIdentityProvider diff --git a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Actions/SignIn/WebAuthn/InitializeWebAuthn.swift b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Actions/SignIn/WebAuthn/InitializeWebAuthn.swift index 684b60cf4c..337b06943c 100644 --- a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Actions/SignIn/WebAuthn/InitializeWebAuthn.swift +++ b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Actions/SignIn/WebAuthn/InitializeWebAuthn.swift @@ -5,7 +5,7 @@ // SPDX-License-Identifier: Apache-2.0 // -#if os(iOS) || os(macOS) +#if os(iOS) || os(macOS) || os(visionOS) import Amplify import Foundation diff --git a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Actions/SignIn/WebAuthn/PlatformWebAuthnCredentials.swift b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Actions/SignIn/WebAuthn/PlatformWebAuthnCredentials.swift index 27b0e15fbe..e6b66e0c04 100644 --- a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Actions/SignIn/WebAuthn/PlatformWebAuthnCredentials.swift +++ b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Actions/SignIn/WebAuthn/PlatformWebAuthnCredentials.swift @@ -5,28 +5,27 @@ // SPDX-License-Identifier: Apache-2.0 // -#if os(iOS) || os(macOS) +#if os(iOS) || os(macOS) || os(visionOS) import Amplify import AuthenticationServices import Foundation -@available(iOS 17.4, macOS 13.5, *) protocol WebAuthnCredentialsProtocol { var presentationAnchor: AuthUIPresentationAnchor? { get } } -@available(iOS 17.4, macOS 13.5, *) +@available(iOS 17.4, macOS 13.5, visionOS 1.0, *) protocol CredentialRegistrantProtocol: WebAuthnCredentialsProtocol { func create(with options: CredentialCreationOptions) async throws -> CredentialRegistrationPayload } -@available(iOS 17.4, macOS 13.5, *) +@available(iOS 17.4, macOS 13.5, visionOS 1.0, *) protocol CredentialAsserterProtocol: WebAuthnCredentialsProtocol { func assert(with options: CredentialAssertionOptions) async throws -> CredentialAssertionPayload } // - MARK: WebAuthnCredentialsProtocol -@available(iOS 17.4, macOS 13.5, *) +@available(iOS 17.4, macOS 13.5, visionOS 1.0, *) class PlatformWebAuthnCredentials: NSObject, WebAuthnCredentialsProtocol { private enum OperationType: String { case assert @@ -43,7 +42,7 @@ class PlatformWebAuthnCredentials: NSObject, WebAuthnCredentialsProtocol { } // - MARK: CredentialAsserterProtocol -@available(iOS 17.4, macOS 13.5, *) +@available(iOS 17.4, macOS 13.5, visionOS 1.0, *) extension PlatformWebAuthnCredentials: CredentialAsserterProtocol{ func assert(with options: CredentialAssertionOptions) async throws -> CredentialAssertionPayload { guard assertionContinuation == nil else { @@ -96,7 +95,7 @@ extension PlatformWebAuthnCredentials: CredentialAsserterProtocol{ } // - MARK: CredentialRegistrantProtocol -@available(iOS 17.4, macOS 13.5, *) +@available(iOS 17.4, macOS 13.5, visionOS 1.0, *) extension PlatformWebAuthnCredentials: CredentialRegistrantProtocol { func create(with options: CredentialCreationOptions) async throws -> CredentialRegistrationPayload { guard registrationContinuation == nil else { @@ -130,11 +129,11 @@ extension PlatformWebAuthnCredentials: CredentialRegistrantProtocol { } } -@available(iOS 17.4, macOS 13.5, *) +@available(iOS 17.4, macOS 13.5, visionOS 1.0, *) extension PlatformWebAuthnCredentials: DefaultLogger {} // - MARK: ASAuthorizationControllerDelegate -@available(iOS 17.4, macOS 13.5, *) +@available(iOS 17.4, macOS 13.5, visionOS 1.0, *) extension PlatformWebAuthnCredentials: ASAuthorizationControllerDelegate { func authorizationController( controller: ASAuthorizationController, @@ -230,7 +229,7 @@ extension PlatformWebAuthnCredentials: ASAuthorizationControllerDelegate { } // - MARK: ASAuthorizationControllerPresentationContextProviding -@available(iOS 17.4, macOS 13.5, *) +@available(iOS 17.4, macOS 13.5, visionOS 1.0, *) extension PlatformWebAuthnCredentials: ASAuthorizationControllerPresentationContextProviding { func presentationAnchor(for controller: ASAuthorizationController) -> ASPresentationAnchor { return presentationAnchor ?? ASPresentationAnchor() diff --git a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Actions/SignIn/WebAuthn/VerifyWebAuthnCredential.swift b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Actions/SignIn/WebAuthn/VerifyWebAuthnCredential.swift index 899e277cfa..525427fdbe 100644 --- a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Actions/SignIn/WebAuthn/VerifyWebAuthnCredential.swift +++ b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Actions/SignIn/WebAuthn/VerifyWebAuthnCredential.swift @@ -5,12 +5,12 @@ // SPDX-License-Identifier: Apache-2.0 // -#if os(iOS) || os(macOS) +#if os(iOS) || os(macOS) || os(visionOS) import Amplify import AWSCognitoIdentityProvider import Foundation -@available(iOS 17.4, macOS 13.5, *) +@available(iOS 17.4, macOS 13.5, visionOS 1.0, *) struct VerifyWebAuthnCredential: Action { let identifier = "VerifyWebAuthnCredential" let username: String @@ -91,10 +91,10 @@ struct VerifyWebAuthnCredential: Action { } } -@available(iOS 17.4, macOS 13.5, *) +@available(iOS 17.4, macOS 13.5, visionOS 1.0, *) extension VerifyWebAuthnCredential: DefaultLogger { } -@available(iOS 17.4, macOS 13.5, *) +@available(iOS 17.4, macOS 13.5, visionOS 1.0, *) extension VerifyWebAuthnCredential: CustomDebugDictionaryConvertible { var debugDictionary: [String: Any] { [ @@ -106,7 +106,7 @@ extension VerifyWebAuthnCredential: CustomDebugDictionaryConvertible { } } -@available(iOS 17.4, macOS 13.5, *) +@available(iOS 17.4, macOS 13.5, visionOS 1.0, *) extension VerifyWebAuthnCredential: CustomDebugStringConvertible { var debugDescription: String { debugDictionary.debugDescription diff --git a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/ClientBehavior/AWSCognitoAuthPlugin+WebAuthnBehaviour.swift b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/ClientBehavior/AWSCognitoAuthPlugin+WebAuthnBehaviour.swift index 5b4e7caa16..674c995070 100644 --- a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/ClientBehavior/AWSCognitoAuthPlugin+WebAuthnBehaviour.swift +++ b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/ClientBehavior/AWSCognitoAuthPlugin+WebAuthnBehaviour.swift @@ -25,6 +25,25 @@ extension AWSCognitoAuthPlugin: AuthCategoryWebAuthnBehaviour { userPoolFactory: authEnvironment.cognitoUserPoolFactory ) + _ = try await taskQueue.sync { + try await task.value + } + } +#elseif os(visionOS) + public func associateWebAuthnCredential( + presentationAnchor: AuthUIPresentationAnchor, + options: AuthAssociateWebAuthnCredentialRequest.Options? = nil + ) async throws { + let request = AuthAssociateWebAuthnCredentialRequest( + presentationAnchor: presentationAnchor, + options: options ?? .init() + ) + let task = AssociateWebAuthnCredentialTask( + request: request, + authStateMachine: authStateMachine, + userPoolFactory: authEnvironment.cognitoUserPoolFactory + ) + _ = try await taskQueue.sync { try await task.value } diff --git a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/HubEvents/AuthHubEventHandler.swift b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/HubEvents/AuthHubEventHandler.swift index c8248e156f..34f7de1dca 100644 --- a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/HubEvents/AuthHubEventHandler.swift +++ b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/HubEvents/AuthHubEventHandler.swift @@ -52,7 +52,7 @@ class AuthHubEventHandler: AuthHubEventBehavior { } self?.handleSignInEvent(result) - #if os(iOS) || os(macOS) + #if os(iOS) || os(macOS) || os(visionOS) case HubPayload.EventName.Auth.webUISignInAPI: guard let event = payload.data as? AWSAuthWebUISignInTask.AmplifyAuthTaskResult, case let .success(result) = event else { diff --git a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Models/AuthFactorTypeExtension.swift b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Models/AuthFactorTypeExtension.swift index b5041d4479..9b32f0a2af 100644 --- a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Models/AuthFactorTypeExtension.swift +++ b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Models/AuthFactorTypeExtension.swift @@ -16,7 +16,7 @@ extension AuthFactorType: DefaultLogger { case "SMS_OTP": self = .smsOTP case "EMAIL_OTP": self = .emailOTP case "WEB_AUTHN": - #if os(iOS) || os(macOS) + #if os(iOS) || os(macOS) || os(visionOS) if #available(iOS 17.4, macOS 13.5, *) { self = .webAuthn } else { @@ -45,7 +45,7 @@ extension AuthFactorType: DefaultLogger { case .password: return "PASSWORD" case .smsOTP: return "SMS_OTP" case .emailOTP: return "EMAIL_OTP" - #if os(iOS) || os(macOS) + #if os(iOS) || os(macOS) || os(visionOS) case .webAuthn: return "WEB_AUTHN" #endif } diff --git a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/StateMachine/CodeGen/Data/ChallengeNameTypeExtension.swift b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/StateMachine/CodeGen/Data/ChallengeNameTypeExtension.swift index bf3918917f..60e55c81bc 100644 --- a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/StateMachine/CodeGen/Data/ChallengeNameTypeExtension.swift +++ b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/StateMachine/CodeGen/Data/ChallengeNameTypeExtension.swift @@ -20,7 +20,7 @@ extension CognitoIdentityProviderClientTypes.ChallengeNameType { case .smsOtp: return .smsOTP case .webAuthn: - #if os(iOS) || os(macOS) + #if os(iOS) || os(macOS) || os(visionOS) if #available(iOS 17.4, macOS 13.5, *) { return .webAuthn } diff --git a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/StateMachine/CodeGen/Data/ConfirmSignInEventData.swift b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/StateMachine/CodeGen/Data/ConfirmSignInEventData.swift index a67194d821..c846179532 100644 --- a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/StateMachine/CodeGen/Data/ConfirmSignInEventData.swift +++ b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/StateMachine/CodeGen/Data/ConfirmSignInEventData.swift @@ -5,7 +5,7 @@ // SPDX-License-Identifier: Apache-2.0 // -#if os(iOS) || os(macOS) +#if os(iOS) || os(macOS) || os(visionOS) import typealias Amplify.AuthUIPresentationAnchor #endif import Foundation diff --git a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/StateMachine/CodeGen/Data/SignInEventData.swift b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/StateMachine/CodeGen/Data/SignInEventData.swift index eba36d3fb2..e69fd399d1 100644 --- a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/StateMachine/CodeGen/Data/SignInEventData.swift +++ b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/StateMachine/CodeGen/Data/SignInEventData.swift @@ -5,7 +5,7 @@ // SPDX-License-Identifier: Apache-2.0 // -#if os(iOS) || os(macOS) +#if os(iOS) || os(macOS) || os(visionOS) import typealias Amplify.AuthUIPresentationAnchor #endif diff --git a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/StateMachine/CodeGen/Data/WebAuthnSignInData.swift b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/StateMachine/CodeGen/Data/WebAuthnSignInData.swift index b3af96dee6..83f2cae7cd 100644 --- a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/StateMachine/CodeGen/Data/WebAuthnSignInData.swift +++ b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/StateMachine/CodeGen/Data/WebAuthnSignInData.swift @@ -5,7 +5,7 @@ // SPDX-License-Identifier: Apache-2.0 // -#if os(iOS) || os(macOS) +#if os(iOS) || os(macOS) || os(visionOS) import typealias Amplify.AuthUIPresentationAnchor #endif import Foundation diff --git a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/StateMachine/CodeGen/Events/SignInEvent.swift b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/StateMachine/CodeGen/Events/SignInEvent.swift index 6dec07bd84..33f4901c90 100644 --- a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/StateMachine/CodeGen/Events/SignInEvent.swift +++ b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/StateMachine/CodeGen/Events/SignInEvent.swift @@ -7,7 +7,7 @@ import Foundation import AWSCognitoIdentityProvider -#if os(iOS) || os(macOS) +#if os(iOS) || os(macOS) || os(visionOS) import typealias Amplify.AuthUIPresentationAnchor #endif diff --git a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/StateMachine/CodeGen/Events/WebAuthnEvent.swift b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/StateMachine/CodeGen/Events/WebAuthnEvent.swift index c3bea0532d..eb3e5f9a3e 100644 --- a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/StateMachine/CodeGen/Events/WebAuthnEvent.swift +++ b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/StateMachine/CodeGen/Events/WebAuthnEvent.swift @@ -5,7 +5,7 @@ // SPDX-License-Identifier: Apache-2.0 // -#if os(iOS) || os(macOS) +#if os(iOS) || os(macOS) || os(visionOS) import Foundation import Amplify diff --git a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/StateMachine/Resolvers/SignIn/SignInState+Resolver.swift b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/StateMachine/Resolvers/SignIn/SignInState+Resolver.swift index f7cfbfb3e7..b6c946aecb 100644 --- a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/StateMachine/Resolvers/SignIn/SignInState+Resolver.swift +++ b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/StateMachine/Resolvers/SignIn/SignInState+Resolver.swift @@ -281,7 +281,7 @@ extension SignInState { actions: [action]) } - #if os(iOS) || os(macOS) + #if os(iOS) || os(macOS) || os(visionOS) if let signInEvent = event as? SignInEvent, case .initiateWebAuthnSignIn(let data, let respondToAuthChallenge) = signInEvent.eventType { let action = InitializeWebAuthn( @@ -466,7 +466,7 @@ extension SignInState { ), actions: [action]) } - #if os(iOS) || os(macOS) + #if os(iOS) || os(macOS) || os(visionOS) if let signInEvent = event as? SignInEvent, case .initiateWebAuthnSignIn(let data, let respondToAuthChallenge) = signInEvent.eventType { let action = InitializeWebAuthn( @@ -504,7 +504,7 @@ extension SignInState { } return .from(oldState) case .signingInWithWebAuthn(let webAuthnState): - #if os(iOS) || os(macOS) + #if os(iOS) || os(macOS) || os(visionOS) if #available(iOS 17.4, macOS 13.5, *) { if case .throwAuthError(let error) = event.isSignInEvent { let action = ThrowSignInError(error: error) diff --git a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/StateMachine/Resolvers/SignIn/WebAuthnSignInState+Resolver.swift b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/StateMachine/Resolvers/SignIn/WebAuthnSignInState+Resolver.swift index 5cff2056e9..e38951c46b 100644 --- a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/StateMachine/Resolvers/SignIn/WebAuthnSignInState+Resolver.swift +++ b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/StateMachine/Resolvers/SignIn/WebAuthnSignInState+Resolver.swift @@ -5,13 +5,13 @@ // SPDX-License-Identifier: Apache-2.0 // -#if os(iOS) || os(macOS) +#if os(iOS) || os(macOS) || os(visionOS) import enum Amplify.AuthFactorType import Foundation extension WebAuthnSignInState { - @available(iOS 17.4, macOS 13.5, *) + @available(iOS 17.4, macOS 13.5, visionOS 1.0, *) struct Resolver: StateMachineResolver { typealias StateType = WebAuthnSignInState diff --git a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Support/StateMachineSupport/StateMachineEvent+Type.swift b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Support/StateMachineSupport/StateMachineEvent+Type.swift index 55d6f397d1..a2b2aa64cb 100644 --- a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Support/StateMachineSupport/StateMachineEvent+Type.swift +++ b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Support/StateMachineSupport/StateMachineEvent+Type.swift @@ -86,7 +86,7 @@ extension StateMachineEvent { return event } -#if os(iOS) || os(macOS) +#if os(iOS) || os(macOS) || os(visionOS) var isWebAuthnEvent: WebAuthnEvent.EventType? { guard let event = (self as? WebAuthnEvent)?.eventType else { return nil diff --git a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Task/AWSAuthConfirmSignInTask.swift b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Task/AWSAuthConfirmSignInTask.swift index 9cbbf5c0c7..6d5e95ab64 100644 --- a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Task/AWSAuthConfirmSignInTask.swift +++ b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Task/AWSAuthConfirmSignInTask.swift @@ -189,7 +189,7 @@ class AWSAuthConfirmSignInTask: AuthConfirmSignInTask, DefaultLogger { $0[attributePrefix + $1.key.rawValue] = $1.value } ?? [:] let presentationAnchor: AuthUIPresentationAnchor? - #if os(iOS) || os(macOS) + #if os(iOS) || os(macOS) || os(visionOS) presentationAnchor = request.options.presentationAnchorForWebAuthn #else presentationAnchor = nil diff --git a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Task/AWSAuthSignInTask.swift b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Task/AWSAuthSignInTask.swift index a8f1fd4861..07718973dd 100644 --- a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Task/AWSAuthSignInTask.swift +++ b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Task/AWSAuthSignInTask.swift @@ -134,7 +134,7 @@ class AWSAuthSignInTask: AuthSignInTask, DefaultLogger { private func sendSignInEvent(authflowType: AuthFlowType) async { var presentationAnchor: AuthUIPresentationAnchor? = nil - #if os(iOS) || os(macOS) + #if os(iOS) || os(macOS) || os(visionOS) presentationAnchor = request.options.presentationAnchorForWebAuthn #endif let signInData = SignInEventData( diff --git a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Task/AssociateWebAuthnCredentialTask.swift b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Task/AssociateWebAuthnCredentialTask.swift index 183dabbd0c..3b64679f82 100644 --- a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Task/AssociateWebAuthnCredentialTask.swift +++ b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Task/AssociateWebAuthnCredentialTask.swift @@ -5,13 +5,13 @@ // SPDX-License-Identifier: Apache-2.0 // -#if os(iOS) || os(macOS) +#if os(iOS) || os(macOS) || os(visionOS) import Amplify import AuthenticationServices import AWSCognitoIdentityProvider import Foundation -@available(iOS 17.4, macOS 13.5, *) +@available(iOS 17.4, macOS 13.5, visionOS 1.0, *) class AssociateWebAuthnCredentialTask: NSObject, AuthAssociateWebAuthnCredentialTask, DefaultLogger { private let request: AuthAssociateWebAuthnCredentialRequest private let authStateMachine: AuthStateMachine diff --git a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Task/Models/AWSWebAuthCredentialsModels.swift b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Task/Models/AWSWebAuthCredentialsModels.swift index b6e438d72b..3a471f6e1d 100644 --- a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Task/Models/AWSWebAuthCredentialsModels.swift +++ b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Task/Models/AWSWebAuthCredentialsModels.swift @@ -5,7 +5,7 @@ // SPDX-License-Identifier: Apache-2.0 // -#if os(iOS) || os(macOS) +#if os(iOS) || os(macOS) || os(visionOS) import AuthenticationServices import Foundation import Smithy @@ -51,7 +51,7 @@ struct CredentialAssertionOptions: Codable, Equatable { } } -@available(iOS 17.4, macOS 13.5, *) +@available(iOS 17.4, macOS 13.5, visionOS 1.0, *) struct CredentialAssertionPayload: Codable { private struct Response: Codable { let authenticatorData: String @@ -176,7 +176,7 @@ struct CredentialCreationOptions { } } -@available(iOS 17.4, macOS 13.5, *) +@available(iOS 17.4, macOS 13.5, visionOS 1.0, *) struct CredentialRegistrationPayload: Codable { private struct Response: Codable { let attestationObject: String diff --git a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Task/Protocols/AuthAssociateWebAuthnCredentialTask.swift b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Task/Protocols/AuthAssociateWebAuthnCredentialTask.swift index 39f3650b2c..d24f559eed 100644 --- a/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Task/Protocols/AuthAssociateWebAuthnCredentialTask.swift +++ b/AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Task/Protocols/AuthAssociateWebAuthnCredentialTask.swift @@ -5,7 +5,7 @@ // SPDX-License-Identifier: Apache-2.0 // -#if os(iOS) || os(macOS) +#if os(iOS) || os(macOS) || os(visionOS) import Amplify import Foundation diff --git a/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/Mocks/MockCredentialRegistrant.swift b/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/Mocks/MockCredentialRegistrant.swift index d19bede367..27e16941ef 100644 --- a/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/Mocks/MockCredentialRegistrant.swift +++ b/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/Mocks/MockCredentialRegistrant.swift @@ -5,7 +5,7 @@ // SPDX-License-Identifier: Apache-2.0 // -#if os(iOS) || os(macOS) +#if os(iOS) || os(macOS) || os(visionOS) import Amplify @testable import AWSCognitoAuthPlugin diff --git a/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/TaskTests/WebAuthnBehaviourTests/AssociateWebAuthnCredentialTaskTests.swift b/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/TaskTests/WebAuthnBehaviourTests/AssociateWebAuthnCredentialTaskTests.swift index 34dd476d7a..e8a5d0ec6d 100644 --- a/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/TaskTests/WebAuthnBehaviourTests/AssociateWebAuthnCredentialTaskTests.swift +++ b/AmplifyPlugins/Auth/Tests/AWSCognitoAuthPluginUnitTests/TaskTests/WebAuthnBehaviourTests/AssociateWebAuthnCredentialTaskTests.swift @@ -5,7 +5,7 @@ // SPDX-License-Identifier: Apache-2.0 // -#if os(iOS) || os(macOS) +#if os(iOS) || os(macOS) || os(visionOS) @testable import AWSCognitoAuthPlugin import enum Amplify.AuthError import enum AWSCognitoIdentity.CognitoIdentityClientTypes diff --git a/AmplifyTestCommon/Mocks/MockAuthCategoryPlugin.swift b/AmplifyTestCommon/Mocks/MockAuthCategoryPlugin.swift index a74ab0eae2..195c88178a 100644 --- a/AmplifyTestCommon/Mocks/MockAuthCategoryPlugin.swift +++ b/AmplifyTestCommon/Mocks/MockAuthCategoryPlugin.swift @@ -145,9 +145,15 @@ class MockAuthCategoryPlugin: MessageReporter, AuthCategoryPlugin { fatalError() } +#if os(iOS) || os(macOS) func associateWebAuthnCredential(presentationAnchor: AuthUIPresentationAnchor?, options: AuthAssociateWebAuthnCredentialRequest.Options?) async throws { fatalError() } +#elseif os(visionOS) + func associateWebAuthnCredential(presentationAnchor: AuthUIPresentationAnchor, options: AuthAssociateWebAuthnCredentialRequest.Options?) async throws { + fatalError() + } +#endif func listWebAuthnCredentials(options: AuthListWebAuthnCredentialsRequest.Options?) async throws -> AuthListWebAuthnCredentialsResult { fatalError()