mirror of
https://github.com/bitwarden/android.git
synced 2026-06-07 23:58:03 -05:00
Add VaultSdkSource.getUserEncryptionKey (#545)
This commit is contained in:
committed by
Álison Fernandes
parent
2d4427a7cf
commit
6686d98e34
@@ -8,6 +8,7 @@ import com.bitwarden.core.CollectionView
|
||||
import com.bitwarden.core.Folder
|
||||
import com.bitwarden.core.FolderView
|
||||
import com.bitwarden.core.InitOrgCryptoRequest
|
||||
import com.bitwarden.core.InitUserCryptoMethod
|
||||
import com.bitwarden.core.InitUserCryptoRequest
|
||||
import com.bitwarden.core.PasswordHistory
|
||||
import com.bitwarden.core.PasswordHistoryView
|
||||
@@ -27,6 +28,15 @@ interface VaultSdkSource {
|
||||
*/
|
||||
fun clearCrypto(userId: String)
|
||||
|
||||
/**
|
||||
* Gets the user's encryption key, which can be used to later unlock their vault via a call to
|
||||
* [initializeCrypto] with [InitUserCryptoMethod.DecryptedKey].
|
||||
*
|
||||
* This should only be called after a successful call to [initializeCrypto] for the associated
|
||||
* user.
|
||||
*/
|
||||
suspend fun getUserEncryptionKey(userId: String): Result<String>
|
||||
|
||||
/**
|
||||
* Attempts to initialize cryptography functionality for an individual user with the given
|
||||
* [userId] for the Bitwarden SDK with a given [InitUserCryptoRequest].
|
||||
|
||||
@@ -31,6 +31,15 @@ class VaultSdkSourceImpl(
|
||||
sdkClientManager.destroyClient(userId = userId)
|
||||
}
|
||||
|
||||
override suspend fun getUserEncryptionKey(
|
||||
userId: String,
|
||||
): Result<String> =
|
||||
runCatching {
|
||||
getClient(userId = userId)
|
||||
.crypto()
|
||||
.getUserEncryptionKey()
|
||||
}
|
||||
|
||||
override suspend fun initializeCrypto(
|
||||
userId: String,
|
||||
request: InitUserCryptoRequest,
|
||||
|
||||
Reference in New Issue
Block a user