<?php

declare(strict_types=1);

namespace App\Framework\LiveComponents\Services;

use App\Framework\LiveComponents\ValueObjects\UploadSessionId;
use App\Framework\Random\RandomGenerator;

/**
 * Upload Session ID Generator
 *
 * Generiert kryptographisch sichere Upload Session IDs.
 * Nutzt Framework's RandomGenerator für sichere Zufallswerte.
 */
final readonly class UploadSessionIdGenerator
{
    public function __construct(
        private RandomGenerator $random
    ) {
    }

    /**
     * Generate new cryptographically secure session ID
     */
    public function generate(): UploadSessionId
    {
        $bytes = $this->random->bytes(16); // 16 bytes = 32 hex characters
        return UploadSessionId::fromString(bin2hex($bytes));
    }
}
