Skip to content

Conversation

@availe
Copy link

@availe availe commented Nov 2, 2025

This is a PR for the JS issue.

Description of your changes

  • Replaced all wasmJs dependancies with webMain dependancies.
  • Made WebPopupFlow an expect class to allow for JS and wasmJS implementation.
  • Added WebMainCodeAuthFlowFactory which is a common factory for both JS and wasmJS targets.
  • Accepted some Intellj IDE suggestions, such as replacing parameters.get("...") with parameters["..."]

How has this been tested?

I tested using a Compose Multiplatform, where I used it to open and login via Keycloak Oidc.

Initially, I tested with "empty" implementations of the JS actual classes. I built my app with composeApp:jsBrowserDevelopmentRun It failed to do anything as expected. I then implemented the JS actual classes, and it worked.

Note that even Compose Web with JS fallback still uses wasm for the Skia UI. I have yet to test it with a pure Kotlin/JS implementation (such as Kotlin React), but I do not have much experience with Kotlin/JS.

Is this a (API-) breaking change?

It breaks an experimental API. Namely, WasmCodeAuthFlowFactory was renamed to WebMainCodeAuthFlowFactory.

Users would have to update import org.publicvalue.multiplatform.oidc.appsupport.WasmCodeAuthFlowFactory to import org.publicvalue.multiplatform.oidc.appsupport.WebMainCodeAuthFlowFactory

Copy link
Owner

@kalinjul kalinjul left a comment

Choose a reason for hiding this comment

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

I just had a quick look, didn't have time to test it yet.
Would the sample app work with this?

Comment on lines +26 to +45
val result = webFlow.startWebFlow(request.url, request.url.parameters["redirect_uri"].orEmpty())

if (result !is WebAuthenticationFlowResult.Success) {
// browser closed, no redirect
Result.failure(OpenIdConnectException.AuthenticationCancelled())
return Result.failure(OpenIdConnectException.AuthenticationCancelled())
}

if (result.responseUri == null) {
return Result.failure(OpenIdConnectException.AuthenticationFailure("No Uri in callback from browser."))
}

return when (val error = getErrorResult<AuthCodeResult>(result.responseUri)) {
null -> {
val state = result.responseUri.parameters["state"]
val code = result.responseUri.parameters["code"]
Result.success(AuthCodeResult(code, state))
}
else -> {
return error
}
Copy link
Owner

Choose a reason for hiding this comment

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

Can we keep this in the old-style nested form so it looks just like in iOS/Android/JVM?
I'd like to refactor out this code block anyways, until then i'd like to keep it structurally equal :)

add(project.projectDir.path)
add(project.projectDir.path + "/commonMain/")
add(project.projectDir.path + "/wasmJsMain/")
add(project.projectDir.path + "/webMain/")
Copy link
Owner

Choose a reason for hiding this comment

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

Maybe we need both webMain and wasmJsMain here?

Comment on lines +28 to +31
js(IR) {
browser()
binaries.library()
}
Copy link
Owner

Choose a reason for hiding this comment

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

Could we have this in a "configureJsTarget" function just like the others?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants