Add getTrustDevice API to AuthSdkSource (#1147)

This commit is contained in:
David Perez
2024-03-14 17:26:23 -05:00
committed by Álison Fernandes
parent 058c4f0dfc
commit 2244e21e29
3 changed files with 40 additions and 0 deletions

View File

@@ -5,12 +5,18 @@ import com.bitwarden.core.MasterPasswordPolicyOptions
import com.bitwarden.core.RegisterKeyResponse
import com.bitwarden.crypto.HashPurpose
import com.bitwarden.crypto.Kdf
import com.bitwarden.crypto.TrustDeviceResponse
import com.x8bit.bitwarden.data.auth.datasource.sdk.model.PasswordStrength
/**
* Source of authentication information and functionality from the Bitwarden SDK.
*/
interface AuthSdkSource {
/**
* Gets the data to authenticate with trusted device encryption.
*/
suspend fun getTrustDevice(): Result<TrustDeviceResponse>
/**
* Gets the data needed to create a new auth request.
*/

View File

@@ -6,6 +6,7 @@ import com.bitwarden.core.MasterPasswordPolicyOptions
import com.bitwarden.core.RegisterKeyResponse
import com.bitwarden.crypto.HashPurpose
import com.bitwarden.crypto.Kdf
import com.bitwarden.crypto.TrustDeviceResponse
import com.bitwarden.sdk.ClientAuth
import com.bitwarden.sdk.ClientPlatform
import com.x8bit.bitwarden.data.auth.datasource.sdk.model.PasswordStrength
@@ -21,6 +22,10 @@ class AuthSdkSourceImpl(
private val clientPlatform: ClientPlatform,
) : AuthSdkSource {
override suspend fun getTrustDevice(): Result<TrustDeviceResponse> = runCatching {
clientAuth.trustDevice()
}
override suspend fun getNewAuthRequest(
email: String,
): Result<AuthRequestResponse> = runCatching {