mirror of
https://github.com/bitwarden/clients.git
synced 2026-11-16 07:03:29 +00:00
Merge branch 'PS55-6-22' into PS-55-8-3
This commit is contained in:
@@ -4,6 +4,7 @@ import { Component, OnInit } from "@angular/core";
|
||||
import { UntypedFormBuilder } from "@angular/forms";
|
||||
|
||||
import { ExportComponent as BaseExportComponent } from "@bitwarden/angular/components/export.component";
|
||||
import { ModalService } from "@bitwarden/angular/services/modal.service";
|
||||
import { BroadcasterService } from "@bitwarden/common/abstractions/broadcaster.service";
|
||||
import { CryptoService } from "@bitwarden/common/abstractions/crypto.service";
|
||||
import { EventService } from "@bitwarden/common/abstractions/event.service";
|
||||
@@ -30,10 +31,11 @@ export class ExportComponent extends BaseExportComponent implements OnInit {
|
||||
eventService: EventService,
|
||||
policyService: PolicyService,
|
||||
userVerificationService: UserVerificationService,
|
||||
formBuilder: UntypedFormBuilder,
|
||||
private broadcasterService: BroadcasterService,
|
||||
logService: LogService,
|
||||
fileDownloadService: FileDownloadService
|
||||
formBuilder: UntypedFormBuilder,
|
||||
fileDownloadService: FileDownloadService,
|
||||
modalService: ModalService
|
||||
) {
|
||||
super(
|
||||
cryptoService,
|
||||
@@ -46,7 +48,8 @@ export class ExportComponent extends BaseExportComponent implements OnInit {
|
||||
logService,
|
||||
userVerificationService,
|
||||
formBuilder,
|
||||
fileDownloadService
|
||||
fileDownloadService,
|
||||
modalService
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -0,0 +1,59 @@
|
||||
<div class="modal fade" role="dialog" aria-modal="true">
|
||||
<div class="modal-dialog modal-dialog-scrollable" role="document">
|
||||
<form #form (ngSubmit)="submit()">
|
||||
<div class="form-group modal-content">
|
||||
<div class="modal-header">
|
||||
<div class="bwi-3x tw-text-center">
|
||||
<i class="bwi bwi-exclamation-triangle text-warning"></i>
|
||||
</div>
|
||||
<h2 class="tw-text-center tw-font-semibold" id="confirmVaultImport">
|
||||
{{ "confirmVaultImport" | i18n }}
|
||||
</h2>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
{{ "confirmVaultImportDesc" | i18n }}
|
||||
<div class="input-group">
|
||||
<bit-form-field>
|
||||
<bit-label>{{ "confirmFilePassword" | i18n }}</bit-label>
|
||||
<input
|
||||
bitInput
|
||||
required
|
||||
type="{{ showFilePassword ? 'text' : 'password' }}"
|
||||
name="filePassword"
|
||||
[formControl]="filePassword"
|
||||
appAutofocus
|
||||
appInputVerbatim
|
||||
/>
|
||||
<button
|
||||
bitSuffix
|
||||
bitButton
|
||||
appStopClick
|
||||
appA11yTitle="{{ 'toggleVisibility' | i18n }}"
|
||||
[attr.aria-pressed]="showFilePassword"
|
||||
(click)="toggleFilePassword()"
|
||||
>
|
||||
<i
|
||||
class="bwi bwi-lg"
|
||||
aria-hidden="true"
|
||||
[ngClass]="{ 'bwi-eye': !showFilePassword, 'bwi-eye-slash': showFilePassword }"
|
||||
></i>
|
||||
</button>
|
||||
</bit-form-field>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<div class="modal-footer-content">
|
||||
<div class="tw-mt-4">
|
||||
<button bitButton buttonType="primary" type="submit" appBlurClick>
|
||||
<span>{{ "importData" | i18n }}</span>
|
||||
</button>
|
||||
<button bitButton buttonType="secondary" type="button" data-dismiss="modal">
|
||||
<span>{{ "cancel" | i18n }}</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@@ -0,0 +1,8 @@
|
||||
import { Component } from "@angular/core";
|
||||
|
||||
import { FilePasswordPromptComponent as BaseFilePasswordPrompt } from "@bitwarden/angular/components/file-password-prompt.component";
|
||||
|
||||
@Component({
|
||||
templateUrl: "file-password-prompt.component.html",
|
||||
})
|
||||
export class FilePasswordPromptComponent extends BaseFilePasswordPrompt {}
|
||||
@@ -0,0 +1,31 @@
|
||||
<div class="modal fade" role="dialog" aria-modal="true" aria-labelledby="confirmUserTitle">
|
||||
<div class="modal-dialog modal-dialog-scrollable" role="document">
|
||||
<form class="modal-content" #form (ngSubmit)="submit()">
|
||||
<div class="modal-header">
|
||||
<div class="bwi-3x tw-text-center">
|
||||
<i class="bwi bwi-exclamation-triangle text-warning"></i>
|
||||
</div>
|
||||
<h2 class="tw-text-center tw-font-semibold" id="modalTitle | i18n">
|
||||
{{ modalTitle | i18n }}
|
||||
</h2>
|
||||
</div>
|
||||
<div class="modal-body">
|
||||
<div>
|
||||
{{ confirmDescription | i18n }}
|
||||
</div>
|
||||
<div class="modal-footer-content">
|
||||
<app-user-verification ngDefaultControl [formControl]="secret" name="secret">
|
||||
</app-user-verification>
|
||||
</div>
|
||||
</div>
|
||||
<div class="modal-footer">
|
||||
<button bitButton buttonType="primary" type="submit" appBlurClick>
|
||||
<span>{{ confirmButtonText | i18n }}</span>
|
||||
</button>
|
||||
<button bitButton buttonType="secondary" data-dismiss="modal">
|
||||
{{ "cancel" | i18n }}
|
||||
</button>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
@@ -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 {}
|
||||
@@ -11,8 +11,16 @@ import {
|
||||
MEMORY_STORAGE,
|
||||
} from "@bitwarden/angular/services/jslib-services.module";
|
||||
import { ModalService as ModalServiceAbstraction } from "@bitwarden/angular/services/modal.service";
|
||||
import { ApiService as ApiServiceAbstraction } from "@bitwarden/common/abstractions/api.service";
|
||||
import { CipherService as CipherServiceAbstraction } from "@bitwarden/common/abstractions/cipher.service";
|
||||
import { CollectionService as CollectionServiceAbstraction } from "@bitwarden/common/abstractions/collection.service";
|
||||
import { CryptoService as CryptoServiceAbstraction } from "@bitwarden/common/abstractions/crypto.service";
|
||||
import { CryptoFunctionService as CryptoFunctionServiceAbstraction } from "@bitwarden/common/abstractions/cryptoFunction.service";
|
||||
import { ExportService as ExportServiceAbstraction } from "@bitwarden/common/abstractions/export.service";
|
||||
import { FileDownloadService } from "@bitwarden/common/abstractions/fileDownload/fileDownload.service";
|
||||
import { FolderService as FolderServiceAbstraction } from "@bitwarden/common/abstractions/folder/folder.service.abstraction";
|
||||
import { I18nService as I18nServiceAbstraction } from "@bitwarden/common/abstractions/i18n.service";
|
||||
import { ImportService as ImportServiceAbstraction } from "@bitwarden/common/abstractions/import.service";
|
||||
import { MessagingService as MessagingServiceAbstraction } from "@bitwarden/common/abstractions/messaging.service";
|
||||
import { PasswordRepromptService as PasswordRepromptServiceAbstraction } from "@bitwarden/common/abstractions/passwordReprompt.service";
|
||||
import { PlatformUtilsService as PlatformUtilsServiceAbstraction } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||
@@ -20,6 +28,8 @@ import { StateService as BaseStateServiceAbstraction } from "@bitwarden/common/a
|
||||
import { StateMigrationService as StateMigrationServiceAbstraction } from "@bitwarden/common/abstractions/stateMigration.service";
|
||||
import { AbstractStorageService } from "@bitwarden/common/abstractions/storage.service";
|
||||
import { StateFactory } from "@bitwarden/common/factories/stateFactory";
|
||||
import { ExportService } from "@bitwarden/common/services/export.service";
|
||||
import { ImportService } from "@bitwarden/common/services/import.service";
|
||||
import { MemoryStorageService } from "@bitwarden/common/services/memoryStorage.service";
|
||||
|
||||
import { BroadcasterMessagingService } from "./broadcaster-messaging.service";
|
||||
@@ -80,6 +90,30 @@ import { WebPlatformUtilsService } from "./web-platform-utils.service";
|
||||
},
|
||||
{ provide: MessagingServiceAbstraction, useClass: BroadcasterMessagingService },
|
||||
{ provide: ModalServiceAbstraction, useClass: ModalService },
|
||||
{
|
||||
provide: ImportServiceAbstraction,
|
||||
useClass: ImportService,
|
||||
deps: [
|
||||
CipherServiceAbstraction,
|
||||
FolderServiceAbstraction,
|
||||
ApiServiceAbstraction,
|
||||
I18nServiceAbstraction,
|
||||
CollectionServiceAbstraction,
|
||||
PlatformUtilsServiceAbstraction,
|
||||
CryptoServiceAbstraction,
|
||||
],
|
||||
},
|
||||
{
|
||||
provide: ExportServiceAbstraction,
|
||||
useClass: ExportService,
|
||||
deps: [
|
||||
FolderServiceAbstraction,
|
||||
CipherServiceAbstraction,
|
||||
ApiServiceAbstraction,
|
||||
CryptoServiceAbstraction,
|
||||
CryptoFunctionServiceAbstraction,
|
||||
],
|
||||
},
|
||||
{
|
||||
provide: StateMigrationServiceAbstraction,
|
||||
useClass: StateMigrationService,
|
||||
|
||||
@@ -19,10 +19,12 @@ import { UpdatePasswordComponent } from "../accounts/update-password.component";
|
||||
import { UpdateTempPasswordComponent } from "../accounts/update-temp-password.component";
|
||||
import { VerifyEmailTokenComponent } from "../accounts/verify-email-token.component";
|
||||
import { VerifyRecoverDeleteComponent } from "../accounts/verify-recover-delete.component";
|
||||
import { FilePasswordPromptComponent } from "../components/file-password-prompt.component";
|
||||
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";
|
||||
@@ -269,6 +271,8 @@ import { OrganizationBadgeModule } from "./vault/modules/organization-badge/orga
|
||||
PasswordGeneratorHistoryComponent,
|
||||
PasswordGeneratorPolicyComponent,
|
||||
PasswordRepromptComponent,
|
||||
FilePasswordPromptComponent,
|
||||
UserVerificationPromptComponent,
|
||||
PaymentMethodComponent,
|
||||
PersonalOwnershipPolicyComponent,
|
||||
PreferencesComponent,
|
||||
|
||||
@@ -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";
|
||||
@@ -31,7 +32,8 @@ export class OrganizationExportComponent extends ExportComponent {
|
||||
logService: LogService,
|
||||
userVerificationService: UserVerificationService,
|
||||
formBuilder: UntypedFormBuilder,
|
||||
fileDownloadService: FileDownloadService
|
||||
fileDownloadService: FileDownloadService,
|
||||
modalService: ModalService
|
||||
) {
|
||||
super(
|
||||
cryptoService,
|
||||
@@ -43,7 +45,8 @@ export class OrganizationExportComponent extends ExportComponent {
|
||||
logService,
|
||||
userVerificationService,
|
||||
formBuilder,
|
||||
fileDownloadService
|
||||
fileDownloadService,
|
||||
modalService
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
@@ -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";
|
||||
@@ -25,9 +26,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() {
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
<form
|
||||
#form
|
||||
(ngSubmit)="submit()"
|
||||
ngNativeValidate
|
||||
[appApiAction]="formPromise"
|
||||
[formGroup]="exportForm"
|
||||
*ngIf="exportForm"
|
||||
>
|
||||
<div class="page-header">
|
||||
<h1>{{ "exportVault" | i18n }}</h1>
|
||||
@@ -19,24 +19,148 @@
|
||||
|
||||
<div class="row">
|
||||
<div class="form-group col-6">
|
||||
<label for="format">{{ "fileFormat" | i18n }}</label>
|
||||
<select class="form-control" id="format" name="Format" formControlName="format">
|
||||
<option *ngFor="let f of formatOptions" [value]="f.value">{{ f.name }}</option>
|
||||
</select>
|
||||
<bit-form-field>
|
||||
<bit-label for="format">{{ "fileFormat" | i18n }}</bit-label>
|
||||
<select bitInput name="format" formControlName="format">
|
||||
<option *ngFor="let f of formatOptions" [value]="f.value">{{ f.name }}</option>
|
||||
</select>
|
||||
</bit-form-field>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<div class="form-group col-6">
|
||||
<app-user-verification ngDefaultControl formControlName="secret" name="secret">
|
||||
</app-user-verification>
|
||||
<ng-container *ngIf="format === 'encrypted_json'">
|
||||
<div role="radiogroup" aria-labelledby="fileTypeHeading">
|
||||
<label id="fileTypeHeading" class="tw-semi-bold tw-text-sm">
|
||||
{{ "fileTypeHeading" | i18n }}
|
||||
</label>
|
||||
|
||||
<div appBoxRow name="FileTypeOptions" class="tw-flex tw-items-center">
|
||||
<div>
|
||||
<input
|
||||
type="radio"
|
||||
class="radio"
|
||||
name="fileEncryptionType"
|
||||
id="AccountEncrypted"
|
||||
[value]="encryptedExportType.AccountEncrypted"
|
||||
formControlName="fileEncryptionType"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label class="tw-semi-bold tw-ml-1 tw-text-xs"> {{ "accountBackup" | i18n }} </label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="tw-regular ml-3 pb-2 tw-text-xs">
|
||||
{{ "accountBackupOptionDescription" | i18n }}
|
||||
</div>
|
||||
|
||||
<div class="tw-flex tw-items-center">
|
||||
<div>
|
||||
<input
|
||||
type="radio"
|
||||
class="radio"
|
||||
name="fileEncryptionType"
|
||||
id="FileEncrypted"
|
||||
[value]="encryptedExportType.FileEncrypted"
|
||||
formControlName="fileEncryptionType"
|
||||
/>
|
||||
</div>
|
||||
<div>
|
||||
<label class="tw-semi-bold tw-ml-1 tw-text-xs">{{
|
||||
"passwordProtected" | i18n
|
||||
}}</label>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="tw-regular ml-3 pb-2 tw-text-xs">
|
||||
{{ "passwordProtectedOptionDescription" | i18n }}
|
||||
</div>
|
||||
</div>
|
||||
<br />
|
||||
|
||||
<ng-container *ngIf="fileEncryptionType == encryptedExportType.FileEncrypted">
|
||||
<div class="input-group">
|
||||
<bit-form-field>
|
||||
<bit-label>{{ "filePassword" | i18n }}</bit-label>
|
||||
<input
|
||||
bitInput
|
||||
required
|
||||
type="{{ showFilePassword ? 'text' : 'password' }}"
|
||||
id="filePassword"
|
||||
formControlName="filePassword"
|
||||
name="password"
|
||||
/>
|
||||
|
||||
<div class="input-group-append">
|
||||
<button
|
||||
bitSuffix
|
||||
bitButton
|
||||
buttonType="secondary"
|
||||
appStopClick
|
||||
appA11yTitle="{{ 'toggleVisibility' | i18n }}"
|
||||
[attr.aria-pressed]="showFilePassword"
|
||||
(click)="toggleFilePassword()"
|
||||
>
|
||||
<i
|
||||
class="bwi bwi-lg"
|
||||
aria-hidden="true"
|
||||
[ngClass]="{ 'bwi-eye': !showFilePassword, 'bwi-eye-slash': showFilePassword }"
|
||||
></i>
|
||||
</button>
|
||||
</div>
|
||||
</bit-form-field>
|
||||
</div>
|
||||
<div class="small text-muted">
|
||||
{{ "exportPasswordDescription" | i18n }}
|
||||
</div>
|
||||
<br />
|
||||
|
||||
<div class="input-group">
|
||||
<bit-form-field>
|
||||
<bit-label>{{ "confirmFilePassword" | i18n }}</bit-label>
|
||||
<input
|
||||
bitInput
|
||||
required
|
||||
type="{{ showConfirmFilePassword ? 'text' : 'password' }}"
|
||||
id="confirmFilePassword"
|
||||
formControlName="confirmFilePassword"
|
||||
name="confirmFilePassword"
|
||||
/>
|
||||
|
||||
<div class="input-group-append">
|
||||
<button
|
||||
bitSuffix
|
||||
bitButton
|
||||
buttonType="secondary"
|
||||
appStopClick
|
||||
appA11yTitle="{{ 'toggleVisibility' | i18n }}"
|
||||
[attr.aria-pressed]="showConfirmFilePassword"
|
||||
(click)="toggleConfirmFilePassword()"
|
||||
>
|
||||
<i
|
||||
class="bwi bwi-lg"
|
||||
aria-hidden="true"
|
||||
[ngClass]="{
|
||||
'bwi-eye': !showConfirmFilePassword,
|
||||
'bwi-eye-slash': showConfirmFilePassword
|
||||
}"
|
||||
></i>
|
||||
</button>
|
||||
</div>
|
||||
</bit-form-field>
|
||||
</div>
|
||||
</ng-container>
|
||||
</ng-container>
|
||||
|
||||
<button
|
||||
type="submit"
|
||||
class="btn btn-primary btn-submit"
|
||||
[disabled]="form.loading || disabled"
|
||||
>
|
||||
<i class="bwi bwi-spinner bwi-spin" title="{{ 'loading' | i18n }}" aria-hidden="true"></i>
|
||||
<span>{{ "confirmFormat" | i18n }}</span>
|
||||
</button>
|
||||
</div>
|
||||
</div>
|
||||
<button
|
||||
type="submit"
|
||||
class="btn btn-primary btn-submit"
|
||||
[disabled]="form.loading || exportForm.disabled"
|
||||
>
|
||||
<i class="bwi bwi-spinner bwi-spin" title="{{ 'loading' | i18n }}" aria-hidden="true"></i>
|
||||
<span>{{ "exportVault" | i18n }}</span>
|
||||
</button>
|
||||
</form>
|
||||
|
||||
@@ -2,6 +2,7 @@ import { Component } from "@angular/core";
|
||||
import { UntypedFormBuilder } from "@angular/forms";
|
||||
|
||||
import { ExportComponent as BaseExportComponent } from "@bitwarden/angular/components/export.component";
|
||||
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";
|
||||
@@ -11,6 +12,9 @@ import { LogService } from "@bitwarden/common/abstractions/log.service";
|
||||
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||
import { PolicyService } from "@bitwarden/common/abstractions/policy.service";
|
||||
import { UserVerificationService } from "@bitwarden/common/abstractions/userVerification.service";
|
||||
import { EncryptedExportType } from "@bitwarden/common/enums/EncryptedExportType";
|
||||
|
||||
import { UserVerificationPromptComponent } from "src/app/components/user-verification-prompt.component";
|
||||
|
||||
@Component({
|
||||
selector: "app-export",
|
||||
@@ -18,6 +22,9 @@ import { UserVerificationService } from "@bitwarden/common/abstractions/userVeri
|
||||
})
|
||||
export class ExportComponent extends BaseExportComponent {
|
||||
organizationId: string;
|
||||
showFilePassword: boolean;
|
||||
showConfirmFilePassword: boolean;
|
||||
encryptedExportType = EncryptedExportType;
|
||||
|
||||
constructor(
|
||||
cryptoService: CryptoService,
|
||||
@@ -29,7 +36,8 @@ export class ExportComponent extends BaseExportComponent {
|
||||
logService: LogService,
|
||||
userVerificationService: UserVerificationService,
|
||||
formBuilder: UntypedFormBuilder,
|
||||
fileDownloadService: FileDownloadService
|
||||
fileDownloadService: FileDownloadService,
|
||||
modalService: ModalService
|
||||
) {
|
||||
super(
|
||||
cryptoService,
|
||||
@@ -42,12 +50,76 @@ export class ExportComponent extends BaseExportComponent {
|
||||
logService,
|
||||
userVerificationService,
|
||||
formBuilder,
|
||||
fileDownloadService
|
||||
fileDownloadService,
|
||||
modalService
|
||||
);
|
||||
}
|
||||
|
||||
async submit() {
|
||||
if (!this.validForm) {
|
||||
return;
|
||||
}
|
||||
|
||||
const confirmDescription =
|
||||
this.exportForm.get("fileEncryptionType").value ===
|
||||
EncryptedExportType.FileEncrypted.toString()
|
||||
? "FileEncryptedExportWarningDesc"
|
||||
: "encExportKeyWarningDesc";
|
||||
|
||||
const ref = this.modalService.open(UserVerificationPromptComponent, {
|
||||
allowMultipleModals: true,
|
||||
data: {
|
||||
confirmDescription: confirmDescription,
|
||||
confirmButtonText: "exportVault",
|
||||
modalTitle: "confirmVaultExport",
|
||||
},
|
||||
});
|
||||
|
||||
if (ref == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
const userVerified = await ref.onClosedPromise();
|
||||
if (userVerified) {
|
||||
//successful
|
||||
this.submitWithSecretAlreadyVerified();
|
||||
}
|
||||
}
|
||||
|
||||
toggleFilePassword() {
|
||||
this.showFilePassword = !this.showFilePassword;
|
||||
document.getElementById("filePassword").focus();
|
||||
}
|
||||
|
||||
toggleConfirmFilePassword() {
|
||||
this.showConfirmFilePassword = !this.showConfirmFilePassword;
|
||||
document.getElementById("confirmFilePassword").focus();
|
||||
}
|
||||
|
||||
protected saved() {
|
||||
super.saved();
|
||||
this.platformUtilsService.showToast("success", null, this.i18nService.t("exportSuccess"));
|
||||
}
|
||||
|
||||
get validForm() {
|
||||
if (
|
||||
this.fileEncryptionType == EncryptedExportType.FileEncrypted.toString() &&
|
||||
this.format == "encrypted_json"
|
||||
) {
|
||||
if (this.filePassword.length > 0 || this.confirmFilePassword.length > 0) {
|
||||
if (this.filePassword != this.confirmFilePassword) {
|
||||
this.platformUtilsService.showToast(
|
||||
"error",
|
||||
this.i18nService.t("errorOccurred"),
|
||||
this.i18nService.t("filePasswordAndConfirmFilePasswordDoNotMatch")
|
||||
);
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
} else {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,12 +7,16 @@ import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
||||
import { CipherService } from "@bitwarden/common/abstractions/cipher.service";
|
||||
import { CollectionService } from "@bitwarden/common/abstractions/collection.service";
|
||||
import { CryptoService } from "@bitwarden/common/abstractions/crypto.service";
|
||||
import { ExportService as ExportServiceAbstraction } from "@bitwarden/common/abstractions/export.service";
|
||||
import { FolderService } from "@bitwarden/common/abstractions/folder/folder.service.abstraction";
|
||||
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||
import { ImportService as ImportServiceAbstraction } from "@bitwarden/common/abstractions/import.service";
|
||||
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||
import { ExportService } from "@bitwarden/common/services/export.service";
|
||||
import { ImportService } from "@bitwarden/common/services/import.service";
|
||||
|
||||
import { SharedModule } from "src/app/modules/shared.module";
|
||||
|
||||
import { LooseComponentsModule } from "../../modules/loose-components.module";
|
||||
|
||||
import { ExportComponent } from "./export.component";
|
||||
@@ -27,9 +31,15 @@ import { ImportComponent } from "./import.component";
|
||||
FormsModule,
|
||||
ReactiveFormsModule,
|
||||
ImportExportRoutingModule,
|
||||
SharedModule,
|
||||
],
|
||||
declarations: [ImportComponent, ExportComponent],
|
||||
providers: [
|
||||
{
|
||||
provide: ExportServiceAbstraction,
|
||||
useClass: ExportService,
|
||||
deps: [FolderService, CipherService, ApiService, CryptoService],
|
||||
},
|
||||
{
|
||||
provide: ImportServiceAbstraction,
|
||||
useClass: ImportService,
|
||||
|
||||
@@ -3,6 +3,7 @@ import { Router } from "@angular/router";
|
||||
import * as JSZip from "jszip";
|
||||
import Swal, { SweetAlertIcon } from "sweetalert2";
|
||||
|
||||
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";
|
||||
@@ -10,6 +11,9 @@ import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUti
|
||||
import { PolicyService } from "@bitwarden/common/abstractions/policy.service";
|
||||
import { ImportOption, ImportType } from "@bitwarden/common/enums/importOptions";
|
||||
import { PolicyType } from "@bitwarden/common/enums/policyType";
|
||||
import { ImportError } from "@bitwarden/common/importers/importError";
|
||||
|
||||
import { FilePasswordPromptComponent } from "src/app/components/file-password-prompt.component";
|
||||
|
||||
@Component({
|
||||
selector: "app-import",
|
||||
@@ -20,7 +24,7 @@ export class ImportComponent implements OnInit {
|
||||
importOptions: ImportOption[];
|
||||
format: ImportType = null;
|
||||
fileContents: string;
|
||||
formPromise: Promise<Error>;
|
||||
formPromise: Promise<ImportError>;
|
||||
loading = false;
|
||||
importBlockedByPolicy = false;
|
||||
|
||||
@@ -33,7 +37,8 @@ export class ImportComponent implements OnInit {
|
||||
protected router: Router,
|
||||
protected platformUtilsService: PlatformUtilsService,
|
||||
protected policyService: PolicyService,
|
||||
private logService: LogService
|
||||
private logService: LogService,
|
||||
protected modalService: ModalService
|
||||
) {}
|
||||
|
||||
async ngOnInit() {
|
||||
@@ -55,7 +60,6 @@ export class ImportComponent implements OnInit {
|
||||
}
|
||||
|
||||
this.loading = true;
|
||||
|
||||
const importer = this.importService.getImporter(this.format, this.organizationId);
|
||||
if (importer === null) {
|
||||
this.platformUtilsService.showToast(
|
||||
@@ -108,10 +112,21 @@ export class ImportComponent implements OnInit {
|
||||
this.formPromise = this.importService.import(importer, fileContents, this.organizationId);
|
||||
const error = await this.formPromise;
|
||||
if (error != null) {
|
||||
this.error(error);
|
||||
this.loading = false;
|
||||
return;
|
||||
//Check if the error is that a password is required
|
||||
if (error.passwordRequired) {
|
||||
if (!(await this.showFilePasswordPrompt(fileContents, this.organizationId))) {
|
||||
//failed - File Password issues
|
||||
this.loading = false;
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
this.error(error);
|
||||
this.loading = false;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
//No errors, display success message
|
||||
this.platformUtilsService.showToast("success", null, this.i18nService.t("importSuccess"));
|
||||
this.router.navigate(this.successNavigate);
|
||||
} catch (e) {
|
||||
@@ -225,4 +240,20 @@ export class ImportComponent implements OnInit {
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
async showFilePasswordPrompt(fcontents: string, organizationId: string) {
|
||||
const ref = await this.modalService.open(FilePasswordPromptComponent, {
|
||||
allowMultipleModals: true,
|
||||
data: {
|
||||
fileContents: fcontents,
|
||||
organizationId: organizationId,
|
||||
},
|
||||
});
|
||||
|
||||
if (ref == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return await ref.onClosedPromise();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -678,6 +678,9 @@
|
||||
"invalidMasterPassword": {
|
||||
"message": "Invalid master password"
|
||||
},
|
||||
"invalidFilePassword": {
|
||||
"message": "Invalid file password, please use the password you entered when you created the export file."
|
||||
},
|
||||
"lockNow": {
|
||||
"message": "Lock Now"
|
||||
},
|
||||
@@ -890,6 +893,48 @@
|
||||
"fileFormat": {
|
||||
"message": "File Format"
|
||||
},
|
||||
"FileEncryptedExportWarningDesc" : {
|
||||
"message": "This file export will be password protected and require the file password to decrypt."
|
||||
},
|
||||
"exportPasswordDescription" : {
|
||||
"message": "This password will be used to export and import this file"
|
||||
},
|
||||
"confirmMasterPassword" : {
|
||||
"message": "Confirm Master Password"
|
||||
},
|
||||
"confirmFormat": {
|
||||
"message": "Confirm Format"
|
||||
},
|
||||
"filePassword": {
|
||||
"message": "File Password"
|
||||
},
|
||||
"confirmFilePassword": {
|
||||
"message": "Confirm File Password"
|
||||
},
|
||||
"accountBackupOptionDescription": {
|
||||
"message": "Leverages your Bitwarden account encryption, not master password, to protect the export. This export can only be imported into the current account. Use this to create a backup that cannot be used elsewhere."
|
||||
},
|
||||
"passwordProtectedOptionDescription": {
|
||||
"message": "Create a user-generated password to protect the export. Use this to create an export that can be used in other accounts."
|
||||
},
|
||||
"fileTypeHeading": {
|
||||
"message": "File Type"
|
||||
},
|
||||
"accountBackup": {
|
||||
"message": "Account Backup"
|
||||
},
|
||||
"passwordProtected": {
|
||||
"message": "Password Protected"
|
||||
},
|
||||
"filePasswordAndConfirmFilePasswordDoNotMatch": {
|
||||
"message": "“File password” and “Confirm File Password“ do not match."
|
||||
},
|
||||
"confirmVaultImport": {
|
||||
"message": "Confirm Vault Import"
|
||||
},
|
||||
"confirmVaultImportDesc": {
|
||||
"message": "This file is password-protected. Please enter the file password to import data."
|
||||
},
|
||||
"exportSuccess": {
|
||||
"message": "Your vault data has been exported."
|
||||
},
|
||||
|
||||
@@ -6,6 +6,21 @@
|
||||
}
|
||||
}
|
||||
|
||||
.modal-footer-content {
|
||||
border: none;
|
||||
border-radius: none;
|
||||
@include themify($themes) {
|
||||
background-color: themed("footerBackgroundColor");
|
||||
}
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
width: 100%;
|
||||
pointer-events: auto;
|
||||
background-clip: padding-box;
|
||||
outline: 0;
|
||||
}
|
||||
|
||||
.modal-dialog {
|
||||
border: 1px solid rgba(0, 0, 0, 0.2);
|
||||
border-radius: 0.3rem;
|
||||
|
||||
@@ -10,9 +10,12 @@ import { LogService } from "@bitwarden/common/abstractions/log.service";
|
||||
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||
import { PolicyService } from "@bitwarden/common/abstractions/policy.service";
|
||||
import { UserVerificationService } from "@bitwarden/common/abstractions/userVerification.service";
|
||||
import { EncryptedExportType } from "@bitwarden/common/enums/EncryptedExportType";
|
||||
import { EventType } from "@bitwarden/common/enums/eventType";
|
||||
import { PolicyType } from "@bitwarden/common/enums/policyType";
|
||||
|
||||
import { ModalService } from "../services/modal.service";
|
||||
|
||||
@Directive()
|
||||
export class ExportComponent implements OnInit {
|
||||
@Output() onSaved = new EventEmitter();
|
||||
@@ -23,6 +26,9 @@ export class ExportComponent implements OnInit {
|
||||
exportForm = this.formBuilder.group({
|
||||
format: ["json"],
|
||||
secret: [""],
|
||||
filePassword: [""],
|
||||
confirmFilePassword: [""],
|
||||
fileEncryptionType: [""],
|
||||
});
|
||||
|
||||
formatOptions = [
|
||||
@@ -42,11 +48,15 @@ export class ExportComponent implements OnInit {
|
||||
private logService: LogService,
|
||||
private userVerificationService: UserVerificationService,
|
||||
private formBuilder: UntypedFormBuilder,
|
||||
protected fileDownloadService: FileDownloadService
|
||||
protected fileDownloadService: FileDownloadService,
|
||||
protected modalService: ModalService
|
||||
) {}
|
||||
|
||||
async ngOnInit() {
|
||||
await this.checkExportDisabled();
|
||||
this.exportForm
|
||||
.get("fileEncryptionType")
|
||||
.setValue(EncryptedExportType.AccountEncrypted.toString());
|
||||
}
|
||||
|
||||
async checkExportDisabled() {
|
||||
@@ -62,6 +72,30 @@ export class ExportComponent implements OnInit {
|
||||
return this.format === "encrypted_json";
|
||||
}
|
||||
|
||||
async submitWithSecretAlreadyVerified() {
|
||||
if (this.disabledByPolicy) {
|
||||
this.platformUtilsService.showToast(
|
||||
"error",
|
||||
null,
|
||||
this.i18nService.t("personalVaultExportPolicyInEffect")
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
this.formPromise = this.getExportData();
|
||||
const data = await this.formPromise;
|
||||
this.downloadFile(data);
|
||||
this.saved();
|
||||
await this.collectEvent();
|
||||
this.exportForm.get("secret").setValue("");
|
||||
this.exportForm.get("filePassword").setValue("");
|
||||
this.exportForm.get("confirmFilePassword").setValue("");
|
||||
} catch (e) {
|
||||
this.logService.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
async submit() {
|
||||
if (this.disabledByPolicy) {
|
||||
this.platformUtilsService.showToast(
|
||||
@@ -76,12 +110,15 @@ export class ExportComponent implements OnInit {
|
||||
if (!acceptedWarning) {
|
||||
return;
|
||||
}
|
||||
|
||||
const secret = this.exportForm.get("secret").value;
|
||||
try {
|
||||
await this.userVerificationService.verifyUser(secret);
|
||||
} catch (e) {
|
||||
this.platformUtilsService.showToast("error", this.i18nService.t("errorOccurred"), e.message);
|
||||
|
||||
const successfulVerification = await this.userVerificationService.verifyUser(secret);
|
||||
if (!successfulVerification) {
|
||||
this.platformUtilsService.showToast(
|
||||
"error",
|
||||
this.i18nService.t("error"),
|
||||
this.i18nService.t("invalidMasterPassword")
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -126,7 +163,11 @@ export class ExportComponent implements OnInit {
|
||||
}
|
||||
|
||||
protected getExportData() {
|
||||
return this.exportService.getExport(this.format);
|
||||
return (this.fileEncryptionType != EncryptedExportType.FileEncrypted.toString() &&
|
||||
this.filePassword == undefined) ||
|
||||
this.filePassword == ""
|
||||
? this.exportService.getExport(this.format, null)
|
||||
: this.exportService.getPasswordProtectedExport(this.filePassword);
|
||||
}
|
||||
|
||||
protected getFileName(prefix?: string) {
|
||||
@@ -150,6 +191,18 @@ export class ExportComponent implements OnInit {
|
||||
return this.exportForm.get("format").value;
|
||||
}
|
||||
|
||||
get filePassword() {
|
||||
return this.exportForm.get("filePassword").value;
|
||||
}
|
||||
|
||||
get confirmFilePassword() {
|
||||
return this.exportForm.get("confirmFilePassword").value;
|
||||
}
|
||||
|
||||
get fileEncryptionType() {
|
||||
return this.exportForm.get("fileEncryptionType").value;
|
||||
}
|
||||
|
||||
private downloadFile(csv: string): void {
|
||||
const fileName = this.getFileName();
|
||||
this.fileDownloadService.download({
|
||||
|
||||
@@ -0,0 +1,61 @@
|
||||
import { Directive } from "@angular/core";
|
||||
import { FormBuilder, FormControl } from "@angular/forms";
|
||||
|
||||
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||
import { ImportService } from "@bitwarden/common/abstractions/import.service";
|
||||
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||
|
||||
import { ModalConfig } from "../services/modal.service";
|
||||
|
||||
import { ModalRef } from "./modal/modal.ref";
|
||||
|
||||
/**
|
||||
* Used to verify the user's File password to import their encyrpted export file" feature only.
|
||||
*/
|
||||
@Directive()
|
||||
export class FilePasswordPromptComponent {
|
||||
showFilePassword: boolean;
|
||||
filePassword = new FormControl("");
|
||||
organizationId: string;
|
||||
fileContents: string;
|
||||
|
||||
constructor(
|
||||
private modalRef: ModalRef,
|
||||
private platformUtilsService: PlatformUtilsService,
|
||||
private i18nService: I18nService,
|
||||
private importService: ImportService,
|
||||
config: ModalConfig,
|
||||
protected formBuilder: FormBuilder
|
||||
) {
|
||||
this.fileContents = config.data.fileContents;
|
||||
this.organizationId = config.data.organizationId;
|
||||
}
|
||||
|
||||
toggleFilePassword() {
|
||||
this.showFilePassword = !this.showFilePassword;
|
||||
}
|
||||
|
||||
async submit() {
|
||||
const importerPassword = this.importService.getImporter(
|
||||
"bitwardenpasswordprotected",
|
||||
this.organizationId,
|
||||
this.filePassword.value
|
||||
);
|
||||
|
||||
const passwordError = this.importService.import(
|
||||
importerPassword,
|
||||
this.fileContents,
|
||||
this.organizationId
|
||||
);
|
||||
|
||||
if (passwordError != null) {
|
||||
this.platformUtilsService.showToast(
|
||||
"error",
|
||||
this.i18nService.t("error"),
|
||||
this.i18nService.t("invalidFilePassword")
|
||||
);
|
||||
} else {
|
||||
this.modalRef.close(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
import { Directive } from "@angular/core";
|
||||
import { FormBuilder, FormControl } from "@angular/forms";
|
||||
|
||||
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||
import { PlatformUtilsService } from "@bitwarden/common/abstractions/platformUtils.service";
|
||||
import { UserVerificationService } from "@bitwarden/common/abstractions/userVerification.service";
|
||||
|
||||
import { ModalConfig } from "../services/modal.service";
|
||||
|
||||
import { ModalRef } from "./modal/modal.ref";
|
||||
|
||||
/**
|
||||
* Used to verify the user's identity (using their master password or email-based OTP for Key Connector users). You can customize all of the text in the modal.
|
||||
*/
|
||||
@Directive()
|
||||
export class UserVerificationPromptComponent {
|
||||
confirmDescription = this.config.data.confirmDescription;
|
||||
confirmButtonText = this.config.data.confirmButtonText;
|
||||
modalTitle = this.config.data.modalTitle;
|
||||
secret = new FormControl();
|
||||
|
||||
constructor(
|
||||
private modalRef: ModalRef,
|
||||
protected config: ModalConfig,
|
||||
protected userVerificationService: UserVerificationService,
|
||||
private formBuilder: FormBuilder,
|
||||
private platformUtilsService: PlatformUtilsService,
|
||||
private i18nService: I18nService
|
||||
) {}
|
||||
|
||||
async submit() {
|
||||
try {
|
||||
//Incorrect secret will throw an invalid password error.
|
||||
await this.userVerificationService.verifyUser(this.secret.value);
|
||||
} catch (e) {
|
||||
this.platformUtilsService.showToast(
|
||||
"error",
|
||||
this.i18nService.t("error"),
|
||||
this.i18nService.t("invalidMasterPassword")
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
this.modalRef.close(true);
|
||||
}
|
||||
}
|
||||
56
libs/angular/src/services/userVerificationPrompt.service.ts
Normal file
56
libs/angular/src/services/userVerificationPrompt.service.ts
Normal file
@@ -0,0 +1,56 @@
|
||||
import { Injectable } from "@angular/core";
|
||||
|
||||
import { I18nService } from "@bitwarden/common/abstractions/i18n.service";
|
||||
import { KeyConnectorService } from "@bitwarden/common/abstractions/keyConnector.service";
|
||||
import { UserVerificationPromptService as UserVerificationPromptServiceAbstraction } from "@bitwarden/common/abstractions/userVerificationPrompt.service";
|
||||
|
||||
import { UserVerificationPromptComponent } from "../components/user-verification-prompt.component";
|
||||
|
||||
import { ModalService } from "./modal.service";
|
||||
|
||||
/**
|
||||
* Used to verify the user's File Password for the "Import passwords using File Password" feature only.
|
||||
*/
|
||||
@Injectable()
|
||||
export class UserVerificationPromptService implements UserVerificationPromptServiceAbstraction {
|
||||
protected component = UserVerificationPromptComponent;
|
||||
|
||||
constructor(
|
||||
private modalService: ModalService,
|
||||
private keyConnectorService: KeyConnectorService,
|
||||
protected i18nService: I18nService
|
||||
) {}
|
||||
|
||||
protectedFields() {
|
||||
return ["TOTP", "Password", "H_Field", "Card Number", "Security Code"];
|
||||
}
|
||||
|
||||
async showUserVerificationPrompt(
|
||||
confirmDescription?: string,
|
||||
confirmButtonText?: string,
|
||||
modalTitle?: string
|
||||
) {
|
||||
if (!(await this.enabled())) {
|
||||
return true;
|
||||
}
|
||||
|
||||
const ref = await this.modalService.open(this.component, {
|
||||
allowMultipleModals: true,
|
||||
data: {
|
||||
confirmDescription: confirmDescription ? confirmDescription : "passwordConfirmationDesc",
|
||||
confirmButtonText: confirmButtonText ? confirmButtonText : "ok",
|
||||
modalTitle: modalTitle ? modalTitle : "passwordConfirmation",
|
||||
},
|
||||
});
|
||||
|
||||
if (ref == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return (await ref.onClosedPromise()) === true;
|
||||
}
|
||||
|
||||
async enabled() {
|
||||
return !(await this.keyConnectorService.getUsesKeyConnector());
|
||||
}
|
||||
}
|
||||
4
libs/common/src/enums/encryptedExportType.ts
Normal file
4
libs/common/src/enums/encryptedExportType.ts
Normal file
@@ -0,0 +1,4 @@
|
||||
export enum EncryptedExportType {
|
||||
AccountEncrypted = 0,
|
||||
FileEncrypted = 1,
|
||||
}
|
||||
Reference in New Issue
Block a user