File tree Expand file tree Collapse file tree 7 files changed +42
-6
lines changed
androidMain/kotlin/io/github/jan/supabase/auth
commonMain/kotlin/io/github/jan/supabase/auth
desktopMain/kotlin/io/github/jan/supabase/auth
nonDesktopMain/kotlin/io/github/jan/supabase/auth Expand file tree Collapse file tree 7 files changed +42
-6
lines changed Original file line number Diff line number Diff line change @@ -14,5 +14,5 @@ internal actual suspend fun Auth.startExternalAuth(
1414 getUrl : suspend (redirectTo: String? ) -> String ,
1515 onSessionSuccess : suspend (UserSession ) -> Unit
1616) {
17- supabaseClient.openExternalUrl( getUrl(redirectUrl))
17+ config.urlLauncher.openUrl(supabaseClient, getUrl(redirectUrl))
1818}
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package io.github.jan.supabase.auth
22
33import io.github.jan.supabase.SupabaseClientBuilder
44import io.github.jan.supabase.SupabaseSerializer
5+ import io.github.jan.supabase.annotations.SupabaseExperimental
56import io.github.jan.supabase.plugins.CustomSerializationConfig
67import io.github.jan.supabase.plugins.MainConfig
78import kotlinx.coroutines.CoroutineDispatcher
@@ -96,6 +97,12 @@ open class AuthConfigDefaults : MainConfig() {
9697 */
9798 var enableLifecycleCallbacks: Boolean = true
9899
100+ /* *
101+ * The URL launcher used to open OAuth links in the system browser.
102+ */
103+ @SupabaseExperimental
104+ var urlLauncher: UrlLauncher = UrlLauncher .DEFAULT
105+
99106}
100107
101108/* *
Original file line number Diff line number Diff line change 1+ package io.github.jan.supabase.auth
2+
3+ import io.github.jan.supabase.SupabaseClient
4+ import io.github.jan.supabase.annotations.SupabaseExperimental
5+
6+ /* *
7+ * A [UrlLauncher] is used to open a URL in the system browser.
8+ */
9+ @SupabaseExperimental
10+ fun interface UrlLauncher {
11+
12+ /* *
13+ * Open the given URL in the system browser.
14+ * @param url The URL to open.
15+ */
16+ suspend fun openUrl (supabase : SupabaseClient , url : String )
17+
18+ companion object {
19+
20+ /* *
21+ * Default implementation of [UrlLauncher] that opens the URL in the system browser.
22+ */
23+ val DEFAULT = UrlLauncher { supabase, url ->
24+ supabase.openExternalUrl(url)
25+ }
26+
27+ }
28+
29+ }
Original file line number Diff line number Diff line change @@ -13,7 +13,7 @@ internal actual suspend fun Auth.startExternalAuth(
1313) {
1414 withContext(Dispatchers .IO ) {
1515 if (redirectUrl != null ) {
16- supabaseClient.openExternalUrl( getUrl(redirectUrl))
16+ config.urlLauncher.openUrl(supabaseClient, getUrl(redirectUrl))
1717 return @withContext
1818 }
1919 createServer({
Original file line number Diff line number Diff line change @@ -2,7 +2,6 @@ package io.github.jan.supabase.auth.server
22
33import io.github.jan.supabase.auth.Auth
44import io.github.jan.supabase.auth.AuthImpl
5- import io.github.jan.supabase.auth.openExternalUrl
65import io.github.jan.supabase.auth.user.UserSession
76import io.github.jan.supabase.logging.d
87import io.ktor.http.ContentType
@@ -42,7 +41,8 @@ internal suspend fun createServer(
4241 Auth .logger.d {
4342 " Started OAuth callback server on port $port . Opening url in browser..."
4443 }
45- auth.supabaseClient.openExternalUrl(
44+ auth.config.urlLauncher.openUrl(
45+ auth.supabaseClient,
4646 url(
4747 " http://localhost:$port "
4848 )
Original file line number Diff line number Diff line change @@ -8,5 +8,5 @@ internal actual suspend fun Auth.startExternalAuth(
88 getUrl : suspend (redirectTo: String? ) -> String ,
99 onSessionSuccess : suspend (UserSession ) -> Unit
1010) {
11- supabaseClient.openExternalUrl( getUrl(redirectUrl))
11+ config.urlLauncher.openUrl(supabaseClient, getUrl(redirectUrl))
1212}
Original file line number Diff line number Diff line change @@ -11,5 +11,5 @@ org.jetbrains.compose.experimental.jscanvas.enabled=true
1111org.jetbrains.compose.experimental.wasm.enabled =true
1212org.jetbrains.dokka.experimental.gradle.pluginMode =V2Enabled
1313
14- supabase-version = 3.2.0-beta-1
14+ supabase-version = 3.2.0-beta-2
1515base-group = io.github.jan-tennert.supabase
You can’t perform that action at this time.
0 commit comments