package de.effigenix.application.usermanagement.dto;

import java.time.OffsetDateTime;
import java.time.ZoneOffset;

/**
 * JWT session token returned after successful authentication.
 */
public record SessionToken(
        String accessToken,
        String tokenType,
        long expiresIn,  // in seconds
        OffsetDateTime expiresAt,
        String refreshToken  // for future refresh token support
) {
    public static SessionToken create(String accessToken, long expiresInMs, String refreshToken) {
        return new SessionToken(
                accessToken,
                "Bearer",
                expiresInMs / 1000,  // convert to seconds
                OffsetDateTime.now(ZoneOffset.UTC).plusSeconds(expiresInMs / 1000),
                refreshToken
        );
    }
}
