| 1 | <?php |
| 2 | |
| 3 | declare(strict_types=1); |
| 4 | |
| 5 | namespace Webauthn\CeremonyStep; |
| 6 | |
| 7 | use function strlen; |
| 8 | use function trigger_deprecation; |
| 9 | use Webauthn\AuthenticatorAssertionResponse; |
| 10 | use Webauthn\AuthenticatorAttestationResponse; |
| 11 | use Webauthn\CredentialRecord; |
| 12 | use Webauthn\Exception\AuthenticatorResponseVerificationException; |
| 13 | use Webauthn\PublicKeyCredentialCreationOptions; |
| 14 | use Webauthn\PublicKeyCredentialRequestOptions; |
| 15 | use Webauthn\PublicKeyCredentialSource; |
| 16 | |
| 17 | class CheckCredentialId implements CeremonyStep |
| 18 | { |
| 19 | public function process( |
| 20 | CredentialRecord $credentialRecord, |
| 21 | AuthenticatorAssertionResponse|AuthenticatorAttestationResponse $authenticatorResponse, |
| 22 | PublicKeyCredentialRequestOptions|PublicKeyCredentialCreationOptions $publicKeyCredentialOptions, |
| 23 | ?string $userHandle, |
| 24 | string $host |
| 25 | ): void { |
| 26 | if ($credentialRecord instanceof PublicKeyCredentialSource) { |
| 27 | trigger_deprecation( |
| 28 | 'web-auth/webauthn-lib', |
| 29 | '5.3', |
| 30 | 'Passing a PublicKeyCredentialSource to "%s::process()" is deprecated, pass a CredentialRecord instead.', |
| 31 | self::class |
| 32 | ); |
| 33 | } |
| 34 | $credentialId = $credentialRecord->publicKeyCredentialId; |
| 35 | strlen($credentialId) <= 1023 || throw new AuthenticatorResponseVerificationException( |
| 36 | 'Credential ID too long.' |
| 37 | ); |
| 38 | } |
| 39 | } |