1
0
mirror of https://github.com/bitwarden/mobile.git synced 2024-11-04 08:50:18 +01:00

cipher service interface

This commit is contained in:
Kyle Spearrin 2019-04-16 23:30:52 -04:00
parent a1a8c95ece
commit 98291caf76
2 changed files with 41 additions and 2 deletions

View File

@ -0,0 +1,39 @@
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using Bit.Core.Enums;
using Bit.Core.Models.Data;
using Bit.Core.Models.Domain;
using Bit.Core.Models.View;
namespace Bit.Core.Abstractions
{
public interface ICipherService
{
Task ClearAsync(string userId);
void ClearCache();
Task DeleteAsync(List<string> ids);
Task DeleteAsync(string id);
Task DeleteAttachmentAsync(string id, string attachmentId);
Task DeleteAttachmentWithServerAsync(string id, string attachmentId);
Task DeleteWithServerAsync(string id);
Task<Cipher> EncryptAsync(CipherView model, SymmetricCryptoKey key = null, Cipher originalCipher = null);
Task<List<Cipher>> GetAllAsync();
Task<List<CipherView>> GetAllDecryptedAsync();
Task<Tuple<List<CipherView>, List<CipherView>, List<CipherView>>> GetAllDecryptedByUrlAsync(string url,
List<CipherType> includeOtherTypes = null);
Task<List<CipherView>> GetAllDecryptedForGroupingAsync(string groupingId, bool folder = true);
Task<List<CipherView>> GetAllDecryptedForUrlAsync(string url);
Task<Cipher> GetAsync(string id);
Task<CipherView> GetLastUsedForUrlAsync(string url);
Task ReplaceAsync(Dictionary<string, CipherData> ciphers);
Task<Cipher> SaveAttachmentRawWithServerAsync(Cipher cipher, string filename, byte[] data);
Task SaveCollectionsWithServerAsync(Cipher cipher);
Task SaveNeverDomainAsync(string domain);
Task SaveWithServerAsync(Cipher cipher);
Task ShareWithServerAsync(CipherView cipher, string organizationId, HashSet<string> collectionIds);
Task UpdateLastUsedDateAsync(string id);
Task UpsertAsync(CipherData cipher);
Task UpsertAsync(List<CipherData> cipher);
}
}

View File

@ -17,7 +17,7 @@ using System.Threading.Tasks;
namespace Bit.Core.Services namespace Bit.Core.Services
{ {
public class CipherService public class CipherService : ICipherService
{ {
private const string Keys_CiphersFormat = "ciphers_{0}"; private const string Keys_CiphersFormat = "ciphers_{0}";
private const string Keys_LocalData = "ciphersLocalData"; private const string Keys_LocalData = "ciphersLocalData";
@ -558,7 +558,7 @@ namespace Bit.Core.Services
DecryptedCipherCache = null; DecryptedCipherCache = null;
} }
public async Task RelaceAsync(Dictionary<string, CipherData> ciphers) public async Task ReplaceAsync(Dictionary<string, CipherData> ciphers)
{ {
var userId = await _userService.GetUserIdAsync(); var userId = await _userService.GetUserIdAsync();
await _storageService.SaveAsync(string.Format(Keys_CiphersFormat, userId), ciphers); await _storageService.SaveAsync(string.Format(Keys_CiphersFormat, userId), ciphers);