import { EmailAddress } from "@/core/common/domain";
import { Result } from "@repo/rdx-utils";
import {
  AuthenticatedUser,
  IJWTPayload,
  LoginData,
  LogoutData,
  RegisterData,
  TabContext,
  Token,
} from "..";

export interface IAuthService {
  generateAccessToken(payload: IJWTPayload): Result<Token, Error>;
  generateRefreshToken(payload: IJWTPayload): Result<Token, Error>;
  verifyRefreshToken(token: Token): IJWTPayload;

  registerUser(
    registerData: RegisterData,
    transaction?: any
  ): Promise<Result<AuthenticatedUser, Error>>;

  loginUser(
    loginData: LoginData,
    transaction?: any
  ): Promise<
    Result<
      {
        user: AuthenticatedUser;
        tabContext: TabContext;
        tokens: {
          accessToken: Token;
          refreshToken: Token;
        };
      },
      Error
    >
  >;

  logoutUser(logoutData: LogoutData, transaction?: any): Promise<Result<void, Error>>;
  getUserByEmail(email: EmailAddress, transaction?: any): Promise<Result<AuthenticatedUser, Error>>;
}
