<?php

declare (strict_types=1);
namespace GuardDog\Vendor\Webauthn\ClientDataCollector;

use GuardDog\Vendor\Webauthn\AuthenticatorResponse;
use GuardDog\Vendor\Webauthn\CollectedClientData;
use GuardDog\Vendor\Webauthn\Exception\AuthenticatorResponseVerificationException;
use GuardDog\Vendor\Webauthn\PublicKeyCredentialOptions;
use function in_array;
use function sprintf;
final class WebauthnAuthenticationCollector implements ClientDataCollector
{
    public function supportedTypes(): array
    {
        return ['webauthn.get', 'webauthn.create'];
    }
    public function verifyCollectedClientData(CollectedClientData $collectedClientData, PublicKeyCredentialOptions $publicKeyCredentialOptions, AuthenticatorResponse $authenticatorResponse, string $host): void
    {
        in_array($collectedClientData->type, $this->supportedTypes(), \true) || throw AuthenticatorResponseVerificationException::create(sprintf('The client data type is not "%s" supported.', implode('", "', $this->supportedTypes())));
    }
}
