Authenticator Counter
<?php
declare(strict_types=1);
namespace App\Service;
use App\SecuritySystem;
use Throwable;
use Webauthn\Counter\CounterChecker;
use Webauthn\CredentialRecord;
final class CustomCounterChecker implements CounterChecker
{
public function __construct(private SecuritySystem $securitySystem)
{
}
public function check(CredentialRecord $credentialRecord, int $currentCounter): void
{
try {
assert($currentCounter > $credentialRecord->counter, 'Invalid counter.');
} catch (Throwable $throwable) {
$this->securitySystem->fakeDeviceDetected($credentialRecord);
throw $throwable;
}
}
}Last updated
Was this helpful?