1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-22 11:13:46 +00:00

[PM-8524] Migrate password/username generation to CipherFormGenerationService

This commit is contained in:
Shane Melton
2024-07-11 12:40:36 -07:00
parent 39ac6061ca
commit 9c1c85155b
6 changed files with 78 additions and 30 deletions

View File

@@ -0,0 +1,30 @@
import { Injectable } from "@angular/core";
import {
PasswordGenerationServiceAbstraction,
UsernameGenerationServiceAbstraction,
} from "@bitwarden/generator-legacy";
import { CipherFormGenerationService } from "../abstractions/cipher-form-generation.service";
@Injectable()
export class DefaultCipherFormGenerationService implements CipherFormGenerationService {
constructor(
private passwordGenerationService: PasswordGenerationServiceAbstraction,
private usernameGenerationService: UsernameGenerationServiceAbstraction,
) {}
async generatePassword(): Promise<string> {
const [options] = await this.passwordGenerationService.getOptions();
return await this.passwordGenerationService.generatePassword(options);
}
async generateUsername(): Promise<string> {
const options = await this.usernameGenerationService.getOptions();
return await this.usernameGenerationService.generateUsername(options);
}
async generateInitialPassword(): Promise<string> {
return await this.generatePassword();
}
}