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

[PM-3609] [Tech-Debt] Add types to password and username generator (#6090)

* Create and use GeneratorOptions

Selection between `password`and `username`

* Use PasswordGeneratorOptions

* Declare and use UsernameGeneratorOptions
This commit is contained in:
Daniel James Smith
2023-09-05 21:48:34 +02:00
committed by GitHub
parent b78d17aa62
commit 255a7381b3
10 changed files with 93 additions and 38 deletions

View File

@@ -8,8 +8,15 @@ import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.servic
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
import { PasswordGenerationServiceAbstraction } from "@bitwarden/common/tools/generator/password";
import { UsernameGenerationServiceAbstraction } from "@bitwarden/common/tools/generator/username";
import { GeneratorOptions } from "@bitwarden/common/tools/generator/generator-options";
import {
PasswordGenerationServiceAbstraction,
PasswordGeneratorOptions,
} from "@bitwarden/common/tools/generator/password";
import {
UsernameGenerationServiceAbstraction,
UsernameGeneratorOptions,
} from "@bitwarden/common/tools/generator/username";
@Directive()
export class GeneratorComponent implements OnInit {
@@ -24,8 +31,8 @@ export class GeneratorComponent implements OnInit {
subaddressOptions: any[];
catchallOptions: any[];
forwardOptions: EmailForwarderOptions[];
usernameOptions: any = {};
passwordOptions: any = {};
usernameOptions: UsernameGeneratorOptions = {};
passwordOptions: PasswordGeneratorOptions = {};
username = "-";
password = "-";
showOptions = false;
@@ -118,7 +125,7 @@ export class GeneratorComponent implements OnInit {
}
async typeChanged() {
await this.stateService.setGeneratorOptions({ type: this.type });
await this.stateService.setGeneratorOptions({ type: this.type } as GeneratorOptions);
if (this.regenerateWithoutButtonPress()) {
await this.regenerate();
}