diff --git a/apps/browser/src/auth/background/service-factories/master-password-service.factory.ts b/apps/browser/src/auth/background/service-factories/master-password-service.factory.ts index a2f9052a3f..37fcf789ff 100644 --- a/apps/browser/src/auth/background/service-factories/master-password-service.factory.ts +++ b/apps/browser/src/auth/background/service-factories/master-password-service.factory.ts @@ -4,20 +4,35 @@ import { } from "@bitwarden/common/auth/abstractions/master-password.service.abstraction"; import { MasterPasswordService } from "@bitwarden/common/auth/services/master-password/master-password.service"; +import { + encryptServiceFactory, + EncryptServiceInitOptions, +} from "../../../platform/background/service-factories/encrypt-service.factory"; import { CachedServices, factory, FactoryOptions, } from "../../../platform/background/service-factories/factory-options"; +import { + keyGenerationServiceFactory, + KeyGenerationServiceInitOptions, +} from "../../../platform/background/service-factories/key-generation-service.factory"; import { stateProviderFactory, StateProviderInitOptions, } from "../../../platform/background/service-factories/state-provider.factory"; +import { + stateServiceFactory, + StateServiceInitOptions, +} from "../../../platform/background/service-factories/state-service.factory"; type MasterPasswordServiceFactoryOptions = FactoryOptions; export type MasterPasswordServiceInitOptions = MasterPasswordServiceFactoryOptions & - StateProviderInitOptions; + StateProviderInitOptions & + StateServiceInitOptions & + KeyGenerationServiceInitOptions & + EncryptServiceInitOptions; export function internalMasterPasswordServiceFactory( cache: { masterPasswordService?: InternalMasterPasswordServiceAbstraction } & CachedServices, @@ -27,7 +42,13 @@ export function internalMasterPasswordServiceFactory( cache, "masterPasswordService", opts, - async () => new MasterPasswordService(await stateProviderFactory(cache, opts)), + async () => + new MasterPasswordService( + await stateProviderFactory(cache, opts), + await stateServiceFactory(cache, opts), + await keyGenerationServiceFactory(cache, opts), + await encryptServiceFactory(cache, opts), + ), ); } diff --git a/apps/browser/src/auth/background/service-factories/pin-crypto-service.factory.ts b/apps/browser/src/auth/background/service-factories/pin-crypto-service.factory.ts deleted file mode 100644 index db16245f67..0000000000 --- a/apps/browser/src/auth/background/service-factories/pin-crypto-service.factory.ts +++ /dev/null @@ -1,53 +0,0 @@ -import { PinCryptoServiceAbstraction, PinCryptoService } from "@bitwarden/auth/common"; - -import { - VaultTimeoutSettingsServiceInitOptions, - vaultTimeoutSettingsServiceFactory, -} from "../../../background/service-factories/vault-timeout-settings-service.factory"; -import { - CryptoServiceInitOptions, - cryptoServiceFactory, -} from "../../../platform/background/service-factories/crypto-service.factory"; -import { - FactoryOptions, - CachedServices, - factory, -} from "../../../platform/background/service-factories/factory-options"; -import { - LogServiceInitOptions, - logServiceFactory, -} from "../../../platform/background/service-factories/log-service.factory"; -import { - StateServiceInitOptions, - stateServiceFactory, -} from "../../../platform/background/service-factories/state-service.factory"; - -import { KdfConfigServiceInitOptions, kdfConfigServiceFactory } from "./kdf-config-service.factory"; - -type PinCryptoServiceFactoryOptions = FactoryOptions; - -export type PinCryptoServiceInitOptions = PinCryptoServiceFactoryOptions & - StateServiceInitOptions & - CryptoServiceInitOptions & - VaultTimeoutSettingsServiceInitOptions & - LogServiceInitOptions & - KdfConfigServiceInitOptions; - -export function pinCryptoServiceFactory( - cache: { pinCryptoService?: PinCryptoServiceAbstraction } & CachedServices, - opts: PinCryptoServiceInitOptions, -): Promise { - return factory( - cache, - "pinCryptoService", - opts, - async () => - new PinCryptoService( - await stateServiceFactory(cache, opts), - await cryptoServiceFactory(cache, opts), - await vaultTimeoutSettingsServiceFactory(cache, opts), - await logServiceFactory(cache, opts), - await kdfConfigServiceFactory(cache, opts), - ), - ); -} diff --git a/apps/browser/src/auth/background/service-factories/pin-service.factory.ts b/apps/browser/src/auth/background/service-factories/pin-service.factory.ts new file mode 100644 index 0000000000..f15e7fe762 --- /dev/null +++ b/apps/browser/src/auth/background/service-factories/pin-service.factory.ts @@ -0,0 +1,74 @@ +import { PinServiceAbstraction, PinService } from "@bitwarden/auth/common"; + +import { + CryptoFunctionServiceInitOptions, + cryptoFunctionServiceFactory, +} from "../../../platform/background/service-factories/crypto-function-service.factory"; +import { + EncryptServiceInitOptions, + encryptServiceFactory, +} from "../../../platform/background/service-factories/encrypt-service.factory"; +import { + FactoryOptions, + CachedServices, + factory, +} from "../../../platform/background/service-factories/factory-options"; +import { + KeyGenerationServiceInitOptions, + keyGenerationServiceFactory, +} from "../../../platform/background/service-factories/key-generation-service.factory"; +import { + LogServiceInitOptions, + logServiceFactory, +} from "../../../platform/background/service-factories/log-service.factory"; +import { + StateProviderInitOptions, + stateProviderFactory, +} from "../../../platform/background/service-factories/state-provider.factory"; +import { + StateServiceInitOptions, + stateServiceFactory, +} from "../../../platform/background/service-factories/state-service.factory"; + +import { AccountServiceInitOptions, accountServiceFactory } from "./account-service.factory"; +import { KdfConfigServiceInitOptions, kdfConfigServiceFactory } from "./kdf-config-service.factory"; +import { + MasterPasswordServiceInitOptions, + masterPasswordServiceFactory, +} from "./master-password-service.factory"; + +type PinServiceFactoryOptions = FactoryOptions; + +export type PinServiceInitOptions = PinServiceFactoryOptions & + AccountServiceInitOptions & + CryptoFunctionServiceInitOptions & + EncryptServiceInitOptions & + KdfConfigServiceInitOptions & + KeyGenerationServiceInitOptions & + LogServiceInitOptions & + MasterPasswordServiceInitOptions & + StateProviderInitOptions & + StateServiceInitOptions; + +export function pinServiceFactory( + cache: { pinService?: PinServiceAbstraction } & CachedServices, + opts: PinServiceInitOptions, +): Promise { + return factory( + cache, + "pinService", + opts, + async () => + new PinService( + await accountServiceFactory(cache, opts), + await cryptoFunctionServiceFactory(cache, opts), + await encryptServiceFactory(cache, opts), + await kdfConfigServiceFactory(cache, opts), + await keyGenerationServiceFactory(cache, opts), + await logServiceFactory(cache, opts), + await masterPasswordServiceFactory(cache, opts), + await stateProviderFactory(cache, opts), + await stateServiceFactory(cache, opts), + ), + ); +} diff --git a/apps/browser/src/auth/background/service-factories/user-verification-service.factory.ts b/apps/browser/src/auth/background/service-factories/user-verification-service.factory.ts index d6f9ce7624..5b5a425045 100644 --- a/apps/browser/src/auth/background/service-factories/user-verification-service.factory.ts +++ b/apps/browser/src/auth/background/service-factories/user-verification-service.factory.ts @@ -37,7 +37,7 @@ import { internalMasterPasswordServiceFactory, MasterPasswordServiceInitOptions, } from "./master-password-service.factory"; -import { PinCryptoServiceInitOptions, pinCryptoServiceFactory } from "./pin-crypto-service.factory"; +import { PinServiceInitOptions, pinServiceFactory } from "./pin-service.factory"; import { userDecryptionOptionsServiceFactory, UserDecryptionOptionsServiceInitOptions, @@ -57,7 +57,7 @@ export type UserVerificationServiceInitOptions = UserVerificationServiceFactoryO I18nServiceInitOptions & UserVerificationApiServiceInitOptions & UserDecryptionOptionsServiceInitOptions & - PinCryptoServiceInitOptions & + PinServiceInitOptions & LogServiceInitOptions & VaultTimeoutSettingsServiceInitOptions & PlatformUtilsServiceInitOptions & @@ -80,7 +80,7 @@ export function userVerificationServiceFactory( await i18nServiceFactory(cache, opts), await userVerificationApiServiceFactory(cache, opts), await userDecryptionOptionsServiceFactory(cache, opts), - await pinCryptoServiceFactory(cache, opts), + await pinServiceFactory(cache, opts), await logServiceFactory(cache, opts), await vaultTimeoutSettingsServiceFactory(cache, opts), await platformUtilsServiceFactory(cache, opts), diff --git a/apps/browser/src/auth/popup/components/set-pin.component.html b/apps/browser/src/auth/popup/components/set-pin.component.html index aff87b5371..50e7aca75f 100644 --- a/apps/browser/src/auth/popup/components/set-pin.component.html +++ b/apps/browser/src/auth/popup/components/set-pin.component.html @@ -12,8 +12,16 @@ -