From 98291caf7622ebce745171ade8a41c9d36aebf06 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Tue, 16 Apr 2019 23:30:52 -0400 Subject: [PATCH] cipher service interface --- src/Core/Abstractions/ICipherService.cs | 39 +++++++++++++++++++++++++ src/Core/Services/CipherService.cs | 4 +-- 2 files changed, 41 insertions(+), 2 deletions(-) create mode 100644 src/Core/Abstractions/ICipherService.cs diff --git a/src/Core/Abstractions/ICipherService.cs b/src/Core/Abstractions/ICipherService.cs new file mode 100644 index 000000000..c41af500c --- /dev/null +++ b/src/Core/Abstractions/ICipherService.cs @@ -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 ids); + Task DeleteAsync(string id); + Task DeleteAttachmentAsync(string id, string attachmentId); + Task DeleteAttachmentWithServerAsync(string id, string attachmentId); + Task DeleteWithServerAsync(string id); + Task EncryptAsync(CipherView model, SymmetricCryptoKey key = null, Cipher originalCipher = null); + Task> GetAllAsync(); + Task> GetAllDecryptedAsync(); + Task, List, List>> GetAllDecryptedByUrlAsync(string url, + List includeOtherTypes = null); + Task> GetAllDecryptedForGroupingAsync(string groupingId, bool folder = true); + Task> GetAllDecryptedForUrlAsync(string url); + Task GetAsync(string id); + Task GetLastUsedForUrlAsync(string url); + Task ReplaceAsync(Dictionary ciphers); + Task 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 collectionIds); + Task UpdateLastUsedDateAsync(string id); + Task UpsertAsync(CipherData cipher); + Task UpsertAsync(List cipher); + } +} \ No newline at end of file diff --git a/src/Core/Services/CipherService.cs b/src/Core/Services/CipherService.cs index 2795c4c22..5fd47a95c 100644 --- a/src/Core/Services/CipherService.cs +++ b/src/Core/Services/CipherService.cs @@ -17,7 +17,7 @@ using System.Threading.Tasks; namespace Bit.Core.Services { - public class CipherService + public class CipherService : ICipherService { private const string Keys_CiphersFormat = "ciphers_{0}"; private const string Keys_LocalData = "ciphersLocalData"; @@ -558,7 +558,7 @@ namespace Bit.Core.Services DecryptedCipherCache = null; } - public async Task RelaceAsync(Dictionary ciphers) + public async Task ReplaceAsync(Dictionary ciphers) { var userId = await _userService.GetUserIdAsync(); await _storageService.SaveAsync(string.Format(Keys_CiphersFormat, userId), ciphers);