Skip to content

Commit 09dc518

Browse files
div5yesheeatonawsmikepschneiderlawmichamikschn-aws
authored
chore: merge main into notifications (#167)
* fix(core): remove unused dynamic nav dependency (#2132) * fix(datastore): remove typename from ModelMetadata (#2122) * fix(datastore): remove typename from ModelMetadata * Test a potential fix * Test a potential fix * fix: callbacks not invoked when attached using getTransfer api (#2111) * fix: listener not invoked when attached using getTransfer api * address PR comments * default state to unknown * add comment * add comment * override getRequest in storage operation & make SocketExcpetion retryable * add nullable annotation * address nullable request Co-authored-by: Tyler Roach <[email protected]> * Prevent attempting to read backed up EncryptedSharedPreferences that are no longer readable (#2113) * fix(auth): device metadata migration (#2114) * Number of attributes being too high is not retryable (#2112) * Number of attributes being too high is not retryable * Match iOS at not retrying bad request error -- covering multiple 400 errors * Fix lint * Fix lint * Update Kotlin SDK version Co-authored-by: Thomas Leing <[email protected]> * Change errors returned on some apis while federated (#2116) * release: Amplify Android 2.0.0 (#2115) * release: Amplify Android 2.0.0 * add core-kotlin changelog * add more info in changelog * revert unintended change * remove breaking change for analytics * fix(datastore): remove typename from ModelMetadata * fix(datastore): remove typename from ModelMetadata * remove unneeded file * small cleanup * remove print statements * fix comment * force tests * force tests * force tests Co-authored-by: Michael Law <[email protected]> Co-authored-by: Michael Schneider <[email protected]> Co-authored-by: Saijad Dhuka <[email protected]> Co-authored-by: Tyler Roach <[email protected]> Co-authored-by: Divyesh Chitroda <[email protected]> Co-authored-by: Thomas Leing <[email protected]> Co-authored-by: Thomas Leing <[email protected]> Co-authored-by: Sunil Timalsina <[email protected]> * chore: Remove deprecated maven plugin (#2137) * Remove deprecated maven project * Fix task name grep * chore: Remove Javadoc tasks (#2139) * Remove deprecated maven project * Fix task name grep * Remove Javadoc tasks * fix: Change order of updating state in local cache (#2141) * fix: fix integration test and added logger to integration test (#2143) * fix: Change order of updating state in local cache * change order for updating status and add logger to integ tests * change log level to debug * Fix for when move to idle state is called twice (#2152) * Update README.md (#2120) remove dev-preview APIs note. * Dengdan stress test (#2153) * Initial commit * Work in progress * finish codes * change build * update build * test excludeStressTest * Revert "Merge branch 'main' into dengdan-stress-test" This reverts commit b50840e, reversing changes made to 3bacf1b. * remove categories * remove external changes * remove external changes * remove more changes * Update copyright and refactor * Update StorageStressTest.kt * Update StorageStressTest.kt * Update StorageStressTest.kt * Update StorageStressTest.kt * linting * Update StorageStressTest.kt * Delete StorageStressTest.kt * Delete amplifyconfigurationupdated.json * Delete amplifyconfigurationupdated.json * Update DataStoreStressTest.kt * Fix(Auth): Sign up if successful should return DONE instead of Confirm sign up (#2130) * If sign up is successful in the first try return DONE * Sign up should send DONE if it is successful * revert jsongenerator cleandir fun * lint fix * Feat(Auth Test): Custom party testing for Custom Test without SRP (#2149) * Adding custom auth test cases * Updating test cases for Custom Auth to ensure they pass * lint format * Fix for phone number * Recreate all tests * Unignore storage and pinpoint tests (#2156) * unignore tests * extend timeout to 60s Co-authored-by: Saijad Dhuka <[email protected]> * feat(Geo): Add Kotlin Geo Facade (#2155) * Add Kotlin Geo Facade * Add return docs to the function comments * Add tests to verify options are passed * fix: Add missing apis in storage Kotlin & RxJava facade (#2160) * fix: Add pause, resume api to kotlin and rxJava facade * add unit tests * remove irrelevant code changes * add assertion * Update DeviceFarm build config (#2168) * fix: user metadata was persisted empty in the database (#2165) * fix: usermeta was persisted as empty in the database * fix compilation error * fix compilation error * avoid adding metadata if it is null * Add Geo Rx Bindings (#2159) * chore: Re-add storage tests (#2163) * Readd storage tests * rename file * reduce stress Co-authored-by: Saijad Dhuka <[email protected]> * Add a network status listener to restart DataStore after the network … (#2148) * Add a network status listener to restart DataStore after the network comes back online. * Add Reachability monitor * working pretty well * cleanup * update test * fix: fix integration test and added logger to integration test (#2143) * fix: Change order of updating state in local cache * change order for updating status and add logger to integ tests * change log level to debug * Fix for when move to idle state is called twice (#2152) * Update README.md (#2120) remove dev-preview APIs note. * Dengdan stress test (#2153) * Initial commit * Work in progress * finish codes * change build * update build * test excludeStressTest * Revert "Merge branch 'main' into dengdan-stress-test" This reverts commit b50840e, reversing changes made to 3bacf1b. * remove categories * remove external changes * remove external changes * remove more changes * Update copyright and refactor * Update StorageStressTest.kt * Update StorageStressTest.kt * Update StorageStressTest.kt * Update StorageStressTest.kt * linting * Update StorageStressTest.kt * Delete StorageStressTest.kt * Delete amplifyconfigurationupdated.json * Delete amplifyconfigurationupdated.json * Update DataStoreStressTest.kt * force build * force build * force build * fix typo * Add a network status listener to restart DataStore after the network comes back online. * Add Reachability monitor * working pretty well * cleanup * update test * force build * force build * force build * fix typo * reply to comments * Add testImplementation lin eto compile tests correctly in intellij * reply to comments * make ReachabilityMonitor expose the observable * Update datastore plugin to use the reachability monitor * cleanup * cleanup * cleanup * force tests Co-authored-by: Michael Schneider <[email protected]> Co-authored-by: Saijad Dhuka <[email protected]> Co-authored-by: gpanshu <[email protected]> Co-authored-by: Divyesh Chitroda <[email protected]> Co-authored-by: dengdan154 <[email protected]> * chore: Upgrade Gradle, AGP, and KtLint (#2172) * Remove deprecated maven project * Fix task name grep * Upgrade Gradle to 7.5.1 * Upgrade AGP * Add VERSION_NAME back to BuildConfig This was removed for library projects in AGP 4.1. We may consider renaming this in the future to disambiguate the Amplify version and the application version. * Update KtLint and fix all new lint errors * Use JDK11 on codebuild * Use JDK11 in workflows * Upgrade compileSdkVersion to 31 * Try using custom commands to install Android SDK 31 * Update device farm buildspec with manual Android SDK install * Fix additional ktlint errors * Upgrade Desugar to JDK11-compatible version * Upgrade Robolectric * Set locale explicitly to match expectation * fix(geo): Increase Geo timeout so that it runs successfully on a Pixel 3a XL (#2177) * Increase Geo timeout so that it runs successfully on a Pixel 3a XL * Fix lint Co-authored-by: Thomas Leing <[email protected]> * Add a buildspec file for nightly tests (#2180) * Chore(Auth): Implementation of the custom auth with SRP parity testing use case (#2167) * Added the test case for custom auth with SRP * ktlint * release: Amplify Android 2.1.0 (manually created) (#2185) Co-authored-by: Thomas Leing <[email protected]> * chore: Add PR checker workflow (#2188) * fix(Auth): Fix for when loading credentials the success/error is fired twice (#2184) * chore: update changelog for Amplify Android 2.1.0 (#2193) * feat(Auth): Overriding sign in when the State machine is already in the signing in state (#2187) * chore: fix inconsistency with endpointWithAttributes test (#2196) * chore: update changelog for v2.1.0 (#2198) * chore: replace md5 with sha-256 for file data validation (#2199) * chore: Remove unused version and group properties (#2186) * chore: Add a label that will disable the PR title check (#2195) Co-authored-by: gpanshu <[email protected]> * chore: add release tag to PR title checker config (#2194) Co-authored-by: Matt Creaser <[email protected]> * fix(datastore): Fix lock contention issue when running DataStore.start() from the callback of DataStore.stop() (#2208) Co-authored-by: Michael Schneider <[email protected]> * chore: Add group and version back to all subprojects (#2213) * chore: Remove the release-kotlin_v block from prepare release script (#2231) * fix(core): Remove unused dependencies (#2207) Co-authored-by: Matt Creaser <[email protected]> * chore: Modify the bump_version branch name to be specific to the base branch (#2240) * fix(geo): Bump MapLibre SDK to 9.6.0 (#2254) * release: Amplify Android 2.1.1 (#2257) Co-authored-by: amplify-android-dev+ghops <[email protected]> * fix(analytics): Remove test dependencies from implementation configuration (#2253) * chore: Ignore clearStopsSyncAndDeletesDatabase test (#2262) * fix(auth): Fix Authorization header for HostedUI fetchToken when appSecret is used (#2264) * chore: Supply base_branch when calling `create_next_release_pr` lane (#2245) * chore: Update PR template to include security checklist item (#2251) * feat(auth): add required hash param to cognito api calls (#2266) Co-authored-by: Banji Jolaoso <[email protected]> Co-authored-by: AWS Mobile SDK Bot <[email protected]> Co-authored-by: Saijad Dhuka <[email protected]> Co-authored-by: Tyler Roach <[email protected]> * feat(datastore): Add recoverability improvements (#2201) Co-authored-by: Matt Creaser <[email protected]> * feat(auth): Added parity test for fetchDevices,rememberDevice,forgetDevice and fetchUserAttributes (#2174) Co-authored-by: Sunil Timalsina <[email protected]> Co-authored-by: Banji Jolaoso <[email protected]> Co-authored-by: Divyesh Chitroda <[email protected]> Co-authored-by: Matt Creaser <[email protected]> Co-authored-by: Saijad Dhuka <[email protected]> Co-authored-by: Tyler Roach <[email protected]> Co-authored-by: Thomas Leing <[email protected]> Co-authored-by: Thomas Leing <[email protected]> Co-authored-by: gpanshu <[email protected]> Co-authored-by: AWS Mobile SDK Bot <[email protected]> * release: Amplify Android 2.2.0 (#2269) Co-authored-by: amplify-android-dev+ghops <[email protected]> * chore: Convert build.gradle files to Kotlin (#2183) * Convert build.gradle files to Kotlin * Fix missing test dependency * Update copyright year * chore: Set the signing information in project extras (#2277) * fix(auth): Moving credential provider to main (#2273) * chore(analytics): Simplify error code checking, uniformly across platforms (#2274) Co-authored-by: Thomas Leing <[email protected]> Co-authored-by: Matt Creaser <[email protected]> * feat(auth): added kover plugin for coverage (#2267) Co-authored-by: Banji Jolaoso <[email protected]> Co-authored-by: gpanshu <[email protected]> * release: Amplify Android 2.2.1 (#2285) Co-authored-by: amplify-android-dev+ghops <[email protected]> Co-authored-by: Matt Creaser <[email protected]> * chore: Remove circleci configuration file (#2279) Co-authored-by: gpanshu <[email protected]> * fix(auth): fix npe in initialize fetch auth session (#2284) Co-authored-by: Banji Jolaoso <[email protected]> * fix(auth): Fix confirm signin when incorrect MFA code is entered (#2286) * release: Amplify Android 2.2.2 (#2292) Co-authored-by: amplify-android-dev+ghops <[email protected]> * chore: Fix using amplify-android in a composite build (#2294) * chore: update device farm configuration for nightly build (#2281) * chore: remove buildspec files (#2308) * chore: remove amplify-data from codeowners (#2252) Co-authored-by: Saijad Dhuka <[email protected]> * fix(datastore): Fix aliasing of column names (#2312) * feat(storage): Add support for S3 acceleration mode (#2304) * feat(aws-datastore): Make the reachability component configurable (#2307) Signed-off-by: Manuel Iglesias <[email protected]> Co-authored-by: Divyesh Chitroda <[email protected]> * release: Amplify Android 2.3.0 (#2323) Co-authored-by: amplify-android-dev+ghops <[email protected]> * feat(aws-api,aws-datastore): WebSocket improvements (#2283) Signed-off-by: Manuel Iglesias <[email protected]> Co-authored-by: Divyesh Chitroda <[email protected]> Co-authored-by: Matt Creaser <[email protected]> * chore(auth): Use restricted API to surface the JSON used to configure the Auth category (#2311) Co-authored-by: Thomas Leing <[email protected]> * chore: Remove incorrect Developer Preview label (#2328) * fix(auth): Delete user invalid state fixes (#2326) Co-authored-by: Anshul Gupta <[email protected]> Co-authored-by: gpanshu <[email protected]> * Restore publishing sources jar (#2329) Co-authored-by: Thomas Leing <[email protected]> * release: Amplify Android 2.3.0 (#2330) Co-authored-by: amplify-android-dev+ghops <[email protected]> Co-authored-by: Thomas Leing <[email protected]> * feat(auth): Add aws-core and AWSCredentialsProvider (#2316) Co-authored-by: Tim Schmelter <[email protected]> Co-authored-by: Erica Eaton <[email protected]> Co-authored-by: Divyesh Chitroda <[email protected]> --------- Signed-off-by: Manuel Iglesias <[email protected]> Co-authored-by: Erica Eaton <[email protected]> Co-authored-by: Michael Schneider <[email protected]> Co-authored-by: Michael Law <[email protected]> Co-authored-by: Michael Schneider <[email protected]> Co-authored-by: Saijad Dhuka <[email protected]> Co-authored-by: Tyler Roach <[email protected]> Co-authored-by: Thomas Leing <[email protected]> Co-authored-by: Thomas Leing <[email protected]> Co-authored-by: Sunil Timalsina <[email protected]> Co-authored-by: Matt Creaser <[email protected]> Co-authored-by: gpanshu <[email protected]> Co-authored-by: dengdan154 <[email protected]> Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com> Co-authored-by: amplify-android-dev+ghops <[email protected]> Co-authored-by: banji180 <[email protected]> Co-authored-by: Banji Jolaoso <[email protected]> Co-authored-by: AWS Mobile SDK Bot <[email protected]> Co-authored-by: Manuel Iglesias <[email protected]> Co-authored-by: Dane Pilcher <[email protected]> Co-authored-by: Anshul Gupta <[email protected]> Co-authored-by: Tim Schmelter <[email protected]>
1 parent 58ca09d commit 09dc518

File tree

50 files changed

+430
-150
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

50 files changed

+430
-150
lines changed

CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,14 @@
33
### Features
44
- **storage:** Add support for S3 acceleration mode ([#2304](https://github.com/aws-amplify/amplify-android/issues/2304))
55
- **aws-datastore:** Make the reachability component configurable ([#2307](https://github.com/aws-amplify/amplify-android/issues/2307))
6+
- **aws-api,aws-datastore:** WebSocket improvements ([#2283](https://github.com/aws-amplify/amplify-android/issues/2283))
67

78
### Bug Fixes
89
- **datastore:** Fix aliasing of column names ([#2312](https://github.com/aws-amplify/amplify-android/issues/2312))
10+
- **auth:** Delete user invalid state fixes ([#2326](https://github.com/aws-amplify/amplify-android/issues/2326))
11+
12+
### Miscellaneous
13+
- Restore publishing sources jar ([#2329](https://github.com/aws-amplify/amplify-android/issues/2329))
914

1015
[See all changes between 2.2.2 and 2.3.0](https://github.com/aws-amplify/amplify-android/compare/release_v2.2.2...release_v2.3.0)
1116

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
## Amplify for Android (Developer Preview)
1+
## Amplify for Android
22
<img src="https://s3.amazonaws.com/aws-mobile-hub-images/aws-amplify-logo.png" alt="AWS Amplify" width="550">
33

44
[![DiscordChat](https://img.shields.io/discord/308323056592486420?logo=discord)](https://discord.gg/jWVbPfC)

annotations/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
/build

annotations/build.gradle.kts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/*
2+
* Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
7+
*
8+
* http://aws.amazon.com/apache2.0
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
14+
*/
15+
16+
plugins {
17+
id("com.android.library")
18+
id("kotlin-android")
19+
}
20+
21+
apply(from = rootProject.file("configuration/checkstyle.gradle"))
22+
apply(from = rootProject.file("configuration/publishing.gradle"))
23+
24+
group = properties["POM_GROUP"].toString()
25+
26+
android {
27+
kotlinOptions {
28+
moduleName = "com.amplifyframework.annotations"
29+
}
30+
}
31+
32+
dependencies {
33+
implementation(dependency.kotlin.stdlib)
34+
}
35+
36+
afterEvaluate {
37+
// Disables this warning:
38+
// warning: listOf(classfile) MethodParameters attribute
39+
// introduced in version 52.0 class files is ignored in
40+
// version 51.0 class files
41+
// Root project has -Werror, so this warning
42+
// would fail the build, otherwise.
43+
tasks.withType<JavaCompile>().configureEach {
44+
options.compilerArgs.add("-Xlint:-classfile")
45+
}
46+
}

annotations/gradle.properties

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
POM_ARTIFACT_ID=annotations
2+
POM_NAME=Amplify Framework for Android - Annotations
3+
POM_DESCRIPTION=Amplify Framework for Android - Annotations for AWS Amplify Libraries
4+
POM_PACKAGING=aar
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<!--
3+
Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
4+
5+
Licensed under the Apache License, Version 2.0 (the "License").
6+
You may not use this file except in compliance with the License.
7+
A copy of the License is located at
8+
9+
http://aws.amazon.com/apache2.0
10+
11+
or in the "license" file accompanying this file. This file is distributed
12+
on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
13+
express or implied. See the License for the specific language governing
14+
permissions and limitations under the License.
15+
-->
16+
17+
<manifest package="com.amplifyframework.annotations"
18+
xmlns:android="http://schemas.android.com/apk/res/android">
19+
</manifest>
20+
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
/*
2+
* Copyright 2023 Amazon.com, Inc. or its affiliates. All Rights Reserved.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License").
5+
* You may not use this file except in compliance with the License.
6+
* A copy of the License is located at
7+
*
8+
* http://aws.amazon.com/apache2.0
9+
*
10+
* or in the "license" file accompanying this file. This file is distributed
11+
* on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either
12+
* express or implied. See the License for the specific language governing
13+
* permissions and limitations under the License.
14+
*/
15+
16+
package com.amplifyframework.annotations
17+
18+
/**
19+
* API marked with this annotation is internal to Amplify, and it is not intended to be used outside.
20+
* It could be modified or removed without any notice.
21+
*
22+
* We strongly recommend to not use such API.
23+
*/
24+
@Suppress("DEPRECATION")
25+
@RequiresOptIn(
26+
level = RequiresOptIn.Level.WARNING,
27+
message = "This API is internal to Amplify and should not be used. It could be removed or changed without notice.",
28+
)
29+
@Target(
30+
AnnotationTarget.CLASS,
31+
AnnotationTarget.TYPEALIAS,
32+
AnnotationTarget.FUNCTION,
33+
AnnotationTarget.PROPERTY,
34+
AnnotationTarget.FIELD,
35+
AnnotationTarget.CONSTRUCTOR,
36+
)
37+
public annotation class InternalApiWarning

aws-analytics-pinpoint/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ group = properties["POM_GROUP"].toString()
2626

2727
dependencies {
2828
implementation(project(":core"))
29+
implementation(project(":aws-core"))
2930
implementation(project(":aws-pinpoint-core"))
3031

3132
implementation(dependency.androidx.appcompat)

aws-api-appsync/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ group = properties["POM_GROUP"].toString()
2525

2626
dependencies {
2727
implementation(project(":core"))
28+
implementation(project(":aws-core"))
2829

2930
implementation(dependency.androidx.annotation)
3031
implementation(dependency.androidx.core)

aws-api/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ group = properties["POM_GROUP"].toString()
2525

2626
dependencies {
2727
api(project(":core"))
28+
api(project(":aws-core"))
2829
implementation(project(":aws-api-appsync"))
2930

3031
implementation(dependency.androidx.appcompat)

aws-auth-cognito/build.gradle.kts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ group = properties["POM_GROUP"].toString()
2626

2727
dependencies {
2828
implementation(project(":core"))
29+
implementation(project(":aws-core"))
2930
implementation(dependency.kotlin.coroutines)
3031
implementation(dependency.kotlin.serializationJson)
3132
implementation(dependency.androidx.appcompat)

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ package com.amplifyframework.auth.cognito
1818
import android.app.Activity
1919
import android.content.Context
2020
import android.content.Intent
21+
import androidx.annotation.RestrictTo
2122
import androidx.annotation.VisibleForTesting
2223
import com.amplifyframework.AmplifyException
2324
import com.amplifyframework.auth.AuthCodeDeliveryDetails
@@ -91,6 +92,13 @@ class AWSCognitoAuthPlugin : AuthPlugin<AWSCognitoAuthService>() {
9192
}
9293
}
9394

95+
private lateinit var pluginConfigurationJSON: JSONObject
96+
97+
@RestrictTo(RestrictTo.Scope.LIBRARY_GROUP)
98+
fun getPluginConfiguration(): JSONObject {
99+
return pluginConfigurationJSON
100+
}
101+
94102
private fun Exception.toAuthException(): AuthException {
95103
return if (this is AuthException) {
96104
this
@@ -105,6 +113,7 @@ class AWSCognitoAuthPlugin : AuthPlugin<AWSCognitoAuthService>() {
105113

106114
@Throws(AmplifyException::class)
107115
override fun configure(pluginConfiguration: JSONObject, context: Context) {
116+
pluginConfigurationJSON = pluginConfiguration
108117
try {
109118
val configuration = AuthConfiguration.fromJson(pluginConfiguration)
110119
val credentialStoreClient = CredentialStoreClient(configuration, context, logger)

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,8 +17,8 @@ package com.amplifyframework.auth.cognito
1717

1818
import aws.sdk.kotlin.services.cognitoidentity.CognitoIdentityClient
1919
import aws.sdk.kotlin.services.cognitoidentityprovider.CognitoIdentityProviderClient
20-
import aws.sdk.kotlin.services.cognitoidentityprovider.endpoints.EndpointProvider
2120
import aws.smithy.kotlin.runtime.client.endpoints.Endpoint
21+
import aws.smithy.kotlin.runtime.client.endpoints.EndpointProvider
2222
import com.amplifyframework.statemachine.codegen.data.AuthConfiguration
2323

2424
interface AWSCognitoAuthService {

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

Lines changed: 27 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,8 @@ internal class RealAWSCognitoAuthPlugin(
833833
when (val authNState = it.authNState) {
834834
is AuthenticationState.SigningOut -> {
835835
(authNState.signOutState as? SignOutState.SigningOutHostedUI)?.let { signOutState ->
836-
if (callbackUri == null && signOutState.signedInData.signInMethod !=
836+
if (callbackUri == null && !signOutState.bypassCancel &&
837+
signOutState.signedInData.signInMethod !=
837838
SignInMethod.ApiBased(SignInMethod.ApiBased.AuthType.UNKNOWN)
838839
) {
839840
authStateMachine.send(
@@ -1734,40 +1735,35 @@ internal class RealAWSCognitoAuthPlugin(
17341735

17351736
private fun _deleteUser(token: String, onSuccess: Action, onError: Consumer<AuthException>) {
17361737
val listenerToken = StateChangeListenerToken()
1738+
var deleteUserException: Exception? = null
17371739
authStateMachine.listen(
17381740
listenerToken,
17391741
{ authState ->
1740-
when (val authNState = authState.authNState) {
1741-
is AuthenticationState.SignedOut -> {
1742-
val event = DeleteUserEvent(DeleteUserEvent.EventType.SignOutDeletedUser())
1743-
authStateMachine.send(event)
1744-
}
1745-
is AuthenticationState.Error -> {
1746-
val event = DeleteUserEvent(DeleteUserEvent.EventType.ThrowError(authNState.exception))
1747-
authStateMachine.send(event)
1748-
}
1749-
else -> {
1750-
// No-op
1751-
}
1752-
}
1753-
val authZState = authState.authZState as? AuthorizationState.DeletingUser
1754-
when (val deleteUserState = authZState?.deleteUserState) {
1755-
is DeleteUserState.UserDeleted -> {
1756-
onSuccess.call()
1757-
sendHubEvent(AuthChannelEventName.USER_DELETED.toString())
1758-
authStateMachine.cancel(listenerToken)
1759-
}
1760-
is DeleteUserState.Error -> {
1761-
authStateMachine.cancel(listenerToken)
1762-
onError.accept(
1763-
CognitoAuthExceptionConverter.lookup(
1764-
deleteUserState.exception,
1765-
"Request to delete user may have failed. Please check exception stack"
1742+
if (authState is AuthState.Configured) {
1743+
val (authNState, authZState) = authState
1744+
val exception = deleteUserException
1745+
when {
1746+
authZState is AuthorizationState.DeletingUser &&
1747+
authZState.deleteUserState is DeleteUserState.Error -> {
1748+
deleteUserException = authZState.deleteUserState.exception
1749+
}
1750+
authNState is AuthenticationState.SignedOut && authZState is AuthorizationState.Configured -> {
1751+
sendHubEvent(AuthChannelEventName.USER_DELETED.toString())
1752+
authStateMachine.cancel(listenerToken)
1753+
onSuccess.call()
1754+
}
1755+
authZState is AuthorizationState.SessionEstablished && exception != null -> {
1756+
authStateMachine.cancel(listenerToken)
1757+
onError.accept(
1758+
CognitoAuthExceptionConverter.lookup(
1759+
exception,
1760+
"Request to delete user may have failed. Please check exception stack"
1761+
)
17661762
)
1767-
)
1768-
}
1769-
else -> {
1770-
// No-op
1763+
}
1764+
else -> {
1765+
// No - op
1766+
}
17711767
}
17721768
}
17731769
},

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

Lines changed: 25 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,31 +22,48 @@ import com.amplifyframework.statemachine.Action
2222
import com.amplifyframework.statemachine.codegen.actions.DeleteUserActions
2323
import com.amplifyframework.statemachine.codegen.data.SignOutData
2424
import com.amplifyframework.statemachine.codegen.events.AuthenticationEvent
25+
import com.amplifyframework.statemachine.codegen.events.AuthorizationEvent
2526
import com.amplifyframework.statemachine.codegen.events.DeleteUserEvent
2627

2728
internal object DeleteUserCognitoActions : DeleteUserActions {
2829
override fun initDeleteUserAction(accessToken: String): Action =
2930
Action<AuthEnvironment>("DeleteUser") { id, dispatcher ->
3031
logger.verbose("$id Starting execution")
31-
val evt = try {
32+
try {
3233
cognitoAuthService.cognitoIdentityProviderClient?.deleteUser(
3334
DeleteUserRequest.invoke { this.accessToken = accessToken }
3435
)
35-
AuthenticationEvent(AuthenticationEvent.EventType.SignOutRequested(SignOutData(globalSignOut = false)))
36+
val evt = DeleteUserEvent(DeleteUserEvent.EventType.UserDeleted())
37+
logger.verbose("$id Sending event ${evt.type}")
38+
dispatcher.send(evt)
3639
} catch (e: Exception) {
3740
logger.warn("Failed to delete user.", e)
3841
if (e is UserNotFoundException) {
3942
// The user could have been remotely deleted, clear local session
40-
AuthenticationEvent(
41-
AuthenticationEvent.EventType.SignOutRequested(
42-
SignOutData(globalSignOut = false)
43-
)
44-
)
43+
val evt = DeleteUserEvent(DeleteUserEvent.EventType.ThrowError(e, true))
44+
logger.verbose("$id Sending event ${evt.type}")
45+
dispatcher.send(evt)
4546
} else {
46-
DeleteUserEvent(DeleteUserEvent.EventType.ThrowError(e))
47+
val evt = DeleteUserEvent(DeleteUserEvent.EventType.ThrowError(e, false))
48+
logger.verbose("$id Sending event ${evt.type}")
49+
dispatcher.send(evt)
50+
val evt2 = AuthorizationEvent(AuthorizationEvent.EventType.ThrowError(e))
51+
logger.verbose("$id Sending event ${evt2.type}")
52+
dispatcher.send(evt2)
4753
}
4854
}
55+
}
56+
57+
override fun initiateSignOut(): Action =
58+
Action<AuthEnvironment>("Sign Out Deleted User") { id, dispatcher ->
59+
logger.verbose("$id Starting execution")
60+
val evt = AuthorizationEvent(AuthorizationEvent.EventType.UserDeleted())
61+
val evt2 = AuthenticationEvent(
62+
AuthenticationEvent.EventType.SignOutRequested(SignOutData(globalSignOut = true, bypassCancel = true))
63+
)
4964
logger.verbose("$id Sending event ${evt.type}")
5065
dispatcher.send(evt)
66+
logger.verbose("$id Sending event ${evt2.type}")
67+
dispatcher.send(evt2)
5168
}
5269
}

aws-auth-cognito/src/main/java/com/amplifyframework/statemachine/codegen/actions/DeleteUserActions.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,5 @@ import com.amplifyframework.statemachine.Action
1919

2020
internal interface DeleteUserActions {
2121
fun initDeleteUserAction(accessToken: String): Action
22+
fun initiateSignOut(): Action
2223
}

aws-auth-cognito/src/main/java/com/amplifyframework/statemachine/codegen/data/SignOutData.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,5 @@ package com.amplifyframework.statemachine.codegen.data
1818
internal data class SignOutData(
1919
val globalSignOut: Boolean = false,
2020
val browserPackage: String? = null,
21+
val bypassCancel: Boolean = false // When user deleted, even if sign out is cancelled, proceed to sign out locally
2122
)

aws-auth-cognito/src/main/java/com/amplifyframework/statemachine/codegen/events/DeleteUserEvent.kt

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,8 @@ internal class DeleteUserEvent(
2424
) : StateMachineEvent {
2525
sealed class EventType {
2626
data class DeleteUser(val accessToken: String) : EventType()
27-
data class UserSignedOutAndDeleted(val id: String = "") : EventType()
28-
data class SignOutDeletedUser(val id: String = "") : EventType()
29-
data class ThrowError(val exception: Exception) : EventType()
27+
data class UserDeleted(val id: String = "") : EventType()
28+
data class ThrowError(val exception: Exception, val signOutUser: Boolean) : EventType()
3029
}
3130

3231
override val type: String = eventType.javaClass.simpleName

aws-auth-cognito/src/main/java/com/amplifyframework/statemachine/codegen/states/AuthenticationState.kt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -130,7 +130,8 @@ internal sealed class AuthenticationState : State {
130130
StateResolution(SigningIn(), listOf(action))
131131
}
132132
authenticationEvent is AuthenticationEvent.EventType.SignOutRequested -> {
133-
val action = authenticationActions.initiateSignOutAction(authenticationEvent, null)
133+
val action = authenticationActions
134+
.initiateSignOutAction(authenticationEvent, null)
134135
StateResolution(SigningOut(), listOf(action))
135136
}
136137
authorizationEvent is AuthorizationEvent.EventType.StartFederationToIdentityPool -> {

0 commit comments

Comments
 (0)