mirror of
https://github.com/bitwarden/browser
synced 2025-12-17 08:43:33 +00:00
[PM-25417] DIRT API Service Refactor (ADR-0005) (#16353)
* encode username for uri and add spec * verify response from getHibpBreach method * test/validate for BreachAccountResponse type and length instead of mock response * - extract dirt api method out of global api service - create new directory structure - change imports accordingly - extract breach account response - put extracted code into new dirt dir * codeowners and dep injection for new hibp service
This commit is contained in:
@@ -3,8 +3,9 @@ import { mergeMap } from "rxjs/operators";
|
||||
|
||||
import { ApiService } from "../abstractions/api.service";
|
||||
import { AuditService as AuditServiceAbstraction } from "../abstractions/audit.service";
|
||||
import { BreachAccountResponse } from "../dirt/models/response/breach-account.response";
|
||||
import { HibpApiService } from "../dirt/services/hibp-api.service";
|
||||
import { CryptoFunctionService } from "../key-management/crypto/abstractions/crypto-function.service";
|
||||
import { BreachAccountResponse } from "../models/response/breach-account.response";
|
||||
import { ErrorResponse } from "../models/response/error.response";
|
||||
import { Utils } from "../platform/misc/utils";
|
||||
|
||||
@@ -20,6 +21,7 @@ export class AuditService implements AuditServiceAbstraction {
|
||||
constructor(
|
||||
private cryptoFunctionService: CryptoFunctionService,
|
||||
private apiService: ApiService,
|
||||
private hibpApiService: HibpApiService,
|
||||
private readonly maxConcurrent: number = 100, // default to 100, can be overridden
|
||||
) {
|
||||
this.maxConcurrent = maxConcurrent;
|
||||
@@ -69,7 +71,7 @@ export class AuditService implements AuditServiceAbstraction {
|
||||
|
||||
async breachedAccounts(username: string): Promise<BreachAccountResponse[]> {
|
||||
try {
|
||||
return await this.apiService.getHibpBreach(username);
|
||||
return await this.hibpApiService.getHibpBreach(username);
|
||||
} catch (e) {
|
||||
const error = e as ErrorResponse;
|
||||
if (error.statusCode === 404) {
|
||||
|
||||
Reference in New Issue
Block a user