Skip to content

Commit

Permalink
Prevent PublicKeyCredentialLoader::load from throwing \JsonException.…
Browse files Browse the repository at this point in the history
… Use of library exception instead (#365)
  • Loading branch information
Spomky authored Jan 22, 2023
1 parent 074740c commit b705c53
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/webauthn/src/PublicKeyCredentialLoader.php
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
}

Expand Down
6 changes: 3 additions & 3 deletions tests/library/Functional/AttestationTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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);
Expand Down

0 comments on commit b705c53

Please sign in to comment.