mirror of
https://github.com/bitwarden/android.git
synced 2026-06-07 23:58:03 -05:00
Add ability to decrypt Collections (#373)
This commit is contained in:
committed by
Álison Fernandes
parent
79f1c2cd4c
commit
970e913373
@@ -3,6 +3,8 @@ package com.x8bit.bitwarden.data.vault.datasource.sdk
|
||||
import com.bitwarden.core.Cipher
|
||||
import com.bitwarden.core.CipherListView
|
||||
import com.bitwarden.core.CipherView
|
||||
import com.bitwarden.core.Collection
|
||||
import com.bitwarden.core.CollectionView
|
||||
import com.bitwarden.core.Folder
|
||||
import com.bitwarden.core.FolderView
|
||||
import com.bitwarden.core.InitUserCryptoRequest
|
||||
@@ -13,6 +15,7 @@ import com.x8bit.bitwarden.data.vault.datasource.sdk.model.InitializeCryptoResul
|
||||
/**
|
||||
* Source of vault information and functionality from the Bitwarden SDK.
|
||||
*/
|
||||
@Suppress("TooManyFunctions")
|
||||
interface VaultSdkSource {
|
||||
|
||||
/**
|
||||
@@ -41,6 +44,18 @@ interface VaultSdkSource {
|
||||
*/
|
||||
suspend fun decryptCipherList(cipherList: List<Cipher>): Result<List<CipherView>>
|
||||
|
||||
/**
|
||||
* Decrypts a [Collection] returning a [CollectionView] wrapped in a [Result].
|
||||
*/
|
||||
suspend fun decryptCollection(collection: Collection): Result<CollectionView>
|
||||
|
||||
/**
|
||||
* Decrypts a list of [Collection]s returning a list of [CollectionView] wrapped in a [Result].
|
||||
*/
|
||||
suspend fun decryptCollectionList(
|
||||
collectionList: List<Collection>,
|
||||
): Result<List<CollectionView>>
|
||||
|
||||
/**
|
||||
* Decrypts a [Send] returning a [SendView] wrapped in a [Result].
|
||||
*/
|
||||
|
||||
@@ -3,6 +3,8 @@ package com.x8bit.bitwarden.data.vault.datasource.sdk
|
||||
import com.bitwarden.core.Cipher
|
||||
import com.bitwarden.core.CipherListView
|
||||
import com.bitwarden.core.CipherView
|
||||
import com.bitwarden.core.Collection
|
||||
import com.bitwarden.core.CollectionView
|
||||
import com.bitwarden.core.Folder
|
||||
import com.bitwarden.core.FolderView
|
||||
import com.bitwarden.core.InitUserCryptoRequest
|
||||
@@ -17,6 +19,7 @@ import com.x8bit.bitwarden.data.vault.datasource.sdk.model.InitializeCryptoResul
|
||||
* Primary implementation of [VaultSdkSource] that serves as a convenience wrapper around a
|
||||
* [ClientVault].
|
||||
*/
|
||||
@Suppress("TooManyFunctions")
|
||||
class VaultSdkSourceImpl(
|
||||
private val clientVault: ClientVault,
|
||||
private val clientCrypto: ClientCrypto,
|
||||
@@ -48,6 +51,18 @@ class VaultSdkSourceImpl(
|
||||
override suspend fun decryptCipherList(cipherList: List<Cipher>): Result<List<CipherView>> =
|
||||
runCatching { cipherList.map { clientVault.ciphers().decrypt(it) } }
|
||||
|
||||
override suspend fun decryptCollection(collection: Collection): Result<CollectionView> =
|
||||
runCatching {
|
||||
clientVault.collections().decrypt(collection)
|
||||
}
|
||||
|
||||
override suspend fun decryptCollectionList(
|
||||
collectionList: List<Collection>,
|
||||
): Result<List<CollectionView>> =
|
||||
runCatching {
|
||||
clientVault.collections().decryptList(collectionList)
|
||||
}
|
||||
|
||||
override suspend fun decryptSend(send: Send): Result<SendView> =
|
||||
runCatching { clientVault.sends().decrypt(send) }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user