Debian Codegraph @

lib/3rdParty/composer/web-auth/webauthn-lib/src/CeremonyStep/CheckExtensions.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\AuthenticationExtensions\ExtensionOutputCheckerHandler;
9 use Webauthn\AuthenticatorAssertionResponse;
10 use Webauthn\AuthenticatorAttestationResponse;
11 use Webauthn\CredentialRecord;
12 use Webauthn\PublicKeyCredentialCreationOptions;
13 use Webauthn\PublicKeyCredentialRequestOptions;
14 use Webauthn\PublicKeyCredentialSource;
15
16 final readonly class CheckExtensions implements CeremonyStep
17 {
18 public function __construct(
19 private ExtensionOutputCheckerHandler $extensionOutputCheckerHandler,
20 ) {
21 }
22
23 public function process(
24 CredentialRecord $credentialRecord,
25 AuthenticatorAssertionResponse|AuthenticatorAttestationResponse $authenticatorResponse,
26 PublicKeyCredentialRequestOptions|PublicKeyCredentialCreationOptions $publicKeyCredentialOptions,
27 ?string $userHandle,
28 string $host
29 ): void {
30 if ($credentialRecord instanceof PublicKeyCredentialSource) {
31 trigger_deprecation(
32 'web-auth/webauthn-lib',
33 '5.3',
34 'Passing a PublicKeyCredentialSource to "%s::process()" is deprecated, pass a CredentialRecord instead.',
35 self::class
36 );
37 }
38 $authData = $authenticatorResponse instanceof AuthenticatorAssertionResponse ? $authenticatorResponse->authenticatorData : $authenticatorResponse->attestationObject->authData;
39 $extensionsClientOutputs = $authData->extensions;
40 if ($extensionsClientOutputs !== null) {
41 $this->extensionOutputCheckerHandler->check(
42 $publicKeyCredentialOptions->extensions,
43 $extensionsClientOutputs
44 );
45 }
46 }
47 }