mirror of
https://github.com/bitwarden/browser
synced 2025-12-13 23:03:32 +00:00
Throttle calls to HIBP api (#25)
Randomly failing to check by passwords, I'm pretty sure its because ~2000 connections are made at the same time.
This commit is contained in:
@@ -2,6 +2,7 @@ import { ApiService } from '../abstractions/api.service';
|
||||
import { AuditService as AuditServiceAbstraction } from '../abstractions/audit.service';
|
||||
import { CryptoFunctionService } from '../abstractions/cryptoFunction.service';
|
||||
|
||||
import { throttle } from '../misc/throttle';
|
||||
import { Utils } from '../misc/utils';
|
||||
|
||||
import { BreachAccountResponse } from '../models/response/breachAccountResponse';
|
||||
@@ -12,6 +13,7 @@ const PwnedPasswordsApi = 'https://api.pwnedpasswords.com/range/';
|
||||
export class AuditService implements AuditServiceAbstraction {
|
||||
constructor(private cryptoFunctionService: CryptoFunctionService, private apiService: ApiService) { }
|
||||
|
||||
@throttle(100, () => 'passwordLeaked')
|
||||
async passwordLeaked(password: string): Promise<number> {
|
||||
const hashBytes = await this.cryptoFunctionService.hash(password, 'sha1');
|
||||
const hash = Utils.fromBufferToHex(hashBytes).toUpperCase();
|
||||
|
||||
Reference in New Issue
Block a user