Skip to content

Commit

Permalink
Add validation for missing "web-token/jwt-library" dependency
Browse files Browse the repository at this point in the history
Ensure the service throws a clear exception if the required "web-token/jwt-library" package is not installed. This prevents potential runtime issues by guiding users to install the necessary dependency upfront.
  • Loading branch information
Spomky committed Feb 2, 2025
1 parent 523735f commit 815dd7f
Showing 1 changed file with 6 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Jose\Component\Signature\Algorithm\RS256;
use Jose\Component\Signature\JWSVerifier;
use Jose\Component\Signature\Serializer\CompactSerializer;
use LogicException;
use Psr\EventDispatcher\EventDispatcherInterface;
use Symfony\Component\Serializer\Encoder\JsonEncoder;
use Symfony\Component\Serializer\SerializerInterface;
Expand Down Expand Up @@ -59,6 +60,11 @@ public function __construct(
private readonly ?string $rootCertificateUri = null,
?SerializerInterface $serializer = null,
) {
if (! class_exists(CompactSerializer::class)) {
throw new LogicException(
'The "web-token/jwt-library" package is required to use this service. Please run "composer require web-token/jwt-library".'
);
}
$this->serializer = $serializer ?? (new WebauthnSerializerFactory(
AttestationStatementSupportManager::create()
))->create();
Expand Down

0 comments on commit 815dd7f

Please sign in to comment.