from typing import Annotated, Any from anydi import Inject from fansifter_common.api.schemas import response_errors from fansifter_common.identifiers.types import ProfileIdentifier, ProfileToken from fastapi import APIRouter from preference_center.profile.exceptions import ProfileNotFoundError from preference_center.profile.services import ProfileService router = APIRouter(tags=["debug"], prefix="/__debug") @router.post( "/profile/token/encrypt", operation_id="debugEncryptProfileToken", description="Encrypt a profile token", response_model=ProfileToken, ) def _debug_encrypt_profile_token( identifier: ProfileIdentifier, profile_service: Annotated[ProfileService, Inject()], ) -> Any: return profile_service.encode_profile_identifier(identifier) @router.post( "/profile/token/decrypt", operation_id="debugDecryptProfileToken", description="Decrypt a profile token", response_model=ProfileIdentifier, responses=response_errors( ProfileNotFoundError, ), ) def _debug_decrypt_profile_token( token: ProfileToken, profile_service: Annotated[ProfileService, Inject()], ) -> Any: return profile_service.decode_profile_identifier(token)