Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 3fbccc51 authored by Guillaume Jacquart's avatar Guillaume Jacquart
Browse files

refac:3870: Remove GPlay Auth validator feature.

parent dd3c4632
Loading
Loading
Loading
Loading
+0 −26
Original line number Diff line number Diff line
/*
 * Copyright MURENA SAS 2023
 * Apps  Quickly and easily install Android apps onto your device!
 *
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see <https://www.gnu.org/licenses/>.
 */

package foundation.e.apps.data.login

import com.aurora.gplayapi.data.models.AuthData
import foundation.e.apps.data.ResultSupreme

interface AuthDataValidator {
    suspend fun validateAuthData(): ResultSupreme<AuthData?>
}
+0 −9
Original line number Diff line number Diff line
@@ -28,8 +28,6 @@ import javax.inject.Singleton
@JvmSuppressWildcards
@Singleton
class AuthenticatorRepository @Inject constructor(
    private val loginCommon: LoginCommon,
    private val authenticators: List<AuthDataValidator>,
    private val appLoungeDataStore: AppLoungeDataStore
) {

@@ -44,11 +42,4 @@ class AuthenticatorRepository @Inject constructor(
    suspend fun setGPlayAuth(auth: AuthData) {
        appLoungeDataStore.saveAuthData(auth)
    }

    suspend fun getValidatedAuthData(): ResultSupreme<AuthData?> {
        val authDataValidator = (authenticators.find { it is AuthDataValidator } as AuthDataValidator)
        val validateAuthData = authDataValidator.validateAuthData()
        appLoungeDataStore.saveAuthData(validateAuthData.data)
        return validateAuthData
    }
}
+1 −19
Original line number Diff line number Diff line
@@ -49,7 +49,7 @@ class PlayStoreAuthenticator @Inject constructor(
    @ApplicationContext private val context: Context,
    private val json: Json,
    private val appLoungeDataStore: AppLoungeDataStore,
): AuthDataValidator {
) {

    @Inject
    lateinit var loginManagerFactory: PlayStoreLoginManagerFactory
@@ -159,22 +159,4 @@ class PlayStoreAuthenticator @Inject constructor(
            else this
        }
    }

    override suspend fun validateAuthData(): ResultSupreme<AuthData?> {
        val savedAuth = getSavedAuthData()
        if (!isAuthDataValid(savedAuth)) {
            Timber.i("Validating AuthData...")
            val authData = generateAuthData()
            authData.data?.let {
                saveAuthData(it)
                return authData
            }
            return ResultSupreme.create(ResultStatus.UNKNOWN)
        }

        return ResultSupreme.create(ResultStatus.OK, savedAuth)
    }

    private suspend fun isAuthDataValid(savedAuth: AuthData?) =
        savedAuth != null && loginWrapper.validate(savedAuth).exception == null
}
+0 −20
Original line number Diff line number Diff line
@@ -19,10 +19,8 @@
package foundation.e.apps.data.login.api

import com.aurora.gplayapi.data.models.AuthData
import com.aurora.gplayapi.data.models.PlayResponse
import com.aurora.gplayapi.helpers.AuthHelper
import foundation.e.apps.data.login.Auth
import foundation.e.apps.data.playstore.utils.CustomAuthValidator
import foundation.e.apps.data.playstore.utils.GPlayHttpClient
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.withContext
@@ -73,22 +71,4 @@ class AnonymousLoginManager(
        }
        return authData
    }

//    /**
//     * Check if an AuthData is valid. Returns a [PlayResponse].
//     * Check [PlayResponse.isSuccessful] to see if the validation was successful.
//     */
//    override suspend fun validate(authData: AuthData): PlayResponse {
//        var result = PlayResponse()
//        withContext(Dispatchers.IO) {
//            try {
//                val authValidator = CustomAuthValidator(authData).using(gPlayHttpClient)
//                result = authValidator.getValidityResponse()
//            } catch (e: Exception) {
//                e.printStackTrace()
//                throw e
//            }
//        }
//        return result
//    }
}
+0 −18
Original line number Diff line number Diff line
@@ -68,22 +68,4 @@ class GoogleLoginManager(
        }
        return authData
    }

    /**
     * Check if an AuthData is valid. Returns a [PlayResponse].
     * Check [PlayResponse.isSuccessful] to see if the validation was successful.
     */
    override suspend fun validate(authData: AuthData): PlayResponse {
        var result = PlayResponse()
        withContext(Dispatchers.IO) {
            try {
                val authValidator = CustomAuthValidator(authData).using(gPlayHttpClient)
                result = authValidator.getValidityResponse()
            } catch (e: Exception) {
                e.printStackTrace()
                throw e
            }
        }
        return result
    }
}
Loading