Skip to content

Commit

Permalink
Merge pull request #59 from Liftric/fix/ktor-2-not-supporting-ios-12
Browse files Browse the repository at this point in the history
Fix: Ktor 2 not supporting iOS 12
  • Loading branch information
tknoelle authored Sep 7, 2022
2 parents 485f342 + 54c0c55 commit 7c4b7b7
Show file tree
Hide file tree
Showing 9 changed files with 41 additions and 5 deletions.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ DerivedData/
!*.xcodeproj/xcshareddata/
!*.xcworkspace/contents.xcworkspacedata
**/xcshareddata/WorkspaceSettings.xcsettings
kotlin-js-store/
6 changes: 3 additions & 3 deletions settings.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ dependencyResolutionManagement {
create("libs") {
version("android-tools-gradle", "7.2.0")
version("kotlin", "1.7.10")
version("ktor", "2.0.3")
version("ktor", "2.1.1")

library("ktor-client-core", "io.ktor", "ktor-client-core").versionRef("ktor")
library("ktor-client-android", "io.ktor", "ktor-client-android").versionRef("ktor")
library("ktor-client-darwin", "io.ktor", "ktor-client-darwin").versionRef("ktor")
library("ktor-client-jvm", "io.ktor", "ktor-client-cio").versionRef("ktor")
library("ktor-client-jvm", "io.ktor", "ktor-client-java").versionRef("ktor")
library("ktor-client-js", "io.ktor", "ktor-client-js").versionRef("ktor")
library("kotlinx-coroutines", "org.jetbrains.kotlinx", "kotlinx-coroutines-core").version("1.6.1")
library("kotlinx-serialization", "org.jetbrains.kotlinx", "kotlinx-serialization-json").version("1.3.3")
Expand All @@ -38,4 +38,4 @@ dependencyResolutionManagement {
plugin("kotlin.serialization", "org.jetbrains.kotlin.plugin.serialization").versionRef("kotlin")
}
}
}
}
6 changes: 6 additions & 0 deletions src/androidMain/kotlin/com/liftric/cognito/idp/core/Engine.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.liftric.cognito.idp.core

import io.ktor.client.engine.HttpClientEngine
import io.ktor.client.engine.android.Android

internal actual val Engine: HttpClientEngine = Android.create()
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package com.liftric.cognito.idp
import com.liftric.cognito.idp.core.*
import io.ktor.client.*
import io.ktor.client.call.*
import io.ktor.client.engine.*
import io.ktor.client.plugins.*
import io.ktor.client.request.*
import io.ktor.client.statement.*
Expand All @@ -18,14 +19,14 @@ import kotlinx.serialization.json.Json
* AWS Cognito Identity Provider client.
* Provides common request methods.
*/
open class IdentityProviderClient(region: String, clientId: String) : IdentityProvider {
open class IdentityProviderClient(region: String, clientId: String, engine: HttpClientEngine? = null) : IdentityProvider {
private val json = Json {
allowStructuredMapKeys = true
ignoreUnknownKeys = true
explicitNulls = false
}
private val configuration = Configuration(region, clientId)
private val client = HttpClient {
private val client = HttpClient(engine ?: Engine) {
expectSuccess = true
/**
* When referencing members that are in the
Expand All @@ -41,6 +42,8 @@ open class IdentityProviderClient(region: String, clientId: String) : IdentityPr
}
}

constructor(region: String, clientId: String) : this(region, clientId, null)

override suspend fun signUp(
username: String,
password: String,
Expand Down
5 changes: 5 additions & 0 deletions src/commonMain/kotlin/com/liftric/cognito/idp/core/Engine.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package com.liftric.cognito.idp.core

import io.ktor.client.engine.HttpClientEngine

internal expect val Engine: HttpClientEngine
7 changes: 7 additions & 0 deletions src/iosMain/kotlin/com/liftric/cognito/idp/core/Engine.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.liftric.cognito.idp.core

import io.ktor.client.engine.HttpClientEngine
import io.ktor.client.engine.darwin.Darwin

internal actual val Engine: HttpClientEngine = Darwin.create()

1 change: 1 addition & 0 deletions src/jsMain/kotlin/IdentityProviderJS.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

import com.liftric.cognito.idp.IdentityProviderClient
import com.liftric.cognito.idp.core.*
import io.ktor.client.engine.js.*
import kotlinx.coroutines.MainScope
import kotlinx.coroutines.promise
import kotlin.js.Promise
Expand Down
7 changes: 7 additions & 0 deletions src/jsMain/kotlin/com/liftric/cognito/idp/core/Engine.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package com.liftric.cognito.idp.core

import io.ktor.client.engine.HttpClientEngine
import io.ktor.client.engine.js.Js

internal actual val Engine: HttpClientEngine = Js.create()

6 changes: 6 additions & 0 deletions src/jvmMain/kotlin/com/liftric/cognito/idp/core/Engine.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
package com.liftric.cognito.idp.core

import io.ktor.client.engine.HttpClientEngine
import io.ktor.client.engine.java.Java

internal actual val Engine: HttpClientEngine = Java.create()

0 comments on commit 7c4b7b7

Please sign in to comment.