1
0
mirror of https://github.com/bitwarden/browser synced 2025-12-06 00:13:28 +00:00

feat(two-factor-api-service) [PM-26465]: (Refactor) Two-Factor API Service (#16747)

* feat(two-factor-api-service) [PM-26465]: Add TwoFactorApiServiceAbstraction.

* feat(two-factor-api-service) [PM-26465]: Add TwoFactorApiService implementation.

* feat(two-factor-api-service) [PM-26465]: Add test suite for TwoFactorApiService.

* feat(two-factor-api-service) [PM-26465]: Replace ApiService dependencies with TwoFactorApiService for all refactored methods.

* feat(two-factor-api-service) [PM-26465]: Finish removal of Two-Factor API methods from ApiService.

* fix(two-factor-api-service) [PM-26465]: Correct endpoint spelling.

* feat(two-factor-api-service) [PM-26465]: Update dependency support for CLI.

* fix(two-factor-api-service) [PM-26465]: Update tests/deps for corrected spelling.

* feat(two-factor-api-service) [PM-26465]: Add TwoFactorApiService to Browser services module.

* fix(two-factor-api-service) [PM-26465]: Re-spell dependencies to take *Abstraction throughout, move to JslibServices module for cleaner importing across clients.

* feat(two-factor-api-service) [PM-26465]: Move new services to a feature area, rename abstract and concrete/default.

* feat(two-factor-api-service) [PM-26465]: Move the feature area to common/auth, not auth/common.

* feat(two-factor-api-service) [PM-26465]: Remove now-unneeded include from auth/tsconfig.
This commit is contained in:
Dave
2025-10-13 12:48:25 -04:00
committed by GitHub
parent 2c08af2b42
commit 886003ba88
25 changed files with 1344 additions and 383 deletions

View File

@@ -14,7 +14,6 @@ import {
SsoUrlService,
UserApiLoginCredentials,
} from "@bitwarden/auth/common";
import { ApiService } from "@bitwarden/common/abstractions/api.service";
import { OrganizationService } from "@bitwarden/common/admin-console/abstractions/organization/organization.service.abstraction";
import { PolicyApiServiceAbstraction } from "@bitwarden/common/admin-console/abstractions/policy/policy-api.service.abstraction";
import { PolicyService } from "@bitwarden/common/admin-console/abstractions/policy/policy.service.abstraction";
@@ -29,6 +28,7 @@ import { TokenTwoFactorRequest } from "@bitwarden/common/auth/models/request/ide
import { PasswordRequest } from "@bitwarden/common/auth/models/request/password.request";
import { TwoFactorEmailRequest } from "@bitwarden/common/auth/models/request/two-factor-email.request";
import { UpdateTempPasswordRequest } from "@bitwarden/common/auth/models/request/update-temp-password.request";
import { TwoFactorApiService } from "@bitwarden/common/auth/two-factor";
import { ClientType } from "@bitwarden/common/enums";
import { CryptoFunctionService } from "@bitwarden/common/key-management/crypto/abstractions/crypto-function.service";
import { EncString } from "@bitwarden/common/key-management/crypto/models/enc-string";
@@ -62,7 +62,7 @@ export class LoginCommand {
constructor(
protected loginStrategyService: LoginStrategyServiceAbstraction,
protected authService: AuthService,
protected apiService: ApiService,
protected twoFactorApiService: TwoFactorApiService,
protected masterPasswordApiService: MasterPasswordApiService,
protected cryptoFunctionService: CryptoFunctionService,
protected environmentService: EnvironmentService,
@@ -279,7 +279,7 @@ export class LoginCommand {
const emailReq = new TwoFactorEmailRequest();
emailReq.email = await this.loginStrategyService.getEmail();
emailReq.masterPasswordHash = await this.loginStrategyService.getMasterPasswordHash();
await this.apiService.postTwoFactorEmail(emailReq);
await this.twoFactorApiService.postTwoFactorEmail(emailReq);
}
if (twoFactorToken == null) {

View File

@@ -175,7 +175,7 @@ export class Program extends BaseProgram {
const command = new LoginCommand(
this.serviceContainer.loginStrategyService,
this.serviceContainer.authService,
this.serviceContainer.apiService,
this.serviceContainer.twoFactorApiService,
this.serviceContainer.masterPasswordApiService,
this.serviceContainer.cryptoFunctionService,
this.serviceContainer.environmentService,

View File

@@ -49,6 +49,7 @@ import { TokenService } from "@bitwarden/common/auth/services/token.service";
import { TwoFactorService } from "@bitwarden/common/auth/services/two-factor.service";
import { UserVerificationApiService } from "@bitwarden/common/auth/services/user-verification/user-verification-api.service";
import { UserVerificationService } from "@bitwarden/common/auth/services/user-verification/user-verification.service";
import { TwoFactorApiService, DefaultTwoFactorApiService } from "@bitwarden/common/auth/two-factor";
import {
AutofillSettingsService,
AutofillSettingsServiceAbstraction,
@@ -228,6 +229,7 @@ export class ServiceContainer {
tokenService: TokenService;
appIdService: AppIdService;
apiService: NodeApiService;
twoFactorApiService: TwoFactorApiService;
hibpApiService: HibpApiService;
environmentService: EnvironmentService;
cipherService: CipherService;
@@ -528,6 +530,8 @@ export class ServiceContainer {
this.configApiService = new ConfigApiService(this.apiService);
this.twoFactorApiService = new DefaultTwoFactorApiService(this.apiService);
this.authService = new AuthService(
this.accountService,
this.messagingService,