Skip to content

Commit

Permalink
Initial commit
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-tennert committed Feb 1, 2023
1 parent aa1cfa3 commit 7859cf4
Show file tree
Hide file tree
Showing 14 changed files with 48 additions and 24 deletions.
2 changes: 1 addition & 1 deletion Functions/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ kotlin {
}
}
}
//ios()
ios()
sourceSets {
all {
languageSettings.optIn("kotlin.RequiresOptIn")
Expand Down
2 changes: 1 addition & 1 deletion GoTrue/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ kotlin {
}
}
}
//ios()
ios()
sourceSets {
all {
languageSettings.optIn("kotlin.RequiresOptIn")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package io.github.jan.supabase.gotrue

import io.github.jan.supabase.plugins.MainConfig

actual class GoTrueConfig : MainConfig, GoTrueConfigDefaults() {

/**
* The scheme for the redirect url, when using deep linking
*/
var scheme: String = "supabase"

/**
* The host for the redirect url, when using deep linking
*/
var host: String = "login"

}
12 changes: 0 additions & 12 deletions GoTrue/src/iosMain/kotlin/io/github/jan/supabase/gotrue/IOS.kt
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,6 @@ import io.github.jan.supabase.gotrue.user.UserSession
import platform.Foundation.NSURL
import platform.Foundation.NSURLComponents

var GoTrue.Config.scheme: String
get() = (params["scheme"] as? String) ?: "supabase"
set(value) {
params["scheme"] = value
}

var GoTrue.Config.host: String
get() = (params["host"] as? String) ?: "login"
set(value) {
params["host"] = value
}

@SupabaseExperimental
fun SupabaseClient.handleDeeplinks(url: NSURL, onSessionSuccess: (UserSession) -> Unit = {}) {
val components = NSURLComponents(url, true)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package io.github.jan.supabase.gotrue

actual fun GoTrue.generateRedirectUrl(fallbackUrl: String?): String? {
if(fallbackUrl != null) return fallbackUrl
this as GoTrueImpl
return "${config.scheme}://${config.host}"
}
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,13 @@ package io.github.jan.supabase.gotrue.providers
import io.github.aakira.napier.Napier
import io.github.jan.supabase.SupabaseClient
import io.github.jan.supabase.gotrue.gotrue
import io.github.jan.supabase.gotrue.host
import io.github.jan.supabase.gotrue.scheme
import io.github.jan.supabase.gotrue.user.UserSession
import platform.Foundation.NSURL
import platform.UIKit.UIApplication

actual abstract class OAuthProvider : AuthProvider<ExternalAuthConfig, Unit> {

actual abstract fun provider(): String
actual abstract val name: String

actual override suspend fun login(
supabaseClient: SupabaseClient,
Expand All @@ -34,7 +32,7 @@ actual abstract class OAuthProvider : AuthProvider<ExternalAuthConfig, Unit> {
private fun openOAuth(redirectUrl: String? = null, supabaseClient: SupabaseClient) {
val gotrue = supabaseClient.gotrue
val deepLink = "${gotrue.config.scheme}://${gotrue.config.host}"
val url = NSURL(supabaseClient.gotrue.resolveUrl("authorize?provider=${provider()}&redirect_to=${redirectUrl ?: deepLink}"))
val url = NSURL(supabaseClient.gotrue.resolveUrl("authorize?provider=$name&redirect_to=${redirectUrl ?: deepLink}"))
UIApplication.sharedApplication.openURL(url, emptyMap<Any?, Any>()) {
if(it) Napier.d { "Successfully opened provider url in safari" } else Napier.e { "Failed to open provider url in safari" }
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package io.github.jan.supabase.gotrue

import io.github.aakira.napier.Napier

actual fun GoTrue.setupPlatform() {
Napier.w { "IOS support is highly experimental, please report any bugs you find!" }
}
4 changes: 4 additions & 0 deletions GoTrue/src/iosTest/kotlin/platformSettings.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
import io.github.jan.supabase.gotrue.GoTrueConfig

actual fun GoTrueConfig.platformSettings() {
}

This file was deleted.

2 changes: 1 addition & 1 deletion Postgrest/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ kotlin {
}
}
}
//ios()
ios()
sourceSets {
all {
languageSettings.optIn("kotlin.RequiresOptIn")
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
package io.github.jan.supabase.postgrest

import kotlin.reflect.KProperty1

actual fun <T, V> getColumnName(property: KProperty1<T, V>) = property.name
2 changes: 1 addition & 1 deletion Realtime/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ kotlin {
}
}
}
//ios()
ios()
sourceSets {
all {
languageSettings.optIn("kotlin.RequiresOptIn")
Expand Down
2 changes: 1 addition & 1 deletion Storage/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ kotlin {
}
}
}
//ios()
ios()
sourceSets {
all {
languageSettings.optIn("kotlin.RequiresOptIn")
Expand Down
2 changes: 1 addition & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ kotlin {
}
}
}
//ios()
ios()
sourceSets {
all {
languageSettings.optIn("kotlin.RequiresOptIn")
Expand Down

0 comments on commit 7859cf4

Please sign in to comment.