package de.effigenix.application.usermanagement;

import de.effigenix.application.usermanagement.dto.SessionToken;
import de.effigenix.domain.usermanagement.User;
import de.effigenix.domain.usermanagement.UserId;

/**
 * Port for session management (JWT).
 * Implementation will be in Infrastructure Layer.
 */
public interface SessionManager {

    /**
     * Creates a new session (JWT token) for a user.
     *
     * @param user User to create session for
     * @return Session token (access token + refresh token)
     */
    SessionToken createSession(User user);

    /**
     * Validates a JWT token and extracts the user ID.
     *
     * @param token JWT access token
     * @return UserId if valid
     * @throws RuntimeException if token is invalid or expired
     */
    UserId validateToken(String token);

    /**
     * Refreshes an expired access token using a refresh token.
     *
     * @param refreshToken Refresh token
     * @return New session token
     * @throws RuntimeException if refresh token is invalid or expired
     */
    SessionToken refreshSession(String refreshToken);

    /**
     * Invalidates a session (logout).
     *
     * @param token JWT access token to invalidate
     */
    void invalidateSession(String token);
}
