Debian Codegraph @

lib/3rdParty/composer/web-auth/webauthn-lib/src/CeremonyStep/CheckChallenge.php

raw symbols SCIP
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 CheckChallenge 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 $publicKeyCredentialOptions->challenge !== '' || throw AuthenticatorResponseVerificationException::create(
34 'Invalid challenge.'
35 );
36 hash_equals(
37 $publicKeyCredentialOptions->challenge,
38 $authenticatorResponse->clientDataJSON->challenge
39 ) || throw AuthenticatorResponseVerificationException::create('Invalid challenge.');
40 }
41 }