| 1 |
<?php |
| 2 |
|
| 3 |
declare(strict_types=1); |
| 4 |
|
| 5 |
namespace Webauthn\CeremonyStep; |
| 6 |
|
| 7 |
use function trigger_deprecation; |
| 8 |
use Webauthn\AuthenticatorAssertionResponse; |
| 9 |
use Webauthn\AuthenticatorAttestationResponse; |
| 10 |
use Webauthn\CredentialRecord; |
| 11 |
use Webauthn\Exception\AuthenticatorResponseVerificationException; |
| 12 |
use Webauthn\PublicKeyCredentialCreationOptions; |
| 13 |
use Webauthn\PublicKeyCredentialRequestOptions; |
| 14 |
use Webauthn\PublicKeyCredentialSource; |
| 15 |
|
| 16 |
final class CheckBackupBitsAreConsistent implements CeremonyStep |
| 17 |
{ |
| 18 |
public function process( |
| 19 |
CredentialRecord $credentialRecord, |
| 20 |
AuthenticatorAssertionResponse|AuthenticatorAttestationResponse $authenticatorResponse, |
| 21 |
PublicKeyCredentialRequestOptions|PublicKeyCredentialCreationOptions $publicKeyCredentialOptions, |
| 22 |
?string $userHandle, |
| 23 |
string $host |
| 24 |
): void { |
| 25 |
if ($credentialRecord instanceof PublicKeyCredentialSource) { |
| 26 |
trigger_deprecation( |
| 27 |
'web-auth/webauthn-lib', |
| 28 |
'5.3', |
| 29 |
'Passing a PublicKeyCredentialSource to "%s::process()" is deprecated, pass a CredentialRecord instead.', |
| 30 |
self::class |
| 31 |
); |
| 32 |
} |
| 33 |
$authData = $authenticatorResponse instanceof AuthenticatorAssertionResponse ? $authenticatorResponse->authenticatorData : $authenticatorResponse->attestationObject->authData; |
| 34 |
if ($authData->isBackupEligible()) { |
| 35 |
return; |
| 36 |
} |
| 37 |
$authData->isBackedUp() !== true || throw AuthenticatorResponseVerificationException::create( |
| 38 |
'Backup up bit is set but the backup is not eligible.' |
| 39 |
); |
| 40 |
} |
| 41 |
} |