Add support for encrypting sends (#515)

This commit is contained in:
David Perez
2024-01-06 21:18:59 -06:00
committed by Álison Fernandes
parent 9aca107183
commit d00e7d69ea
3 changed files with 41 additions and 0 deletions

View File

@@ -120,6 +120,18 @@ interface VaultSdkSource {
collectionList: List<Collection>,
): Result<List<CollectionView>>
/**
* Encrypts a [SendView] for the user with the given [userId], returning a [Send] wrapped
* in a [Result].
*
* This should only be called after a successful call to [initializeCrypto] for the associated
* user.
*/
suspend fun encryptSend(
userId: String,
sendView: SendView,
): Result<Send>
/**
* Decrypts a [Send] for the user with the given [userId], returning a [SendView] wrapped in a
* [Result].

View File

@@ -63,6 +63,17 @@ class VaultSdkSourceImpl(
}
}
override suspend fun encryptSend(
userId: String,
sendView: SendView,
): Result<Send> =
runCatching {
getClient(userId = userId)
.vault()
.sends()
.encrypt(sendView)
}
override suspend fun encryptCipher(
userId: String,
cipherView: CipherView,