1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-12 22:33:35 +00:00

[PM-9422] generator engines (#10032)

* introduce email-randomizer
* introduce email-calculator
* introduce password-randomizer
* introduce username-randomizer
* move randomizer abstraction
This commit is contained in:
✨ Audrey ✨
2024-07-19 16:34:39 -04:00
committed by GitHub
parent 5b5c165e10
commit e22568f05a
32 changed files with 2138 additions and 226 deletions

View File

@@ -10,9 +10,9 @@ import { DefaultGeneratorNavigationService } from "@bitwarden/generator-navigati
import { LegacyPasswordGenerationService } from "./legacy-password-generation.service";
import { PasswordGenerationServiceAbstraction } from "./password-generation.service.abstraction";
const PassphraseGeneratorStrategy = strategies.PassphraseGeneratorStrategy;
const PasswordGeneratorStrategy = strategies.PasswordGeneratorStrategy;
const CryptoServiceRandomizer = engine.CryptoServiceRandomizer;
const { PassphraseGeneratorStrategy, PasswordGeneratorStrategy } = strategies;
const { CryptoServiceRandomizer, PasswordRandomizer } = engine;
const DefaultGeneratorService = services.DefaultGeneratorService;
export function legacyPasswordGenerationServiceFactory(
@@ -23,14 +23,15 @@ export function legacyPasswordGenerationServiceFactory(
stateProvider: StateProvider,
): PasswordGenerationServiceAbstraction {
const randomizer = new CryptoServiceRandomizer(cryptoService);
const passwordRandomizer = new PasswordRandomizer(randomizer);
const passwords = new DefaultGeneratorService(
new PasswordGeneratorStrategy(randomizer, stateProvider),
new PasswordGeneratorStrategy(passwordRandomizer, stateProvider),
policyService,
);
const passphrases = new DefaultGeneratorService(
new PassphraseGeneratorStrategy(randomizer, stateProvider),
new PassphraseGeneratorStrategy(passwordRandomizer, stateProvider),
policyService,
);