1
0
mirror of https://github.com/bitwarden/browser.git synced 2024-12-11 14:48:46 +01:00

[PM-15872] fix username generation character limit (#12329)

This commit is contained in:
✨ Audrey ✨ 2024-12-10 11:08:01 -05:00 committed by GitHub
parent 7a26b041cc
commit b2af12ab24
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -6,6 +6,9 @@ import { CredentialGenerator, EffUsernameGenerationOptions, GeneratedCredential
import { Randomizer } from "./abstractions";
import { WordsRequest } from "./types";
/** The number of digits used when generating an Eff username with a number. */
const NUMBER_OF_DIGITS = 4;
/** Generation algorithms that produce randomized usernames */
export class UsernameRandomizer implements CredentialGenerator<EffUsernameGenerationOptions> {
/** Instantiates the username randomizer
@ -51,7 +54,7 @@ export class UsernameRandomizer implements CredentialGenerator<EffUsernameGenera
async generate(_request: GenerationRequest, settings: EffUsernameGenerationOptions) {
if (isEffUsernameGenerationOptions(settings)) {
const username = await this.randomWords({
digits: settings.wordIncludeNumber ? 1 : 0,
digits: settings.wordIncludeNumber ? NUMBER_OF_DIGITS : 0,
casing: settings.wordCapitalize ? "TitleCase" : "lowercase",
});