<?php

declare(strict_types=1);

namespace apexl\Io\modules\user\services;

use apexl\Config\ConfigurationInterface;
use apexl\Config\Exceptions\MissingConfigException;
use apexl\Io\modules\user\interfaces\JwtKeyProviderInterface;
use Firebase\JWT\Key;

final readonly class JwtKeyFromConfigService implements JwtKeyProviderInterface
{
    public function __construct(private ConfigurationInterface $config) {}

    /**
     * @throws MissingConfigException
     */
    public function key(): Key
    {
        return new Key(
            $this->config->get('auth.jwt.secret_key'),
            $this->config->get('auth.jwt.algorithm')
        );
    }
}