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(
14
14
getUrl : suspend (redirectTo: String? ) -> String ,
15
15
onSessionSuccess : suspend (UserSession ) -> Unit
16
16
) {
17
- supabaseClient.openExternalUrl( getUrl(redirectUrl))
17
+ config.urlLauncher.openUrl(supabaseClient, getUrl(redirectUrl))
18
18
}
Original file line number Diff line number Diff line change @@ -2,6 +2,7 @@ package io.github.jan.supabase.auth
2
2
3
3
import io.github.jan.supabase.SupabaseClientBuilder
4
4
import io.github.jan.supabase.SupabaseSerializer
5
+ import io.github.jan.supabase.annotations.SupabaseExperimental
5
6
import io.github.jan.supabase.plugins.CustomSerializationConfig
6
7
import io.github.jan.supabase.plugins.MainConfig
7
8
import kotlinx.coroutines.CoroutineDispatcher
@@ -96,6 +97,12 @@ open class AuthConfigDefaults : MainConfig() {
96
97
*/
97
98
var enableLifecycleCallbacks: Boolean = true
98
99
100
+ /* *
101
+ * The URL launcher used to open OAuth links in the system browser.
102
+ */
103
+ @SupabaseExperimental
104
+ var urlLauncher: UrlLauncher = UrlLauncher .DEFAULT
105
+
99
106
}
100
107
101
108
/* *
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(
13
13
) {
14
14
withContext(Dispatchers .IO ) {
15
15
if (redirectUrl != null ) {
16
- supabaseClient.openExternalUrl( getUrl(redirectUrl))
16
+ config.urlLauncher.openUrl(supabaseClient, getUrl(redirectUrl))
17
17
return @withContext
18
18
}
19
19
createServer({
Original file line number Diff line number Diff line change @@ -2,7 +2,6 @@ package io.github.jan.supabase.auth.server
2
2
3
3
import io.github.jan.supabase.auth.Auth
4
4
import io.github.jan.supabase.auth.AuthImpl
5
- import io.github.jan.supabase.auth.openExternalUrl
6
5
import io.github.jan.supabase.auth.user.UserSession
7
6
import io.github.jan.supabase.logging.d
8
7
import io.ktor.http.ContentType
@@ -42,7 +41,8 @@ internal suspend fun createServer(
42
41
Auth .logger.d {
43
42
" Started OAuth callback server on port $port . Opening url in browser..."
44
43
}
45
- auth.supabaseClient.openExternalUrl(
44
+ auth.config.urlLauncher.openUrl(
45
+ auth.supabaseClient,
46
46
url(
47
47
" http://localhost:$port "
48
48
)
Original file line number Diff line number Diff line change @@ -8,5 +8,5 @@ internal actual suspend fun Auth.startExternalAuth(
8
8
getUrl : suspend (redirectTo: String? ) -> String ,
9
9
onSessionSuccess : suspend (UserSession ) -> Unit
10
10
) {
11
- supabaseClient.openExternalUrl( getUrl(redirectUrl))
11
+ config.urlLauncher.openUrl(supabaseClient, getUrl(redirectUrl))
12
12
}
Original file line number Diff line number Diff line change @@ -11,5 +11,5 @@ org.jetbrains.compose.experimental.jscanvas.enabled=true
11
11
org.jetbrains.compose.experimental.wasm.enabled =true
12
12
org.jetbrains.dokka.experimental.gradle.pluginMode =V2Enabled
13
13
14
- supabase-version = 3.2.0-beta-1
14
+ supabase-version = 3.2.0-beta-2
15
15
base-group = io.github.jan-tennert.supabase
You can’t perform that action at this time.
0 commit comments