1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-06 00:13:28 +00:00

[PM-17948] Migrate export from generator legacy to generator core (#13238)

* Migrate export from generator-legacy to generator-core

* Remove unused platformUtilsService

* Wire up password generation within ngOnInit

---------

Co-authored-by: Daniel James Smith <djsmith85@users.noreply.github.com>
This commit is contained in:
Daniel James Smith
2025-02-18 20:21:42 +01:00
committed by GitHub
parent 30ee79d206
commit f798760dc5
2 changed files with 18 additions and 8 deletions

View File

@@ -42,7 +42,6 @@ import { EventType } from "@bitwarden/common/enums";
import { FileDownloadService } from "@bitwarden/common/platform/abstractions/file-download/file-download.service";
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { Utils } from "@bitwarden/common/platform/misc/utils";
import {
AsyncActionsModule,
@@ -56,7 +55,8 @@ import {
SelectModule,
ToastService,
} from "@bitwarden/components";
import { PasswordGenerationServiceAbstraction } from "@bitwarden/generator-legacy";
import { GeneratorServicesModule } from "@bitwarden/generator-components";
import { CredentialGeneratorService, GenerateRequest, Generators } from "@bitwarden/generator-core";
import { VaultExportServiceAbstraction } from "@bitwarden/vault-export-core";
import { EncryptedExportType } from "../enums/encrypted-export-type.enum";
@@ -81,6 +81,7 @@ import { ExportScopeCalloutComponent } from "./export-scope-callout.component";
ExportScopeCalloutComponent,
UserVerificationDialogComponent,
PasswordStrengthV2Component,
GeneratorServicesModule,
],
})
export class ExportComponent implements OnInit, OnDestroy, AfterViewInit {
@@ -175,14 +176,14 @@ export class ExportComponent implements OnInit, OnDestroy, AfterViewInit {
private destroy$ = new Subject<void>();
private onlyManagedCollections = true;
private onGenerate$ = new Subject<GenerateRequest>();
constructor(
protected i18nService: I18nService,
protected toastService: ToastService,
protected exportService: VaultExportServiceAbstraction,
protected eventCollectionService: EventCollectionService,
protected passwordGenerationService: PasswordGenerationServiceAbstraction,
private platformUtilsService: PlatformUtilsService,
protected generatorService: CredentialGeneratorService,
private policyService: PolicyService,
private logService: LogService,
private formBuilder: UntypedFormBuilder,
@@ -218,6 +219,17 @@ export class ExportComponent implements OnInit, OnDestroy, AfterViewInit {
const userId = await firstValueFrom(getUserId(this.accountService.activeAccount$));
// Wire up the password generation for the password-protected export
this.generatorService
.generate$(Generators.password, { on$: this.onGenerate$ })
.pipe(takeUntil(this.destroy$))
.subscribe((generated) => {
this.exportForm.patchValue({
filePassword: generated.credential,
confirmFilePassword: generated.credential,
});
});
if (this.organizationId) {
this.organizations$ = this.organizationService
.memberOrganizations$(userId)
@@ -302,10 +314,7 @@ export class ExportComponent implements OnInit, OnDestroy, AfterViewInit {
}
generatePassword = async () => {
const [options] = await this.passwordGenerationService.getOptions();
const generatedPassword = await this.passwordGenerationService.generatePassword(options);
this.exportForm.get("filePassword").setValue(generatedPassword);
this.exportForm.get("confirmFilePassword").setValue(generatedPassword);
this.onGenerate$.next({ source: "export" });
};
submit = async () => {

View File

@@ -9,6 +9,7 @@
"@bitwarden/common/*": ["../../../../common/src/*"],
"@bitwarden/components": ["../../../../components/src"],
"@bitwarden/generator-core": ["../../../../tools/generator/core/src"],
"@bitwarden/generator-components": ["../../../../tools/generator/components/src"],
"@bitwarden/generator-history": ["../../../../tools/generator/extensions/history/src"],
"@bitwarden/generator-legacy": ["../../../../tools/generator/extensions/legacy/src"],
"@bitwarden/generator-navigation": ["../../../../tools/generator/extensions/navigation/src"],