diff --git a/aws-auth-cognito/src/main/java/com/amplifyframework/auth/cognito/RealAWSCognitoAuthPlugin.kt b/aws-auth-cognito/src/main/java/com/amplifyframework/auth/cognito/RealAWSCognitoAuthPlugin.kt index 09fa969bc8..7a59ddf665 100644 --- a/aws-auth-cognito/src/main/java/com/amplifyframework/auth/cognito/RealAWSCognitoAuthPlugin.kt +++ b/aws-auth-cognito/src/main/java/com/amplifyframework/auth/cognito/RealAWSCognitoAuthPlugin.kt @@ -164,6 +164,13 @@ import com.amplifyframework.statemachine.codegen.states.SetupTOTPState import com.amplifyframework.statemachine.codegen.states.SignInChallengeState import com.amplifyframework.statemachine.codegen.states.SignInState import com.amplifyframework.statemachine.codegen.states.SignOutState +import java.io.IOException +import java.util.concurrent.CountDownLatch +import java.util.concurrent.TimeUnit +import java.util.concurrent.atomic.AtomicReference +import kotlin.coroutines.resume +import kotlin.coroutines.resumeWithException +import kotlin.coroutines.suspendCoroutine import kotlinx.coroutines.DelicateCoroutinesApi import kotlinx.coroutines.GlobalScope import kotlinx.coroutines.async @@ -177,13 +184,6 @@ import okhttp3.OkHttpClient import okhttp3.Request import okhttp3.RequestBody.Companion.toRequestBody import okhttp3.Response -import java.io.IOException -import java.util.concurrent.CountDownLatch -import java.util.concurrent.TimeUnit -import java.util.concurrent.atomic.AtomicReference -import kotlin.coroutines.resume -import kotlin.coroutines.resumeWithException -import kotlin.coroutines.suspendCoroutine internal class RealAWSCognitoAuthPlugin( private val configuration: AuthConfiguration, diff --git a/aws-auth-cognito/src/main/java/com/amplifyframework/auth/cognito/helpers/AuthHelper.kt b/aws-auth-cognito/src/main/java/com/amplifyframework/auth/cognito/helpers/AuthHelper.kt index a480ab212f..9b7449a496 100644 --- a/aws-auth-cognito/src/main/java/com/amplifyframework/auth/cognito/helpers/AuthHelper.kt +++ b/aws-auth-cognito/src/main/java/com/amplifyframework/auth/cognito/helpers/AuthHelper.kt @@ -17,15 +17,14 @@ package com.amplifyframework.auth.cognito.helpers import com.amplifyframework.auth.cognito.exceptions.service.InvalidParameterException import com.amplifyframework.auth.exceptions.UnknownException -import org.json.JSONObject import javax.crypto.Mac import javax.crypto.spec.SecretKeySpec - +import org.json.JSONObject internal open class AuthHelper { companion object { val HMAC_SHA_256 = "HmacSHA256" - val USERNAME_KEY = "username" + val KEY_USERNAME = "username" /** * Generates secret hash. Uses HMAC SHA256. @@ -78,7 +77,7 @@ internal open class AuthHelper { return try { val header = magicLinkCode.split(".")[0] val jsonString = android.util.Base64.decode(header, android.util.Base64.NO_WRAP) - JSONObject(jsonString.toString(Charsets.UTF_8)).getString(USERNAME_KEY) + JSONObject(jsonString.toString(Charsets.UTF_8)).getString(KEY_USERNAME) } catch (e: Exception) { null } diff --git a/aws-auth-cognito/src/test/java/com/amplifyframework/auth/cognito/featuretest/generators/authstategenerators/AuthStateJsonGenerator.kt b/aws-auth-cognito/src/test/java/com/amplifyframework/auth/cognito/featuretest/generators/authstategenerators/AuthStateJsonGenerator.kt index 6197e592ac..18e1d05afb 100644 --- a/aws-auth-cognito/src/test/java/com/amplifyframework/auth/cognito/featuretest/generators/authstategenerators/AuthStateJsonGenerator.kt +++ b/aws-auth-cognito/src/test/java/com/amplifyframework/auth/cognito/featuretest/generators/authstategenerators/AuthStateJsonGenerator.kt @@ -95,7 +95,7 @@ object AuthStateJsonGenerator : SerializableProvider { "CODE_DELIVERY_DESTINATION" to "+12345678900" ) ), - hasNewResponse = false + hasNewResponse = false ) ) ), @@ -117,7 +117,7 @@ object AuthStateJsonGenerator : SerializableProvider { "USERNAME" to "username" ) ), - hasNewResponse = false + hasNewResponse = false ) ) ), @@ -139,7 +139,7 @@ object AuthStateJsonGenerator : SerializableProvider { "USERNAME" to "username" ) ), - hasNewResponse = false + hasNewResponse = false ) ) ),