<?php

namespace Database\Factories;

use App\Models\ApiRefreshToken;
use App\Models\User;
use Illuminate\Database\Eloquent\Factories\Factory;
use Illuminate\Support\Str;

/** @extends Factory<ApiRefreshToken> */
class ApiRefreshTokenFactory extends Factory
{
    protected $model = ApiRefreshToken::class;

    public function definition(): array
    {
        $jti = (string) Str::uuid();
        $token = Str::random(96);

        return [
            'uuid' => (string) Str::uuid(),
            'user_id' => User::factory(),
            'token_family' => (string) Str::uuid(),
            'jti_hash' => hash('sha256', $jti),
            'token_hash' => hash('sha256', $token),
            'device_identifier_hash' => hash('sha256', (string) Str::uuid()),
            'device_name' => 'Test Device',
            'issued_ip' => fake()->ipv4(),
            'user_agent' => fake()->userAgent(),
            'expires_at' => now()->addDays(30),
        ];
    }
}
