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:
committed by
GitHub
parent
30ee79d206
commit
f798760dc5
@@ -42,7 +42,6 @@ import { EventType } from "@bitwarden/common/enums";
|
|||||||
import { FileDownloadService } from "@bitwarden/common/platform/abstractions/file-download/file-download.service";
|
import { FileDownloadService } from "@bitwarden/common/platform/abstractions/file-download/file-download.service";
|
||||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
import { LogService } from "@bitwarden/common/platform/abstractions/log.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 { Utils } from "@bitwarden/common/platform/misc/utils";
|
||||||
import {
|
import {
|
||||||
AsyncActionsModule,
|
AsyncActionsModule,
|
||||||
@@ -56,7 +55,8 @@ import {
|
|||||||
SelectModule,
|
SelectModule,
|
||||||
ToastService,
|
ToastService,
|
||||||
} from "@bitwarden/components";
|
} 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 { VaultExportServiceAbstraction } from "@bitwarden/vault-export-core";
|
||||||
|
|
||||||
import { EncryptedExportType } from "../enums/encrypted-export-type.enum";
|
import { EncryptedExportType } from "../enums/encrypted-export-type.enum";
|
||||||
@@ -81,6 +81,7 @@ import { ExportScopeCalloutComponent } from "./export-scope-callout.component";
|
|||||||
ExportScopeCalloutComponent,
|
ExportScopeCalloutComponent,
|
||||||
UserVerificationDialogComponent,
|
UserVerificationDialogComponent,
|
||||||
PasswordStrengthV2Component,
|
PasswordStrengthV2Component,
|
||||||
|
GeneratorServicesModule,
|
||||||
],
|
],
|
||||||
})
|
})
|
||||||
export class ExportComponent implements OnInit, OnDestroy, AfterViewInit {
|
export class ExportComponent implements OnInit, OnDestroy, AfterViewInit {
|
||||||
@@ -175,14 +176,14 @@ export class ExportComponent implements OnInit, OnDestroy, AfterViewInit {
|
|||||||
|
|
||||||
private destroy$ = new Subject<void>();
|
private destroy$ = new Subject<void>();
|
||||||
private onlyManagedCollections = true;
|
private onlyManagedCollections = true;
|
||||||
|
private onGenerate$ = new Subject<GenerateRequest>();
|
||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
protected i18nService: I18nService,
|
protected i18nService: I18nService,
|
||||||
protected toastService: ToastService,
|
protected toastService: ToastService,
|
||||||
protected exportService: VaultExportServiceAbstraction,
|
protected exportService: VaultExportServiceAbstraction,
|
||||||
protected eventCollectionService: EventCollectionService,
|
protected eventCollectionService: EventCollectionService,
|
||||||
protected passwordGenerationService: PasswordGenerationServiceAbstraction,
|
protected generatorService: CredentialGeneratorService,
|
||||||
private platformUtilsService: PlatformUtilsService,
|
|
||||||
private policyService: PolicyService,
|
private policyService: PolicyService,
|
||||||
private logService: LogService,
|
private logService: LogService,
|
||||||
private formBuilder: UntypedFormBuilder,
|
private formBuilder: UntypedFormBuilder,
|
||||||
@@ -218,6 +219,17 @@ export class ExportComponent implements OnInit, OnDestroy, AfterViewInit {
|
|||||||
|
|
||||||
const userId = await firstValueFrom(getUserId(this.accountService.activeAccount$));
|
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) {
|
if (this.organizationId) {
|
||||||
this.organizations$ = this.organizationService
|
this.organizations$ = this.organizationService
|
||||||
.memberOrganizations$(userId)
|
.memberOrganizations$(userId)
|
||||||
@@ -302,10 +314,7 @@ export class ExportComponent implements OnInit, OnDestroy, AfterViewInit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
generatePassword = async () => {
|
generatePassword = async () => {
|
||||||
const [options] = await this.passwordGenerationService.getOptions();
|
this.onGenerate$.next({ source: "export" });
|
||||||
const generatedPassword = await this.passwordGenerationService.generatePassword(options);
|
|
||||||
this.exportForm.get("filePassword").setValue(generatedPassword);
|
|
||||||
this.exportForm.get("confirmFilePassword").setValue(generatedPassword);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
submit = async () => {
|
submit = async () => {
|
||||||
|
|||||||
@@ -9,6 +9,7 @@
|
|||||||
"@bitwarden/common/*": ["../../../../common/src/*"],
|
"@bitwarden/common/*": ["../../../../common/src/*"],
|
||||||
"@bitwarden/components": ["../../../../components/src"],
|
"@bitwarden/components": ["../../../../components/src"],
|
||||||
"@bitwarden/generator-core": ["../../../../tools/generator/core/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-history": ["../../../../tools/generator/extensions/history/src"],
|
||||||
"@bitwarden/generator-legacy": ["../../../../tools/generator/extensions/legacy/src"],
|
"@bitwarden/generator-legacy": ["../../../../tools/generator/extensions/legacy/src"],
|
||||||
"@bitwarden/generator-navigation": ["../../../../tools/generator/extensions/navigation/src"],
|
"@bitwarden/generator-navigation": ["../../../../tools/generator/extensions/navigation/src"],
|
||||||
|
|||||||
Reference in New Issue
Block a user