Skip to content

Commit 4e53373

Browse files
authored
chore: kickoff release
2 parents 35ed09d + b01d22d commit 4e53373

File tree

40 files changed

+341
-120
lines changed

40 files changed

+341
-120
lines changed

Amplify/Categories/Auth/Error/AuthError.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ extension AuthError: AmplifyError {
7777
.invalidState(_, let recoverySuggestion, _):
7878
return recoverySuggestion
7979
case .unknown:
80-
return AmplifyErrorMessages.shouldNotHappenReportBugToAWS()
80+
return AmplifyErrorMessages.shouldNotHappenReportBugToAWSWithoutLineInfo()
8181
}
8282
}
8383

Amplify/Core/Support/AmplifyErrorMessages.swift

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,13 @@ public struct AmplifyErrorMessages {
2727
"This should not happen. \(reportBugToAWS(file: file, function: function, line: line))"
2828
}
2929

30+
public static func shouldNotHappenReportBugToAWSWithoutLineInfo() -> String {
31+
"""
32+
This should not happen. There is a possibility that there is a bug if this error persists. \
33+
Please take a look at https://github.com/aws-amplify/amplify-swift/issues to see if there \
34+
are any existing issues that match your scenario, and file an issue with the details of \
35+
the bug if there isn't.
36+
"""
37+
}
38+
3039
}

AmplifyPlugins/API/Sources/AWSAPIPlugin/Operation/AWSGraphQLSubscriptionTaskRunner.swift

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,9 +151,10 @@ public class AWSGraphQLSubscriptionTaskRunner<R: Decodable>: InternalTaskRunner,
151151
} catch let error as APIError {
152152
fail(error)
153153
} catch {
154-
// TODO: Verify with the team that terminating a subscription after failing to decode/cast one
154+
// Verify with the team that terminating a subscription after failing to decode/cast one
155155
// payload is the right thing to do. Another option would be to propagate a GraphQL error, but
156156
// leave the subscription alive.
157+
// see https://github.com/aws-amplify/amplify-swift/issues/2577
157158

158159
fail(APIError.operationError("Failed to deserialize", "", error))
159160
}
@@ -185,7 +186,7 @@ public class AWSGraphQLSubscriptionTaskRunner<R: Decodable>: InternalTaskRunner,
185186
}
186187
}
187188

188-
// TODO: Remove this code, it has replaced been with AWSGraphQLSubscriptionTaskRunner above.
189+
// Class is still necessary. See https://github.com/aws-amplify/amplify-swift/issues/2252
189190
final public class AWSGraphQLSubscriptionOperation<R: Decodable>: GraphQLSubscriptionOperation<R> {
190191

191192
let pluginConfig: AWSAPICategoryPluginConfiguration
@@ -342,9 +343,11 @@ final public class AWSGraphQLSubscriptionOperation<R: Decodable>: GraphQLSubscri
342343
dispatch(result: .failure(error))
343344
finish()
344345
} catch {
345-
// TODO: Verify with the team that terminating a subscription after failing to decode/cast one
346+
// Verify with the team that terminating a subscription after failing to decode/cast one
346347
// payload is the right thing to do. Another option would be to propagate a GraphQL error, but
347348
// leave the subscription alive.
349+
// see https://github.com/aws-amplify/amplify-swift/issues/2577
350+
348351
dispatch(result: .failure(APIError.operationError("Failed to deserialize", "", error)))
349352
finish()
350353
}

AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/ClientBehavior/AWSCognitoAuthPlugin+ClientBehavior.swift

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,9 @@ extension AWSCognitoAuthPlugin: AuthCategoryBehavior {
8989
let options = options ?? AuthConfirmSignInRequest.Options()
9090
let request = AuthConfirmSignInRequest(challengeResponse: challengeResponse,
9191
options: options)
92-
let task = AWSAuthConfirmSignInTask(request, stateMachine: authStateMachine)
92+
let task = AWSAuthConfirmSignInTask(request,
93+
stateMachine: authStateMachine,
94+
configuration: authConfiguration)
9395
return try await taskQueue.sync {
9496
return try await task.value
9597
} as! AuthSignInResult

AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Operations/Helpers/HostedUISignInHelper.swift

Lines changed: 28 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ struct HostedUISignInHelper {
2626

2727
func initiateSignIn() async throws -> AuthSignInResult {
2828
try await isValidState()
29-
await prepareForSignIn()
3029
return try await doSignIn()
3130
}
3231

@@ -38,38 +37,19 @@ struct HostedUISignInHelper {
3837
}
3938
switch authenticationState {
4039
case .signingIn:
41-
continue
40+
await sendCancelSignInEvent()
4241
case .signedIn:
4342
throw AuthError.invalidState(
4443
"There is already a user in signedIn state. SignOut the user first before calling signIn",
4544
AuthPluginErrorConstants.invalidStateError, nil)
46-
default:
47-
return
48-
}
49-
}
50-
}
51-
52-
private func prepareForSignIn() async {
53-
54-
let stateSequences = await authStateMachine.listen()
55-
56-
for await state in stateSequences {
57-
guard case .configured(let authNState, _) = state else { continue }
58-
59-
switch authNState {
6045
case .signedOut:
6146
return
62-
63-
case .signingIn:
64-
Task {
65-
await sendCancelSignInEvent()
66-
}
67-
default:
68-
continue
47+
default: continue
6948
}
7049
}
7150
}
7251

52+
7353
private func doSignIn() async throws -> AuthSignInResult {
7454

7555
let oauthConfiguration: OAuthConfigurationData
@@ -101,13 +81,19 @@ struct HostedUISignInHelper {
10181
}
10282

10383
case .error(let error):
104-
throw AuthError.unknown("Sign in reached an error state", error)
84+
await waitForSignInCancel()
85+
throw error.authError
10586

10687
case .signingIn(let signInState):
107-
guard let result = try UserPoolSignInHelper.checkNextStep(signInState) else {
108-
continue
88+
do {
89+
guard let result = try UserPoolSignInHelper.checkNextStep(signInState) else {
90+
continue
91+
}
92+
return result
93+
} catch {
94+
await waitForSignInCancel()
95+
throw error
10996
}
110-
return result
11197
default:
11298
continue
11399
}
@@ -141,4 +127,19 @@ struct HostedUISignInHelper {
141127
await authStateMachine.send(event)
142128
}
143129

130+
private func waitForSignInCancel() async {
131+
await sendCancelSignInEvent()
132+
let stateSequences = await authStateMachine.listen()
133+
for await state in stateSequences {
134+
guard case .configured(let authenticationState, _) = state else {
135+
continue
136+
}
137+
138+
switch authenticationState {
139+
case .signedOut:
140+
return
141+
default: continue
142+
}
143+
}
144+
}
144145
}

AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Service/ErrorMapping/ChangePasswordOutputError+AuthError.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,8 +58,6 @@ extension ChangePasswordOutputError: AuthErrorConvertible {
5858
case .forbiddenException(let forbiddenException):
5959
return .service(forbiddenException.message ?? "Access to the requested resource is forbidden",
6060
AuthPluginErrorConstants.forbiddenError)
61-
@unknown default:
62-
return .unknown("Unknown service error occurred")
6361
}
6462
}
6563
}

AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Service/ErrorMapping/ConfirmForgotPasswordOutputError+AuthError.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -76,8 +76,6 @@ extension ConfirmForgotPasswordOutputError: AuthErrorConvertible {
7676
case .forbiddenException(let forbiddenException):
7777
return .service(forbiddenException.message ?? "Access to the requested resource is forbidden",
7878
AuthPluginErrorConstants.forbiddenError)
79-
@unknown default:
80-
return .unknown("Unknown service error occurred")
8179
}
8280
}
8381
}

AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Service/ErrorMapping/ConfirmSignUpOutputError+AuthError.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,6 @@ extension ConfirmSignUpOutputError: AuthErrorConvertible {
115115
case .forbiddenException(let forbiddenException):
116116
return .service(forbiddenException.message ?? "Access to the requested resource is forbidden",
117117
AuthPluginErrorConstants.forbiddenError)
118-
@unknown default:
119-
return .unknown("Unknown service error occurred")
120118
}
121119
}
122120

AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Service/ErrorMapping/DeleteUserOutputError+AuthError.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,6 @@ extension DeleteUserOutputError: AuthErrorConvertible {
5050
case .forbiddenException(let forbiddenException):
5151
return .service(forbiddenException.message ?? "Access to the requested resource is forbidden",
5252
AuthPluginErrorConstants.forbiddenError)
53-
@unknown default:
54-
return .unknown("Unknown service error occurred")
5553
}
5654
}
5755
}

AmplifyPlugins/Auth/Sources/AWSCognitoAuthPlugin/Service/ErrorMapping/ForgetDeviceOutputError+AuthError.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,6 @@ extension ForgetDeviceOutputError: AuthErrorConvertible {
5353
case .forbiddenException(let forbiddenException):
5454
return .service(forbiddenException.message ?? "Access to the requested resource is forbidden",
5555
AuthPluginErrorConstants.forbiddenError)
56-
@unknown default:
57-
return .unknown("Unknown service error occurred")
5856
}
5957
}
6058
}

0 commit comments

Comments
 (0)