2023-03-10 21:39:46 +01:00
|
|
|
import {
|
|
|
|
PasswordGenerationService,
|
|
|
|
PasswordGenerationServiceAbstraction,
|
|
|
|
} from "@bitwarden/common/tools/generator/password";
|
2022-10-18 19:03:09 +02:00
|
|
|
|
|
|
|
import { cryptoServiceFactory, CryptoServiceInitOptions } from "./crypto-service.factory";
|
|
|
|
import { CachedServices, factory, FactoryOptions } from "./factory-options";
|
|
|
|
import { policyServiceFactory, PolicyServiceInitOptions } from "./policy-service.factory";
|
|
|
|
import { stateServiceFactory, StateServiceInitOptions } from "./state-service.factory";
|
|
|
|
|
|
|
|
type PasswordGenerationServiceFactoryOptions = FactoryOptions;
|
|
|
|
|
|
|
|
export type PasswordGenerationServiceInitOptions = PasswordGenerationServiceFactoryOptions &
|
|
|
|
CryptoServiceInitOptions &
|
|
|
|
PolicyServiceInitOptions &
|
|
|
|
StateServiceInitOptions;
|
|
|
|
|
|
|
|
export function passwordGenerationServiceFactory(
|
2023-03-10 21:39:46 +01:00
|
|
|
cache: { passwordGenerationService?: PasswordGenerationServiceAbstraction } & CachedServices,
|
2022-10-18 19:03:09 +02:00
|
|
|
opts: PasswordGenerationServiceInitOptions
|
2023-03-10 21:39:46 +01:00
|
|
|
): Promise<PasswordGenerationServiceAbstraction> {
|
2022-10-18 19:03:09 +02:00
|
|
|
return factory(
|
|
|
|
cache,
|
|
|
|
"passwordGenerationService",
|
|
|
|
opts,
|
|
|
|
async () =>
|
|
|
|
new PasswordGenerationService(
|
|
|
|
await cryptoServiceFactory(cache, opts),
|
|
|
|
await policyServiceFactory(cache, opts),
|
|
|
|
await stateServiceFactory(cache, opts)
|
|
|
|
)
|
|
|
|
);
|
|
|
|
}
|