Skip to content

Commit da0256d

Browse files
authored
Merge branch 'main' into mattcreaser/usecase-delete-user
2 parents c86712e + 71d9031 commit da0256d

File tree

20 files changed

+809
-174
lines changed

20 files changed

+809
-174
lines changed

apollo/CHANGELOG.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
1+
## [Release 1.2.0](https://github.com/aws-amplify/amplify-android/releases/tag/release_apollo_v1.2.0)
2+
3+
### Features
4+
- **Apollo:** Add constructor to ApolloAmplifyConnector for directly specifying connection information ([#2980](https://github.com/aws-amplify/amplify-android/issues/2980))
5+
6+
### Bug Fixes
7+
- **apollo:** Fix using Apollo to connect to AppSync in China ([#2947](https://github.com/aws-amplify/amplify-android/issues/2947))
8+
9+
[See all changes between 1.1.0 and 1.2.0](https://github.com/aws-amplify/amplify-android/compare/release_apollo_v1.1.0...release_apollo_v1.2.0)
10+
111
## [Release 1.1.0](https://github.com/aws-amplify/amplify-android/releases/tag/release_apollo_v1.1.0)
212

313
### Features

apollo/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,10 +17,10 @@ Add the dependency you prefer to your `build.gradle.kts` file.
1717

1818
```kotlin
1919
// To only use Apollo to speak to AppSync, without using Amplify
20-
implementation("com.amplifyframework:apollo-appsync:1.1.0")
20+
implementation("com.amplifyframework:apollo-appsync:1.2.0")
2121

2222
// To connect Apollo to AppSync using your existing Amplify Gen2 Backend
23-
implementation("com.amplifyframework:apollo-appsync-amplify:1.1.0")
23+
implementation("com.amplifyframework:apollo-appsync-amplify:1.2.0")
2424
```
2525

2626
For applications using `apollo-appsync` directly, instantiate the Endpoint and the desired Authorizer instance, and then call the Apollo builder extension.

apollo/apollo-appsync-amplify/src/androidTest/backend/package-lock.json

Lines changed: 32 additions & 9 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

apollo/apollo-appsync-amplify/src/androidTest/backend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313
"@aws-amplify/backend": "^1.14.3",
1414
"@aws-amplify/backend-cli": "^1.5.0",
1515
"aws-cdk": "^2.1005.0",
16-
"aws-cdk-lib": "^2.185.0",
16+
"aws-cdk-lib": "^2.187.0",
1717
"constructs": "^10.4.2",
1818
"esbuild": "^0.25.1",
1919
"tsx": "^4.19.3",

apollo/version.properties

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
VERSION_NAME=1.1.0
1+
VERSION_NAME=1.2.0

aws-auth-cognito/src/main/java/com/amplifyframework/auth/cognito/AWSCognitoAuthPlugin.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -459,7 +459,7 @@ class AWSCognitoAuthPlugin : AuthPlugin<AWSCognitoAuthService>() {
459459
) = enqueue(onSuccess, onError) { useCaseFactory.listWebAuthnCredentials().execute(options) }
460460

461461
override fun autoSignIn(onSuccess: Consumer<AuthSignInResult>, onError: Consumer<AuthException>) =
462-
enqueue(onSuccess, onError) { queueFacade.autoSignIn() }
462+
enqueue(onSuccess, onError) { useCaseFactory.autoSignIn().execute() }
463463

464464
override fun deleteWebAuthnCredential(credentialId: String, onSuccess: Action, onError: Consumer<AuthException>) =
465465
deleteWebAuthnCredential(credentialId, AuthDeleteWebAuthnCredentialOptions.defaults(), onSuccess, onError)

aws-auth-cognito/src/main/java/com/amplifyframework/auth/cognito/KotlinAuthFacadeInternal.kt

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -161,11 +161,4 @@ internal class KotlinAuthFacadeInternal(private val delegate: RealAWSCognitoAuth
161161
{ continuation.resumeWithException(it) }
162162
)
163163
}
164-
165-
suspend fun autoSignIn(): AuthSignInResult = suspendCoroutine { continuation ->
166-
delegate.autoSignIn(
167-
{ continuation.resume(it) },
168-
{ continuation.resumeWithException(it) }
169-
)
170-
}
171164
}

aws-auth-cognito/src/main/java/com/amplifyframework/auth/cognito/RealAWSCognitoAuthPlugin.kt

Lines changed: 0 additions & 103 deletions
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,6 @@ import com.amplifyframework.statemachine.codegen.data.HostedUIErrorData
8787
import com.amplifyframework.statemachine.codegen.data.SignInData
8888
import com.amplifyframework.statemachine.codegen.data.SignInMethod
8989
import com.amplifyframework.statemachine.codegen.data.SignOutData
90-
import com.amplifyframework.statemachine.codegen.data.SignUpData
9190
import com.amplifyframework.statemachine.codegen.data.WebAuthnSignInContext
9291
import com.amplifyframework.statemachine.codegen.data.challengeNameType
9392
import com.amplifyframework.statemachine.codegen.errors.SessionError
@@ -108,7 +107,6 @@ import com.amplifyframework.statemachine.codegen.states.SetupTOTPState
108107
import com.amplifyframework.statemachine.codegen.states.SignInChallengeState
109108
import com.amplifyframework.statemachine.codegen.states.SignInState
110109
import com.amplifyframework.statemachine.codegen.states.SignOutState
111-
import com.amplifyframework.statemachine.codegen.states.SignUpState
112110
import com.amplifyframework.statemachine.codegen.states.WebAuthnSignInState
113111
import java.lang.ref.WeakReference
114112
import java.util.concurrent.CountDownLatch
@@ -172,107 +170,6 @@ internal class RealAWSCognitoAuthPlugin(
172170
authStateMachine.state.takeWhile { it !is AuthState.Configured && it !is AuthState.Error }.collect()
173171
}
174172

175-
fun autoSignIn(onSuccess: Consumer<AuthSignInResult>, onError: Consumer<AuthException>) {
176-
authStateMachine.getCurrentState { authState ->
177-
when (authState.authNState) {
178-
is AuthenticationState.NotConfigured -> onError.accept(
179-
InvalidUserPoolConfigurationException()
180-
)
181-
is AuthenticationState.SignedIn -> {
182-
onError.accept(InvalidStateException())
183-
}
184-
is AuthenticationState.SignedOut -> GlobalScope.launch {
185-
when (val signUpState = authState.authSignUpState) {
186-
is SignUpState.SignedUp -> {
187-
_autoSignIn(signUpState.signUpData, onSuccess, onError)
188-
}
189-
else -> onError.accept(InvalidStateException())
190-
}
191-
}
192-
is AuthenticationState.SigningIn -> {
193-
val token = StateChangeListenerToken()
194-
authStateMachine.listen(
195-
token,
196-
{ authState ->
197-
when (authState.authNState) {
198-
is AuthenticationState.SignedOut -> {
199-
authStateMachine.cancel(token)
200-
when (val signUpState = authState.authSignUpState) {
201-
is SignUpState.SignedUp -> GlobalScope.launch {
202-
_autoSignIn(signUpState.signUpData, onSuccess, onError)
203-
}
204-
else -> onError.accept(InvalidStateException())
205-
}
206-
}
207-
else -> Unit
208-
}
209-
},
210-
{
211-
authStateMachine.send(AuthenticationEvent(AuthenticationEvent.EventType.CancelSignIn()))
212-
}
213-
)
214-
}
215-
else -> onError.accept(InvalidStateException())
216-
}
217-
}
218-
}
219-
220-
private suspend fun _autoSignIn(
221-
signUpData: SignUpData,
222-
onSuccess: Consumer<AuthSignInResult>,
223-
onError: Consumer<AuthException>
224-
) {
225-
val token = StateChangeListenerToken()
226-
authStateMachine.listen(
227-
token,
228-
{ authState ->
229-
val authNState = authState.authNState
230-
val authZState = authState.authZState
231-
when {
232-
authNState is AuthenticationState.SigningIn -> {
233-
val signInState = authNState.signInState
234-
when {
235-
signInState is SignInState.Error -> {
236-
authStateMachine.cancel(token)
237-
onError.accept(
238-
CognitoAuthExceptionConverter.lookup(signInState.exception, "Sign in failed.")
239-
)
240-
}
241-
}
242-
}
243-
authNState is AuthenticationState.SignedIn &&
244-
authZState is AuthorizationState.SessionEstablished -> {
245-
authStateMachine.cancel(token)
246-
val authSignInResult = AuthSignInResult(
247-
true,
248-
AuthNextSignInStep(
249-
AuthSignInStep.DONE,
250-
mapOf(),
251-
null,
252-
null,
253-
null,
254-
null
255-
)
256-
)
257-
onSuccess.accept(authSignInResult)
258-
sendHubEvent(AuthChannelEventName.SIGNED_IN.toString())
259-
}
260-
else -> Unit
261-
}
262-
},
263-
{
264-
val signInData = SignInData.AutoSignInData(
265-
signUpData.username,
266-
signUpData.session,
267-
signUpData.clientMetadata ?: mapOf(),
268-
signUpData.userId
269-
)
270-
val event = AuthenticationEvent(AuthenticationEvent.EventType.SignInRequested(signInData))
271-
authStateMachine.send(event)
272-
}
273-
)
274-
}
275-
276173
fun signIn(
277174
username: String?,
278175
password: String?,

aws-auth-cognito/src/main/java/com/amplifyframework/auth/cognito/usecases/AuthUseCaseFactory.kt

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,13 @@ import com.amplifyframework.auth.cognito.AuthStateMachine
2020
import com.amplifyframework.auth.cognito.RealAWSCognitoAuthPlugin
2121
import com.amplifyframework.auth.cognito.helpers.WebAuthnHelper
2222
import com.amplifyframework.auth.cognito.requireIdentityProviderClient
23+
import com.amplifyframework.auth.plugins.core.AuthHubEventEmitter
2324

2425
internal class AuthUseCaseFactory(
2526
private val plugin: RealAWSCognitoAuthPlugin,
2627
private val authEnvironment: AuthEnvironment,
27-
private val stateMachine: AuthStateMachine
28+
private val stateMachine: AuthStateMachine,
29+
private val hubEmitter: AuthHubEventEmitter = AuthHubEventEmitter()
2830
) {
2931

3032
fun fetchAuthSession() = FetchAuthSessionUseCase(plugin)
@@ -140,6 +142,11 @@ internal class AuthUseCaseFactory(
140142
stateMachine = stateMachine
141143
)
142144

145+
fun autoSignIn() = AutoSignInUseCase(
146+
stateMachine = stateMachine,
147+
hubEmitter = hubEmitter
148+
)
149+
143150
fun fetchMfaPreference() = FetchMfaPreferenceUseCase(
144151
client = authEnvironment.requireIdentityProviderClient(),
145152
fetchAuthSession = fetchAuthSession(),

0 commit comments

Comments
 (0)