Skip to content
Open
Show file tree
Hide file tree
Changes from 22 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,12 @@ build
**/.DS_Store
*.hprof
local.properties
.kotlin
.kotlin

xcuserdata
*.xcodeproj/*
!*.xcodeproj/project.pbxproj
!*.xcodeproj/xcshareddata/
!*.xcodeproj/project.xcworkspace/
!*.xcworkspace/contents.xcworkspacedata
**/xcshareddata/WorkspaceSettings.xcsettings
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ fun KotlinMultiplatformExtension.configureAndroidTarget() {
@OptIn(ExperimentalWasmDsl::class)
fun KotlinMultiplatformExtension.configureWasmTarget(baseName: String? = null) {
wasmJs {
outputModuleName.set(baseName ?: project.path.substring(1).replace(":","-").replace("-","_"))
outputModuleName.set(baseName ?: project.path.substring(1).replace(":", "-").replace("-", "_"))
browser {
commonWebpackConfig {
outputFileName = "$baseName.js"
Expand All @@ -31,6 +31,7 @@ fun KotlinMultiplatformExtension.configureWasmTarget(baseName: String? = null) {
// Serve sources to debug inside browser
add(project.projectDir.path)
add(project.projectDir.path + "/commonMain/")
add(project.projectDir.path + "/webMain/")
add(project.projectDir.path + "/wasmJsMain/")
}
}
Expand All @@ -39,6 +40,13 @@ fun KotlinMultiplatformExtension.configureWasmTarget(baseName: String? = null) {
}
}

fun KotlinMultiplatformExtension.configureJsTarget() {
js(IR) {
browser()
binaries.library()
}
}

fun KotlinMultiplatformExtension.configureIosTargets(baseName: String? = null) {
listOf(
iosX64(),
Expand Down
8 changes: 3 additions & 5 deletions oidc-appsupport/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,12 +1,9 @@
import com.android.build.gradle.internal.tasks.factory.dependsOn
import org.jetbrains.kotlin.gradle.plugin.mpp.Framework
import org.jetbrains.kotlin.gradle.plugin.mpp.KotlinNativeTarget
import org.publicvalue.convention.config.configureIosTargets
import org.publicvalue.convention.config.configureJsTarget
import org.publicvalue.convention.config.configureWasmTarget
import org.publicvalue.convention.config.exportKdoc
import java.nio.file.Files
import java.util.stream.Collectors.toList
import kotlin.io.path.name

plugins {
id("org.publicvalue.convention.android.library")
Expand All @@ -27,6 +24,7 @@ kotlin {
jvm()
configureIosTargets(baseName = "OpenIdConnectClient")
configureWasmTarget(baseName = "OpenIdConnectClient")
configureJsTarget()
sourceSets {
val commonMain by getting {
dependencies {
Expand Down Expand Up @@ -58,7 +56,7 @@ kotlin {
}
}

val wasmJsMain by getting {
val webMain by getting {
dependencies {
implementation(libs.kotlinx.browser)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import org.publicvalue.multiplatform.oidc.ExperimentalOpenIdConnect
import org.publicvalue.multiplatform.oidc.OpenIdConnectClient
import org.publicvalue.multiplatform.oidc.flows.CodeAuthFlow
import org.publicvalue.multiplatform.oidc.flows.EndSessionFlow
import org.publicvalue.multiplatform.oidc.flows.EndSessionResponse
import org.publicvalue.multiplatform.oidc.preferences.Preferences
import org.publicvalue.multiplatform.oidc.types.AuthCodeRequest
import org.publicvalue.multiplatform.oidc.types.EndSessionRequest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,16 @@ import kotlinx.browser.window
import org.publicvalue.multiplatform.oidc.ExperimentalOpenIdConnect
import org.publicvalue.multiplatform.oidc.OpenIdConnectClient
import org.publicvalue.multiplatform.oidc.flows.EndSessionFlow
import org.publicvalue.multiplatform.oidc.preferences.PREFERENCES_FILENAME
import org.publicvalue.multiplatform.oidc.preferences.PreferencesFactory

@ExperimentalOpenIdConnect
class WasmCodeAuthFlowFactory(
class WebCodeAuthFlowFactory(
private val windowTarget: String = "",
private val windowFeatures: String = "width=1000,height=800,resizable=yes,scrollbars=yes",
private val redirectOrigin: String = window.location.origin,
/** factory used to create preferences to save session information during login process. **/
private val preferencesFactory: PreferencesFactory = PreferencesFactory()
): CodeAuthFlowFactory {
) : CodeAuthFlowFactory {
override fun createAuthFlow(client: OpenIdConnectClient): PlatformCodeAuthFlow {
val preferences = preferencesFactory.create()
return PlatformCodeAuthFlow(windowTarget, windowFeatures, redirectOrigin, client, preferences)
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
@file:OptIn(ExperimentalWasmJsInterop::class)

package org.publicvalue.multiplatform.oidc.appsupport

import io.ktor.http.*
Expand All @@ -12,14 +14,16 @@ import org.w3c.dom.Window
import org.w3c.dom.events.Event
import kotlin.coroutines.resume
import kotlin.coroutines.suspendCoroutine
import kotlin.js.ExperimentalWasmJsInterop
import kotlin.js.js

@ExperimentalOpenIdConnect
internal class WebPopupFlow(
private val windowTarget: String = "",
private val windowFeatures: String = "width=1000,height=800,resizable=yes,scrollbars=yes",
private val redirectOrigin: String,
private val preferences: Preferences,
): WebAuthenticationFlow {
) : WebAuthenticationFlow {

private class WindowHolder(var window: Window?)

Expand Down
2 changes: 2 additions & 0 deletions oidc-core/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import org.publicvalue.convention.config.configureIosTargets
import org.publicvalue.convention.config.configureJsTarget
import org.publicvalue.convention.config.configureWasmTarget
import org.publicvalue.convention.config.exportKdoc

Expand All @@ -15,6 +16,7 @@ kotlin {
jvm()
configureIosTargets()
configureWasmTarget()
configureJsTarget()
sourceSets {
commonMain {
dependencies {
Expand Down
5 changes: 3 additions & 2 deletions oidc-crypto/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import org.gradle.nativeplatform.platform.internal.DefaultNativePlatform
import org.publicvalue.convention.config.configureIosTargets
import org.publicvalue.convention.config.configureJsTarget
import org.publicvalue.convention.config.configureWasmTarget
import org.publicvalue.convention.config.exportKdoc

Expand All @@ -16,6 +16,7 @@ kotlin {
jvm()
configureIosTargets()
configureWasmTarget()
configureJsTarget()
sourceSets {
val commonMain by getting {
dependencies {
Expand All @@ -34,7 +35,7 @@ kotlin {
}
}

val wasmJsMain by getting {
val webMain by getting {
dependencies {
implementation(project.dependencies.platform(libs.kotlincrypto.hash.bom))
implementation(libs.kotlincrypto.hash.sha2)
Expand Down
2 changes: 2 additions & 0 deletions oidc-ktor/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import org.publicvalue.convention.config.configureIosTargets
import org.publicvalue.convention.config.configureJsTarget
import org.publicvalue.convention.config.configureWasmTarget

plugins {
Expand All @@ -14,6 +15,7 @@ kotlin {
jvm()
configureIosTargets()
configureWasmTarget()
configureJsTarget()
sourceSets {
val commonMain by getting {
dependencies {
Expand Down
13 changes: 7 additions & 6 deletions oidc-preferences/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import org.publicvalue.convention.config.configureIosTargets
import org.publicvalue.convention.config.configureJsTarget
import org.publicvalue.convention.config.configureWasmTarget
import org.publicvalue.convention.config.exportKdoc

Expand All @@ -16,6 +17,7 @@ kotlin {
jvm()
configureIosTargets()
configureWasmTarget()
configureJsTarget()
sourceSets {
commonMain {
dependencies {
Expand All @@ -26,23 +28,22 @@ kotlin {
}
}

wasmJsMain {
webMain {
dependencies {
implementation(libs.kotlinx.browser)
}
}

val nonWasmJsMain by creating {
val nonWebMain by creating {
dependsOn(commonMain.get())
dependencies {
implementation(libs.androidx.datastore.core)
}
}

jvmMain.get().dependsOn(nonWasmJsMain)
iosMain.get().dependsOn(nonWasmJsMain)
androidMain.get().dependsOn(nonWasmJsMain)

jvmMain.get().dependsOn(nonWebMain)
iosMain.get().dependsOn(nonWebMain)
androidMain.get().dependsOn(nonWebMain)
}

exportKdoc()
Expand Down
2 changes: 2 additions & 0 deletions oidc-tokenstore/build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import org.publicvalue.convention.config.configureIosTargets
import org.publicvalue.convention.config.configureJsTarget
import org.publicvalue.convention.config.configureWasmTarget

plugins {
Expand All @@ -14,6 +15,7 @@ kotlin {
jvm()
configureIosTargets()
configureWasmTarget()
configureJsTarget()
sourceSets {
val commonMain by getting {
dependencies {
Expand Down
18 changes: 18 additions & 0 deletions sample-app/kotlin-js-store/wasm/yarn.lock
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need a yarn.lock because it's just a sample app, could you remove it?

Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1


"@js-joda/[email protected]":
version "3.2.0"
resolved "https://registry.yarnpkg.com/@js-joda/core/-/core-3.2.0.tgz#3e61e21b7b2b8a6be746df1335cf91d70db2a273"
integrity sha512-PMqgJ0sw5B7FKb2d5bWYIoxjri+QlW/Pys7+Rw82jSH0QN3rB05jZ/VrrsUdh1w4+i2kw9JOejXGq/KhDOX7Kg==

format-util@^1.0.5:
version "1.0.5"
resolved "https://registry.yarnpkg.com/format-util/-/format-util-1.0.5.tgz#1ffb450c8a03e7bccffe40643180918cc297d271"
integrity sha512-varLbTj0e0yVyRpqQhuWV+8hlePAgaoFRhNFj50BNjEIrw1/DphHSObtqwskVCPWNgzwPoQrZAbfa/SBiicNeg==

[email protected]:
version "8.18.3"
resolved "https://registry.yarnpkg.com/ws/-/ws-8.18.3.tgz#b56b88abffde62791c639170400c93dcb0c95472"
integrity sha512-PEIGCY5tSlUt50cqyMXfCzX+oOPqN0vuGqWzbcJ2xvnkzkq46oOpz7dQaTDBdfICb4N14+GARUDw2XV2N4tvzg==
Loading