jwtProvider = $jwtProvider; $this->mercureConfig = $mercureConfig; } public function handle(ServerRequestInterface $request): ResponseInterface { $hubUrl = $this->mercureConfig['public_hub_url'] ?? null; if ($hubUrl === null) { throw MercureException::mercureNotConfigured(); } $days = $this->mercureConfig['jwt_days_duration'] ?? 1; $expiresAt = Chronos::now()->addDays($days); try { $jwt = $this->jwtProvider->buildSubscriptionToken($expiresAt); } catch (Throwable $e) { throw MercureException::mercureNotConfigured($e); } return new JsonResponse([ 'mercureHubUrl' => sprintf('%s/.well-known/mercure', $hubUrl), 'token' => $jwt, 'jwtExpiration' => $expiresAt->toAtomString(), ]); } }