<?php

namespace App\Providers;

use Illuminate\Support\ServiceProvider;
use Tymon\JWTAuth\Factory as JwtPayloadFactory;

class AppServiceProvider extends ServiceProvider
{
    /**
     * Register any application services.
     */
    public function register(): void
    {
        //
    }

    /**
     * Bootstrap any application services.
     */
    public function boot(): void
    {
        // jwt-auth 2.2 casts a null TTL to zero internally, which would create
        // tokens that expire immediately. Remove the expiration claim from the
        // factory defaults when non-expiring tokens are configured.
        if (config('jwt.ttl') === null) {
            app(JwtPayloadFactory::class)->setDefaultClaims([
                'iss',
                'iat',
                'nbf',
                'jti',
            ]);
        }
    }
}
