Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: Upgrade Gradle, AGP, and KtLint #2172

Merged
merged 20 commits into from Dec 13, 2022
Merged
Show file tree
Hide file tree
Changes from 15 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/codecov_code_coverage.yml
Expand Up @@ -29,7 +29,7 @@ jobs:
- name: Setup Java
uses: actions/setup-java@v3
with:
java-version: '8'
java-version: '11'
distribution: 'corretto'

- name: Run test and generate jacoco report
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/gradle.yml
Expand Up @@ -16,10 +16,10 @@ jobs:

steps:
- uses: actions/checkout@v2
- name: Set up JDK 1.8
- name: Set up JDK 11
uses: actions/setup-java@v1
with:
java-version: 1.8
java-version: 11
- name: Grant execute permission for gradlew
run: chmod +x gradlew
- name: Build with Gradle
Expand Down
3 changes: 3 additions & 0 deletions .idea/codeStyles/Project.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Expand Up @@ -181,34 +181,32 @@ internal class KotlinAuthFacadeInternal(private val delegate: RealAWSCognitoAuth
suspend fun signInWithSocialWebUI(
provider: AuthProvider,
callingActivity: Activity
):
AuthSignInResult {
return suspendCoroutine { continuation ->
delegate.signInWithSocialWebUI(
provider,
callingActivity,
{ continuation.resume(it) },
{ continuation.resumeWithException(it) }
)
}
): AuthSignInResult {
return suspendCoroutine { continuation ->
delegate.signInWithSocialWebUI(
provider,
callingActivity,
{ continuation.resume(it) },
{ continuation.resumeWithException(it) }
)
}
}

suspend fun signInWithSocialWebUI(
provider: AuthProvider,
callingActivity: Activity,
options: AuthWebUISignInOptions
):
AuthSignInResult {
return suspendCoroutine { continuation ->
delegate.signInWithSocialWebUI(
provider,
callingActivity,
options,
{ continuation.resume(it) },
{ continuation.resumeWithException(it) }
)
}
): AuthSignInResult {
return suspendCoroutine { continuation ->
delegate.signInWithSocialWebUI(
provider,
callingActivity,
options,
{ continuation.resume(it) },
{ continuation.resumeWithException(it) }
)
}
}

suspend fun signInWithWebUI(
callingActivity: Activity
Expand Down
Expand Up @@ -519,8 +519,8 @@ internal class RealAWSCognitoAuthPlugin(
}
}
}
authNState is AuthenticationState.SignedIn
&& authZState is AuthorizationState.SessionEstablished -> {
authNState is AuthenticationState.SignedIn &&
authZState is AuthorizationState.SessionEstablished -> {
authStateMachine.cancel(token)
val authSignInResult = AuthSignInResult(
true,
Expand Down Expand Up @@ -594,8 +594,8 @@ internal class RealAWSCognitoAuthPlugin(
val signInState = (authNState as? AuthenticationState.SigningIn)?.signInState
val challengeState = (signInState as? SignInState.ResolvingChallenge)?.challengeState
when {
authNState is AuthenticationState.SignedIn
&& authZState is AuthorizationState.SessionEstablished -> {
authNState is AuthenticationState.SignedIn &&
authZState is AuthorizationState.SessionEstablished -> {
authStateMachine.cancel(token)
val authSignInResult = AuthSignInResult(
true,
Expand Down Expand Up @@ -740,8 +740,8 @@ internal class RealAWSCognitoAuthPlugin(
authStateMachine.send(AuthenticationEvent(AuthenticationEvent.EventType.CancelSignIn()))
}
}
authNState is AuthenticationState.SignedIn
&& authZState is AuthorizationState.SessionEstablished -> {
authNState is AuthenticationState.SignedIn &&
authZState is AuthorizationState.SessionEstablished -> {
authStateMachine.cancel(token)
val authSignInResult =
AuthSignInResult(
Expand Down Expand Up @@ -1798,8 +1798,8 @@ internal class RealAWSCognitoAuthPlugin(
val authNState = authState.authNState
val authZState = authState.authZState
when {
authNState is AuthenticationState.FederatedToIdentityPool
&& authZState is AuthorizationState.SessionEstablished -> {
authNState is AuthenticationState.FederatedToIdentityPool &&
authZState is AuthorizationState.SessionEstablished -> {
authStateMachine.cancel(token)
val credential = authZState.amplifyCredential as? AmplifyCredential.IdentityPoolFederated
val identityId = credential?.identityId
Expand Down Expand Up @@ -1853,12 +1853,11 @@ internal class RealAWSCognitoAuthPlugin(
(
authNState is AuthenticationState.FederatedToIdentityPool &&
authZState is AuthorizationState.SessionEstablished
) ||
(
authZState is AuthorizationState.Error &&
authZState.exception is SessionError &&
authZState.exception.amplifyCredential is AmplifyCredential.IdentityPoolFederated
) -> {
) || (
authZState is AuthorizationState.Error &&
authZState.exception is SessionError &&
authZState.exception.amplifyCredential is AmplifyCredential.IdentityPoolFederated
) -> {
val event = AuthenticationEvent(AuthenticationEvent.EventType.ClearFederationToIdentityPool())
authStateMachine.send(event)
_clearFederationToIdentityPool(onSuccess, onError)
Expand Down
Expand Up @@ -27,7 +27,6 @@ import java.net.HttpURLConnection
import java.net.URL
import java.net.URLEncoder
import javax.net.ssl.HttpsURLConnection
import kotlin.jvm.Throws
import kotlin.time.Duration.Companion.seconds
import kotlinx.serialization.SerialName
import kotlinx.serialization.Serializable
Expand All @@ -39,39 +38,42 @@ internal object HostedUIHttpHelper {
private val json = Json { ignoreUnknownKeys = true }

@Throws(Exception::class)
fun fetchTokens(url: URL, headerParams: Map<String, String>, bodyParams: Map<String, String>):
CognitoUserPoolTokens {
val connection = (url.openConnection() as HttpsURLConnection).apply {
requestMethod = "POST"
doOutput = true
// add headers
headerParams.map { addRequestProperty(it.key, it.value) }
// add body
DataOutputStream(outputStream).use { dos ->
val requestBody = bodyParams.map {
"${URLEncoder.encode(it.key, "UTF-8")}=${URLEncoder.encode(it.value, "UTF-8")}"
}.joinToString("&")
dos.writeBytes(requestBody)
}
fun fetchTokens(
url: URL,
headerParams: Map<String, String>,
bodyParams: Map<String, String>
): CognitoUserPoolTokens {
val connection = (url.openConnection() as HttpsURLConnection).apply {
requestMethod = "POST"
doOutput = true
// add headers
headerParams.map { addRequestProperty(it.key, it.value) }
// add body
DataOutputStream(outputStream).use { dos ->
val requestBody = bodyParams.map {
"${URLEncoder.encode(it.key, "UTF-8")}=${URLEncoder.encode(it.value, "UTF-8")}"
}.joinToString("&")
dos.writeBytes(requestBody)
}
}

val responseCode = connection.responseCode
val responseCode = connection.responseCode

if (responseCode >= HttpURLConnection.HTTP_OK && responseCode < HttpURLConnection.HTTP_INTERNAL_ERROR) {
val responseStream = if (responseCode < HttpURLConnection.HTTP_MULT_CHOICE) {
connection.inputStream
} else {
connection.errorStream
}
val responseString = responseStream.bufferedReader().use(BufferedReader::readText)
return parseTokenResponse(responseString)
if (responseCode >= HttpURLConnection.HTTP_OK && responseCode < HttpURLConnection.HTTP_INTERNAL_ERROR) {
val responseStream = if (responseCode < HttpURLConnection.HTTP_MULT_CHOICE) {
connection.inputStream
} else {
throw ServiceException(
message = connection.responseMessage,
recoverySuggestion = AmplifyException.TODO_RECOVERY_SUGGESTION
)
connection.errorStream
}
val responseString = responseStream.bufferedReader().use(BufferedReader::readText)
return parseTokenResponse(responseString)
} else {
throw ServiceException(
message = connection.responseMessage,
recoverySuggestion = AmplifyException.TODO_RECOVERY_SUGGESTION
)
}
}

private fun parseTokenResponse(responseString: String): CognitoUserPoolTokens {

Expand Down
Expand Up @@ -77,8 +77,8 @@ internal object SignInChallengeHelper {
}
}
challengeNameType is ChallengeNameType.SmsMfa ||
challengeNameType is ChallengeNameType.CustomChallenge
|| challengeNameType is ChallengeNameType.NewPasswordRequired -> {
challengeNameType is ChallengeNameType.CustomChallenge ||
challengeNameType is ChallengeNameType.NewPasswordRequired -> {
val challenge =
AuthChallenge(challengeNameType.value, username, session, challengeParameters)
SignInEvent(SignInEvent.EventType.ReceivedChallenge(challenge))
Expand Down
Expand Up @@ -86,20 +86,19 @@ object SignUpTestCaseGenerator : SerializableProvider {
ExpectationShapes.Amplify(
apiName = AuthAPI.signUp,
responseType = ResponseType.Success,
response =
AuthSignUpResult(
false,
AuthNextSignUpStep(
AuthSignUpStep.CONFIRM_SIGN_UP_STEP,
emptyMap(),
AuthCodeDeliveryDetails(
email,
AuthCodeDeliveryDetails.DeliveryMedium.EMAIL,
"attributeName"
)
),
null
).toJsonElement()
response = AuthSignUpResult(
false,
AuthNextSignUpStep(
AuthSignUpStep.CONFIRM_SIGN_UP_STEP,
emptyMap(),
AuthCodeDeliveryDetails(
email,
AuthCodeDeliveryDetails.DeliveryMedium.EMAIL,
"attributeName"
)
),
null
).toJsonElement()
)
)
)
Expand Down Expand Up @@ -131,15 +130,15 @@ object SignUpTestCaseGenerator : SerializableProvider {
apiName = AuthAPI.signUp,
responseType = ResponseType.Success,
response =
AuthSignUpResult(
true,
AuthNextSignUpStep(
AuthSignUpStep.DONE,
emptyMap(),
null
),
AuthSignUpResult(
true,
AuthNextSignUpStep(
AuthSignUpStep.DONE,
emptyMap(),
null
).toJsonElement()
),
null
).toJsonElement()
)
)
)
Expand Down
Expand Up @@ -28,12 +28,11 @@ class AWSS3StoragePluginConfiguration private constructor(builder: Builder) {
.build()
}

fun getAWSS3PluginPrefixResolver(authCredentialsProvider: AuthCredentialsProvider):
AWSS3PluginPrefixResolver {
return awsS3PluginPrefixResolver ?: StorageAccessLevelAwarePrefixResolver(
authCredentialsProvider
)
}
fun getAWSS3PluginPrefixResolver(authCredentialsProvider: AuthCredentialsProvider): AWSS3PluginPrefixResolver {
return awsS3PluginPrefixResolver ?: StorageAccessLevelAwarePrefixResolver(
authCredentialsProvider
)
}

class Builder {
var awsS3PluginPrefixResolver: AWSS3PluginPrefixResolver? = null
Expand Down
8 changes: 5 additions & 3 deletions build.gradle
Expand Up @@ -23,10 +23,10 @@ buildscript {
}

dependencies {
classpath 'com.android.tools.build:gradle:4.0.2'
classpath 'com.android.tools.build:gradle:7.3.1'
classpath 'org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10'
classpath "org.jetbrains.dokka:dokka-gradle-plugin:1.7.10"
classpath 'org.jlleitschuh.gradle:ktlint-gradle:9.4.1'
classpath 'org.jlleitschuh.gradle:ktlint-gradle:11.0.0'
classpath "org.gradle:test-retry-gradle-plugin:1.4.1"
}
}
Expand Down Expand Up @@ -66,7 +66,7 @@ task clean(type: Delete) {

ext {
buildToolsVersion = "30.0.2"
compileSdkVersion = 30
compileSdkVersion = 31
minSdkVersion = 24
targetSdkVersion = 30
awsKotlinSdkVersion = '0.17.12-beta'
Expand Down Expand Up @@ -224,6 +224,8 @@ private void configureAndroidLibrary(Project project) {
includeAndroidResources = true
}
}

buildConfigField "String", "VERSION_NAME", "\"${project.ext.VERSION_NAME}\""
}

lintOptions {
Expand Down