mirror of
https://github.com/bitwarden/browser
synced 2026-01-06 10:33:57 +00:00
* remove libs/angular dialog service; move simple dialog types to CL * update DialogServiceAbstraction imports to CL * update imports in libs/angular to use CL * colocate simple dialog types * move SimpleConfigurableDialog files under SimpleDialog * remove CL import alias from CL src * update imports * run prettier * convert SimpleDialog enums to types * replace DialogServiceAbstraction with DialogService * restrict libs/angular imports in CL * add deprecation note to ModalService * Delete BrowserDialogService * Remove ElectronDialogService * update browser and desktop services.module * remove os.EOL in simple dialog * change SimpleDialogCloseType to boolean * remove close type
63 lines
1.8 KiB
TypeScript
63 lines
1.8 KiB
TypeScript
import { Component, OnInit } from "@angular/core";
|
|
|
|
import { KdfConfig } from "@bitwarden/common/auth/models/domain/kdf-config";
|
|
import {
|
|
DEFAULT_KDF_CONFIG,
|
|
DEFAULT_PBKDF2_ITERATIONS,
|
|
DEFAULT_ARGON2_ITERATIONS,
|
|
DEFAULT_ARGON2_MEMORY,
|
|
DEFAULT_ARGON2_PARALLELISM,
|
|
KdfType,
|
|
} from "@bitwarden/common/enums";
|
|
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
|
|
import { DialogService } from "@bitwarden/components";
|
|
|
|
import { ChangeKdfConfirmationComponent } from "./change-kdf-confirmation.component";
|
|
|
|
@Component({
|
|
selector: "app-change-kdf",
|
|
templateUrl: "change-kdf.component.html",
|
|
})
|
|
export class ChangeKdfComponent implements OnInit {
|
|
kdf = KdfType.PBKDF2_SHA256;
|
|
kdfConfig: KdfConfig = DEFAULT_KDF_CONFIG;
|
|
kdfType = KdfType;
|
|
kdfOptions: any[] = [];
|
|
recommendedPbkdf2Iterations = DEFAULT_PBKDF2_ITERATIONS;
|
|
|
|
constructor(private stateService: StateService, private dialogService: DialogService) {
|
|
this.kdfOptions = [
|
|
{ name: "PBKDF2 SHA-256", value: KdfType.PBKDF2_SHA256 },
|
|
{ name: "Argon2id", value: KdfType.Argon2id },
|
|
];
|
|
}
|
|
|
|
async ngOnInit() {
|
|
this.kdf = await this.stateService.getKdfType();
|
|
this.kdfConfig = await this.stateService.getKdfConfig();
|
|
}
|
|
|
|
async onChangeKdf(newValue: KdfType) {
|
|
if (newValue === KdfType.PBKDF2_SHA256) {
|
|
this.kdfConfig = new KdfConfig(DEFAULT_PBKDF2_ITERATIONS);
|
|
} else if (newValue === KdfType.Argon2id) {
|
|
this.kdfConfig = new KdfConfig(
|
|
DEFAULT_ARGON2_ITERATIONS,
|
|
DEFAULT_ARGON2_MEMORY,
|
|
DEFAULT_ARGON2_PARALLELISM
|
|
);
|
|
} else {
|
|
throw new Error("Unknown KDF type.");
|
|
}
|
|
}
|
|
|
|
async openConfirmationModal() {
|
|
this.dialogService.open(ChangeKdfConfirmationComponent, {
|
|
data: {
|
|
kdf: this.kdf,
|
|
kdfConfig: this.kdfConfig,
|
|
},
|
|
});
|
|
}
|
|
}
|