diff --git a/phpstan-baseline.neon b/phpstan-baseline.neon index 2278e957..3c10d4ff 100644 --- a/phpstan-baseline.neon +++ b/phpstan-baseline.neon @@ -1755,11 +1755,6 @@ parameters: count: 2 path: src/webauthn/src/AuthenticatorAssertionResponseValidator.php - - - message: "#^Parameter \\#1 \\$credentialId of method Webauthn\\\\AuthenticatorAssertionResponseValidator\\:\\:createAuthenticatorAssertionResponseValidationFailedEvent\\(\\) expects string, string\\|Webauthn\\\\PublicKeyCredentialSource given\\.$#" - count: 1 - path: src/webauthn/src/AuthenticatorAssertionResponseValidator.php - - message: "#^Parameter \\#1 \\$data of static method Cose\\\\Key\\\\Key\\:\\:create\\(\\) expects array\\, array given\\.$#" count: 1 diff --git a/src/symfony/src/Event/AuthenticatorAssertionResponseValidationFailedEvent.php b/src/symfony/src/Event/AuthenticatorAssertionResponseValidationFailedEvent.php index 51b455ff..c0ce4110 100644 --- a/src/symfony/src/Event/AuthenticatorAssertionResponseValidationFailedEvent.php +++ b/src/symfony/src/Event/AuthenticatorAssertionResponseValidationFailedEvent.php @@ -9,6 +9,7 @@ use Webauthn\AuthenticatorAssertionResponse; use Webauthn\Event\AuthenticatorAssertionResponseValidationFailedEvent as BaseAuthenticatorAssertionResponseValidationFailedEvent; use Webauthn\PublicKeyCredentialRequestOptions; +use Webauthn\PublicKeyCredentialSource; /** * @final @@ -16,7 +17,7 @@ class AuthenticatorAssertionResponseValidationFailedEvent extends BaseAuthenticatorAssertionResponseValidationFailedEvent { public function __construct( - string $credentialId, + string|PublicKeyCredentialSource $credentialId, AuthenticatorAssertionResponse $authenticatorAssertionResponse, PublicKeyCredentialRequestOptions $publicKeyCredentialRequestOptions, ServerRequestInterface|string $request, diff --git a/src/symfony/src/Service/AuthenticatorAssertionResponseValidator.php b/src/symfony/src/Service/AuthenticatorAssertionResponseValidator.php index 3a22e788..8a2a3d6d 100644 --- a/src/symfony/src/Service/AuthenticatorAssertionResponseValidator.php +++ b/src/symfony/src/Service/AuthenticatorAssertionResponseValidator.php @@ -56,7 +56,7 @@ protected function createAuthenticatorAssertionResponseValidationSucceededEvent( } protected function createAuthenticatorAssertionResponseValidationFailedEvent( - string $credentialId, + string|PublicKeyCredentialSource $credentialId, AuthenticatorAssertionResponse $authenticatorAssertionResponse, PublicKeyCredentialRequestOptions $publicKeyCredentialRequestOptions, ServerRequestInterface|string $request, diff --git a/src/webauthn/src/AuthenticatorAssertionResponseValidator.php b/src/webauthn/src/AuthenticatorAssertionResponseValidator.php index 21c35495..ff143b05 100644 --- a/src/webauthn/src/AuthenticatorAssertionResponseValidator.php +++ b/src/webauthn/src/AuthenticatorAssertionResponseValidator.php @@ -363,7 +363,7 @@ protected function createAuthenticatorAssertionResponseValidationSucceededEvent( } protected function createAuthenticatorAssertionResponseValidationFailedEvent( - string $credentialId, + string|PublicKeyCredentialSource $credentialId, AuthenticatorAssertionResponse $authenticatorAssertionResponse, PublicKeyCredentialRequestOptions $publicKeyCredentialRequestOptions, ServerRequestInterface|string $request, diff --git a/src/webauthn/src/Event/AuthenticatorAssertionResponseValidationFailedEvent.php b/src/webauthn/src/Event/AuthenticatorAssertionResponseValidationFailedEvent.php index 72957bc1..c6e6d323 100644 --- a/src/webauthn/src/Event/AuthenticatorAssertionResponseValidationFailedEvent.php +++ b/src/webauthn/src/Event/AuthenticatorAssertionResponseValidationFailedEvent.php @@ -8,11 +8,12 @@ use Throwable; use Webauthn\AuthenticatorAssertionResponse; use Webauthn\PublicKeyCredentialRequestOptions; +use Webauthn\PublicKeyCredentialSource; class AuthenticatorAssertionResponseValidationFailedEvent { public function __construct( - private readonly string $credentialId, + private readonly string|PublicKeyCredentialSource $credentialId, private readonly AuthenticatorAssertionResponse $authenticatorAssertionResponse, private readonly PublicKeyCredentialRequestOptions $publicKeyCredentialRequestOptions, public readonly ServerRequestInterface|string $host, @@ -30,11 +31,23 @@ public function __construct( ) ); } + if (! $this->credentialId instanceof PublicKeyCredentialSource) { + trigger_deprecation( + 'web-auth/webauthn-lib', + '4.6.0', + 'Passing a string for the argument "$credentialId" is deprecated since 4.6.0. Please set the PublicKeyCredentialSource instead.' + ); + } } public function getCredentialId(): string { - return $this->credentialId; + return $this->credentialId instanceof PublicKeyCredentialSource ? $this->credentialId->getPublicKeyCredentialId() : $this->credentialId; + } + + public function getCredential(): ?PublicKeyCredentialSource + { + return $this->credentialId instanceof PublicKeyCredentialSource ? $this->credentialId : null; } public function getAuthenticatorAssertionResponse(): AuthenticatorAssertionResponse