diff --git a/src/Core/Services/ExportService.cs b/src/Core/Services/ExportService.cs index 1aa7b46e2..c5fd0c728 100644 --- a/src/Core/Services/ExportService.cs +++ b/src/Core/Services/ExportService.cs @@ -20,13 +20,16 @@ namespace Bit.Core.Services { private readonly IFolderService _folderService; private readonly ICipherService _cipherService; + private readonly ICryptoService _cryptoService; public ExportService( IFolderService folderService, - ICipherService cipherService) + ICipherService cipherService, + ICryptoService cryptoService) { _folderService = folderService; _cipherService = cipherService; + _cryptoService = cryptoService; } public async Task GetExport(string format = "csv") @@ -37,7 +40,7 @@ namespace Bit.Core.Services var items = (await _cipherService.GetAllAsync()).Where(c => c.OrganizationId == null && c.DeletedDate == null) .Select(c => new CipherWithId(c)); - return ExportEncryptedJson(folders, items); + return await ExportEncryptedJson(folders, items); } else { @@ -177,11 +180,14 @@ namespace Bit.Core.Services }); } - private string ExportEncryptedJson(IEnumerable folders, IEnumerable ciphers) + private async Task ExportEncryptedJson(IEnumerable folders, IEnumerable ciphers) { + var encKeyValidation = await _cryptoService.EncryptAsync(Guid.NewGuid().ToString()); + var jsonDoc = new { Encrypted = true, + EncKeyValidation_DO_NOT_EDIT = encKeyValidation.EncryptedString, Folders = folders, Items = ciphers, }; diff --git a/src/Core/Utilities/ServiceContainer.cs b/src/Core/Utilities/ServiceContainer.cs index a1e713c98..c15d237ef 100644 --- a/src/Core/Utilities/ServiceContainer.cs +++ b/src/Core/Utilities/ServiceContainer.cs @@ -68,7 +68,7 @@ namespace Bit.Core.Utilities var totpService = new TotpService(storageService, cryptoFunctionService); var authService = new AuthService(cryptoService, apiService, userService, tokenService, appIdService, i18nService, platformUtilsService, messagingService, vaultTimeoutService); - var exportService = new ExportService(folderService, cipherService); + var exportService = new ExportService(folderService, cipherService, cryptoService); var auditService = new AuditService(cryptoFunctionService, apiService); var environmentService = new EnvironmentService(apiService, storageService); var eventService = new EventService(storageService, apiService, userService, cipherService);