From a108476c3c984172ba1771494d30caf0204b6ddf Mon Sep 17 00:00:00 2001 From: cd-bitwarden <106776772+cd-bitwarden@users.noreply.github.com> Date: Mon, 29 Aug 2022 10:11:44 -0400 Subject: [PATCH] [SM-89] Updates to encrypted export (#2963) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit * Rough draft of Export/Import changes w/ password encryption * fix for encrypted export changes * Create launch.json * Updates to export logic modal user secret prompt * Updates to error handling * renaming the component for checking the user secret to a name that is more clear about what it accomplishes * Fixing lint errors * Adding a comment * Suggested changes from CR * Suggested changes from CR * Making suggested changes * removing unnecessary properties * changes suggested * Fix * Updating error messages * Removing unecessary launch.json file commit * running lint, removing commented code * removing launch.json * Updates to remove the userVerificationPromptService * updates * Removing unused import, running npm prettier/lint * Changes to use Form Fields * Updates * updates requested by Matt * Update apps/web/src/app/tools/import-export/export.component.ts Co-authored-by: Thomas Rittson <31796059+eliykat@users.noreply.github.com> * Suggested Changes from PR * Fix after merge from Master * changes to styling * Removing unused code and cleanup * Update libs/angular/src/components/user-verification-prompt.component.ts Co-authored-by: Thomas Rittson <31796059+eliykat@users.noreply.github.com> * Update apps/web/src/locales/en/messages.json Co-authored-by: Thomas Rittson <31796059+eliykat@users.noreply.github.com> * Changes suggested by Thomas R * Merging master into branch * Revert "Merging master into branch" This reverts commit eb2cdffe49955e5a902219bc23b1d79fd8c92c03. * Requested changes and improvements * merging master into feature branch * Revert "merging master into feature branch" This reverts commit e287715251880641f79f68e5e187fe29bbaca22f. * Suggested Changes * changes * requested changes * Requested changes * removing comments, fixing code * reducing copied code * fixing bug * fixing bug * changes * WIP * Thomas's requested changes * adding back missing spaces * change needed after the merge from master into feature branch * prettier + lint * Updating the EncryptedExportType Import * Fixing build errors Co-authored-by: Thomas Rittson * Move FilePasswordPrompt to ImportExportModule Also remove base class Also remove duplicate service providers * Run prettier * Suggested Changes from Thomas * only require filePassword and confirmFilePassword if it's type is FileEncrypted * Update to only enable the field when submitting a file password encrypted file * Requested changes, moving logic to web * undoing change to bit button * Refactor to process file-encrypted imports in main import.component *  Refactor confirm file password check * Remove UserVerificationPromptService * Address CodeScene feedback * Updates to disable the required file password field when needed * Subscribe to reactive form changes to adjust validators * style changes requested by suhkleen * Delete duplicate classes Co-authored-by: CarleyDiaz-Bitwarden <103955722+CarleyDiaz-Bitwarden@users.noreply.github.com> Co-authored-by: Thomas Rittson <31796059+eliykat@users.noreply.github.com> Co-authored-by: Thomas Rittson Co-authored-by: Thomas Rittson --- apps/cli/src/locales/en/messages.json | 5 +- .../user-verification-prompt.component.html | 26 +++ .../user-verification-prompt.component.ts | 8 + .../import-export/org-export.component.ts | 7 +- .../import-export/org-import.component.ts | 14 +- .../src/app/shared/loose-components.module.ts | 2 + .../tools/import-export/export.component.html | 157 ++++++++++++++++-- .../tools/import-export/export.component.ts | 78 ++++++++- .../file-password-prompt.component.html | 58 +++++++ .../file-password-prompt.component.ts | 31 ++++ .../import-export/import-export.module.ts | 3 +- .../tools/import-export/import.component.ts | 49 +++++- apps/web/src/locales/en/messages.json | 45 +++++ apps/web/src/scss/modals.scss | 15 ++ .../src/components/export.component.ts | 99 +++++++++-- .../user-verification-prompt.component.ts | 46 +++++ .../src/services/jslib-services.module.ts | 1 + libs/common/src/enums/encryptedExportType.ts | 4 + .../bitwardenPasswordProtectedImporter.ts | 2 +- 19 files changed, 607 insertions(+), 43 deletions(-) create mode 100644 apps/web/src/app/components/user-verification-prompt.component.html create mode 100644 apps/web/src/app/components/user-verification-prompt.component.ts create mode 100644 apps/web/src/app/tools/import-export/file-password-prompt.component.html create mode 100644 apps/web/src/app/tools/import-export/file-password-prompt.component.ts create mode 100644 libs/angular/src/components/user-verification-prompt.component.ts create mode 100644 libs/common/src/enums/encryptedExportType.ts diff --git a/apps/cli/src/locales/en/messages.json b/apps/cli/src/locales/en/messages.json index ca1e8317a8..4b6524b7cc 100644 --- a/apps/cli/src/locales/en/messages.json +++ b/apps/cli/src/locales/en/messages.json @@ -15,7 +15,10 @@ "message": "No Folder" }, "importEncKeyError": { - "message": "Invalid file password." + "message": "Error decrypting the exported file. Your encryption key does not match the encryption key used export the data." + }, + "invalidFilePassword": { + "message": "Invalid file password, please use the password you entered when you created the export file." }, "importPasswordRequired": { "message": "File is password protected, please provide a decryption password." diff --git a/apps/web/src/app/components/user-verification-prompt.component.html b/apps/web/src/app/components/user-verification-prompt.component.html new file mode 100644 index 0000000000..37e2ce87cf --- /dev/null +++ b/apps/web/src/app/components/user-verification-prompt.component.html @@ -0,0 +1,26 @@ + diff --git a/apps/web/src/app/components/user-verification-prompt.component.ts b/apps/web/src/app/components/user-verification-prompt.component.ts new file mode 100644 index 0000000000..e057193aff --- /dev/null +++ b/apps/web/src/app/components/user-verification-prompt.component.ts @@ -0,0 +1,8 @@ +import { Component } from "@angular/core"; + +import { UserVerificationPromptComponent as BaseUserVerificationPrompt } from "@bitwarden/angular/components/user-verification-prompt.component"; + +@Component({ + templateUrl: "user-verification-prompt.component.html", +}) +export class UserVerificationPromptComponent extends BaseUserVerificationPrompt {} diff --git a/apps/web/src/app/organizations/tools/import-export/org-export.component.ts b/apps/web/src/app/organizations/tools/import-export/org-export.component.ts index c2803cab9b..20b6690acd 100644 --- a/apps/web/src/app/organizations/tools/import-export/org-export.component.ts +++ b/apps/web/src/app/organizations/tools/import-export/org-export.component.ts @@ -2,6 +2,7 @@ import { Component } from "@angular/core"; import { UntypedFormBuilder } from "@angular/forms"; import { ActivatedRoute } from "@angular/router"; +import { ModalService } from "@bitwarden/angular/services/modal.service"; import { CryptoService } from "@bitwarden/common/abstractions/crypto.service"; import { EventService } from "@bitwarden/common/abstractions/event.service"; import { ExportService } from "@bitwarden/common/abstractions/export.service"; @@ -32,7 +33,8 @@ export class OrganizationExportComponent extends ExportComponent { logService: LogService, userVerificationService: UserVerificationService, formBuilder: UntypedFormBuilder, - fileDownloadService: FileDownloadService + fileDownloadService: FileDownloadService, + modalService: ModalService ) { super( cryptoService, @@ -44,7 +46,8 @@ export class OrganizationExportComponent extends ExportComponent { logService, userVerificationService, formBuilder, - fileDownloadService + fileDownloadService, + modalService ); } diff --git a/apps/web/src/app/organizations/tools/import-export/org-import.component.ts b/apps/web/src/app/organizations/tools/import-export/org-import.component.ts index 5d24a2cfd4..27d1c6cd39 100644 --- a/apps/web/src/app/organizations/tools/import-export/org-import.component.ts +++ b/apps/web/src/app/organizations/tools/import-export/org-import.component.ts @@ -1,6 +1,7 @@ import { Component } from "@angular/core"; import { ActivatedRoute, Router } from "@angular/router"; +import { ModalService } from "@bitwarden/angular/services/modal.service"; import { I18nService } from "@bitwarden/common/abstractions/i18n.service"; import { ImportService } from "@bitwarden/common/abstractions/import.service"; import { LogService } from "@bitwarden/common/abstractions/log.service"; @@ -26,9 +27,18 @@ export class OrganizationImportComponent extends ImportComponent { platformUtilsService: PlatformUtilsService, policyService: PolicyService, private organizationService: OrganizationService, - logService: LogService + logService: LogService, + modalService: ModalService ) { - super(i18nService, importService, router, platformUtilsService, policyService, logService); + super( + i18nService, + importService, + router, + platformUtilsService, + policyService, + logService, + modalService + ); } async ngOnInit() { diff --git a/apps/web/src/app/shared/loose-components.module.ts b/apps/web/src/app/shared/loose-components.module.ts index a9f6369a3d..59315f9253 100644 --- a/apps/web/src/app/shared/loose-components.module.ts +++ b/apps/web/src/app/shared/loose-components.module.ts @@ -24,6 +24,7 @@ import { NestedCheckboxComponent } from "../components/nested-checkbox.component import { OrganizationSwitcherComponent } from "../components/organization-switcher.component"; import { PasswordRepromptComponent } from "../components/password-reprompt.component"; import { PremiumBadgeComponent } from "../components/premium-badge.component"; +import { UserVerificationPromptComponent } from "../components/user-verification-prompt.component"; import { FooterComponent } from "../layouts/footer.component"; import { FrontendLayoutComponent } from "../layouts/frontend-layout.component"; import { NavbarComponent } from "../layouts/navbar.component"; @@ -253,6 +254,7 @@ import { SharedModule } from "."; PasswordGeneratorHistoryComponent, PasswordGeneratorPolicyComponent, PasswordRepromptComponent, + UserVerificationPromptComponent, PaymentComponent, PaymentMethodComponent, PersonalOwnershipPolicyComponent, diff --git a/apps/web/src/app/tools/import-export/export.component.html b/apps/web/src/app/tools/import-export/export.component.html index da667f3e44..4e27fc70f7 100644 --- a/apps/web/src/app/tools/import-export/export.component.html +++ b/apps/web/src/app/tools/import-export/export.component.html @@ -1,9 +1,9 @@