1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-22 03:03:43 +00:00
Files
browser/libs/vault/src/cipher-form/services/default-cipher-form-generation.service.ts

31 lines
1.0 KiB
TypeScript

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();
}
}