Skip to content
Open
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@
@_spi(InternalHttpEngineProxy) import AWSPluginsCore
import SmithyRetriesAPI
import SmithyRetries
#if canImport(UIKit)
import UIKit
#endif

extension AWSCognitoAuthPlugin {

Expand All @@ -38,6 +41,15 @@
AuthPluginErrorConstants.decodeConfigurationError.recoverySuggestion)
}

#if canImport(UIKit)
guard UIApplication.shared.isProtectedDataAvailable else {

Check failure on line 45 in AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/AWSCognitoAuthPlugin+Configure.swift

View workflow job for this annotation

GitHub Actions / Build Amplify Swift for watchOS / Build Amplify-Package | watchOS

cannot find 'UIApplication' in scope

Check failure on line 45 in AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/AWSCognitoAuthPlugin+Configure.swift

View workflow job for this annotation

GitHub Actions / Build Amplify Swift for watchOS / Build Amplify-Build | watchOS

cannot find 'UIApplication' in scope

Check failure on line 45 in AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/AWSCognitoAuthPlugin+Configure.swift

View workflow job for this annotation

GitHub Actions / InternalAWSPinpointUnitTests Unit Tests / watchOS Tests | InternalAWSPinpointUnitTests / watchOS Tests | InternalAWSPinpointUnitTests

cannot find 'UIApplication' in scope

Check failure on line 45 in AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/AWSCognitoAuthPlugin+Configure.swift

View workflow job for this annotation

GitHub Actions / AWSCognitoAuthPlugin Unit Tests / watchOS Tests | AWSCognitoAuthPlugin / watchOS Tests | AWSCognitoAuthPlugin

cannot find 'UIApplication' in scope

Check failure on line 45 in AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/AWSCognitoAuthPlugin+Configure.swift

View workflow job for this annotation

GitHub Actions / AWSPinpointAnalyticsPlugin Unit Tests / watchOS Tests | AWSPinpointAnalyticsPlugin / watchOS Tests | AWSPinpointAnalyticsPlugin

cannot find 'UIApplication' in scope
throw PluginError.pluginConfigurationError(
AuthPluginErrorConstants.protectedDataUnavailableError.errorDescription,
AuthPluginErrorConstants.protectedDataUnavailableError.recoverySuggestion,
AWSCognitoAuthError.protectedDataUnavailable)
}
#endif

let credentialStoreResolver = CredentialStoreState.Resolver().eraseToAnyResolver()
let credentialEnvironment = credentialStoreEnvironment(authConfiguration: authConfiguration)
let credentialStoreMachine = StateMachine(resolver: credentialStoreResolver,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,9 @@ public enum AWSCognitoAuthError: Error {

/// The WebAuthn configuration is missing or incomplete
case webAuthnConfigurationMissing

/// Protected data is not yet available (iOS prewarming or locked state)
case protectedDataUnavailable
}

extension AWSCognitoAuthError: LocalizedError {
Expand Down Expand Up @@ -185,6 +188,8 @@ extension AWSCognitoAuthError: LocalizedError {
message = "The relying party ID doesn't match."
case .webAuthnConfigurationMissing:
message = "The WebAuthn configuration is missing or incomplete."
case .protectedDataUnavailable:
message = "Protected data is not yet available."
}
return "\(String(describing: Self.self)).\(self): \(message)"
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,11 @@ typealias AuthPluginValidationErrorString = (field: Field,

enum AuthPluginErrorConstants {

static let protectedDataUnavailableError: AuthPluginErrorString = (
"Protected data is not yet available",
"Delay Amplify calls until `UIApplication.shared.isProtectedDataAvailable` returns true"
)

static let decodeConfigurationError: AuthPluginErrorString = (
"Unable to decode configuration",
"Make sure the plugin configuration is JSONValue")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
import Foundation
import Amplify

#if canImport(UIKit)
import UIKit
#endif

protocol AmplifyAuthTask {

associatedtype Success
Expand All @@ -30,6 +34,14 @@
get async throws {
do {
log.info("Starting execution for \(eventName)")
#if canImport(UIKit)
guard await UIApplication.shared.isProtectedDataAvailable else {

Check failure on line 38 in AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Task/Protocols/AmplifyAuthTask.swift

View workflow job for this annotation

GitHub Actions / AWSPinpointPushNotificationsPlugin Unit Tests / watchOS Tests | AWSPinpointPushNotificationsPlugin / watchOS Tests | AWSPinpointPushNotificationsPlugin

cannot find 'UIApplication' in scope

Check failure on line 38 in AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Task/Protocols/AmplifyAuthTask.swift

View workflow job for this annotation

GitHub Actions / AWSPinpointPushNotificationsPlugin Unit Tests / watchOS Tests | AWSPinpointPushNotificationsPlugin / watchOS Tests | AWSPinpointPushNotificationsPlugin

cannot find 'UIApplication' in scope

Check failure on line 38 in AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Task/Protocols/AmplifyAuthTask.swift

View workflow job for this annotation

GitHub Actions / InternalAWSPinpointUnitTests Unit Tests / watchOS Tests | InternalAWSPinpointUnitTests / watchOS Tests | InternalAWSPinpointUnitTests

cannot find 'UIApplication' in scope

Check failure on line 38 in AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Task/Protocols/AmplifyAuthTask.swift

View workflow job for this annotation

GitHub Actions / AWSCognitoAuthPlugin Unit Tests / watchOS Tests | AWSCognitoAuthPlugin / watchOS Tests | AWSCognitoAuthPlugin

cannot find 'UIApplication' in scope
throw AuthError.configuration(
AuthPluginErrorConstants.protectedDataUnavailableError.errorDescription,
AuthPluginErrorConstants.protectedDataUnavailableError.recoverySuggestion,
AWSCognitoAuthError.protectedDataUnavailable)
}
#endif
let valueReturned = try await execute()
log.info("Successfully completed execution for \(eventName) with result:\n\(valueReturned)")
dispatch(result: .success(valueReturned))
Expand Down
Loading