from fansifter_common.encrypter import JWTEncrypter from fansifter_common.legal_info.services import LegalInfoService from fansifter_common.translation.services import TranslationService from fansifter_common.utils.functional import lazy_proxy from app.config import settings class DummyEncrypter(JWTEncrypter): def __init__(self) -> None: # noqa pass def encrypt(self, payload: bytes) -> bytes: return payload def decrypt(self, token: bytes | str) -> bytes: if isinstance(token, str): return token.encode() return token def get_encrypter() -> JWTEncrypter: if settings.preference_center_encrypted_backend == "dummy": return DummyEncrypter() return JWTEncrypter(key=settings.preference_center_secret_key) encrypter = lazy_proxy(get_encrypter) def get_legal_info() -> LegalInfoService: return LegalInfoService() legal_info = lazy_proxy(get_legal_info) def get_translations() -> TranslationService: return TranslationService(translations_path=settings.translations_path) translations = lazy_proxy(get_translations)