2023-02-06 22:53:37 +01:00
|
|
|
import { TwoFactorService as AbstractTwoFactorService } from "@bitwarden/common/auth/abstractions/two-factor.service";
|
|
|
|
import { TwoFactorService } from "@bitwarden/common/auth/services/two-factor.service";
|
2022-08-29 20:46:42 +02:00
|
|
|
|
|
|
|
import {
|
2023-02-06 22:53:37 +01:00
|
|
|
FactoryOptions,
|
|
|
|
CachedServices,
|
|
|
|
factory,
|
2023-06-06 22:34:53 +02:00
|
|
|
} from "../../../platform/background/service-factories/factory-options";
|
2023-02-06 22:53:37 +01:00
|
|
|
import {
|
|
|
|
I18nServiceInitOptions,
|
|
|
|
i18nServiceFactory,
|
2023-06-06 22:34:53 +02:00
|
|
|
} from "../../../platform/background/service-factories/i18n-service.factory";
|
2023-02-06 22:53:37 +01:00
|
|
|
import {
|
2022-08-29 20:46:42 +02:00
|
|
|
PlatformUtilsServiceInitOptions,
|
2023-02-06 22:53:37 +01:00
|
|
|
platformUtilsServiceFactory,
|
2023-06-06 22:34:53 +02:00
|
|
|
} from "../../../platform/background/service-factories/platform-utils-service.factory";
|
2022-08-29 20:46:42 +02:00
|
|
|
|
|
|
|
type TwoFactorServiceFactoryOptions = FactoryOptions;
|
|
|
|
|
|
|
|
export type TwoFactorServiceInitOptions = TwoFactorServiceFactoryOptions &
|
|
|
|
I18nServiceInitOptions &
|
|
|
|
PlatformUtilsServiceInitOptions;
|
|
|
|
|
|
|
|
export async function twoFactorServiceFactory(
|
|
|
|
cache: { twoFactorService?: AbstractTwoFactorService } & CachedServices,
|
2023-11-29 22:15:20 +01:00
|
|
|
opts: TwoFactorServiceInitOptions,
|
2022-08-29 20:46:42 +02:00
|
|
|
): Promise<AbstractTwoFactorService> {
|
|
|
|
const service = await factory(
|
|
|
|
cache,
|
|
|
|
"twoFactorService",
|
|
|
|
opts,
|
|
|
|
async () =>
|
|
|
|
new TwoFactorService(
|
|
|
|
await i18nServiceFactory(cache, opts),
|
2023-11-29 22:15:20 +01:00
|
|
|
await platformUtilsServiceFactory(cache, opts),
|
|
|
|
),
|
2022-08-29 20:46:42 +02:00
|
|
|
);
|
2022-10-19 15:55:57 +02:00
|
|
|
service.init();
|
2022-08-29 20:46:42 +02:00
|
|
|
return service;
|
|
|
|
}
|