Skip to content

Commit

Permalink
Bug fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
Spomky committed Jun 12, 2023
1 parent f5b7086 commit 8d3f80b
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 10 deletions.
5 changes: 0 additions & 5 deletions phpstan-baseline.neon
Original file line number Diff line number Diff line change
Expand Up @@ -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\\<int\\|string, mixed\\>, array given\\.$#"
count: 1
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,14 +9,15 @@
use Webauthn\AuthenticatorAssertionResponse;
use Webauthn\Event\AuthenticatorAssertionResponseValidationFailedEvent as BaseAuthenticatorAssertionResponseValidationFailedEvent;
use Webauthn\PublicKeyCredentialRequestOptions;
use Webauthn\PublicKeyCredentialSource;

/**
* @final
*/
class AuthenticatorAssertionResponseValidationFailedEvent extends BaseAuthenticatorAssertionResponseValidationFailedEvent
{
public function __construct(
string $credentialId,
string|PublicKeyCredentialSource $credentialId,
AuthenticatorAssertionResponse $authenticatorAssertionResponse,
PublicKeyCredentialRequestOptions $publicKeyCredentialRequestOptions,
ServerRequestInterface|string $request,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ protected function createAuthenticatorAssertionResponseValidationSucceededEvent(
}

protected function createAuthenticatorAssertionResponseValidationFailedEvent(
string $credentialId,
string|PublicKeyCredentialSource $credentialId,
AuthenticatorAssertionResponse $authenticatorAssertionResponse,
PublicKeyCredentialRequestOptions $publicKeyCredentialRequestOptions,
ServerRequestInterface|string $request,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ protected function createAuthenticatorAssertionResponseValidationSucceededEvent(
}

protected function createAuthenticatorAssertionResponseValidationFailedEvent(
string $credentialId,
string|PublicKeyCredentialSource $credentialId,
AuthenticatorAssertionResponse $authenticatorAssertionResponse,
PublicKeyCredentialRequestOptions $publicKeyCredentialRequestOptions,
ServerRequestInterface|string $request,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
Expand Down

0 comments on commit 8d3f80b

Please sign in to comment.