diff --git a/src/webauthn/src/PublicKeyCredentialLoader.php b/src/webauthn/src/PublicKeyCredentialLoader.php index f5e3bf87..f745e26b 100644 --- a/src/webauthn/src/PublicKeyCredentialLoader.php +++ b/src/webauthn/src/PublicKeyCredentialLoader.php @@ -119,7 +119,7 @@ public function load(string $data): PublicKeyCredential $this->logger->error('An error occurred', [ 'exception' => $throwable, ]); - throw $throwable; + throw InvalidDataException::create($data, 'Unable to load the data', $throwable); } } diff --git a/tests/library/Functional/AttestationTest.php b/tests/library/Functional/AttestationTest.php index f7be5871..e77e691b 100644 --- a/tests/library/Functional/AttestationTest.php +++ b/tests/library/Functional/AttestationTest.php @@ -5,10 +5,10 @@ namespace Webauthn\Tests\Functional; use ParagonIE\ConstantTime\Base64UrlSafe; -use RangeException; use Webauthn\AttestedCredentialData; use Webauthn\AuthenticatorAttestationResponse; use Webauthn\AuthenticatorData; +use Webauthn\Exception\InvalidDataException; use Webauthn\PublicKeyCredentialCreationOptions; use Webauthn\PublicKeyCredentialDescriptor; use Webauthn\Tests\MemoryPublicKeyCredentialSourceRepository; @@ -23,8 +23,8 @@ final class AttestationTest extends AbstractTestCase */ public function aResponseCannotBeLoaded(): void { - static::expectException(RangeException::class); - static::expectExceptionMessage('Incorrect padding'); + static::expectException(InvalidDataException::class); + static::expectExceptionMessage('Unable to load the data'); $response = '{"id":"wHU13DaUWRqIQq94SAfCG8jqUZGdW0N95hnchI3rG7s===","rawId":"wHU13DaUWRqIQq94SAfCG8jqUZGdW0N95hnchI3rG7s","response":{"authenticatorData":"lgTqgoJOmKStoUtEYtDXOo7EaRMNqRsZMHRZIp90o1kBAAAAag","signature":"MEYCIQD4faYQG08_xpmAxFwp33OObSPavG7iUCJimHhH2QwyVAIhAMVRovz5DR_itNGYzTpKgO2urLgx5F2mZf3U4INTRR74","userHandle":"MDFHN0VEWUMxQ1QxSjBUUVBIWEY3QVlGNUs","clientDataJSON":"eyJvcmlnaW4iOiJodHRwczovL3dlYmF1dGhuLnNwb21reS1sYWJzLmNvbSIsImNoYWxsZW5nZSI6IkhaaktrWURKTEgtVnF6bFgtaXpCcUc3Q1pvN0FVRmtobG12TnRHM1VKSjQiLCJ0eXBlIjoid2ViYXV0aG4uZ2V0In0"},"getClientExtensionResults":{},"type":"public-key"}'; $this->getPublicKeyCredentialLoader() ->load($response);