mirror of
https://github.com/bitwarden/browser
synced 2025-12-10 13:23:34 +00:00
consolidate login strategy deps (#8859)
This commit is contained in:
@@ -97,6 +97,7 @@ describe("AuthRequestLoginStrategy", () => {
|
|||||||
|
|
||||||
authRequestLoginStrategy = new AuthRequestLoginStrategy(
|
authRequestLoginStrategy = new AuthRequestLoginStrategy(
|
||||||
cache,
|
cache,
|
||||||
|
deviceTrustService,
|
||||||
accountService,
|
accountService,
|
||||||
masterPasswordService,
|
masterPasswordService,
|
||||||
cryptoService,
|
cryptoService,
|
||||||
@@ -109,7 +110,6 @@ describe("AuthRequestLoginStrategy", () => {
|
|||||||
stateService,
|
stateService,
|
||||||
twoFactorService,
|
twoFactorService,
|
||||||
userDecryptionOptions,
|
userDecryptionOptions,
|
||||||
deviceTrustService,
|
|
||||||
billingAccountProfileStateService,
|
billingAccountProfileStateService,
|
||||||
vaultTimeoutSettingsService,
|
vaultTimeoutSettingsService,
|
||||||
kdfConfigService,
|
kdfConfigService,
|
||||||
|
|||||||
@@ -1,28 +1,13 @@
|
|||||||
import { firstValueFrom, Observable, map, BehaviorSubject } from "rxjs";
|
import { firstValueFrom, Observable, map, BehaviorSubject } from "rxjs";
|
||||||
import { Jsonify } from "type-fest";
|
import { Jsonify } from "type-fest";
|
||||||
|
|
||||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
import { DeviceTrustServiceAbstraction } from "@bitwarden/common/auth/abstractions/device-trust.service.abstraction";
|
||||||
import { VaultTimeoutSettingsService } from "@bitwarden/common/abstractions/vault-timeout/vault-timeout-settings.service";
|
|
||||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
|
||||||
import { KdfConfigService } from "@bitwarden/common/auth/abstractions/kdf-config.service";
|
|
||||||
import { InternalMasterPasswordServiceAbstraction } from "@bitwarden/common/auth/abstractions/master-password.service.abstraction";
|
|
||||||
import { TokenService } from "@bitwarden/common/auth/abstractions/token.service";
|
|
||||||
import { TwoFactorService } from "@bitwarden/common/auth/abstractions/two-factor.service";
|
|
||||||
import { AuthResult } from "@bitwarden/common/auth/models/domain/auth-result";
|
import { AuthResult } from "@bitwarden/common/auth/models/domain/auth-result";
|
||||||
import { PasswordTokenRequest } from "@bitwarden/common/auth/models/request/identity-token/password-token.request";
|
import { PasswordTokenRequest } from "@bitwarden/common/auth/models/request/identity-token/password-token.request";
|
||||||
import { TokenTwoFactorRequest } from "@bitwarden/common/auth/models/request/identity-token/token-two-factor.request";
|
import { TokenTwoFactorRequest } from "@bitwarden/common/auth/models/request/identity-token/token-two-factor.request";
|
||||||
import { IdentityTokenResponse } from "@bitwarden/common/auth/models/response/identity-token.response";
|
import { IdentityTokenResponse } from "@bitwarden/common/auth/models/response/identity-token.response";
|
||||||
import { BillingAccountProfileStateService } from "@bitwarden/common/billing/abstractions/account/billing-account-profile-state.service";
|
|
||||||
import { AppIdService } from "@bitwarden/common/platform/abstractions/app-id.service";
|
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
|
||||||
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
|
||||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
|
||||||
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
|
|
||||||
import { DeviceTrustServiceAbstraction } from "@bitwarden/common/src/auth/abstractions/device-trust.service.abstraction";
|
|
||||||
import { UserId } from "@bitwarden/common/types/guid";
|
import { UserId } from "@bitwarden/common/types/guid";
|
||||||
|
|
||||||
import { InternalUserDecryptionOptionsServiceAbstraction } from "../abstractions/user-decryption-options.service.abstraction";
|
|
||||||
import { AuthRequestLoginCredentials } from "../models/domain/login-credentials";
|
import { AuthRequestLoginCredentials } from "../models/domain/login-credentials";
|
||||||
import { CacheData } from "../services/login-strategies/login-strategy.state";
|
import { CacheData } from "../services/login-strategies/login-strategy.state";
|
||||||
|
|
||||||
@@ -51,40 +36,10 @@ export class AuthRequestLoginStrategy extends LoginStrategy {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
data: AuthRequestLoginStrategyData,
|
data: AuthRequestLoginStrategyData,
|
||||||
accountService: AccountService,
|
|
||||||
masterPasswordService: InternalMasterPasswordServiceAbstraction,
|
|
||||||
cryptoService: CryptoService,
|
|
||||||
apiService: ApiService,
|
|
||||||
tokenService: TokenService,
|
|
||||||
appIdService: AppIdService,
|
|
||||||
platformUtilsService: PlatformUtilsService,
|
|
||||||
messagingService: MessagingService,
|
|
||||||
logService: LogService,
|
|
||||||
stateService: StateService,
|
|
||||||
twoFactorService: TwoFactorService,
|
|
||||||
userDecryptionOptionsService: InternalUserDecryptionOptionsServiceAbstraction,
|
|
||||||
private deviceTrustService: DeviceTrustServiceAbstraction,
|
private deviceTrustService: DeviceTrustServiceAbstraction,
|
||||||
billingAccountProfileStateService: BillingAccountProfileStateService,
|
...sharedDeps: ConstructorParameters<typeof LoginStrategy>
|
||||||
vaultTimeoutSettingsService: VaultTimeoutSettingsService,
|
|
||||||
kdfConfigService: KdfConfigService,
|
|
||||||
) {
|
) {
|
||||||
super(
|
super(...sharedDeps);
|
||||||
accountService,
|
|
||||||
masterPasswordService,
|
|
||||||
cryptoService,
|
|
||||||
apiService,
|
|
||||||
tokenService,
|
|
||||||
appIdService,
|
|
||||||
platformUtilsService,
|
|
||||||
messagingService,
|
|
||||||
logService,
|
|
||||||
stateService,
|
|
||||||
twoFactorService,
|
|
||||||
userDecryptionOptionsService,
|
|
||||||
billingAccountProfileStateService,
|
|
||||||
vaultTimeoutSettingsService,
|
|
||||||
kdfConfigService,
|
|
||||||
);
|
|
||||||
|
|
||||||
this.cache = new BehaviorSubject(data);
|
this.cache = new BehaviorSubject(data);
|
||||||
this.email$ = this.cache.pipe(map((data) => data.tokenRequest.email));
|
this.email$ = this.cache.pipe(map((data) => data.tokenRequest.email));
|
||||||
|
|||||||
@@ -150,6 +150,9 @@ describe("LoginStrategy", () => {
|
|||||||
// The base class is abstract so we test it via PasswordLoginStrategy
|
// The base class is abstract so we test it via PasswordLoginStrategy
|
||||||
passwordLoginStrategy = new PasswordLoginStrategy(
|
passwordLoginStrategy = new PasswordLoginStrategy(
|
||||||
cache,
|
cache,
|
||||||
|
passwordStrengthService,
|
||||||
|
policyService,
|
||||||
|
loginStrategyService,
|
||||||
accountService,
|
accountService,
|
||||||
masterPasswordService,
|
masterPasswordService,
|
||||||
cryptoService,
|
cryptoService,
|
||||||
@@ -162,9 +165,6 @@ describe("LoginStrategy", () => {
|
|||||||
stateService,
|
stateService,
|
||||||
twoFactorService,
|
twoFactorService,
|
||||||
userDecryptionOptionsService,
|
userDecryptionOptionsService,
|
||||||
passwordStrengthService,
|
|
||||||
policyService,
|
|
||||||
loginStrategyService,
|
|
||||||
billingAccountProfileStateService,
|
billingAccountProfileStateService,
|
||||||
vaultTimeoutSettingsService,
|
vaultTimeoutSettingsService,
|
||||||
kdfConfigService,
|
kdfConfigService,
|
||||||
@@ -461,6 +461,9 @@ describe("LoginStrategy", () => {
|
|||||||
|
|
||||||
passwordLoginStrategy = new PasswordLoginStrategy(
|
passwordLoginStrategy = new PasswordLoginStrategy(
|
||||||
cache,
|
cache,
|
||||||
|
passwordStrengthService,
|
||||||
|
policyService,
|
||||||
|
loginStrategyService,
|
||||||
accountService,
|
accountService,
|
||||||
masterPasswordService,
|
masterPasswordService,
|
||||||
cryptoService,
|
cryptoService,
|
||||||
@@ -473,9 +476,6 @@ describe("LoginStrategy", () => {
|
|||||||
stateService,
|
stateService,
|
||||||
twoFactorService,
|
twoFactorService,
|
||||||
userDecryptionOptionsService,
|
userDecryptionOptionsService,
|
||||||
passwordStrengthService,
|
|
||||||
policyService,
|
|
||||||
loginStrategyService,
|
|
||||||
billingAccountProfileStateService,
|
billingAccountProfileStateService,
|
||||||
vaultTimeoutSettingsService,
|
vaultTimeoutSettingsService,
|
||||||
kdfConfigService,
|
kdfConfigService,
|
||||||
|
|||||||
@@ -121,6 +121,9 @@ describe("PasswordLoginStrategy", () => {
|
|||||||
|
|
||||||
passwordLoginStrategy = new PasswordLoginStrategy(
|
passwordLoginStrategy = new PasswordLoginStrategy(
|
||||||
cache,
|
cache,
|
||||||
|
passwordStrengthService,
|
||||||
|
policyService,
|
||||||
|
loginStrategyService,
|
||||||
accountService,
|
accountService,
|
||||||
masterPasswordService,
|
masterPasswordService,
|
||||||
cryptoService,
|
cryptoService,
|
||||||
@@ -133,9 +136,6 @@ describe("PasswordLoginStrategy", () => {
|
|||||||
stateService,
|
stateService,
|
||||||
twoFactorService,
|
twoFactorService,
|
||||||
userDecryptionOptionsService,
|
userDecryptionOptionsService,
|
||||||
passwordStrengthService,
|
|
||||||
policyService,
|
|
||||||
loginStrategyService,
|
|
||||||
billingAccountProfileStateService,
|
billingAccountProfileStateService,
|
||||||
vaultTimeoutSettingsService,
|
vaultTimeoutSettingsService,
|
||||||
kdfConfigService,
|
kdfConfigService,
|
||||||
|
|||||||
@@ -1,15 +1,8 @@
|
|||||||
import { BehaviorSubject, firstValueFrom, map, Observable } from "rxjs";
|
import { BehaviorSubject, firstValueFrom, map, Observable } from "rxjs";
|
||||||
import { Jsonify } from "type-fest";
|
import { Jsonify } from "type-fest";
|
||||||
|
|
||||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
|
||||||
import { VaultTimeoutSettingsService } from "@bitwarden/common/abstractions/vault-timeout/vault-timeout-settings.service";
|
|
||||||
import { PolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction";
|
import { PolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction";
|
||||||
import { MasterPasswordPolicyOptions } from "@bitwarden/common/admin-console/models/domain/master-password-policy-options";
|
import { MasterPasswordPolicyOptions } from "@bitwarden/common/admin-console/models/domain/master-password-policy-options";
|
||||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
|
||||||
import { KdfConfigService } from "@bitwarden/common/auth/abstractions/kdf-config.service";
|
|
||||||
import { InternalMasterPasswordServiceAbstraction } from "@bitwarden/common/auth/abstractions/master-password.service.abstraction";
|
|
||||||
import { TokenService } from "@bitwarden/common/auth/abstractions/token.service";
|
|
||||||
import { TwoFactorService } from "@bitwarden/common/auth/abstractions/two-factor.service";
|
|
||||||
import { AuthResult } from "@bitwarden/common/auth/models/domain/auth-result";
|
import { AuthResult } from "@bitwarden/common/auth/models/domain/auth-result";
|
||||||
import { ForceSetPasswordReason } from "@bitwarden/common/auth/models/domain/force-set-password-reason";
|
import { ForceSetPasswordReason } from "@bitwarden/common/auth/models/domain/force-set-password-reason";
|
||||||
import { PasswordTokenRequest } from "@bitwarden/common/auth/models/request/identity-token/password-token.request";
|
import { PasswordTokenRequest } from "@bitwarden/common/auth/models/request/identity-token/password-token.request";
|
||||||
@@ -17,13 +10,6 @@ import { TokenTwoFactorRequest } from "@bitwarden/common/auth/models/request/ide
|
|||||||
import { IdentityCaptchaResponse } from "@bitwarden/common/auth/models/response/identity-captcha.response";
|
import { IdentityCaptchaResponse } from "@bitwarden/common/auth/models/response/identity-captcha.response";
|
||||||
import { IdentityTokenResponse } from "@bitwarden/common/auth/models/response/identity-token.response";
|
import { IdentityTokenResponse } from "@bitwarden/common/auth/models/response/identity-token.response";
|
||||||
import { IdentityTwoFactorResponse } from "@bitwarden/common/auth/models/response/identity-two-factor.response";
|
import { IdentityTwoFactorResponse } from "@bitwarden/common/auth/models/response/identity-two-factor.response";
|
||||||
import { BillingAccountProfileStateService } from "@bitwarden/common/billing/abstractions/account/billing-account-profile-state.service";
|
|
||||||
import { AppIdService } from "@bitwarden/common/platform/abstractions/app-id.service";
|
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
|
||||||
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
|
||||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
|
||||||
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
|
|
||||||
import { HashPurpose } from "@bitwarden/common/platform/enums";
|
import { HashPurpose } from "@bitwarden/common/platform/enums";
|
||||||
import { SymmetricCryptoKey } from "@bitwarden/common/platform/models/domain/symmetric-crypto-key";
|
import { SymmetricCryptoKey } from "@bitwarden/common/platform/models/domain/symmetric-crypto-key";
|
||||||
import { PasswordStrengthServiceAbstraction } from "@bitwarden/common/tools/password-strength";
|
import { PasswordStrengthServiceAbstraction } from "@bitwarden/common/tools/password-strength";
|
||||||
@@ -31,7 +17,6 @@ import { UserId } from "@bitwarden/common/types/guid";
|
|||||||
import { MasterKey } from "@bitwarden/common/types/key";
|
import { MasterKey } from "@bitwarden/common/types/key";
|
||||||
|
|
||||||
import { LoginStrategyServiceAbstraction } from "../abstractions";
|
import { LoginStrategyServiceAbstraction } from "../abstractions";
|
||||||
import { InternalUserDecryptionOptionsServiceAbstraction } from "../abstractions/user-decryption-options.service.abstraction";
|
|
||||||
import { PasswordLoginCredentials } from "../models/domain/login-credentials";
|
import { PasswordLoginCredentials } from "../models/domain/login-credentials";
|
||||||
import { CacheData } from "../services/login-strategies/login-strategy.state";
|
import { CacheData } from "../services/login-strategies/login-strategy.state";
|
||||||
|
|
||||||
@@ -75,42 +60,12 @@ export class PasswordLoginStrategy extends LoginStrategy {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
data: PasswordLoginStrategyData,
|
data: PasswordLoginStrategyData,
|
||||||
accountService: AccountService,
|
|
||||||
masterPasswordService: InternalMasterPasswordServiceAbstraction,
|
|
||||||
cryptoService: CryptoService,
|
|
||||||
apiService: ApiService,
|
|
||||||
tokenService: TokenService,
|
|
||||||
appIdService: AppIdService,
|
|
||||||
platformUtilsService: PlatformUtilsService,
|
|
||||||
messagingService: MessagingService,
|
|
||||||
logService: LogService,
|
|
||||||
protected stateService: StateService,
|
|
||||||
twoFactorService: TwoFactorService,
|
|
||||||
userDecryptionOptionsService: InternalUserDecryptionOptionsServiceAbstraction,
|
|
||||||
private passwordStrengthService: PasswordStrengthServiceAbstraction,
|
private passwordStrengthService: PasswordStrengthServiceAbstraction,
|
||||||
private policyService: PolicyService,
|
private policyService: PolicyService,
|
||||||
private loginStrategyService: LoginStrategyServiceAbstraction,
|
private loginStrategyService: LoginStrategyServiceAbstraction,
|
||||||
billingAccountProfileStateService: BillingAccountProfileStateService,
|
...sharedDeps: ConstructorParameters<typeof LoginStrategy>
|
||||||
vaultTimeoutSettingsService: VaultTimeoutSettingsService,
|
|
||||||
kdfConfigService: KdfConfigService,
|
|
||||||
) {
|
) {
|
||||||
super(
|
super(...sharedDeps);
|
||||||
accountService,
|
|
||||||
masterPasswordService,
|
|
||||||
cryptoService,
|
|
||||||
apiService,
|
|
||||||
tokenService,
|
|
||||||
appIdService,
|
|
||||||
platformUtilsService,
|
|
||||||
messagingService,
|
|
||||||
logService,
|
|
||||||
stateService,
|
|
||||||
twoFactorService,
|
|
||||||
userDecryptionOptionsService,
|
|
||||||
billingAccountProfileStateService,
|
|
||||||
vaultTimeoutSettingsService,
|
|
||||||
kdfConfigService,
|
|
||||||
);
|
|
||||||
|
|
||||||
this.cache = new BehaviorSubject(data);
|
this.cache = new BehaviorSubject(data);
|
||||||
this.email$ = this.cache.pipe(map((state) => state.tokenRequest.email));
|
this.email$ = this.cache.pipe(map((state) => state.tokenRequest.email));
|
||||||
|
|||||||
@@ -118,6 +118,10 @@ describe("SsoLoginStrategy", () => {
|
|||||||
|
|
||||||
ssoLoginStrategy = new SsoLoginStrategy(
|
ssoLoginStrategy = new SsoLoginStrategy(
|
||||||
null,
|
null,
|
||||||
|
keyConnectorService,
|
||||||
|
deviceTrustService,
|
||||||
|
authRequestService,
|
||||||
|
i18nService,
|
||||||
accountService,
|
accountService,
|
||||||
masterPasswordService,
|
masterPasswordService,
|
||||||
cryptoService,
|
cryptoService,
|
||||||
@@ -130,10 +134,6 @@ describe("SsoLoginStrategy", () => {
|
|||||||
stateService,
|
stateService,
|
||||||
twoFactorService,
|
twoFactorService,
|
||||||
userDecryptionOptionsService,
|
userDecryptionOptionsService,
|
||||||
keyConnectorService,
|
|
||||||
deviceTrustService,
|
|
||||||
authRequestService,
|
|
||||||
i18nService,
|
|
||||||
billingAccountProfileStateService,
|
billingAccountProfileStateService,
|
||||||
vaultTimeoutSettingsService,
|
vaultTimeoutSettingsService,
|
||||||
kdfConfigService,
|
kdfConfigService,
|
||||||
|
|||||||
@@ -1,36 +1,19 @@
|
|||||||
import { firstValueFrom, Observable, map, BehaviorSubject } from "rxjs";
|
import { firstValueFrom, Observable, map, BehaviorSubject } from "rxjs";
|
||||||
import { Jsonify } from "type-fest";
|
import { Jsonify } from "type-fest";
|
||||||
|
|
||||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
import { DeviceTrustServiceAbstraction } from "@bitwarden/common/auth/abstractions/device-trust.service.abstraction";
|
||||||
import { VaultTimeoutSettingsService } from "@bitwarden/common/abstractions/vault-timeout/vault-timeout-settings.service";
|
|
||||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
|
||||||
import { KdfConfigService } from "@bitwarden/common/auth/abstractions/kdf-config.service";
|
|
||||||
import { KeyConnectorService } from "@bitwarden/common/auth/abstractions/key-connector.service";
|
import { KeyConnectorService } from "@bitwarden/common/auth/abstractions/key-connector.service";
|
||||||
import { InternalMasterPasswordServiceAbstraction } from "@bitwarden/common/auth/abstractions/master-password.service.abstraction";
|
|
||||||
import { TokenService } from "@bitwarden/common/auth/abstractions/token.service";
|
|
||||||
import { TwoFactorService } from "@bitwarden/common/auth/abstractions/two-factor.service";
|
|
||||||
import { AuthResult } from "@bitwarden/common/auth/models/domain/auth-result";
|
import { AuthResult } from "@bitwarden/common/auth/models/domain/auth-result";
|
||||||
import { ForceSetPasswordReason } from "@bitwarden/common/auth/models/domain/force-set-password-reason";
|
import { ForceSetPasswordReason } from "@bitwarden/common/auth/models/domain/force-set-password-reason";
|
||||||
import { SsoTokenRequest } from "@bitwarden/common/auth/models/request/identity-token/sso-token.request";
|
import { SsoTokenRequest } from "@bitwarden/common/auth/models/request/identity-token/sso-token.request";
|
||||||
import { AuthRequestResponse } from "@bitwarden/common/auth/models/response/auth-request.response";
|
import { AuthRequestResponse } from "@bitwarden/common/auth/models/response/auth-request.response";
|
||||||
import { IdentityTokenResponse } from "@bitwarden/common/auth/models/response/identity-token.response";
|
import { IdentityTokenResponse } from "@bitwarden/common/auth/models/response/identity-token.response";
|
||||||
import { BillingAccountProfileStateService } from "@bitwarden/common/billing/abstractions/account/billing-account-profile-state.service";
|
|
||||||
import { HttpStatusCode } from "@bitwarden/common/enums";
|
import { HttpStatusCode } from "@bitwarden/common/enums";
|
||||||
import { ErrorResponse } from "@bitwarden/common/models/response/error.response";
|
import { ErrorResponse } from "@bitwarden/common/models/response/error.response";
|
||||||
import { AppIdService } from "@bitwarden/common/platform/abstractions/app-id.service";
|
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
import { I18nService } from "@bitwarden/common/platform/abstractions/i18n.service";
|
||||||
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
|
||||||
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
|
||||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
|
||||||
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
|
|
||||||
import { DeviceTrustServiceAbstraction } from "@bitwarden/common/src/auth/abstractions/device-trust.service.abstraction";
|
|
||||||
import { UserId } from "@bitwarden/common/types/guid";
|
import { UserId } from "@bitwarden/common/types/guid";
|
||||||
|
|
||||||
import {
|
import { AuthRequestServiceAbstraction } from "../abstractions";
|
||||||
InternalUserDecryptionOptionsServiceAbstraction,
|
|
||||||
AuthRequestServiceAbstraction,
|
|
||||||
} from "../abstractions";
|
|
||||||
import { SsoLoginCredentials } from "../models/domain/login-credentials";
|
import { SsoLoginCredentials } from "../models/domain/login-credentials";
|
||||||
import { CacheData } from "../services/login-strategies/login-strategy.state";
|
import { CacheData } from "../services/login-strategies/login-strategy.state";
|
||||||
|
|
||||||
@@ -84,43 +67,13 @@ export class SsoLoginStrategy extends LoginStrategy {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
data: SsoLoginStrategyData,
|
data: SsoLoginStrategyData,
|
||||||
accountService: AccountService,
|
|
||||||
masterPasswordService: InternalMasterPasswordServiceAbstraction,
|
|
||||||
cryptoService: CryptoService,
|
|
||||||
apiService: ApiService,
|
|
||||||
tokenService: TokenService,
|
|
||||||
appIdService: AppIdService,
|
|
||||||
platformUtilsService: PlatformUtilsService,
|
|
||||||
messagingService: MessagingService,
|
|
||||||
logService: LogService,
|
|
||||||
stateService: StateService,
|
|
||||||
twoFactorService: TwoFactorService,
|
|
||||||
userDecryptionOptionsService: InternalUserDecryptionOptionsServiceAbstraction,
|
|
||||||
private keyConnectorService: KeyConnectorService,
|
private keyConnectorService: KeyConnectorService,
|
||||||
private deviceTrustService: DeviceTrustServiceAbstraction,
|
private deviceTrustService: DeviceTrustServiceAbstraction,
|
||||||
private authRequestService: AuthRequestServiceAbstraction,
|
private authRequestService: AuthRequestServiceAbstraction,
|
||||||
private i18nService: I18nService,
|
private i18nService: I18nService,
|
||||||
billingAccountProfileStateService: BillingAccountProfileStateService,
|
...sharedDeps: ConstructorParameters<typeof LoginStrategy>
|
||||||
vaultTimeoutSettingsService: VaultTimeoutSettingsService,
|
|
||||||
kdfConfigService: KdfConfigService,
|
|
||||||
) {
|
) {
|
||||||
super(
|
super(...sharedDeps);
|
||||||
accountService,
|
|
||||||
masterPasswordService,
|
|
||||||
cryptoService,
|
|
||||||
apiService,
|
|
||||||
tokenService,
|
|
||||||
appIdService,
|
|
||||||
platformUtilsService,
|
|
||||||
messagingService,
|
|
||||||
logService,
|
|
||||||
stateService,
|
|
||||||
twoFactorService,
|
|
||||||
userDecryptionOptionsService,
|
|
||||||
billingAccountProfileStateService,
|
|
||||||
vaultTimeoutSettingsService,
|
|
||||||
kdfConfigService,
|
|
||||||
);
|
|
||||||
|
|
||||||
this.cache = new BehaviorSubject(data);
|
this.cache = new BehaviorSubject(data);
|
||||||
this.email$ = this.cache.pipe(map((state) => state.email));
|
this.email$ = this.cache.pipe(map((state) => state.email));
|
||||||
|
|||||||
@@ -94,6 +94,8 @@ describe("UserApiLoginStrategy", () => {
|
|||||||
|
|
||||||
apiLogInStrategy = new UserApiLoginStrategy(
|
apiLogInStrategy = new UserApiLoginStrategy(
|
||||||
cache,
|
cache,
|
||||||
|
environmentService,
|
||||||
|
keyConnectorService,
|
||||||
accountService,
|
accountService,
|
||||||
masterPasswordService,
|
masterPasswordService,
|
||||||
cryptoService,
|
cryptoService,
|
||||||
@@ -106,8 +108,6 @@ describe("UserApiLoginStrategy", () => {
|
|||||||
stateService,
|
stateService,
|
||||||
twoFactorService,
|
twoFactorService,
|
||||||
userDecryptionOptionsService,
|
userDecryptionOptionsService,
|
||||||
environmentService,
|
|
||||||
keyConnectorService,
|
|
||||||
billingAccountProfileStateService,
|
billingAccountProfileStateService,
|
||||||
vaultTimeoutSettingsService,
|
vaultTimeoutSettingsService,
|
||||||
kdfConfigService,
|
kdfConfigService,
|
||||||
|
|||||||
@@ -1,28 +1,13 @@
|
|||||||
import { firstValueFrom, BehaviorSubject } from "rxjs";
|
import { firstValueFrom, BehaviorSubject } from "rxjs";
|
||||||
import { Jsonify } from "type-fest";
|
import { Jsonify } from "type-fest";
|
||||||
|
|
||||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
|
||||||
import { VaultTimeoutSettingsService } from "@bitwarden/common/abstractions/vault-timeout/vault-timeout-settings.service";
|
|
||||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
|
||||||
import { KdfConfigService } from "@bitwarden/common/auth/abstractions/kdf-config.service";
|
|
||||||
import { KeyConnectorService } from "@bitwarden/common/auth/abstractions/key-connector.service";
|
import { KeyConnectorService } from "@bitwarden/common/auth/abstractions/key-connector.service";
|
||||||
import { InternalMasterPasswordServiceAbstraction } from "@bitwarden/common/auth/abstractions/master-password.service.abstraction";
|
|
||||||
import { TokenService } from "@bitwarden/common/auth/abstractions/token.service";
|
|
||||||
import { TwoFactorService } from "@bitwarden/common/auth/abstractions/two-factor.service";
|
|
||||||
import { UserApiTokenRequest } from "@bitwarden/common/auth/models/request/identity-token/user-api-token.request";
|
import { UserApiTokenRequest } from "@bitwarden/common/auth/models/request/identity-token/user-api-token.request";
|
||||||
import { IdentityTokenResponse } from "@bitwarden/common/auth/models/response/identity-token.response";
|
import { IdentityTokenResponse } from "@bitwarden/common/auth/models/response/identity-token.response";
|
||||||
import { BillingAccountProfileStateService } from "@bitwarden/common/billing/abstractions/account/billing-account-profile-state.service";
|
|
||||||
import { VaultTimeoutAction } from "@bitwarden/common/enums/vault-timeout-action.enum";
|
import { VaultTimeoutAction } from "@bitwarden/common/enums/vault-timeout-action.enum";
|
||||||
import { AppIdService } from "@bitwarden/common/platform/abstractions/app-id.service";
|
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
|
import { EnvironmentService } from "@bitwarden/common/platform/abstractions/environment.service";
|
||||||
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
|
||||||
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
|
||||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
|
||||||
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
|
|
||||||
import { UserId } from "@bitwarden/common/types/guid";
|
import { UserId } from "@bitwarden/common/types/guid";
|
||||||
|
|
||||||
import { InternalUserDecryptionOptionsServiceAbstraction } from "../abstractions/user-decryption-options.service.abstraction";
|
|
||||||
import { UserApiLoginCredentials } from "../models/domain/login-credentials";
|
import { UserApiLoginCredentials } from "../models/domain/login-credentials";
|
||||||
import { CacheData } from "../services/login-strategies/login-strategy.state";
|
import { CacheData } from "../services/login-strategies/login-strategy.state";
|
||||||
|
|
||||||
@@ -44,41 +29,12 @@ export class UserApiLoginStrategy extends LoginStrategy {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
data: UserApiLoginStrategyData,
|
data: UserApiLoginStrategyData,
|
||||||
accountService: AccountService,
|
|
||||||
masterPasswordService: InternalMasterPasswordServiceAbstraction,
|
|
||||||
cryptoService: CryptoService,
|
|
||||||
apiService: ApiService,
|
|
||||||
tokenService: TokenService,
|
|
||||||
appIdService: AppIdService,
|
|
||||||
platformUtilsService: PlatformUtilsService,
|
|
||||||
messagingService: MessagingService,
|
|
||||||
logService: LogService,
|
|
||||||
stateService: StateService,
|
|
||||||
twoFactorService: TwoFactorService,
|
|
||||||
userDecryptionOptionsService: InternalUserDecryptionOptionsServiceAbstraction,
|
|
||||||
private environmentService: EnvironmentService,
|
private environmentService: EnvironmentService,
|
||||||
private keyConnectorService: KeyConnectorService,
|
private keyConnectorService: KeyConnectorService,
|
||||||
billingAccountProfileStateService: BillingAccountProfileStateService,
|
...sharedDeps: ConstructorParameters<typeof LoginStrategy>
|
||||||
vaultTimeoutSettingsService: VaultTimeoutSettingsService,
|
|
||||||
protected kdfConfigService: KdfConfigService,
|
|
||||||
) {
|
) {
|
||||||
super(
|
super(...sharedDeps);
|
||||||
accountService,
|
|
||||||
masterPasswordService,
|
|
||||||
cryptoService,
|
|
||||||
apiService,
|
|
||||||
tokenService,
|
|
||||||
appIdService,
|
|
||||||
platformUtilsService,
|
|
||||||
messagingService,
|
|
||||||
logService,
|
|
||||||
stateService,
|
|
||||||
twoFactorService,
|
|
||||||
userDecryptionOptionsService,
|
|
||||||
billingAccountProfileStateService,
|
|
||||||
vaultTimeoutSettingsService,
|
|
||||||
kdfConfigService,
|
|
||||||
);
|
|
||||||
this.cache = new BehaviorSubject(data);
|
this.cache = new BehaviorSubject(data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,28 +1,13 @@
|
|||||||
import { BehaviorSubject } from "rxjs";
|
import { BehaviorSubject } from "rxjs";
|
||||||
import { Jsonify } from "type-fest";
|
import { Jsonify } from "type-fest";
|
||||||
|
|
||||||
import { ApiService } from "@bitwarden/common/abstractions/api.service";
|
|
||||||
import { VaultTimeoutSettingsService } from "@bitwarden/common/abstractions/vault-timeout/vault-timeout-settings.service";
|
|
||||||
import { AccountService } from "@bitwarden/common/auth/abstractions/account.service";
|
|
||||||
import { KdfConfigService } from "@bitwarden/common/auth/abstractions/kdf-config.service";
|
|
||||||
import { InternalMasterPasswordServiceAbstraction } from "@bitwarden/common/auth/abstractions/master-password.service.abstraction";
|
|
||||||
import { TokenService } from "@bitwarden/common/auth/abstractions/token.service";
|
|
||||||
import { TwoFactorService } from "@bitwarden/common/auth/abstractions/two-factor.service";
|
|
||||||
import { AuthResult } from "@bitwarden/common/auth/models/domain/auth-result";
|
import { AuthResult } from "@bitwarden/common/auth/models/domain/auth-result";
|
||||||
import { WebAuthnLoginTokenRequest } from "@bitwarden/common/auth/models/request/identity-token/webauthn-login-token.request";
|
import { WebAuthnLoginTokenRequest } from "@bitwarden/common/auth/models/request/identity-token/webauthn-login-token.request";
|
||||||
import { IdentityTokenResponse } from "@bitwarden/common/auth/models/response/identity-token.response";
|
import { IdentityTokenResponse } from "@bitwarden/common/auth/models/response/identity-token.response";
|
||||||
import { BillingAccountProfileStateService } from "@bitwarden/common/billing/abstractions/account/billing-account-profile-state.service";
|
|
||||||
import { AppIdService } from "@bitwarden/common/platform/abstractions/app-id.service";
|
|
||||||
import { CryptoService } from "@bitwarden/common/platform/abstractions/crypto.service";
|
|
||||||
import { LogService } from "@bitwarden/common/platform/abstractions/log.service";
|
|
||||||
import { MessagingService } from "@bitwarden/common/platform/abstractions/messaging.service";
|
|
||||||
import { PlatformUtilsService } from "@bitwarden/common/platform/abstractions/platform-utils.service";
|
|
||||||
import { StateService } from "@bitwarden/common/platform/abstractions/state.service";
|
|
||||||
import { SymmetricCryptoKey } from "@bitwarden/common/platform/models/domain/symmetric-crypto-key";
|
import { SymmetricCryptoKey } from "@bitwarden/common/platform/models/domain/symmetric-crypto-key";
|
||||||
import { UserId } from "@bitwarden/common/types/guid";
|
import { UserId } from "@bitwarden/common/types/guid";
|
||||||
import { UserKey } from "@bitwarden/common/types/key";
|
import { UserKey } from "@bitwarden/common/types/key";
|
||||||
|
|
||||||
import { InternalUserDecryptionOptionsServiceAbstraction } from "../abstractions";
|
|
||||||
import { WebAuthnLoginCredentials } from "../models/domain/login-credentials";
|
import { WebAuthnLoginCredentials } from "../models/domain/login-credentials";
|
||||||
import { CacheData } from "../services/login-strategies/login-strategy.state";
|
import { CacheData } from "../services/login-strategies/login-strategy.state";
|
||||||
|
|
||||||
@@ -46,39 +31,9 @@ export class WebAuthnLoginStrategy extends LoginStrategy {
|
|||||||
|
|
||||||
constructor(
|
constructor(
|
||||||
data: WebAuthnLoginStrategyData,
|
data: WebAuthnLoginStrategyData,
|
||||||
accountService: AccountService,
|
...sharedDeps: ConstructorParameters<typeof LoginStrategy>
|
||||||
masterPasswordService: InternalMasterPasswordServiceAbstraction,
|
|
||||||
cryptoService: CryptoService,
|
|
||||||
apiService: ApiService,
|
|
||||||
tokenService: TokenService,
|
|
||||||
appIdService: AppIdService,
|
|
||||||
platformUtilsService: PlatformUtilsService,
|
|
||||||
messagingService: MessagingService,
|
|
||||||
logService: LogService,
|
|
||||||
stateService: StateService,
|
|
||||||
twoFactorService: TwoFactorService,
|
|
||||||
userDecryptionOptionsService: InternalUserDecryptionOptionsServiceAbstraction,
|
|
||||||
billingAccountProfileStateService: BillingAccountProfileStateService,
|
|
||||||
vaultTimeoutSettingsService: VaultTimeoutSettingsService,
|
|
||||||
kdfConfigService: KdfConfigService,
|
|
||||||
) {
|
) {
|
||||||
super(
|
super(...sharedDeps);
|
||||||
accountService,
|
|
||||||
masterPasswordService,
|
|
||||||
cryptoService,
|
|
||||||
apiService,
|
|
||||||
tokenService,
|
|
||||||
appIdService,
|
|
||||||
platformUtilsService,
|
|
||||||
messagingService,
|
|
||||||
logService,
|
|
||||||
stateService,
|
|
||||||
twoFactorService,
|
|
||||||
userDecryptionOptionsService,
|
|
||||||
billingAccountProfileStateService,
|
|
||||||
vaultTimeoutSettingsService,
|
|
||||||
kdfConfigService,
|
|
||||||
);
|
|
||||||
|
|
||||||
this.cache = new BehaviorSubject(data);
|
this.cache = new BehaviorSubject(data);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -48,6 +48,7 @@ import { MasterKey } from "@bitwarden/common/types/key";
|
|||||||
import { AuthRequestServiceAbstraction, LoginStrategyServiceAbstraction } from "../../abstractions";
|
import { AuthRequestServiceAbstraction, LoginStrategyServiceAbstraction } from "../../abstractions";
|
||||||
import { InternalUserDecryptionOptionsServiceAbstraction } from "../../abstractions/user-decryption-options.service.abstraction";
|
import { InternalUserDecryptionOptionsServiceAbstraction } from "../../abstractions/user-decryption-options.service.abstraction";
|
||||||
import { AuthRequestLoginStrategy } from "../../login-strategies/auth-request-login.strategy";
|
import { AuthRequestLoginStrategy } from "../../login-strategies/auth-request-login.strategy";
|
||||||
|
import { LoginStrategy } from "../../login-strategies/login.strategy";
|
||||||
import { PasswordLoginStrategy } from "../../login-strategies/password-login.strategy";
|
import { PasswordLoginStrategy } from "../../login-strategies/password-login.strategy";
|
||||||
import { SsoLoginStrategy } from "../../login-strategies/sso-login.strategy";
|
import { SsoLoginStrategy } from "../../login-strategies/sso-login.strategy";
|
||||||
import { UserApiLoginStrategy } from "../../login-strategies/user-api-login.strategy";
|
import { UserApiLoginStrategy } from "../../login-strategies/user-api-login.strategy";
|
||||||
@@ -338,6 +339,24 @@ export class LoginStrategyService implements LoginStrategyServiceAbstraction {
|
|||||||
private initializeLoginStrategy(
|
private initializeLoginStrategy(
|
||||||
source: Observable<[AuthenticationType | null, CacheData | null]>,
|
source: Observable<[AuthenticationType | null, CacheData | null]>,
|
||||||
) {
|
) {
|
||||||
|
const sharedDeps: ConstructorParameters<typeof LoginStrategy> = [
|
||||||
|
this.accountService,
|
||||||
|
this.masterPasswordService,
|
||||||
|
this.cryptoService,
|
||||||
|
this.apiService,
|
||||||
|
this.tokenService,
|
||||||
|
this.appIdService,
|
||||||
|
this.platformUtilsService,
|
||||||
|
this.messagingService,
|
||||||
|
this.logService,
|
||||||
|
this.stateService,
|
||||||
|
this.twoFactorService,
|
||||||
|
this.userDecryptionOptionsService,
|
||||||
|
this.billingAccountProfileStateService,
|
||||||
|
this.vaultTimeoutSettingsService,
|
||||||
|
this.kdfConfigService,
|
||||||
|
];
|
||||||
|
|
||||||
return source.pipe(
|
return source.pipe(
|
||||||
map(([strategy, data]) => {
|
map(([strategy, data]) => {
|
||||||
if (strategy == null) {
|
if (strategy == null) {
|
||||||
@@ -347,108 +366,35 @@ export class LoginStrategyService implements LoginStrategyServiceAbstraction {
|
|||||||
case AuthenticationType.Password:
|
case AuthenticationType.Password:
|
||||||
return new PasswordLoginStrategy(
|
return new PasswordLoginStrategy(
|
||||||
data?.password,
|
data?.password,
|
||||||
this.accountService,
|
|
||||||
this.masterPasswordService,
|
|
||||||
this.cryptoService,
|
|
||||||
this.apiService,
|
|
||||||
this.tokenService,
|
|
||||||
this.appIdService,
|
|
||||||
this.platformUtilsService,
|
|
||||||
this.messagingService,
|
|
||||||
this.logService,
|
|
||||||
this.stateService,
|
|
||||||
this.twoFactorService,
|
|
||||||
this.userDecryptionOptionsService,
|
|
||||||
this.passwordStrengthService,
|
this.passwordStrengthService,
|
||||||
this.policyService,
|
this.policyService,
|
||||||
this,
|
this,
|
||||||
this.billingAccountProfileStateService,
|
...sharedDeps,
|
||||||
this.vaultTimeoutSettingsService,
|
|
||||||
this.kdfConfigService,
|
|
||||||
);
|
);
|
||||||
case AuthenticationType.Sso:
|
case AuthenticationType.Sso:
|
||||||
return new SsoLoginStrategy(
|
return new SsoLoginStrategy(
|
||||||
data?.sso,
|
data?.sso,
|
||||||
this.accountService,
|
|
||||||
this.masterPasswordService,
|
|
||||||
this.cryptoService,
|
|
||||||
this.apiService,
|
|
||||||
this.tokenService,
|
|
||||||
this.appIdService,
|
|
||||||
this.platformUtilsService,
|
|
||||||
this.messagingService,
|
|
||||||
this.logService,
|
|
||||||
this.stateService,
|
|
||||||
this.twoFactorService,
|
|
||||||
this.userDecryptionOptionsService,
|
|
||||||
this.keyConnectorService,
|
this.keyConnectorService,
|
||||||
this.deviceTrustService,
|
this.deviceTrustService,
|
||||||
this.authRequestService,
|
this.authRequestService,
|
||||||
this.i18nService,
|
this.i18nService,
|
||||||
this.billingAccountProfileStateService,
|
...sharedDeps,
|
||||||
this.vaultTimeoutSettingsService,
|
|
||||||
this.kdfConfigService,
|
|
||||||
);
|
);
|
||||||
case AuthenticationType.UserApiKey:
|
case AuthenticationType.UserApiKey:
|
||||||
return new UserApiLoginStrategy(
|
return new UserApiLoginStrategy(
|
||||||
data?.userApiKey,
|
data?.userApiKey,
|
||||||
this.accountService,
|
|
||||||
this.masterPasswordService,
|
|
||||||
this.cryptoService,
|
|
||||||
this.apiService,
|
|
||||||
this.tokenService,
|
|
||||||
this.appIdService,
|
|
||||||
this.platformUtilsService,
|
|
||||||
this.messagingService,
|
|
||||||
this.logService,
|
|
||||||
this.stateService,
|
|
||||||
this.twoFactorService,
|
|
||||||
this.userDecryptionOptionsService,
|
|
||||||
this.environmentService,
|
this.environmentService,
|
||||||
this.keyConnectorService,
|
this.keyConnectorService,
|
||||||
this.billingAccountProfileStateService,
|
...sharedDeps,
|
||||||
this.vaultTimeoutSettingsService,
|
|
||||||
this.kdfConfigService,
|
|
||||||
);
|
);
|
||||||
case AuthenticationType.AuthRequest:
|
case AuthenticationType.AuthRequest:
|
||||||
return new AuthRequestLoginStrategy(
|
return new AuthRequestLoginStrategy(
|
||||||
data?.authRequest,
|
data?.authRequest,
|
||||||
this.accountService,
|
|
||||||
this.masterPasswordService,
|
|
||||||
this.cryptoService,
|
|
||||||
this.apiService,
|
|
||||||
this.tokenService,
|
|
||||||
this.appIdService,
|
|
||||||
this.platformUtilsService,
|
|
||||||
this.messagingService,
|
|
||||||
this.logService,
|
|
||||||
this.stateService,
|
|
||||||
this.twoFactorService,
|
|
||||||
this.userDecryptionOptionsService,
|
|
||||||
this.deviceTrustService,
|
this.deviceTrustService,
|
||||||
this.billingAccountProfileStateService,
|
...sharedDeps,
|
||||||
this.vaultTimeoutSettingsService,
|
|
||||||
this.kdfConfigService,
|
|
||||||
);
|
);
|
||||||
case AuthenticationType.WebAuthn:
|
case AuthenticationType.WebAuthn:
|
||||||
return new WebAuthnLoginStrategy(
|
return new WebAuthnLoginStrategy(data?.webAuthn, ...sharedDeps);
|
||||||
data?.webAuthn,
|
|
||||||
this.accountService,
|
|
||||||
this.masterPasswordService,
|
|
||||||
this.cryptoService,
|
|
||||||
this.apiService,
|
|
||||||
this.tokenService,
|
|
||||||
this.appIdService,
|
|
||||||
this.platformUtilsService,
|
|
||||||
this.messagingService,
|
|
||||||
this.logService,
|
|
||||||
this.stateService,
|
|
||||||
this.twoFactorService,
|
|
||||||
this.userDecryptionOptionsService,
|
|
||||||
this.billingAccountProfileStateService,
|
|
||||||
this.vaultTimeoutSettingsService,
|
|
||||||
this.kdfConfigService,
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
|
|||||||
Reference in New Issue
Block a user