From 6c617fcea259c0bd5eae39c2beb7ee403971e957 Mon Sep 17 00:00:00 2001 From: waltkb <68587968+waltkb@users.noreply.github.com> Date: Mon, 17 Feb 2025 23:04:56 +0100 Subject: [PATCH] Update dependencies, fix build issues --- .run/Verifier.run.xml | 26 ++-- build.gradle.kts | 2 +- gradle/wrapper/gradle-wrapper.properties | 2 +- gradlew | 3 +- .../waltid-android/build.gradle.kts | 7 +- .../waltid-cli/build.gradle.kts | 20 +-- .../cli/commands/WaltIdVCVerifyCmdTest.kt | 6 +- .../shared/build.gradle.kts | 4 +- .../auth/waltid-idpkit/build.gradle.kts | 12 +- .../src/main/kotlin/id/walt/idp/poc/App.kt | 29 +--- .../auth/waltid-ktor-authnz/build.gradle.kts | 16 +- .../docs/new-auth-method.md | 8 +- .../auth/KtorAuthnzAuthenticationHelpers.kt | 20 +-- .../methods/AuthenticationMethod.kt | 16 +- .../id/walt/ktorauthnz/methods/EmailPass.kt | 11 +- .../kotlin/id/walt/ktorauthnz/methods/JWT.kt | 9 +- .../id/walt/ktorauthnz/methods/Kerberos.kt | 6 +- .../kotlin/id/walt/ktorauthnz/methods/LDAP.kt | 9 +- .../kotlin/id/walt/ktorauthnz/methods/OIDC.kt | 13 +- .../id/walt/ktorauthnz/methods/RADIUS.kt | 10 +- .../kotlin/id/walt/ktorauthnz/methods/TOTP.kt | 7 +- .../id/walt/ktorauthnz/methods/UserPass.kt | 9 +- .../methods/VerifiableCredential.kt | 11 +- .../kotlin/id/walt/ktorauthnz/methods/Web3.kt | 9 +- .../methods/virtual/GlobalIdentify.kt | 2 +- .../methods/virtual/IdentifyEmail.kt | 4 +- .../id/walt/AuthFlowExampleApplication.kt | 6 +- .../src/test/kotlin/id/walt/ExampleWeb.kt | 40 ++--- .../kotlin/id/walt/KtorAuthnzDevMockedTest.kt | 6 +- .../src/test/kotlin/id/walt/RouteCollector.kt | 70 ++++----- .../kotlin/id/walt/web/plugins/Monitoring.kt | 2 +- .../kotlin/id/walt/web/plugins/OpenApi.kt | 2 +- .../auth/waltid-permissions/build.gradle.kts | 6 +- .../build.gradle.kts | 8 +- .../waltid-mdoc-credentials/build.gradle.kts | 13 +- .../build.gradle.kts | 16 +- .../build.gradle.kts | 20 +-- .../policies/DynamicPolicyVerificationTest.kt | 9 +- .../waltid-crypto-android/build.gradle.kts | 10 +- .../crypto/waltid-crypto-aws/build.gradle.kts | 8 +- .../crypto/waltid-crypto-ios/build.gradle.kts | 1 + .../crypto/waltid-crypto-oci/build.gradle.kts | 20 +-- .../crypto/waltid-crypto/build.gradle.kts | 30 ++-- .../kotlin/id/walt/crypto/keys/tse/TSEKey.kt | 1 - .../crypto/waltid-target-ios/build.gradle.kts | 5 +- .../waltid-openid4vc/build.gradle.kts | 24 +-- .../sdjwt/waltid-sdjwt-ios/build.gradle.kts | 1 + .../sdjwt/waltid-sdjwt/build.gradle.kts | 8 +- .../util/waltid-reporting/build.gradle.kts | 16 +- .../waltid-core-wallet/build.gradle.kts | 17 +- waltid-libraries/waltid-did/build.gradle.kts | 25 +-- .../did/dids/document/DidCheqdDocument.kt | 2 +- .../local/cheqd/DidCheqdRegistrar.kt | 20 ++- .../didstates/{action => }/ActionDidState.kt | 20 ++- .../didstates/{finished => }/DidDocument.kt | 3 +- .../cheqd/models/job/didstates/DidState.kt | 7 +- .../didstates/{failed => }/FailedDidState.kt | 3 +- .../{finished => }/FinishedDidState.kt | 4 +- .../models/job/didstates/action/Secret.kt | 12 -- .../job/didstates/action/SigningRequest.kt | 15 -- .../dids/resolver/local/DidCheqdResolver.kt | 2 +- .../kotlin/LocalDidWebConsistencyTest.kt | 17 +- .../src/jvmTest/kotlin/TestServer.kt | 13 +- .../registrars/DidCheqdRegistrarTest.kt | 3 + .../jvmTest/resources/simplelogger.properties | 4 + .../waltid-java-compat/build.gradle.kts | 1 + .../waltid-library-commons/build.gradle.kts | 2 +- .../waltid-e2e-tests/build.gradle.kts | 15 +- .../waltid-issuer-api/build.gradle.kts | 12 +- .../id/walt/issuer/NewTestOidcMetadata.kt | 2 +- .../id/walt/issuer/entra/EntraIssuanceApi.kt | 4 +- .../id/walt/issuer/issuance/IssuerApi.kt | 145 +++++++----------- .../kotlin/id/walt/issuer/issuance/OidcApi.kt | 2 +- .../id/walt/issuer/issuance2/NewApiStub.kt | 2 +- .../LspPotentialIssuanceInterop.kt | 4 +- .../id/walt/issuer/web/plugins/Monitoring.kt | 3 +- .../build.gradle.kts | 6 +- .../waltid-service-commons/build.gradle.kts | 24 +-- .../logging/setups/TraceLoggingSetup.kt | 2 +- .../modules/FeatureFlagInformationModule.kt | 4 +- .../walt/commons/web/modules/OpenApiModule.kt | 14 +- .../modules/ServiceHealthchecksDebugModule.kt | 6 +- .../walt/commons/web/plugins/StatusPages.kt | 2 + .../waltid-verifier-api/build.gradle.kts | 10 +- .../kotlin/id/walt/verifier/VerifierApi.kt | 118 ++++++-------- .../walt/verifier/entra/EntraVerifierApi.kt | 24 +-- .../LspPotentialVerificationInterop.kt | 4 +- .../walt/verifier/web/plugins/Monitoring.kt | 2 +- .../waltid-wallet-api/build.gradle.kts | 30 ++-- .../id/walt/webwallet/FeatureCatalog.kt | 3 +- .../main/kotlin/id/walt/webwallet/db/Db.kt | 2 +- .../id/walt/webwallet/db/KotlinxUUIDTable.kt | 11 +- .../webwallet/db/models/WalletCredentials.kt | 9 +- .../db/models/WallletNotifications.kt | 1 - .../webwallet/service/SSIKit2WalletService.kt | 1 - .../webwallet/service/WalletServiceManager.kt | 11 +- .../account/authnz/AuthenticationService.kt | 10 +- .../service/account/x5c/X5CAccountStrategy.kt | 5 +- .../service/credentials/CredentialsService.kt | 8 +- .../walt/webwallet/service/dids/DidService.kt | 6 +- .../endpoint/EntraServiceEndpointProvider.kt | 2 +- .../webwallet/service/events/EventService.kt | 5 +- .../exchange/CredentialOfferProcessor.kt | 18 +-- .../service/exchange/IssuanceService.kt | 11 +- .../exchange/ProcessedCredentialOffer.kt | 6 +- .../exchange/ProofOfPossessionFactory.kt | 80 +++++----- .../webwallet/service/keys/KeysService.kt | 3 +- .../notifications/NotificationService.kt | 5 +- .../service/oidc4vc/TestCredentialWallet.kt | 10 +- .../webwallet/service/push/PushManager.kt | 1 - .../service/settings/SettingsService.kt | 5 +- .../webwallet/usecase/claim/ClaimCommons.kt | 28 ++-- .../claim/ExternalSignatureClaimStrategy.kt | 2 +- .../usecase/claim/SilentClaimStrategy.kt | 2 +- .../entity/EntityNameResolutionUseCase.kt | 2 +- .../usecase/issuer/IssuerUseCaseImpl.kt | 6 +- .../notification/NotificationFilterUseCase.kt | 2 +- .../web/controllers/AccountController.kt | 4 +- .../web/controllers/CategoryController.kt | 23 +-- .../web/controllers/CredentialController.kt | 42 ++--- .../web/controllers/DidController.kt | 23 +-- .../webwallet/web/controllers/DidCreation.kt | 38 ++--- .../controllers/DidWebRegistryController.kt | 6 +- .../web/controllers/EventLogController.kt | 10 +- .../web/controllers/HistoryController.kt | 7 +- .../web/controllers/IssuersController.kt | 26 ++-- .../web/controllers/KeyController.kt | 59 +++---- .../web/controllers/ManifestController.kt | 16 +- .../web/controllers/NotificationController.kt | 12 +- .../web/controllers/ReasonController.kt | 2 +- .../web/controllers/ReportsController.kt | 6 +- .../controllers/SilentExchangeController.kt | 4 +- .../web/controllers/TrustController.kt | 2 +- .../web/controllers/UtilityController.kt | 35 +++-- .../controllers/WalletSettingsController.kt | 15 +- .../web/controllers/Web3Controller.kt | 20 +-- .../web/controllers/auth/AuthController.kt | 43 +++--- .../web/controllers/auth/Controller.kt | 6 +- .../web/controllers/auth/DefaultAuthRoutes.kt | 4 +- .../controllers/auth/KtorAuthnzController.kt | 7 +- .../auth/KtorAuthnzFrontendController.kt | 8 +- .../controllers/auth/LoginControllerBase.kt | 4 +- .../controllers/auth/LogoutControllerBase.kt | 8 +- .../auth/RegisterControllerBase.kt | 6 +- .../auth/keycloak/KeycloakLogoutController.kt | 7 +- .../auth/oidc/OidcLogoutController.kt | 7 +- .../exchange/ExchangeController.kt | 47 +++--- .../ExchangeExternalSignaturesController.kt | 46 +++--- .../src/main/resources/example_klogging.conf | 24 +-- .../src/test/kotlin/E2EWalletTestBase.kt | 2 - ...ltStatusListCredentialFetchStrategyTest.kt | 16 +- .../id/walt/webwallet/utils/PKIXUtilsTest.kt | 6 +- ...n-list-with-status-message-vc-wrapped.json | 14 +- .../revocation-list-with-status-message.json | 11 +- .../build.gradle.kts | 4 +- .../src/main/kotlin/id/walt/NftController.kt | 18 +-- .../main/kotlin/id/walt/plugins/Monitoring.kt | 2 +- 157 files changed, 1008 insertions(+), 1085 deletions(-) rename waltid-libraries/waltid-did/src/commonMain/kotlin/id/walt/did/dids/registrar/local/cheqd/models/job/didstates/{action => }/ActionDidState.kt (57%) rename waltid-libraries/waltid-did/src/commonMain/kotlin/id/walt/did/dids/registrar/local/cheqd/models/job/didstates/{finished => }/DidDocument.kt (80%) rename waltid-libraries/waltid-did/src/commonMain/kotlin/id/walt/did/dids/registrar/local/cheqd/models/job/didstates/{failed => }/FailedDidState.kt (82%) rename waltid-libraries/waltid-did/src/commonMain/kotlin/id/walt/did/dids/registrar/local/cheqd/models/job/didstates/{finished => }/FinishedDidState.kt (73%) delete mode 100644 waltid-libraries/waltid-did/src/commonMain/kotlin/id/walt/did/dids/registrar/local/cheqd/models/job/didstates/action/Secret.kt delete mode 100644 waltid-libraries/waltid-did/src/commonMain/kotlin/id/walt/did/dids/registrar/local/cheqd/models/job/didstates/action/SigningRequest.kt create mode 100644 waltid-libraries/waltid-did/src/jvmTest/resources/simplelogger.properties diff --git a/.run/Verifier.run.xml b/.run/Verifier.run.xml index 9f2da2945..3fefd8587 100644 --- a/.run/Verifier.run.xml +++ b/.run/Verifier.run.xml @@ -1,14 +1,14 @@ - - - + + + \ No newline at end of file diff --git a/build.gradle.kts b/build.gradle.kts index c9977ea4d..19929cec4 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -21,7 +21,7 @@ plugins { kotlin("plugin.serialization") version kotlinVersion apply false - id("love.forte.plugin.suspend-transform") version "2.1.0-0.10.1" apply false + id("love.forte.plugin.suspend-transform") version "2.1.0-0.11.0" apply false id("com.android.library") version "8.7.3" apply false id("com.android.application") version "8.7.3" apply false diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index df97d72b8..cea7a793a 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-8.10.2-bin.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-8.12-bin.zip networkTimeout=10000 validateDistributionUrl=true zipStoreBase=GRADLE_USER_HOME diff --git a/gradlew b/gradlew index f5feea6d6..f3b75f3b0 100755 --- a/gradlew +++ b/gradlew @@ -86,8 +86,7 @@ done # shellcheck disable=SC2034 APP_BASE_NAME=${0##*/} # Discard cd standard output in case $CDPATH is set (https://github.com/gradle/gradle/issues/25036) -APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s -' "$PWD" ) || exit +APP_HOME=$( cd -P "${APP_HOME:-./}" > /dev/null && printf '%s\n' "$PWD" ) || exit # Use the maximum available, or set MAX_FD != -1 to use that value. MAX_FD=maximum diff --git a/waltid-applications/waltid-android/build.gradle.kts b/waltid-applications/waltid-android/build.gradle.kts index 6a21e75d4..39ee5b6f8 100644 --- a/waltid-applications/waltid-android/build.gradle.kts +++ b/waltid-applications/waltid-android/build.gradle.kts @@ -3,6 +3,7 @@ plugins { kotlin("android") kotlin("plugin.serialization") kotlin("plugin.compose") + id("com.github.ben-manes.versions") } android { @@ -57,7 +58,7 @@ dependencies { api(project(":waltid-libraries:sdjwt:waltid-sdjwt")) // JSON - implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3") + implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.0") // -- Android -- implementation("androidx.biometric:biometric:1.2.0-alpha05") @@ -65,7 +66,7 @@ dependencies { implementation("androidx.navigation:navigation-compose:2.7.7") implementation("androidx.core:core-ktx:1.13.1") implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.8.3") - implementation("androidx.activity:activity-compose:1.9.0") + implementation("androidx.activity:activity-compose:1.10.1") // Compose implementation(platform("androidx.compose:compose-bom:2024.02.01")) @@ -77,7 +78,7 @@ dependencies { // Testing testImplementation(kotlin("test")) - testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.9.0") + testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.10.1") testImplementation("junit:junit:4.13.2") testImplementation("androidx.test.ext:junit:1.2.1") testImplementation("androidx.test.espresso:espresso-core:3.6.1") diff --git a/waltid-applications/waltid-cli/build.gradle.kts b/waltid-applications/waltid-cli/build.gradle.kts index 693f9aed6..2316319c8 100644 --- a/waltid-applications/waltid-cli/build.gradle.kts +++ b/waltid-applications/waltid-cli/build.gradle.kts @@ -1,7 +1,7 @@ import org.jetbrains.kotlin.gradle.dsl.JvmTarget object Versions { - const val KTOR_VERSION = "2.3.12" + const val KTOR_VERSION = "3.1.0" } plugins { @@ -9,7 +9,7 @@ plugins { kotlin("plugin.serialization") id("maven-publish") id("com.github.ben-manes.versions") - id("io.ktor.plugin") version "2.3.12" // Versions.KTOR_VERSION + id("io.ktor.plugin") version "3.1.0" // Versions.KTOR_VERSION // Apply the application plugin to add support for building a CLI application in Java. application } @@ -65,8 +65,8 @@ kotlin { api(project(":waltid-libraries:sdjwt:waltid-sdjwt")) api(project(":waltid-libraries:protocols:waltid-openid4vc")) - implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3") - implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.6.1") + implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.0") + implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.6.2") implementation("com.google.code.gson:gson:2.11.0") // CLI @@ -74,16 +74,16 @@ kotlin { implementation("com.github.ajalt.clikt:clikt:4.4.0") // Coroutines - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.1") // Logging - implementation("io.github.oshai:kotlin-logging:7.0.0") + implementation("io.github.oshai:kotlin-logging:7.0.4") } } val commonTest by getting { dependencies { implementation(kotlin("test")) - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.9.0") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.10.1") } } val jvmMain by getting { @@ -95,15 +95,15 @@ kotlin { implementation("com.nimbusds:nimbus-jose-jwt:9.41.1") // BouncyCastle for PEM import - implementation("org.bouncycastle:bcpkix-lts8on:2.73.6") + implementation("org.bouncycastle:bcpkix-lts8on:2.73.7") } } val jvmTest by getting { dependencies { - implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3") + implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.0") implementation("com.wolpl.clikt-testkit:clikt-testkit:2.0.0") - implementation("org.junit.jupiter:junit-jupiter-params:5.11.0") + implementation("org.junit.jupiter:junit-jupiter-params:5.11.4") // Ktor server implementation("io.ktor:ktor-server-core-jvm:${Versions.KTOR_VERSION}") diff --git a/waltid-applications/waltid-cli/src/jvmTest/kotlin/id/walt/cli/commands/WaltIdVCVerifyCmdTest.kt b/waltid-applications/waltid-cli/src/jvmTest/kotlin/id/walt/cli/commands/WaltIdVCVerifyCmdTest.kt index 0a8d08293..79993b10d 100644 --- a/waltid-applications/waltid-cli/src/jvmTest/kotlin/id/walt/cli/commands/WaltIdVCVerifyCmdTest.kt +++ b/waltid-applications/waltid-cli/src/jvmTest/kotlin/id/walt/cli/commands/WaltIdVCVerifyCmdTest.kt @@ -56,7 +56,7 @@ class WaltIdVCVerifyCmdTest { val schemaFilePath = "${resourcesPath}/schema/OpenBadgeV3_schema.json" - private val webhookTestServer: NettyApplicationEngine + private val webhookTestServer: EmbeddedServer private val webhookTestServerURL: String private val webhookTestServerSuccessURL: String private val webhookTestServerFailURL: String @@ -78,8 +78,8 @@ class WaltIdVCVerifyCmdTest { } }.start(false) runBlocking { - url = "http://" + webhookTestServer.resolvedConnectors() - .first().host + ":${webhookTestServer.resolvedConnectors().first().port}" + url = "http://" + webhookTestServer.engine.resolvedConnectors() + .first().host + ":${webhookTestServer.engine.resolvedConnectors().first().port}" } webhookTestServerURL = url webhookTestServerSuccessURL = "$webhookTestServerURL/success" diff --git a/waltid-applications/waltid-openid4vc-ios-testApp/shared/build.gradle.kts b/waltid-applications/waltid-openid4vc-ios-testApp/shared/build.gradle.kts index 74d95af4d..6fba93497 100644 --- a/waltid-applications/waltid-openid4vc-ios-testApp/shared/build.gradle.kts +++ b/waltid-applications/waltid-openid4vc-ios-testApp/shared/build.gradle.kts @@ -24,7 +24,7 @@ kotlin { } sourceSets { - val ktor_version = "2.3.12" + val ktor_version = "3.1.0" commonMain.dependencies { implementation(project(":waltid-libraries:sdjwt:waltid-sdjwt")) @@ -53,7 +53,7 @@ kotlin { iosSimulatorArm64Main.dependsOn(this) dependencies { implementation(project(":waltid-libraries:crypto:waltid-crypto-ios")) - implementation("io.ktor:ktor-client-darwin:2.3.12") + implementation("io.ktor:ktor-client-darwin:3.1.0") } } } diff --git a/waltid-libraries/auth/waltid-idpkit/build.gradle.kts b/waltid-libraries/auth/waltid-idpkit/build.gradle.kts index 305443d29..5c3705d1c 100644 --- a/waltid-libraries/auth/waltid-idpkit/build.gradle.kts +++ b/waltid-libraries/auth/waltid-idpkit/build.gradle.kts @@ -1,6 +1,6 @@ plugins { kotlin("jvm") - id("io.ktor.plugin") version "2.3.12" + id("io.ktor.plugin") version "3.1.0" kotlin("plugin.serialization") id("maven-publish") @@ -38,8 +38,8 @@ dependencies { implementation("io.ktor:ktor-client-content-negotiation") // JSON - implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3") - implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.6.1") + implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.0") + implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.6.2") implementation("com.eygraber:jsonpathkt-kotlinx:3.0.2") // OIDC @@ -47,14 +47,14 @@ dependencies { implementation("com.nimbusds:nimbus-jose-jwt:9.41.1") // for Ed25519 - implementation("com.google.crypto.tink:tink:1.15.0") { + implementation("com.google.crypto.tink:tink:1.16.0") { exclude("org.slf4j.simple") } // Logging - implementation("io.klogging:klogging-jvm:0.7.2") - implementation("io.klogging:slf4j-klogging:0.7.2") + implementation("io.klogging:klogging-jvm:0.9.1") + implementation("io.klogging:slf4j-klogging:0.9.1") testImplementation("io.ktor:ktor-server-test-host-jvm") testImplementation("org.jetbrains.kotlin:kotlin-test-junit") diff --git a/waltid-libraries/auth/waltid-idpkit/src/main/kotlin/id/walt/idp/poc/App.kt b/waltid-libraries/auth/waltid-idpkit/src/main/kotlin/id/walt/idp/poc/App.kt index 0ff4a2c46..3d926cb65 100644 --- a/waltid-libraries/auth/waltid-idpkit/src/main/kotlin/id/walt/idp/poc/App.kt +++ b/waltid-libraries/auth/waltid-idpkit/src/main/kotlin/id/walt/idp/poc/App.kt @@ -24,7 +24,7 @@ import io.ktor.serialization.kotlinx.json.* import io.ktor.server.application.* import io.ktor.server.cio.* import io.ktor.server.engine.* -import io.ktor.server.plugins.callloging.* +import io.ktor.server.plugins.calllogging.CallLogging import io.ktor.server.plugins.contentnegotiation.* import io.ktor.server.plugins.doublereceive.* import io.ktor.server.plugins.statuspages.* @@ -107,31 +107,6 @@ fun main() { } } - fun toLogString(subject: Any): String = when (subject) { - is TextContent -> subject.text - is OutputStreamContent -> { - val channel = ByteChannel(true) - runBlocking { - subject.writeTo(channel) - StringBuilder().apply { - while (!channel.isClosedForRead) channel.readUTF8LineTo(this) - }.toString() - } - } - - else -> "???" - } - - suspend fun PipelineContext.logResponseBody(call: ApplicationCall) { - call.response.pipeline.intercept(ApplicationSendPipeline.Engine) { message -> - this@embeddedServer.log.debug("Response Body (${call.request.uri}): ${toLogString(message)}") - } - } - - intercept(ApplicationCallPipeline.Call) { - logResponseBody(call) - } - install(StatusPages) { exception { call, cause -> cause.printStackTrace() @@ -175,7 +150,7 @@ fun Application.test() { routing { get("/jwks") { - context.respond(mapOf( + call.respond(mapOf( "keys" to listOf(key).map { it.toPublicJWK().toJSONObject() } )) } diff --git a/waltid-libraries/auth/waltid-ktor-authnz/build.gradle.kts b/waltid-libraries/auth/waltid-ktor-authnz/build.gradle.kts index 8e5bd3ad7..78cd07b9a 100644 --- a/waltid-libraries/auth/waltid-ktor-authnz/build.gradle.kts +++ b/waltid-libraries/auth/waltid-ktor-authnz/build.gradle.kts @@ -4,7 +4,7 @@ plugins { kotlin("jvm") kotlin("plugin.power-assert") kotlin("plugin.serialization") - id("io.ktor.plugin") version "2.3.12" + id("io.ktor.plugin") version "3.1.0" id("maven-publish") application @@ -85,24 +85,24 @@ dependencies { implementation("io.ktor:ktor-serialization-kotlinx-json-jvm") // Ktor server external - implementation("io.github.smiley4:ktor-swagger-ui:3.5.1") + implementation("io.github.smiley4:ktor-swagger-ui:4.1.6") // JSON - implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3") - implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.6.1") + implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.0") + implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.6.2") implementation("com.eygraber:jsonpathkt-kotlinx:3.0.2") // Logging - implementation("io.klogging:klogging-jvm:0.7.2") - implementation("io.klogging:slf4j-klogging:0.7.2") + implementation("io.klogging:klogging-jvm:0.9.1") + implementation("io.klogging:slf4j-klogging:0.9.1") /* --- Testing --- */ testImplementation("io.ktor:ktor-client-logging") - testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.9.0") + testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.10.1") // Ktor testImplementation("io.ktor:ktor-server-cio-jvm") - testImplementation("io.ktor:ktor-server-tests-jvm") + testImplementation("io.ktor:ktor-server-test-host") // Kotlin testImplementation("org.jetbrains.kotlin:kotlin-test-junit") diff --git a/waltid-libraries/auth/waltid-ktor-authnz/docs/new-auth-method.md b/waltid-libraries/auth/waltid-ktor-authnz/docs/new-auth-method.md index 42922e9a7..b2375d849 100644 --- a/waltid-libraries/auth/waltid-ktor-authnz/docs/new-auth-method.md +++ b/waltid-libraries/auth/waltid-ktor-authnz/docs/new-auth-method.md @@ -126,10 +126,10 @@ object MultiStepExample : AuthenticationMethod("multistep-example") { val publicKey: String ) - override fun Route.register(authContext: PipelineContext.() -> AuthContext) { + override fun Route.register(authContext: ApplicationCall.() -> AuthContext) { route("multistep-example") { get("nonce") { // Step 1 - context.respond(makeNonce()) + call.respond(makeNonce()) } post("signed", { // Step 2 @@ -191,7 +191,7 @@ fun Route.globalMultistepExample() { """.trimIndent() val authFlow = AuthFlow.fromConfig(flowConfig) - val contextFunction: PipelineContext.() -> AuthContext = { + val contextFunction: ApplicationCall.() -> AuthContext = { AuthContext( tenant = call.request.host(), sessionId = call.parameters["sessionId"], @@ -225,7 +225,7 @@ fun Application.testApp() { post("register-by-identifier") { identifier -> val newAccountId = Uuid.random().toString() KtorAuthnzManager.accountStore.addAccountIdentifierToAccount(newAccountId, identifier) - context.respond(newAccountId) + call.respond(newAccountId) } } diff --git a/waltid-libraries/auth/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/auth/KtorAuthnzAuthenticationHelpers.kt b/waltid-libraries/auth/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/auth/KtorAuthnzAuthenticationHelpers.kt index acbac43d3..230f43610 100644 --- a/waltid-libraries/auth/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/auth/KtorAuthnzAuthenticationHelpers.kt +++ b/waltid-libraries/auth/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/auth/KtorAuthnzAuthenticationHelpers.kt @@ -4,25 +4,21 @@ import id.walt.ktorauthnz.KtorAuthnzManager import id.walt.ktorauthnz.sessions.AuthSession import io.ktor.server.application.* import io.ktor.server.auth.* +import io.ktor.server.routing.RoutingContext import io.ktor.util.pipeline.* -fun PipelineContext.getAuthToken(): String { - val token = call.principal()?.name +fun ApplicationCall.getAuthToken(): String { + val token = principal()?.name check(token != null) { "No token for request principal" } return token } // TODO: switch to @OptIn instead of @Deprecated -@Deprecated("Externally provided JWT token cannot resolve to authenticated session") -suspend fun PipelineContext.getAuthenticatedSession(): AuthSession { - val token = getAuthToken() - - return KtorAuthnzManager.tokenHandler.resolveTokenToSession(token) -} -suspend fun PipelineContext.getAuthenticatedAccount(): String { - val token = getAuthToken() +@Deprecated("Externally provided JWT token cannot resolve to authenticated session") +suspend fun RoutingContext.getAuthenticatedSession(): AuthSession = KtorAuthnzManager.tokenHandler.resolveTokenToSession(call.getAuthToken()) +@Deprecated("Externally provided JWT token cannot resolve to authenticated session") +suspend fun PipelineContext.getAuthenticatedSession(): AuthSession = KtorAuthnzManager.tokenHandler.resolveTokenToSession(call.getAuthToken()) - return KtorAuthnzManager.tokenHandler.getTokenAccountId(token) -} +suspend fun ApplicationCall.getAuthenticatedAccount(): String = KtorAuthnzManager.tokenHandler.getTokenAccountId(getAuthToken()) diff --git a/waltid-libraries/auth/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/methods/AuthenticationMethod.kt b/waltid-libraries/auth/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/methods/AuthenticationMethod.kt index 8a51db578..7b2e42db7 100644 --- a/waltid-libraries/auth/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/methods/AuthenticationMethod.kt +++ b/waltid-libraries/auth/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/methods/AuthenticationMethod.kt @@ -13,7 +13,6 @@ import id.walt.ktorauthnz.sessions.SessionTokenCookieHandler import io.ktor.server.application.* import io.ktor.server.response.* import io.ktor.server.routing.* -import io.ktor.util.pipeline.* import kotlinx.serialization.EncodeDefault import kotlinx.serialization.ExperimentalSerializationApi import kotlinx.serialization.Serializable @@ -37,7 +36,7 @@ abstract class AuthenticationMethod(open val id: String) { /** Login routes */ abstract fun Route.registerAuthenticationRoutes( - authContext: PipelineContext.() -> AuthContext, + authContext: ApplicationCall.() -> AuthContext, functionAmendments: Map Unit>? = null ) @@ -81,7 +80,7 @@ abstract class AuthenticationMethod(open val id: String) { * - [supportsRegistration] does this method support automatic registration (set to true) * - [authenticationHandlesRegistration] Login & registration is not a combined step (set to false) */ - open fun Route.registerRegistrationRoutes(authContext: PipelineContext.() -> AuthContext): Unit = + open fun Route.registerRegistrationRoutes(authContext: ApplicationCall.() -> AuthContext): Unit = throw NotImplementedError("Authentication method ${this::class.simpleName} does not offer registration routes. Authentication routes handle registration: $authenticationHandlesRegistration") @@ -98,9 +97,7 @@ abstract class AuthenticationMethod(open val id: String) { return (storedData as? V) ?: error("${storedData::class.simpleName} is not requested ${V::class.simpleName}") } - suspend fun PipelineContext.getSession(authContext: PipelineContext.() -> AuthContext): AuthSession { - val currentContext = authContext.invoke(this) - + private suspend fun sessionForAuthContext(currentContext: AuthContext): AuthSession { val session = if (currentContext.implicitSessionGeneration && currentContext.sessionId == null) { // Implicit session start SessionManager.openImplicitGlobalSession(currentContext.initialFlow!!) @@ -112,6 +109,9 @@ abstract class AuthenticationMethod(open val id: String) { return session } + suspend fun ApplicationCall.getAuthSession(authContext: ApplicationCall.() -> AuthContext): AuthSession = + sessionForAuthContext(currentContext = authContext.invoke(this)) + // Relations open val relatedAuthMethodStoredData: KClass? = null open val relatedAuthMethodConfiguration: KClass? = null @@ -120,7 +120,7 @@ abstract class AuthenticationMethod(open val id: String) { fun Route.registerAuthenticationMethod( method: AuthenticationMethod, - authContext: PipelineContext.() -> AuthContext, + authContext: ApplicationCall.() -> AuthContext, functionAmendments: Map Unit>? = null ) { method.apply { @@ -130,7 +130,7 @@ fun Route.registerAuthenticationMethod( fun Route.registerAuthenticationMethods( methods: List, - authContext: PipelineContext.() -> AuthContext, + authContext: ApplicationCall.() -> AuthContext, functionAmendments: Map Unit>>? = null ) { methods.forEach { method -> diff --git a/waltid-libraries/auth/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/methods/EmailPass.kt b/waltid-libraries/auth/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/methods/EmailPass.kt index 92fbea279..1d386e876 100644 --- a/waltid-libraries/auth/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/methods/EmailPass.kt +++ b/waltid-libraries/auth/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/methods/EmailPass.kt @@ -16,7 +16,6 @@ import io.ktor.http.* import io.ktor.server.application.* import io.ktor.server.auth.* import io.ktor.server.routing.* -import io.ktor.util.pipeline.* import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable @@ -62,24 +61,24 @@ object EmailPass : UserPassBasedAuthMethod("email", usernameName = "email") { data class EmailPassCredentials(val email: String, val password: String) override fun Route.registerAuthenticationRoutes( - authContext: PipelineContext.() -> AuthContext, + authContext: ApplicationCall.() -> AuthContext, functionAmendments: Map Unit>? ) { post("emailpass", { request { body() } response { HttpStatusCode.OK to { body() } } }) { - val session = getSession(authContext) + val session = call.getAuthSession(authContext) val credential = call.getUsernamePasswordFromRequest() - val identifier = auth(session, credential, context) + val identifier = auth(session, credential, call) - context.handleAuthSuccess(session, identifier.resolveToAccountId()) + call.handleAuthSuccess(session, identifier.resolveToAccountId()) } } - /*override fun Route.registerRegistrationRoutes(authContext: PipelineContext.() -> AuthContext) { + /*override fun Route.registerRegistrationRoutes(authContext: ApplicationCall.() -> AuthContext) { post("emailpass", { request { body() } response { HttpStatusCode.OK to { body() } } diff --git a/waltid-libraries/auth/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/methods/JWT.kt b/waltid-libraries/auth/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/methods/JWT.kt index 3c90869d6..c8fc704fa 100644 --- a/waltid-libraries/auth/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/methods/JWT.kt +++ b/waltid-libraries/auth/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/methods/JWT.kt @@ -13,7 +13,6 @@ import io.ktor.http.* import io.ktor.server.application.* import io.ktor.server.request.* import io.ktor.server.routing.* -import io.ktor.util.pipeline.* object JWT : AuthenticationMethod("jwt") { @@ -30,20 +29,20 @@ object JWT : AuthenticationMethod("jwt") { } override fun Route.registerAuthenticationRoutes( - authContext: PipelineContext.() -> AuthContext, + authContext: ApplicationCall.() -> AuthContext, functionAmendments: Map Unit>? ) { post("jwt", { request { body() } response { HttpStatusCode.OK to { body() } } }) { - val session = getSession(authContext) + val session = call.getAuthSession(authContext) val config = session.lookupConfiguration(this@JWT) - val jwt = context.receiveText() + val jwt = call.receiveText() val id = auth(jwt, config) - context.handleAuthSuccess(session, id.resolveToAccountId()) + call.handleAuthSuccess(session, id.resolveToAccountId()) } } diff --git a/waltid-libraries/auth/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/methods/Kerberos.kt b/waltid-libraries/auth/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/methods/Kerberos.kt index c3667b445..21ff0343c 100644 --- a/waltid-libraries/auth/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/methods/Kerberos.kt +++ b/waltid-libraries/auth/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/methods/Kerberos.kt @@ -31,9 +31,9 @@ fun auth(kerberosRealm: String, kerberosKdc: String, servicePrincipal: String, u ) return try { - context.requestMutualAuth(true) - context.requestConf(true) - context.requestInteg(true) + call.requestMutualAuth(true) + call.requestConf(true) + call.requestInteg(true) val token = ByteArray(0) val outToken = context.initSecContext(token, 0, token.size) diff --git a/waltid-libraries/auth/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/methods/LDAP.kt b/waltid-libraries/auth/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/methods/LDAP.kt index f4b5c70c7..06e41a6c8 100644 --- a/waltid-libraries/auth/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/methods/LDAP.kt +++ b/waltid-libraries/auth/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/methods/LDAP.kt @@ -13,7 +13,6 @@ import io.ktor.http.* import io.ktor.server.application.* import io.ktor.server.auth.* import io.ktor.server.routing.* -import io.ktor.util.pipeline.* import org.apache.directory.api.ldap.model.exception.LdapException import org.apache.directory.ldap.client.api.LdapConnection import org.apache.directory.ldap.client.api.LdapNetworkConnection @@ -45,20 +44,20 @@ object LDAP : UserPassBasedAuthMethod("ldap") { } override fun Route.registerAuthenticationRoutes( - authContext: PipelineContext.() -> AuthContext, + authContext: ApplicationCall.() -> AuthContext, functionAmendments: Map Unit>? ) { post("ldap", { request { body() } response { HttpStatusCode.OK to { body() } } }) { - val session = getSession(authContext) + val session = call.getAuthSession(authContext) val credential = call.getUsernamePasswordFromRequest() - val identifier = auth(session, credential, context) + val identifier = auth(session, credential, call) - context.handleAuthSuccess(session, identifier.resolveToAccountId()) + call.handleAuthSuccess(session, identifier.resolveToAccountId()) } } diff --git a/waltid-libraries/auth/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/methods/OIDC.kt b/waltid-libraries/auth/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/methods/OIDC.kt index 879dca440..c96943fe6 100644 --- a/waltid-libraries/auth/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/methods/OIDC.kt +++ b/waltid-libraries/auth/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/methods/OIDC.kt @@ -17,7 +17,6 @@ import io.ktor.server.application.* import io.ktor.server.response.* import io.ktor.server.routing.* import io.ktor.server.util.* -import io.ktor.util.pipeline.* import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable import kotlinx.serialization.json.Json @@ -151,24 +150,24 @@ object OIDC : AuthenticationMethod("oidc") { } override fun Route.registerAuthenticationRoutes( - authContext: PipelineContext.() -> AuthContext, + authContext: ApplicationCall.() -> AuthContext, functionAmendments: Map Unit>? ) { route("oidc") { get("auth") { - val session = getSession(authContext) + val session = call.getAuthSession(authContext) val config = session.lookupConfiguration(this@OIDC) val oidcAuthSession = createOidcSession(context = Unit, config) - context.respondRedirect(oidcAuthSession.authUrl) + call.respondRedirect(oidcAuthSession.authUrl) } get("callback") { - val session = getSession(authContext) + val session = call.getAuthSession(authContext) val config = session.lookupConfiguration(this@OIDC) - val params = context.parameters + val params = call.parameters val code = params.getOrFail("code") val state = params.getOrFail("state") @@ -182,7 +181,7 @@ object OIDC : AuthenticationMethod("oidc") { // TODO: better OIDC Identifier (make sure malicious cannot generate a clash per URL) val identifier = OIDCIdentifier(config.openIdConfiguration.authorizationEndpoint, sub) - context.handleAuthSuccess(session, identifier.resolveToAccountId()) + call.handleAuthSuccess(session, identifier.resolveToAccountId()) } } diff --git a/waltid-libraries/auth/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/methods/RADIUS.kt b/waltid-libraries/auth/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/methods/RADIUS.kt index 0e3ac948a..ef6b42abd 100644 --- a/waltid-libraries/auth/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/methods/RADIUS.kt +++ b/waltid-libraries/auth/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/methods/RADIUS.kt @@ -13,7 +13,6 @@ import io.ktor.http.* import io.ktor.server.application.* import io.ktor.server.auth.* import io.ktor.server.routing.* -import io.ktor.util.pipeline.* import org.aaa4j.radius.client.RadiusClient import org.aaa4j.radius.client.clients.UdpRadiusClient import org.aaa4j.radius.core.attribute.StringData @@ -54,21 +53,20 @@ object RADIUS : UserPassBasedAuthMethod("radius") { return identifier } - override fun Route.registerAuthenticationRoutes( - authContext: PipelineContext.() -> AuthContext, + authContext: ApplicationCall.() -> AuthContext, functionAmendments: Map Unit>? ) { post("radius", { request { body() } response { HttpStatusCode.OK to { body() } } }) { - val session = getSession(authContext) + val session = call.getAuthSession(authContext) val credential = call.getUsernamePasswordFromRequest() - val identifier = auth(session, credential, context) - context.handleAuthSuccess(session, identifier.resolveToAccountId()) + val identifier = auth(session, credential, call) + call.handleAuthSuccess(session, identifier.resolveToAccountId()) } } diff --git a/waltid-libraries/auth/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/methods/TOTP.kt b/waltid-libraries/auth/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/methods/TOTP.kt index 75585efcf..3a582cdfb 100644 --- a/waltid-libraries/auth/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/methods/TOTP.kt +++ b/waltid-libraries/auth/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/methods/TOTP.kt @@ -17,7 +17,6 @@ import io.ktor.http.* import io.ktor.server.application.* import io.ktor.server.request.* import io.ktor.server.routing.* -import io.ktor.util.pipeline.* import kotlinx.serialization.Serializable object TOTP : AuthenticationMethod("totp") { @@ -40,14 +39,14 @@ object TOTP : AuthenticationMethod("totp") { data class TOTPCode(val code: String) override fun Route.registerAuthenticationRoutes( - authContext: PipelineContext.() -> AuthContext, + authContext: ApplicationCall.() -> AuthContext, functionAmendments: Map Unit>? ) { post("totp", { request { body() } response { HttpStatusCode.OK to { body() } } }) { - val session = getSession(authContext) + val session = call.getAuthSession(authContext) val otp = when (call.request.contentType()) { ContentType.Application.Json -> call.receive().code @@ -59,7 +58,7 @@ object TOTP : AuthenticationMethod("totp") { auth(session, otp) - context.handleAuthSuccess(session, null) + call.handleAuthSuccess(session, null) } } diff --git a/waltid-libraries/auth/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/methods/UserPass.kt b/waltid-libraries/auth/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/methods/UserPass.kt index b77c21577..913f9d7b4 100644 --- a/waltid-libraries/auth/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/methods/UserPass.kt +++ b/waltid-libraries/auth/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/methods/UserPass.kt @@ -16,7 +16,6 @@ import io.ktor.http.* import io.ktor.server.application.* import io.ktor.server.auth.* import io.ktor.server.routing.* -import io.ktor.util.pipeline.* import kotlinx.serialization.Serializable @Serializable @@ -44,20 +43,20 @@ object UserPass : UserPassBasedAuthMethod("userpass") { } override fun Route.registerAuthenticationRoutes( - authContext: PipelineContext.() -> AuthContext, + authContext: ApplicationCall.() -> AuthContext, functionAmendments: Map Unit>? ) { post("userpass", { request { body() } response { HttpStatusCode.OK to { body() } } }) { - val session = getSession(authContext) + val session = call.getAuthSession(authContext) val credential = call.getUsernamePasswordFromRequest() - val identifier = auth(session, credential, context) + val identifier = auth(session, credential, call) - context.handleAuthSuccess(session, identifier.resolveToAccountId()) + call.handleAuthSuccess(session, identifier.resolveToAccountId()) } } diff --git a/waltid-libraries/auth/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/methods/VerifiableCredential.kt b/waltid-libraries/auth/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/methods/VerifiableCredential.kt index 23c04c5ca..520b6ddfc 100644 --- a/waltid-libraries/auth/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/methods/VerifiableCredential.kt +++ b/waltid-libraries/auth/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/methods/VerifiableCredential.kt @@ -20,7 +20,6 @@ import io.ktor.server.request.* import io.ktor.server.response.* import io.ktor.server.routing.* import io.ktor.server.util.* -import io.ktor.util.pipeline.* import kotlinx.serialization.Serializable import kotlinx.serialization.json.* import kotlin.io.encoding.Base64 @@ -33,24 +32,24 @@ object VerifiableCredential : AuthenticationMethod("vc") { val verifierUrl = "http://localhost:7003" override fun Route.registerAuthenticationRoutes( - authContext: PipelineContext.() -> AuthContext, + authContext: ApplicationCall.() -> AuthContext, functionAmendments: Map Unit>? ) { route("vc", { }) { get("start-presentation") { - val session = getSession(authContext) + val session = call.getAuthSession(authContext) val config = session.lookupConfiguration(this@VerifiableCredential) - val redirectUrl = context.request.uri.removeSuffix("/start-presentation") + "/callback" + val redirectUrl = call.request.uri.removeSuffix("/start-presentation") + "/callback" val resp = Verifier.verify(verifierUrl, config.verification, redirectUrl) - context.respond(resp.presentationRequest) + call.respond(resp.presentationRequest) } get("callback") { - context.respond("handle further...") + call.respond("handle further...") //val session = getSession(authContext) //context.handleAuthSuccess(session, ) } diff --git a/waltid-libraries/auth/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/methods/Web3.kt b/waltid-libraries/auth/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/methods/Web3.kt index b2ed0e7e1..b940cd9de 100644 --- a/waltid-libraries/auth/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/methods/Web3.kt +++ b/waltid-libraries/auth/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/methods/Web3.kt @@ -14,7 +14,6 @@ import io.klogging.logger import io.ktor.server.application.* import io.ktor.server.response.* import io.ktor.server.routing.* -import io.ktor.util.pipeline.* import kotlinx.coroutines.runBlocking import kotlinx.datetime.Clock import kotlinx.serialization.Serializable @@ -119,19 +118,19 @@ object Web3 : AuthenticationMethod("web3") { } override fun Route.registerAuthenticationRoutes( - authContext: PipelineContext.() -> AuthContext, + authContext: ApplicationCall.() -> AuthContext, functionAmendments: Map Unit>? ) { route("web3") { get("nonce") { val newNonce = makeNonce() - context.respond(newNonce) + call.respond(newNonce) } post("signed", { request { body() } }) { req -> - val session = getSession(authContext) + val session = call.getAuthSession(authContext) val address = verifySiweLogin(req) val identifier = Web3Identifier(address) @@ -142,7 +141,7 @@ object Web3 : AuthenticationMethod("web3") { registrationFunction.invoke(identifier) } - context.handleAuthSuccess(session, identifierResolved ?: identifier.resolveToAccountId()) + call.handleAuthSuccess(session, identifierResolved ?: identifier.resolveToAccountId()) } } } diff --git a/waltid-libraries/auth/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/methods/virtual/GlobalIdentify.kt b/waltid-libraries/auth/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/methods/virtual/GlobalIdentify.kt index 79c784f1f..1d204bc16 100644 --- a/waltid-libraries/auth/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/methods/virtual/GlobalIdentify.kt +++ b/waltid-libraries/auth/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/methods/virtual/GlobalIdentify.kt @@ -9,7 +9,7 @@ import io.ktor.util.pipeline.* object GlobalIdentify : IdentifyVirtualAuth("identify-global") { override fun Route.registerAuthenticationRoutes( - authContext: PipelineContext.() -> AuthContext, + authContext: ApplicationCall.() -> AuthContext, functionAmendments: Map Unit>? ) { throw NotImplementedError("This method is internally referenced and not to be used by the caller.") diff --git a/waltid-libraries/auth/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/methods/virtual/IdentifyEmail.kt b/waltid-libraries/auth/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/methods/virtual/IdentifyEmail.kt index 531dd3b44..1e7a4c68d 100644 --- a/waltid-libraries/auth/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/methods/virtual/IdentifyEmail.kt +++ b/waltid-libraries/auth/waltid-ktor-authnz/src/main/kotlin/id/walt/ktorauthnz/methods/virtual/IdentifyEmail.kt @@ -18,13 +18,13 @@ object IdentifyEmail : IdentifyVirtualAuth("identify") { @Serializable data class IdentifyEmailRequest(val email: String) - override fun Route.register(authContext: PipelineContext.() -> AuthContext) { + override fun Route.register(authContext: ApplicationCall.() -> AuthContext) { post("identify-email", { request { body() } }) { // TODO: support the others (form, etc) - val email = context.receive().email + val email = call.receive().email val identifier = EmailIdentifier(email) val store = KtorAuthnzManager.accountStore diff --git a/waltid-libraries/auth/waltid-ktor-authnz/src/test/kotlin/id/walt/AuthFlowExampleApplication.kt b/waltid-libraries/auth/waltid-ktor-authnz/src/test/kotlin/id/walt/AuthFlowExampleApplication.kt index 16493b8b8..72f01b3d2 100644 --- a/waltid-libraries/auth/waltid-ktor-authnz/src/test/kotlin/id/walt/AuthFlowExampleApplication.kt +++ b/waltid-libraries/auth/waltid-ktor-authnz/src/test/kotlin/id/walt/AuthFlowExampleApplication.kt @@ -47,7 +47,7 @@ fun loggingSetup() { } } -fun startExample(wait: Boolean = true, jwt: Boolean): ApplicationEngine { +fun startExample(wait: Boolean = true, jwt: Boolean): EmbeddedServer { loggingSetup() return embeddedServer(CIO, port = 8088, host = "0.0.0.0", module = { this.module(jwt) }) .start(wait = wait) @@ -63,7 +63,7 @@ fun Application.module(jwt: Boolean) { testApp(jwt) - collectRoutes().forEach { + /*collectRoutes().forEach { println(it) - } + }*/ } diff --git a/waltid-libraries/auth/waltid-ktor-authnz/src/test/kotlin/id/walt/ExampleWeb.kt b/waltid-libraries/auth/waltid-ktor-authnz/src/test/kotlin/id/walt/ExampleWeb.kt index 70f62d93b..732df7047 100644 --- a/waltid-libraries/auth/waltid-ktor-authnz/src/test/kotlin/id/walt/ExampleWeb.kt +++ b/waltid-libraries/auth/waltid-ktor-authnz/src/test/kotlin/id/walt/ExampleWeb.kt @@ -33,10 +33,10 @@ fun Route.globalMultistepExample() { """.trimIndent() val authFlow = AuthFlow.fromConfig(flowConfig) - val contextFunction: PipelineContext.() -> AuthContext = { + val contextFunction: ApplicationCall.() -> AuthContext = { AuthContext( - tenant = call.request.host(), - sessionId = call.parameters["sessionId"], + tenant = request.host(), + sessionId = parameters["sessionId"], implicitSessionGeneration = true, initialFlow = authFlow ) @@ -59,10 +59,10 @@ fun Route.globalImplicitSingleStep() { val authFlow = AuthFlow.fromConfig(flowConfig) - val contextFunction: PipelineContext.() -> AuthContext = { + val contextFunction: ApplicationCall.() -> AuthContext = { AuthContext( - tenant = call.request.host(), - sessionId = call.parameters["sessionId"], + tenant = request.host(), + sessionId = parameters["sessionId"], implicitSessionGeneration = true, initialFlow = authFlow ) @@ -87,10 +87,10 @@ fun Route.globalImplicitMultiStep() { val authFlow = AuthFlow.fromConfig(flowConfig) - val contextFunction: PipelineContext.() -> AuthContext = { + val contextFunction: ApplicationCall.() -> AuthContext = { AuthContext( - tenant = call.request.host(), - sessionId = call.parameters["sessionId"], + tenant = request.host(), + sessionId = parameters["sessionId"], implicitSessionGeneration = true, initialFlow = authFlow ) @@ -107,10 +107,10 @@ fun Route.globalExplicitMultiStep() { route("global-explicit2") { val methods = listOf(UserPass, TOTP) - val contextFunction: PipelineContext.() -> AuthContext = { + val contextFunction: ApplicationCall.() -> AuthContext = { AuthContext( - tenant = call.request.host(), - sessionId = call.parameters["sessionId"] ?: error("Missing sessionId") + tenant = request.host(), + sessionId = parameters["sessionId"] ?: error("Missing sessionId") ) } @@ -132,7 +132,7 @@ fun Route.globalExplicitMultiStep() { post("start") { val session = SessionManager.openExplicitGlobalSession(authFlow) - context.respond(session.toInformation()) + call.respond(session.toInformation()) } } } @@ -156,10 +156,10 @@ fun Route.globalImplicitVc() { val authFlow = AuthFlow.fromConfig(flowConfig) - val contextFunction: PipelineContext.() -> AuthContext = { + val contextFunction: ApplicationCall.() -> AuthContext = { AuthContext( - tenant = call.request.host(), - sessionId = call.parameters["sessionId"], + tenant = request.host(), + sessionId = parameters["sessionId"], implicitSessionGeneration = true, initialFlow = authFlow ) @@ -184,7 +184,7 @@ fun Route.globalImplicitVc() { val authFlow = AuthFlow.fromConfig(flowConfig) - val contextFunction: PipelineContext.() -> AuthContext = { + val contextFunction: ApplicationCall.() -> AuthContext = { AuthContext( tenant = call.request.host(), sessionId = call.parameters["sessionId"], @@ -202,7 +202,7 @@ fun Route.globalImplicitVc() { post("start") { val session = SessionManager.openExplicitGlobalSession(authFlow) - context.respond(session.toInformation()) + call.respond(session.toInformation()) } } }*/ @@ -245,8 +245,8 @@ fun Application.testApp(jwt: Boolean) { authenticate("ktor-authnz") { get("/protected") { - val token = getAuthToken() - val accountId = getAuthenticatedAccount() + val token = call.getAuthToken() + val accountId = call.getAuthenticatedAccount() call.respondText("Hello token ${token}, you are $accountId") } } diff --git a/waltid-libraries/auth/waltid-ktor-authnz/src/test/kotlin/id/walt/KtorAuthnzDevMockedTest.kt b/waltid-libraries/auth/waltid-ktor-authnz/src/test/kotlin/id/walt/KtorAuthnzDevMockedTest.kt index 298240625..bb0f258ab 100644 --- a/waltid-libraries/auth/waltid-ktor-authnz/src/test/kotlin/id/walt/KtorAuthnzDevMockedTest.kt +++ b/waltid-libraries/auth/waltid-ktor-authnz/src/test/kotlin/id/walt/KtorAuthnzDevMockedTest.kt @@ -27,7 +27,7 @@ class KtorAuthnzDevMockedTest { routing { authenticate { get("/protected") { - context.respond("protected") + call.respond("protected") } } } @@ -56,8 +56,8 @@ class KtorAuthnzDevMockedTest { routing { authenticate("dev-auth") { get("/protected") { - val acc = getAuthenticatedAccount() - context.respond("protected! you are: $acc") + val acc = call.getAuthenticatedAccount() + call.respond("protected! you are: $acc") } } } diff --git a/waltid-libraries/auth/waltid-ktor-authnz/src/test/kotlin/id/walt/RouteCollector.kt b/waltid-libraries/auth/waltid-ktor-authnz/src/test/kotlin/id/walt/RouteCollector.kt index 72c0a1bc4..108ab36f6 100644 --- a/waltid-libraries/auth/waltid-ktor-authnz/src/test/kotlin/id/walt/RouteCollector.kt +++ b/waltid-libraries/auth/waltid-ktor-authnz/src/test/kotlin/id/walt/RouteCollector.kt @@ -28,41 +28,41 @@ fun Application.collectRoutes(): List { */ private fun Route.allRoutes(prefix: String = ""): List { val routes = mutableListOf() - - /** - * Checks if the route is a prefix (non-terminal) route. - * A prefix route is identified by having children with specific HTTP method selectors. - * - * @return True if the route is a prefix route, false otherwise. - */ - fun Route.isPrefixRoute(): Boolean { - return this.children.any { it.selector is HttpMethodRouteSelector } - } - - /** - * Recursive function to traverse the route tree and collect terminal routes. - * - * @param currentPath The current path accumulated from the parent routes. - */ - fun Route.collectRoutes(currentPath: String) { - val pathSegment = when (val selector = this.selector) { - is PathSegmentConstantRouteSelector -> "${currentPath}/${selector.value}" - is PathSegmentParameterRouteSelector -> "${currentPath}/{${selector.name}}" - is PathSegmentWildcardRouteSelector -> "${currentPath}/*" - else -> currentPath - } - - // Add the route if it's a terminal route (has an HttpMethodRouteSelector and is not a prefix route). - if (this.selector is HttpMethodRouteSelector && !this.isPrefixRoute()) { - val method = (this.selector as HttpMethodRouteSelector).method.value - routes.add("$method $pathSegment") - } - - // Recursively collect routes from children. - this.children.forEach { it.collectRoutes(pathSegment) } - } - - this.collectRoutes(prefix) +// +// /** +// * Checks if the route is a prefix (non-terminal) route. +// * A prefix route is identified by having children with specific HTTP method selectors. +// * +// * @return True if the route is a prefix route, false otherwise. +// */ +// fun Route.isPrefixRoute(): Boolean { +// return this.children.any { it.selector is HttpMethodRouteSelector } +// } +// +// /** +// * Recursive function to traverse the route tree and collect terminal routes. +// * +// * @param currentPath The current path accumulated from the parent routes. +// */ +// fun Route.collectRoutes(currentPath: String) { +// val pathSegment = when (val selector = this.selector) { +// is PathSegmentConstantRouteSelector -> "${currentPath}/${selector.value}" +// is PathSegmentParameterRouteSelector -> "${currentPath}/{${selector.name}}" +// is PathSegmentWildcardRouteSelector -> "${currentPath}/*" +// else -> currentPath +// } +// +// // Add the route if it's a terminal route (has an HttpMethodRouteSelector and is not a prefix route). +// if (this.selector is HttpMethodRouteSelector && !this.isPrefixRoute()) { +// val method = (this.selector as HttpMethodRouteSelector).method.value +// routes.add("$method $pathSegment") +// } +// +// // Recursively collect routes from children. +// this.children.forEach { it.collectRoutes(pathSegment) } +// } +// +// this.collectRoutes(prefix) return routes.distinct() } diff --git a/waltid-libraries/auth/waltid-ktor-authnz/src/test/kotlin/id/walt/web/plugins/Monitoring.kt b/waltid-libraries/auth/waltid-ktor-authnz/src/test/kotlin/id/walt/web/plugins/Monitoring.kt index 3616dd9d3..4781b61a3 100644 --- a/waltid-libraries/auth/waltid-ktor-authnz/src/test/kotlin/id/walt/web/plugins/Monitoring.kt +++ b/waltid-libraries/auth/waltid-ktor-authnz/src/test/kotlin/id/walt/web/plugins/Monitoring.kt @@ -2,7 +2,7 @@ package id.walt.web.plugins import io.ktor.http.* import io.ktor.server.application.* -import io.ktor.server.plugins.callloging.* +import io.ktor.server.plugins.calllogging.CallLogging import io.ktor.server.plugins.statuspages.* import io.ktor.server.response.* diff --git a/waltid-libraries/auth/waltid-ktor-authnz/src/test/kotlin/id/walt/web/plugins/OpenApi.kt b/waltid-libraries/auth/waltid-ktor-authnz/src/test/kotlin/id/walt/web/plugins/OpenApi.kt index 7b991c6bb..b0928f6db 100644 --- a/waltid-libraries/auth/waltid-ktor-authnz/src/test/kotlin/id/walt/web/plugins/OpenApi.kt +++ b/waltid-libraries/auth/waltid-ktor-authnz/src/test/kotlin/id/walt/web/plugins/OpenApi.kt @@ -39,7 +39,7 @@ fun Application.configureOpenApi() { get("/", { summary = "Redirect to swagger interface for API documentation" }) { - context.respondRedirect("swagger") + call.respondRedirect("swagger") } } } diff --git a/waltid-libraries/auth/waltid-permissions/build.gradle.kts b/waltid-libraries/auth/waltid-permissions/build.gradle.kts index de5f59211..7e49c6032 100644 --- a/waltid-libraries/auth/waltid-permissions/build.gradle.kts +++ b/waltid-libraries/auth/waltid-permissions/build.gradle.kts @@ -65,15 +65,15 @@ kotlin { sourceSets { val commonMain by getting { dependencies { - implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0") + implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.0") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.1") implementation("${SuspendTransPluginConstants.ANNOTATION_GROUP}:${SuspendTransPluginConstants.ANNOTATION_NAME}:${SuspendTransPluginConstants.ANNOTATION_VERSION}") } } val commonTest by getting { dependencies { implementation(kotlin("test")) - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.9.0") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.10.1") } } } diff --git a/waltid-libraries/credentials/waltid-dif-definitions-parser/build.gradle.kts b/waltid-libraries/credentials/waltid-dif-definitions-parser/build.gradle.kts index a0674332d..d2444570c 100644 --- a/waltid-libraries/credentials/waltid-dif-definitions-parser/build.gradle.kts +++ b/waltid-libraries/credentials/waltid-dif-definitions-parser/build.gradle.kts @@ -52,16 +52,16 @@ kotlin { dependencies { // JSON implementation("com.eygraber:jsonpathkt-kotlinx:3.0.2") - implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3") + implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.0") implementation("io.github.optimumcode:json-schema-validator:0.2.3") implementation(project(":waltid-libraries:credentials:waltid-verifiable-credentials")) // Coroutines - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.1") // Logging - implementation("io.github.oshai:kotlin-logging:7.0.0") + implementation("io.github.oshai:kotlin-logging:7.0.4") } } val commonTest by getting { @@ -71,7 +71,7 @@ kotlin { } val jvmTest by getting { dependencies { - implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3") + implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.0") implementation("org.slf4j:slf4j-simple:2.0.16") } } diff --git a/waltid-libraries/credentials/waltid-mdoc-credentials/build.gradle.kts b/waltid-libraries/credentials/waltid-mdoc-credentials/build.gradle.kts index 3507a6cd4..2492ca874 100644 --- a/waltid-libraries/credentials/waltid-mdoc-credentials/build.gradle.kts +++ b/waltid-libraries/credentials/waltid-mdoc-credentials/build.gradle.kts @@ -3,6 +3,7 @@ plugins { kotlin("plugin.serialization") id("dev.petuska.npm.publish") version "3.4.3" `maven-publish` + id("com.github.ben-manes.versions") } group = "id.walt.mdoc-credentials" @@ -55,10 +56,10 @@ kotlin { sourceSets { val commonMain by getting { dependencies { - implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3") + implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.0") //implementation("org.jetbrains.kotlinx:kotlinx-serialization-cbor:1.5.1") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0") - implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.6.1") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.1") + implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.6.2") implementation("com.soywiz.korlibs.krypto:krypto:4.0.10") } } @@ -74,9 +75,9 @@ kotlin { } val jvmTest by getting { dependencies { - implementation("org.bouncycastle:bcprov-lts8on:2.73.6") - implementation("org.bouncycastle:bcpkix-lts8on:2.73.6") - implementation("io.mockk:mockk:1.13.11") + implementation("org.bouncycastle:bcprov-lts8on:2.73.7") + implementation("org.bouncycastle:bcpkix-lts8on:2.73.7") + implementation("io.mockk:mockk:1.13.16") implementation(kotlin("reflect")) } diff --git a/waltid-libraries/credentials/waltid-verifiable-credentials/build.gradle.kts b/waltid-libraries/credentials/waltid-verifiable-credentials/build.gradle.kts index 3a18a7692..dcda20ec9 100644 --- a/waltid-libraries/credentials/waltid-verifiable-credentials/build.gradle.kts +++ b/waltid-libraries/credentials/waltid-verifiable-credentials/build.gradle.kts @@ -84,12 +84,12 @@ kotlin { iosSimulatorArm64() } - val ktor_version = "2.3.12" + val ktor_version = "3.1.0" sourceSets { val commonMain by getting { dependencies { // JSON - implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3") + implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.0") implementation("io.github.optimumcode:json-schema-validator:0.2.3") // Ktor client @@ -101,14 +101,14 @@ kotlin { implementation("io.ktor:ktor-client-logging:$ktor_version") // Coroutines - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.1") // Kotlinx - implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.6.1") + implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.6.2") implementation("app.softwork:kotlinx-uuid-core:0.1.2") // Loggin - implementation("io.github.oshai:kotlin-logging:7.0.0") + implementation("io.github.oshai:kotlin-logging:7.0.4") // walt.id api(project(":waltid-libraries:crypto:waltid-crypto")) @@ -122,7 +122,7 @@ kotlin { val commonTest by getting { dependencies { implementation(kotlin("test")) - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.9.0") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.10.1") } } val jvmMain by getting { @@ -136,9 +136,9 @@ kotlin { } val jvmTest by getting { dependencies { - implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3") + implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.0") implementation("org.slf4j:slf4j-simple:2.0.16") - implementation("org.junit.jupiter:junit-jupiter-params:5.11.0") + implementation("org.junit.jupiter:junit-jupiter-params:5.11.4") } } val jsMain by getting { diff --git a/waltid-libraries/credentials/waltid-verification-policies/build.gradle.kts b/waltid-libraries/credentials/waltid-verification-policies/build.gradle.kts index fa1842617..e5515804b 100644 --- a/waltid-libraries/credentials/waltid-verification-policies/build.gradle.kts +++ b/waltid-libraries/credentials/waltid-verification-policies/build.gradle.kts @@ -61,21 +61,21 @@ kotlin { iosSimulatorArm64() } - val ktor_version = "2.3.12" + val ktor_version = "3.1.0" sourceSets { val commonMain by getting { dependencies { implementation("com.eygraber:jsonpathkt-kotlinx:3.0.2") // JSON - implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.1") - implementation("io.github.optimumcode:json-schema-validator:0.2.2") + implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.0") + implementation("io.github.optimumcode:json-schema-validator:0.4.0") implementation(project(":waltid-libraries:credentials:waltid-verifiable-credentials")) implementation(project(":waltid-libraries:credentials:waltid-dif-definitions-parser")) implementation(project(":waltid-libraries:sdjwt:waltid-sdjwt")) // Kotlinx - implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.6.0") + implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.6.2") // Ktor client implementation("io.ktor:ktor-client-core:$ktor_version") @@ -86,10 +86,10 @@ kotlin { implementation("io.ktor:ktor-client-logging:$ktor_version") // Loggin - implementation("io.github.oshai:kotlin-logging:7.0.0") + implementation("io.github.oshai:kotlin-logging:7.0.4") // Coroutines - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.8.1") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.1") // suspend-transform plugin annotations (required in the current version to avoid "compileOnly" warning) implementation("${SuspendTransPluginConstants.ANNOTATION_GROUP}:${SuspendTransPluginConstants.ANNOTATION_NAME}:${SuspendTransPluginConstants.ANNOTATION_VERSION}") @@ -98,14 +98,14 @@ kotlin { val commonTest by getting { dependencies { implementation(kotlin("test")) - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.8.1") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.10.1") } } val jvmTest by getting { dependencies { - implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.1") - implementation("org.slf4j:slf4j-simple:2.0.13") - implementation("org.junit.jupiter:junit-jupiter-params:5.11.0-M2") + implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.0") + implementation("org.slf4j:slf4j-simple:2.0.16") + implementation("org.junit.jupiter:junit-jupiter-params:5.11.4") } } diff --git a/waltid-libraries/credentials/waltid-verification-policies/src/commonTest/kotlin/id/walt/policies/DynamicPolicyVerificationTest.kt b/waltid-libraries/credentials/waltid-verification-policies/src/commonTest/kotlin/id/walt/policies/DynamicPolicyVerificationTest.kt index 827ac7165..99227ad4c 100644 --- a/waltid-libraries/credentials/waltid-verification-policies/src/commonTest/kotlin/id/walt/policies/DynamicPolicyVerificationTest.kt +++ b/waltid-libraries/credentials/waltid-verification-policies/src/commonTest/kotlin/id/walt/policies/DynamicPolicyVerificationTest.kt @@ -11,7 +11,6 @@ import io.ktor.client.statement.* import io.ktor.http.* import io.ktor.serialization.kotlinx.json.* import kotlinx.coroutines.test.runTest -import kotlinx.serialization.encodeToString import kotlinx.serialization.json.Json import kotlinx.serialization.json.JsonObject import kotlinx.serialization.json.jsonArray @@ -30,8 +29,8 @@ class DynamicPolicyTest { return try { val response: HttpResponse = http.get("http://localhost:8181") response.status == HttpStatusCode.OK - } catch (e: Exception) { - println("Error connecting to OPA server: ${e.message}") + } catch (e: Throwable) { + println("OPA server is not available: ${e.stackTraceToString()}") false } finally { http.close() @@ -42,7 +41,7 @@ class DynamicPolicyTest { @Test fun testPresentationVerificationWithDynamicPolicy() = runTest { if (!isOpaServerRunning()) { - println("Skipping test: OPA server is not running.") + println("Skipping test: OPA server is not available.") return@runTest } DidService.apply { @@ -122,4 +121,4 @@ class DynamicPolicyTest { println("Results: " + x.size) println("OK: ${x.count { it.isSuccess() }}") } -} \ No newline at end of file +} diff --git a/waltid-libraries/crypto/waltid-crypto-android/build.gradle.kts b/waltid-libraries/crypto/waltid-crypto-android/build.gradle.kts index b22f70793..ac86764c9 100644 --- a/waltid-libraries/crypto/waltid-crypto-android/build.gradle.kts +++ b/waltid-libraries/crypto/waltid-crypto-android/build.gradle.kts @@ -88,14 +88,14 @@ kotlin { val androidMain by getting { dependencies { api(project(":waltid-libraries:crypto:waltid-crypto")) - implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3") - implementation("io.github.oshai:kotlin-logging:7.0.0") + implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.0") + implementation("io.github.oshai:kotlin-logging:7.0.4") } } val androidInstrumentedTest by getting { dependencies { implementation(kotlin("test")) - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.9.0") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.10.1") implementation("androidx.test.ext:junit:1.2.1") implementation("androidx.test:runner:1.6.1") implementation("androidx.test:rules:1.6.1") @@ -104,8 +104,8 @@ kotlin { val androidUnitTest by getting { dependencies { implementation(kotlin("test")) - implementation("org.junit.jupiter:junit-jupiter-api:5.11.0") - implementation("org.junit.jupiter:junit-jupiter-params:5.11.0") + implementation("org.junit.jupiter:junit-jupiter-api:5.11.4") + implementation("org.junit.jupiter:junit-jupiter-params:5.11.4") } } publishing { diff --git a/waltid-libraries/crypto/waltid-crypto-aws/build.gradle.kts b/waltid-libraries/crypto/waltid-crypto-aws/build.gradle.kts index 4366a969b..4900eccb2 100644 --- a/waltid-libraries/crypto/waltid-crypto-aws/build.gradle.kts +++ b/waltid-libraries/crypto/waltid-crypto-aws/build.gradle.kts @@ -14,19 +14,19 @@ repositories { dependencies { testImplementation(kotlin("test")) - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.9.0") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.10.1") // walt.id api(project(":waltid-libraries:crypto:waltid-crypto")) // JSON - implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3") + implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.0") // Coroutines - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.7.3") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.1") // AWS - implementation("aws.sdk.kotlin:kms:1.3.91") + implementation("aws.sdk.kotlin:kms:1.4.22") // JOSE implementation("com.nimbusds:nimbus-jose-jwt:9.41.1") diff --git a/waltid-libraries/crypto/waltid-crypto-ios/build.gradle.kts b/waltid-libraries/crypto/waltid-crypto-ios/build.gradle.kts index 06e79c98b..8ab44423c 100644 --- a/waltid-libraries/crypto/waltid-crypto-ios/build.gradle.kts +++ b/waltid-libraries/crypto/waltid-crypto-ios/build.gradle.kts @@ -1,6 +1,7 @@ plugins { kotlin("multiplatform") kotlin("native.cocoapods") + id("com.github.ben-manes.versions") } kotlin { diff --git a/waltid-libraries/crypto/waltid-crypto-oci/build.gradle.kts b/waltid-libraries/crypto/waltid-crypto-oci/build.gradle.kts index a49ed9a65..7d0b7383a 100644 --- a/waltid-libraries/crypto/waltid-crypto-oci/build.gradle.kts +++ b/waltid-libraries/crypto/waltid-crypto-oci/build.gradle.kts @@ -74,17 +74,17 @@ kotlin { val commonMain by getting { dependencies { // JSON - implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3") + implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.0") // Coroutines - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.1") // Crypto - implementation(project.dependencies.platform("org.kotlincrypto.hash:bom:0.5.3")) + implementation(project.dependencies.platform("org.kotlincrypto.hash:bom:0.6.1")) implementation("org.kotlincrypto.hash:sha2") // Logging - implementation("io.github.oshai:kotlin-logging:7.0.0") + implementation("io.github.oshai:kotlin-logging:7.0.4") // walt.id api(project(":waltid-libraries:crypto:waltid-crypto")) @@ -94,16 +94,16 @@ kotlin { dependencies { implementation(kotlin("test-common")) implementation(kotlin("test-annotations-common")) - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.9.0") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.10.1") } } val jvmMain by getting { dependencies { // Coroutines - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:1.9.0") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:1.10.1") // OCI - implementation("com.oracle.oci.sdk:oci-java-sdk-shaded-full:3.49.0") + implementation("com.oracle.oci.sdk:oci-java-sdk-shaded-full:3.57.1") // JOSE implementation("com.nimbusds:nimbus-jose-jwt:9.41.1") @@ -114,15 +114,15 @@ kotlin { } val jvmTest by getting { dependencies { - implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3") + implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.0") // Logging implementation("org.slf4j:slf4j-simple:2.0.16") // Test implementation(kotlin("test")) - implementation("org.junit.jupiter:junit-jupiter-api:5.11.0") - implementation("org.junit.jupiter:junit-jupiter-params:5.11.0") + implementation("org.junit.jupiter:junit-jupiter-api:5.11.4") + implementation("org.junit.jupiter:junit-jupiter-params:5.11.4") } } // val androidMain by getting { diff --git a/waltid-libraries/crypto/waltid-crypto/build.gradle.kts b/waltid-libraries/crypto/waltid-crypto/build.gradle.kts index a15ffb3d3..2251b2283 100644 --- a/waltid-libraries/crypto/waltid-crypto/build.gradle.kts +++ b/waltid-libraries/crypto/waltid-crypto/build.gradle.kts @@ -86,7 +86,7 @@ kotlin { iosSimulatorArm64() } - val ktor_version = "2.3.12" + val ktor_version = "3.1.0" sourceSets { @@ -97,7 +97,7 @@ kotlin { val commonMain by getting { dependencies { // JSON - implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3") + implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.0") // Ktor client implementation("io.ktor:ktor-client-core:$ktor_version") @@ -107,25 +107,25 @@ kotlin { implementation("io.ktor:ktor-client-json:$ktor_version") implementation("io.ktor:ktor-client-logging:$ktor_version") - implementation(project.dependencies.platform("org.kotlincrypto.hash:bom:0.5.3")) + implementation(project.dependencies.platform("org.kotlincrypto.hash:bom:0.6.1")) implementation("org.kotlincrypto.hash:sha2") // Date - implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.6.1") + implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.6.2") // Cache implementation("io.github.reactivecircus.cache4k:cache4k:0.13.0") // Coroutines - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.1") // Logging - implementation("io.github.oshai:kotlin-logging:7.0.0") + implementation("io.github.oshai:kotlin-logging:7.0.4") implementation("${SuspendTransPluginConstants.ANNOTATION_GROUP}:${SuspendTransPluginConstants.ANNOTATION_NAME}:${SuspendTransPluginConstants.ANNOTATION_VERSION}") - implementation(platform("org.kotlincrypto.macs:bom:0.5.3")) + implementation(platform("org.kotlincrypto.macs:bom:0.6.1")) implementation("org.kotlincrypto.macs:hmac-sha2") } @@ -134,21 +134,21 @@ kotlin { dependencies { implementation(kotlin("test-common")) implementation(kotlin("test-annotations-common")) - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.9.0") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.10.1") } } val jvmMain by getting { dependencies { - implementation("com.google.crypto.tink:tink:1.15.0") // for JOSE using Ed25519 + implementation("com.google.crypto.tink:tink:1.16.0") // for JOSE using Ed25519 - implementation("org.bouncycastle:bcprov-lts8on:2.73.6") // for secp256k1 (which was removed with Java 17) - implementation("org.bouncycastle:bcpkix-lts8on:2.73.6") // PEM import + implementation("org.bouncycastle:bcprov-lts8on:2.73.7") // for secp256k1 (which was removed with Java 17) + implementation("org.bouncycastle:bcpkix-lts8on:2.73.7") // PEM import // Ktor client implementation("io.ktor:ktor-client-okhttp:$ktor_version") // Coroutines - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:1.9.0") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-jdk8:1.10.1") // JOSE implementation("com.nimbusds:nimbus-jose-jwt:9.41.1") @@ -163,9 +163,9 @@ kotlin { // Test implementation(kotlin("test")) - implementation("org.junit.jupiter:junit-jupiter-api:5.11.0") - implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3") - implementation("org.junit.jupiter:junit-jupiter-params:5.11.0") + implementation("org.junit.jupiter:junit-jupiter-api:5.11.4") + implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.0") + implementation("org.junit.jupiter:junit-jupiter-params:5.11.4") } } val jsMain by getting { diff --git a/waltid-libraries/crypto/waltid-crypto/src/commonMain/kotlin/id/walt/crypto/keys/tse/TSEKey.kt b/waltid-libraries/crypto/waltid-crypto/src/commonMain/kotlin/id/walt/crypto/keys/tse/TSEKey.kt index e6d917adf..256fdb6e9 100644 --- a/waltid-libraries/crypto/waltid-crypto/src/commonMain/kotlin/id/walt/crypto/keys/tse/TSEKey.kt +++ b/waltid-libraries/crypto/waltid-crypto/src/commonMain/kotlin/id/walt/crypto/keys/tse/TSEKey.kt @@ -326,7 +326,6 @@ class TSEKey( else -> throw KeyTypeNotSupportedException(type) } - @OptIn(InternalAPI::class) @JvmBlocking @JvmAsync @JsPromise diff --git a/waltid-libraries/crypto/waltid-target-ios/build.gradle.kts b/waltid-libraries/crypto/waltid-target-ios/build.gradle.kts index 719c63fbd..660f3d209 100644 --- a/waltid-libraries/crypto/waltid-target-ios/build.gradle.kts +++ b/waltid-libraries/crypto/waltid-target-ios/build.gradle.kts @@ -2,6 +2,7 @@ plugins { kotlin("multiplatform") kotlin("native.cocoapods") kotlin("plugin.serialization") + id("com.github.ben-manes.versions") } kotlin { @@ -55,8 +56,8 @@ kotlin { val commonMain by getting { dependencies { - implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0") + implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.0") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.1") } } diff --git a/waltid-libraries/protocols/waltid-openid4vc/build.gradle.kts b/waltid-libraries/protocols/waltid-openid4vc/build.gradle.kts index a0c29eecf..c829be4ae 100644 --- a/waltid-libraries/protocols/waltid-openid4vc/build.gradle.kts +++ b/waltid-libraries/protocols/waltid-openid4vc/build.gradle.kts @@ -76,7 +76,7 @@ kotlin { iosSimulatorArm64() } - val ktor_version = "2.3.12" + val ktor_version = "3.1.0" sourceSets { @@ -86,17 +86,17 @@ kotlin { val commonMain by getting { dependencies { // Coroutines - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.1") // HTTP implementation("io.ktor:ktor-client-core:$ktor_version") implementation("io.ktor:ktor-client-content-negotiation:$ktor_version") implementation("io.ktor:ktor-serialization-kotlinx-json:$ktor_version") - implementation("io.github.oshai:kotlin-logging:7.0.0") + implementation("io.github.oshai:kotlin-logging:7.0.4") // JSON - implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3") + implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.0") // walt.id implementation(project(":waltid-libraries:crypto:waltid-crypto")) @@ -111,10 +111,10 @@ kotlin { implementation("app.softwork:kotlinx-uuid-core:0.1.2") // Multiplatform / Date & time - implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.6.1") + implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.6.2") // Multiplatform / Hashes - implementation(project.dependencies.platform("org.kotlincrypto.hash:bom:0.5.3")) + implementation(project.dependencies.platform("org.kotlincrypto.hash:bom:0.6.1")) implementation("org.kotlincrypto.hash:sha2") } } @@ -124,7 +124,7 @@ kotlin { implementation(project(":waltid-libraries:crypto:waltid-crypto")) implementation(project(":waltid-libraries:waltid-did")) implementation(project(":waltid-libraries:credentials:waltid-verifiable-credentials")) - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.9.0") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.10.1") } } val jvmMain by getting { @@ -140,10 +140,10 @@ kotlin { implementation("io.kotest:kotest-runner-junit5:5.9.1") implementation("io.kotest:kotest-assertions-core:5.9.1") implementation("io.kotest:kotest-assertions-json:5.9.1") - implementation("org.junit.jupiter:junit-jupiter-params:5.11.0") - implementation("com.google.crypto.tink:tink:1.15.0") // for JOSE using Ed25519 - implementation("org.bouncycastle:bcprov-lts8on:2.73.6") // for secp256k1 (which was removed with Java 17) - implementation("org.bouncycastle:bcpkix-lts8on:2.73.6") // PEM import + implementation("org.junit.jupiter:junit-jupiter-params:5.11.4") + implementation("com.google.crypto.tink:tink:1.16.0") // for JOSE using Ed25519 + implementation("org.bouncycastle:bcprov-lts8on:2.73.7") // for secp256k1 (which was removed with Java 17) + implementation("org.bouncycastle:bcpkix-lts8on:2.73.7") // PEM import implementation("io.ktor:ktor-server-core-jvm:$ktor_version") implementation("io.ktor:ktor-server-netty-jvm:$ktor_version") @@ -156,7 +156,7 @@ kotlin { implementation("io.ktor:ktor-client-content-negotiation:$ktor_version") implementation("io.ktor:ktor-serialization-kotlinx-json:$ktor_version") implementation("io.ktor:ktor-client-logging-jvm:$ktor_version") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-slf4j:1.9.0") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-slf4j:1.10.1") implementation("io.ktor:ktor-client-okhttp:$ktor_version") implementation("com.augustcellars.cose:cose-java:1.1.0") diff --git a/waltid-libraries/sdjwt/waltid-sdjwt-ios/build.gradle.kts b/waltid-libraries/sdjwt/waltid-sdjwt-ios/build.gradle.kts index ab4167693..49e00a8fd 100644 --- a/waltid-libraries/sdjwt/waltid-sdjwt-ios/build.gradle.kts +++ b/waltid-libraries/sdjwt/waltid-sdjwt-ios/build.gradle.kts @@ -2,6 +2,7 @@ plugins { kotlin("multiplatform") kotlin("native.cocoapods") kotlin("plugin.serialization") + id("com.github.ben-manes.versions") } kotlin { diff --git a/waltid-libraries/sdjwt/waltid-sdjwt/build.gradle.kts b/waltid-libraries/sdjwt/waltid-sdjwt/build.gradle.kts index c050dccd6..f9f51c8f4 100644 --- a/waltid-libraries/sdjwt/waltid-sdjwt/build.gradle.kts +++ b/waltid-libraries/sdjwt/waltid-sdjwt/build.gradle.kts @@ -104,11 +104,11 @@ kotlin { val commonMain by getting { dependencies { implementation("dev.whyoleg.cryptography:cryptography-random:0.3.1") - implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3") - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0") - implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.6.1") + implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.0") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.1") + implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.6.2") implementation("com.soywiz.korlibs.krypto:krypto:4.0.10") - implementation("io.github.oshai:kotlin-logging:7.0.0") + implementation("io.github.oshai:kotlin-logging:7.0.4") } } val commonTest by getting { diff --git a/waltid-libraries/util/waltid-reporting/build.gradle.kts b/waltid-libraries/util/waltid-reporting/build.gradle.kts index 58a80b106..e68716e92 100644 --- a/waltid-libraries/util/waltid-reporting/build.gradle.kts +++ b/waltid-libraries/util/waltid-reporting/build.gradle.kts @@ -46,12 +46,12 @@ kotlin { } } - val ktor_version = "2.3.12" + val ktor_version = "3.1.0" sourceSets { val commonMain by getting { dependencies { // JSON - implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3") + implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.0") // Ktor client implementation("io.ktor:ktor-client-core:$ktor_version") @@ -67,20 +67,20 @@ kotlin { implementation("it.justwrote:kjob-kron:0.2.0")*/ // Coroutines - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.1") // datetime - implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.6.1") + implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.6.2") // Logging - implementation("io.github.oshai:kotlin-logging:7.0.0") + implementation("io.github.oshai:kotlin-logging:7.0.4") } } val commonTest by getting { dependencies { implementation(kotlin("test")) - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.9.0") - implementation("org.junit.jupiter:junit-jupiter-api:5.11.0") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.10.1") + implementation("org.junit.jupiter:junit-jupiter-api:5.11.4") } } val jvmMain by getting { @@ -97,7 +97,7 @@ kotlin { } val jvmTest by getting { dependencies { - implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3") + implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.0") } } publishing { diff --git a/waltid-libraries/waltid-core-wallet/build.gradle.kts b/waltid-libraries/waltid-core-wallet/build.gradle.kts index faa86686b..3f701d8bc 100644 --- a/waltid-libraries/waltid-core-wallet/build.gradle.kts +++ b/waltid-libraries/waltid-core-wallet/build.gradle.kts @@ -2,6 +2,7 @@ plugins { kotlin("multiplatform") kotlin("plugin.serialization") id("maven-publish") + id("com.github.ben-manes.versions") } group = "id.walt.wallet" @@ -18,12 +19,12 @@ kotlin { jvmToolchain(21) sourceSets { - val ktor_version = "2.3.12" + val ktor_version = "3.1.0" val commonMain by getting { dependencies { - implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3") - implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.6.1") + implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.0") + implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.6.2") implementation("io.github.oshai:kotlin-logging-jvm:7.0.0") @@ -44,8 +45,8 @@ kotlin { implementation("io.ktor:ktor-client-logging:$ktor_version") // Bouncy Castle - implementation("org.bouncycastle:bcprov-lts8on:2.73.6") - implementation("org.bouncycastle:bcpkix-lts8on:2.73.6") + implementation("org.bouncycastle:bcprov-lts8on:2.73.7") + implementation("org.bouncycastle:bcpkix-lts8on:2.73.7") // Problematic libraries: implementation("com.nimbusds:nimbus-jose-jwt:9.41.1") @@ -61,13 +62,13 @@ kotlin { val commonTest by getting { dependencies { implementation(kotlin("test")) - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.9.0") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.10.1") } } val jvmTest by getting { dependencies { - implementation("org.junit.jupiter:junit-jupiter-api:5.11.0") - implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3") + implementation("org.junit.jupiter:junit-jupiter-api:5.11.4") + implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.0") implementation("org.slf4j:slf4j-simple:2.0.16") } } diff --git a/waltid-libraries/waltid-did/build.gradle.kts b/waltid-libraries/waltid-did/build.gradle.kts index c2bf49c50..9d5deed0a 100644 --- a/waltid-libraries/waltid-did/build.gradle.kts +++ b/waltid-libraries/waltid-did/build.gradle.kts @@ -84,12 +84,12 @@ kotlin { iosSimulatorArm64() } - val ktor_version = "2.3.12" + val ktor_version = "3.1.0" sourceSets { val commonMain by getting { dependencies { // JSON - implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3") + implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.0") // Ktor client implementation("io.ktor:ktor-client-core:$ktor_version") @@ -100,10 +100,10 @@ kotlin { implementation("io.ktor:ktor-client-logging:$ktor_version") // Coroutines - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.1") // Date - implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.6.1") + implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.6.2") // Uuid implementation("app.softwork:kotlinx-uuid-core:0.1.2") @@ -112,10 +112,11 @@ kotlin { api(project(":waltid-libraries:crypto:waltid-crypto")) // Encodings - implementation("net.thauvin.erik.urlencoder:urlencoder-lib:1.5.0") + implementation("net.thauvin.erik.urlencoder:urlencoder-lib:1.6.0") // Logging - implementation("io.github.oshai:kotlin-logging:7.0.0") + implementation("io.github.oshai:kotlin-logging:7.0.4") + // suspend-transform plugin annotations (required in the current version to avoid "compileOnly" warning) implementation("${SuspendTransPluginConstants.ANNOTATION_GROUP}:${SuspendTransPluginConstants.ANNOTATION_NAME}:${SuspendTransPluginConstants.ANNOTATION_VERSION}") @@ -124,7 +125,7 @@ kotlin { val commonTest by getting { dependencies { implementation(kotlin("test")) - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.9.0") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.10.1") } } val jvmMain by getting { @@ -141,12 +142,16 @@ kotlin { } val jvmTest by getting { dependencies { - implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3") + implementation("org.slf4j:slf4j-simple:2.0.16") + + + implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.0") implementation(kotlin("test")) - implementation("org.junit.jupiter:junit-jupiter-params:5.11.0") + implementation("org.junit.jupiter:junit-jupiter-params:5.11.4") implementation("io.ktor:ktor-server-test-host:$ktor_version") implementation("io.ktor:ktor-server-content-negotiation:$ktor_version") - implementation("io.ktor:ktor-server-netty:2.3.12") + implementation("io.ktor:ktor-server-netty:$ktor_version") + implementation("io.ktor:ktor-network-tls-certificates:$ktor_version") } } val jsMain by getting { diff --git a/waltid-libraries/waltid-did/src/commonMain/kotlin/id/walt/did/dids/document/DidCheqdDocument.kt b/waltid-libraries/waltid-did/src/commonMain/kotlin/id/walt/did/dids/document/DidCheqdDocument.kt index a02f55e06..c386f0864 100644 --- a/waltid-libraries/waltid-did/src/commonMain/kotlin/id/walt/did/dids/document/DidCheqdDocument.kt +++ b/waltid-libraries/waltid-did/src/commonMain/kotlin/id/walt/did/dids/document/DidCheqdDocument.kt @@ -1,7 +1,7 @@ package id.walt.did.dids.document import id.walt.did.dids.DidUtils -import id.walt.did.dids.registrar.local.cheqd.models.job.didstates.finished.DidDocument +import id.walt.did.dids.registrar.local.cheqd.models.job.didstates.DidDocument import kotlinx.serialization.EncodeDefault import kotlinx.serialization.ExperimentalSerializationApi import kotlinx.serialization.SerialName diff --git a/waltid-libraries/waltid-did/src/commonMain/kotlin/id/walt/did/dids/registrar/local/cheqd/DidCheqdRegistrar.kt b/waltid-libraries/waltid-did/src/commonMain/kotlin/id/walt/did/dids/registrar/local/cheqd/DidCheqdRegistrar.kt index d471138d1..c94e80bd4 100644 --- a/waltid-libraries/waltid-did/src/commonMain/kotlin/id/walt/did/dids/registrar/local/cheqd/DidCheqdRegistrar.kt +++ b/waltid-libraries/waltid-did/src/commonMain/kotlin/id/walt/did/dids/registrar/local/cheqd/DidCheqdRegistrar.kt @@ -10,11 +10,11 @@ import id.walt.did.dids.registrar.dids.DidCreateOptions import id.walt.did.dids.registrar.local.LocalRegistrarMethod import id.walt.did.dids.registrar.local.cheqd.models.job.didstates.Secret import id.walt.did.dids.registrar.local.cheqd.models.job.didstates.SigningResponse -import id.walt.did.dids.registrar.local.cheqd.models.job.didstates.action.ActionDidState +import id.walt.did.dids.registrar.local.cheqd.models.job.didstates.ActionDidState import id.walt.did.dids.registrar.local.cheqd.models.job.didstates.didStateSerializationModule -import id.walt.did.dids.registrar.local.cheqd.models.job.didstates.failed.FailedDidState -import id.walt.did.dids.registrar.local.cheqd.models.job.didstates.finished.DidDocument -import id.walt.did.dids.registrar.local.cheqd.models.job.didstates.finished.FinishedDidState +import id.walt.did.dids.registrar.local.cheqd.models.job.didstates.FailedDidState +import id.walt.did.dids.registrar.local.cheqd.models.job.didstates.DidDocument +import id.walt.did.dids.registrar.local.cheqd.models.job.didstates.FinishedDidState import id.walt.did.dids.registrar.local.cheqd.models.job.request.JobCreateRequest import id.walt.did.dids.registrar.local.cheqd.models.job.request.JobDeactivateRequest import id.walt.did.dids.registrar.local.cheqd.models.job.request.JobSignRequest @@ -24,6 +24,8 @@ import io.github.oshai.kotlinlogging.KotlinLogging import io.ktor.client.* import io.ktor.client.call.* import io.ktor.client.plugins.contentnegotiation.* +import io.ktor.client.plugins.logging.LogLevel +import io.ktor.client.plugins.logging.Logging import io.ktor.client.request.* import io.ktor.client.statement.* import io.ktor.http.* @@ -68,6 +70,9 @@ class DidCheqdRegistrar : LocalRegistrarMethod("cheqd") { install(ContentNegotiation) { json(json) } + install(Logging) { + level = LogLevel.BODY + } } @JvmBlocking @@ -133,11 +138,14 @@ class DidCheqdRegistrar : LocalRegistrarMethod("cheqd") { TODO() } - private suspend fun initiateDidJob(url: String, body: JsonElement) = + private suspend fun initiateDidJob(url: String, body: JsonElement): JobActionResponse = client.post(url) { contentType(ContentType.Application.Json) setBody(body) - }.body() + }.bodyAsText().let { + log.debug { "Try parse Job action response: $it" } + json.decodeFromString(it) + } private suspend fun finalizeDidJob(url: String, jobId: String, verificationMethodId: String, signatures: List) = let { client.post(url) { diff --git a/waltid-libraries/waltid-did/src/commonMain/kotlin/id/walt/did/dids/registrar/local/cheqd/models/job/didstates/action/ActionDidState.kt b/waltid-libraries/waltid-did/src/commonMain/kotlin/id/walt/did/dids/registrar/local/cheqd/models/job/didstates/ActionDidState.kt similarity index 57% rename from waltid-libraries/waltid-did/src/commonMain/kotlin/id/walt/did/dids/registrar/local/cheqd/models/job/didstates/action/ActionDidState.kt rename to waltid-libraries/waltid-did/src/commonMain/kotlin/id/walt/did/dids/registrar/local/cheqd/models/job/didstates/ActionDidState.kt index 0f0561d3c..2c2812892 100644 --- a/waltid-libraries/waltid-did/src/commonMain/kotlin/id/walt/did/dids/registrar/local/cheqd/models/job/didstates/action/ActionDidState.kt +++ b/waltid-libraries/waltid-did/src/commonMain/kotlin/id/walt/did/dids/registrar/local/cheqd/models/job/didstates/ActionDidState.kt @@ -1,6 +1,5 @@ -package id.walt.did.dids.registrar.local.cheqd.models.job.didstates.action +package id.walt.did.dids.registrar.local.cheqd.models.job.didstates -import id.walt.did.dids.registrar.local.cheqd.models.job.didstates.DidState import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable import kotlin.js.ExperimentalJsExport @@ -17,4 +16,19 @@ data class ActionDidState( val did: String, val secret: Secret, val signingRequest: List, -) : DidState() +) : DidState() { + @OptIn(ExperimentalJsExport::class) + @Serializable + data class Secret( + val signingResponse: List, + ) + + @OptIn(ExperimentalJsExport::class) + @Serializable + data class SigningRequest( + val alg: String, + val kid: String, + val serializedPayload: String, + val type: String, + ) +} diff --git a/waltid-libraries/waltid-did/src/commonMain/kotlin/id/walt/did/dids/registrar/local/cheqd/models/job/didstates/finished/DidDocument.kt b/waltid-libraries/waltid-did/src/commonMain/kotlin/id/walt/did/dids/registrar/local/cheqd/models/job/didstates/DidDocument.kt similarity index 80% rename from waltid-libraries/waltid-did/src/commonMain/kotlin/id/walt/did/dids/registrar/local/cheqd/models/job/didstates/finished/DidDocument.kt rename to waltid-libraries/waltid-did/src/commonMain/kotlin/id/walt/did/dids/registrar/local/cheqd/models/job/didstates/DidDocument.kt index b5ee14132..e67bb49b0 100644 --- a/waltid-libraries/waltid-did/src/commonMain/kotlin/id/walt/did/dids/registrar/local/cheqd/models/job/didstates/finished/DidDocument.kt +++ b/waltid-libraries/waltid-did/src/commonMain/kotlin/id/walt/did/dids/registrar/local/cheqd/models/job/didstates/DidDocument.kt @@ -1,6 +1,5 @@ -package id.walt.did.dids.registrar.local.cheqd.models.job.didstates.finished +package id.walt.did.dids.registrar.local.cheqd.models.job.didstates -import id.walt.did.dids.registrar.local.cheqd.models.job.didstates.VerificationMethod import kotlinx.serialization.Serializable import kotlin.js.ExperimentalJsExport import kotlin.js.JsExport diff --git a/waltid-libraries/waltid-did/src/commonMain/kotlin/id/walt/did/dids/registrar/local/cheqd/models/job/didstates/DidState.kt b/waltid-libraries/waltid-did/src/commonMain/kotlin/id/walt/did/dids/registrar/local/cheqd/models/job/didstates/DidState.kt index ecd2ad571..cc130962c 100644 --- a/waltid-libraries/waltid-did/src/commonMain/kotlin/id/walt/did/dids/registrar/local/cheqd/models/job/didstates/DidState.kt +++ b/waltid-libraries/waltid-did/src/commonMain/kotlin/id/walt/did/dids/registrar/local/cheqd/models/job/didstates/DidState.kt @@ -1,8 +1,5 @@ package id.walt.did.dids.registrar.local.cheqd.models.job.didstates -import id.walt.did.dids.registrar.local.cheqd.models.job.didstates.action.ActionDidState -import id.walt.did.dids.registrar.local.cheqd.models.job.didstates.failed.FailedDidState -import id.walt.did.dids.registrar.local.cheqd.models.job.didstates.finished.FinishedDidState import kotlinx.serialization.ExperimentalSerializationApi import kotlinx.serialization.Polymorphic import kotlinx.serialization.Serializable @@ -15,10 +12,10 @@ import kotlin.js.JsExport @OptIn(ExperimentalJsExport::class, ExperimentalSerializationApi::class) @JsExport -@Polymorphic +//@Polymorphic @Serializable @JsonClassDiscriminator("state") -abstract class DidState { +sealed class DidState { abstract val state: String } diff --git a/waltid-libraries/waltid-did/src/commonMain/kotlin/id/walt/did/dids/registrar/local/cheqd/models/job/didstates/failed/FailedDidState.kt b/waltid-libraries/waltid-did/src/commonMain/kotlin/id/walt/did/dids/registrar/local/cheqd/models/job/didstates/FailedDidState.kt similarity index 82% rename from waltid-libraries/waltid-did/src/commonMain/kotlin/id/walt/did/dids/registrar/local/cheqd/models/job/didstates/failed/FailedDidState.kt rename to waltid-libraries/waltid-did/src/commonMain/kotlin/id/walt/did/dids/registrar/local/cheqd/models/job/didstates/FailedDidState.kt index 5bc65b1ca..f2377d276 100644 --- a/waltid-libraries/waltid-did/src/commonMain/kotlin/id/walt/did/dids/registrar/local/cheqd/models/job/didstates/failed/FailedDidState.kt +++ b/waltid-libraries/waltid-did/src/commonMain/kotlin/id/walt/did/dids/registrar/local/cheqd/models/job/didstates/FailedDidState.kt @@ -1,6 +1,5 @@ -package id.walt.did.dids.registrar.local.cheqd.models.job.didstates.failed +package id.walt.did.dids.registrar.local.cheqd.models.job.didstates -import id.walt.did.dids.registrar.local.cheqd.models.job.didstates.DidState import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable import kotlin.js.ExperimentalJsExport diff --git a/waltid-libraries/waltid-did/src/commonMain/kotlin/id/walt/did/dids/registrar/local/cheqd/models/job/didstates/finished/FinishedDidState.kt b/waltid-libraries/waltid-did/src/commonMain/kotlin/id/walt/did/dids/registrar/local/cheqd/models/job/didstates/FinishedDidState.kt similarity index 73% rename from waltid-libraries/waltid-did/src/commonMain/kotlin/id/walt/did/dids/registrar/local/cheqd/models/job/didstates/finished/FinishedDidState.kt rename to waltid-libraries/waltid-did/src/commonMain/kotlin/id/walt/did/dids/registrar/local/cheqd/models/job/didstates/FinishedDidState.kt index 2d39909f6..6e2ac2234 100644 --- a/waltid-libraries/waltid-did/src/commonMain/kotlin/id/walt/did/dids/registrar/local/cheqd/models/job/didstates/finished/FinishedDidState.kt +++ b/waltid-libraries/waltid-did/src/commonMain/kotlin/id/walt/did/dids/registrar/local/cheqd/models/job/didstates/FinishedDidState.kt @@ -1,7 +1,5 @@ -package id.walt.did.dids.registrar.local.cheqd.models.job.didstates.finished +package id.walt.did.dids.registrar.local.cheqd.models.job.didstates -import id.walt.did.dids.registrar.local.cheqd.models.job.didstates.DidState -import id.walt.did.dids.registrar.local.cheqd.models.job.didstates.Secret import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable import kotlin.js.ExperimentalJsExport diff --git a/waltid-libraries/waltid-did/src/commonMain/kotlin/id/walt/did/dids/registrar/local/cheqd/models/job/didstates/action/Secret.kt b/waltid-libraries/waltid-did/src/commonMain/kotlin/id/walt/did/dids/registrar/local/cheqd/models/job/didstates/action/Secret.kt deleted file mode 100644 index fdce134bc..000000000 --- a/waltid-libraries/waltid-did/src/commonMain/kotlin/id/walt/did/dids/registrar/local/cheqd/models/job/didstates/action/Secret.kt +++ /dev/null @@ -1,12 +0,0 @@ -package id.walt.did.dids.registrar.local.cheqd.models.job.didstates.action - -import kotlinx.serialization.Serializable -import kotlin.js.ExperimentalJsExport -import kotlin.js.JsExport - -@OptIn(ExperimentalJsExport::class) -@JsExport -@Serializable -data class Secret( - val signingResponse: List, -) diff --git a/waltid-libraries/waltid-did/src/commonMain/kotlin/id/walt/did/dids/registrar/local/cheqd/models/job/didstates/action/SigningRequest.kt b/waltid-libraries/waltid-did/src/commonMain/kotlin/id/walt/did/dids/registrar/local/cheqd/models/job/didstates/action/SigningRequest.kt deleted file mode 100644 index 30dc599a2..000000000 --- a/waltid-libraries/waltid-did/src/commonMain/kotlin/id/walt/did/dids/registrar/local/cheqd/models/job/didstates/action/SigningRequest.kt +++ /dev/null @@ -1,15 +0,0 @@ -package id.walt.did.dids.registrar.local.cheqd.models.job.didstates.action - -import kotlinx.serialization.Serializable -import kotlin.js.ExperimentalJsExport -import kotlin.js.JsExport - -@OptIn(ExperimentalJsExport::class) -@JsExport -@Serializable -data class SigningRequest( - val alg: String, - val kid: String, - val serializedPayload: String, - val type: String, -) diff --git a/waltid-libraries/waltid-did/src/commonMain/kotlin/id/walt/did/dids/resolver/local/DidCheqdResolver.kt b/waltid-libraries/waltid-did/src/commonMain/kotlin/id/walt/did/dids/resolver/local/DidCheqdResolver.kt index e6d7b53bd..f0a20c5e1 100644 --- a/waltid-libraries/waltid-did/src/commonMain/kotlin/id/walt/did/dids/resolver/local/DidCheqdResolver.kt +++ b/waltid-libraries/waltid-did/src/commonMain/kotlin/id/walt/did/dids/resolver/local/DidCheqdResolver.kt @@ -58,7 +58,7 @@ class DidCheqdResolver : LocalResolverMethod("cheqd") { resolution.jsonObject["didDocument"]?.jsonObject ?: throw IllegalArgumentException("Response for did:cheqd did not contain a DID document!") }.let { - json.decodeFromString( + json.decodeFromString( it.toString() ) } diff --git a/waltid-libraries/waltid-did/src/jvmTest/kotlin/LocalDidWebConsistencyTest.kt b/waltid-libraries/waltid-did/src/jvmTest/kotlin/LocalDidWebConsistencyTest.kt index 8bbe1a80f..02ac18b8e 100644 --- a/waltid-libraries/waltid-did/src/jvmTest/kotlin/LocalDidWebConsistencyTest.kt +++ b/waltid-libraries/waltid-did/src/jvmTest/kotlin/LocalDidWebConsistencyTest.kt @@ -43,7 +43,7 @@ class LocalDidWebConsistencyTest { private val didWebTestEntryList: List private val didWebPathToDocMap = mutableMapOf() - private val didWebTestServer: NettyApplicationEngine + private val didWebTestServer: EmbeddedServer private val keyStoreFile = File(this.javaClass.classLoader.getResource("")!!.path.plus("keystore.jks")) private val keyStore = buildKeyStore { @@ -53,16 +53,14 @@ class LocalDidWebConsistencyTest { subject = X500Principal("CN=localhost, OU=walt.id, O=walt.id, C=AT") } }.also { it.saveToFile(keyStoreFile, "test123") } - private val environment = applicationEngineEnvironment { - envConfig() - } init { didWebTestEntryList = populateTestData() + didWebTestServer = embeddedServer( - Netty, - environment, - ).start(false) + Netty, applicationEnvironment(), { envConfig() }, + module = { module() } + ).start(wait = false) } @AfterTest @@ -102,10 +100,7 @@ class LocalDidWebConsistencyTest { } } - private fun ApplicationEngineEnvironmentBuilder.envConfig() { - module { - module() - } + private fun ApplicationEngine.Configuration.envConfig() { connector { port = 8000 } diff --git a/waltid-libraries/waltid-did/src/jvmTest/kotlin/TestServer.kt b/waltid-libraries/waltid-did/src/jvmTest/kotlin/TestServer.kt index 4a2e84e19..c0b1d1453 100644 --- a/waltid-libraries/waltid-did/src/jvmTest/kotlin/TestServer.kt +++ b/waltid-libraries/waltid-did/src/jvmTest/kotlin/TestServer.kt @@ -35,12 +35,10 @@ object TestServer { subject = X500Principal("CN=localhost, OU=walt.id, O=walt.id, C=AT") } }.also { it.saveToFile(keyStoreFile, "test123") } - private val environment = applicationEngineEnvironment { - envConfig() - } - val server: ApplicationEngine by lazy { + + val server: EmbeddedServer by lazy { println("Initializing embedded webserver...") - embeddedServer(Netty, environment) + embeddedServer(Netty, applicationEnvironment(), { envConfig() }, module = { module() }) } private fun Application.module() { @@ -63,10 +61,7 @@ object TestServer { } } - private fun ApplicationEngineEnvironmentBuilder.envConfig() { - module { - module() - } + private fun ApplicationEngine.Configuration.envConfig() { connector { port = 8000 } diff --git a/waltid-libraries/waltid-did/src/jvmTest/kotlin/registrars/DidCheqdRegistrarTest.kt b/waltid-libraries/waltid-did/src/jvmTest/kotlin/registrars/DidCheqdRegistrarTest.kt index b42ed3d04..98cb33988 100644 --- a/waltid-libraries/waltid-did/src/jvmTest/kotlin/registrars/DidCheqdRegistrarTest.kt +++ b/waltid-libraries/waltid-did/src/jvmTest/kotlin/registrars/DidCheqdRegistrarTest.kt @@ -12,9 +12,11 @@ import org.junit.jupiter.params.provider.Arguments import org.junit.jupiter.params.provider.Arguments.arguments import org.junit.jupiter.params.provider.MethodSource import java.util.stream.Stream +import kotlin.test.Ignore class DidCheqdRegistrarTest : DidRegistrarTestBase(DidCheqdRegistrar()) { + @Ignore @ParameterizedTest @MethodSource override fun `given did options with no key when register then returns a valid did result`( @@ -24,6 +26,7 @@ class DidCheqdRegistrarTest : DidRegistrarTestBase(DidCheqdRegistrar()) { super.`given did options with no key when register then returns a valid did result`(options, assert) } + @Ignore @ParameterizedTest @MethodSource override fun `given did options and key when register with key then returns a valid did result`( diff --git a/waltid-libraries/waltid-did/src/jvmTest/resources/simplelogger.properties b/waltid-libraries/waltid-did/src/jvmTest/resources/simplelogger.properties new file mode 100644 index 000000000..27efa1cfe --- /dev/null +++ b/waltid-libraries/waltid-did/src/jvmTest/resources/simplelogger.properties @@ -0,0 +1,4 @@ +org.slf4j.simpleLogger.showDateTime=true + +org.slf4j.simpleLogger.defaultLogLevel=debug +org.slf4j.simpleLogger.log.id.walt=trace diff --git a/waltid-libraries/waltid-java-compat/build.gradle.kts b/waltid-libraries/waltid-java-compat/build.gradle.kts index 8d2e52eff..1267226e0 100644 --- a/waltid-libraries/waltid-java-compat/build.gradle.kts +++ b/waltid-libraries/waltid-java-compat/build.gradle.kts @@ -2,6 +2,7 @@ plugins { kotlin("jvm") id("maven-publish") //`maven-publish` + id("com.github.ben-manes.versions") } group = "id.walt" diff --git a/waltid-libraries/waltid-library-commons/build.gradle.kts b/waltid-libraries/waltid-library-commons/build.gradle.kts index 561a4a906..93a1cfba6 100644 --- a/waltid-libraries/waltid-library-commons/build.gradle.kts +++ b/waltid-libraries/waltid-library-commons/build.gradle.kts @@ -105,7 +105,7 @@ kotlin { dependencies { implementation(kotlin("test-common")) implementation(kotlin("test-annotations-common")) - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.8.1") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.10.1") } } val jvmMain by getting { diff --git a/waltid-services/waltid-e2e-tests/build.gradle.kts b/waltid-services/waltid-e2e-tests/build.gradle.kts index 4227f1835..1e90cf72c 100644 --- a/waltid-services/waltid-e2e-tests/build.gradle.kts +++ b/waltid-services/waltid-e2e-tests/build.gradle.kts @@ -3,6 +3,7 @@ import org.jetbrains.kotlin.gradle.ExperimentalKotlinGradlePluginApi plugins { kotlin("jvm") kotlin("plugin.power-assert") + id("com.github.ben-manes.versions") } group = "id.walt" @@ -15,11 +16,11 @@ repositories { dependencies { // Testing testImplementation(kotlin("test")) - testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test-jvm:1.9.0") - testImplementation("io.ktor:ktor-server-test-host:2.3.12") - testImplementation("io.ktor:ktor-client-cio:2.3.12") - testImplementation("io.ktor:ktor-client-content-negotiation:2.3.12") - testImplementation("io.ktor:ktor-client-logging:2.3.12") + testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test-jvm:1.10.1") + testImplementation("io.ktor:ktor-server-test-host:3.1.0") + testImplementation("io.ktor:ktor-client-cio:3.1.0") + testImplementation("io.ktor:ktor-client-content-negotiation:3.1.0") + testImplementation("io.ktor:ktor-client-logging:3.1.0") // Command line formatting @@ -34,10 +35,10 @@ dependencies { testImplementation("app.softwork:kotlinx-uuid-core:0.1.2") testImplementation("com.nimbusds:nimbus-jose-jwt:9.37.3") testImplementation("com.augustcellars.cose:cose-java:1.1.0") - testImplementation("org.bouncycastle:bcpkix-lts8on:2.73.6") + testImplementation("org.bouncycastle:bcpkix-lts8on:2.73.7") // Multiplatform / Hashes - testImplementation(project.dependencies.platform("org.kotlincrypto.hash:bom:0.5.3")) + testImplementation(project.dependencies.platform("org.kotlincrypto.hash:bom:0.6.1")) testImplementation("org.kotlincrypto.hash:sha2") } diff --git a/waltid-services/waltid-issuer-api/build.gradle.kts b/waltid-services/waltid-issuer-api/build.gradle.kts index dc9ae9420..81998403e 100644 --- a/waltid-services/waltid-issuer-api/build.gradle.kts +++ b/waltid-services/waltid-issuer-api/build.gradle.kts @@ -3,7 +3,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import java.util.Properties object Versions { - const val KTOR_VERSION = "2.3.12" // also change 1 plugin + const val KTOR_VERSION = "3.1.0" // also change 1 plugin const val COROUTINES_VERSION = "1.9.0" const val HOPLITE_VERSION = "2.8.0" } @@ -12,7 +12,7 @@ plugins { kotlin("jvm") kotlin("plugin.serialization") - id("io.ktor.plugin") version "2.3.12" // Versions.KTOR_VERSION + id("io.ktor.plugin") version "3.1.0" // Versions.KTOR_VERSION id("org.owasp.dependencycheck") version "9.2.0" id("com.github.jk1.dependency-license-report") version "2.9" id("com.github.ben-manes.versions") @@ -66,7 +66,7 @@ dependencies { implementation("io.ktor:ktor-serialization-kotlinx-json-jvm:${Versions.KTOR_VERSION}") // Date - implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.6.1") + implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.6.2") // Coroutines implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:${Versions.COROUTINES_VERSION}") @@ -80,8 +80,8 @@ dependencies { // Logging implementation("io.github.oshai:kotlin-logging-jvm:7.0.0") implementation("org.slf4j:jul-to-slf4j:2.0.16") - implementation("io.klogging:klogging-jvm:0.7.2") - implementation("io.klogging:slf4j-klogging:0.7.2") + implementation("io.klogging:klogging-jvm:0.9.1") + implementation("io.klogging:slf4j-klogging:0.9.1") // Test testImplementation(kotlin("test")) @@ -106,7 +106,7 @@ dependencies { implementation("com.nimbusds:nimbus-jose-jwt:9.41.1") // Multiplatform / Hashes - testImplementation(project.dependencies.platform("org.kotlincrypto.hash:bom:0.5.3")) + testImplementation(project.dependencies.platform("org.kotlincrypto.hash:bom:0.6.1")) testImplementation("org.kotlincrypto.hash:sha2") } diff --git a/waltid-services/waltid-issuer-api/src/main/kotlin/id/walt/issuer/NewTestOidcMetadata.kt b/waltid-services/waltid-issuer-api/src/main/kotlin/id/walt/issuer/NewTestOidcMetadata.kt index a06b2d74e..1626b8da4 100644 --- a/waltid-services/waltid-issuer-api/src/main/kotlin/id/walt/issuer/NewTestOidcMetadata.kt +++ b/waltid-services/waltid-issuer-api/src/main/kotlin/id/walt/issuer/NewTestOidcMetadata.kt @@ -8,7 +8,7 @@ import io.ktor.serialization.kotlinx.json.* import io.ktor.server.application.* import io.ktor.server.cio.* import io.ktor.server.engine.* -import io.ktor.server.plugins.callloging.* +import io.ktor.server.plugins.calllogging.* import io.ktor.server.plugins.contentnegotiation.* import io.ktor.server.response.* import io.ktor.server.routing.* diff --git a/waltid-services/waltid-issuer-api/src/main/kotlin/id/walt/issuer/entra/EntraIssuanceApi.kt b/waltid-services/waltid-issuer-api/src/main/kotlin/id/walt/issuer/entra/EntraIssuanceApi.kt index 8bf369459..76a3ca931 100644 --- a/waltid-services/waltid-issuer-api/src/main/kotlin/id/walt/issuer/entra/EntraIssuanceApi.kt +++ b/waltid-services/waltid-issuer-api/src/main/kotlin/id/walt/issuer/entra/EntraIssuanceApi.kt @@ -85,11 +85,11 @@ fun Application.entraIssuance() { body() } }) { - val req = context.receive() + val req = call.receive() val url = EntraIssuanceApi.entraIssuance(req.authorization, req.data) - context.respond(url) + call.respond(url) } } } diff --git a/waltid-services/waltid-issuer-api/src/main/kotlin/id/walt/issuer/issuance/IssuerApi.kt b/waltid-services/waltid-issuer-api/src/main/kotlin/id/walt/issuer/issuance/IssuerApi.kt index 7e0a3efc6..a262f81f1 100644 --- a/waltid-services/waltid-issuer-api/src/main/kotlin/id/walt/issuer/issuance/IssuerApi.kt +++ b/waltid-services/waltid-issuer-api/src/main/kotlin/id/walt/issuer/issuance/IssuerApi.kt @@ -24,8 +24,6 @@ import kotlinx.serialization.json.JsonObject import kotlinx.serialization.json.JsonPrimitive import kotlinx.serialization.json.jsonObject import kotlinx.serialization.json.jsonPrimitive -import redis.clients.jedis.exceptions.JedisAccessControlException -import redis.clients.jedis.exceptions.JedisConnectionException import kotlin.reflect.KClass import kotlin.time.Duration import kotlin.time.Duration.Companion.minutes @@ -40,7 +38,9 @@ suspend fun createCredentialOfferUri( val overwrittenIssuanceRequests = issuanceRequests.map { it.copy( credentialFormat = credentialFormat, - vct = if (credentialFormat == CredentialFormat.sd_jwt_vc) OidcApi.metadata.getVctByCredentialConfigurationId(it.credentialConfigurationId) ?: throw IllegalArgumentException("VCT not found") else null) + vct = if (credentialFormat == CredentialFormat.sd_jwt_vc) OidcApi.metadata.getVctByCredentialConfigurationId(it.credentialConfigurationId) + ?: throw IllegalArgumentException("VCT not found") else null + ) } val issuanceSession = OidcApi.initializeCredentialOffer( @@ -166,7 +166,7 @@ fun Application.issuerApi() { } } }) { - val req = context.receive() + val req = call.receive() val keyConfig = req.key.config?.mapValues { (key, value) -> if (key == "signingKeyPem") { JsonPrimitive(value.jsonPrimitive.content.trimIndent().replace(" ", "")) @@ -200,7 +200,7 @@ fun Application.issuerApi() { } else { serializedKey } - context.respond( + call.respond( HttpStatusCode.OK, IssuerOnboardingResponse(issuanceKey, did) ) } @@ -213,7 +213,7 @@ fun Application.issuerApi() { required = false } - fun PipelineContext.getCallbackUriHeader() = context.request.header("statusCallbackUri") + fun RoutingContext.getCallbackUriHeader() = call.request.header("statusCallbackUri") route("raw") { route("jwt") { @@ -266,15 +266,10 @@ fun Application.issuerApi() { } } }) { - - runCatching { - val body = context.receive() - validateRawSignatureRequest(body) - val signedCredential = executeCredentialSigning(body) - context.respond(HttpStatusCode.OK, signedCredential) - }.onFailure { - throwError(it) - } + val body = call.receive() + validateRawSignatureRequest(body) + val signedCredential = executeCredentialSigning(body) + call.respond(HttpStatusCode.OK, signedCredential) } } } @@ -344,14 +339,14 @@ fun Application.issuerApi() { } } }) { - runCatching { - val jwtIssuanceRequest = context.receive() - val offerUri = createCredentialOfferUri(listOf(jwtIssuanceRequest), getFormatByCredentialConfigurationId(jwtIssuanceRequest.credentialConfigurationId) ?: throw IllegalArgumentException("Invalid Credential Configuration Id"), getCallbackUriHeader()) - context.respond(HttpStatusCode.OK, offerUri) - }.onFailure { - throwError(it) - } - + val jwtIssuanceRequest = call.receive() + val offerUri = createCredentialOfferUri( + listOf(jwtIssuanceRequest), + getFormatByCredentialConfigurationId(jwtIssuanceRequest.credentialConfigurationId) + ?: throw IllegalArgumentException("Invalid Credential Configuration Id"), + getCallbackUriHeader() + ) + call.respond(HttpStatusCode.OK, offerUri) } post("issueBatch", { summary = "Signs a list of credentials and starts an OIDC credential exchange flow." @@ -380,16 +375,15 @@ fun Application.issuerApi() { } } }) { - - - runCatching { - val issuanceRequests = context.receive>() - val offerUri = createCredentialOfferUri(issuanceRequests, getFormatByCredentialConfigurationId(issuanceRequests.first().credentialConfigurationId) ?: throw IllegalArgumentException("Invalid Credential Configuration Id"), getCallbackUriHeader()) - logger.debug { "Offer URI: $offerUri" } - context.respond(HttpStatusCode.OK, offerUri) - }.onFailure { - throwError(it) - } + val issuanceRequests = call.receive>() + val offerUri = createCredentialOfferUri( + issuanceRequests, + getFormatByCredentialConfigurationId(issuanceRequests.first().credentialConfigurationId) + ?: throw IllegalArgumentException("Invalid Credential Configuration Id"), + getCallbackUriHeader() + ) + logger.debug { "Offer URI: $offerUri" } + call.respond(HttpStatusCode.OK, offerUri) } } @@ -407,7 +401,10 @@ fun Application.issuerApi() { example("W3C SD-JWT example", IssuanceExamples.sdJwtW3CExample) example("W3C SD-JWT PDA1 example", IssuanceExamples.sdJwtW3CPDA1Example) example("SD-JWT-VC example", IssuanceExamples.sdJwtVCExample) - example("SD-JWT-VC example featuring selectively disclosable sub and iat claims", IssuanceExamples.sdJwtVCExampleWithSDSub) + example( + "SD-JWT-VC example featuring selectively disclosable sub and iat claims", + IssuanceExamples.sdJwtVCExampleWithSDSub + ) example("SD-JWT-VC example with issuer DID", IssuanceExamples.sdJwtVCWithIssuerDidExample) required = true } @@ -425,20 +422,17 @@ fun Application.issuerApi() { } } }) { - runCatching { - val sdJwtIssuanceRequest = context.receive() - val offerUri = createCredentialOfferUri( - listOf(sdJwtIssuanceRequest), - getFormatByCredentialConfigurationId(sdJwtIssuanceRequest.credentialConfigurationId) ?: throw IllegalArgumentException("Invalid Credential Configuration Id"), - getCallbackUriHeader() - ) + val sdJwtIssuanceRequest = call.receive() + val offerUri = createCredentialOfferUri( + listOf(sdJwtIssuanceRequest), + getFormatByCredentialConfigurationId(sdJwtIssuanceRequest.credentialConfigurationId) + ?: throw IllegalArgumentException("Invalid Credential Configuration Id"), + getCallbackUriHeader() + ) - context.respond( - HttpStatusCode.OK, offerUri - ) - }.onFailure { - throwError(it) - } + call.respond( + HttpStatusCode.OK, offerUri + ) } post("issueBatch", { @@ -468,25 +462,20 @@ fun Application.issuerApi() { } } }) { + val sdJwtIssuanceRequests = call.receive>() + val offerUri = + createCredentialOfferUri( + sdJwtIssuanceRequests, + getFormatByCredentialConfigurationId(sdJwtIssuanceRequests.first().credentialConfigurationId) + ?: throw IllegalArgumentException("Invalid Credential Configuration Id"), + getCallbackUriHeader() + ) + logger.debug { "Offer URI: $offerUri" } - runCatching { - val sdJwtIssuanceRequests = context.receive>() - val offerUri = - createCredentialOfferUri( - sdJwtIssuanceRequests, - getFormatByCredentialConfigurationId(sdJwtIssuanceRequests.first().credentialConfigurationId) ?: throw IllegalArgumentException("Invalid Credential Configuration Id"), - getCallbackUriHeader() - ) - - logger.debug { "Offer URI: $offerUri" } - - context.respond( - HttpStatusCode.OK, offerUri - ) - }.onFailure { - throwError(it) - } + call.respond( + HttpStatusCode.OK, offerUri + ) } } @@ -504,13 +493,15 @@ fun Application.issuerApi() { } } }) { - val mdocIssuanceRequest = context.receive() + val mdocIssuanceRequest = call.receive() val offerUri = createCredentialOfferUri( listOf(mdocIssuanceRequest), - getFormatByCredentialConfigurationId(mdocIssuanceRequest.credentialConfigurationId) ?: throw IllegalArgumentException("Invalid Credential Configuration Id"), - getCallbackUriHeader()) + getFormatByCredentialConfigurationId(mdocIssuanceRequest.credentialConfigurationId) + ?: throw IllegalArgumentException("Invalid Credential Configuration Id"), + getCallbackUriHeader() + ) - context.respond( + call.respond( HttpStatusCode.OK, offerUri ) } @@ -521,24 +512,6 @@ fun Application.issuerApi() { } } -private suspend fun PipelineContext.throwError( - it: Throwable -) { - when (it) { - is JedisConnectionException -> context.respond( - HttpStatusCode.InternalServerError, - "Distributed session management couldn't be initialized : Cannot connect to redis server." - ) - - is JedisAccessControlException -> context.respond( - HttpStatusCode.InternalServerError, - "Distributed session management couldn't be initialized : Cannot access redis server, wrong username/password." - ) - - else -> throw it - } -} - private fun validateRawSignatureRequest(body: JsonObject) { requireNotNull(body["issuerKey"]?.jsonObject) { "Missing issuerKey in the request body." } requireNotNull(body["subjectDid"]?.jsonPrimitive?.content) { "Missing subjectDid in the request body." } diff --git a/waltid-services/waltid-issuer-api/src/main/kotlin/id/walt/issuer/issuance/OidcApi.kt b/waltid-services/waltid-issuer-api/src/main/kotlin/id/walt/issuer/issuance/OidcApi.kt index 20aea5910..235e5eea1 100644 --- a/waltid-services/waltid-issuer-api/src/main/kotlin/id/walt/issuer/issuance/OidcApi.kt +++ b/waltid-services/waltid-issuer-api/src/main/kotlin/id/walt/issuer/issuance/OidcApi.kt @@ -435,7 +435,7 @@ object OidcApi : CIProvider() { ) } - context.respond(credentialOffer.toJSON()) + call.respond(credentialOffer.toJSON()) } post("{standardVersion}/credential") { diff --git a/waltid-services/waltid-issuer-api/src/main/kotlin/id/walt/issuer/issuance2/NewApiStub.kt b/waltid-services/waltid-issuer-api/src/main/kotlin/id/walt/issuer/issuance2/NewApiStub.kt index 906e3aabb..025f67a1c 100644 --- a/waltid-services/waltid-issuer-api/src/main/kotlin/id/walt/issuer/issuance2/NewApiStub.kt +++ b/waltid-services/waltid-issuer-api/src/main/kotlin/id/walt/issuer/issuance2/NewApiStub.kt @@ -38,7 +38,7 @@ object NewApiStub { } } }) { - val issuanceRequest = context.receive() + val issuanceRequest = call.receive() IssuanceOfferManager.makeOfferFor(issuanceRequest) } } diff --git a/waltid-services/waltid-issuer-api/src/main/kotlin/id/walt/issuer/lspPotential/LspPotentialIssuanceInterop.kt b/waltid-services/waltid-issuer-api/src/main/kotlin/id/walt/issuer/lspPotential/LspPotentialIssuanceInterop.kt index 893bec1ed..e9a154fb5 100644 --- a/waltid-services/waltid-issuer-api/src/main/kotlin/id/walt/issuer/lspPotential/LspPotentialIssuanceInterop.kt +++ b/waltid-services/waltid-issuer-api/src/main/kotlin/id/walt/issuer/lspPotential/LspPotentialIssuanceInterop.kt @@ -56,7 +56,7 @@ fun Application.lspPotentialIssuanceTestApi() { val offerUri = LspPotentialIssuanceInterop.createInteropSampleCredentialOfferUrimDL( IssuanceExamples.mDLCredentialIssuanceData ) - context.respond( + call.respond( HttpStatusCode.OK, offerUri ) } @@ -64,7 +64,7 @@ fun Application.lspPotentialIssuanceTestApi() { val offerUri = LspPotentialIssuanceInterop.createInteropSampleCredentialOfferUriSdJwt( IssuanceExamples.sdJwtVCData ) - context.respond( + call.respond( HttpStatusCode.OK, offerUri ) } diff --git a/waltid-services/waltid-issuer-api/src/main/kotlin/id/walt/issuer/web/plugins/Monitoring.kt b/waltid-services/waltid-issuer-api/src/main/kotlin/id/walt/issuer/web/plugins/Monitoring.kt index d78ac1aea..7b8e86aea 100644 --- a/waltid-services/waltid-issuer-api/src/main/kotlin/id/walt/issuer/web/plugins/Monitoring.kt +++ b/waltid-services/waltid-issuer-api/src/main/kotlin/id/walt/issuer/web/plugins/Monitoring.kt @@ -4,7 +4,8 @@ import io.ktor.http.* import io.ktor.server.application.* import io.ktor.server.plugins.* import io.ktor.server.plugins.callid.* -import io.ktor.server.plugins.callloging.* +import io.ktor.server.plugins.calllogging.CallLogging +import io.ktor.server.plugins.calllogging.processingTimeMillis import io.ktor.server.request.* import org.slf4j.event.Level diff --git a/waltid-services/waltid-service-commons-test/build.gradle.kts b/waltid-services/waltid-service-commons-test/build.gradle.kts index cda32d352..e8e899a28 100644 --- a/waltid-services/waltid-service-commons-test/build.gradle.kts +++ b/waltid-services/waltid-service-commons-test/build.gradle.kts @@ -3,7 +3,7 @@ plugins { kotlin("plugin.serialization") id("maven-publish") - id("com.github.ben-manes.versions") version "0.52.0" + id("com.github.ben-manes.versions") } group = "id.walt" @@ -14,7 +14,7 @@ repositories { } object Versions { - const val KTOR_VERSION = "2.3.12" // also change 1 plugin + const val KTOR_VERSION = "3.1.0" // also change 1 plugin } dependencies { @@ -23,7 +23,7 @@ dependencies { // Testing api(kotlin("test")) api("io.ktor:ktor-server-test-host:${Versions.KTOR_VERSION}") - api("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.9.0") + api("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.10.1") implementation("io.ktor:ktor-client-okhttp-jvm:${Versions.KTOR_VERSION}") implementation("io.ktor:ktor-client-content-negotiation:${Versions.KTOR_VERSION}") diff --git a/waltid-services/waltid-service-commons/build.gradle.kts b/waltid-services/waltid-service-commons/build.gradle.kts index 0aa13b78a..0992040f2 100644 --- a/waltid-services/waltid-service-commons/build.gradle.kts +++ b/waltid-services/waltid-service-commons/build.gradle.kts @@ -3,7 +3,7 @@ plugins { kotlin("plugin.serialization") id("maven-publish") - id("com.github.ben-manes.versions") version "0.52.0" + id("com.github.ben-manes.versions") } group = "id.walt" @@ -14,7 +14,7 @@ repositories { } object Versions { - const val KTOR_VERSION = "2.3.12" // also change 1 plugin + const val KTOR_VERSION = "3.1.0" // also change 1 plugin } dependencies { @@ -30,12 +30,12 @@ dependencies { implementation("io.ktor:ktor-client-okhttp-jvm:${Versions.KTOR_VERSION}") // Logging - api("io.klogging:klogging-jvm:0.7.2") // JVM + ~JS - implementation("io.klogging:slf4j-klogging:0.7.2") + api("io.klogging:klogging-jvm:0.9.1") // JVM + ~JS + implementation("io.klogging:slf4j-klogging:0.9.1") implementation("org.slf4j:jul-to-slf4j:2.0.16") // CLI - api("com.github.ajalt.clikt:clikt:5.0.1") // JVM + api("com.github.ajalt.clikt:clikt:5.0.3") // JVM // Config api("com.sksamuel.hoplite:hoplite-core:2.8.2") @@ -43,17 +43,17 @@ dependencies { api("com.sksamuel.hoplite:hoplite-hikaricp:2.8.2") // Kotlinx.serialization - api("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3") + api("org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.0") // Health checks - api("com.sksamuel.cohort:cohort-ktor:2.5.1") + api("com.sksamuel.cohort:cohort-ktor:2.6.1") // OpenAPI - api("io.github.smiley4:ktor-swagger-ui:3.5.1") - implementation("io.github.smiley4:schema-kenerator-core:1.4.1") + api("io.github.smiley4:ktor-swagger-ui:4.1.6") + /*implementation("io.github.smiley4:schema-kenerator-core:1.4.1") implementation("io.github.smiley4:schema-kenerator-serialization:1.4.1") implementation("io.github.smiley4:schema-kenerator-reflection:1.4.1") - implementation("io.github.smiley4:schema-kenerator-swagger:1.4.1") + implementation("io.github.smiley4:schema-kenerator-swagger:1.4.1")*/ // Persistence api("io.github.reactivecircus.cache4k:cache4k:0.13.0") @@ -62,8 +62,8 @@ dependencies { // Testing testApi(kotlin("test")) - testApi("io.ktor:ktor-server-test-host:2.3.12") - testApi("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.9.0") + testApi("io.ktor:ktor-server-test-host:3.1.0") + testApi("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.10.1") } tasks.test { diff --git a/waltid-services/waltid-service-commons/src/main/kotlin/id/walt/commons/logging/setups/TraceLoggingSetup.kt b/waltid-services/waltid-service-commons/src/main/kotlin/id/walt/commons/logging/setups/TraceLoggingSetup.kt index 91ae6efe8..0a88ab1b5 100644 --- a/waltid-services/waltid-service-commons/src/main/kotlin/id/walt/commons/logging/setups/TraceLoggingSetup.kt +++ b/waltid-services/waltid-service-commons/src/main/kotlin/id/walt/commons/logging/setups/TraceLoggingSetup.kt @@ -16,7 +16,7 @@ data object TraceLoggingSetup : LoggingSetup("trace", { } } logging { - fromLoggerBase("io.ktor.routing.Routing", stopOnMatch = true) + fromLoggerBase("io.ktor", stopOnMatch = true) fromMinLevel(Level.DEBUG) { toSink("stdout") } diff --git a/waltid-services/waltid-service-commons/src/main/kotlin/id/walt/commons/web/modules/FeatureFlagInformationModule.kt b/waltid-services/waltid-service-commons/src/main/kotlin/id/walt/commons/web/modules/FeatureFlagInformationModule.kt index fa39e86f7..418b52596 100644 --- a/waltid-services/waltid-service-commons/src/main/kotlin/id/walt/commons/web/modules/FeatureFlagInformationModule.kt +++ b/waltid-services/waltid-service-commons/src/main/kotlin/id/walt/commons/web/modules/FeatureFlagInformationModule.kt @@ -39,7 +39,7 @@ object FeatureFlagInformationModule { } } }) { - context.respond(FeatureManager.registeredFeatures.mapValues { it.value.description }) + call.respond(FeatureManager.registeredFeatures.mapValues { it.value.description }) } get("state", { summary = "Show state of features" @@ -57,7 +57,7 @@ object FeatureFlagInformationModule { val defaulted = registered.keys.subtract(enabled.keys).subtract(disabled.keys) .associateWith { registered[it]!!.description } - context.respond( + call.respond( FeatureFlagInformations( enabled = FeatureFlagInformation(enabled), disabled = FeatureFlagInformation(disabled), diff --git a/waltid-services/waltid-service-commons/src/main/kotlin/id/walt/commons/web/modules/OpenApiModule.kt b/waltid-services/waltid-service-commons/src/main/kotlin/id/walt/commons/web/modules/OpenApiModule.kt index 04e7f57c3..14d70ccc7 100644 --- a/waltid-services/waltid-service-commons/src/main/kotlin/id/walt/commons/web/modules/OpenApiModule.kt +++ b/waltid-services/waltid-service-commons/src/main/kotlin/id/walt/commons/web/modules/OpenApiModule.kt @@ -9,13 +9,13 @@ import io.github.smiley4.ktorswaggerui.dsl.config.PluginConfigDsl import io.github.smiley4.ktorswaggerui.dsl.routing.get import io.github.smiley4.ktorswaggerui.routing.openApiSpec import io.github.smiley4.ktorswaggerui.routing.swaggerUI -import io.github.smiley4.schemakenerator.core.connectSubTypes +/*import io.github.smiley4.schemakenerator.core.connectSubTypes import io.github.smiley4.schemakenerator.core.handleNameAnnotation import io.github.smiley4.schemakenerator.reflection.collectSubTypes import io.github.smiley4.schemakenerator.reflection.processReflection import io.github.smiley4.schemakenerator.serialization.processKotlinxSerialization import io.github.smiley4.schemakenerator.swagger.* -import io.github.smiley4.schemakenerator.swagger.data.TitleType +import io.github.smiley4.schemakenerator.swagger.data.TitleType*/ import io.klogging.noCoLogger import io.ktor.server.application.* import io.ktor.server.response.* @@ -39,7 +39,7 @@ object OpenApiModule { var custom: (PluginConfigDsl.() -> Unit)? = null } - private fun KType.processWithKotlinxSerializationGenerator() = processKotlinxSerialization() + /* private fun KType.processWithKotlinxSerializationGenerator() = processKotlinxSerialization() .connectSubTypes() .handleNameAnnotation() .generateSwaggerSchema() @@ -55,7 +55,7 @@ object OpenApiModule { .generateSwaggerSchema() .handleCoreAnnotations() .withTitle(TitleType.SIMPLE) - .compileReferencingRoot() + .compileReferencingRoot()*/ // Module fun Application.enable() { @@ -83,7 +83,7 @@ object OpenApiModule { schemas { val kotlinxPrefixes = listOf("id.walt") - generator = { type -> + /*generator = { type -> if (kotlinxPrefixes.any { type.toString().startsWith(it) }) { runCatching { @@ -96,7 +96,7 @@ object OpenApiModule { error("Could neither parse with kotlinx nor reflection: $type, due to $ex") } } else type.processWithReflectionGenerator() - } + }*/ } info { @@ -151,7 +151,7 @@ object OpenApiModule { get("/", { summary = "Redirect to swagger interface for API documentation" }) { - context.respondRedirect("swagger") + call.respondRedirect("swagger") } } } diff --git a/waltid-services/waltid-service-commons/src/main/kotlin/id/walt/commons/web/modules/ServiceHealthchecksDebugModule.kt b/waltid-services/waltid-service-commons/src/main/kotlin/id/walt/commons/web/modules/ServiceHealthchecksDebugModule.kt index 2145513b0..9d8051bde 100644 --- a/waltid-services/waltid-service-commons/src/main/kotlin/id/walt/commons/web/modules/ServiceHealthchecksDebugModule.kt +++ b/waltid-services/waltid-service-commons/src/main/kotlin/id/walt/commons/web/modules/ServiceHealthchecksDebugModule.kt @@ -109,7 +109,7 @@ object ServiceHealthChecksDebugModule { if (debugConfig.ram) get("ram") { val rt = Runtime.getRuntime() val memory = ManagementFactory.getMemoryMXBean() - context.respond(buildJsonObject { + call.respond(buildJsonObject { put("free", rt.freeMemory()) put("max", rt.maxMemory()) put("total", rt.totalMemory()) @@ -122,7 +122,7 @@ object ServiceHealthChecksDebugModule { if (debugConfig.cpu) get("cpu") { val thread = ManagementFactory.getThreadMXBean() - context.respond(buildJsonObject { + call.respond(buildJsonObject { put("loadAverage", ManagementFactory.getOperatingSystemMXBean().systemLoadAverage) put("processors", ManagementFactory.getOperatingSystemMXBean().availableProcessors) put("threadCount", JsonPrimitive(thread.threadCount)) @@ -132,7 +132,7 @@ object ServiceHealthChecksDebugModule { } if (debugConfig.memoryPool) get("memoryPool") { - context.respond(buildJsonObject { + call.respond(buildJsonObject { ManagementFactory.getMemoryPoolMXBeans().forEach { putJsonObject(it.name) { put("type", JsonPrimitive(it.type.name)) diff --git a/waltid-services/waltid-service-commons/src/main/kotlin/id/walt/commons/web/plugins/StatusPages.kt b/waltid-services/waltid-service-commons/src/main/kotlin/id/walt/commons/web/plugins/StatusPages.kt index 3ef15ff12..80c3f312d 100644 --- a/waltid-services/waltid-service-commons/src/main/kotlin/id/walt/commons/web/plugins/StatusPages.kt +++ b/waltid-services/waltid-service-commons/src/main/kotlin/id/walt/commons/web/plugins/StatusPages.kt @@ -10,6 +10,7 @@ import io.ktor.server.response.* import kotlinx.serialization.json.Json import kotlinx.serialization.json.JsonPrimitive import kotlinx.serialization.json.encodeToJsonElement +import redis.clients.jedis.exceptions.JedisException import kotlin.reflect.jvm.jvmName @@ -35,6 +36,7 @@ private fun statusCodeForException(cause: Throwable) = when (cause) { is IllegalArgumentException -> HttpStatusCode.BadRequest is BadRequestException -> HttpStatusCode.BadRequest is IllegalStateException -> HttpStatusCode.InternalServerError + is JedisException -> HttpStatusCode.InternalServerError is WebException -> cause.status else -> HttpStatusCode.InternalServerError } diff --git a/waltid-services/waltid-verifier-api/build.gradle.kts b/waltid-services/waltid-verifier-api/build.gradle.kts index ce31baf11..ff75b0cba 100644 --- a/waltid-services/waltid-verifier-api/build.gradle.kts +++ b/waltid-services/waltid-verifier-api/build.gradle.kts @@ -3,7 +3,7 @@ import org.jetbrains.kotlin.gradle.tasks.KotlinCompile import java.util.Properties object Versions { - const val KTOR_VERSION = "2.3.12" // also change 1 plugin + const val KTOR_VERSION = "3.1.0" // also change 1 plugin const val COROUTINES_VERSION = "1.9.0" const val EXPOSED_VERSION = "0.43.0" const val HOPLITE_VERSION = "2.8.0" @@ -13,7 +13,7 @@ plugins { kotlin("jvm") kotlin("plugin.serialization") - id("io.ktor.plugin") version "2.3.12" // Versions.KTOR_VERSION + id("io.ktor.plugin") version "3.1.0" // Versions.KTOR_VERSION id("org.owasp.dependencycheck") version "9.2.0" id("com.github.jk1.dependency-license-report") version "2.9" id("com.github.ben-manes.versions") @@ -66,7 +66,7 @@ dependencies { implementation("io.ktor:ktor-serialization-kotlinx-json-jvm:${Versions.KTOR_VERSION}") // Date - implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.6.1") + implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.6.2") // Coroutines implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:${Versions.COROUTINES_VERSION}") @@ -83,8 +83,8 @@ dependencies { // Logging implementation("io.github.oshai:kotlin-logging-jvm:7.0.0") implementation("org.slf4j:jul-to-slf4j:2.0.16") - implementation("io.klogging:klogging-jvm:0.7.2") - implementation("io.klogging:slf4j-klogging:0.7.2") + implementation("io.klogging:klogging-jvm:0.9.1") + implementation("io.klogging:slf4j-klogging:0.9.1") implementation("io.ktor:ktor-client-okhttp-jvm:${Versions.KTOR_VERSION}") diff --git a/waltid-services/waltid-verifier-api/src/main/kotlin/id/walt/verifier/VerifierApi.kt b/waltid-services/waltid-verifier-api/src/main/kotlin/id/walt/verifier/VerifierApi.kt index 5df49c4cc..0f071c4ed 100644 --- a/waltid-services/waltid-verifier-api/src/main/kotlin/id/walt/verifier/VerifierApi.kt +++ b/waltid-services/waltid-verifier-api/src/main/kotlin/id/walt/verifier/VerifierApi.kt @@ -17,6 +17,7 @@ import id.walt.verifier.config.OIDCVerifierServiceConfig import id.walt.verifier.oidc.RequestSigningCryptoProvider import id.walt.verifier.oidc.SwaggerPresentationSessionInfo import id.walt.verifier.oidc.VerificationUseCase +import id.walt.verifier.oidc.VerificationUseCase.FailedVerificationException import io.github.smiley4.ktorswaggerui.dsl.routing.get import io.github.smiley4.ktorswaggerui.dsl.routing.post import io.github.smiley4.ktorswaggerui.dsl.routing.route @@ -30,14 +31,14 @@ import io.ktor.server.application.* import io.ktor.server.plugins.* import io.ktor.server.request.* import io.ktor.server.response.* +import io.ktor.server.response.respond +import io.ktor.server.response.respondRedirect import io.ktor.server.routing.* import io.ktor.server.util.* import io.ktor.util.* -import io.ktor.util.pipeline.* import kotlinx.coroutines.runBlocking import kotlinx.serialization.SerialName import kotlinx.serialization.Serializable -import kotlinx.serialization.encodeToString import kotlinx.serialization.json.* import kotlin.uuid.ExperimentalUuidApi import kotlin.uuid.Uuid @@ -215,18 +216,18 @@ fun Application.verifierApi() { }) { - val authorizeBaseUrl = context.request.header("authorizeBaseUrl") ?: defaultAuthorizeBaseUrl + val authorizeBaseUrl = call.request.header("authorizeBaseUrl") ?: defaultAuthorizeBaseUrl val responseMode = - context.request.header("responseMode")?.let { ResponseMode.fromString(it) } + call.request.header("responseMode")?.let { ResponseMode.fromString(it) } ?: ResponseMode.direct_post - val successRedirectUri = context.request.header("successRedirectUri") - val errorRedirectUri = context.request.header("errorRedirectUri") - val statusCallbackUri = context.request.header("statusCallbackUri") - val statusCallbackApiKey = context.request.header("statusCallbackApiKey") - val stateId = context.request.header("stateId") - val openId4VPProfile = context.request.header("openId4VPProfile") + val successRedirectUri = call.request.header("successRedirectUri") + val errorRedirectUri = call.request.header("errorRedirectUri") + val statusCallbackUri = call.request.header("statusCallbackUri") + val statusCallbackApiKey = call.request.header("statusCallbackApiKey") + val stateId = call.request.header("stateId") + val openId4VPProfile = call.request.header("openId4VPProfile") - val body = context.receive() + val body = call.receive() val session = verificationUseCase.createSession( vpPoliciesJson = body["vp_policies"], @@ -245,7 +246,7 @@ fun Application.verifierApi() { trustedRootCAs = body["trusted_root_cas"]?.jsonArray ) - context.respond( + call.respond( authorizeBaseUrl.plus("?").plus( when (session.openId4VPProfile) { OpenId4VPProfile.ISO_18013_7_MDOC -> session.authorizationRequest!!.toRequestObjectByReferenceHttpQueryString( @@ -294,11 +295,43 @@ fun Application.verifierApi() { logger.info { "POST verify/state" } val sessionId = call.parameters.getOrFail("state") logger.info { "State: $sessionId" } - verificationUseCase.verify(sessionId, context.request.call.receiveParameters().toMap()) + verificationUseCase.verify(sessionId, call.request.call.receiveParameters().toMap()) .onSuccess { - processVerificationSuccessResult(sessionId, it) + val session = verificationUseCase.getSession(sessionId!!) + if (session.walletInitiatedAuthState != null) { + val state = session.walletInitiatedAuthState + val code = Uuid.random().toString() + call.respondRedirect("openid://?code=$code&state=$state") + } else { + call.respond(HttpStatusCode.OK, it) + } }.onFailure { - processVerificationFailureResult(sessionId, it) + runBlocking { logger.debug(it) { "Verification failed ($it)" } } + val errorDescription = it.message ?: "Verification failed" + runBlocking { logger.error { "Error: $errorDescription" } } + if (sessionId != null) { + val session = verificationUseCase.getSession(sessionId) + if (session.walletInitiatedAuthState != null) { + val state = session.walletInitiatedAuthState + runBlocking { + this@post.call.respondRedirect( + "openid://?state=$state&error=invalid_request&error_description=${getErrorDescription(it)}" + ) + } + } else if (it is FailedVerificationException && it.redirectUrl != null) { + runBlocking { + this@post.call.respond(HttpStatusCode.BadRequest, it.redirectUrl) + } + + } else { + throw it + } + } else { + runBlocking { + logger.error(it) { "/verify error: $errorDescription" } + this@post.call.respond(HttpStatusCode.BadRequest, errorDescription) + } + } }.also { verificationUseCase.notifySubscribers(sessionId) } @@ -464,7 +497,7 @@ fun Application.verifierApi() { }, openId4VPProfile = OpenId4VPProfile.EBSIV3 ) - context.respondRedirect( + call.respondRedirect( "openid://?${ session.authorizationRequest!!.toEbsiRequestObjectByReferenceHttpQueryString( SERVER_URL.let { "$it/openid4vc/request/${session.id}" }) @@ -486,56 +519,3 @@ private fun getErrorDescription(it: Throwable): String? = when (it.message) { else -> null } - -private fun PipelineContext.processError( - sessionId: String, - error: Throwable -) { - val session = verificationUseCase.getSession(sessionId) - if (session.walletInitiatedAuthState != null) { - val state = session.walletInitiatedAuthState - runBlocking { - context.respondRedirect( - "openid://?state=$state&error=invalid_request&error_description=${getErrorDescription(error)}" - ) - } - } else if (error is VerificationUseCase.FailedVerificationException && error.redirectUrl != null) { - runBlocking { - context.respond(HttpStatusCode.BadRequest, error.redirectUrl) - } - - } else { - throw error - } -} - -private fun PipelineContext.processVerificationFailureResult( - sessionId: String?, - error: Throwable, -) { - runBlocking { logger.debug(error) { "Verification failed ($error)" } } - val errorDescription = error.message ?: "Verification failed" - runBlocking { logger.error { "Error: $errorDescription" } } - if (sessionId != null) { - processError(sessionId, error) - } else { - runBlocking { - logger.error(error) { "/verify error: $errorDescription" } - call.respond(HttpStatusCode.BadRequest, errorDescription) - } - } -} - -private suspend fun PipelineContext.processVerificationSuccessResult( - sessionId: String?, - redirectUrl: String, -) { - val session = verificationUseCase.getSession(sessionId!!) - if (session.walletInitiatedAuthState != null) { - val state = session.walletInitiatedAuthState - val code = Uuid.random().toString() - context.respondRedirect("openid://?code=$code&state=$state") - } else { - call.respond(HttpStatusCode.OK, redirectUrl) - } -} diff --git a/waltid-services/waltid-verifier-api/src/main/kotlin/id/walt/verifier/entra/EntraVerifierApi.kt b/waltid-services/waltid-verifier-api/src/main/kotlin/id/walt/verifier/entra/EntraVerifierApi.kt index a4c925fdc..71273a370 100644 --- a/waltid-services/waltid-verifier-api/src/main/kotlin/id/walt/verifier/entra/EntraVerifierApi.kt +++ b/waltid-services/waltid-verifier-api/src/main/kotlin/id/walt/verifier/entra/EntraVerifierApi.kt @@ -204,26 +204,26 @@ fun Application.entraVerifierApi() { request { body() } response { HttpStatusCode.OK to { body() } } }) { - val verifyRequest = context.receive() + val verifyRequest = call.receive() val res = EntraVerifierApi.createPresentationRequest(verifyRequest.entraVerification, verifyRequest.data) - context.respond(res.getOrThrow()) + call.respond(res.getOrThrow()) } post("verification-callback/{nonce}", { tags = listOf("Entra") }) { - val nonce = context.parameters["nonce"]?.let { Uuid.parse(it) } + val nonce = call.parameters["nonce"]?.let { Uuid.parse(it) } println("--- ENTRA CALLBACK ---") - println("Nonce: " + context.parameters["nonce"]) - println("Headers: " + context.request.headers) - //println("Body: " + context.receiveText()) - println("URL: " + context.url()) + println("Nonce: " + call.parameters["nonce"]) + println("Headers: " + call.request.headers) + //println("Body: " + call.receiveText()) + println("URL: " + call.url()) require(EntraVerifierApi.callbackMapping.containsKey(nonce)) { "Invalid nonce: $nonce" } - val body = context.receiveText() + val body = call.receiveText() println("Response: $body") val response = Json.decodeFromString(body) @@ -241,7 +241,7 @@ fun Application.entraVerifierApi() { EntraVerifierApi.policyStatusMapping[nonce!!] = result } - context.respond(HttpStatusCode.OK) + call.respond(HttpStatusCode.OK) } get("status/{nonce}", { @@ -249,7 +249,7 @@ fun Application.entraVerifierApi() { request { pathParameter("nonce") } response { HttpStatusCode.OK to { body() } } }) { - val nonce = context.parameters["nonce"]?.let { Uuid.parse(it) } + val nonce = call.parameters["nonce"]?.let { Uuid.parse(it) } val result = EntraVerifierApi.policyStatusMapping[nonce] @@ -270,8 +270,8 @@ fun Application.entraVerifierApi() { } } - context.respond(output) - } else context.respond(HttpStatusCode.NotFound) + call.respond(output) + } else call.respond(HttpStatusCode.NotFound) } } } diff --git a/waltid-services/waltid-verifier-api/src/main/kotlin/id/walt/verifier/lspPotential/LspPotentialVerificationInterop.kt b/waltid-services/waltid-verifier-api/src/main/kotlin/id/walt/verifier/lspPotential/LspPotentialVerificationInterop.kt index 1c5fed7f4..51ee51ba2 100644 --- a/waltid-services/waltid-verifier-api/src/main/kotlin/id/walt/verifier/lspPotential/LspPotentialVerificationInterop.kt +++ b/waltid-services/waltid-verifier-api/src/main/kotlin/id/walt/verifier/lspPotential/LspPotentialVerificationInterop.kt @@ -108,7 +108,7 @@ fun Application.lspPotentialVerificationTestApi() { } } }) { - val deviceJwk = context.request.call.receiveParameters().toMap()["jwk"] + val deviceJwk = call.request.call.receiveParameters().toMap()["jwk"] val devicePubKey = JWK.parse(deviceJwk!!.first()).toECKey().toPublicKey() val mdoc = MDocBuilder(MDocTypes.ISO_MDL) @@ -145,7 +145,7 @@ fun Application.lspPotentialVerificationTestApi() { } } }) { - val holderJwk = context.request.call.receiveParameters().toMap().get("jwk")!!.first() + val holderJwk = call.request.call.receiveParameters().toMap().get("jwk")!!.first() val sdJwtVc = SDJwtVC.sign( SDPayload.Companion.createSDPayload(buildJsonObject { diff --git a/waltid-services/waltid-verifier-api/src/main/kotlin/id/walt/verifier/web/plugins/Monitoring.kt b/waltid-services/waltid-verifier-api/src/main/kotlin/id/walt/verifier/web/plugins/Monitoring.kt index 25703b929..9a1b16ff5 100644 --- a/waltid-services/waltid-verifier-api/src/main/kotlin/id/walt/verifier/web/plugins/Monitoring.kt +++ b/waltid-services/waltid-verifier-api/src/main/kotlin/id/walt/verifier/web/plugins/Monitoring.kt @@ -3,7 +3,7 @@ package id.walt.verifier.web.plugins import io.ktor.http.* import io.ktor.server.application.* import io.ktor.server.plugins.callid.* -import io.ktor.server.plugins.callloging.* +import io.ktor.server.plugins.calllogging.CallLogging import io.ktor.server.request.* import org.slf4j.event.Level diff --git a/waltid-services/waltid-wallet-api/build.gradle.kts b/waltid-services/waltid-wallet-api/build.gradle.kts index ce0df445e..61b3d1491 100644 --- a/waltid-services/waltid-wallet-api/build.gradle.kts +++ b/waltid-services/waltid-wallet-api/build.gradle.kts @@ -4,7 +4,7 @@ import java.util.Properties plugins { kotlin("jvm") - id("io.ktor.plugin") version "2.3.12" + id("io.ktor.plugin") version "3.1.0" kotlin("plugin.serialization") id("com.github.ben-manes.versions") } @@ -64,7 +64,7 @@ dependencies { /* -- KTOR -- */ - val ktor_version = "2.3.12" + val ktor_version = "3.1.0" // Ktor server implementation("io.ktor:ktor-server-core-jvm:$ktor_version") implementation("io.ktor:ktor-server-auth-jvm:$ktor_version") @@ -96,13 +96,13 @@ dependencies { /* -- Kotlin -- */ // Kotlinx.serialization - implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.7.3") + implementation("org.jetbrains.kotlinx:kotlinx-serialization-json:1.8.0") // Date - implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.6.1") + implementation("org.jetbrains.kotlinx:kotlinx-datetime:0.6.2") // Coroutines - implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0") + implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.10.1") // Uuid implementation("app.softwork:kotlinx-uuid-core:0.1.2") @@ -110,8 +110,8 @@ dependencies { /* -- Security -- */ // Bouncy Castle - implementation("org.bouncycastle:bcprov-lts8on:2.73.6") - implementation("org.bouncycastle:bcpkix-lts8on:2.73.6") + implementation("org.bouncycastle:bcprov-lts8on:2.73.7") + implementation("org.bouncycastle:bcpkix-lts8on:2.73.7") // Argon2 implementation("de.mkammerer:argon2-jvm:2.11") @@ -161,9 +161,9 @@ dependencies { implementation("org.jetbrains.exposed:exposed-java-time:0.54.0") implementation("org.jetbrains.exposed:exposed-json:0.54.0") // drivers - implementation("org.xerial:sqlite-jdbc:3.46.1.0") - implementation("org.postgresql:postgresql:42.7.4") - implementation("com.mysql:mysql-connector-j:9.0.0") + implementation("org.xerial:sqlite-jdbc:3.49.0.0") + implementation("org.postgresql:postgresql:42.7.5") + implementation("com.mysql:mysql-connector-j:9.2.0") implementation("com.microsoft.sqlserver:mssql-jdbc:12.8.1.jre11") // Web push @@ -180,15 +180,15 @@ dependencies { // Logging implementation("io.github.oshai:kotlin-logging-jvm:7.0.0") implementation("org.slf4j:jul-to-slf4j:2.0.16") - implementation("io.klogging:klogging-jvm:0.7.2") - implementation("io.klogging:slf4j-klogging:0.7.2") + implementation("io.klogging:klogging-jvm:0.9.1") + implementation("io.klogging:slf4j-klogging:0.9.1") // Test testImplementation("org.junit.jupiter:junit-jupiter-api:5.11.4") testImplementation("org.junit.jupiter:junit-jupiter-params:5.11.4") testImplementation(kotlin("test")) - testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.9.0") - testImplementation("io.ktor:ktor-server-tests-jvm:$ktor_version") + testImplementation("org.jetbrains.kotlinx:kotlinx-coroutines-test:1.10.1") + testImplementation("io.ktor:ktor-server-test-host:$ktor_version") testImplementation("io.mockk:mockk:1.13.16") - testImplementation("io.klogging:klogging-jvm:0.7.2") + testImplementation("io.klogging:klogging-jvm:0.9.1") } diff --git a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/FeatureCatalog.kt b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/FeatureCatalog.kt index 7002393fb..8a7e4203c 100644 --- a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/FeatureCatalog.kt +++ b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/FeatureCatalog.kt @@ -12,7 +12,8 @@ object FeatureCatalog : ServiceFeatureCatalog { val devModeFeature = OptionalFeature("dev-mode", "Development mode", default = false) val legacyAuthenticationFeature = OptionalFeature("auth", "Legacy authentication system", AuthConfig::class, true) - val ktorAuthnzAuthenticationFeature = OptionalFeature("ktor-authnz", "waltid-ktor-authnz authentication system", KtorAuthnzConfig::class, false) + val ktorAuthnzAuthenticationFeature = + OptionalFeature("ktor-authnz", "waltid-ktor-authnz authentication system", KtorAuthnzConfig::class, false) // val loginsMethodFeature = BaseFeature("logins", "Logins method management", LoginMethodsConfig::class) diff --git a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/db/Db.kt b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/db/Db.kt index ff292462f..6759bda90 100644 --- a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/db/Db.kt +++ b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/db/Db.kt @@ -94,7 +94,7 @@ object Db { val accountResult = AccountsService.register(request = EmailAccountRequest("Max Mustermann", "user@email.com", "password")) val accountId = accountResult.getOrNull()?.id!! val walletResult = AccountsService.getAccountWalletMappings("", accountId) - val walletId = walletResult.wallets[0].id + walletResult.wallets[0].id /*CredentialsService().add( wallet = walletId, diff --git a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/db/KotlinxUUIDTable.kt b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/db/KotlinxUUIDTable.kt index 0af2d8067..71b690f2d 100644 --- a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/db/KotlinxUUIDTable.kt +++ b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/db/KotlinxUUIDTable.kt @@ -3,8 +3,9 @@ package id.walt.webwallet.db import app.softwork.uuid.isValidUuidString -import org.jetbrains.exposed.dao.id.* -import org.jetbrains.exposed.sql.* +import org.jetbrains.exposed.sql.Column +import org.jetbrains.exposed.sql.ColumnType +import org.jetbrains.exposed.sql.Table import org.jetbrains.exposed.sql.vendors.currentDialect import java.nio.ByteBuffer import kotlin.uuid.ExperimentalUuidApi @@ -36,7 +37,7 @@ import kotlin.uuid.toKotlinUuid * Creates a binary column, with the specified [name], for storing Uuids. * Unlike the [Table.uuid] function, this one registers [kotlinx.uuid.Uuid] type instead of [java.util.Uuid]. **/ -public fun Table.kotlinxUuid(name: String): Column { +fun Table.kotlinxUuid(name: String): Column { return registerColumn(name, UuidColumnType()) } @@ -55,7 +56,7 @@ fun Table.typedUUID(name: String, factory: UUIDTypeFactory): Colum * Remember that using a [SecureRandom] may require to seed the system random source * otherwise a system may get stuck. **/ -public fun Column.autoGenerate(): Column = apply { +fun Column.autoGenerate(): Column = apply { defaultValueFun = { Uuid.random() } } @@ -63,7 +64,7 @@ public fun Column.autoGenerate(): Column = apply { * A [Uuid] column type for registering in exposed tables. * @see kotlinxUuid to see how it is used */ -public class UuidColumnType : ColumnType() { +class UuidColumnType : ColumnType() { override fun sqlType(): String = currentDialect.dataTypeProvider.uuidType() override fun valueFromDB(value: Any): Uuid = when { diff --git a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/db/models/WalletCredentials.kt b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/db/models/WalletCredentials.kt index 7fea28dda..54ccac905 100644 --- a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/db/models/WalletCredentials.kt +++ b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/db/models/WalletCredentials.kt @@ -61,11 +61,12 @@ data class WalletCredential @OptIn(ExperimentalUuidApi::class) constructor( companion object { fun parseDocument(document: String, id: String, format: CredentialFormat) = runCatching { - when(format) { + when (format) { CredentialFormat.ldp_vc -> Json.parseToJsonElement(document).jsonObject CredentialFormat.jwt_vc, CredentialFormat.sd_jwt_vc, CredentialFormat.jwt_vc_json, CredentialFormat.jwt_vc_json_ld -> document.decodeJws().payload .run { jsonObject["vc"]?.jsonObject ?: jsonObject } + CredentialFormat.mso_mdoc -> MDoc.fromCBORHex(document).toMapElement().toJsonElement().jsonObject else -> throw IllegalArgumentException("Unknown credential format") }?.toMutableMap().also { @@ -97,9 +98,10 @@ data class WalletCredential @OptIn(ExperimentalUuidApi::class) constructor( manifest?.let { JsonUtils.tryGetData(it, "display.card.issuedBy")?.jsonPrimitive?.content } fun parseFullDocument(document: String, disclosures: String?, id: String, format: CredentialFormat) = kotlin.runCatching { - when(format) { + when (format) { CredentialFormat.jwt_vc, CredentialFormat.sd_jwt_vc, CredentialFormat.jwt_vc_json, CredentialFormat.jwt_vc_json_ld -> SDJwt.parse(document + (disclosures?.let { "~$it" } ?: "")).fullPayload + else -> parseDocument(document, id, format) } }.onFailure { it.printStackTrace() } @@ -116,6 +118,7 @@ data class WalletCredential @OptIn(ExperimentalUuidApi::class) constructor( manifest = result[WalletCredentials.manifest], deletedOn = result[WalletCredentials.deletedOn]?.toKotlinInstant(), pending = result[WalletCredentials.pending], - format = CredentialFormat.fromValue(result[WalletCredentials.format]) ?: throw IllegalArgumentException("Credential format couldn't be decoded") + format = CredentialFormat.fromValue(result[WalletCredentials.format]) + ?: throw IllegalArgumentException("Credential format couldn't be decoded") ) } diff --git a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/db/models/WallletNotifications.kt b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/db/models/WallletNotifications.kt index f80b6350e..4365ee439 100644 --- a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/db/models/WallletNotifications.kt +++ b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/db/models/WallletNotifications.kt @@ -4,7 +4,6 @@ import id.walt.webwallet.db.kotlinxUuid import kotlinx.datetime.Instant import kotlinx.datetime.toKotlinInstant import kotlinx.serialization.Serializable -import kotlinx.serialization.encodeToString import kotlinx.serialization.json.Json import kotlinx.serialization.json.JsonElement import kotlinx.serialization.json.decodeFromJsonElement diff --git a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/SSIKit2WalletService.kt b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/SSIKit2WalletService.kt index f38f4e94b..b0630df0e 100644 --- a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/SSIKit2WalletService.kt +++ b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/SSIKit2WalletService.kt @@ -69,7 +69,6 @@ import kotlinx.coroutines.runBlocking import kotlinx.datetime.Clock import kotlinx.datetime.toJavaInstant import kotlinx.serialization.Serializable -import kotlinx.serialization.encodeToString import kotlinx.serialization.json.* import org.jetbrains.exposed.sql.insert import org.jetbrains.exposed.sql.selectAll diff --git a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/WalletServiceManager.kt b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/WalletServiceManager.kt index 1d21fde3b..9492bdbb5 100644 --- a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/WalletServiceManager.kt +++ b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/WalletServiceManager.kt @@ -227,14 +227,17 @@ object WalletServiceManager { it[Wallets.id].value.toKotlinUuid() } - suspend fun matchCredentialsForPresentationDefinition(walletId: Uuid, presentationDefinition: PresentationDefinition): List { + suspend fun matchCredentialsForPresentationDefinition( + walletId: Uuid, + presentationDefinition: PresentationDefinition + ): List { val pd = Json.decodeFromJsonElement(presentationDefinition.toJSON()) val matches = credentialService.list(walletId, CredentialFilterObject.default).filter { cred -> val fullDoc = WalletCredential.parseFullDocument(cred.document, cred.disclosures, cred.id, cred.format) fullDoc != null && - pd.inputDescriptors.any { inputDesc -> - PresentationDefinitionParser.matchCredentialsForInputDescriptor(flowOf(fullDoc), inputDesc).toList().isNotEmpty() - } + pd.inputDescriptors.any { inputDesc -> + PresentationDefinitionParser.matchCredentialsForInputDescriptor(flowOf(fullDoc), inputDesc).toList().isNotEmpty() + } } return matches } diff --git a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/account/authnz/AuthenticationService.kt b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/account/authnz/AuthenticationService.kt index 1b6c2134b..0f4b5e025 100644 --- a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/account/authnz/AuthenticationService.kt +++ b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/account/authnz/AuthenticationService.kt @@ -13,7 +13,7 @@ import kotlinx.coroutines.withContext import org.jetbrains.exposed.sql.insert import org.jetbrains.exposed.sql.selectAll import org.jetbrains.exposed.sql.transactions.transaction -import java.util.* +import java.util.UUID import kotlin.uuid.ExperimentalUuidApi @OptIn(ExperimentalUuidApi::class) @@ -26,8 +26,8 @@ class AuthenticationService(private val dispatcher: CoroutineDispatcher = Dispat ): Unit = withContext(dispatcher) { transaction { AuthnzAccountIdentifiers.insert { - it[AuthnzAccountIdentifiers.userId] = UUID.fromString(accountId) - it[AuthnzAccountIdentifiers.identifier] = newAccountIdentifier.accountIdentifierName + it[userId] = UUID.fromString(accountId) + it[identifier] = newAccountIdentifier.accountIdentifierName //it[AuthnzAccountIdentifiers.method] = } Unit // Explicitly return Unit @@ -46,9 +46,9 @@ class AuthenticationService(private val dispatcher: CoroutineDispatcher = Dispat val savableStoredData = data.transformSavable() transaction { val userId = AuthnzAccountIdentifiers - .select(AuthnzAccountIdentifiers.userId) + .select(userId) .where { AuthnzAccountIdentifiers.identifier eq accountIdentifier.accountIdentifierName } - .singleOrNull()?.get(AuthnzAccountIdentifiers.userId) + .singleOrNull()?.get(userId) ?: throw IllegalStateException("Account not found") AuthnzStoredData.insert { diff --git a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/account/x5c/X5CAccountStrategy.kt b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/account/x5c/X5CAccountStrategy.kt index 6966dbd26..d1e0030f8 100644 --- a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/account/x5c/X5CAccountStrategy.kt +++ b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/account/x5c/X5CAccountStrategy.kt @@ -20,7 +20,6 @@ import org.jetbrains.exposed.sql.insert import org.jetbrains.exposed.sql.transactions.transaction import kotlin.uuid.ExperimentalUuidApi import kotlin.uuid.Uuid -import kotlin.uuid.toJavaUuid object X5CAccountStrategy : PasswordlessAccountStrategy() { @@ -43,8 +42,8 @@ object X5CAccountStrategy : PasswordlessAccountStrategy() { override suspend fun authenticate(tenant: String, request: X5CAccountRequest): AuthenticatedUser { val thumbprint = validate(request.token) - val registeredUserId = AccountsService.getAccountByX5CId(tenant, thumbprint)?.id ?: - AccountsService.register(tenant, request).getOrThrow().id + val registeredUserId = + AccountsService.getAccountByX5CId(tenant, thumbprint)?.id ?: AccountsService.register(tenant, request).getOrThrow().id return X5CAuthenticatedUser(registeredUserId) } diff --git a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/credentials/CredentialsService.kt b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/credentials/CredentialsService.kt index 3d6b21848..09fd906d1 100644 --- a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/credentials/CredentialsService.kt +++ b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/credentials/CredentialsService.kt @@ -138,16 +138,18 @@ class CredentialsService { transaction { WalletCredentials.deleteWhere { (WalletCredentials.wallet eq wallet.toJavaUuid()) and (id eq credentialId) } } private fun categorizedQuery(wallet: Uuid, deleted: Boolean?, pending: Boolean?, categories: List) = - WalletCredentials.innerJoin(otherTable = WalletCredentialCategoryMap, + WalletCredentials.innerJoin( + otherTable = WalletCredentialCategoryMap, onColumn = { id }, otherColumn = { credential }, additionalConstraint = { WalletCredentials.wallet eq wallet.toJavaUuid() and (WalletCredentialCategoryMap.wallet eq wallet) and deletedCondition( deleted ) and pendingCondition(pending) - }).innerJoin(otherTable = WalletCategory, + }).innerJoin( + otherTable = WalletCategory, onColumn = { WalletCredentialCategoryMap.category }, - otherColumn = { WalletCategory.id }, + otherColumn = { id }, additionalConstraint = { WalletCategory.wallet eq wallet.toJavaUuid() and (WalletCredentialCategoryMap.wallet eq wallet) and (WalletCategory.name inList (categories)) }).selectAll() diff --git a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/dids/DidService.kt b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/dids/DidService.kt index 4f27d5b41..81bc013b4 100644 --- a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/dids/DidService.kt +++ b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/dids/DidService.kt @@ -50,7 +50,11 @@ object DidsService { }.insertedCount fun delete(wallet: Uuid, did: String): Boolean = - transaction { WalletDids.deleteWhere { (WalletDids.wallet eq wallet.toJavaUuid()) and (WalletDids.did eq did.replace("%3A", ":").replace("%3D", "=")) } } > 0 + transaction { + WalletDids.deleteWhere { + (WalletDids.wallet eq wallet.toJavaUuid()) and (WalletDids.did eq did.replace("%3A", ":").replace("%3D", "=")) + } + } > 0 fun makeDidDefault(wallet: Uuid, newDefaultDid: String) { diff --git a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/endpoint/EntraServiceEndpointProvider.kt b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/endpoint/EntraServiceEndpointProvider.kt index 0953a32cc..b0f75ac12 100644 --- a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/endpoint/EntraServiceEndpointProvider.kt +++ b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/endpoint/EntraServiceEndpointProvider.kt @@ -19,7 +19,7 @@ class EntraServiceEndpointProvider( contentType(ContentType.Application.Json) setBody( IdentityHubRequest( - requestId = Uuid.random().toString(), + requestId = Uuid.random().toString(), target = did, messages = listOf( IdentityHubRequest.Message( diff --git a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/events/EventService.kt b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/events/EventService.kt index c125743aa..8c8bd9dbd 100644 --- a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/events/EventService.kt +++ b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/events/EventService.kt @@ -4,9 +4,7 @@ package id.walt.webwallet.service.events import id.walt.webwallet.db.models.Events import kotlinx.datetime.toJavaInstant -import kotlinx.serialization.encodeToString import kotlinx.serialization.json.Json - import org.jetbrains.exposed.sql.* import org.jetbrains.exposed.sql.SqlExpressionBuilder.eq import org.jetbrains.exposed.sql.javatime.date @@ -116,7 +114,8 @@ class EventService { sortBy: String, dataFilter: Map>, ) = Events.selectAll().where { Events.account eq accountId or (Events.wallet eq walletId) } - .orderBy(getColumn(sortBy) ?: Events.timestamp, + .orderBy( + getColumn(sortBy) ?: Events.timestamp, sortOrder.takeIf { it.uppercase() == "ASC" }?.let { SortOrder.ASC } ?: SortOrder.DESC) .addWhereClause(dataFilter) diff --git a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/exchange/CredentialOfferProcessor.kt b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/exchange/CredentialOfferProcessor.kt index 64d87b741..60b1a329e 100644 --- a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/exchange/CredentialOfferProcessor.kt +++ b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/exchange/CredentialOfferProcessor.kt @@ -16,18 +16,18 @@ object CredentialOfferProcessor { private val http = WalletHttpClients.getHttpClient() private val logger = logger() suspend fun process( - credentialRequests: List, - providerMetadata: OpenIDProviderMetadata, - accessToken: String, + credentialRequests: List, + providerMetadata: OpenIDProviderMetadata, + accessToken: String, ) = when (credentialRequests.size) { 1 -> processedSingleCredentialOffer(credentialRequests, providerMetadata, accessToken) else -> processBatchCredentialOffer(credentialRequests, providerMetadata, accessToken) } private suspend fun processBatchCredentialOffer( - credReqs: List, - providerMetadata: OpenIDProviderMetadata, - accessToken: String, + credReqs: List, + providerMetadata: OpenIDProviderMetadata, + accessToken: String, ): List { providerMetadata as OpenIDProviderMetadata.Draft13 @@ -51,9 +51,9 @@ object CredentialOfferProcessor { } private suspend fun processedSingleCredentialOffer( - credReqs: List, - providerMetadata: OpenIDProviderMetadata, - accessToken: String, + credReqs: List, + providerMetadata: OpenIDProviderMetadata, + accessToken: String, ): List { val credReq = credReqs.first() diff --git a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/exchange/IssuanceService.kt b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/exchange/IssuanceService.kt index 7c6fd6266..eb2662526 100644 --- a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/exchange/IssuanceService.kt +++ b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/exchange/IssuanceService.kt @@ -2,10 +2,15 @@ package id.walt.webwallet.service.exchange import id.walt.did.dids.DidService import id.walt.oid4vc.OpenID4VCI -import id.walt.oid4vc.data.* +import id.walt.oid4vc.data.CredentialFormat +import id.walt.oid4vc.data.CredentialOffer +import id.walt.oid4vc.data.GrantType import id.walt.oid4vc.providers.TokenTarget import id.walt.oid4vc.requests.* -import id.walt.oid4vc.responses.* +import id.walt.oid4vc.responses.CredentialResponse +import id.walt.oid4vc.responses.EntraIssuanceCompletionCode +import id.walt.oid4vc.responses.EntraIssuanceCompletionErrorDetails +import id.walt.oid4vc.responses.EntraIssuanceCompletionResponse import id.walt.webwallet.manifest.extractor.EntraManifestExtractor import id.walt.webwallet.service.oidc4vc.TestCredentialWallet import io.klogging.logger @@ -16,7 +21,7 @@ import kotlinx.serialization.json.Json import kotlinx.serialization.json.jsonObject import kotlinx.serialization.json.jsonPrimitive -object IssuanceService: IssuanceServiceBase() { +object IssuanceService : IssuanceServiceBase() { override val logger = logger() diff --git a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/exchange/ProcessedCredentialOffer.kt b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/exchange/ProcessedCredentialOffer.kt index 3483019ee..555da7a8c 100644 --- a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/exchange/ProcessedCredentialOffer.kt +++ b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/exchange/ProcessedCredentialOffer.kt @@ -5,7 +5,7 @@ import id.walt.oid4vc.requests.EntraIssuanceRequest import id.walt.oid4vc.responses.CredentialResponse data class ProcessedCredentialOffer( - val credentialResponse: CredentialResponse, - val credentialRequest: CredentialRequest?, - val entraIssuanceRequest: EntraIssuanceRequest? = null + val credentialResponse: CredentialResponse, + val credentialRequest: CredentialRequest?, + val entraIssuanceRequest: EntraIssuanceRequest? = null ) diff --git a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/exchange/ProofOfPossessionFactory.kt b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/exchange/ProofOfPossessionFactory.kt index 539bcd5c7..13458fd55 100644 --- a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/exchange/ProofOfPossessionFactory.kt +++ b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/exchange/ProofOfPossessionFactory.kt @@ -10,46 +10,46 @@ import id.walt.oid4vc.data.ProofType import id.walt.webwallet.service.oidc4vc.TestCredentialWallet object ProofOfPossessionFactory { - suspend fun new( - useKeyProof: Boolean, - credentialWallet: TestCredentialWallet, - offeredCredential: OfferedCredential, - credentialOffer: CredentialOffer, - nonce: String? - ): ProofOfPossession = when (useKeyProof) { - true -> keyProofOfPossession(credentialWallet, offeredCredential, credentialOffer, nonce) - false -> didProofOfPossession(credentialWallet, offeredCredential, credentialOffer, nonce) - } + suspend fun new( + useKeyProof: Boolean, + credentialWallet: TestCredentialWallet, + offeredCredential: OfferedCredential, + credentialOffer: CredentialOffer, + nonce: String? + ): ProofOfPossession = when (useKeyProof) { + true -> keyProofOfPossession(credentialWallet, offeredCredential, credentialOffer, nonce) + false -> didProofOfPossession(credentialWallet, offeredCredential, credentialOffer, nonce) + } - private fun didProofOfPossession( - credentialWallet: TestCredentialWallet, - offeredCredential: OfferedCredential, - credentialOffer: CredentialOffer, - nonce: String? - ) = credentialWallet.generateDidProof( - did = credentialWallet.did, - issuerUrl = credentialOffer.credentialIssuer, - nonce = nonce, - proofType = offeredCredential.proofTypesSupported?.keys?.first() ?: ProofType.jwt - ) - - private suspend fun keyProofOfPossession( - credentialWallet: TestCredentialWallet, - offeredCredential: OfferedCredential, - credentialOffer: CredentialOffer, - nonce: String? - ): ProofOfPossession { - val key = DidService.resolveToKey(credentialWallet.did).getOrThrow() - val proofType = offeredCredential.proofTypesSupported?.keys?.first() ?: ProofType.jwt - return credentialWallet.generateKeyProof( - key = key, - cosePubKey = if (proofType == ProofType.cwt) OneKey( - ECKey.parse(key.getPublicKey().exportJWK()).toECPublicKey(), - null - ).AsCBOR().EncodeToBytes() else null, - issuerUrl = credentialOffer.credentialIssuer, - nonce = nonce, - proofType = proofType + private fun didProofOfPossession( + credentialWallet: TestCredentialWallet, + offeredCredential: OfferedCredential, + credentialOffer: CredentialOffer, + nonce: String? + ) = credentialWallet.generateDidProof( + did = credentialWallet.did, + issuerUrl = credentialOffer.credentialIssuer, + nonce = nonce, + proofType = offeredCredential.proofTypesSupported?.keys?.first() ?: ProofType.jwt ) - } + + private suspend fun keyProofOfPossession( + credentialWallet: TestCredentialWallet, + offeredCredential: OfferedCredential, + credentialOffer: CredentialOffer, + nonce: String? + ): ProofOfPossession { + val key = DidService.resolveToKey(credentialWallet.did).getOrThrow() + val proofType = offeredCredential.proofTypesSupported?.keys?.first() ?: ProofType.jwt + return credentialWallet.generateKeyProof( + key = key, + cosePubKey = if (proofType == ProofType.cwt) OneKey( + ECKey.parse(key.getPublicKey().exportJWK()).toECPublicKey(), + null + ).AsCBOR().EncodeToBytes() else null, + issuerUrl = credentialOffer.credentialIssuer, + nonce = nonce, + proofType = proofType + ) + } } diff --git a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/keys/KeysService.kt b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/keys/KeysService.kt index dc837b129..a0236d7e6 100644 --- a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/keys/KeysService.kt +++ b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/keys/KeysService.kt @@ -27,7 +27,8 @@ object KeysService { WalletKeys.selectAll().where { WalletKeys.keyId eq keyId }.firstOrNull()?.let { WalletKey(it) } } - fun list(wallet: Uuid): List = WalletKeys.selectAll().where { WalletKeys.wallet eq wallet.toJavaUuid() }.map { WalletKey(it) } + fun list(wallet: Uuid): List = + WalletKeys.selectAll().where { WalletKeys.wallet eq wallet.toJavaUuid() }.map { WalletKey(it) } fun add(wallet: Uuid, keyId: String, document: String) = transaction { WalletKeys.insert { diff --git a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/notifications/NotificationService.kt b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/notifications/NotificationService.kt index 2017ba41a..b722ea3a7 100644 --- a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/notifications/NotificationService.kt +++ b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/notifications/NotificationService.kt @@ -43,7 +43,7 @@ object NotificationService { } fun delete(vararg ids: Uuid): Int = transaction { - WalletNotifications.deleteWhere { WalletNotifications.id inList ids.map { it.toJavaUuid() } } + WalletNotifications.deleteWhere { id inList ids.map { it.toJavaUuid() } } } fun update(vararg notification: Notification): Int = transaction { @@ -63,7 +63,8 @@ object NotificationService { }.andWhere { runCatching { LocalDate.parse(addedOn!!) }.getOrNull() ?.let { WalletNotifications.addedOn.date() eq dateParam(it.toJavaLocalDate()) } ?: Op.TRUE - }.orderBy(column = WalletNotifications.addedOn, + }.orderBy( + column = WalletNotifications.addedOn, order = ascending?.takeIf { it }?.let { SortOrder.ASC } ?: SortOrder.DESC) private fun insert(vararg notifications: Notification): List = WalletNotifications.batchInsert( diff --git a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/oidc4vc/TestCredentialWallet.kt b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/oidc4vc/TestCredentialWallet.kt index d06ad4d6e..ab5b4af0e 100644 --- a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/oidc4vc/TestCredentialWallet.kt +++ b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/oidc4vc/TestCredentialWallet.kt @@ -2,6 +2,7 @@ package id.walt.webwallet.service.oidc4vc + import COSE.AlgorithmID import com.nimbusds.jose.jwk.ECKey import id.walt.credentials.utils.VCFormat @@ -52,10 +53,7 @@ import io.ktor.util.* import kotlinx.coroutines.runBlocking import kotlinx.datetime.Clock import kotlinx.datetime.Instant -import kotlinx.serialization.encodeToString import kotlinx.serialization.json.* - - import kotlin.time.Duration import kotlin.time.Duration.Companion.minutes import kotlin.uuid.ExperimentalUuidApi @@ -199,7 +197,7 @@ class TestCredentialWallet( val documentWithDisclosures = if (selectedDisclosures?.containsKey(it.id) == true) { it.document + "~${selectedDisclosures[it.id]!!.joinToString("~")}" } else { - it.document + it.document } SDJwtVC.parse(documentWithDisclosures).present( @@ -289,12 +287,14 @@ class TestCredentialWallet( credential.document, rootPathMDoc, ) + CredentialFormat.sd_jwt_vc -> buildDescriptorMappingSDJwtVC( session.presentationDefinition, index, credential.document, "$", ) + else -> buildDescriptorMappingJwtVP( session.presentationDefinition, index, @@ -448,7 +448,7 @@ class TestCredentialWallet( rootPath: String = "$", ) = let { val vcJws = vcJwsStr.base64UrlToBase64().decodeJws() - val type = vcJws.payload["vc"]?.jsonObject?.get("type")?.jsonArray?.last()?.jsonPrimitive?.contentOrNull + vcJws.payload["vc"]?.jsonObject?.get("type")?.jsonArray?.last()?.jsonPrimitive?.contentOrNull ?: "VerifiableCredential" DescriptorMapping( diff --git a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/push/PushManager.kt b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/push/PushManager.kt index 1cc5a9830..ee6766e2e 100644 --- a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/push/PushManager.kt +++ b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/push/PushManager.kt @@ -5,7 +5,6 @@ import com.interaso.webpush.WebPushService import id.walt.commons.config.ConfigManager import id.walt.webwallet.config.PushConfig import io.github.oshai.kotlinlogging.KotlinLogging -import kotlinx.serialization.encodeToString import kotlinx.serialization.json.Json object PushManager { diff --git a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/settings/SettingsService.kt b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/settings/SettingsService.kt index 910d7f82a..70cf483f6 100644 --- a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/settings/SettingsService.kt +++ b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/service/settings/SettingsService.kt @@ -4,10 +4,8 @@ package id.walt.webwallet.service.settings import id.walt.webwallet.db.models.WalletSettings import kotlinx.serialization.Serializable -import kotlinx.serialization.encodeToString import kotlinx.serialization.json.Json import kotlinx.serialization.json.JsonObject - import org.jetbrains.exposed.sql.selectAll import org.jetbrains.exposed.sql.transactions.transaction import org.jetbrains.exposed.sql.upsert @@ -36,7 +34,8 @@ object SettingsService { } private fun tryParseSettings(settings: String?) = - runCatching { json.decodeFromString(settings ?: "") }.fold(onSuccess = { WalletSetting(it) }, + runCatching { json.decodeFromString(settings ?: "") }.fold( + onSuccess = { WalletSetting(it) }, onFailure = { WalletSetting.default }) } diff --git a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/usecase/claim/ClaimCommons.kt b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/usecase/claim/ClaimCommons.kt index c3062f398..e957ee788 100644 --- a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/usecase/claim/ClaimCommons.kt +++ b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/usecase/claim/ClaimCommons.kt @@ -36,19 +36,19 @@ object ClaimCommons { credentialType: String, eventUseCase: EventLogUseCase, ) = eventUseCase.log( - action = EventType.Credential.Receive, - originator = "", //parsedOfferReq.credentialOffer!!.credentialIssuer, - tenant = tenant, - accountId = account, - walletId = wallet, - data = eventUseCase.credentialEventData( - credential = credential, - subject = eventUseCase.subjectData(credential), - organization = eventUseCase.issuerData(credential), - type = credentialType - ), - credentialId = credential.id, - ) + action = EventType.Credential.Receive, + originator = "", //parsedOfferReq.credentialOffer!!.credentialIssuer, + tenant = tenant, + accountId = account, + walletId = wallet, + data = eventUseCase.credentialEventData( + credential = credential, + subject = eventUseCase.subjectData(credential), + organization = eventUseCase.issuerData(credential), + type = credentialType + ), + credentialId = credential.id, + ) fun storeWalletCredentials( wallet: Uuid, @@ -60,4 +60,4 @@ object ClaimCommons { credentials = credentials.toTypedArray(), ) } -} \ No newline at end of file +} diff --git a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/usecase/claim/ExternalSignatureClaimStrategy.kt b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/usecase/claim/ExternalSignatureClaimStrategy.kt index 6860d7c1b..fa4f3bc14 100644 --- a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/usecase/claim/ExternalSignatureClaimStrategy.kt +++ b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/usecase/claim/ExternalSignatureClaimStrategy.kt @@ -3,8 +3,8 @@ package id.walt.webwallet.usecase.claim import id.walt.crypto.keys.Key import id.walt.webwallet.service.SSIKit2WalletService import id.walt.webwallet.service.credentials.CredentialsService -import id.walt.webwallet.service.exchange.IssuanceServiceExternalSignatures.OfferedCredentialProofOfPossession import id.walt.webwallet.service.exchange.IssuanceServiceExternalSignatures +import id.walt.webwallet.service.exchange.IssuanceServiceExternalSignatures.OfferedCredentialProofOfPossession import id.walt.webwallet.usecase.event.EventLogUseCase import kotlin.uuid.ExperimentalUuidApi import kotlin.uuid.Uuid diff --git a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/usecase/claim/SilentClaimStrategy.kt b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/usecase/claim/SilentClaimStrategy.kt index d980f981f..8b731be45 100644 --- a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/usecase/claim/SilentClaimStrategy.kt +++ b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/usecase/claim/SilentClaimStrategy.kt @@ -104,7 +104,7 @@ class SilentClaimStrategy( addedOn = Clock.System.now(), manifest = data.manifest, deletedOn = null, - pending = issuerUseCase.get(wallet = it, did = issuerDid).getOrNull()?.authorized ?: true, + pending = issuerUseCase.get(wallet = it, did = issuerDid).getOrNull()?.authorized != false, format = data.format ), data.type ) diff --git a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/usecase/entity/EntityNameResolutionUseCase.kt b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/usecase/entity/EntityNameResolutionUseCase.kt index 6fb333e78..dc196d6b0 100644 --- a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/usecase/entity/EntityNameResolutionUseCase.kt +++ b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/usecase/entity/EntityNameResolutionUseCase.kt @@ -22,5 +22,5 @@ class EntityNameResolutionUseCase( private fun validateAge(age: Instant?) = age?.let { now().minus(it).inWholeDays <= cacheAge - } ?: false + } == true } diff --git a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/usecase/issuer/IssuerUseCaseImpl.kt b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/usecase/issuer/IssuerUseCaseImpl.kt index 22cf8fdc5..5b861e37b 100644 --- a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/usecase/issuer/IssuerUseCaseImpl.kt +++ b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/usecase/issuer/IssuerUseCaseImpl.kt @@ -55,9 +55,9 @@ class IssuerUseCaseImpl( suspend fun fetchCredentials(url: String): List { val issuerConfiguration = fetchConfiguration(url).jsonObject val credentialConfigurations = ( - issuerConfiguration["credential_configurations_supported"]?.jsonObject?.entries - ?: issuerConfiguration["credentials_supported"]?.jsonArray?.associateBy { it.jsonObject["id"]!!.jsonPrimitive.content }?.entries - ) + issuerConfiguration["credential_configurations_supported"]?.jsonObject?.entries + ?: issuerConfiguration["credentials_supported"]?.jsonArray?.associateBy { it.jsonObject["id"]!!.jsonPrimitive.content }?.entries + ) return credentialConfigurations?.mapNotNull { (key, value) -> value.jsonObject.let { jsonObject -> val format = jsonObject["format"]?.jsonPrimitive?.content diff --git a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/usecase/notification/NotificationFilterUseCase.kt b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/usecase/notification/NotificationFilterUseCase.kt index 346fbe76a..cceba901d 100644 --- a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/usecase/notification/NotificationFilterUseCase.kt +++ b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/usecase/notification/NotificationFilterUseCase.kt @@ -26,7 +26,7 @@ class NotificationFilterUseCase( notificationFormatter.format(it) } - private fun parseSortOrder(sort: String) = sort.lowercase().takeIf { it == "asc" }?.let { true } ?: false + private fun parseSortOrder(sort: String) = sort.lowercase().takeIf { it == "asc" }?.let { true } == true private fun filterPending(notifications: List, showPending: Boolean?) = showPending?.let { pending -> credentialService.get(notifications.mapNotNull { (it.data as? Notification.CredentialIssuanceData)?.credentialId }) diff --git a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/AccountController.kt b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/AccountController.kt index 0b372fd96..85c4f93f7 100644 --- a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/AccountController.kt +++ b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/AccountController.kt @@ -23,8 +23,8 @@ fun Application.accounts() { summary = "Get wallets associated with account" response { HttpStatusCode.OK to { body() } } }) { - val user = getUserUUID() - context.respond(AccountsService.getAccountWalletMappings("", user)) // FIXME -> TENANT HERE + val user = call.getUserUUID() + call.respond(AccountsService.getAccountWalletMappings("", user)) // FIXME -> TENANT HERE } } } diff --git a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/CategoryController.kt b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/CategoryController.kt index b3f0218ed..0d14ec1f2 100644 --- a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/CategoryController.kt +++ b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/CategoryController.kt @@ -1,3 +1,5 @@ +@file:OptIn(ExperimentalUuidApi::class) + package id.walt.webwallet.web.controllers import id.walt.webwallet.web.controllers.auth.getWalletService @@ -7,6 +9,7 @@ import io.ktor.server.application.* import io.ktor.server.response.* import io.ktor.server.util.* import kotlinx.serialization.json.JsonObject +import kotlin.uuid.ExperimentalUuidApi fun Application.categories() = walletRoute { route("categories", { @@ -21,7 +24,7 @@ fun Application.categories() = walletRoute { } } }) { - context.respond(getWalletService().listCategories()) + call.respond(call.getWalletService().listCategories()) } route("{name}", { request { @@ -38,9 +41,9 @@ fun Application.categories() = walletRoute { } }) { val name = call.parameters.getOrFail("name") - runCatching { getWalletService().addCategory(name) }.onSuccess { - context.respond(if (it) HttpStatusCode.Created else HttpStatusCode.BadRequest) - }.onFailure { context.respond(HttpStatusCode.BadRequest, it.localizedMessage) } + runCatching { call.getWalletService().addCategory(name) }.onSuccess { + call.respond(if (it) HttpStatusCode.Created else HttpStatusCode.BadRequest) + }.onFailure { call.respond(HttpStatusCode.BadRequest, it.localizedMessage) } } delete({ summary = "Delete category" @@ -50,9 +53,9 @@ fun Application.categories() = walletRoute { } }) { val name = call.parameters.getOrFail("name") - runCatching { getWalletService().deleteCategory(name) }.onSuccess { - context.respond(if (it) HttpStatusCode.Accepted else HttpStatusCode.BadRequest) - }.onFailure { context.respond(HttpStatusCode.BadRequest, it.localizedMessage) } + runCatching { call.getWalletService().deleteCategory(name) }.onSuccess { + call.respond(if (it) HttpStatusCode.Accepted else HttpStatusCode.BadRequest) + }.onFailure { call.respond(HttpStatusCode.BadRequest, it.localizedMessage) } } put("rename/{newName}", { summary = "Rename category" @@ -68,9 +71,9 @@ fun Application.categories() = walletRoute { }) { val oldName = call.parameters.getOrFail("name") val newName = call.parameters.getOrFail("newName") - runCatching { getWalletService().renameCategory(oldName, newName) }.onSuccess { - context.respond(if (it) HttpStatusCode.Accepted else HttpStatusCode.BadRequest) - }.onFailure { context.respond(HttpStatusCode.BadRequest, it.localizedMessage) } + runCatching { call.getWalletService().renameCategory(oldName, newName) }.onSuccess { + call.respond(if (it) HttpStatusCode.Accepted else HttpStatusCode.BadRequest) + }.onFailure { call.respond(HttpStatusCode.BadRequest, it.localizedMessage) } } } } diff --git a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/CredentialController.kt b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/CredentialController.kt index b0fbd1c2d..0647b9a3f 100644 --- a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/CredentialController.kt +++ b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/CredentialController.kt @@ -59,8 +59,8 @@ fun Application.credentials() = walletRoute { val showPending = call.request.queryParameters["showPending"]?.toBooleanStrictOrNull() val sortBy = call.request.queryParameters["sortBy"] ?: "addedOn" val descending = call.request.queryParameters["descending"].toBoolean() - context.respond( - getWalletService().listCredentials( + call.respond( + call.getWalletService().listCredentials( CredentialFilterObject( categories = categories, showDeleted = showDeleted, @@ -98,7 +98,7 @@ fun Application.credentials() = walletRoute { } }) { val credentialId = call.parameters.getOrFail("credentialId") - context.respond(getWalletService().getCredential(credentialId)) + call.respond(call.getWalletService().getCredential(credentialId)) } delete({ summary = "Delete a credential" @@ -115,8 +115,8 @@ fun Application.credentials() = walletRoute { }) { val credentialId = call.parameters.getOrFail("credentialId") val permanent = call.request.queryParameters["permanent"].toBoolean() - context.respond( - if (getWalletService().deleteCredential( + call.respond( + if (call.getWalletService().deleteCredential( credentialId, permanent ) ) HttpStatusCode.Accepted else HttpStatusCode.BadRequest @@ -135,8 +135,8 @@ fun Application.credentials() = walletRoute { } }) { val credentialId = call.parameters.getOrFail("credentialId") - runCatching { getWalletService().restoreCredential(credentialId) }.onSuccess { - context.respond(HttpStatusCode.OK, it) + runCatching { call.getWalletService().restoreCredential(credentialId) }.onSuccess { + call.respond(HttpStatusCode.OK, it) }.onFailure { throw it } @@ -149,8 +149,8 @@ fun Application.credentials() = walletRoute { } }) { val credentialId = call.parameters.getOrFail("credentialId") - runCatching { getWalletService().acceptCredential(CredentialRequestParameter(credentialId)) }.onSuccess { - if (it) context.respond(HttpStatusCode.Accepted) else context.respond(HttpStatusCode.BadRequest) + runCatching { call.getWalletService().acceptCredential(CredentialRequestParameter(credentialId)) }.onSuccess { + if (it) call.respond(HttpStatusCode.Accepted) else call.respond(HttpStatusCode.BadRequest) }.onFailure { throw it } @@ -172,15 +172,15 @@ fun Application.credentials() = walletRoute { val credentialId = call.parameters.getOrFail("credentialId") val requestParameter = call.receiveNullable() runCatching { - getWalletService().rejectCredential( + call.getWalletService().rejectCredential( CredentialRequestParameter( credentialId = credentialId, parameter = requestParameter ) ) }.onSuccess { - if (it) context.respond(HttpStatusCode.Accepted) else context.respond(HttpStatusCode.BadRequest) + if (it) call.respond(HttpStatusCode.Accepted) else call.respond(HttpStatusCode.BadRequest) }.onFailure { - context.respond(HttpStatusCode.BadRequest, it.localizedMessage) + call.respond(HttpStatusCode.BadRequest, it.localizedMessage) } } get("status", { @@ -198,11 +198,11 @@ fun Application.credentials() = walletRoute { }) { runCatching { val credentialId = call.parameters.getOrFail("credentialId") - WalletServiceManager.credentialStatusUseCase.get(getWalletId(), credentialId) + WalletServiceManager.credentialStatusUseCase.get(call.getWalletId(), credentialId) }.onSuccess { - context.respond(it) + call.respond(it) }.onFailure { - context.respond(HttpStatusCode.BadRequest, it.localizedMessage) + call.respond(HttpStatusCode.BadRequest, it.localizedMessage) } } route("category", { @@ -223,9 +223,9 @@ fun Application.credentials() = walletRoute { }) { val credentialId = call.parameters.getOrFail("credentialId") val categories = call.receive>() - runCatching { getWalletService().attachCategory(credentialId, categories) }.onSuccess { - if (it) context.respond(HttpStatusCode.Created) else context.respond(HttpStatusCode.BadRequest) - }.onFailure { context.respond(HttpStatusCode.BadRequest, it.localizedMessage) } + runCatching { call.getWalletService().attachCategory(credentialId, categories) }.onSuccess { + if (it) call.respond(HttpStatusCode.Created) else call.respond(HttpStatusCode.BadRequest) + }.onFailure { call.respond(HttpStatusCode.BadRequest, it.localizedMessage) } } delete({ summary = "Detach category from credential" @@ -237,9 +237,9 @@ fun Application.credentials() = walletRoute { }) { val credentialId = call.parameters.getOrFail("credentialId") val categories = call.receive>() - runCatching { getWalletService().detachCategory(credentialId, categories) }.onSuccess { - if (it) context.respond(HttpStatusCode.Accepted) else context.respond(HttpStatusCode.BadRequest) - }.onFailure { context.respond(HttpStatusCode.BadRequest, it.localizedMessage) } + runCatching { call.getWalletService().detachCategory(credentialId, categories) }.onSuccess { + if (it) call.respond(HttpStatusCode.Accepted) else call.respond(HttpStatusCode.BadRequest) + }.onFailure { call.respond(HttpStatusCode.BadRequest, it.localizedMessage) } } } } diff --git a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/DidController.kt b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/DidController.kt index 5dfc47314..948dd2bce 100644 --- a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/DidController.kt +++ b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/DidController.kt @@ -1,3 +1,5 @@ +@file:OptIn(ExperimentalUuidApi::class) + package id.walt.webwallet.web.controllers import id.walt.webwallet.db.models.WalletDid @@ -12,6 +14,7 @@ import io.ktor.server.application.* import io.ktor.server.response.* import kotlinx.coroutines.runBlocking import kotlinx.serialization.json.JsonObject +import kotlin.uuid.ExperimentalUuidApi fun Application.dids() = walletRoute { route("dids", { @@ -26,7 +29,7 @@ fun Application.dids() = walletRoute { } } }) { - context.respond(getWalletService().run { runBlocking { listDids() } }) + call.respond(call.getWalletService().run { runBlocking { listDids() } }) } route("{did}", { @@ -49,9 +52,9 @@ fun Application.dids() = walletRoute { } } }) { - context.respond( - getWalletService().loadDid( - context.parameters["did"] ?: throw IllegalArgumentException("No DID supplied") + call.respond( + call.getWalletService().loadDid( + call.parameters["did"] ?: throw IllegalArgumentException("No DID supplied") ) ) } @@ -63,11 +66,11 @@ fun Application.dids() = walletRoute { HttpStatusCode.BadRequest to { description = "DID could not be deleted" } } }) { - val success = getWalletService().deleteDid( - context.parameters["did"] ?: throw IllegalArgumentException("No DID supplied") + val success = call.getWalletService().deleteDid( + call.parameters["did"] ?: throw IllegalArgumentException("No DID supplied") ) - context.respond( + call.respond( if (success) HttpStatusCode.Accepted else HttpStatusCode.BadRequest ) @@ -89,10 +92,10 @@ fun Application.dids() = walletRoute { } response { HttpStatusCode.Accepted to { description = "Default DID updated" } } }) { - getWalletService().setDefault( - context.parameters["did"] ?: throw IllegalArgumentException("No DID supplied") + call.getWalletService().setDefault( + call.parameters["did"] ?: throw IllegalArgumentException("No DID supplied") ) - context.respond(HttpStatusCode.Accepted) + call.respond(HttpStatusCode.Accepted) } route("create", { diff --git a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/DidCreation.kt b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/DidCreation.kt index 2532218a0..3b335a84c 100644 --- a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/DidCreation.kt +++ b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/DidCreation.kt @@ -6,7 +6,9 @@ import io.ktor.http.* import io.ktor.server.response.* import io.ktor.server.routing.* import kotlinx.serialization.json.JsonPrimitive +import kotlin.uuid.ExperimentalUuidApi +@OptIn(ExperimentalUuidApi::class) object DidCreation { private const val DidKeyMethodName = "key" @@ -26,17 +28,17 @@ object DidCreation { } } }) { - getWalletService().createDid( - DidKeyMethodName, extractDidCreateParameters(DidKeyMethodName, context.request.queryParameters) - ).let { context.respond(it) } + call.getWalletService().createDid( + DidKeyMethodName, extractDidCreateParameters(DidKeyMethodName, call.request.queryParameters) + ).let { call.respond(it) } } post(DidJwkMethodName, { summary = "Create a did:jwk" }) { - getWalletService().createDid( - DidJwkMethodName, extractDidCreateParameters(DidJwkMethodName, context.request.queryParameters) - ).let { context.respond(it) } + call.getWalletService().createDid( + DidJwkMethodName, extractDidCreateParameters(DidJwkMethodName, call.request.queryParameters) + ).let { call.respond(it) } } post(DidWebMethodName, { @@ -50,8 +52,8 @@ object DidCreation { } } }) { - val parameters = extractDidCreateParameters(DidWebMethodName, context.request.queryParameters) - getWalletService().createDid(DidWebMethodName, parameters).let { context.respond(it) } + val parameters = extractDidCreateParameters(DidWebMethodName, call.request.queryParameters) + call.getWalletService().createDid(DidWebMethodName, parameters).let { call.respond(it) } } post(DidEbsiMethodName, { @@ -61,9 +63,9 @@ object DidCreation { queryParameter("bearerToken") { description = "Required for v1 (LegalEntity)" } } }) { - getWalletService().createDid( - DidEbsiMethodName, extractDidCreateParameters(DidEbsiMethodName, context.request.queryParameters) - ).let { context.respond(it) } + call.getWalletService().createDid( + DidEbsiMethodName, extractDidCreateParameters(DidEbsiMethodName, call.request.queryParameters) + ).let { call.respond(it) } } post(DidCheqdMethodName, { @@ -72,17 +74,17 @@ object DidCreation { queryParameter("network") { description = "testnet or mainnet" } } }) { - getWalletService().createDid( - DidCheqdMethodName, extractDidCreateParameters(DidCheqdMethodName, context.request.queryParameters) - ).let { context.respond(it) } + call.getWalletService().createDid( + DidCheqdMethodName, extractDidCreateParameters(DidCheqdMethodName, call.request.queryParameters) + ).let { call.respond(it) } } post(DidIotaMethodName, { summary = "Create a did:iota" }) { - getWalletService().createDid( - DidIotaMethodName, extractDidCreateParameters(DidIotaMethodName, context.request.queryParameters) - ).let { context.respond(it) } + call.getWalletService().createDid( + DidIotaMethodName, extractDidCreateParameters(DidIotaMethodName, call.request.queryParameters) + ).let { call.respond(it) } } } @@ -95,7 +97,7 @@ object DidCreation { when (method) { DidKeyMethodName -> mapOf( "useJwkJcsPub" to JsonPrimitive( - parameters["useJwkJcsPub"]?.toBoolean() ?: false + parameters["useJwkJcsPub"]?.toBoolean() == true ) ) diff --git a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/DidWebRegistryController.kt b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/DidWebRegistryController.kt index 0ad9888a6..fc2f697fc 100644 --- a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/DidWebRegistryController.kt +++ b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/DidWebRegistryController.kt @@ -23,7 +23,7 @@ fun Application.didRegistry() = webWalletRoute { } } }) { - context.respond(runBlocking { + call.respond(runBlocking { DidWebRegistryService.listRegisteredDids() }) } @@ -47,9 +47,9 @@ fun Application.didRegistry() = webWalletRoute { } }) { - val id = context.parameters["id"] ?: throw IllegalArgumentException("No ID supplied") + val id = call.parameters["id"] ?: throw IllegalArgumentException("No ID supplied") - context.respond( + call.respond( DidWebRegistryService.loadRegisteredDid(id) ) } diff --git a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/EventLogController.kt b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/EventLogController.kt index 269da5524..d25813071 100644 --- a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/EventLogController.kt +++ b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/EventLogController.kt @@ -63,10 +63,10 @@ fun Application.eventLogs() = walletRoute { val startingAfter = call.request.queryParameters["startingAfter"] val sortBy = call.request.queryParameters["sortBy"] val sortOrder = call.request.queryParameters["sortOrder"] - context.respond( + call.respond( eventFilterUseCase.filter( - accountId = getUserUUID(), - walletId = getWalletId(), + accountId = call.getUserUUID(), + walletId = call.getWalletId(), filter = EventLogFilter( limit = limit, startingAfter = startingAfter, @@ -91,8 +91,8 @@ fun Application.eventLogs() = walletRoute { HttpStatusCode.BadRequest to { description = "Event log could not be deleted" } } }) { - val id = context.parameters.getOrFail("id").toInt() - context.respond(HttpStatusCode.Accepted, eventUseCase.delete(id)) + val id = call.parameters.getOrFail("id").toInt() + call.respond(HttpStatusCode.Accepted, eventUseCase.delete(id)) } } } diff --git a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/HistoryController.kt b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/HistoryController.kt index 0c6928763..12dbdd952 100644 --- a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/HistoryController.kt +++ b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/HistoryController.kt @@ -1,3 +1,5 @@ +@file:OptIn(ExperimentalUuidApi::class) + package id.walt.webwallet.web.controllers import id.walt.webwallet.db.models.WalletOperationHistory @@ -8,6 +10,7 @@ import io.ktor.http.* import io.ktor.server.application.* import io.ktor.server.response.* import org.jetbrains.exposed.sql.transactions.transaction +import kotlin.uuid.ExperimentalUuidApi fun Application.history() = walletRoute { route("history", { @@ -21,8 +24,8 @@ fun Application.history() = walletRoute { } } }) { - val wallet = getWalletService() - context.respond(transaction { + val wallet = call.getWalletService() + call.respond(transaction { wallet.getHistory() }) } diff --git a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/IssuersController.kt b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/IssuersController.kt index 656beee69..c22b92ee1 100644 --- a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/IssuersController.kt +++ b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/IssuersController.kt @@ -31,7 +31,7 @@ fun Application.issuers() = walletRoute { } } }) { - context.respond(WalletServiceManager.issuerUseCase.list(getWalletService().walletId)) + call.respond(WalletServiceManager.issuerUseCase.list(call.getWalletService().walletId)) } post("add", { summary = "Add issuer to wallet" @@ -49,16 +49,16 @@ fun Application.issuers() = walletRoute { val issuer = call.receive() WalletServiceManager.issuerUseCase.add( IssuerDataTransferObject( - wallet = getWalletService().walletId, + wallet = call.getWalletService().walletId, did = issuer.name, description = issuer.description, uiEndpoint = issuer.uiEndpoint, configurationEndpoint = issuer.configurationEndpoint, ) ).onSuccess { - context.respond(HttpStatusCode.Created) + call.respond(HttpStatusCode.Created) }.onFailure { - context.respond(HttpStatusCode.BadRequest, it.localizedMessage) + call.respond(HttpStatusCode.BadRequest, it.localizedMessage) } } route("{issuer}", { @@ -83,10 +83,10 @@ fun Application.issuers() = walletRoute { } } }) { - WalletServiceManager.issuerUseCase.get(getWalletService().walletId, call.parameters.getOrFail("issuer")).onSuccess { - context.respond(it) + WalletServiceManager.issuerUseCase.get(call.getWalletService().walletId, call.parameters.getOrFail("issuer")).onSuccess { + call.respond(it) }.onFailure { - context.respondText(it.localizedMessage, ContentType.Text.Plain, HttpStatusCode.NotFound) + call.respondText(it.localizedMessage, ContentType.Text.Plain, HttpStatusCode.NotFound) } } put("authorize", { @@ -96,10 +96,10 @@ fun Application.issuers() = walletRoute { HttpStatusCode.BadRequest to { description = "Authorization failed" } } }) { - WalletServiceManager.issuerUseCase.authorize(getWalletService().walletId, call.parameters.getOrFail("issuer")).onSuccess { - context.respond(HttpStatusCode.Accepted) + WalletServiceManager.issuerUseCase.authorize(call.getWalletService().walletId, call.parameters.getOrFail("issuer")).onSuccess { + call.respond(HttpStatusCode.Accepted) }.onFailure { - context.respond(HttpStatusCode.BadRequest, it.localizedMessage) + call.respond(HttpStatusCode.BadRequest, it.localizedMessage) } } } @@ -125,10 +125,10 @@ fun Application.issuers() = walletRoute { } } }) { - WalletServiceManager.issuerUseCase.credentials(getWalletService().walletId, call.parameters.getOrFail("issuer")).onSuccess { - context.respond(it) + WalletServiceManager.issuerUseCase.credentials(call.getWalletService().walletId, call.parameters.getOrFail("issuer")).onSuccess { + call.respond(it) }.onFailure { - context.respond(HttpStatusCode.BadRequest, it.localizedMessage) + call.respond(HttpStatusCode.BadRequest, it.localizedMessage) } } } diff --git a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/KeyController.kt b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/KeyController.kt index b3f17c9a5..740ca12a5 100644 --- a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/KeyController.kt +++ b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/KeyController.kt @@ -1,3 +1,5 @@ +@file:OptIn(ExperimentalUuidApi::class) + package id.walt.webwallet.web.controllers import id.walt.crypto.keys.KeyGenerationRequest @@ -15,6 +17,7 @@ import io.ktor.server.util.* import kotlinx.coroutines.runBlocking import kotlinx.serialization.json.* import org.jetbrains.exposed.sql.transactions.transaction +import kotlin.uuid.ExperimentalUuidApi fun Application.keys() = walletRoute { route("keys", { @@ -29,7 +32,7 @@ fun Application.keys() = walletRoute { } } }) { - context.respond(getWalletService().run { transaction { runBlocking { listKeys() } } }) + call.respond(call.getWalletService().run { transaction { runBlocking { listKeys() } } }) } post("generate", { @@ -144,14 +147,14 @@ fun Application.keys() = walletRoute { } } }) { - val keyGenerationRequest = context.receive() + val keyGenerationRequest = call.receive() runCatching { - getWalletService().generateKey(keyGenerationRequest) + call.getWalletService().generateKey(keyGenerationRequest) }.onSuccess { - context.respond(HttpStatusCode.Created, it) + call.respond(HttpStatusCode.Created, it) }.onFailure { - context.respond(HttpStatusCode.BadRequest, it.localizedMessage) + call.respond(HttpStatusCode.BadRequest, it.localizedMessage) } } @@ -165,11 +168,11 @@ fun Application.keys() = walletRoute { val body = call.receiveText() runCatching { - getWalletService().importKey(body) + call.getWalletService().importKey(body) } .onSuccess { key -> - context.respond( + call.respond( HttpStatusCode.Created, key ) @@ -205,9 +208,9 @@ fun Application.keys() = walletRoute { } } }) { - val jwk = context.request.queryParameters.getOrFail("JWK") - val signature = context.receive() - context.respond(getWalletService().verify(jwk, signature)) + val jwk = call.request.queryParameters.getOrFail("JWK") + val signature = call.receive() + call.respond(call.getWalletService().verify(jwk, signature)) } @@ -229,9 +232,9 @@ fun Application.keys() = walletRoute { } } }) { - context.respond( - getWalletService().loadKey( - context.parameters["keyId"] ?: throw IllegalArgumentException("No key supplied") + call.respond( + call.getWalletService().loadKey( + call.parameters["keyId"] ?: throw IllegalArgumentException("No key supplied") ) ) } @@ -245,8 +248,8 @@ fun Application.keys() = walletRoute { } } }) { - val keyId = context.parameters["keyId"] ?: error("No key supplied") - context.respond(getWalletService().getKeyMeta(keyId)) + val keyId = call.parameters["keyId"] ?: error("No key supplied") + call.respond(call.getWalletService().getKeyMeta(keyId)) } get("export", { @@ -266,12 +269,12 @@ fun Application.keys() = walletRoute { } } }) { - val keyId = context.parameters["keyId"] ?: throw IllegalArgumentException("No key id provided.") + val keyId = call.parameters["keyId"] ?: throw IllegalArgumentException("No key id provided.") - val format = context.request.queryParameters["format"] ?: "JWK" - val loadPrivateKey = context.request.queryParameters["loadPrivateKey"].toBoolean() + val format = call.request.queryParameters["format"] ?: "JWK" + val loadPrivateKey = call.request.queryParameters["loadPrivateKey"].toBoolean() - context.respond(getWalletService().exportKey(keyId, format, loadPrivateKey)) + call.respond(call.getWalletService().exportKey(keyId, format, loadPrivateKey)) } delete({ @@ -282,10 +285,10 @@ fun Application.keys() = walletRoute { HttpStatusCode.BadRequest to { description = "Key could not be deleted" } } }) { - val keyId = context.parameters.getOrFail("keyId") + val keyId = call.parameters.getOrFail("keyId") - val success = getWalletService().deleteKey(keyId) - context.respond(if (success) HttpStatusCode.Accepted else HttpStatusCode.BadRequest) + val success = call.getWalletService().deleteKey(keyId) + call.respond(if (success) HttpStatusCode.Accepted else HttpStatusCode.BadRequest) } delete("remove", { @@ -295,10 +298,10 @@ fun Application.keys() = walletRoute { HttpStatusCode.BadRequest to { description = "Failed to remove the key" } } }) { - val keyId = context.parameters.getOrFail("keyId") + val keyId = call.parameters.getOrFail("keyId") - val success = getWalletService().removeKey(keyId) - context.respond(if (success) HttpStatusCode.Accepted else HttpStatusCode.BadRequest) + val success = call.getWalletService().removeKey(keyId) + call.respond(if (success) HttpStatusCode.Accepted else HttpStatusCode.BadRequest) } post("sign", { @@ -313,9 +316,9 @@ fun Application.keys() = walletRoute { } } }) { - val keyId = context.parameters.getOrFail("keyId") - val message = context.receive() - context.respond(getWalletService().sign(keyId, message)) + val keyId = call.parameters.getOrFail("keyId") + val message = call.receive() + call.respond(call.getWalletService().sign(keyId, message)) } } diff --git a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/ManifestController.kt b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/ManifestController.kt index 92805e7e3..055f75152 100644 --- a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/ManifestController.kt +++ b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/ManifestController.kt @@ -47,8 +47,8 @@ fun Application.manifest() = walletRoute { val credentialService = CredentialsService() val manifest = callManifest(call.parameters) { getManifest(it, credentialService) } when (manifest) { - null -> context.respond(HttpStatusCode.NoContent) - else -> context.respond(manifest) + null -> call.respond(HttpStatusCode.NoContent) + else -> call.respond(manifest) } } get("display", { @@ -75,8 +75,8 @@ fun Application.manifest() = walletRoute { }?.toString() when (manifest) { - null -> context.respond(HttpStatusCode.NoContent) - else -> context.respond(ManifestProvider.new(manifest).display()) + null -> call.respond(HttpStatusCode.NoContent) + else -> call.respond(ManifestProvider.new(manifest).display()) } } get("issuer", { @@ -103,8 +103,8 @@ fun Application.manifest() = walletRoute { }?.toString() when (manifest) { - null -> context.respond(HttpStatusCode.NoContent) - else -> context.respond(ManifestProvider.new(manifest).issuer()) + null -> call.respond(HttpStatusCode.NoContent) + else -> call.respond(ManifestProvider.new(manifest).issuer()) } } } @@ -140,8 +140,8 @@ fun Application.manifest() = walletRoute { val manifest = callManifest(call.parameters) { extractManifest(it) } when (manifest) { - null -> context.respond(HttpStatusCode.NoContent) - else -> context.respond(manifest) + null -> call.respond(HttpStatusCode.NoContent) + else -> call.respond(manifest) } } } diff --git a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/NotificationController.kt b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/NotificationController.kt index 015087e74..941426154 100644 --- a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/NotificationController.kt +++ b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/NotificationController.kt @@ -82,9 +82,9 @@ object NotificationController { } } }) { - context.respond( + call.respond( WalletServiceManager.notificationFilterUseCase.filter( - getWalletId(), NotificationFilterParameter( + call.getWalletId(), NotificationFilterParameter( type = call.request.queryParameters["type"], isRead = call.request.queryParameters["isRead"]?.toBooleanStrictOrNull(), addedOn = call.request.queryParameters["addedOn"], @@ -101,7 +101,7 @@ object NotificationController { HttpStatusCode.BadRequest to { description = "Notifications could not be deleted" } } }) { - context.respond(if (WalletServiceManager.notificationUseCase.deleteAll(getWalletId()) > 0) HttpStatusCode.Accepted else HttpStatusCode.BadRequest) + call.respond(if (WalletServiceManager.notificationUseCase.deleteAll(call.getWalletId()) > 0) HttpStatusCode.Accepted else HttpStatusCode.BadRequest) } put("status/{status}", { summary = "Set notification read status" @@ -123,7 +123,7 @@ object NotificationController { }) { val ids = call.receive>() val status = call.parameters.getOrFail("status").toBoolean() - context.respond( + call.respond( if (WalletServiceManager.notificationUseCase.setStatus( *ids.map { Uuid.parse(it) }.toTypedArray(), isRead = status ) > 0 @@ -149,7 +149,7 @@ object NotificationController { } }) { val id = call.parameters.getOrFail("id") - context.respond(WalletServiceManager.notificationUseCase.findById(Uuid.parse(id)).fold(onSuccess = { + call.respond(WalletServiceManager.notificationUseCase.findById(Uuid.parse(id)).fold(onSuccess = { it }, onFailure = { it.localizedMessage @@ -163,7 +163,7 @@ object NotificationController { } }) { val id = call.parameters.getOrFail("id") - context.respond(if (WalletServiceManager.notificationUseCase.deleteById(Uuid.parse(id)) > 0) HttpStatusCode.Accepted else HttpStatusCode.BadRequest) + call.respond(if (WalletServiceManager.notificationUseCase.deleteById(Uuid.parse(id)) > 0) HttpStatusCode.Accepted else HttpStatusCode.BadRequest) } } diff --git a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/ReasonController.kt b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/ReasonController.kt index 8c116aceb..84ec197ed 100644 --- a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/ReasonController.kt +++ b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/ReasonController.kt @@ -23,7 +23,7 @@ fun Application.reasons() = authenticatedWebWalletRoute { } }) { val service = RejectionReasonService() - context.respond(service.list()) + call.respond(service.list()) } } } diff --git a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/ReportsController.kt b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/ReportsController.kt index 5a45a3cf2..3bf9174b2 100644 --- a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/ReportsController.kt +++ b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/ReportsController.kt @@ -37,10 +37,10 @@ fun Application.reports() = walletRoute { } }) { val limit = call.request.queryParameters["limit"]?.toIntOrNull() - context.respond( - getWalletService().getFrequentCredentials( + call.respond( + call.getWalletService().getFrequentCredentials( CredentialReportRequestParameter( - walletId = getWalletId(), limit = limit + walletId = call.getWalletId(), limit = limit ) ) ) diff --git a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/SilentExchangeController.kt b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/SilentExchangeController.kt index ea9482ccf..9676e3594 100644 --- a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/SilentExchangeController.kt +++ b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/SilentExchangeController.kt @@ -29,9 +29,9 @@ fun Application.silentExchange() = webWalletRoute { runCatching { WalletServiceManager.silentClaimStrategy.claim(did, offer) }.onSuccess { - context.respond(HttpStatusCode.Accepted, it.size) + call.respond(HttpStatusCode.Accepted, it.size) }.onFailure { - context.respond(HttpStatusCode.BadRequest, it.localizedMessage) + call.respond(HttpStatusCode.BadRequest, it.localizedMessage) } } } diff --git a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/TrustController.kt b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/TrustController.kt index b47a2912b..8ffb02ec6 100644 --- a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/TrustController.kt +++ b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/TrustController.kt @@ -25,7 +25,7 @@ fun Application.trustRegistry() = authenticatedWebWalletRoute { val result = request.isVerifier.takeIf { it } ?.let { WalletServiceManager.verifierTrustValidationService.validate(request.did, request.credentialType, request.egfUri) } ?: WalletServiceManager.issuerTrustValidationService.validate(request.did, request.credentialType, request.egfUri) - context.respond(TrustResponse(result)) + call.respond(TrustResponse(result)) } } } diff --git a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/UtilityController.kt b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/UtilityController.kt index d9c57e3d6..022f69b58 100644 --- a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/UtilityController.kt +++ b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/UtilityController.kt @@ -11,24 +11,25 @@ import io.ktor.server.request.* import io.ktor.server.response.* fun Application.utility() { - webWalletRoute { - route("util", { tags = listOf("Utilities") }) { - post("parseMDoc", { - summary = "Parse MDOC document to JSON element" - request { - body { - example("Sample mdoc") { - value = "a267646f6354797065756f72672e69736f2e31383031332e352e312e6d444c6c6973737565725369676e6564a26a6e616d65537061636573a1716f72672e69736f2e31383031332e352e3183d8185852a4686469676573744944006672616e646f6d50fce6b21d930b5b99fad34980ab06c8ee71656c656d656e744964656e7469666965726b66616d696c795f6e616d656c656c656d656e7456616c756563446f65d8185852a4686469676573744944016672616e646f6d5058daba0e58ae65726d9ba1aaa62256ee71656c656d656e744964656e7469666965726a676976656e5f6e616d656c656c656d656e7456616c7565644a6f686ed8185858a4686469676573744944026672616e646f6d5063fd5066277bce71963369771b78c1f671656c656d656e744964656e7469666965726a62697274685f646174656c656c656d656e7456616c75656a313938302d30312d30316a697373756572417574688443a10126a1182159014b308201473081eea003020102020839edc87a9a78f92a300a06082a8648ce3d04030230173115301306035504030c0c4d444f4320524f4f54204341301e170d3234303530323133313333305a170d3235303530323133313333305a301b3119301706035504030c104d444f432054657374204973737565723059301306072a8648ce3d020106082a8648ce3d030107034200041b4448341885fa84140f77790c69de810b977a7236f490da306a0cbe2a0a441379ddde146b36a44b6ba7bbc067b04b71bad4b692a4616013d893d440ae253781a320301e300c0603551d130101ff04023000300e0603551d0f0101ff040403020780300a06082a8648ce3d04030203480030450221008e70041000ddec2a230b2586ecc59f8acd156f5d933d9363bc5e2263bb0ab69802201885a8b537327a69b022620f07c5c45d6293b86eed927a3f04e82cc51cadf8635901c3d8185901bea66776657273696f6e63312e306f646967657374416c676f726974686d675348412d3235366c76616c756544696765737473a1716f72672e69736f2e31383031332e352e31a3005820ac6801aa40d9871db115c9ba804bbccbddf7f29a6773d626cb6604d468e8714e015820066fc7c19bce2aeaf2d655351da21dbb12561db212e21e8c3e969fa469fd1c7c025820dbf831a97d5b504ca70c212224109e243f01f82cb4cde7c704a7166fd671ed326d6465766963654b6579496e666fa1696465766963654b6579a4010220012158200f08fd91a6b62e757e090514cd54d506ea4fb4354e10cdaa24c7748f59fb5e10225820ffa4113b5aef1a4dbd3fb4b9da126bc1ffc09b9cc679b4673dd321f021f2fc2167646f6354797065756f72672e69736f2e31383031332e352e312e6d444c6c76616c6964697479496e666fa3667369676e6564c0781e323032342d30372d32355431333a30353a33312e3438333237373433355a6976616c696446726f6dc0781e323032342d30372d32355431333a30353a33312e3438333237373738305a6a76616c6964556e74696cc0781e323032352d30372d32355431333a30353a33312e3438333237373836335a5840d57ee4f1a38cf49860b2f9b7c8f2469faa68720a8b731eae1d727e681bf0299fe86c0c120407cc8f0a7b951a6db6eac4c1905f07436fc556be1a65c13e432490" + webWalletRoute { + route("util", { tags = listOf("Utilities") }) { + post("parseMDoc", { + summary = "Parse MDOC document to JSON element" + request { + body { + example("Sample mdoc") { + value = + "a267646f6354797065756f72672e69736f2e31383031332e352e312e6d444c6c6973737565725369676e6564a26a6e616d65537061636573a1716f72672e69736f2e31383031332e352e3183d8185852a4686469676573744944006672616e646f6d50fce6b21d930b5b99fad34980ab06c8ee71656c656d656e744964656e7469666965726b66616d696c795f6e616d656c656c656d656e7456616c756563446f65d8185852a4686469676573744944016672616e646f6d5058daba0e58ae65726d9ba1aaa62256ee71656c656d656e744964656e7469666965726a676976656e5f6e616d656c656c656d656e7456616c7565644a6f686ed8185858a4686469676573744944026672616e646f6d5063fd5066277bce71963369771b78c1f671656c656d656e744964656e7469666965726a62697274685f646174656c656c656d656e7456616c75656a313938302d30312d30316a697373756572417574688443a10126a1182159014b308201473081eea003020102020839edc87a9a78f92a300a06082a8648ce3d04030230173115301306035504030c0c4d444f4320524f4f54204341301e170d3234303530323133313333305a170d3235303530323133313333305a301b3119301706035504030c104d444f432054657374204973737565723059301306072a8648ce3d020106082a8648ce3d030107034200041b4448341885fa84140f77790c69de810b977a7236f490da306a0cbe2a0a441379ddde146b36a44b6ba7bbc067b04b71bad4b692a4616013d893d440ae253781a320301e300c0603551d130101ff04023000300e0603551d0f0101ff040403020780300a06082a8648ce3d04030203480030450221008e70041000ddec2a230b2586ecc59f8acd156f5d933d9363bc5e2263bb0ab69802201885a8b537327a69b022620f07c5c45d6293b86eed927a3f04e82cc51cadf8635901c3d8185901bea66776657273696f6e63312e306f646967657374416c676f726974686d675348412d3235366c76616c756544696765737473a1716f72672e69736f2e31383031332e352e31a3005820ac6801aa40d9871db115c9ba804bbccbddf7f29a6773d626cb6604d468e8714e015820066fc7c19bce2aeaf2d655351da21dbb12561db212e21e8c3e969fa469fd1c7c025820dbf831a97d5b504ca70c212224109e243f01f82cb4cde7c704a7166fd671ed326d6465766963654b6579496e666fa1696465766963654b6579a4010220012158200f08fd91a6b62e757e090514cd54d506ea4fb4354e10cdaa24c7748f59fb5e10225820ffa4113b5aef1a4dbd3fb4b9da126bc1ffc09b9cc679b4673dd321f021f2fc2167646f6354797065756f72672e69736f2e31383031332e352e312e6d444c6c76616c6964697479496e666fa3667369676e6564c0781e323032342d30372d32355431333a30353a33312e3438333237373433355a6976616c696446726f6dc0781e323032342d30372d32355431333a30353a33312e3438333237373738305a6a76616c6964556e74696cc0781e323032352d30372d32355431333a30353a33312e3438333237373836335a5840d57ee4f1a38cf49860b2f9b7c8f2469faa68720a8b731eae1d727e681bf0299fe86c0c120407cc8f0a7b951a6db6eac4c1905f07436fc556be1a65c13e432490" + } + } + } + response { + HttpStatusCode.OK to { description = "MDoc successfully parsed to JSON" } + } + }) { + val mdoc = call.receive() + call.respond(DataElement.fromCBORHex(mdoc).toJsonElement()) } - } } - response { - HttpStatusCode.OK to { description = "MDoc successfully parsed to JSON" } - } - }) { - val mdoc = call.receive() - call.respond(DataElement.fromCBORHex(mdoc).toJsonElement()) - } } - } } diff --git a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/WalletSettingsController.kt b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/WalletSettingsController.kt index a94b1f342..3f8cc933c 100644 --- a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/WalletSettingsController.kt +++ b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/WalletSettingsController.kt @@ -1,3 +1,5 @@ +@file:OptIn(ExperimentalUuidApi::class) + package id.walt.webwallet.web.controllers import id.walt.webwallet.service.settings.WalletSetting @@ -10,6 +12,7 @@ import io.ktor.server.application.* import io.ktor.server.request.* import io.ktor.server.response.* import kotlinx.serialization.json.JsonObject +import kotlin.uuid.ExperimentalUuidApi fun Application.settings() = walletRoute { route("settings", { @@ -25,10 +28,10 @@ fun Application.settings() = walletRoute { HttpStatusCode.BadRequest to { description = "Error fetching wallet settings" } } }) { - runCatching { getWalletService().getSettings() }.onSuccess { - context.respond(HttpStatusCode.OK, it) + runCatching { call.getWalletService().getSettings() }.onSuccess { + call.respond(HttpStatusCode.OK, it) }.onFailure { - context.respond(HttpStatusCode.BadRequest, it.localizedMessage) + call.respond(HttpStatusCode.BadRequest, it.localizedMessage) } } //put @@ -44,11 +47,11 @@ fun Application.settings() = walletRoute { }) { runCatching { val request = call.receive() - getWalletService().setSettings(request) + call.getWalletService().setSettings(request) }.onSuccess { - context.respond(HttpStatusCode.Accepted) + call.respond(HttpStatusCode.Accepted) }.onFailure { - context.respond(HttpStatusCode.BadRequest, it.localizedMessage) + call.respond(HttpStatusCode.BadRequest, it.localizedMessage) } } } diff --git a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/Web3Controller.kt b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/Web3Controller.kt index 1d5d36868..8445bcc1e 100644 --- a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/Web3Controller.kt +++ b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/Web3Controller.kt @@ -31,8 +31,8 @@ fun Application.web3accounts() = walletRoute { } } }) { - val wallet = getWalletService() - context.respond>(wallet.getLinkedWallets()) + val wallet = call.getWalletService() + call.respond>(wallet.getLinkedWallets()) } post("link", { @@ -49,9 +49,9 @@ fun Application.web3accounts() = walletRoute { } } }) { - val wallet = getWalletService() + val wallet = call.getWalletService() val data = Json.decodeFromString(call.receive()) - context.respond(wallet.linkWallet(data)) + call.respond(wallet.linkWallet(data)) } post("unlink", { @@ -63,9 +63,9 @@ fun Application.web3accounts() = walletRoute { HttpStatusCode.OK to { description = "Wallet unlinked" } } }) { - val wallet = getWalletService() + val wallet = call.getWalletService() val walletId = Uuid.parse(call.receiveText()) - context.respond(wallet.unlinkWallet(walletId)) + call.respond(wallet.unlinkWallet(walletId)) } post("connect", { @@ -82,9 +82,9 @@ fun Application.web3accounts() = walletRoute { } } }) { - val wallet = getWalletService() + val wallet = call.getWalletService() val walletId = Uuid.parse(call.receiveText()) - context.respond(wallet.connectWallet(walletId)) + call.respond(wallet.connectWallet(walletId)) } post("disconnect", { @@ -96,9 +96,9 @@ fun Application.web3accounts() = walletRoute { HttpStatusCode.OK to { description = "Wallet disconnected" } } }) { - val wallet = getWalletService() + val wallet = call.getWalletService() val walletId = Uuid.parse(call.receiveText()) - context.respond(wallet.disconnectWallet(walletId)) + call.respond(wallet.disconnectWallet(walletId)) } } } diff --git a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/auth/AuthController.kt b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/auth/AuthController.kt index 0fdefaccf..67bfe7651 100644 --- a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/auth/AuthController.kt +++ b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/auth/AuthController.kt @@ -32,14 +32,13 @@ import io.ktor.server.auth.* import io.ktor.server.plugins.* import io.ktor.server.request.* import io.ktor.server.response.* +import io.ktor.server.routing.* import io.ktor.server.sessions.* -import io.ktor.util.pipeline.* import kotlinx.coroutines.runBlocking import kotlinx.datetime.Clock import kotlinx.datetime.toJavaInstant import kotlinx.serialization.Serializable import kotlinx.serialization.SerializationException -import kotlinx.serialization.encodeToString import kotlinx.serialization.json.* import org.jetbrains.exposed.sql.and import org.jetbrains.exposed.sql.selectAll @@ -58,9 +57,11 @@ data class ByteLoginRequest(val username: String, val password: ByteArray) { override fun toString() = "[LOGIN REQUEST FOR: $username]" } -data class LoginTokenSession(val token: String) : Principal +@Serializable +data class LoginTokenSession(val token: String) -data class OidcTokenSession(val token: String) : Principal +@Serializable +data class OidcTokenSession(val token: String) object AuthKeys { private val config = ConfigManager.getConfig() @@ -132,7 +133,7 @@ suspend fun ApplicationCall.getLoginRequest() = runCatching { }.getOrElse { throw LoginRequestError(it) } -suspend fun PipelineContext.doLogin() { +suspend fun RoutingContext.doLogin() { val reqBody = call.getLoginRequest() val authenticatedUser = AccountsService.authenticate("", reqBody).getOrThrow() val now = Clock.System.now().toJavaInstant() @@ -159,14 +160,14 @@ suspend fun PipelineContext.doLogin() { ) } -fun PipelineContext.getUserId() = - call.principal("auth-session") - ?: call.principal("auth-bearer") - ?: call.principal("auth-bearer-alternative") - ?: call.principal() // bearer is registered with no name for some reason +fun ApplicationCall.getUserId() = + principal("auth-session") + ?: principal("auth-bearer") + ?: principal("auth-bearer-alternative") + ?: principal() // bearer is registered with no name for some reason ?: throw UnauthorizedException("Could not find user authorization within request.") -suspend fun PipelineContext.getUserUUID() = +suspend fun ApplicationCall.getUserUUID() = runCatching { when { FeatureManager.isFeatureEnabled(FeatureCatalog.legacyAuthenticationFeature) -> Uuid.parse(getUserId().name) @@ -175,25 +176,23 @@ suspend fun PipelineContext.getUserUUID() = } }.getOrElse { throw IllegalArgumentException("Invalid user id: $it") } -fun PipelineContext.getWalletId() = +fun ApplicationCall.getWalletId() = runCatching { - Uuid.parse(call.parameters["wallet"] ?: throw IllegalArgumentException("No wallet ID provided")) + Uuid.parse(parameters["wallet"] ?: throw IllegalArgumentException("No wallet ID provided")) }.getOrElse { throw IllegalArgumentException("Invalid wallet ID provided: ${it.message}") } .also { ensurePermissionsForWallet(AccountWalletPermissions.READ_ONLY, walletId = it) } -suspend fun PipelineContext.getWalletService(walletId: Uuid) = - WalletServiceManager.getWalletService("", getUserUUID(), walletId) // FIXME -> TENANT HERE - -suspend fun PipelineContext.getWalletService() = - WalletServiceManager.getWalletService("", getUserUUID(), getWalletId()) // FIXME -> TENANT HERE +@OptIn(ExperimentalUuidApi::class) +suspend fun ApplicationCall.getWalletService(walletId: Uuid? = null) = + WalletServiceManager.getWalletService("", getUserUUID(), walletId ?: getWalletId()) // FIXME -> TENANT HERE -fun PipelineContext.getUsersSessionToken(): String? = - call.sessions.get(LoginTokenSession::class)?.token - ?: call.request.authorization()?.removePrefix("Bearer ") +fun ApplicationCall.getUsersSessionToken(): String? = + sessions.get(LoginTokenSession::class)?.token + ?: request.authorization()?.removePrefix("Bearer ") -fun PipelineContext.ensurePermissionsForWallet( +fun ApplicationCall.ensurePermissionsForWallet( required: AccountWalletPermissions, userId: Uuid = runBlocking { getUserUUID() }, diff --git a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/auth/Controller.kt b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/auth/Controller.kt index 971e35165..1330fb578 100644 --- a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/auth/Controller.kt +++ b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/auth/Controller.kt @@ -1,12 +1,10 @@ package id.walt.webwallet.web.controllers.auth import io.github.smiley4.ktorswaggerui.dsl.routes.OpenApiRoute -import io.ktor.server.application.* import io.ktor.server.routing.* -import io.ktor.util.pipeline.* interface Controller { fun routes(name: String): Route.() -> Route fun apiBuilder(): OpenApiRoute.() -> Unit - suspend fun PipelineContext.execute() -} \ No newline at end of file + suspend fun RoutingContext.execute() +} diff --git a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/auth/DefaultAuthRoutes.kt b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/auth/DefaultAuthRoutes.kt index 5f5fab7e9..c87d6e9ae 100644 --- a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/auth/DefaultAuthRoutes.kt +++ b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/auth/DefaultAuthRoutes.kt @@ -34,7 +34,7 @@ fun Application.defaultAuthRoutes() = webWalletRoute { } } }) { - getUsersSessionToken()?.run { + call.getUsersSessionToken()?.run { val jwsObject = JWSObject.parse(this) val uuid = Json.parseToJsonElement(jwsObject.payload.toString()).jsonObject["sub"]?.jsonPrimitive?.content.toString() @@ -42,7 +42,7 @@ fun Application.defaultAuthRoutes() = webWalletRoute { } ?: call.respond(HttpStatusCode.BadRequest) } get("session", { summary = "Return session ID if logged in" }) { - val token = getUsersSessionToken() ?: throw UnauthorizedException("Invalid session") + val token = call.getUsersSessionToken() ?: throw UnauthorizedException("Invalid session") call.respond(mapOf("token" to mapOf("accessToken" to token))) } } diff --git a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/auth/KtorAuthnzController.kt b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/auth/KtorAuthnzController.kt index fc680b224..b0f58244f 100644 --- a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/auth/KtorAuthnzController.kt +++ b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/auth/KtorAuthnzController.kt @@ -20,7 +20,6 @@ import io.github.smiley4.ktorswaggerui.dsl.routing.route import io.ktor.server.application.* import io.ktor.server.request.* import io.ktor.server.routing.* -import io.ktor.util.pipeline.* import kotlinx.datetime.Clock import kotlinx.datetime.toJavaInstant import org.jetbrains.exposed.sql.insert @@ -68,10 +67,10 @@ fun Application.ktorAuthnzRoutes() { summary = "Account authentication" description = "Configured authentication flow:

${flowConfig.toString().replace("\n", "
")}" }) { - val contextFunction: PipelineContext.() -> AuthContext = { + val contextFunction: ApplicationCall.() -> AuthContext = { AuthContext( - tenant = call.request.host(), - sessionId = call.parameters["sessionId"], + tenant = request.host(), + sessionId = parameters["sessionId"], implicitSessionGeneration = true, initialFlow = authConfig.authFlow ) diff --git a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/auth/KtorAuthnzFrontendController.kt b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/auth/KtorAuthnzFrontendController.kt index 51266e631..25609336e 100644 --- a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/auth/KtorAuthnzFrontendController.kt +++ b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/auth/KtorAuthnzFrontendController.kt @@ -31,7 +31,7 @@ fun Application.ktorAuthnzFrontendRoutes() { } } }) { - call.respond(getAuthenticatedAccount()) + call.respond(call.getAuthenticatedAccount()) } get("session", { summary = "Return session ID if logged in" }) { val token = getAuthenticatedSession().token ?: throw UnauthorizedException("Invalid session") @@ -52,12 +52,12 @@ fun Application.ktorAuthnzFrontendRoutes() { account to sessionToken } else { - val authenticatedAccount = getAuthenticatedAccount() + val authenticatedAccount = call.getAuthenticatedAccount() val authenticatedSessionToken = getAuthenticatedSession().token authenticatedAccount to authenticatedSessionToken } - context.respond( + call.respond( buildJsonObject { put("id", account) put("token", token) @@ -69,7 +69,7 @@ fun Application.ktorAuthnzFrontendRoutes() { call.response.cookies.append("ktor-authnz-auth", "", CookieEncoding.URI_ENCODING, 0L, GMTDate()) call.response.cookies.append("auth.token", "", CookieEncoding.URI_ENCODING, 0L, GMTDate()) - context.respond(HttpStatusCode.OK) + call.respond(HttpStatusCode.OK) } } } diff --git a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/auth/LoginControllerBase.kt b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/auth/LoginControllerBase.kt index 0501422c9..5e9d636fe 100644 --- a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/auth/LoginControllerBase.kt +++ b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/auth/LoginControllerBase.kt @@ -8,10 +8,8 @@ import io.github.smiley4.ktorswaggerui.dsl.routes.OpenApiRoute import io.github.smiley4.ktorswaggerui.dsl.routing.post import io.github.smiley4.ktorswaggerui.dsl.routing.route import io.ktor.http.* -import io.ktor.server.application.* import io.ktor.server.plugins.ratelimit.* import io.ktor.server.routing.* -import io.ktor.util.pipeline.* abstract class LoginControllerBase( private val path: String = defaultAuthPath, @@ -52,7 +50,7 @@ abstract class LoginControllerBase( } } - override suspend fun PipelineContext.execute() { + override suspend fun RoutingContext.execute() { doLogin() } } diff --git a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/auth/LogoutControllerBase.kt b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/auth/LogoutControllerBase.kt index ded1735ec..60052dedf 100644 --- a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/auth/LogoutControllerBase.kt +++ b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/auth/LogoutControllerBase.kt @@ -5,11 +5,9 @@ import io.github.smiley4.ktorswaggerui.dsl.routes.OpenApiRoute import io.github.smiley4.ktorswaggerui.dsl.routing.post import io.github.smiley4.ktorswaggerui.dsl.routing.route import io.ktor.http.* -import io.ktor.server.application.* import io.ktor.server.response.* import io.ktor.server.routing.* import io.ktor.server.sessions.* -import io.ktor.util.pipeline.* abstract class LogoutControllerBase( private val path: String = defaultAuthPath, @@ -28,12 +26,12 @@ abstract class LogoutControllerBase( response { HttpStatusCode.OK to { description = "Logged out." } } } - override suspend fun PipelineContext.execute() { + override suspend fun RoutingContext.execute() { clearUserSession() call.respond(HttpStatusCode.OK) } - protected fun PipelineContext.clearUserSession() { + protected fun RoutingContext.clearUserSession() { call.sessions.get()?.let { logger.debug { "Clearing login token session" } call.sessions.clear() @@ -44,4 +42,4 @@ abstract class LogoutControllerBase( call.sessions.clear() } } -} \ No newline at end of file +} diff --git a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/auth/RegisterControllerBase.kt b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/auth/RegisterControllerBase.kt index d1e64236d..51b609780 100644 --- a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/auth/RegisterControllerBase.kt +++ b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/auth/RegisterControllerBase.kt @@ -7,11 +7,9 @@ import io.github.smiley4.ktorswaggerui.dsl.routes.OpenApiRoute import io.github.smiley4.ktorswaggerui.dsl.routing.post import io.github.smiley4.ktorswaggerui.dsl.routing.route import io.ktor.http.* -import io.ktor.server.application.* import io.ktor.server.request.* import io.ktor.server.response.* import io.ktor.server.routing.* -import io.ktor.util.pipeline.* abstract class RegisterControllerBase( private val path: String = defaultAuthPath, @@ -53,7 +51,7 @@ abstract class RegisterControllerBase( } } - override suspend fun PipelineContext.execute() { + override suspend fun RoutingContext.execute() { // val jsonObject = call.receive() // val type = jsonObject["type"]?.jsonPrimitive?.contentOrNull // if (type.isNullOrEmpty()) { @@ -71,4 +69,4 @@ abstract class RegisterControllerBase( throw it } } -} \ No newline at end of file +} diff --git a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/auth/keycloak/KeycloakLogoutController.kt b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/auth/keycloak/KeycloakLogoutController.kt index 1f605a3a1..59905c4da 100644 --- a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/auth/keycloak/KeycloakLogoutController.kt +++ b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/auth/keycloak/KeycloakLogoutController.kt @@ -5,10 +5,9 @@ import id.walt.webwallet.web.controllers.auth.LogoutControllerBase import id.walt.webwallet.web.model.KeycloakLogoutRequest import io.github.smiley4.ktorswaggerui.dsl.routes.OpenApiRoute import io.ktor.http.* -import io.ktor.server.application.* import io.ktor.server.request.* import io.ktor.server.response.* -import io.ktor.util.pipeline.* +import io.ktor.server.routing.* import kotlinx.serialization.json.Json class KeycloakLogoutController : LogoutControllerBase(keycloakAuthPath, keycloakAuthTags) { @@ -29,10 +28,10 @@ class KeycloakLogoutController : LogoutControllerBase(keycloakAuthPath, keycloak response { HttpStatusCode.OK to { description = "Keycloak HTTP status code." } } } - override suspend fun PipelineContext.execute() { + override suspend fun RoutingContext.execute() { clearUserSession() logger.debug { "Clearing Keycloak user session" } val req = Json.decodeFromString(call.receive()) call.respond("Keycloak responded with: ${KeycloakAccountStrategy.logout(req)}") } -} \ No newline at end of file +} diff --git a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/auth/oidc/OidcLogoutController.kt b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/auth/oidc/OidcLogoutController.kt index 2b1e5a814..153553e96 100644 --- a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/auth/oidc/OidcLogoutController.kt +++ b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/auth/oidc/OidcLogoutController.kt @@ -3,13 +3,12 @@ package id.walt.webwallet.web.controllers.auth.oidc import id.walt.webwallet.service.WalletServiceManager.oidcConfig import id.walt.webwallet.web.controllers.auth.LogoutControllerBase import io.github.smiley4.ktorswaggerui.dsl.routes.OpenApiRoute -import io.ktor.server.application.* import io.ktor.server.response.* -import io.ktor.util.pipeline.* +import io.ktor.server.routing.* class OidcLogoutController : LogoutControllerBase() { override fun apiBuilder(): OpenApiRoute.() -> Unit = { description = "Logout via OIDC provider" } - override suspend fun PipelineContext.execute() { + override suspend fun RoutingContext.execute() { call.respondRedirect("${oidcConfig.logoutUrl}?post_logout_redirect_uri=${oidcConfig.publicBaseUrl}&client_id=${oidcConfig.clientId}") } -} \ No newline at end of file +} diff --git a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/exchange/ExchangeController.kt b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/exchange/ExchangeController.kt index 8c5a52ebd..8cddf317b 100644 --- a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/exchange/ExchangeController.kt +++ b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/exchange/ExchangeController.kt @@ -16,8 +16,8 @@ import id.walt.webwallet.web.controllers.auth.getUserUUID import id.walt.webwallet.web.controllers.auth.getWalletId import id.walt.webwallet.web.controllers.auth.getWalletService import id.walt.webwallet.web.controllers.exchange.openapi.ExchangeOpenApiCommons -import io.github.smiley4.ktorswaggerui.dsl.routing.get import id.walt.webwallet.web.controllers.walletRoute +import io.github.smiley4.ktorswaggerui.dsl.routing.get import io.github.smiley4.ktorswaggerui.dsl.routing.post import io.github.smiley4.ktorswaggerui.dsl.routing.route import io.ktor.http.* @@ -47,7 +47,7 @@ fun Application.exchange() = walletRoute { response(ExchangeOpenApiCommons.useOfferRequestEndpointResponseParams()) }) { - val wallet = getWalletService() + val wallet = call.getWalletService() val did = call.request.queryParameters["did"] ?: wallet.listDids().firstOrNull()?.did ?: throw IllegalArgumentException("No DID to use supplied and no DID was found in wallet.") @@ -58,7 +58,7 @@ fun Application.exchange() = walletRoute { runCatching { WalletServiceManager.explicitClaimStrategy.claim( tenant = wallet.tenant, - account = getUserUUID(), + account = call.getUserUUID(), wallet = wallet.walletId, did = did, offer = offer, @@ -74,10 +74,10 @@ fun Application.exchange() = walletRoute { ) } }.onSuccess { - context.respond(HttpStatusCode.OK, it) + call.respond(HttpStatusCode.OK, it) }.onFailure { error -> error.printStackTrace() - context.respond(HttpStatusCode.BadRequest, error.message ?: "Unknown error") + call.respond(HttpStatusCode.BadRequest, error.message ?: "Unknown error") } } post("matchCredentialsForPresentationDefinition", { @@ -94,9 +94,10 @@ fun Application.exchange() = walletRoute { } } }) { - val presentationDefinition = PresentationDefinition.fromJSON(context.receive()) - val matchedCredentials = WalletServiceManager.matchCredentialsForPresentationDefinition(getWalletId(), presentationDefinition) - context.respond(matchedCredentials) + val presentationDefinition = PresentationDefinition.fromJSON(call.receive()) + val matchedCredentials = + WalletServiceManager.matchCredentialsForPresentationDefinition(call.getWalletId(), presentationDefinition) + call.respond(matchedCredentials) } post("unmatchedCredentialsForPresentationDefinition", { summary = @@ -113,11 +114,11 @@ fun Application.exchange() = walletRoute { } } }) { - val presentationDefinition = PresentationDefinition.fromJSON(context.receive()) + val presentationDefinition = PresentationDefinition.fromJSON(call.receive()) val unmatchedCredentialTypes = WalletServiceManager.unmatchedPresentationDefinitionCredentialsUseCase.find( - getWalletId(), presentationDefinition + call.getWalletId(), presentationDefinition ) - context.respond(unmatchedCredentialTypes) + call.respond(unmatchedCredentialTypes) } post("usePresentationRequest", { @@ -128,7 +129,7 @@ fun Application.exchange() = walletRoute { } response(ExchangeOpenApiCommons.usePresentationRequestResponse()) }) { - val wallet = getWalletService() + val wallet = call.getWalletService() val req = call.receive() println("req: $req") @@ -169,7 +170,7 @@ fun Application.exchange() = walletRoute { ) ) - context.respond(HttpStatusCode.OK, mapOf("redirectUri" to result.getOrThrow())) + call.respond(HttpStatusCode.OK, mapOf("redirectUri" to result.getOrThrow())) } else { val err = result.exceptionOrNull() println("Presentation failed: $err") @@ -189,7 +190,7 @@ fun Application.exchange() = walletRoute { ) when (err) { is SSIKit2WalletService.PresentationError -> { - context.respond( + call.respond( HttpStatusCode.BadRequest, mapOf( "redirectUri" to err.redirectUri, "errorMessage" to err.message @@ -197,7 +198,7 @@ fun Application.exchange() = walletRoute { ) } - else -> context.respond(HttpStatusCode.BadRequest, mapOf("errorMessage" to err?.message)) + else -> call.respond(HttpStatusCode.BadRequest, mapOf("errorMessage" to err?.message)) } } } @@ -213,10 +214,10 @@ fun Application.exchange() = walletRoute { } } }) { - val wallet = getWalletService() + val wallet = call.getWalletService() val request = call.receiveText() val parsedRequest = wallet.resolvePresentationRequest(request) - context.respond(parsedRequest) + call.respond(parsedRequest) } post("resolveCredentialOffer", { summary = "Return resolved / parsed credential offer" @@ -232,14 +233,14 @@ fun Application.exchange() = walletRoute { } } }) { - val wallet = getWalletService() + val wallet = call.getWalletService() val request = call.receiveText() val reqParams = Url(request).parameters.toMap() val parsedOffer = wallet.resolveCredentialOffer(CredentialOfferRequest.fromHttpParameters(reqParams)) val serializedOffer = Json.encodeToString(CredentialOfferSerializer, parsedOffer) - context.respondText(serializedOffer, ContentType.Application.Json) + call.respondText(serializedOffer, ContentType.Application.Json) } get("resolveVctUrl", { summary = "Receive an verifiable credential type (VCT) URL and return resolved vct object as described in IETF SD-JWT VC" @@ -258,14 +259,14 @@ fun Application.exchange() = walletRoute { } }) { val vct = call.request.queryParameters["vct"] ?: throw IllegalArgumentException("VCT not set") - val wallet = getWalletService() + val wallet = call.getWalletService() runCatching { wallet.resolveVct(vct) }.onSuccess { - context.respond(HttpStatusCode.OK, it.toJSON()) + call.respond(HttpStatusCode.OK, it.toJSON()) }.onFailure { error -> error.printStackTrace() - context.respond(HttpStatusCode.BadRequest, error.message ?: "Unknown error") + call.respond(HttpStatusCode.BadRequest, error.message ?: "Unknown error") } } get("resolveIssuerOpenIDMetadata", { @@ -282,7 +283,7 @@ fun Application.exchange() = walletRoute { }) { val issuer = call.request.queryParameters["issuer"] ?: throw BadRequestException("Issuer base url not set") val serializedMetadata = Json.encodeToString(OpenIDProviderMetadataSerializer, OpenID4VCI.resolveCIProviderMetadata(issuer)) - context.respondText(serializedMetadata, ContentType.Application.Json) + call.respondText(serializedMetadata, ContentType.Application.Json) } } } diff --git a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/exchange/ExchangeExternalSignaturesController.kt b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/exchange/ExchangeExternalSignaturesController.kt index edd0ea4b8..fd39d2b41 100644 --- a/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/exchange/ExchangeExternalSignaturesController.kt +++ b/waltid-services/waltid-wallet-api/src/main/kotlin/id/walt/webwallet/web/controllers/exchange/ExchangeExternalSignaturesController.kt @@ -5,12 +5,13 @@ package id.walt.webwallet.web.controllers.exchange import com.nimbusds.jose.jwk.JWK import com.nimbusds.jose.jwk.KeyUse import com.nimbusds.jose.util.Base64URL -import id.walt.credentials.utils.VCFormat import id.walt.crypto.keys.KeyGenerationRequest import id.walt.crypto.keys.KeyManager import id.walt.crypto.keys.KeyType import id.walt.crypto.utils.JsonUtils.toJsonElement -import id.walt.oid4vc.data.* +import id.walt.oid4vc.data.CredentialFormat +import id.walt.oid4vc.data.ResponseMode +import id.walt.oid4vc.data.VpTokenParameter import id.walt.oid4vc.data.dif.PresentationSubmission import id.walt.oid4vc.errors.AuthorizationError import id.walt.oid4vc.requests.AuthorizationRequest @@ -48,7 +49,10 @@ import io.ktor.server.request.* import io.ktor.server.response.* import io.ktor.util.* import kotlinx.coroutines.runBlocking -import kotlinx.serialization.json.* +import kotlinx.serialization.json.JsonArray +import kotlinx.serialization.json.JsonPrimitive +import kotlinx.serialization.json.jsonArray +import kotlinx.serialization.json.jsonObject import kotlin.uuid.ExperimentalUuidApi import kotlin.uuid.Uuid @@ -101,7 +105,7 @@ fun Application.exchangeExternalSignatures() = walletRoute { } } }) { - val walletService = getWalletService() + val walletService = call.getWalletService() runCatching { val req = call.receive() logger.debug { "Request: $req" } @@ -169,7 +173,7 @@ fun Application.exchangeExternalSignatures() = walletRoute { req.disclosures, ) - val (rootPathVP, rootPathMDoc) = if (ietfVpTokenParams != null && w3cJwtVpTokenParams == null) { + val (rootPathVP, _) = if (ietfVpTokenParams != null && w3cJwtVpTokenParams == null) { Pair("$", "$[0]") } else if (ietfVpTokenParams != null) { Pair("$[0]", "$[1]") @@ -215,14 +219,14 @@ fun Application.exchangeExternalSignatures() = walletRoute { }.onSuccess { responsePayload -> logger.debug { "Response payload: $responsePayload" } - context.respond( + call.respond( HttpStatusCode.OK, responsePayload, ) }.onFailure { error -> logger.debug { "error: $error" } - context.respond( + call.respond( HttpStatusCode.BadRequest, error.message ?: "Unknown error", ) @@ -253,7 +257,7 @@ fun Application.exchangeExternalSignatures() = walletRoute { response(ExchangeOpenApiCommons.usePresentationRequestResponse()) }) { - val walletService = getWalletService() + val walletService = call.getWalletService() runCatching { val req = call.receive() @@ -312,7 +316,7 @@ fun Application.exchangeExternalSignatures() = walletRoute { if (authReq.responseMode == ResponseMode.direct_post_jwt) { val encKey = authReq.clientMetadata?.jwks?.get("keys")?.jsonArray?.first { jwk -> - JWK.parse(jwk.toString()).keyUse?.equals(KeyUse.ENCRYPTION) ?: false + JWK.parse(jwk.toString()).keyUse?.equals(KeyUse.ENCRYPTION) == true }?.jsonObject ?: throw Exception("No ephemeral reader key found") val ephemeralWalletKey = runBlocking { KeyManager.createKey(KeyGenerationRequest(keyType = KeyType.secp256r1)) } @@ -379,14 +383,14 @@ fun Application.exchangeExternalSignatures() = walletRoute { } else { throw PresentationError( message = - if (responseBody.isNotBlank()) "Presentation failed:\n $responseBody" - else "Presentation failed", + if (responseBody.isNotBlank()) "Presentation failed:\n $responseBody" + else "Presentation failed", redirectUri = "" ) } } }.onSuccess { - context.respond( + call.respond( HttpStatusCode.OK, it, ) @@ -394,7 +398,7 @@ fun Application.exchangeExternalSignatures() = walletRoute { logger.debug { "error: $error" } when (error) { is PresentationError -> { - context.respond( + call.respond( HttpStatusCode.BadRequest, mapOf( "redirectUri" to error.redirectUri, @@ -404,7 +408,7 @@ fun Application.exchangeExternalSignatures() = walletRoute { } else -> { - context.respond( + call.respond( HttpStatusCode.BadRequest, mapOf( "errorMessage" to error.message @@ -451,7 +455,7 @@ fun Application.exchangeExternalSignatures() = walletRoute { } } }) { - val walletService = getWalletService() + val walletService = call.getWalletService() runCatching { val req = call.receive() @@ -497,12 +501,12 @@ fun Application.exchangeExternalSignatures() = walletRoute { ) } }.onSuccess { responsePayload -> - context.respond( + call.respond( HttpStatusCode.OK, responsePayload, ) }.onFailure { error -> - context.respond( + call.respond( HttpStatusCode.BadRequest, error.message ?: "Unknown error", ) @@ -532,7 +536,7 @@ fun Application.exchangeExternalSignatures() = walletRoute { response(ExchangeOpenApiCommons.useOfferRequestEndpointResponseParams()) }) { - val walletService = getWalletService() + val walletService = call.getWalletService() runCatching { val req = call.receive() @@ -546,7 +550,7 @@ fun Application.exchangeExternalSignatures() = walletRoute { tenantId = walletService.tenant, accountId = walletService.accountId, walletId = walletService.walletId, - pending = req.requireUserInput ?: true, + pending = req.requireUserInput != false, did = did, offerURL = req.offerURL, credentialIssuerURL = req.credentialIssuer, @@ -554,12 +558,12 @@ fun Application.exchangeExternalSignatures() = walletRoute { offeredCredentialProofsOfPossession = req.offeredCredentialProofsOfPossession, ) }.onSuccess { walletCredentialList -> - context.respond( + call.respond( HttpStatusCode.OK, walletCredentialList, ) }.onFailure { error -> - context.respond( + call.respond( HttpStatusCode.BadRequest, error.message ?: "Unknown error", ) diff --git a/waltid-services/waltid-wallet-api/src/main/resources/example_klogging.conf b/waltid-services/waltid-wallet-api/src/main/resources/example_klogging.conf index 7de60d22a..40438a6d0 100644 --- a/waltid-services/waltid-wallet-api/src/main/resources/example_klogging.conf +++ b/waltid-services/waltid-wallet-api/src/main/resources/example_klogging.conf @@ -1,17 +1,17 @@ sinks = { - stdout = { - renderWith = "RENDER_ANSI" - sendTo = "STDOUT" - } + stdout = { + renderWith = "RENDER_ANSI" + sendTo = "STDOUT" + } } logging = [ - { - levelRanges = [ - { - fromMinLevel = "INFO" - toSinks = ["stdout"] - } - ] - } + { + levelRanges = [ + { + fromMinLevel = "INFO" + toSinks = ["stdout"] + } + ] + } ] diff --git a/waltid-services/waltid-wallet-api/src/test/kotlin/E2EWalletTestBase.kt b/waltid-services/waltid-wallet-api/src/test/kotlin/E2EWalletTestBase.kt index c32329d03..7576ef2dd 100644 --- a/waltid-services/waltid-wallet-api/src/test/kotlin/E2EWalletTestBase.kt +++ b/waltid-services/waltid-wallet-api/src/test/kotlin/E2EWalletTestBase.kt @@ -14,9 +14,7 @@ import io.ktor.client.call.* import io.ktor.client.request.* import io.ktor.client.statement.* import io.ktor.http.* -import kotlinx.serialization.encodeToString import kotlinx.serialization.json.* - import kotlin.test.assertEquals import kotlin.test.assertNotEquals import kotlin.test.assertNotNull diff --git a/waltid-services/waltid-wallet-api/src/test/kotlin/id/walt/webwallet/service/credentials/status/fetch/DefaultStatusListCredentialFetchStrategyTest.kt b/waltid-services/waltid-wallet-api/src/test/kotlin/id/walt/webwallet/service/credentials/status/fetch/DefaultStatusListCredentialFetchStrategyTest.kt index 9de753f63..799fbca75 100644 --- a/waltid-services/waltid-wallet-api/src/test/kotlin/id/walt/webwallet/service/credentials/status/fetch/DefaultStatusListCredentialFetchStrategyTest.kt +++ b/waltid-services/waltid-wallet-api/src/test/kotlin/id/walt/webwallet/service/credentials/status/fetch/DefaultStatusListCredentialFetchStrategyTest.kt @@ -76,12 +76,9 @@ class DefaultStatusListCredentialFetchStrategyTest { const val credentialResourcePath = "credential-status/status-list-credential" const val statusCredentialPath = "credentials/%s" - private val environment = applicationEngineEnvironment { - envConfig() - } - val server: ApplicationEngine by lazy { + val server: EmbeddedServer<*, *> by lazy { println("Initializing embedded webserver...") - embeddedServer(CIO, environment) + embeddedServer(CIO, applicationEnvironment(), { envConfig() }, module = { module() }) } private fun Application.module() { @@ -90,20 +87,17 @@ class DefaultStatusListCredentialFetchStrategyTest { } routing { get("credentials/{id}") { - val id = context.parameters.getOrFail("id") + val id = call.parameters.getOrFail("id") val credential = TestUtils.loadResource("$credentialResourcePath/$id.json") call.respond(credential) } } } - private fun ApplicationEngineEnvironmentBuilder.envConfig() { - module { - module() - } + private fun ApplicationEngine.Configuration.envConfig() { connector { port = serverPort } } } -} \ No newline at end of file +} diff --git a/waltid-services/waltid-wallet-api/src/test/kotlin/id/walt/webwallet/utils/PKIXUtilsTest.kt b/waltid-services/waltid-wallet-api/src/test/kotlin/id/walt/webwallet/utils/PKIXUtilsTest.kt index 3414cea76..4b16616b9 100644 --- a/waltid-services/waltid-wallet-api/src/test/kotlin/id/walt/webwallet/utils/PKIXUtilsTest.kt +++ b/waltid-services/waltid-wallet-api/src/test/kotlin/id/walt/webwallet/utils/PKIXUtilsTest.kt @@ -1,8 +1,8 @@ package id.walt.webwallet.utils import kotlinx.coroutines.test.runTest -import org.junit.Test import java.security.KeyPairGenerator +import kotlin.test.Test import kotlin.test.assertTrue class PKIXUtilsTest { @@ -18,6 +18,6 @@ class PKIXUtilsTest { val keyPair = keyPairGenerator.generateKeyPair() val pemEncodedPrivateKey = PKIXUtils.pemEncodeJavaPrivateKey(keyPair.private) val decodedPrivateKey = PKIXUtils.pemDecodeJavaPrivateKey(pemEncodedPrivateKey) - assertTrue { keyPair.private.encoded.contentEquals(decodedPrivateKey.encoded)} + assertTrue { keyPair.private.encoded.contentEquals(decodedPrivateKey.encoded) } } -} \ No newline at end of file +} diff --git a/waltid-services/waltid-wallet-api/src/test/resources/credential-status/status-list-credential/revocation-list-with-status-message-vc-wrapped.json b/waltid-services/waltid-wallet-api/src/test/resources/credential-status/status-list-credential/revocation-list-with-status-message-vc-wrapped.json index 805c64d7e..bf1d31698 100644 --- a/waltid-services/waltid-wallet-api/src/test/resources/credential-status/status-list-credential/revocation-list-with-status-message-vc-wrapped.json +++ b/waltid-services/waltid-wallet-api/src/test/resources/credential-status/status-list-credential/revocation-list-with-status-message-vc-wrapped.json @@ -1,19 +1,15 @@ { - "vc": - { - "type": - [ + "vc": { + "type": [ "VerifiableCredential", "RevocationList2020" ], - "credentialSubject": - { + "credentialSubject": { "id": "urn:uuid:cca8bd0a-83c2-4ae1-9f43-e99943cdfa5c", "type": "RevocationList2020", "statusPurpose": "status", "statusSize": 2, - "statusMessage": - [ + "statusMessage": [ { "status": "0x0", "message": "valid" @@ -34,4 +30,4 @@ "encodedList": "H4sIAAAAAAAA/zMwNABDAKb12i0IAAAA" } } -} \ No newline at end of file +} diff --git a/waltid-services/waltid-wallet-api/src/test/resources/credential-status/status-list-credential/revocation-list-with-status-message.json b/waltid-services/waltid-wallet-api/src/test/resources/credential-status/status-list-credential/revocation-list-with-status-message.json index 01fc9f023..05b10a4d2 100644 --- a/waltid-services/waltid-wallet-api/src/test/resources/credential-status/status-list-credential/revocation-list-with-status-message.json +++ b/waltid-services/waltid-wallet-api/src/test/resources/credential-status/status-list-credential/revocation-list-with-status-message.json @@ -1,17 +1,14 @@ { - "type": - [ + "type": [ "VerifiableCredential", "RevocationList2020" ], - "credentialSubject": - { + "credentialSubject": { "id": "urn:uuid:cca8bd0a-83c2-4ae1-9f43-e99943cdfa5c", "type": "RevocationList2020", "statusPurpose": "status", "statusSize": 2, - "statusMessage": - [ + "statusMessage": [ { "status": "0x0", "message": "valid" @@ -31,4 +28,4 @@ ], "encodedList": "H4sIAAAAAAAA/zMwNABDAKb12i0IAAAA" } -} \ No newline at end of file +} diff --git a/waltid-services/waltid-web3login-microservice/build.gradle.kts b/waltid-services/waltid-web3login-microservice/build.gradle.kts index 855a813f3..d235b0689 100644 --- a/waltid-services/waltid-web3login-microservice/build.gradle.kts +++ b/waltid-services/waltid-web3login-microservice/build.gradle.kts @@ -1,7 +1,8 @@ plugins { kotlin("jvm") version "2.0.0" - id("io.ktor.plugin") version "2.3.12" + id("io.ktor.plugin") version "3.1.0" id("org.jetbrains.kotlin.plugin.serialization") version "2.0.0" + id("com.github.ben-manes.versions") } group = "id.walt" @@ -27,7 +28,6 @@ dependencies { implementation("io.ktor:ktor-server-content-negotiation-jvm") implementation("io.ktor:ktor-serialization-kotlinx-json-jvm") implementation("io.ktor:ktor-server-cio-jvm") - testImplementation("io.ktor:ktor-server-tests-jvm") testImplementation(kotlin("test-junit")) // nftkit diff --git a/waltid-services/waltid-web3login-microservice/src/main/kotlin/id/walt/NftController.kt b/waltid-services/waltid-web3login-microservice/src/main/kotlin/id/walt/NftController.kt index ed5fb2b64..903c05038 100644 --- a/waltid-services/waltid-web3login-microservice/src/main/kotlin/id/walt/NftController.kt +++ b/waltid-services/waltid-web3login-microservice/src/main/kotlin/id/walt/NftController.kt @@ -37,7 +37,7 @@ fun Application.nfts() = walletRoute { }) { val nft = getNftService() val ecosystem = call.parameters["ecosystem"] ?: throw IllegalArgumentException("No ecosystem provided") - context.respond(nft.getChains(ecosystem = ecosystem)) + call.respond(nft.getChains(ecosystem = ecosystem)) } get("filter", { summary = "Fetch the list of tokens with details" @@ -61,9 +61,9 @@ fun Application.nfts() = walletRoute { } }) { val nft = getNftService() - val accountIds = context.request.queryParameters.getAll("accountId") - val networks = context.request.queryParameters.getAll("network") - context.respond( + val accountIds = call.request.queryParameters.getAll("accountId") + val networks = call.request.queryParameters.getAll("network") + call.respond( nft.filterTokens("", FilterParameter(accountIds ?: emptyList(), networks ?: emptyList())) // FIXME -> TENANT HERE ) @@ -91,7 +91,7 @@ fun Application.nfts() = walletRoute { val nft = getNftService() val chain = call.parameters["chain"] ?: throw IllegalArgumentException("No chain provided") val account = call.parameters["account"] ?: throw IllegalArgumentException("No account provided") - context.respond( + call.respond( nft.getTokens( "", // FIXME -> TENANT HERE ListFetchParameter( @@ -137,7 +137,7 @@ fun Application.nfts() = walletRoute { val account = call.parameters["account"] ?: throw IllegalArgumentException("No account provided") val contract = call.parameters["contract"] ?: throw IllegalArgumentException("No contract provided") val tokenId = call.parameters["tokenId"] ?: throw IllegalArgumentException("No tokenId provided") - val collection = context.request.queryParameters["collectionId"] + val collection = call.request.queryParameters["collectionId"] val nft = getNftService() runCatching { nft.getTokenDetails( @@ -151,7 +151,7 @@ fun Application.nfts() = walletRoute { ) ) }.onSuccess { - context.respond(it) + call.respond(it) }.onFailure { context.response.status(HttpStatusCode.NotFound) } } get("marketplace/{chain}/{contract}/{tokenId}", { @@ -185,7 +185,7 @@ fun Application.nfts() = walletRoute { tokenId = call.parameters["tokenId"] ?: throw IllegalArgumentException("No tokenId provided") ) )?.run { - context.respond(this) + call.respond(this) } ?: run { context.response.status(HttpStatusCode.NotFound) } @@ -217,7 +217,7 @@ fun Application.nfts() = walletRoute { ?: throw IllegalArgumentException("No contract provided"), ) )?.run { - context.respond(this) + call.respond(this) } ?: run { context.response.status(HttpStatusCode.NotFound) } diff --git a/waltid-services/waltid-web3login-microservice/src/main/kotlin/id/walt/plugins/Monitoring.kt b/waltid-services/waltid-web3login-microservice/src/main/kotlin/id/walt/plugins/Monitoring.kt index 88530779a..4bc819b85 100644 --- a/waltid-services/waltid-web3login-microservice/src/main/kotlin/id/walt/plugins/Monitoring.kt +++ b/waltid-services/waltid-web3login-microservice/src/main/kotlin/id/walt/plugins/Monitoring.kt @@ -1,7 +1,7 @@ package id.walt.plugins import io.ktor.server.application.* -import io.ktor.server.plugins.callloging.* +import io.ktor.server.plugins.calllogging.CallLogging import io.ktor.server.request.* import org.slf4j.event.*