@@ -37,6 +37,7 @@ import com.descope.internal.others.debug
3737import com.descope.internal.others.error
3838import com.descope.internal.others.info
3939import com.descope.internal.others.isUnsafeEnabled
40+ import com.descope.internal.others.toJsonObject
4041import com.descope.internal.others.with
4142import com.descope.internal.routes.convert
4243import com.descope.internal.routes.getPackageOrigin
@@ -272,6 +273,7 @@ class DescopeFlowCoordinator(val webView: WebView) {
272273 ssoRedirect = pickRedirectUrl(flow?.ssoRedirect, flow?.ssoRedirectCustomScheme, useCustomSchemeFallback),
273274 magicLinkRedirect = flow?.magicLinkRedirect ? : " " ,
274275 isWebAuthnSupported = isWebAuthnSupported,
276+ clientJson = flow?.clientParams?.toJsonObject()?.toString()?.escapeForBackticks() ? : " {}"
275277 )
276278 ) {}
277279 }
@@ -537,6 +539,7 @@ private fun setupScript(
537539 ssoRedirect : String ,
538540 magicLinkRedirect : String ,
539541 isWebAuthnSupported : Boolean ,
542+ clientJson : String ,
540543) = """
541544
542545window.descopeBridge = {}
@@ -590,6 +593,18 @@ function flowBridgeSetRefreshJwt(wc, refreshJwt) {
590593 }
591594}
592595
596+ function flowBridgeMergeClientJson(wc, clientJson) {
597+ let client = {}
598+ try {
599+ client = JSON.parse(wc.getAttribute("client") || '{}')
600+ } catch (e) {}
601+ client = {
602+ ...client,
603+ ...JSON.parse(clientJson),
604+ }
605+ wc.setAttribute("client", JSON.stringify(client))
606+ }
607+
593608function flowBridgePrepareWebComponent(wc) {
594609 flowBridgeSetRefreshJwt(wc, '$refreshJwt ')
595610
@@ -623,6 +638,9 @@ function flowBridgePrepareWebComponent(wc) {
623638 flow.native(JSON.stringify(e.detail), window.location.href);
624639 })
625640
641+ // add incoming client params to any already exiting client parameters on the web-component
642+ flowBridgeMergeClientJson(wc, '$clientJson ')
643+
626644 // ensure we support old web-components without this function
627645 wc.lazyInit?.()
628646}
0 commit comments