1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-14 23:33:31 +00:00

improve developer experience of generator extension symbols (#9690)

This commit is contained in:
✨ Audrey ✨
2024-06-17 11:10:00 -04:00
committed by GitHub
parent c26669cf60
commit ce88038c0d
3 changed files with 5 additions and 0 deletions

View File

@@ -0,0 +1,49 @@
import { PolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction";
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
import { EncryptService } from "@bitwarden/common/platform/abstractions/encrypt.service";
import { StateProvider } from "@bitwarden/common/platform/state";
import { engine, services, strategies } from "@bitwarden/generator-core";
import { LocalGeneratorHistoryService } from "../history";
import { DefaultGeneratorNavigationService } from "../navigation";
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 DefaultGeneratorService = services.DefaultGeneratorService;
export function legacyPasswordGenerationServiceFactory(
encryptService: EncryptService,
cryptoService: CryptoService,
policyService: PolicyService,
accountService: AccountService,
stateProvider: StateProvider,
): PasswordGenerationServiceAbstraction {
const randomizer = new CryptoServiceRandomizer(cryptoService);
const passwords = new DefaultGeneratorService(
new PasswordGeneratorStrategy(randomizer, stateProvider),
policyService,
);
const passphrases = new DefaultGeneratorService(
new PassphraseGeneratorStrategy(randomizer, stateProvider),
policyService,
);
const navigation = new DefaultGeneratorNavigationService(stateProvider, policyService);
const history = new LocalGeneratorHistoryService(encryptService, cryptoService, stateProvider);
return new LegacyPasswordGenerationService(
accountService,
navigation,
passwords,
passphrases,
history,
);
}