Skip to content

Commit

Permalink
refactor: Added dynamic types to the js functions and changed the dep…
Browse files Browse the repository at this point in the history
…endency of mock engine
  • Loading branch information
Zoe Maas committed Oct 8, 2024
1 parent 1c90e8d commit 6bfd979
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 87 deletions.
80 changes: 2 additions & 78 deletions modules/openid-federation-client/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@ import org.jetbrains.kotlin.gradle.targets.js.webpack.KotlinWebpackConfig

plugins {
alias(libs.plugins.kotlinMultiplatform)
// alias(libs.plugins.androidLibrary)
kotlin("plugin.serialization") version "2.0.0"
}

val ktorVersion = "3.0.0-beta-2"
val ktorVersion = "2.3.12"

repositories {
mavenCentral()
Expand Down Expand Up @@ -34,19 +33,6 @@ kotlin {
}
}

// wasmJs is not available yet for ktor until v3.x is released which is still in alpha

// androidTarget {
// @OptIn(ExperimentalKotlinGradlePluginApi::class)
// compilerOptions {
// jvmTarget.set(JvmTarget.JVM_11)
// }
// }

// iosX64()
// iosArm64()
// iosSimulatorArm64()

sourceSets {

all {
Expand Down Expand Up @@ -91,50 +77,6 @@ kotlin {
implementation("com.nimbusds:nimbus-jose-jwt:9.40")
}
}
// TODO Should be placed back at a later point in time: https://sphereon.atlassian.net/browse/OIDF-50
// val androidMain by getting {
// dependencies {
// implementation("io.ktor:ktor-client-core-jvm:$ktorVersion")
// implementation("io.ktor:ktor-client-cio-jvm:$ktorVersion")
// }
// }
// val androidUnitTest by getting {
// dependencies {
// implementation(kotlin("test-junit"))
// }
// }

// val iosMain by creating {
// dependsOn(commonMain)
// }
// val iosX64Main by getting {
// dependsOn(iosMain)
// dependencies {
// implementation("io.ktor:ktor-client-core-iosx64:$ktorVersion")
// implementation("io.ktor:ktor-client-cio-iosx64:$ktorVersion")
// }
// }
// val iosArm64Main by getting {
// dependsOn(iosMain)
// dependencies {
// implementation("io.ktor:ktor-client-core-iosarm64:$ktorVersion")
// implementation("io.ktor:ktor-client-cio-iosarm64:$ktorVersion")
// }
// }
// val iosSimulatorArm64Main by getting {
// dependsOn(iosMain)
// dependencies {
// implementation("io.ktor:ktor-client-core-iossimulatorarm64:$ktorVersion")
// implementation("io.ktor:ktor-client-cio-iossimulatorarm64:$ktorVersion")
// }
// }
//
// val iosTest by creating {
// dependsOn(commonTest)
// dependencies {
// implementation(kotlin("test"))
// }
// }

val jsMain by getting {
dependencies {
Expand All @@ -152,27 +94,9 @@ kotlin {
implementation(kotlin("test-js"))
implementation(npm("jose", "5.6.3"))
implementation(kotlin("test-annotations-common"))
implementation("io.ktor:ktor-client-mock-js:$ktorVersion")
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.9.0-RC")
}
}
}
}

//tasks.register("printSdkLocation") {
// doLast {
// println("Android SDK Location: ${android.sdkDirectory}")
// }
//}
//
//android {
// namespace = "com.sphereon.oid.fed.common"
// compileSdk = libs.versions.android.compileSdk.get().toInt()
// compileOptions {
// sourceCompatibility = JavaVersion.VERSION_11
// targetCompatibility = JavaVersion.VERSION_11
// }
// defaultConfig {
// minSdk = libs.versions.android.minSdk.get().toInt()
// }
//}

Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package com.sphereon.oid.fed.client.validation

import com.sphereon.oid.fed.common.jwt.JwtService
import com.sphereon.oid.fed.openapi.models.EntityConfigurationStatement
import io.ktor.client.engine.*
import kotlinx.coroutines.CoroutineName
import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.promise
Expand All @@ -16,10 +14,10 @@ class TrustChainValidation(val jwtService: JwtService) {

fun readAuthorityHints(
partyBId: String,
engine: HttpClientEngine,
trustChains: MutableList<List<EntityConfigurationStatement>> = mutableListOf(),
trustChain: MutableSet<EntityConfigurationStatement> = mutableSetOf()
): Promise<List<List<EntityConfigurationStatement>>> = CoroutineScope(context = CoroutineName(NAME)).promise {
engine: dynamic,
trustChains: dynamic,
trustChain: dynamic
): Promise<dynamic> = CoroutineScope(context = CoroutineName(NAME)).promise {
TrustChainValidationCommon(jwtService)
.readAuthorityHints(
partyBId = partyBId,
Expand All @@ -30,8 +28,8 @@ class TrustChainValidation(val jwtService: JwtService) {
}

fun fetchSubordinateStatements(
entityConfigurationStatementsList: List<List<EntityConfigurationStatement>>,
engine: HttpClientEngine
entityConfigurationStatementsList: dynamic,
engine: dynamic
): Promise<List<List<String>>> = CoroutineScope(context = CoroutineName(NAME)).promise {
TrustChainValidationCommon(jwtService)
.fetchSubordinateStatements(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,7 +443,9 @@ class TrustChainValidationTest {
listOfEntityConfigurationStatementList,
TrustChainValidation(jwtServiceImpl).readAuthorityHints(
partyBId = "https://edugain.org/federation",
engine = mockEngine
engine = mockEngine,
trustChains = mutableListOf(mutableListOf<EntityConfigurationStatement>()),
trustChain = mutableListOf<EntityConfigurationStatement>(),
).await()
)
}
Expand Down

0 comments on commit 6bfd979

Please sign in to comment.