-
-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'development' into wasm
# Conflicts: # gradle.properties # gradle/libs.versions.toml
- Loading branch information
Showing
90 changed files
with
1,350 additions
and
1,041 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,6 @@ package io.github.jan.supabase.gotrue | |
|
||
import co.touchlab.kermit.Logger | ||
import io.github.jan.supabase.SupabaseClient | ||
import io.github.jan.supabase.encodeToJsonElement | ||
import io.github.jan.supabase.exceptions.HttpRequestException | ||
import io.github.jan.supabase.exceptions.RestException | ||
import io.github.jan.supabase.gotrue.admin.AdminApi | ||
|
@@ -11,7 +10,6 @@ import io.github.jan.supabase.gotrue.providers.AuthProvider | |
import io.github.jan.supabase.gotrue.providers.ExternalAuthConfigDefaults | ||
import io.github.jan.supabase.gotrue.providers.Google | ||
import io.github.jan.supabase.gotrue.providers.OAuthProvider | ||
import io.github.jan.supabase.gotrue.providers.builtin.DefaultAuthProvider | ||
import io.github.jan.supabase.gotrue.providers.builtin.Email | ||
import io.github.jan.supabase.gotrue.providers.builtin.Phone | ||
import io.github.jan.supabase.gotrue.providers.builtin.SSO | ||
|
@@ -23,8 +21,6 @@ import io.github.jan.supabase.plugins.MainPlugin | |
import io.github.jan.supabase.plugins.SupabasePluginProvider | ||
import io.ktor.client.plugins.HttpRequestTimeoutException | ||
import kotlinx.coroutines.flow.StateFlow | ||
import kotlinx.serialization.json.JsonObject | ||
import kotlinx.serialization.json.jsonObject | ||
|
||
/** | ||
* Plugin to interact with the Supabase Auth API | ||
|
@@ -103,33 +99,6 @@ sealed interface Auth : MainPlugin<AuthConfig>, CustomSerializationPlugin { | |
config: (C.() -> Unit)? = null | ||
): R? | ||
|
||
/** | ||
* Logins the user with the specified [provider] | ||
* | ||
* Example: | ||
* ```kotlin | ||
* val result = gotrue.loginWith(Email) { | ||
* email = "[email protected]" | ||
* password = "password" | ||
* } | ||
* or | ||
* gotrue.loginWith(Google) // Opens the browser to login with google | ||
* ``` | ||
* | ||
* @param provider the provider to use for signing up. E.g. [Email], [Phone] or [Google] | ||
* @param redirectUrl The redirect url to use. If you don't specify this, the platform specific will be used, like deeplinks on android. | ||
* @param config The configuration to use for the sign-up. | ||
* @throws RestException or one of its subclasses if receiving an error response | ||
* @throws HttpRequestTimeoutException if the request timed out | ||
* @throws HttpRequestException on network related issues | ||
*/ | ||
@Deprecated("Use signInWith instead", ReplaceWith("signInWith(provider, redirectUrl, config)")) | ||
suspend fun <C, R, Provider : AuthProvider<C, R>> loginWith( | ||
provider: Provider, | ||
redirectUrl: String? = null, | ||
config: (C.() -> Unit)? = null | ||
) = signInWith(provider, redirectUrl, config) | ||
|
||
/** | ||
* Signs in the user with the specified [provider] | ||
* | ||
|
@@ -140,12 +109,12 @@ sealed interface Auth : MainPlugin<AuthConfig>, CustomSerializationPlugin { | |
* password = "password" | ||
* } | ||
* or | ||
* gotrue.loginWith(Google) // Opens the browser to login with google | ||
* gotrue.signInWith(Google) // Opens the browser to login with google | ||
* ``` | ||
* | ||
* @param provider the provider to use for signing up. E.g. [Email], [Phone] or [Google] | ||
* @param provider the provider to use for signing in. E.g. [Email], [Phone] or [Google] | ||
* @param redirectUrl The redirect url to use. If you don't specify this, the platform specific will be used, like deeplinks on android. | ||
* @param config The configuration to use for the sign-up. | ||
* @param config The configuration to use for the sign-in. | ||
* @throws RestException or one of its subclasses if receiving an error response | ||
* @throws HttpRequestTimeoutException if the request timed out | ||
* @throws HttpRequestException on network related issues | ||
|
@@ -158,11 +127,10 @@ sealed interface Auth : MainPlugin<AuthConfig>, CustomSerializationPlugin { | |
|
||
/** | ||
* Retrieves the sso url for the specified [type] | ||
* @param type The type of sso to retrieve e.g. [SSO.withDomain] or [SSO.withProvider] | ||
* @param redirectUrl The redirect url to use | ||
* @param config The configuration to use | ||
*/ | ||
suspend fun <Config: SSO.Config> retrieveSSOUrl(type: SSO<Config>, redirectUrl: String? = null, config: (Config.() -> Unit)? = null): SSO.Result | ||
suspend fun retrieveSSOUrl(redirectUrl: String? = null, config: SSO.Config.() -> Unit): SSO.Result | ||
|
||
/** | ||
* Modifies the current user | ||
|
@@ -178,32 +146,6 @@ sealed interface Auth : MainPlugin<AuthConfig>, CustomSerializationPlugin { | |
config: UserUpdateBuilder.() -> Unit | ||
): UserInfo | ||
|
||
/** | ||
* Sends a one time password to the specified [provider] | ||
* | ||
* Example: | ||
* ```kotlin | ||
* gotrue.sendOtpTo(Email) { | ||
* email = "[email protected]" | ||
* password = "password" | ||
* } | ||
* ``` | ||
* | ||
* @param provider The provider to use. Either [Email] or [Phone] | ||
* @param createUser Whether to create a user when a user with the given credentials doesn't exist | ||
* @param redirectUrl The redirect url to use. If you don't specify this, the platform specific will be use, like deeplinks on android. | ||
* @throws RestException or one of its subclasses if receiving an error response | ||
* @throws HttpRequestTimeoutException if the request timed out | ||
* @throws HttpRequestException on network related issues | ||
*/ | ||
suspend fun <C, R, Provider : DefaultAuthProvider<C, R>> sendOtpTo( | ||
provider: Provider, | ||
createUser: Boolean = false, | ||
redirectUrl: String? = null, | ||
data: JsonObject? = null, | ||
config: C.() -> Unit | ||
) | ||
|
||
/** | ||
* Resends an existing signup confirmation email, email change email | ||
* @param type The email otp type | ||
|
@@ -259,12 +201,12 @@ sealed interface Auth : MainPlugin<AuthConfig>, CustomSerializationPlugin { | |
* Verifies a phone/sms otp | ||
* @param type The type of the verification | ||
* @param token The otp to verify | ||
* @param phoneNumber The phone number the token was sent to | ||
* @param phone The phone number the token was sent to | ||
* @throws RestException or one of its subclasses if receiving an error response | ||
* @throws HttpRequestTimeoutException if the request timed out | ||
* @throws HttpRequestException on network related issues | ||
*/ | ||
suspend fun verifyPhoneOtp(type: OtpType.Phone, phoneNumber: String, token: String, captchaToken: String? = null) | ||
suspend fun verifyPhoneOtp(type: OtpType.Phone, phone: String, token: String, captchaToken: String? = null) | ||
|
||
/** | ||
* Retrieves the user attached to the specified [jwt] | ||
|
@@ -284,14 +226,14 @@ sealed interface Auth : MainPlugin<AuthConfig>, CustomSerializationPlugin { | |
suspend fun retrieveUserForCurrentSession(updateSession: Boolean = false): UserInfo | ||
|
||
/** | ||
* Logs out the current user, which means [sessionStatus] will be [SessionStatus.NotAuthenticated] and the access token will be revoked | ||
* @param scope The scope of the logout. | ||
* Signs out the current user, which means [sessionStatus] will be [SessionStatus.NotAuthenticated] and the access token will be revoked | ||
* @param scope The scope of the sign-out. | ||
* @throws RestException or one of its subclasses if receiving an error response | ||
* @throws HttpRequestTimeoutException if the request timed out | ||
* @throws HttpRequestException on network related issues | ||
* @see LogoutScope | ||
* @see SignOutScope | ||
*/ | ||
suspend fun logout(scope: LogoutScope = LogoutScope.LOCAL) | ||
suspend fun signOut(scope: SignOutScope = SignOutScope.LOCAL) | ||
|
||
/** | ||
* Imports a user session and starts auto-refreshing if [autoRefresh] is true | ||
|
@@ -307,7 +249,7 @@ sealed interface Auth : MainPlugin<AuthConfig>, CustomSerializationPlugin { | |
suspend fun importAuthToken(accessToken: String, refreshToken: String = "", retrieveUser: Boolean = false, autoRefresh: Boolean = if(refreshToken.isNotBlank()) config.alwaysAutoRefresh else false) = importSession(UserSession(accessToken, refreshToken, "", "", 0L, "", if(retrieveUser) tryToGetUser(accessToken) else null), autoRefresh) | ||
|
||
/** | ||
* Retrieves the latest session from storage and starts auto-refreshing if [autoRefresh] is true or [Auth.Config.alwaysAutoRefresh] as the default parameter | ||
* Retrieves the latest session from storage and starts auto-refreshing if [autoRefresh] is true or [AuthConfig.alwaysAutoRefresh] as the default parameter | ||
* @return true, if a session was found, false otherwise | ||
*/ | ||
suspend fun loadFromStorage(autoRefresh: Boolean = config.alwaysAutoRefresh): Boolean | ||
|
@@ -393,41 +335,6 @@ sealed interface Auth : MainPlugin<AuthConfig>, CustomSerializationPlugin { | |
|
||
} | ||
|
||
/** | ||
* Sends a one time password to the specified [provider] | ||
* | ||
* Example: | ||
* ```kotlin | ||
* gotrue.sendOtpTo(Email) { | ||
* email = "[email protected]" | ||
* password = "password" | ||
* } | ||
* ``` | ||
* | ||
* @param provider The provider to use. Either [Email] or [Phone] | ||
* @param createUser Whether to create a user when a user with the given credentials doesn't exist | ||
* @param redirectUrl The redirect url to use. If you don't specify this, the platform specific will be used, like deeplinks on android. | ||
* @throws RestException or one of its subclasses if receiving an error response | ||
* @throws HttpRequestTimeoutException if the request timed out | ||
* @throws HttpRequestException on network related issues | ||
*/ | ||
suspend inline fun <C, R, reified D : Any, Provider : DefaultAuthProvider<C, R>> Auth.sendOtpTo( | ||
provider: Provider, | ||
data: D, | ||
createUser: Boolean = false, | ||
redirectUrl: String? = null, | ||
noinline config: C.() -> Unit = { } | ||
): Unit = sendOtpTo(provider, createUser, redirectUrl, this.serializer.encodeToJsonElement(data).jsonObject, config) | ||
|
||
/** | ||
* The Auth plugin handles everything related to supabase's authentication system | ||
* | ||
* **DEPRECATED** Use [auth] instead | ||
*/ | ||
@Deprecated("Use auth instead", ReplaceWith("auth", "io.github.jan.supabase.gotrue.auth"), DeprecationLevel.WARNING) | ||
val SupabaseClient.gotrue: GoTrue | ||
get() = pluginManager.getPlugin(GoTrue) | ||
|
||
/** | ||
* The Auth plugin handles everything related to Supabase's authentication system | ||
*/ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.