diff --git a/descopesdk/src/main/java/com/descope/internal/routes/Auth.kt b/descopesdk/src/main/java/com/descope/internal/routes/Auth.kt index 963f6132..b4c1f9b5 100644 --- a/descopesdk/src/main/java/com/descope/internal/routes/Auth.kt +++ b/descopesdk/src/main/java/com/descope/internal/routes/Auth.kt @@ -7,49 +7,28 @@ import com.descope.types.DescopeTenant import com.descope.types.DescopeUser import com.descope.types.RevokeType import com.descope.types.RefreshResponse -import com.descope.types.Result internal class Auth(private val client: DescopeClient) : DescopeAuth { override suspend fun me(refreshJwt: String): DescopeUser = client.me(refreshJwt).convert() - override fun me(refreshJwt: String, callback: (Result) -> Unit) = wrapCoroutine(callback) { - me(refreshJwt) - } - override suspend fun tenants(dct: Boolean, tenantIds: List, refreshJwt: String): List = client.tenants(dct, tenantIds, refreshJwt).convert() - override fun tenants(dct: Boolean, tenantIds: List, refreshJwt: String, callback: (Result>) -> Unit) = wrapCoroutine(callback) { - tenants(dct, tenantIds, refreshJwt) - } - override suspend fun refreshSession(refreshJwt: String): RefreshResponse = client.refresh(refreshJwt).toRefreshResponse() - override fun refreshSession(refreshJwt: String, callback: (Result) -> Unit) = wrapCoroutine(callback) { - refreshSession(refreshJwt) - } - override suspend fun revokeSessions(revokeType: RevokeType, refreshJwt: String) { client.logout(refreshJwt, revokeType) } - override fun revokeSessions(revoke: RevokeType, refreshJwt: String, callback: (Result) -> Unit) = wrapCoroutine(callback) { - revokeSessions(revoke, refreshJwt) - } - // Deprecated @Deprecated(message = "Use revokeSessions instead", replaceWith = ReplaceWith("revokeSessions(RevokeType.CurrentSession, refreshJwt)")) override suspend fun logout(refreshJwt: String) = revokeSessions(RevokeType.CurrentSession, refreshJwt) - @Deprecated(message = "Use revokeSessions instead", replaceWith = ReplaceWith("revokeSessions(RevokeType.CurrentSession, refreshJwt, callback)")) - override fun logout(refreshJwt: String, callback: (Result) -> Unit) = - revokeSessions(RevokeType.CurrentSession, refreshJwt, callback) - } internal fun TenantsResponse.convert(): List { diff --git a/descopesdk/src/main/java/com/descope/internal/routes/EnchantedLink.kt b/descopesdk/src/main/java/com/descope/internal/routes/EnchantedLink.kt index a3be463d..1ba199f8 100644 --- a/descopesdk/src/main/java/com/descope/internal/routes/EnchantedLink.kt +++ b/descopesdk/src/main/java/com/descope/internal/routes/EnchantedLink.kt @@ -8,7 +8,6 @@ import com.descope.sdk.DescopeLogger.Level.Info import com.descope.types.AuthenticationResponse import com.descope.types.DescopeException import com.descope.types.EnchantedLinkResponse -import com.descope.types.Result import com.descope.types.SignInOptions import com.descope.types.SignUpDetails import com.descope.types.UpdateOptions @@ -21,38 +20,18 @@ internal class EnchantedLink(override val client: DescopeClient) : Route, Descop override suspend fun signUp(loginId: String, details: SignUpDetails?, uri: String?): EnchantedLinkResponse = client.enchantedLinkSignUp(loginId, details, uri).convert() - override fun signUp(loginId: String, details: SignUpDetails?, uri: String?, callback: (Result) -> Unit) = wrapCoroutine(callback) { - signUp(loginId, details, uri) - } - override suspend fun signIn(loginId: String, uri: String?, options: List?): EnchantedLinkResponse = client.enchantedLinkSignIn(loginId, uri, options).convert() - override fun signIn(loginId: String, uri: String?, options: List?, callback: (Result) -> Unit) = wrapCoroutine(callback) { - signIn(loginId, uri, options) - } - override suspend fun signUpOrIn(loginId: String, uri: String?, options: List?): EnchantedLinkResponse = client.enchantedLinkSignUpOrIn(loginId, uri, options).convert() - override fun signUpOrIn(loginId: String, uri: String?, options: List?, callback: (Result) -> Unit) = wrapCoroutine(callback) { - signUpOrIn(loginId, uri, options) - } - override suspend fun updateEmail(email: String, loginId: String, uri: String?, refreshJwt: String, options: UpdateOptions?): EnchantedLinkResponse = client.enchantedLinkUpdateEmail(email, loginId, uri, refreshJwt, options).convert() - override fun updateEmail(email: String, loginId: String, uri: String?, refreshJwt: String, options: UpdateOptions?, callback: (Result) -> Unit) = wrapCoroutine(callback) { - updateEmail(email, loginId, uri, refreshJwt, options) - } - override suspend fun checkForSession(pendingRef: String): AuthenticationResponse = client.enchantedLinkCheckForSession(pendingRef).convert() - override fun checkForSession(pendingRef: String, callback: (Result) -> Unit) = wrapCoroutine(callback) { - checkForSession(pendingRef) - } - override suspend fun pollForSession(pendingRef: String, timeoutMilliseconds: Long?): AuthenticationResponse { val pollingEndsAt = System.currentTimeMillis() + (timeoutMilliseconds ?: DEFAULT_POLL_DURATION) log(Info, "Polling for enchanted link", timeoutMilliseconds ?: DEFAULT_POLL_DURATION) @@ -78,10 +57,6 @@ internal class EnchantedLink(override val client: DescopeClient) : Route, Descop } } } - - override fun pollForSession(pendingRef: String, timeoutMilliseconds: Long?, callback: (Result) -> Unit) = wrapCoroutine(callback) { - pollForSession(pendingRef, timeoutMilliseconds) - } } private fun EnchantedLinkServerResponse.convert() = EnchantedLinkResponse( diff --git a/descopesdk/src/main/java/com/descope/internal/routes/Flow.kt b/descopesdk/src/main/java/com/descope/internal/routes/Flow.kt index 26279271..897d8150 100644 --- a/descopesdk/src/main/java/com/descope/internal/routes/Flow.kt +++ b/descopesdk/src/main/java/com/descope/internal/routes/Flow.kt @@ -10,7 +10,6 @@ import com.descope.sdk.DescopeFlow import com.descope.sdk.DescopeLogger.Level.Info import com.descope.types.AuthenticationResponse import com.descope.types.DescopeException -import com.descope.types.Result import java.security.MessageDigest import kotlin.random.Random @@ -45,10 +44,6 @@ internal class Flow( startFlowViaBrowser(codeChallenge, context) } - override fun start(context: Context, callback: (Result) -> Unit) = wrapCoroutine(callback) { - start(context) - } - override fun resume(context: Context, incomingUriString: String) { // create the redirect flow URL by copying all url parameters received from the incoming URI val incomingUri = Uri.parse(incomingUriString) @@ -71,10 +66,6 @@ internal class Flow( return client.flowExchange(authorizationCode, codeVerifier).convert() } - override fun exchange(incomingUri: Uri, callback: (Result) -> Unit) = wrapCoroutine(callback) { - exchange(incomingUri) - } - // Internal private fun initVerifierAndChallenge(): String { diff --git a/descopesdk/src/main/java/com/descope/internal/routes/MagicLink.kt b/descopesdk/src/main/java/com/descope/internal/routes/MagicLink.kt index 156d34de..6a5a97cd 100644 --- a/descopesdk/src/main/java/com/descope/internal/routes/MagicLink.kt +++ b/descopesdk/src/main/java/com/descope/internal/routes/MagicLink.kt @@ -4,7 +4,6 @@ import com.descope.internal.http.DescopeClient import com.descope.sdk.DescopeMagicLink import com.descope.types.AuthenticationResponse import com.descope.types.DeliveryMethod -import com.descope.types.Result import com.descope.types.SignInOptions import com.descope.types.SignUpDetails import com.descope.types.UpdateOptions @@ -14,42 +13,18 @@ internal class MagicLink(private val client: DescopeClient): DescopeMagicLink { override suspend fun signUp(method: DeliveryMethod, loginId: String, details: SignUpDetails?, uri: String?): String = client.magicLinkSignUp(method, loginId, details, uri).convert(method) - override fun signUp(method: DeliveryMethod, loginId: String, details: SignUpDetails?, uri: String?, callback: (Result) -> Unit) = wrapCoroutine(callback) { - signUp(method, loginId, details, uri) - } - override suspend fun signIn(method: DeliveryMethod, loginId: String, uri: String?, options: List?): String = client.magicLinkSignIn(method, loginId, uri, options).convert(method) - override fun signIn(method: DeliveryMethod, loginId: String, uri: String?, options: List?, callback: (Result) -> Unit) = wrapCoroutine(callback) { - signIn(method, loginId, uri, options) - } - override suspend fun signUpOrIn(method: DeliveryMethod, loginId: String, uri: String?, options: List?): String = client.magicLinkSignUpOrIn(method, loginId, uri, options).convert(method) - override fun signUpOrIn(method: DeliveryMethod, loginId: String, uri: String?, options: List?, callback: (Result) -> Unit) = wrapCoroutine(callback) { - signUpOrIn(method, loginId, uri, options) - } - override suspend fun updateEmail(email: String, loginId: String, uri: String?, refreshJwt: String, options: UpdateOptions?): String = client.magicLinkUpdateEmail(email, loginId, uri, refreshJwt, options).convert(DeliveryMethod.Email) - override fun updateEmail(email: String, loginId: String, uri: String?, refreshJwt: String, options: UpdateOptions?, callback: (Result) -> Unit) = wrapCoroutine(callback) { - updateEmail(email, loginId, uri, refreshJwt, options) - } - override suspend fun updatePhone(phone: String, method: DeliveryMethod, loginId: String, uri: String?, refreshJwt: String, options: UpdateOptions?): String = client.magicLinkUpdatePhone(phone, method, loginId, uri, refreshJwt, options).convert(method) - override fun updatePhone(phone: String, method: DeliveryMethod, loginId: String, uri: String?, refreshJwt: String, options: UpdateOptions?, callback: (Result) -> Unit) = wrapCoroutine(callback) { - updatePhone(phone, method, loginId, uri, refreshJwt, options) - } - override suspend fun verify(token: String): AuthenticationResponse = client.magicLinkVerify(token).convert() - override fun verify(token: String, callback: (Result) -> Unit) = wrapCoroutine(callback) { - verify(token) - } - } diff --git a/descopesdk/src/main/java/com/descope/internal/routes/OAuth.kt b/descopesdk/src/main/java/com/descope/internal/routes/OAuth.kt index db03431b..9c191ed6 100644 --- a/descopesdk/src/main/java/com/descope/internal/routes/OAuth.kt +++ b/descopesdk/src/main/java/com/descope/internal/routes/OAuth.kt @@ -16,7 +16,6 @@ import com.descope.sdk.DescopeOAuth import com.descope.types.AuthenticationResponse import com.descope.types.DescopeException import com.descope.types.OAuthProvider -import com.descope.types.Result import com.descope.types.SignInOptions import com.google.android.libraries.identity.googleid.GetGoogleIdOption import com.google.android.libraries.identity.googleid.GoogleIdTokenCredential @@ -28,50 +27,26 @@ internal class OAuth(override val client: DescopeClient) : Route, DescopeOAuth { override suspend fun signUp(provider: OAuthProvider, redirectUrl: String?, options: List?): String = client.oauthWebStart(provider, redirectUrl, options, OAuthMethod.SignUp).url - override fun signUp(provider: OAuthProvider, redirectUrl: String?, options: List?, callback: (Result) -> Unit) = wrapCoroutine(callback) { - signUp(provider, redirectUrl, options) - } - override suspend fun signIn(provider: OAuthProvider, redirectUrl: String?, options: List?): String = client.oauthWebStart(provider, redirectUrl, options, OAuthMethod.SignIn).url - override fun signIn(provider: OAuthProvider, redirectUrl: String?, options: List?, callback: (Result) -> Unit) = wrapCoroutine(callback) { - signIn(provider, redirectUrl, options) - } - override suspend fun signUpOrIn(provider: OAuthProvider, redirectUrl: String?, options: List?): String = client.oauthWebStart(provider, redirectUrl, options, OAuthMethod.SignUpOrIn).url - override fun signUpOrIn(provider: OAuthProvider, redirectUrl: String?, options: List?, callback: (Result) -> Unit) = wrapCoroutine(callback) { - signUpOrIn(provider, redirectUrl, options) - } - override suspend fun exchange(code: String): AuthenticationResponse = client.oauthWebExchange(code).convert() - override fun exchange(code: String, callback: (Result) -> Unit) = wrapCoroutine(callback) { - exchange(code) - } - override suspend fun native(context: Context, provider: OAuthProvider, options: List?): AuthenticationResponse { val startResponse = client.oauthNativeStart(provider, options) val authorizationResponse = nativeAuthorization(context, startResponse) return client.oauthNativeFinish(provider, authorizationResponse.stateId, authorizationResponse.identityToken).convert() } - override fun native(context: Context, provider: OAuthProvider, options: List?, callback: (Result) -> Unit) = wrapCoroutine(callback) { - native(context, provider, options) - } - // Deprecated @Deprecated(message = "Use signUpOrIn instead", replaceWith = ReplaceWith("signUpOrIn(provider, redirectUrl, options)")) override suspend fun start(provider: OAuthProvider, redirectUrl: String?, options: List?): String = signUpOrIn(provider, redirectUrl, options) - - @Deprecated(message = "Use signUpOrIn instead", replaceWith = ReplaceWith("signUpOrIn(provider, redirectUrl, options, callback)")) - override fun start(provider: OAuthProvider, redirectUrl: String?, options: List?, callback: (Result) -> Unit) = - signUpOrIn(provider, redirectUrl, options, callback) } internal suspend fun nativeAuthorization(context: Context, responseJson: JSONObject): NativeAuthorizationResponse { diff --git a/descopesdk/src/main/java/com/descope/internal/routes/Otp.kt b/descopesdk/src/main/java/com/descope/internal/routes/Otp.kt index f5d96b93..d4971e19 100644 --- a/descopesdk/src/main/java/com/descope/internal/routes/Otp.kt +++ b/descopesdk/src/main/java/com/descope/internal/routes/Otp.kt @@ -4,7 +4,6 @@ import com.descope.internal.http.DescopeClient import com.descope.sdk.DescopeOtp import com.descope.types.AuthenticationResponse import com.descope.types.DeliveryMethod -import com.descope.types.Result import com.descope.types.SignInOptions import com.descope.types.SignUpDetails import com.descope.types.UpdateOptions @@ -14,43 +13,19 @@ internal class Otp(private val client: DescopeClient) : DescopeOtp { override suspend fun signUp(method: DeliveryMethod, loginId: String, details: SignUpDetails?): String = client.otpSignUp(method, loginId, details).convert(method) - override fun signUp(method: DeliveryMethod, loginId: String, details: SignUpDetails?, callback: (Result) -> Unit) = wrapCoroutine(callback) { - signUp(method, loginId, details) - } - override suspend fun signIn(method: DeliveryMethod, loginId: String, options: List?): String = client.otpSignIn(method, loginId, options).convert(method) - override fun signIn(method: DeliveryMethod, loginId: String, options: List?, callback: (Result) -> Unit) = wrapCoroutine(callback) { - signIn(method, loginId, options) - } - override suspend fun signUpOrIn(method: DeliveryMethod, loginId: String, options: List?): String = client.otpSignUpIn(method, loginId, options).convert(method) - override fun signUpOrIn(method: DeliveryMethod, loginId: String, options: List?, callback: (Result) -> Unit) = wrapCoroutine(callback) { - signUpOrIn(method, loginId, options) - } - override suspend fun verify(method: DeliveryMethod, loginId: String, code: String): AuthenticationResponse = client.otpVerify(method, loginId, code).convert() - override fun verify(method: DeliveryMethod, loginId: String, code: String, callback: (Result) -> Unit) = wrapCoroutine(callback) { - verify(method, loginId, code) - } - override suspend fun updateEmail(email: String, loginId: String, refreshJwt: String, options: UpdateOptions?): String = client.otpUpdateEmail(email, loginId, refreshJwt, options).convert(DeliveryMethod.Email) - override fun updateEmail(email: String, loginId: String, refreshJwt: String, options: UpdateOptions?, callback: (Result) -> Unit) = wrapCoroutine(callback) { - updateEmail(email, loginId, refreshJwt, options) - } - override suspend fun updatePhone(phone: String, method: DeliveryMethod, loginId: String, refreshJwt: String, options: UpdateOptions?): String = client.otpUpdatePhone(phone, method, loginId, refreshJwt, options).convert(method) - override fun updatePhone(phone: String, method: DeliveryMethod, loginId: String, refreshJwt: String, options: UpdateOptions?, callback: (Result) -> Unit) = wrapCoroutine(callback) { - updatePhone(phone, method, loginId, refreshJwt, options) - } } - diff --git a/descopesdk/src/main/java/com/descope/internal/routes/Password.kt b/descopesdk/src/main/java/com/descope/internal/routes/Password.kt index 2444ccca..a2e1773f 100644 --- a/descopesdk/src/main/java/com/descope/internal/routes/Password.kt +++ b/descopesdk/src/main/java/com/descope/internal/routes/Password.kt @@ -5,7 +5,6 @@ import com.descope.internal.http.PasswordPolicyServerResponse import com.descope.sdk.DescopePassword import com.descope.types.AuthenticationResponse import com.descope.types.PasswordPolicy -import com.descope.types.Result import com.descope.types.SignUpDetails internal class Password(private val client: DescopeClient) : DescopePassword { @@ -13,44 +12,20 @@ internal class Password(private val client: DescopeClient) : DescopePassword { override suspend fun signUp(loginId: String, password: String, details: SignUpDetails?): AuthenticationResponse = client.passwordSignUp(loginId, password, details).convert() - override fun signUp(loginId: String, password: String, details: SignUpDetails?, callback: (Result) -> Unit) = wrapCoroutine(callback) { - signUp(loginId, password, details) - } - override suspend fun signIn(loginId: String, password: String): AuthenticationResponse = client.passwordSignIn(loginId, password).convert() - override fun signIn(loginId: String, password: String, callback: (Result) -> Unit) = wrapCoroutine(callback) { - signIn(loginId, password) - } - override suspend fun update(loginId: String, newPassword: String, refreshJwt: String) = client.passwordUpdate(loginId, newPassword, refreshJwt) - override fun update(loginId: String, newPassword: String, refreshJwt: String, callback: (Result) -> Unit) = wrapCoroutine(callback) { - update(loginId, newPassword, refreshJwt) - } - override suspend fun replace(loginId: String, oldPassword: String, newPassword: String): AuthenticationResponse = client.passwordReplace(loginId, oldPassword, newPassword).convert() - override fun replace(loginId: String, oldPassword: String, newPassword: String, callback: (Result) -> Unit) = wrapCoroutine(callback) { - replace(loginId, oldPassword, newPassword) - } - override suspend fun sendReset(loginId: String, redirectUrl: String?) = client.passwordSendReset(loginId, redirectUrl) - override fun sendReset(loginId: String, redirectUrl: String?, callback: (Result) -> Unit) = wrapCoroutine(callback) { - sendReset(loginId, redirectUrl) - } - override suspend fun getPolicy(): PasswordPolicy = client.passwordGetPolicy().convert() - - override fun getPolicy(callback: (Result) -> Unit) = wrapCoroutine(callback) { - getPolicy() - } } private fun PasswordPolicyServerResponse.convert() = PasswordPolicy( diff --git a/descopesdk/src/main/java/com/descope/internal/routes/Shared.kt b/descopesdk/src/main/java/com/descope/internal/routes/Shared.kt index 536b3136..a2fcb52b 100644 --- a/descopesdk/src/main/java/com/descope/internal/routes/Shared.kt +++ b/descopesdk/src/main/java/com/descope/internal/routes/Shared.kt @@ -13,10 +13,6 @@ import com.descope.types.DeliveryMethod import com.descope.types.DescopeException import com.descope.types.DescopeUser import com.descope.types.RefreshResponse -import com.descope.types.Result -import kotlinx.coroutines.Dispatchers -import kotlinx.coroutines.GlobalScope -import kotlinx.coroutines.launch internal interface Route { val client: DescopeClient @@ -66,16 +62,3 @@ internal fun MaskedAddressServerResponse.convert(method: DeliveryMethod) = when DeliveryMethod.Email -> maskedEmail ?: throw DescopeException.decodeError.with(message = "masked email not received") DeliveryMethod.Sms, DeliveryMethod.Whatsapp -> maskedPhone ?: throw DescopeException.decodeError.with(message = "masked phone not received") } - -@Suppress("OPT_IN_USAGE") -internal fun wrapCoroutine(callback: (Result) -> Unit, coroutine: suspend () -> T) { - GlobalScope.launch(Dispatchers.Main) { - val result = try { - val result = coroutine() - Result.Success(result) - } catch (e: Exception) { - Result.Failure(e) - } - callback(result) - } -} diff --git a/descopesdk/src/main/java/com/descope/internal/routes/Sso.kt b/descopesdk/src/main/java/com/descope/internal/routes/Sso.kt index 4db39939..ee40b1a6 100644 --- a/descopesdk/src/main/java/com/descope/internal/routes/Sso.kt +++ b/descopesdk/src/main/java/com/descope/internal/routes/Sso.kt @@ -3,7 +3,6 @@ package com.descope.internal.routes import com.descope.internal.http.DescopeClient import com.descope.sdk.DescopeSso import com.descope.types.AuthenticationResponse -import com.descope.types.Result import com.descope.types.SignInOptions internal class Sso(private val client: DescopeClient): DescopeSso { @@ -11,15 +10,7 @@ internal class Sso(private val client: DescopeClient): DescopeSso { override suspend fun start(emailOrTenantId: String, redirectUrl: String?, options: List?): String = client.ssoStart(emailOrTenantId, redirectUrl, options).url - override fun start(emailOrTenantId: String, redirectUrl: String?, options: List?, callback: (Result) -> Unit) = wrapCoroutine(callback) { - start(emailOrTenantId, redirectUrl, options) - } - override suspend fun exchange(code: String): AuthenticationResponse = client.ssoExchange(code).convert() - override fun exchange(code: String, callback: (Result) -> Unit) = wrapCoroutine(callback) { - exchange(code) - } - } diff --git a/descopesdk/src/main/java/com/descope/internal/routes/Totp.kt b/descopesdk/src/main/java/com/descope/internal/routes/Totp.kt index b16d3c47..3c1b9cfe 100644 --- a/descopesdk/src/main/java/com/descope/internal/routes/Totp.kt +++ b/descopesdk/src/main/java/com/descope/internal/routes/Totp.kt @@ -4,7 +4,6 @@ import com.descope.internal.http.DescopeClient import com.descope.internal.http.TotpServerResponse import com.descope.sdk.DescopeTotp import com.descope.types.AuthenticationResponse -import com.descope.types.Result import com.descope.types.SignInOptions import com.descope.types.SignUpDetails import com.descope.types.TotpResponse @@ -14,24 +13,12 @@ internal class Totp(private val client: DescopeClient) : DescopeTotp { override suspend fun signUp(loginId: String, details: SignUpDetails?): TotpResponse = client.totpSignUp(loginId, details).convert() - override fun signUp(loginId: String, details: SignUpDetails?, callback: (Result) -> Unit) = wrapCoroutine(callback) { - signUp(loginId, details) - } - override suspend fun update(loginId: String, refreshJwt: String): TotpResponse = client.totpUpdate(loginId, refreshJwt).convert() - override suspend fun update(loginId: String, refreshJwt: String, callback: (Result) -> Unit) = wrapCoroutine(callback) { - update(loginId, refreshJwt) - } - override suspend fun verify(loginId: String, code: String, options: List?): AuthenticationResponse = client.totpVerify(loginId, code, options).convert() - override fun verify(loginId: String, code: String, options: List?, callback: (Result) -> Unit) = wrapCoroutine(callback) { - verify(loginId, code, options) - } - } private fun TotpServerResponse.convert() = TotpResponse( diff --git a/descopesdk/src/main/java/com/descope/sdk/Routes.kt b/descopesdk/src/main/java/com/descope/sdk/Routes.kt index ebeca268..60b682e9 100644 --- a/descopesdk/src/main/java/com/descope/sdk/Routes.kt +++ b/descopesdk/src/main/java/com/descope/sdk/Routes.kt @@ -15,7 +15,6 @@ import com.descope.types.RevokeType import com.descope.types.OAuthProvider import com.descope.types.PasswordPolicy import com.descope.types.RefreshResponse -import com.descope.types.Result import com.descope.types.SignInOptions import com.descope.types.SignUpDetails import com.descope.types.TotpResponse @@ -37,9 +36,6 @@ interface DescopeAuth { */ suspend fun me(refreshJwt: String): DescopeUser - /** @see me */ - fun me(refreshJwt: String, callback: (Result) -> Unit) - /** * Returns the current session user tenants. * @@ -53,9 +49,6 @@ interface DescopeAuth { */ suspend fun tenants(dct: Boolean, tenantIds: List, refreshJwt: String): List - /** @see tenants */ - fun tenants(dct: Boolean, tenantIds: List, refreshJwt: String, callback: (Result>) -> Unit) - /** * Refreshes a [DescopeSession]. * @@ -68,9 +61,6 @@ interface DescopeAuth { */ suspend fun refreshSession(refreshJwt: String): RefreshResponse - /** @see refreshSession */ - fun refreshSession(refreshJwt: String, callback: (Result) -> Unit) - /** * It's a good security practice to remove refresh JWTs from the Descope servers if * they become redundant before expiry. This function will usually be called with `.currentSession` @@ -102,14 +92,8 @@ interface DescopeAuth { */ suspend fun revokeSessions(revokeType: RevokeType, refreshJwt: String) - /** @see revokeSessions*/ - fun revokeSessions(revoke: RevokeType, refreshJwt: String, callback: (Result) -> Unit) - @Deprecated(message = "Use revokeSessions instead", replaceWith = ReplaceWith("revokeSessions(RevokeType.CurrentSession, refreshJwt)")) suspend fun logout(refreshJwt: String) - - @Deprecated(message = "Use revokeSessions instead", replaceWith = ReplaceWith("revokeSessions(RevokeType.CurrentSession, refreshJwt, callback)")) - fun logout(refreshJwt: String, callback: (Result) -> Unit) } /** @@ -133,9 +117,6 @@ interface DescopeOtp { */ suspend fun signUp(method: DeliveryMethod, loginId: String, details: SignUpDetails? = null): String - /** @see signUp */ - fun signUp(method: DeliveryMethod, loginId: String, details: SignUpDetails? = null, callback: (Result) -> Unit) - /** * Authenticates an existing user using an OTP * @@ -150,9 +131,6 @@ interface DescopeOtp { */ suspend fun signIn(method: DeliveryMethod, loginId: String, options: List? = null): String - /** @see signIn */ - fun signIn(method: DeliveryMethod, loginId: String, options: List? = null, callback: (Result) -> Unit) - /** * Authenticates an existing user if one exists, or creates a new user * using an OTP @@ -168,9 +146,6 @@ interface DescopeOtp { */ suspend fun signUpOrIn(method: DeliveryMethod, loginId: String, options: List? = null): String - /** @see signUpOrIn*/ - fun signUpOrIn(method: DeliveryMethod, loginId: String, options: List? = null, callback: (Result) -> Unit) - /** * Verifies an OTP [code] sent to the user. * @@ -181,9 +156,6 @@ interface DescopeOtp { */ suspend fun verify(method: DeliveryMethod, loginId: String, code: String): AuthenticationResponse - /** @see verify */ - fun verify(method: DeliveryMethod, loginId: String, code: String, callback: (Result) -> Unit) - /** * Updates an existing user by adding an email address. * @@ -202,9 +174,6 @@ interface DescopeOtp { */ suspend fun updateEmail(email: String, loginId: String, refreshJwt: String, options: UpdateOptions? = null): String - /** @see updateEmail */ - fun updateEmail(email: String, loginId: String, refreshJwt: String, options: UpdateOptions? = null, callback: (Result) -> Unit) - /** * Updates an existing user by adding a phone number. * @@ -225,9 +194,6 @@ interface DescopeOtp { * @return masked phone number the OTP was sent to. */ suspend fun updatePhone(phone: String, method: DeliveryMethod, loginId: String, refreshJwt: String, options: UpdateOptions? = null): String - - /** @see updatePhone */ - fun updatePhone(phone: String, method: DeliveryMethod, loginId: String, refreshJwt: String, options: UpdateOptions? = null, callback: (Result) -> Unit) } /** @@ -237,7 +203,6 @@ interface DescopeOtp { * can produce TOTP codes. */ interface DescopeTotp { - /** * Authenticates a new user using a TOTP. * @@ -253,9 +218,6 @@ interface DescopeTotp { */ suspend fun signUp(loginId: String, details: SignUpDetails? = null): TotpResponse - /** @see signUp */ - fun signUp(loginId: String, details: SignUpDetails? = null, callback: (Result) -> Unit) - /** * Updates an existing user by adding TOTP as an authentication method. * @@ -271,9 +233,6 @@ interface DescopeTotp { */ suspend fun update(loginId: String, refreshJwt: String): TotpResponse - /** @see update */ - suspend fun update(loginId: String, refreshJwt: String, callback: (Result) -> Unit) - /** * Verifies a TOTP code that was generated by an authenticator app. * @@ -286,9 +245,6 @@ interface DescopeTotp { * @return an [AuthenticationResponse] upon successful verification. */ suspend fun verify(loginId: String, code: String, options: List? = null): AuthenticationResponse - - /** @see verify */ - fun verify(loginId: String, code: String, options: List? = null, callback: (Result) -> Unit) } /** @@ -300,7 +256,6 @@ interface DescopeTotp { * on the appended token URL parameter. */ interface DescopeMagicLink { - /** * Authenticates a new user using a magic link. * @@ -315,9 +270,6 @@ interface DescopeMagicLink { */ suspend fun signUp(method: DeliveryMethod, loginId: String, details: SignUpDetails? = null, uri: String? = null): String - /** @see signUp */ - fun signUp(method: DeliveryMethod, loginId: String, details: SignUpDetails? = null, uri: String? = null, callback: (Result) -> Unit) - /** * Authenticates an existing user using a magic link. * @@ -332,10 +284,6 @@ interface DescopeMagicLink { */ suspend fun signIn(method: DeliveryMethod, loginId: String, uri: String? = null, options: List? = null): String - - /** @see signIn */ - fun signIn(method: DeliveryMethod, loginId: String, uri: String? = null, options: List? = null, callback: (Result) -> Unit) - /** * Authenticates an existing user if one exists, or creates a new user * using a magic link. @@ -351,9 +299,6 @@ interface DescopeMagicLink { */ suspend fun signUpOrIn(method: DeliveryMethod, loginId: String, uri: String? = null, options: List? = null): String - /** @see signUpOrIn */ - fun signUpOrIn(method: DeliveryMethod, loginId: String, uri: String? = null, options: List? = null, callback: (Result) -> Unit) - /** * Updates an existing user by adding an [email] address. * @@ -373,9 +318,6 @@ interface DescopeMagicLink { */ suspend fun updateEmail(email: String, loginId: String, uri: String? = null, refreshJwt: String, options: UpdateOptions? = null): String - /** @see updateEmail */ - fun updateEmail(email: String, loginId: String, uri: String? = null, refreshJwt: String, options: UpdateOptions? = null, callback: (Result) -> Unit) - /** * Updates an existing user by adding a [phone] number. * @@ -396,9 +338,6 @@ interface DescopeMagicLink { */ suspend fun updatePhone(phone: String, method: DeliveryMethod, loginId: String, uri: String? = null, refreshJwt: String, options: UpdateOptions? = null): String - /** @see updatePhone */ - fun updatePhone(phone: String, method: DeliveryMethod, loginId: String, uri: String? = null, refreshJwt: String, options: UpdateOptions? = null, callback: (Result) -> Unit) - /** * Verifies a magic link [token]. * @@ -410,9 +349,6 @@ interface DescopeMagicLink { * @return an [AuthenticationResponse] upon successful verification */ suspend fun verify(token: String): AuthenticationResponse - - /** @see verify */ - fun verify(token: String, callback: (Result) -> Unit) } /** @@ -427,7 +363,6 @@ interface DescopeMagicLink { * official Descope docs. */ interface DescopeEnchantedLink { - /** * Authenticates a new user using an enchanted link, sent via email. * @@ -445,9 +380,6 @@ interface DescopeEnchantedLink { */ suspend fun signUp(loginId: String, details: SignUpDetails? = null, uri: String? = null): EnchantedLinkResponse - /** @see signUp */ - fun signUp(loginId: String, details: SignUpDetails? = null, uri: String? = null, callback: (Result) -> Unit) - /** * Authenticates an existing user using an enchanted link, sent via email. * @@ -463,9 +395,6 @@ interface DescopeEnchantedLink { */ suspend fun signIn(loginId: String, uri: String? = null, options: List? = null): EnchantedLinkResponse - /** @see signIn */ - fun signIn(loginId: String, uri: String? = null, options: List? = null, callback: (Result) -> Unit) - /** * Authenticates an existing user if one exists, or create a new user using an * enchanted link, sent via email. @@ -481,9 +410,6 @@ interface DescopeEnchantedLink { */ suspend fun signUpOrIn(loginId: String, uri: String? = null, options: List? = null): EnchantedLinkResponse - /** @see signUpOrIn */ - fun signUpOrIn(loginId: String, uri: String? = null, options: List? = null, callback: (Result) -> Unit) - /** * Updates an existing user by adding an [email] address. * @@ -506,9 +432,6 @@ interface DescopeEnchantedLink { */ suspend fun updateEmail(email: String, loginId: String, uri: String? = null, refreshJwt: String, options: UpdateOptions? = null): EnchantedLinkResponse - /** @see updateEmail */ - fun updateEmail(email: String, loginId: String, uri: String? = null, refreshJwt: String, options: UpdateOptions? = null, callback: (Result) -> Unit) - /** * Checks if an enchanted link authentication has been verified by the user. * @@ -526,9 +449,6 @@ interface DescopeEnchantedLink { */ suspend fun checkForSession(pendingRef: String): AuthenticationResponse - /** @see checkForSession */ - fun checkForSession(pendingRef: String, callback: (Result) -> Unit) - /** * Waits until an enchanted link authentication has been verified by the user. * @@ -551,9 +471,6 @@ interface DescopeEnchantedLink { * @return an [AuthenticationResponse] upon successful verification. */ suspend fun pollForSession(pendingRef: String, timeoutMilliseconds: Long? = null): AuthenticationResponse - - /** @see pollForSession */ - fun pollForSession(pendingRef: String, timeoutMilliseconds: Long? = null, callback: (Result) -> Unit) } /** @@ -568,7 +485,6 @@ interface DescopeEnchantedLink { * See examples for more information on how to handle deep links. */ interface DescopeOAuth { - /** * Authenticates a new user using an OAuth redirect chain. * @@ -592,9 +508,6 @@ interface DescopeOAuth { */ suspend fun signUp(provider: OAuthProvider, redirectUrl: String? = null, options: List? = null): String - /** @see signUp */ - fun signUp(provider: OAuthProvider, redirectUrl: String? = null, options: List? = null, callback: (Result) -> Unit) - /** * Authenticates an existing user using an OAuth redirect chain. * @@ -618,9 +531,6 @@ interface DescopeOAuth { */ suspend fun signIn(provider: OAuthProvider, redirectUrl: String? = null, options: List? = null): String - /** @see signIn */ - fun signIn(provider: OAuthProvider, redirectUrl: String? = null, options: List? = null, callback: (Result) -> Unit) - /** * Authenticate an existing user if one exists, or create a new user using an * OAuth redirect chain. @@ -645,9 +555,6 @@ interface DescopeOAuth { */ suspend fun signUpOrIn(provider: OAuthProvider, redirectUrl: String? = null, options: List? = null): String - /** @see signUpOrIn */ - fun signUpOrIn(provider: OAuthProvider, redirectUrl: String? = null, options: List? = null, callback: (Result) -> Unit) - /** * Starts an OAuth redirect chain to authenticate a user. * @@ -672,10 +579,6 @@ interface DescopeOAuth { @Deprecated(message = "Use signUpOrIn instead", replaceWith = ReplaceWith("signUpOrIn(provider, redirectUrl, options)")) suspend fun start(provider: OAuthProvider, redirectUrl: String? = null, options: List? = null): String - /** @see start */ - @Deprecated(message = "Use signUpOrIn instead", replaceWith = ReplaceWith("signUpOrIn(provider, redirectUrl, options, callback)")) - fun start(provider: OAuthProvider, redirectUrl: String? = null, options: List? = null, callback: (Result) -> Unit) - /** * Completes an OAuth redirect chain. * @@ -692,9 +595,6 @@ interface DescopeOAuth { */ suspend fun exchange(code: String): AuthenticationResponse - /** @see exchange */ - fun exchange(code: String, callback: (Result) -> Unit) - /** * Authenticates the user using the native Sign in with Google dialog. * @@ -725,9 +625,6 @@ interface DescopeOAuth { * @return an [AuthenticationResponse] upon successful authentication. */ suspend fun native(context: Context, provider: OAuthProvider, options: List? = null): AuthenticationResponse - - /** @see native */ - fun native(context: Context, provider: OAuthProvider, options: List? = null, callback: (Result) -> Unit) } /** @@ -742,7 +639,6 @@ interface DescopeOAuth { * See examples for more information on how to handle deep links. */ interface DescopeSso { - /** * Starts an SSO redirect chain to authenticate a user. * @@ -760,9 +656,6 @@ interface DescopeSso { */ suspend fun start(emailOrTenantId: String, redirectUrl: String?, options: List? = null): String - /** @see start */ - fun start(emailOrTenantId: String, redirectUrl: String?, options: List? = null, callback: (Result) -> Unit) - /** * Completes an SSO redirect chain. * @@ -773,10 +666,6 @@ interface DescopeSso { * @return an [AuthenticationResponse] upon successful verification. */ suspend fun exchange(code: String): AuthenticationResponse - - /** @see exchange */ - fun exchange(code: String, callback: (Result) -> Unit) - } /** @@ -862,9 +751,6 @@ interface DescopePassword { */ suspend fun signUp(loginId: String, password: String, details: SignUpDetails? = null): AuthenticationResponse - /** @see signUp */ - fun signUp(loginId: String, password: String, details: SignUpDetails? = null, callback: (Result) -> Unit) - /** * Authenticates an existing user using a password. * @@ -874,9 +760,6 @@ interface DescopePassword { */ suspend fun signIn(loginId: String, password: String): AuthenticationResponse - /** @see signIn */ - fun signIn(loginId: String, password: String, callback: (Result) -> Unit) - /** * Updates a user's password. * @@ -893,8 +776,6 @@ interface DescopePassword { */ suspend fun update(loginId: String, newPassword: String, refreshJwt: String) - fun update(loginId: String, newPassword: String, refreshJwt: String, callback: (Result) -> Unit) - /** * Replaces a user's password by providing their current password. * @@ -909,9 +790,6 @@ interface DescopePassword { */ suspend fun replace(loginId: String, oldPassword: String, newPassword: String): AuthenticationResponse - /** @see replace */ - fun replace(loginId: String, oldPassword: String, newPassword: String, callback: (Result) -> Unit) - /** * Sends a password reset email to the user. * @@ -929,9 +807,6 @@ interface DescopePassword { */ suspend fun sendReset(loginId: String, redirectUrl: String? = null) - /** @see sendReset */ - fun sendReset(loginId: String, redirectUrl: String? = null, callback: (Result) -> Unit) - /** * Fetches the rules for valid passwords. * @@ -944,9 +819,6 @@ interface DescopePassword { * @return the [PasswordPolicy] for this project. */ suspend fun getPolicy(): PasswordPolicy - - /** @see getPolicy */ - fun getPolicy(callback: (Result) -> Unit) } /** @@ -1011,9 +883,6 @@ interface DescopeFlow { */ suspend fun start(context: Context) - /** @see start */ - fun start(context: Context, callback: (Result) -> Unit) - /** * Resumes an ongoing flow after a redirect back to the app. * This is required for *Magic Link only* at this stage. @@ -1037,9 +906,6 @@ interface DescopeFlow { * @return an [AuthenticationResponse] upon successful verification. */ suspend fun exchange(incomingUri: Uri): AuthenticationResponse - - /** @see exchange */ - fun exchange(incomingUri: Uri, callback: (Result) -> Unit) } /** diff --git a/descopesdk/src/main/java/com/descope/types/Result.kt b/descopesdk/src/main/java/com/descope/types/Result.kt deleted file mode 100644 index 0ad8108f..00000000 --- a/descopesdk/src/main/java/com/descope/types/Result.kt +++ /dev/null @@ -1,6 +0,0 @@ -package com.descope.types - -sealed class Result { - data class Success(val result: T) : Result() - data class Failure(val error: Exception) : Result() -}