-
Notifications
You must be signed in to change notification settings - Fork 1.2k
/
password-generation-service.factory.ts
46 lines (42 loc) · 1.41 KB
/
password-generation-service.factory.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
import {
PasswordGenerationService,
PasswordGenerationServiceAbstraction,
} from "@bitwarden/common/tools/generator/password";
import {
policyServiceFactory,
PolicyServiceInitOptions,
} from "../../admin-console/background/service-factories/policy-service.factory";
import {
CryptoServiceInitOptions,
cryptoServiceFactory,
} from "../../platform/background/service-factories/crypto-service.factory";
import {
CachedServices,
factory,
FactoryOptions,
} from "../../platform/background/service-factories/factory-options";
import {
stateServiceFactory,
StateServiceInitOptions,
} from "../../platform/background/service-factories/state-service.factory";
type PasswordGenerationServiceFactoryOptions = FactoryOptions;
export type PasswordGenerationServiceInitOptions = PasswordGenerationServiceFactoryOptions &
CryptoServiceInitOptions &
PolicyServiceInitOptions &
StateServiceInitOptions;
export function passwordGenerationServiceFactory(
cache: { passwordGenerationService?: PasswordGenerationServiceAbstraction } & CachedServices,
opts: PasswordGenerationServiceInitOptions,
): Promise<PasswordGenerationServiceAbstraction> {
return factory(
cache,
"passwordGenerationService",
opts,
async () =>
new PasswordGenerationService(
await cryptoServiceFactory(cache, opts),
await policyServiceFactory(cache, opts),
await stateServiceFactory(cache, opts),
),
);
}