import type { AuthenticatedAccountDTO, CurrentSessionResponseDTO, LoginWithPasswordResponseDTO, } from "@erp/identity/common"; import type { AuthSession, AuthTokens } from "../entities"; export function mapAuthenticatedAccount( dto: AuthenticatedAccountDTO ): AuthSession["account"] { return { id: dto.id, email: dto.email, name: dto.name, avatarUrl: dto.avatar_url, languageCode: dto.language_code, }; } export function mapLoginResponseToAuthSession( dto: LoginWithPasswordResponseDTO ): AuthSession { return { accessToken: dto.access_token, refreshToken: dto.refresh_token, account: mapAuthenticatedAccount(dto.account), }; } export function mapCurrentSessionToAuthSession( dto: CurrentSessionResponseDTO, tokens: AuthTokens ): AuthSession { return { accessToken: tokens.accessToken, refreshToken: tokens.refreshToken, account: mapAuthenticatedAccount(dto.account), }; }