mirror of
https://github.com/bitwarden/android.git
synced 2026-06-07 23:58:03 -05:00
Add VaultSdkSource.derivePinKey (#609)
This commit is contained in:
committed by
Álison Fernandes
parent
32c1c2155e
commit
c59ae03f97
@@ -5,6 +5,7 @@ import com.bitwarden.core.CipherListView
|
||||
import com.bitwarden.core.CipherView
|
||||
import com.bitwarden.core.Collection
|
||||
import com.bitwarden.core.CollectionView
|
||||
import com.bitwarden.core.DerivePinKeyResponse
|
||||
import com.bitwarden.core.Folder
|
||||
import com.bitwarden.core.FolderView
|
||||
import com.bitwarden.core.InitOrgCryptoRequest
|
||||
@@ -28,6 +29,18 @@ interface VaultSdkSource {
|
||||
*/
|
||||
fun clearCrypto(userId: String)
|
||||
|
||||
/**
|
||||
* Derives a "pin key" from the given [pin] for the given [userId]. This can be used to later
|
||||
* unlock their vault via a call to [initializeCrypto] with [InitUserCryptoMethod.Pin].
|
||||
*
|
||||
* This should only be called after a successful call to [initializeCrypto] for the associated
|
||||
* user.
|
||||
*/
|
||||
suspend fun derivePinKey(
|
||||
userId: String,
|
||||
pin: String,
|
||||
): Result<DerivePinKeyResponse>
|
||||
|
||||
/**
|
||||
* Gets the user's encryption key, which can be used to later unlock their vault via a call to
|
||||
* [initializeCrypto] with [InitUserCryptoMethod.DecryptedKey].
|
||||
|
||||
@@ -5,6 +5,7 @@ import com.bitwarden.core.CipherListView
|
||||
import com.bitwarden.core.CipherView
|
||||
import com.bitwarden.core.Collection
|
||||
import com.bitwarden.core.CollectionView
|
||||
import com.bitwarden.core.DerivePinKeyResponse
|
||||
import com.bitwarden.core.Folder
|
||||
import com.bitwarden.core.FolderView
|
||||
import com.bitwarden.core.InitOrgCryptoRequest
|
||||
@@ -31,6 +32,16 @@ class VaultSdkSourceImpl(
|
||||
sdkClientManager.destroyClient(userId = userId)
|
||||
}
|
||||
|
||||
override suspend fun derivePinKey(
|
||||
userId: String,
|
||||
pin: String,
|
||||
): Result<DerivePinKeyResponse> =
|
||||
runCatching {
|
||||
getClient(userId = userId)
|
||||
.crypto()
|
||||
.derivePinKey(pin = pin)
|
||||
}
|
||||
|
||||
override suspend fun getUserEncryptionKey(
|
||||
userId: String,
|
||||
): Result<String> =
|
||||
|
||||
Reference in New Issue
Block a user