commit d94dd31439ae053dc626f9a9be28e3c966e663de Author: Noloquideus Date: Tue May 12 20:44:35 2026 +0300 feat(account): GET /me user endpoint only, disable cache and extra routers Co-authored-by: Cursor diff --git a/.dockerignore b/.dockerignore new file mode 100644 index 0000000..4f65d19 --- /dev/null +++ b/.dockerignore @@ -0,0 +1,22 @@ +__pycache__/ +*.pyc +*.pyo +*.pyd +.pytest_cache/ +.mypy_cache/ +.ruff_cache/ +.cache/ + +.venv/ +venv/ + +.env + +.git/ +.gitignore + +dist/ +build/ +*.egg-info/ + +.DS_Store diff --git a/Dockerfile b/Dockerfile new file mode 100644 index 0000000..3e1f5f9 --- /dev/null +++ b/Dockerfile @@ -0,0 +1,29 @@ +FROM ghcr.io/astral-sh/uv:python3.12-bookworm AS builder + +WORKDIR /app + +# Install dependencies (cached layer) +COPY pyproject.toml uv.lock ./ +RUN uv sync --frozen --no-dev + +# Copy source last (fast rebuilds) +COPY src ./src + + +FROM ghcr.io/astral-sh/uv:python3.12-bookworm AS runtime + +WORKDIR /app + +# Use the virtualenv created by `uv sync` in builder +COPY --from=builder /app/.venv /app/.venv +COPY --from=builder /app/src /app/src + +ENV PATH="/app/.venv/bin:$PATH" \ + PYTHONUNBUFFERED=1 \ + PYTHONDONTWRITEBYTECODE=1 \ + PYTHONPATH=/app + +EXPOSE 8002 + +#CMD ["sh", "-c", "granian --interface asgi ${APP_MODULE:-src.main:app} --host ${APP_HOST:-0.0.0.0} --port ${APP_PORT:-8002} --workers ${APP_WORKERS:-1} --loop uvloop"] +CMD ["sh", "-c", "python -m granian --interface asgi ${APP_MODULE:-src.main:app} --host ${APP_HOST:-0.0.0.0} --port ${APP_PORT:-8002} --workers ${APP_WORKERS:-1} --loop uvloop"] diff --git a/docker-compose.yml b/docker-compose.yml new file mode 100644 index 0000000..3835b5e --- /dev/null +++ b/docker-compose.yml @@ -0,0 +1,83 @@ +services: + users: + container_name: user-service + build: + context: . + dockerfile: Dockerfile + ports: + - "8002:8002" + environment: + PYTHONUNBUFFERED: "1" + APP_MODULE: "src.main:app" + APP_HOST: "0.0.0.0" + APP_PORT: "8002" + APP_WORKERS: "1" + env_file: + - .env + depends_on: + users_keydb: + condition: service_healthy + restart: no + + users_keydb: + image: eqalpha/keydb + container_name: users_keydb + restart: no + expose: + - "6379" + volumes: + - keydb_data:/data + command: + - keydb-server + - --requirepass + - keydb + - --dir + - /data + - --appendonly + - "yes" + - --appendfsync + - everysec + - --save + - "900" + - "1" + - --save + - "300" + - "10" + - --save + - "60" + - "10000" + healthcheck: + test: [ "CMD", "redis-cli", "-a", "keydb", "ping" ] + interval: 5s + timeout: 2s + retries: 20 + +# keydb: +# image: eqalpha/keydb +# container_name: keydb +# restart: no +# expose: +# - "6379" +# volumes: +# - keydb_data:/data +# environment: +# KEYDB_PASSWORD: keydb +# command: > +# sh -c " +# keydb-server +# --requirepass $$KEYDB_PASSWORD +# --dir /data +# --appendonly yes +# --appendfsync everysec +# --save 900 1 +# --save 300 10 +# --save 60 10000 +# " +# healthcheck: +# test: ["CMD", "redis-cli", "ping"] +# interval: 5s +# timeout: 2s +# retries: 20 + +volumes: + keydb_data: diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 0000000..5050b86 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,23 @@ +[project] +name = "bit-users" +version = "0.1.0" +description = "Add your description here" +requires-python = "==3.12.*" +dependencies = [ + "apscheduler==3.11.2", + "asyncpg==0.31.0", + "dotenv==0.9.9", + "fastapi==0.128.7", + "itsdangerous==2.2.0", + "pydantic-settings==2.12.0", + "python-jose==3.5.0", + "python-ulid==3.1.0", + "sqlalchemy==2.0.46", + "uvloop==0.22.1; platform_system != 'Windows'", + "granian==2.6.1", + "hvac==2.4.0", + "redis==7.2.0", + "orjson==3.11.7", + "bcrypt==5.0.0", + "faststream[rabbit]==0.6.6", +] diff --git a/src/application/abstractions/__init__.py b/src/application/abstractions/__init__.py new file mode 100644 index 0000000..76a0e8d --- /dev/null +++ b/src/application/abstractions/__init__.py @@ -0,0 +1 @@ +from src.application.abstractions.i_unit_of_work import IUnitOfWork \ No newline at end of file diff --git a/src/application/abstractions/i_unit_of_work.py b/src/application/abstractions/i_unit_of_work.py new file mode 100644 index 0000000..6a706bc --- /dev/null +++ b/src/application/abstractions/i_unit_of_work.py @@ -0,0 +1,19 @@ +from __future__ import annotations +from typing import Protocol, runtime_checkable +from src.application.abstractions.repositories import IUserRepository, ISessionRepository + + +@runtime_checkable +class IUnitOfWork(Protocol): + async def __aenter__(self) -> "IUnitOfWork": ... + async def __aexit__(self, exc_type, exc_val, exc_tb) -> None: ... + + async def commit(self) -> None: ... + async def rollback(self) -> None: ... + + @property + def user_repository(self) -> IUserRepository: ... + + @property + def session_repository(self) -> ISessionRepository: ... + diff --git a/src/application/abstractions/repositories/__init__.py b/src/application/abstractions/repositories/__init__.py new file mode 100644 index 0000000..7e142d8 --- /dev/null +++ b/src/application/abstractions/repositories/__init__.py @@ -0,0 +1,2 @@ +from src.application.abstractions.repositories.i_user_repository import IUserRepository +from src.application.abstractions.repositories.i_session_repository import ISessionRepository \ No newline at end of file diff --git a/src/application/abstractions/repositories/i_session_repository.py b/src/application/abstractions/repositories/i_session_repository.py new file mode 100644 index 0000000..66b40d9 --- /dev/null +++ b/src/application/abstractions/repositories/i_session_repository.py @@ -0,0 +1,59 @@ +from __future__ import annotations +from abc import ABC, abstractmethod +from datetime import datetime +from src.application.domain.entities import SessionEntity + + + +class ISessionRepository(ABC): + @abstractmethod + async def get_by_sid(self, sid: str) -> SessionEntity | None: + raise NotImplementedError + + @abstractmethod + async def get_by_user_device(self, user_id: str, device_id: str) -> SessionEntity | None: + raise NotImplementedError + + @abstractmethod + async def upsert_by_device( + self, + user_id: str, + device_id: str, + sid: str, + refresh_jti_hash: str, + refresh_expires_at: datetime, + user_agent: str | None, + ip: str | None, + now: datetime, + ) -> SessionEntity: + raise NotImplementedError + + @abstractmethod + async def revoke_by_sid(self, sid: str, now: datetime) -> None: + raise NotImplementedError + + @abstractmethod + async def rotate_refresh( + self, + sid: str, + new_jti_hash: str, + new_refresh_expires_at: datetime, + now: datetime, + ip: str | None, + user_agent: str | None, + ) -> None: + raise NotImplementedError + + @abstractmethod + async def rotate_refresh_if_match( + self, + *, + sid: str, + old_jti_hash: str, + new_jti_hash: str, + new_refresh_expires_at: datetime, + now: datetime, + ip: str | None, + user_agent: str | None, + ) -> bool: + raise NotImplementedError diff --git a/src/application/abstractions/repositories/i_user_repository.py b/src/application/abstractions/repositories/i_user_repository.py new file mode 100644 index 0000000..d400a15 --- /dev/null +++ b/src/application/abstractions/repositories/i_user_repository.py @@ -0,0 +1,39 @@ +from __future__ import annotations +from abc import ABC +from abc import abstractmethod +from src.application.domain.entities import UserEntity + + +class IUserRepository(ABC): + + @abstractmethod + async def get_user_by_id(self, user_id: str) -> UserEntity: + raise NotImplementedError + + @abstractmethod + async def set_phone(self, user_id: str, phone: str) -> UserEntity: + raise NotImplementedError + + @abstractmethod + async def set_bank_details(self, user_id: str, **fields: str) -> UserEntity: + raise NotImplementedError + + @abstractmethod + async def set_crypto_wallet(self, user_id: str, wallet_address: str) -> UserEntity: + raise NotImplementedError + + @abstractmethod + async def get_password_hash(self, user_id: str) -> str: + raise NotImplementedError + + @abstractmethod + async def set_password(self, user_id: str, password_hash: str) -> UserEntity: + raise NotImplementedError + + @abstractmethod + async def set_email(self, user_id: str, email: str) -> UserEntity: + raise NotImplementedError + + @abstractmethod + async def email_exists(self, email: str) -> bool: + raise NotImplementedError \ No newline at end of file diff --git a/src/application/commands/__init__.py b/src/application/commands/__init__.py new file mode 100644 index 0000000..4d2ec64 --- /dev/null +++ b/src/application/commands/__init__.py @@ -0,0 +1,11 @@ +from src.application.commands.get_me import GetMeCommand +from src.application.commands.set_phone import SetPhoneCommand +from src.application.commands.set_crypto_wallet_start import SetCryptoWalletStartCommand +from src.application.commands.set_crypto_wallet_complete import SetCryptoWalletCompleteCommand +from src.application.commands.update_bank_details_start import UpdateBankDetailsStartCommand +from src.application.commands.update_bank_details_complete import UpdateBankDetailsCompleteCommand +from src.application.commands.change_password_start import ChangePasswordStartCommand +from src.application.commands.change_password_complete import ChangePasswordCompleteCommand +from src.application.commands.change_email_start import ChangeEmailStartCommand +from src.application.commands.change_email_confirm_old import ChangeEmailConfirmOldCommand +from src.application.commands.change_email_complete import ChangeEmailCompleteCommand diff --git a/src/application/commands/change_email_complete.py b/src/application/commands/change_email_complete.py new file mode 100644 index 0000000..0ccfbf7 --- /dev/null +++ b/src/application/commands/change_email_complete.py @@ -0,0 +1,63 @@ +from src.application.abstractions import IUnitOfWork +from src.application.contracts import IHashService, ILogger, ICache +from src.application.domain.exceptions import ApplicationException +from src.infrastructure.database.decorators import transactional + + +class ChangeEmailCompleteCommand: + def __init__( + self, + unit_of_work: IUnitOfWork, + hash_service: IHashService, + cache: ICache, + logger: ILogger, + ): + self._unit_of_work = unit_of_work + self._hash_service = hash_service + self._cache = cache + self._logger = logger + + @transactional + async def __call__(self, *, user_id: str, code: str) -> bool: + code = (code or '').strip() + + NEW_USER_PREFIX = 'change_email:new_user:' + NEW_CODE_PREFIX = 'change_email:new_code:' + + new_user_key = f'{NEW_USER_PREFIX}{user_id}' + new_code_key = f'{NEW_CODE_PREFIX}{code}' + + cached_user_id = await self._cache.get(new_code_key) + if not cached_user_id: + self._logger.info(f'Change email complete failed: code not found (user_id={user_id})') + raise ApplicationException(400, 'Invalid or expired code') + + if cached_user_id != user_id: + self._logger.info(f'Change email complete failed: code-user mismatch (user_id={user_id})') + raise ApplicationException(400, 'Invalid or expired code') + + raw_value = await self._cache.get(new_user_key) + if not raw_value: + self._logger.info(f'Change email complete failed: user key missing (user_id={user_id})') + raise ApplicationException(400, 'Invalid or expired code') + + separator_idx = raw_value.index(':') + code_hash = raw_value[:separator_idx] + new_email = raw_value[separator_idx + 1:] + + ok = await self._hash_service.verify(hashed_value=code_hash, plain_value=code) + if not ok: + self._logger.info(f'Change email complete failed: code hash mismatch (user_id={user_id})') + raise ApplicationException(400, 'Invalid or expired code') + + user = await self._unit_of_work.user_repository.set_email(user_id=user_id, email=new_email) + await self._cache.set_user(user_id, user) + + try: + await self._cache.delete(new_code_key) + await self._cache.delete(new_user_key) + except Exception as e: + self._logger.warning(f'Change email complete cleanup failed (user_id={user_id}): {e}') + + self._logger.info(f'Email changed for user_id={user_id}') + return True diff --git a/src/application/commands/change_email_confirm_old.py b/src/application/commands/change_email_confirm_old.py new file mode 100644 index 0000000..95d955f --- /dev/null +++ b/src/application/commands/change_email_confirm_old.py @@ -0,0 +1,145 @@ +import secrets +from datetime import datetime, timezone +from ulid import ULID +from src.application.abstractions import IUnitOfWork +from src.application.contracts import IHashService, ICache, ILogger, IQueueMessanger +from src.application.domain.exceptions import ApplicationException +from src.infrastructure.config import settings +from src.infrastructure.context_vars import trace_id_var +from src.infrastructure.database.decorators import transactional + + +class ChangeEmailConfirmOldCommand: + def __init__( + self, + hash_service: IHashService, + cache: ICache, + unit_of_work: IUnitOfWork, + logger: ILogger, + messanger: IQueueMessanger, + ): + self._hash_service = hash_service + self._unit_of_work = unit_of_work + self._cache = cache + self._logger = logger + self._messanger = messanger + + @transactional + async def __call__(self, *, user_id: str, code: str, new_email: str) -> bool: + TTL = 300 + MAX_ATTEMPTS = 20 + + OLD_USER_PREFIX = 'change_email:old_user:' + OLD_CODE_PREFIX = 'change_email:old_code:' + NEW_USER_PREFIX = 'change_email:new_user:' + NEW_CODE_PREFIX = 'change_email:new_code:' + + code = (code or '').strip() + old_user_key = f'{OLD_USER_PREFIX}{user_id}' + old_code_key = f'{OLD_CODE_PREFIX}{code}' + + cached_user_id = await self._cache.get(old_code_key) + if not cached_user_id: + self._logger.info(f'Change email confirm-old failed: code not found (user_id={user_id})') + raise ApplicationException(400, 'Invalid or expired code') + + if cached_user_id != user_id: + self._logger.info(f'Change email confirm-old failed: code-user mismatch (user_id={user_id})') + raise ApplicationException(400, 'Invalid or expired code') + + code_hash = await self._cache.get(old_user_key) + if not code_hash: + self._logger.info(f'Change email confirm-old failed: user key missing (user_id={user_id})') + raise ApplicationException(400, 'Invalid or expired code') + + ok = await self._hash_service.verify(hashed_value=code_hash, plain_value=code) + if not ok: + self._logger.info(f'Change email confirm-old failed: code hash mismatch (user_id={user_id})') + raise ApplicationException(400, 'Invalid or expired code') + + user = await self._unit_of_work.user_repository.get_user_by_id(user_id=user_id) + + if user.email and user.email.lower() == new_email.lower(): + self._logger.info(f'Change email confirm-old failed: new email same as current (user_id={user_id})') + raise ApplicationException(400, 'New email must differ from the current one') + + email_taken = await self._unit_of_work.user_repository.email_exists(email=new_email) + if email_taken: + self._logger.info(f'Change email confirm-old failed: new email already taken (user_id={user_id})') + raise ApplicationException(409, 'Email already in use') + + try: + await self._cache.delete(old_code_key) + await self._cache.delete(old_user_key) + except Exception as e: + self._logger.warning(f'Change email confirm-old cleanup failed (user_id={user_id}): {e}') + + trace_id = trace_id_var.get() + if not trace_id or trace_id == 'N/A': + trace_id = None + + new_user_key = f'{NEW_USER_PREFIX}{user_id}' + + for _ in range(MAX_ATTEMPTS): + new_code = f'{secrets.randbelow(1_000_000):06d}' + new_code_key = f'{NEW_CODE_PREFIX}{new_code}' + + new_code_hash = await self._hash_service.hash(new_code) + + reserved = await self._cache.set_nx(new_code_key, user_id, ttl=TTL) + if not reserved: + continue + + saved = await self._cache.set(new_user_key, f'{new_code_hash}:{new_email}', ttl=TTL) + if not saved: + await self._cache.delete(new_code_key) + self._logger.error(f'Change email confirm-old failed: cannot save new code hash for user_id={user_id}') + raise ApplicationException(503, 'Temporary error. Please try again.') + + message_id = str(ULID()) + now = datetime.now(timezone.utc).isoformat() + + metadata = { + 'trace_id': trace_id, + 'source': 'user-service', + 'timestamp': now, + 'message_id': message_id, + } + + payload = { + 'email': new_email, + 'code': new_code, + 'ttl_seconds': TTL, + } + + message = { + 'event': 'change_email_new', + 'payload': payload, + 'metadata': metadata, + } + + self._logger.info(f'Change email new code created for user_id={user_id}') + + try: + await self._messanger.publish_to_queue( + queue=settings.RABBIT_EMAIL_CODE_QUEUE, + message=message, + persist=True, + correlation_id=trace_id, + message_id=message_id, + headers={'trace_id': trace_id} if trace_id else None, + ) + except Exception as exception: + try: + await self._cache.delete(new_user_key) + await self._cache.delete(new_code_key) + except Exception as rollback_err: + self._logger.error(f'Publish failed and rollback cache failed for user_id={user_id}: {str(rollback_err)}') + + self._logger.error(f'Failed to publish change email new code for user_id={user_id}: {str(exception)}') + raise ApplicationException(503, 'Temporary error. Please try again.') + + return True + + self._logger.error(f'Change email confirm-old failed: code space exhausted for user_id={user_id}') + raise ApplicationException(503, 'Temporary error. Please try again.') diff --git a/src/application/commands/change_email_start.py b/src/application/commands/change_email_start.py new file mode 100644 index 0000000..e9047df --- /dev/null +++ b/src/application/commands/change_email_start.py @@ -0,0 +1,126 @@ +import secrets +from datetime import datetime, timezone +from ulid import ULID +from src.application.abstractions import IUnitOfWork +from src.application.contracts import IHashService, ICache, ILogger, IQueueMessanger +from src.application.domain.exceptions import ApplicationException +from src.infrastructure.config import settings +from src.infrastructure.context_vars import trace_id_var +from src.infrastructure.database.decorators import transactional + + +class ChangeEmailStartCommand: + def __init__( + self, + hash_service: IHashService, + cache: ICache, + unit_of_work: IUnitOfWork, + logger: ILogger, + messanger: IQueueMessanger, + ): + self._hash_service = hash_service + self._unit_of_work = unit_of_work + self._cache = cache + self._logger = logger + self._messanger = messanger + + @transactional + async def __call__(self, user_id: str) -> bool: + TTL = 300 + LOCK_TTL = 30 + MAX_ATTEMPTS = 20 + + USER_PREFIX = 'change_email:old_user:' + CODE_PREFIX = 'change_email:old_code:' + LOCK_PREFIX = 'change_email:lock:' + + user = await self._unit_of_work.user_repository.get_user_by_id(user_id=user_id) + + if not user.email: + self._logger.warning(f'User {user_id} does not have an email address') + raise ApplicationException(404, f'User {user_id} does not have an email address') + + trace_id = trace_id_var.get() + if not trace_id or trace_id == 'N/A': + trace_id = None + + lock_key = f'{LOCK_PREFIX}{user_id}' + locked = await self._cache.set_nx(lock_key, '1', ttl=LOCK_TTL) + if not locked: + self._logger.info(f'Change email throttled by lock (user_id={user_id})') + raise ApplicationException(429, 'Too many requests. Please wait.') + + try: + user_key = f'{USER_PREFIX}{user_id}' + + existing = await self._cache.get(user_key) + if existing: + self._logger.info(f'Change email denied: code already exists for user_id={user_id}') + raise ApplicationException(429, 'Code already sent. Please wait before retrying.') + + for _ in range(MAX_ATTEMPTS): + code = f'{secrets.randbelow(1_000_000):06d}' + code_key = f'{CODE_PREFIX}{code}' + + code_hash = await self._hash_service.hash(code) + + reserved = await self._cache.set_nx(code_key, user_id, ttl=TTL) + if not reserved: + continue + + saved = await self._cache.set(user_key, code_hash, ttl=TTL) + if not saved: + await self._cache.delete(code_key) + self._logger.error(f'Change email failed: cannot save code hash for user_id={user_id}') + raise ApplicationException(503, 'Temporary error. Please try again.') + + message_id = str(ULID()) + now = datetime.now(timezone.utc).isoformat() + + metadata = { + 'trace_id': trace_id, + 'source': 'user-service', + 'timestamp': now, + 'message_id': message_id, + } + + payload = { + 'email': user.email, + 'code': code, + 'ttl_seconds': TTL, + } + + message = { + 'event': 'change_email_old', + 'payload': payload, + 'metadata': metadata, + } + + self._logger.info(f'Change email old code created for user_id={user_id}') + + try: + await self._messanger.publish_to_queue( + queue=settings.RABBIT_EMAIL_CODE_QUEUE, + message=message, + persist=True, + correlation_id=trace_id, + message_id=message_id, + headers={'trace_id': trace_id} if trace_id else None, + ) + except Exception as exception: + try: + await self._cache.delete(user_key) + await self._cache.delete(code_key) + except Exception as rollback_err: + self._logger.error(f'Publish failed and rollback cache failed for user_id={user_id}: {str(rollback_err)}') + + self._logger.error(f'Failed to publish change email old code for user_id={user_id}: {str(exception)}') + raise ApplicationException(503, 'Temporary error. Please try again.') + + return True + + self._logger.error(f'Change email failed: code space exhausted for user_id={user_id}') + raise ApplicationException(503, 'Temporary error. Please try again.') + + finally: + await self._cache.delete(lock_key) diff --git a/src/application/commands/change_password_complete.py b/src/application/commands/change_password_complete.py new file mode 100644 index 0000000..9dc7367 --- /dev/null +++ b/src/application/commands/change_password_complete.py @@ -0,0 +1,81 @@ +from src.application.abstractions import IUnitOfWork +from src.application.contracts import IHashService, ILogger, ICache +from src.application.domain.exceptions import ApplicationException +from src.infrastructure.database.decorators import transactional + + +class ChangePasswordCompleteCommand: + def __init__( + self, + unit_of_work: IUnitOfWork, + hash_service: IHashService, + cache: ICache, + logger: ILogger, + ): + self._unit_of_work = unit_of_work + self._hash_service = hash_service + self._cache = cache + self._logger = logger + + @transactional + async def __call__( + self, + *, + user_id: str, + code: str, + new_password: str, + confirm_password: str, + ) -> bool: + code = (code or '').strip() + + USER_PREFIX = 'change_password:user:' + CODE_PREFIX = 'change_password:code:' + + user_key = f'{USER_PREFIX}{user_id}' + code_key = f'{CODE_PREFIX}{code}' + + if new_password != confirm_password: + self._logger.info(f'Change password failed: passwords do not match (user_id={user_id})') + raise ApplicationException(400, 'Passwords do not match') + + cached_user_id = await self._cache.get(code_key) + if not cached_user_id: + self._logger.info(f'Change password failed: code not found (user_id={user_id})') + raise ApplicationException(400, 'Invalid or expired code') + + if cached_user_id != user_id: + self._logger.info(f'Change password failed: code-user mismatch (user_id={user_id})') + raise ApplicationException(400, 'Invalid or expired code') + + code_hash = await self._cache.get(user_key) + if not code_hash: + self._logger.info(f'Change password failed: user key missing (user_id={user_id})') + raise ApplicationException(400, 'Invalid or expired code') + + ok = await self._hash_service.verify(hashed_value=code_hash, plain_value=code) + if not ok: + self._logger.info(f'Change password failed: code hash mismatch (user_id={user_id})') + raise ApplicationException(400, 'Invalid or expired code') + + current_password_hash = await self._unit_of_work.user_repository.get_password_hash(user_id=user_id) + + is_same = await self._hash_service.verify(hashed_value=current_password_hash, plain_value=new_password) + if is_same: + self._logger.info(f'Change password failed: new password same as current (user_id={user_id})') + raise ApplicationException(400, 'New password must differ from the current one') + + new_password_hash = await self._hash_service.hash(new_password) + user = await self._unit_of_work.user_repository.set_password( + user_id=user_id, + password_hash=new_password_hash, + ) + await self._cache.set_user(user_id, user) + + try: + await self._cache.delete(code_key) + await self._cache.delete(user_key) + except Exception as e: + self._logger.warning(f'Change password cleanup failed (user_id={user_id}): {e}') + + self._logger.info(f'Password changed for user_id={user_id}') + return True diff --git a/src/application/commands/change_password_start.py b/src/application/commands/change_password_start.py new file mode 100644 index 0000000..d3c1138 --- /dev/null +++ b/src/application/commands/change_password_start.py @@ -0,0 +1,126 @@ +import secrets +from datetime import datetime, timezone +from ulid import ULID +from src.application.abstractions import IUnitOfWork +from src.application.contracts import IHashService, ICache, ILogger, IQueueMessanger +from src.application.domain.exceptions import ApplicationException +from src.infrastructure.config import settings +from src.infrastructure.context_vars import trace_id_var +from src.infrastructure.database.decorators import transactional + + +class ChangePasswordStartCommand: + def __init__( + self, + hash_service: IHashService, + cache: ICache, + unit_of_work: IUnitOfWork, + logger: ILogger, + messanger: IQueueMessanger, + ): + self._hash_service = hash_service + self._unit_of_work = unit_of_work + self._cache = cache + self._logger = logger + self._messanger = messanger + + @transactional + async def __call__(self, user_id: str) -> bool: + TTL = 300 + LOCK_TTL = 30 + MAX_ATTEMPTS = 20 + + USER_PREFIX = 'change_password:user:' + CODE_PREFIX = 'change_password:code:' + LOCK_PREFIX = 'change_password:lock:' + + user = await self._unit_of_work.user_repository.get_user_by_id(user_id=user_id) + + if not user.email: + self._logger.warning(f'User {user_id} does not have an email address') + raise ApplicationException(404, f'User {user_id} does not have an email address') + + trace_id = trace_id_var.get() + if not trace_id or trace_id == 'N/A': + trace_id = None + + lock_key = f'{LOCK_PREFIX}{user_id}' + locked = await self._cache.set_nx(lock_key, '1', ttl=LOCK_TTL) + if not locked: + self._logger.info(f'Change password throttled by lock (user_id={user_id})') + raise ApplicationException(429, 'Too many requests. Please wait.') + + try: + user_key = f'{USER_PREFIX}{user_id}' + + existing = await self._cache.get(user_key) + if existing: + self._logger.info(f'Change password denied: code already exists for user_id={user_id}') + raise ApplicationException(429, 'Code already sent. Please wait before retrying.') + + for _ in range(MAX_ATTEMPTS): + code = f'{secrets.randbelow(1_000_000):06d}' + code_key = f'{CODE_PREFIX}{code}' + + code_hash = await self._hash_service.hash(code) + + reserved = await self._cache.set_nx(code_key, user_id, ttl=TTL) + if not reserved: + continue + + saved = await self._cache.set(user_key, code_hash, ttl=TTL) + if not saved: + await self._cache.delete(code_key) + self._logger.error(f'Change password failed: cannot save code hash for user_id={user_id}') + raise ApplicationException(503, 'Temporary error. Please try again.') + + message_id = str(ULID()) + now = datetime.now(timezone.utc).isoformat() + + metadata = { + 'trace_id': trace_id, + 'source': 'user-service', + 'timestamp': now, + 'message_id': message_id, + } + + payload = { + 'email': user.email, + 'code': code, + 'ttl_seconds': TTL, + } + + message = { + 'event': 'change_password', + 'payload': payload, + 'metadata': metadata, + } + + self._logger.info(f'Change password code created for user_id={user_id}') + + try: + await self._messanger.publish_to_queue( + queue=settings.RABBIT_EMAIL_CODE_QUEUE, + message=message, + persist=True, + correlation_id=trace_id, + message_id=message_id, + headers={'trace_id': trace_id} if trace_id else None, + ) + except Exception as exception: + try: + await self._cache.delete(user_key) + await self._cache.delete(code_key) + except Exception as rollback_err: + self._logger.error(f'Publish failed and rollback cache failed for user_id={user_id}: {str(rollback_err)}') + + self._logger.error(f'Failed to publish change password email for user_id={user_id}: {str(exception)}') + raise ApplicationException(503, 'Temporary error. Please try again.') + + return True + + self._logger.error(f'Change password failed: code space exhausted for user_id={user_id}') + raise ApplicationException(503, 'Temporary error. Please try again.') + + finally: + await self._cache.delete(lock_key) diff --git a/src/application/commands/get_me.py b/src/application/commands/get_me.py new file mode 100644 index 0000000..7da5eb8 --- /dev/null +++ b/src/application/commands/get_me.py @@ -0,0 +1,17 @@ +from src.application.abstractions import IUnitOfWork +from src.application.contracts import ILogger, ICache +from src.application.domain.entities import UserEntity +from src.infrastructure.database.decorators import transactional + + +class GetMeCommand: + def __init__(self, unit_of_work: IUnitOfWork, logger: ILogger, cache: ICache): + self._unit_of_work = unit_of_work + self._logger = logger + self._cache = cache + + @transactional + async def __call__(self, user_id: str) -> UserEntity: + user = await self._unit_of_work.user_repository.get_user_by_id(user_id=user_id) + self._logger.info(f'User ID: {user.id}') + return user \ No newline at end of file diff --git a/src/application/commands/set_crypto_wallet_complete.py b/src/application/commands/set_crypto_wallet_complete.py new file mode 100644 index 0000000..f8757d6 --- /dev/null +++ b/src/application/commands/set_crypto_wallet_complete.py @@ -0,0 +1,68 @@ +from src.application.abstractions import IUnitOfWork +from src.application.contracts import IHashService, ILogger, ICache +from src.application.domain.entities import UserEntity +from src.application.domain.exceptions import ApplicationException +from src.infrastructure.database.decorators import transactional + + +class SetCryptoWalletCompleteCommand: + def __init__( + self, + unit_of_work: IUnitOfWork, + hash_service: IHashService, + cache: ICache, + logger: ILogger, + ): + self._unit_of_work = unit_of_work + self._hash_service = hash_service + self._cache = cache + self._logger = logger + + @transactional + async def __call__(self, *, user_id: str, code: str, wallet_address: str) -> UserEntity: + code = (code or '').strip() + + USER_PREFIX = 'crypto_wallet:user:' + CODE_PREFIX = 'crypto_wallet:code:' + + user_key = f'{USER_PREFIX}{user_id}' + code_key = f'{CODE_PREFIX}{code}' + + user = await self._unit_of_work.user_repository.get_user_by_id(user_id=user_id) + if user.crypto_wallet is not None: + self._logger.info(f'Crypto wallet already set for user_id={user_id}') + raise ApplicationException(409, 'Crypto wallet already set and cannot be changed') + + cached_user_id = await self._cache.get(code_key) + if not cached_user_id: + self._logger.info(f'Crypto wallet set failed: code not found (user_id={user_id})') + raise ApplicationException(400, 'Invalid or expired code') + + if cached_user_id != user_id: + self._logger.info(f'Crypto wallet set failed: code-user mismatch (user_id={user_id})') + raise ApplicationException(400, 'Invalid or expired code') + + code_hash = await self._cache.get(user_key) + if not code_hash: + self._logger.info(f'Crypto wallet set failed: user key missing (user_id={user_id})') + raise ApplicationException(400, 'Invalid or expired code') + + ok = await self._hash_service.verify(hashed_value=code_hash, plain_value=code) + if not ok: + self._logger.info(f'Crypto wallet set failed: code hash mismatch (user_id={user_id})') + raise ApplicationException(400, 'Invalid or expired code') + + user = await self._unit_of_work.user_repository.set_crypto_wallet( + user_id=user_id, + wallet_address=wallet_address, + ) + await self._cache.set_user(user_id, user) + + try: + await self._cache.delete(code_key) + await self._cache.delete(user_key) + except Exception as e: + self._logger.warning(f'Crypto wallet set cleanup failed (user_id={user_id}): {e}') + + self._logger.info(f'Crypto wallet set for user_id={user_id}') + return user diff --git a/src/application/commands/set_crypto_wallet_start.py b/src/application/commands/set_crypto_wallet_start.py new file mode 100644 index 0000000..ac4d952 --- /dev/null +++ b/src/application/commands/set_crypto_wallet_start.py @@ -0,0 +1,130 @@ +import secrets +from datetime import datetime, timezone +from ulid import ULID +from src.application.abstractions import IUnitOfWork +from src.application.contracts import IHashService, ICache, ILogger, IQueueMessanger +from src.application.domain.exceptions import ApplicationException +from src.infrastructure.config import settings +from src.infrastructure.context_vars import trace_id_var +from src.infrastructure.database.decorators import transactional + + +class SetCryptoWalletStartCommand: + def __init__( + self, + hash_service: IHashService, + cache: ICache, + unit_of_work: IUnitOfWork, + logger: ILogger, + messanger: IQueueMessanger, + ): + self._hash_service = hash_service + self._unit_of_work = unit_of_work + self._cache = cache + self._logger = logger + self._messanger = messanger + + @transactional + async def __call__(self, user_id: str) -> bool: + TTL = 300 + LOCK_TTL = 30 + MAX_ATTEMPTS = 20 + + USER_PREFIX = 'crypto_wallet:user:' + CODE_PREFIX = 'crypto_wallet:code:' + LOCK_PREFIX = 'crypto_wallet:lock:' + + user = await self._unit_of_work.user_repository.get_user_by_id(user_id=user_id) + + if user.crypto_wallet is not None: + self._logger.info(f'Crypto wallet already set for user_id={user_id}') + raise ApplicationException(409, 'Crypto wallet already set and cannot be changed') + + if not user.email: + self._logger.warning(f'User {user_id} does not have an email address') + raise ApplicationException(404, f'User {user_id} does not have an email address') + + trace_id = trace_id_var.get() + if not trace_id or trace_id == 'N/A': + trace_id = None + + lock_key = f'{LOCK_PREFIX}{user_id}' + locked = await self._cache.set_nx(lock_key, '1', ttl=LOCK_TTL) + if not locked: + self._logger.info(f'Crypto wallet set throttled by lock (user_id={user_id})') + raise ApplicationException(429, 'Too many requests. Please wait.') + + try: + user_key = f'{USER_PREFIX}{user_id}' + + existing = await self._cache.get(user_key) + if existing: + self._logger.info(f'Crypto wallet set denied: code already exists for user_id={user_id}') + raise ApplicationException(429, 'Code already sent. Please wait before retrying.') + + for _ in range(MAX_ATTEMPTS): + code = f'{secrets.randbelow(1_000_000):06d}' + code_key = f'{CODE_PREFIX}{code}' + + code_hash = await self._hash_service.hash(code) + + reserved = await self._cache.set_nx(code_key, user_id, ttl=TTL) + if not reserved: + continue + + saved = await self._cache.set(user_key, code_hash, ttl=TTL) + if not saved: + await self._cache.delete(code_key) + self._logger.error(f'Crypto wallet set failed: cannot save code hash for user_id={user_id}') + raise ApplicationException(503, 'Temporary error. Please try again.') + + message_id = str(ULID()) + now = datetime.now(timezone.utc).isoformat() + + metadata = { + 'trace_id': trace_id, + 'source': 'user-service', + 'timestamp': now, + 'message_id': message_id, + } + + payload = { + 'email': user.email, + 'code': code, + 'ttl_seconds': TTL, + } + + message = { + 'event': 'crypto_wallet_set', + 'payload': payload, + 'metadata': metadata, + } + + self._logger.info(f'Crypto wallet set code created for user_id={user_id}') + + try: + await self._messanger.publish_to_queue( + queue=settings.RABBIT_EMAIL_CODE_QUEUE, + message=message, + persist=True, + correlation_id=trace_id, + message_id=message_id, + headers={'trace_id': trace_id} if trace_id else None, + ) + except Exception as exception: + try: + await self._cache.delete(user_key) + await self._cache.delete(code_key) + except Exception as rollback_err: + self._logger.error(f'Publish failed and rollback cache failed for user_id={user_id}: {str(rollback_err)}') + + self._logger.error(f'Failed to publish crypto wallet set email for user_id={user_id}: {str(exception)}') + raise ApplicationException(503, 'Temporary error. Please try again.') + + return True + + self._logger.error(f'Crypto wallet set failed: code space exhausted for user_id={user_id}') + raise ApplicationException(503, 'Temporary error. Please try again.') + + finally: + await self._cache.delete(lock_key) diff --git a/src/application/commands/set_phone.py b/src/application/commands/set_phone.py new file mode 100644 index 0000000..6537533 --- /dev/null +++ b/src/application/commands/set_phone.py @@ -0,0 +1,18 @@ +from src.application.abstractions import IUnitOfWork +from src.application.contracts import ILogger, ICache +from src.application.domain.entities import UserEntity +from src.infrastructure.database.decorators import transactional + + +class SetPhoneCommand: + def __init__(self, unit_of_work: IUnitOfWork, logger: ILogger, cache: ICache): + self._unit_of_work = unit_of_work + self._logger = logger + self._cache = cache + + @transactional + async def __call__(self, user_id: str, phone: str) -> UserEntity: + user = await self._unit_of_work.user_repository.set_phone(user_id=user_id, phone=phone) + await self._cache.set_user(user_id, user) + self._logger.info(f'Set phone for user {user_id}') + return user \ No newline at end of file diff --git a/src/application/commands/update_bank_details_complete.py b/src/application/commands/update_bank_details_complete.py new file mode 100644 index 0000000..02b0c49 --- /dev/null +++ b/src/application/commands/update_bank_details_complete.py @@ -0,0 +1,76 @@ +from src.application.abstractions import IUnitOfWork +from src.application.contracts import IHashService, ILogger, ICache +from src.application.domain.entities import UserEntity +from src.application.domain.exceptions import ApplicationException +from src.infrastructure.database.decorators import transactional + + +class UpdateBankDetailsCompleteCommand: + def __init__( + self, + unit_of_work: IUnitOfWork, + hash_service: IHashService, + cache: ICache, + logger: ILogger, + ): + self._unit_of_work = unit_of_work + self._hash_service = hash_service + self._cache = cache + self._logger = logger + + @transactional + async def __call__( + self, + *, + user_id: str, + code: str, + bik: str | None = None, + account_number: str | None = None, + card_number: str | None = None, + ) -> UserEntity: + code = (code or '').strip() + + USER_PREFIX = 'bank_details:user:' + CODE_PREFIX = 'bank_details:code:' + + user_key = f'{USER_PREFIX}{user_id}' + code_key = f'{CODE_PREFIX}{code}' + + cached_user_id = await self._cache.get(code_key) + if not cached_user_id: + self._logger.info(f'Bank details update failed: code not found (user_id={user_id})') + raise ApplicationException(400, 'Invalid or expired code') + + if cached_user_id != user_id: + self._logger.info(f'Bank details update failed: code-user mismatch (user_id={user_id})') + raise ApplicationException(400, 'Invalid or expired code') + + code_hash = await self._cache.get(user_key) + if not code_hash: + self._logger.info(f'Bank details update failed: user key missing (user_id={user_id})') + raise ApplicationException(400, 'Invalid or expired code') + + ok = await self._hash_service.verify(hashed_value=code_hash, plain_value=code) + if not ok: + self._logger.info(f'Bank details update failed: code hash mismatch (user_id={user_id})') + raise ApplicationException(400, 'Invalid or expired code') + + fields = {} + if bik is not None: + fields['bik'] = bik + if account_number is not None: + fields['account_number'] = account_number + if card_number is not None: + fields['card_number'] = card_number + + user = await self._unit_of_work.user_repository.set_bank_details(user_id, **fields) + await self._cache.set_user(user_id, user) + + try: + await self._cache.delete(code_key) + await self._cache.delete(user_key) + except Exception as e: + self._logger.warning(f'Bank details update cleanup failed (user_id={user_id}): {e}') + + self._logger.info(f'Bank details updated for user_id={user_id}, fields={list(fields.keys())}') + return user diff --git a/src/application/commands/update_bank_details_start.py b/src/application/commands/update_bank_details_start.py new file mode 100644 index 0000000..f3d8148 --- /dev/null +++ b/src/application/commands/update_bank_details_start.py @@ -0,0 +1,126 @@ +import secrets +from datetime import datetime, timezone +from ulid import ULID +from src.application.abstractions import IUnitOfWork +from src.application.contracts import IHashService, ICache, ILogger, IQueueMessanger +from src.application.domain.exceptions import ApplicationException +from src.infrastructure.config import settings +from src.infrastructure.context_vars import trace_id_var +from src.infrastructure.database.decorators import transactional + + +class UpdateBankDetailsStartCommand: + def __init__( + self, + hash_service: IHashService, + cache: ICache, + unit_of_work: IUnitOfWork, + logger: ILogger, + messanger: IQueueMessanger, + ): + self._hash_service = hash_service + self._unit_of_work = unit_of_work + self._cache = cache + self._logger = logger + self._messanger = messanger + + @transactional + async def __call__(self, user_id: str) -> bool: + TTL = 300 + LOCK_TTL = 30 + MAX_ATTEMPTS = 20 + + USER_PREFIX = 'bank_details:user:' + CODE_PREFIX = 'bank_details:code:' + LOCK_PREFIX = 'bank_details:lock:' + + user = await self._unit_of_work.user_repository.get_user_by_id(user_id=user_id) + + if not user.email: + self._logger.warning(f'User {user_id} does not have an email address') + raise ApplicationException(status_code=404, message=f'User {user_id} does not have an email address') + + trace_id = trace_id_var.get() + if not trace_id or trace_id == 'N/A': + trace_id = None + + lock_key = f'{LOCK_PREFIX}{user_id}' + locked = await self._cache.set_nx(lock_key, '1', ttl=LOCK_TTL) + if not locked: + self._logger.info(f'Bank details update throttled by lock (user_id={user_id})') + raise ApplicationException(429, 'Too many requests. Please wait.') + + try: + user_key = f'{USER_PREFIX}{user_id}' + + existing = await self._cache.get(user_key) + if existing: + self._logger.info(f'Bank details update denied: code already exists for user_id={user_id}') + raise ApplicationException(429, 'Code already sent. Please wait before retrying.') + + for _ in range(MAX_ATTEMPTS): + code = f'{secrets.randbelow(1_000_000):06d}' + code_key = f'{CODE_PREFIX}{code}' + + code_hash = await self._hash_service.hash(code) + + reserved = await self._cache.set_nx(code_key, user_id, ttl=TTL) + if not reserved: + continue + + saved = await self._cache.set(user_key, code_hash, ttl=TTL) + if not saved: + await self._cache.delete(code_key) + self._logger.error(f'Bank details update failed: cannot save code hash for user_id={user_id}') + raise ApplicationException(503, 'Temporary error. Please try again.') + + message_id = str(ULID()) + now = datetime.now(timezone.utc).isoformat() + + metadata = { + 'trace_id': trace_id, + 'source': 'user-service', + 'timestamp': now, + 'message_id': message_id, + } + + payload = { + 'email': user.email, + 'code': code, + 'ttl_seconds': TTL, + } + + message = { + 'event': 'bank_details_update', + 'payload': payload, + 'metadata': metadata, + } + + self._logger.info(f'Bank details update code created for user_id={user_id}') + + try: + await self._messanger.publish_to_queue( + queue=settings.RABBIT_EMAIL_CODE_QUEUE, + message=message, + persist=True, + correlation_id=trace_id, + message_id=message_id, + headers={'trace_id': trace_id} if trace_id else None, + ) + except Exception as exception: + try: + await self._cache.delete(user_key) + await self._cache.delete(code_key) + except Exception as rollback_err: + self._logger.error(f'Publish failed and rollback cache failed for user_id={user_id}: {str(rollback_err)}') + + self._logger.error(f'Failed to publish bank details update email for user_id={user_id}: {str(exception)}') + raise ApplicationException(503, 'Temporary error. Please try again.') + + return True + + self._logger.error(f'Bank details update failed: code space exhausted for user_id={user_id}') + raise ApplicationException(503, 'Temporary error. Please try again.') + + finally: + await self._cache.delete(lock_key) diff --git a/src/application/contracts/__init__.py b/src/application/contracts/__init__.py new file mode 100644 index 0000000..055d045 --- /dev/null +++ b/src/application/contracts/__init__.py @@ -0,0 +1,6 @@ +from src.application.contracts.i_logger import ILogger +from src.application.contracts.i_jwt_service import IJwtService +from src.application.contracts.i_csrf_service import ICsrfService +from src.application.contracts.i_cache import ICache +from src.application.contracts.i_hash_service import IHashService +from src.application.contracts.i_queue_messanger import IQueueMessanger \ No newline at end of file diff --git a/src/application/contracts/i_cache.py b/src/application/contracts/i_cache.py new file mode 100644 index 0000000..9627ad8 --- /dev/null +++ b/src/application/contracts/i_cache.py @@ -0,0 +1,30 @@ +from __future__ import annotations +from abc import ABC, abstractmethod +from src.application.domain.entities.user import UserEntity + + +class ICache(ABC): + + @abstractmethod + async def set(self, key: str, value: str, ttl: int) -> bool: + raise NotImplementedError + + @abstractmethod + async def set_nx(self, key: str, value: str, ttl: int) -> bool: + raise NotImplementedError + + @abstractmethod + async def get(self, key: str) -> str | None: + raise NotImplementedError + + @abstractmethod + async def delete(self, key: str) -> bool: + raise NotImplementedError + + @abstractmethod + async def get_user(self, user_id: str) -> dict | None: + raise NotImplementedError + + @abstractmethod + async def set_user(self, user_id: str, user: UserEntity, ttl: int = 300) -> None: + raise NotImplementedError \ No newline at end of file diff --git a/src/application/contracts/i_csrf_service.py b/src/application/contracts/i_csrf_service.py new file mode 100644 index 0000000..a493d60 --- /dev/null +++ b/src/application/contracts/i_csrf_service.py @@ -0,0 +1,26 @@ +from __future__ import annotations +from abc import ABC, abstractmethod +from typing import Any, Optional, Mapping + + +class ICsrfService(ABC): + @abstractmethod + def issue(self, subject: Optional[str] = None) -> str: + raise NotImplementedError + + @abstractmethod + def verify(self, token: str, expected_subject: Optional[str] = None) -> dict[str, Any]: + raise NotImplementedError + + @abstractmethod + def extract(self, cookies: Mapping[str, str], headers: Mapping[str, str]) -> tuple[Optional[str], Optional[str]]: + raise NotImplementedError + + @abstractmethod + def verify_pair( + self, + cookie_token: Optional[str], + header_token: Optional[str], + expected_subject: Optional[str] = None, + ) -> None: + raise NotImplementedError diff --git a/src/application/contracts/i_hash_service.py b/src/application/contracts/i_hash_service.py new file mode 100644 index 0000000..438090f --- /dev/null +++ b/src/application/contracts/i_hash_service.py @@ -0,0 +1,12 @@ +from abc import ABC, abstractmethod + + +class IHashService(ABC): + + @abstractmethod + async def hash(self, value: str) -> str: + raise NotImplementedError + + @abstractmethod + async def verify(self, hashed_value: str, plain_value: str) -> bool: + raise NotImplementedError \ No newline at end of file diff --git a/src/application/contracts/i_jwt_service.py b/src/application/contracts/i_jwt_service.py new file mode 100644 index 0000000..eafd65d --- /dev/null +++ b/src/application/contracts/i_jwt_service.py @@ -0,0 +1,10 @@ +from __future__ import annotations +from abc import ABC, abstractmethod +from src.application.domain.dto import AccessTokenPayload + + +class IJwtService(ABC): + + @abstractmethod + async def decode_access_token(self, token: str) -> AccessTokenPayload: + raise NotImplementedError diff --git a/src/application/contracts/i_logger.py b/src/application/contracts/i_logger.py new file mode 100644 index 0000000..1ac5797 --- /dev/null +++ b/src/application/contracts/i_logger.py @@ -0,0 +1,68 @@ +from typing import Protocol, Optional, Callable +from src.application.domain.enums.log_format import LogFormat +from src.application.domain.enums.log_level import LogLevel + + +class ILogger(Protocol): + """Interface for synchronous logger with ContextVar support for trace_id.""" + + log_format: LogFormat + min_level: LogLevel + id_generator: Optional[Callable[[], str]] + instance_id: str + + def set_format(self, log_format: LogFormat) -> None: + """Set log format using LogFormat enum""" + ... + + def set_min_level(self, level: LogLevel) -> None: + """Set minimum log level""" + ... + + def new_trace_id(self) -> str: + """Create and set new trace_id in context""" + ... + + def set_trace_id(self, trace_id: str) -> None: + """Set existing trace_id in context""" + ... + + def get_trace_id(self) -> str: + """Get current trace_id from context""" + ... + + def clear_trace_id(self) -> None: + """Clear the trace_id in the context""" + ... + + def set_instance_id(self, instance_id: str) -> None: + """Set service instance id (ULID recommended)""" + ... + + def get_instance_id(self) -> str: + """Get current service instance id""" + ... + + def debug(self, message: str) -> None: + """Log debug message""" + ... + + def info(self, message: str) -> None: + """Log info message""" + ... + + def warning(self, message: str) -> None: + """Log warning message""" + ... + + def error(self, message: str) -> None: + """Log error message""" + ... + + def critical(self, message: str) -> None: + """Log critical message""" + ... + + def exception(self, message: str) -> None: + """Log exception with traceback""" + ... \ No newline at end of file diff --git a/src/application/contracts/i_queue_messanger.py b/src/application/contracts/i_queue_messanger.py new file mode 100644 index 0000000..ab7be50 --- /dev/null +++ b/src/application/contracts/i_queue_messanger.py @@ -0,0 +1,40 @@ +from abc import ABC, abstractmethod +from typing import Mapping, Any + + +class IQueueMessanger(ABC): + + @abstractmethod + async def connect(self) -> None: + raise NotImplementedError + + @abstractmethod + async def close(self) -> None: + raise NotImplementedError + + @abstractmethod + async def publish_to_queue( + self, + queue: str, + message: Any, + *, + persist: bool = True, + headers: Mapping[str, Any] | None = None, + correlation_id: str | None = None, + message_id: str | None = None, + ) -> None: + raise NotImplementedError + + @abstractmethod + async def publish( + self, + message: Any, + *, + exchange: str, + routing_key: str, + persist: bool = True, + headers: Mapping[str, Any] | None = None, + correlation_id: str | None = None, + message_id: str | None = None, + ) -> None: + raise NotImplementedError \ No newline at end of file diff --git a/src/application/domain/dto/__init__.py b/src/application/domain/dto/__init__.py new file mode 100644 index 0000000..fbf3570 --- /dev/null +++ b/src/application/domain/dto/__init__.py @@ -0,0 +1,2 @@ +from src.application.domain.dto.token import AccessTokenPayload, AuthContext +from src.application.domain.dto.keys import JwtPublicKey, JwtPublicKeySet \ No newline at end of file diff --git a/src/application/domain/dto/keys.py b/src/application/domain/dto/keys.py new file mode 100644 index 0000000..99e953d --- /dev/null +++ b/src/application/domain/dto/keys.py @@ -0,0 +1,20 @@ +from dataclasses import dataclass +from typing import Optional, Dict + + +@dataclass(frozen=True) +class JwtPublicKey: + kid: str + public_key_pem: str + + +@dataclass(frozen=True) +class JwtPublicKeySet: + active: JwtPublicKey + previous: Optional[JwtPublicKey] = None + + def public_keys_by_kid(self) -> Dict[str, str]: + out = {self.active.kid: self.active.public_key_pem} + if self.previous: + out[self.previous.kid] = self.previous.public_key_pem + return out \ No newline at end of file diff --git a/src/application/domain/dto/token.py b/src/application/domain/dto/token.py new file mode 100644 index 0000000..f46391c --- /dev/null +++ b/src/application/domain/dto/token.py @@ -0,0 +1,18 @@ +from pydantic import BaseModel + + +class AccessTokenPayload(BaseModel): + sub: str + type: str + sid: str + iat: int + nbf: int + exp: int + iss: str | None = None + aud: str | None = None + + +class AuthContext(BaseModel): + user_id: str + sid: str + token: AccessTokenPayload \ No newline at end of file diff --git a/src/application/domain/entities/__init__.py b/src/application/domain/entities/__init__.py new file mode 100644 index 0000000..7b2df0e --- /dev/null +++ b/src/application/domain/entities/__init__.py @@ -0,0 +1,5 @@ +from src.application.domain.entities.user import UserEntity +from src.application.domain.entities.session import SessionEntity + + +__all__ = ['UserEntity', 'SessionEntity'] \ No newline at end of file diff --git a/src/application/domain/entities/session.py b/src/application/domain/entities/session.py new file mode 100644 index 0000000..f774cbc --- /dev/null +++ b/src/application/domain/entities/session.py @@ -0,0 +1,20 @@ +from __future__ import annotations +from dataclasses import dataclass +from datetime import datetime + + +@dataclass(slots=True) +class SessionEntity: + sid: str + user_id: str + device_id: str + + revoked_at: datetime | None + last_seen_at: datetime + + refresh_jti_hash: str | None + refresh_expires_at: datetime | None + + user_agent: str | None = None + first_ip: str | None = None + last_ip: str | None = None diff --git a/src/application/domain/entities/user.py b/src/application/domain/entities/user.py new file mode 100644 index 0000000..f0a7961 --- /dev/null +++ b/src/application/domain/entities/user.py @@ -0,0 +1,30 @@ +from __future__ import annotations +from dataclasses import dataclass +from datetime import date, datetime + + +@dataclass(slots=True) +class UserEntity: + id: str | None = None + email: str | None = None + password_hash: str | None = None + + first_name: str | None = None + middle_name: str | None = None + last_name: str | None = None + birth_date: date | None = None + + crypto_wallet: str | None = None + phone: str | None = None + + bik: str | None = None + account_number: str | None = None + card_number: str | None = None + inn: str | None = None + + kyc_verified: bool | None = None + is_deleted: bool | None = None + + created_at: datetime | None = None + updated_at: datetime | None = None + kyc_verified_at: datetime | None = None diff --git a/src/application/domain/enums/__init__.py b/src/application/domain/enums/__init__.py new file mode 100644 index 0000000..f2785a9 --- /dev/null +++ b/src/application/domain/enums/__init__.py @@ -0,0 +1,2 @@ +from src.application.domain.enums.log_level import LogLevel +from src.application.domain.enums.log_format import LogFormat \ No newline at end of file diff --git a/src/application/domain/enums/log_format.py b/src/application/domain/enums/log_format.py new file mode 100644 index 0000000..b67feab --- /dev/null +++ b/src/application/domain/enums/log_format.py @@ -0,0 +1,7 @@ +from enum import Enum + + +class LogFormat(Enum): + """Enum for supported log formats""" + TEXT = 'text' + JSON = 'json' diff --git a/src/application/domain/enums/log_level.py b/src/application/domain/enums/log_level.py new file mode 100644 index 0000000..be1bc17 --- /dev/null +++ b/src/application/domain/enums/log_level.py @@ -0,0 +1,54 @@ +from enum import Enum + + +class LogLevel(Enum): + DEBUG = 10 + INFO = 20 + WARNING = 30 + ERROR = 40 + CRITICAL = 50 + EXCEPTION = 60 + + def __str__(self) -> str: + return self.name + + def __repr__(self) -> str: + return f"[{self.value}, '{self.name}']" + + def __eq__(self, other: object) -> bool: + if isinstance(other, LogLevel): + return self.value == other.value + if isinstance(other, int): + return self.value == other + return NotImplemented + + def __ne__(self, other: object) -> bool: + return not self.__eq__(other) + + def __lt__(self, other: object) -> bool: + if isinstance(other, LogLevel): + return self.value < other.value + if isinstance(other, int): + return self.value < other + return NotImplemented + + def __le__(self, other: object) -> bool: + if isinstance(other, LogLevel): + return self.value <= other.value + if isinstance(other, int): + return self.value <= other + return NotImplemented + + def __gt__(self, other: object) -> bool: + if isinstance(other, LogLevel): + return self.value > other.value + if isinstance(other, int): + return self.value > other + return NotImplemented + + def __ge__(self, other: object) -> bool: + if isinstance(other, LogLevel): + return self.value >= other.value + if isinstance(other, int): + return self.value >= other + return NotImplemented diff --git a/src/application/domain/exceptions/__init__.py b/src/application/domain/exceptions/__init__.py new file mode 100644 index 0000000..6d6ca18 --- /dev/null +++ b/src/application/domain/exceptions/__init__.py @@ -0,0 +1 @@ +from src.application.domain.exceptions.application_exceptions import ApplicationException \ No newline at end of file diff --git a/src/application/domain/exceptions/application_exceptions.py b/src/application/domain/exceptions/application_exceptions.py new file mode 100644 index 0000000..5006dee --- /dev/null +++ b/src/application/domain/exceptions/application_exceptions.py @@ -0,0 +1,18 @@ +from __future__ import annotations +from typing import Mapping + + +class ApplicationException(Exception): + def __init__( + self, + status_code: int, + message: str, + headers: Mapping[str, str] | None = None, + ): + super().__init__(message) + self.status_code = status_code + self.message = message + self.headers = headers + + def __str__(self): + return f"{self.status_code}: {self.message}" diff --git a/src/infrastructure/cache/__init__.py b/src/infrastructure/cache/__init__.py new file mode 100644 index 0000000..552c4f5 --- /dev/null +++ b/src/infrastructure/cache/__init__.py @@ -0,0 +1,2 @@ +from src.infrastructure.cache.client import create_redis_client +from src.infrastructure.cache.keydb_client import KeydbCache \ No newline at end of file diff --git a/src/infrastructure/cache/client.py b/src/infrastructure/cache/client.py new file mode 100644 index 0000000..4c8b59a --- /dev/null +++ b/src/infrastructure/cache/client.py @@ -0,0 +1,16 @@ +import redis.asyncio as redis +from redis.asyncio.client import Redis +from src.infrastructure.config import settings + + +def create_redis_client() -> Redis: + return redis.from_url( + settings.REDIS_URL, + max_connections=50, + decode_responses=True, + socket_timeout=5, + socket_connect_timeout=5, + health_check_interval=30, + retry_on_timeout=True, + socket_keepalive=True, + ) \ No newline at end of file diff --git a/src/infrastructure/cache/keydb_client.py b/src/infrastructure/cache/keydb_client.py new file mode 100644 index 0000000..17d98be --- /dev/null +++ b/src/infrastructure/cache/keydb_client.py @@ -0,0 +1,52 @@ +from __future__ import annotations +import orjson +from redis.asyncio.client import Redis +from src.application.contracts import ICache +from src.application.domain.entities.user import UserEntity + + +class KeydbCache(ICache): + USER_PREFIX = 'user:me' + + def __init__(self, redis_client: Redis): + self._r = redis_client + + async def set(self, key: str, value: str, ttl: int) -> bool: + return bool(await self._r.set(key, value, ex=ttl)) + + async def set_nx(self, key: str, value: str, ttl: int) -> bool: + return bool(await self._r.set(key, value, ex=ttl, nx=True)) + + async def get(self, key: str) -> str | None: + return await self._r.get(key) + + async def delete(self, key: str) -> bool: + return (await self._r.delete(key)) > 0 + + async def get_user(self, user_id: str) -> dict | None: + raw = await self._r.get(f'{self.USER_PREFIX}:{user_id}') + if raw is None: + return None + return orjson.loads(raw) + + async def set_user(self, user_id: str, user: UserEntity, ttl: int = 300) -> None: + data = orjson.dumps({ + 'id': user.id, + 'email': user.email, + 'first_name': user.first_name, + 'middle_name': user.middle_name, + 'last_name': user.last_name, + 'birth_date': str(user.birth_date) if user.birth_date else None, + 'crypto_wallet': user.crypto_wallet, + 'phone': user.phone, + 'bik': user.bik, + 'account_number': user.account_number, + 'card_number': user.card_number, + 'inn': user.inn, + 'kyc_verified': user.kyc_verified, + 'is_deleted': user.is_deleted, + 'created_at': user.created_at.isoformat() if user.created_at else None, + 'updated_at': user.updated_at.isoformat() if user.updated_at else None, + 'kyc_verified_at': user.kyc_verified_at.isoformat() if user.kyc_verified_at else None, + }) + await self._r.set(f'{self.USER_PREFIX}:{user_id}', data, ex=ttl) diff --git a/src/infrastructure/config/__init__.py b/src/infrastructure/config/__init__.py new file mode 100644 index 0000000..4fb5df4 --- /dev/null +++ b/src/infrastructure/config/__init__.py @@ -0,0 +1 @@ +from src.infrastructure.config.settings import settings diff --git a/src/infrastructure/config/settings.py b/src/infrastructure/config/settings.py new file mode 100644 index 0000000..18e9592 --- /dev/null +++ b/src/infrastructure/config/settings.py @@ -0,0 +1,155 @@ +from __future__ import annotations + +from functools import lru_cache +from typing import List, Literal +import os +from dotenv import load_dotenv, find_dotenv +from pydantic import Field, model_validator +from pydantic_settings import BaseSettings, SettingsConfigDict +from src.infrastructure.vault import create_hvac_client, read_kv2_secret + +env_file = find_dotenv(".env") +if env_file: + load_dotenv(env_file) + + +class Settings(BaseSettings): + VAULT_ADDR: str = Field(default="http://localhost:8200") + VAULT_TOKEN: str = Field(..., description="Vault token is required") + VAULT_MOUNT_POINT: str = Field(default="secrets") + + VAULT_JWT_KID_PATH: str = "jwt/kid" + VAULT_JWT_KIDS_PREFIX: str = "jwt/kids" + JWT_KEYS_REFRESH_SECONDS: int = 3600 + + DATABASE_HOST: str + DATABASE_PORT: int = Field(default=5432, ge=1, le=65535) + DATABASE_NAME: str + DATABASE_USER: str + DATABASE_PASSWORD: str + + DATABASE_POOL_SIZE: int = 10 + DATABASE_MAX_OVERFLOW: int = 20 + DATABASE_POOL_TIMEOUT: int = 30 + DATABASE_POOL_RECYCLE: int = 3600 + DATABASE_ECHO: bool = False + + CSRF_SECRET_KEY: str = Field( + default="change-me-change-me-change-me-change-me", + min_length=32, + ) + + CSRF_COOKIE_SECURE: bool = False + CSRF_COOKIE_HTTPONLY: bool = True + CSRF_COOKIE_SAMESITE: Literal["Lax", "Strict", "None"] = "Lax" + CSRF_COOKIE_PATH: str = "/" + CSRF_COOKIE_DOMAIN: str | None = None + + DOCS_USERNAME: str = "admin" + DOCS_PASSWORD: str = "admin" + + JWT_ACCESS_TTL_SECONDS: int = 15 * 60 + JWT_REFRESH_TTL_SECONDS: int = 30 * 24 * 60 * 60 + JWT_ISSUER: str | None = None + JWT_AUDIENCE: str | None = None + JWT_ALGORITHM: str = "RS256" + + REDIS_HOST: str = "localhost" + REDIS_PORT: int = 6379 + REDIS_PASSWORD: str | None = None + REDIS_DB: int = 0 + + RABBIT_HOST: str = "localhost" + RABBIT_PORT: int = 5672 + RABBIT_USER: str = "guest" + RABBIT_PASSWORD: str = "guest" + RABBIT_VHOST: str = "/" + + RABBIT_PUBLISH_PERSIST: bool = True + RABBIT_CONNECT_TIMEOUT: int = 5 + RABBIT_EMAIL_CODE_QUEUE: str = "email.verification_code" + + LOG_LEVEL: Literal["DEBUG", "INFO", "WARNING", "ERROR", "CRITICAL"] = "INFO" + LOG_FORMAT: Literal["JSON", "TEXT"] = "TEXT" + + model_config = SettingsConfigDict( + env_file=".env", + env_file_encoding="utf-8", + case_sensitive=True, + extra="ignore", + ) + + @model_validator(mode="before") + @classmethod + def load_from_vault(cls, data: dict): + addr = data.get("VAULT_ADDR") or os.getenv("VAULT_ADDR") or "http://localhost:8200" + token = data.get("VAULT_TOKEN") or os.getenv("VAULT_TOKEN") + mount = data.get("VAULT_MOUNT_POINT") or os.getenv("VAULT_MOUNT_POINT") or "secrets" + + if not token: + raise RuntimeError("VAULT_TOKEN is required") + + client = create_hvac_client(url=addr, token=token, timeout=5) + + def safe_read(path: str) -> dict: + try: + return read_kv2_secret(client=client, mount_point=mount, path=path) + except Exception: + return {} + + database = safe_read("database") + rabbitmq = safe_read("rabbitmq") + csrf = safe_read("csrf") + + if database: + required = ["HOST", "NAME", "USER", "PASSWORD", "PORT"] + missing = [k for k in required if k not in database] + if missing: + raise RuntimeError(f"Vault database secret missing keys {missing}") + + data["DATABASE_HOST"] = database["HOST"] + data["DATABASE_PORT"] = database["PORT"] + data["DATABASE_NAME"] = database["NAME"] + data["DATABASE_USER"] = database["USER"] + data["DATABASE_PASSWORD"] = database["PASSWORD"] + + if rabbitmq: + data["RABBIT_HOST"] = rabbitmq.get("HOST", data.get("RABBIT_HOST")) + data["RABBIT_PORT"] = rabbitmq.get("PORT", data.get("RABBIT_PORT")) + data["RABBIT_USER"] = rabbitmq.get("USER", data.get("RABBIT_USER")) + data["RABBIT_PASSWORD"] = rabbitmq.get("PASSWORD", data.get("RABBIT_PASSWORD")) + data["RABBIT_VHOST"] = rabbitmq.get("VHOST", data.get("RABBIT_VHOST")) + + if csrf: + data["CSRF_SECRET_KEY"] = csrf.get("KEY", data.get("CSRF_SECRET_KEY")) + + return data + + @property + def DATABASE_URL(self) -> str: + return ( + f"postgresql+asyncpg://{self.DATABASE_USER}:{self.DATABASE_PASSWORD}" + f"@{self.DATABASE_HOST}:{self.DATABASE_PORT}/{self.DATABASE_NAME}" + ) + + @property + def REDIS_URL(self) -> str: + auth = f":{self.REDIS_PASSWORD}@" if self.REDIS_PASSWORD else "" + return f"redis://{auth}{self.REDIS_HOST}:{self.REDIS_PORT}/{self.REDIS_DB}" + + @property + def RABBIT_URL(self) -> str: + vhost = "%2F" if self.RABBIT_VHOST == "/" else self.RABBIT_VHOST.lstrip("/") + return f"amqp://{self.RABBIT_USER}:{self.RABBIT_PASSWORD}@{self.RABBIT_HOST}:{self.RABBIT_PORT}/{vhost}" + + @property + def EXCLUDED_PATHS(self) -> List[str]: + return ["/docs", "/redoc", "/openapi.json", "/ping", "/health"] + + +@lru_cache(maxsize=1) +def get_settings() -> Settings: + return Settings() + + +settings = get_settings() \ No newline at end of file diff --git a/src/infrastructure/context_vars/__init__.py b/src/infrastructure/context_vars/__init__.py new file mode 100644 index 0000000..b68ba6f --- /dev/null +++ b/src/infrastructure/context_vars/__init__.py @@ -0,0 +1 @@ +from src.infrastructure.context_vars.trace_id import trace_id_var \ No newline at end of file diff --git a/src/infrastructure/context_vars/trace_id.py b/src/infrastructure/context_vars/trace_id.py new file mode 100644 index 0000000..ec63d65 --- /dev/null +++ b/src/infrastructure/context_vars/trace_id.py @@ -0,0 +1,4 @@ +from contextvars import ContextVar + + +trace_id_var: ContextVar[str] = ContextVar('trace_id', default='N/A') diff --git a/src/infrastructure/database/__init__.py b/src/infrastructure/database/__init__.py new file mode 100644 index 0000000..71393f5 --- /dev/null +++ b/src/infrastructure/database/__init__.py @@ -0,0 +1 @@ +from src.infrastructure.database.unit_of_work import UnitOfWork \ No newline at end of file diff --git a/src/infrastructure/database/context.py b/src/infrastructure/database/context.py new file mode 100644 index 0000000..c3ac8e9 --- /dev/null +++ b/src/infrastructure/database/context.py @@ -0,0 +1,22 @@ +from sqlalchemy.ext.asyncio import async_sessionmaker +from sqlalchemy.ext.asyncio.engine import create_async_engine +from sqlalchemy.ext.asyncio.session import AsyncSession +from typing import AsyncGenerator +from src.infrastructure.config import settings + + +engine = create_async_engine( + settings.DATABASE_URL, + pool_size=settings.DATABASE_POOL_SIZE, + max_overflow=settings.DATABASE_MAX_OVERFLOW, + pool_timeout=settings.DATABASE_POOL_TIMEOUT, + pool_recycle=settings.DATABASE_POOL_RECYCLE, + echo=settings.DATABASE_ECHO +) + +async_session_maker = async_sessionmaker(engine, expire_on_commit=False, class_=AsyncSession) + + +async def get_session() -> AsyncGenerator[AsyncSession, None]: + async with async_session_maker() as session: + yield session \ No newline at end of file diff --git a/src/infrastructure/database/decorators/__init__.py b/src/infrastructure/database/decorators/__init__.py new file mode 100644 index 0000000..02df9d0 --- /dev/null +++ b/src/infrastructure/database/decorators/__init__.py @@ -0,0 +1 @@ +from src.infrastructure.database.decorators.transactional import transactional \ No newline at end of file diff --git a/src/infrastructure/database/decorators/transactional.py b/src/infrastructure/database/decorators/transactional.py new file mode 100644 index 0000000..b472d47 --- /dev/null +++ b/src/infrastructure/database/decorators/transactional.py @@ -0,0 +1,15 @@ +from __future__ import annotations +from functools import wraps +from typing import Callable, Awaitable, TypeVar, ParamSpec + + +P = ParamSpec("P") +R = TypeVar("R") + + +def transactional(method: Callable[P, Awaitable[R]]) -> Callable[P, Awaitable[R]]: + @wraps(method) + async def wrapper(self, *args: P.args, **kwargs: P.kwargs) -> R: + async with self._unit_of_work: + return await method(self, *args, **kwargs) + return wrapper diff --git a/src/infrastructure/database/models/__init__.py b/src/infrastructure/database/models/__init__.py new file mode 100644 index 0000000..cf032ec --- /dev/null +++ b/src/infrastructure/database/models/__init__.py @@ -0,0 +1,6 @@ +from src.infrastructure.database.models.base import Base +from src.infrastructure.database.models.user import UserModel +from src.infrastructure.database.models.sessions import Session + +__all__ = ['Base', 'UserModel', 'Session'] + diff --git a/src/infrastructure/database/models/base.py b/src/infrastructure/database/models/base.py new file mode 100644 index 0000000..aaed4e3 --- /dev/null +++ b/src/infrastructure/database/models/base.py @@ -0,0 +1,19 @@ +from sqlalchemy.ext.asyncio import AsyncAttrs +from sqlalchemy.orm import DeclarativeBase + + +class Base(AsyncAttrs, DeclarativeBase): + __abstract__ = True + + def __repr__(self) -> str: + class_name = self.__class__.__name__ + attributes = ', '.join(f"{col.name}={getattr(self, col.name, None)!r}" + for col in self.__table__.columns) + return f"<{class_name}({attributes})>" + + def __str__(self) -> str: + class_name = self.__class__.__name__ + attributes = ', '.join(f"{col.name}={getattr(self, col.name)}" + for col in self.__table__.columns + if getattr(self, col.name) is not None) + return f"{class_name}({attributes})" \ No newline at end of file diff --git a/src/infrastructure/database/models/mixins/__init__.py b/src/infrastructure/database/models/mixins/__init__.py new file mode 100644 index 0000000..b69a0df --- /dev/null +++ b/src/infrastructure/database/models/mixins/__init__.py @@ -0,0 +1,3 @@ +from src.infrastructure.database.models.mixins.audit import AuditTimestampsMixin +from src.infrastructure.database.models.mixins.ulid import UlidPrimaryKeyMixin +from src.infrastructure.database.models.mixins.soft_delete import SoftDeleteMixin \ No newline at end of file diff --git a/src/infrastructure/database/models/mixins/audit.py b/src/infrastructure/database/models/mixins/audit.py new file mode 100644 index 0000000..c3f143d --- /dev/null +++ b/src/infrastructure/database/models/mixins/audit.py @@ -0,0 +1,16 @@ +from sqlalchemy import DateTime, func +from sqlalchemy.orm import Mapped, mapped_column + + +class AuditTimestampsMixin: + created_at: Mapped[DateTime] = mapped_column( + DateTime(timezone=True), + nullable=False, + server_default=func.now(), + ) + updated_at: Mapped[DateTime] = mapped_column( + DateTime(timezone=True), + nullable=False, + server_default=func.now(), + onupdate=func.now(), + ) \ No newline at end of file diff --git a/src/infrastructure/database/models/mixins/soft_delete.py b/src/infrastructure/database/models/mixins/soft_delete.py new file mode 100644 index 0000000..ca6a14a --- /dev/null +++ b/src/infrastructure/database/models/mixins/soft_delete.py @@ -0,0 +1,6 @@ +from sqlalchemy import Boolean +from sqlalchemy.orm import Mapped, mapped_column + + +class SoftDeleteMixin: + is_deleted: Mapped[bool] = mapped_column(Boolean, nullable=False, server_default='false', default=False) \ No newline at end of file diff --git a/src/infrastructure/database/models/mixins/ulid.py b/src/infrastructure/database/models/mixins/ulid.py new file mode 100644 index 0000000..1d272ef --- /dev/null +++ b/src/infrastructure/database/models/mixins/ulid.py @@ -0,0 +1,8 @@ +from sqlalchemy import String +from sqlalchemy.orm import Mapped, mapped_column +from ulid import ULID + + +class UlidPrimaryKeyMixin: + + id: Mapped[str] = mapped_column(String(26), primary_key=True, default=lambda: str(ULID())) diff --git a/src/infrastructure/database/models/sessions.py b/src/infrastructure/database/models/sessions.py new file mode 100644 index 0000000..b482d74 --- /dev/null +++ b/src/infrastructure/database/models/sessions.py @@ -0,0 +1,50 @@ +from datetime import datetime, timezone +from sqlalchemy import String, DateTime, ForeignKey, Index +from sqlalchemy.orm import Mapped, mapped_column +from ulid import ULID +from src.infrastructure.database.models import Base +from src.infrastructure.database.models.mixins import UlidPrimaryKeyMixin, AuditTimestampsMixin + + +class Session(Base, UlidPrimaryKeyMixin, AuditTimestampsMixin): + __tablename__ = "sessions" + + sid: Mapped[str] = mapped_column( + String(26), + unique=True, + index=True, + nullable=False, + default=lambda: str(ULID()), + ) + + user_id: Mapped[str] = mapped_column( + String(26), + ForeignKey("users.id", ondelete="CASCADE"), + index=True, + nullable=False, + ) + + device_id: Mapped[str] = mapped_column( + String(26), + nullable=False, + index=True, + ) + + user_agent: Mapped[str | None] = mapped_column(String(500)) + first_ip: Mapped[str | None] = mapped_column(String(64)) + last_ip: Mapped[str | None] = mapped_column(String(64)) + + last_seen_at: Mapped[datetime] = mapped_column( + DateTime(timezone=True), + nullable=False, + default=lambda: datetime.now(timezone.utc), + ) + + revoked_at: Mapped[datetime | None] = mapped_column(DateTime(timezone=True)) + + refresh_jti_hash: Mapped[str | None] = mapped_column(String(255)) + refresh_expires_at: Mapped[datetime | None] = mapped_column(DateTime(timezone=True)) + + +Index("ux_sessions_user_device", Session.user_id, Session.device_id, unique=True) +Index("ix_sessions_user_active", Session.user_id, Session.revoked_at) diff --git a/src/infrastructure/database/models/user.py b/src/infrastructure/database/models/user.py new file mode 100644 index 0000000..ecdb681 --- /dev/null +++ b/src/infrastructure/database/models/user.py @@ -0,0 +1,28 @@ +from __future__ import annotations + +from sqlalchemy import Boolean,Date,String,DateTime +from sqlalchemy.orm import Mapped,mapped_column +from src.infrastructure.database.models.base import Base +from src.infrastructure.database.models.mixins import UlidPrimaryKeyMixin,AuditTimestampsMixin,SoftDeleteMixin + + +class UserModel(Base, UlidPrimaryKeyMixin, AuditTimestampsMixin, SoftDeleteMixin): + __tablename__ = 'users' + + email: Mapped[str] = mapped_column(String(255), nullable=False, unique=True, index=True) + password_hash: Mapped[str] = mapped_column(String(255), nullable=False) + + last_name: Mapped[str | None] = mapped_column(String(128), nullable=True) + first_name: Mapped[str | None] = mapped_column(String(128), nullable=True) + middle_name: Mapped[str | None] = mapped_column(String(128), nullable=True) + birth_date: Mapped[Date | None] = mapped_column(Date, nullable=True) + + crypto_wallet: Mapped[str | None] = mapped_column(String(255), nullable=True) + phone: Mapped[str | None] = mapped_column(String(16), nullable=True) + + passport_data: Mapped[str | None] = mapped_column(String(255), nullable=True) + inn: Mapped[str | None] = mapped_column(String(12), nullable=True) + erc20: Mapped[str | None] = mapped_column(String(255), nullable=True) + + kyc_verified: Mapped[bool] = mapped_column(Boolean, nullable=False, server_default='false', default=False) + kyc_verified_at: Mapped[DateTime | None] = mapped_column(DateTime(timezone=True), nullable=True) diff --git a/src/infrastructure/database/repositories/__init__.py b/src/infrastructure/database/repositories/__init__.py new file mode 100644 index 0000000..a0d771e --- /dev/null +++ b/src/infrastructure/database/repositories/__init__.py @@ -0,0 +1,2 @@ +from src.infrastructure.database.repositories.user_repository import UserRepository +from src.infrastructure.database.repositories.session_repository import SessionRepository \ No newline at end of file diff --git a/src/infrastructure/database/repositories/session_repository.py b/src/infrastructure/database/repositories/session_repository.py new file mode 100644 index 0000000..55e8bc4 --- /dev/null +++ b/src/infrastructure/database/repositories/session_repository.py @@ -0,0 +1,198 @@ +from __future__ import annotations +from datetime import datetime +from typing import Optional +from sqlalchemy import select, update +from sqlalchemy.ext.asyncio import AsyncSession +from src.application.contracts import ILogger +from src.application.domain.entities import SessionEntity +from src.application.abstractions.repositories import ISessionRepository +from src.infrastructure.database.models import Session + + +class SessionRepository(ISessionRepository): + def __init__(self, session: AsyncSession, logger: ILogger): + self._session = session + self._logger = logger + + async def get_by_sid(self, sid: str) -> Optional[SessionEntity]: + res = await self._session.execute(select(Session).where(Session.sid == sid)) + m = res.scalar_one_or_none() + if m is None: + return None + + return SessionEntity( + sid=m.sid, + user_id=m.user_id, + device_id=m.device_id, + revoked_at=m.revoked_at, + last_seen_at=m.last_seen_at, + refresh_jti_hash=m.refresh_jti_hash, + refresh_expires_at=m.refresh_expires_at, + user_agent=m.user_agent, + first_ip=m.first_ip, + last_ip=m.last_ip, + ) + + async def get_by_user_device(self, user_id: str, device_id: str) -> Optional[SessionEntity]: + res = await self._session.execute( + select(Session).where(Session.user_id == user_id, Session.device_id == device_id) + ) + m = res.scalar_one_or_none() + if m is None: + return None + + return SessionEntity( + sid=m.sid, + user_id=m.user_id, + device_id=m.device_id, + revoked_at=m.revoked_at, + last_seen_at=m.last_seen_at, + refresh_jti_hash=m.refresh_jti_hash, + refresh_expires_at=m.refresh_expires_at, + user_agent=m.user_agent, + first_ip=m.first_ip, + last_ip=m.last_ip, + ) + + async def upsert_by_device( + self, + *, + user_id: str, + device_id: str, + sid: str, + refresh_jti_hash: str, + refresh_expires_at: datetime, + user_agent: str | None, + ip: str | None, + now: datetime, + ) -> SessionEntity: + res = await self._session.execute( + select(Session).where(Session.user_id == user_id, Session.device_id == device_id) + ) + m = res.scalar_one_or_none() + + if m is None: + m = Session( + sid=sid, + user_id=user_id, + device_id=device_id, + revoked_at=None, + last_seen_at=now, + refresh_jti_hash=refresh_jti_hash, + refresh_expires_at=refresh_expires_at, + user_agent=user_agent, + first_ip=ip, + last_ip=ip, + ) + self._session.add(m) + await self._session.flush() + + self._logger.info(f'Session created (user_id={user_id}, device_id={device_id}, sid={sid})') + else: + m.sid = sid + m.revoked_at = None + m.last_seen_at = now + m.refresh_jti_hash = refresh_jti_hash + m.refresh_expires_at = refresh_expires_at + m.user_agent = user_agent + m.last_ip = ip + + await self._session.flush() + + self._logger.info(f'Session updated (user_id={user_id}, device_id={device_id}, sid={sid})') + + return SessionEntity( + sid=m.sid, + user_id=m.user_id, + device_id=m.device_id, + revoked_at=m.revoked_at, + last_seen_at=m.last_seen_at, + refresh_jti_hash=m.refresh_jti_hash, + refresh_expires_at=m.refresh_expires_at, + user_agent=m.user_agent, + first_ip=m.first_ip, + last_ip=m.last_ip, + ) + + async def revoke_by_sid(self, sid: str, now: datetime) -> None: + # Интерфейс требует None -> просто делаем update и flush + await self._session.execute( + update(Session) + .where(Session.sid == sid, Session.revoked_at.is_(None)) + .values(revoked_at=now) + .execution_options(synchronize_session='fetch') + ) + await self._session.flush() + + async def rotate_refresh( + self, + sid: str, + new_jti_hash: str, + new_refresh_expires_at: datetime, + now: datetime, + ip: str | None, + user_agent: str | None, + ) -> None: + + values = { + 'refresh_jti_hash': new_jti_hash, + 'refresh_expires_at': new_refresh_expires_at, + 'last_seen_at': now, + 'user_agent': user_agent, + } + if ip is not None: + values['last_ip'] = ip + + await self._session.execute( + update(Session) + .where(Session.sid == sid, Session.revoked_at.is_(None)) + .values(**values) + .execution_options(synchronize_session='fetch') + ) + await self._session.flush() + + async def touch_last_seen(self, sid: str, *, ip: str | None, now: datetime) -> None: + values = {'last_seen_at': now} + if ip is not None: + values['last_ip'] = ip + + await self._session.execute( + update(Session) + .where(Session.sid == sid, Session.revoked_at.is_(None)) + .values(**values) + .execution_options(synchronize_session='fetch') + ) + await self._session.flush() + + async def rotate_refresh_if_match( + self, + *, + sid: str, + old_jti_hash: str, + new_jti_hash: str, + new_refresh_expires_at: datetime, + now: datetime, + ip: str | None, + user_agent: str | None, + ) -> bool: + values = { + 'refresh_jti_hash': new_jti_hash, + 'refresh_expires_at': new_refresh_expires_at, + 'last_seen_at': now, + 'user_agent': user_agent, + } + if ip is not None: + values['last_ip'] = ip + + res = await self._session.execute( + update(Session) + .where( + Session.sid == sid, + Session.revoked_at.is_(None), + Session.refresh_jti_hash == old_jti_hash, # ✅ защита от гонок + ) + .values(**values) + .execution_options(synchronize_session='fetch') + ) + await self._session.flush() + return (res.rowcount or 0) > 0 diff --git a/src/infrastructure/database/repositories/user_repository.py b/src/infrastructure/database/repositories/user_repository.py new file mode 100644 index 0000000..d491121 --- /dev/null +++ b/src/infrastructure/database/repositories/user_repository.py @@ -0,0 +1,118 @@ +from __future__ import annotations +from fastapi import status +from sqlalchemy import select +from sqlalchemy.ext.asyncio import AsyncSession +from sqlalchemy.exc import SQLAlchemyError +from src.application.contracts import ILogger +from src.application.domain.exceptions import ApplicationException +from src.application.abstractions.repositories import IUserRepository +from src.application.domain.entities import UserEntity +from src.infrastructure.database.models import UserModel + + +class UserRepository(IUserRepository): + def __init__(self, session: AsyncSession, logger: ILogger): + self._session = session + self._logger = logger + + async def _get_active_user(self, user_id: str) -> UserModel: + stmt = ( + select(UserModel) + .where( + UserModel.id == user_id, + UserModel.is_deleted.is_(False), + ) + ) + result = await self._session.execute(stmt) + user: UserModel | None = result.scalar_one_or_none() + if user is None: + self._logger.warning(f'User not found with user_id {user_id}') + raise ApplicationException(status_code=status.HTTP_404_NOT_FOUND, message='User not found') + return user + + @staticmethod + def _to_entity(user: UserModel) -> UserEntity: + return UserEntity( + id=user.id, + email=user.email, + password_hash=None, + first_name=user.first_name, + middle_name=user.middle_name, + last_name=user.last_name, + birth_date=user.birth_date, + crypto_wallet=user.crypto_wallet, + phone=user.phone, + bik=user.bik, + account_number=user.account_number, + card_number=user.card_number, + inn=user.inn, + kyc_verified_at=user.kyc_verified_at, + kyc_verified=user.kyc_verified, + is_deleted=user.is_deleted, + created_at=user.created_at, + updated_at=user.updated_at, + ) + + async def get_user_by_id(self, user_id: str) -> UserEntity: + try: + user = await self._get_active_user(user_id) + return self._to_entity(user) + except ApplicationException: + raise + except SQLAlchemyError as exception: + self._logger.exception(str(exception)) + raise ApplicationException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, message=f'Database error: {str(exception)}') + + async def _update_field(self, user_id: str, **fields: object) -> UserEntity: + try: + user = await self._get_active_user(user_id) + for key, value in fields.items(): + setattr(user, key, value) + await self._session.flush() + await self._session.refresh(user) + return self._to_entity(user) + except ApplicationException: + raise + except SQLAlchemyError as exception: + self._logger.exception(str(exception)) + raise ApplicationException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, message=f'Database error: {str(exception)}') + + async def set_phone(self, user_id: str, phone: str) -> UserEntity: + return await self._update_field(user_id, phone=phone) + + async def set_bank_details(self, user_id: str, **fields: str) -> UserEntity: + return await self._update_field(user_id, **fields) + + async def set_crypto_wallet(self, user_id: str, wallet_address: str) -> UserEntity: + return await self._update_field(user_id, crypto_wallet=wallet_address) + + async def get_password_hash(self, user_id: str) -> str: + try: + user = await self._get_active_user(user_id) + return user.password_hash + except ApplicationException: + raise + except SQLAlchemyError as exception: + self._logger.exception(str(exception)) + raise ApplicationException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, message=f'Database error: {str(exception)}') + + async def set_password(self, user_id: str, password_hash: str) -> UserEntity: + return await self._update_field(user_id, password_hash=password_hash) + + async def set_email(self, user_id: str, email: str) -> UserEntity: + return await self._update_field(user_id, email=email) + + async def email_exists(self, email: str) -> bool: + try: + stmt = ( + select(UserModel) + .where( + UserModel.email == email, + UserModel.is_deleted.is_(False), + ) + ) + result = await self._session.execute(stmt) + return result.scalar_one_or_none() is not None + except SQLAlchemyError as exception: + self._logger.exception(str(exception)) + raise ApplicationException(status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, message=f'Database error: {str(exception)}') diff --git a/src/infrastructure/database/unit_of_work.py b/src/infrastructure/database/unit_of_work.py new file mode 100644 index 0000000..3e2363c --- /dev/null +++ b/src/infrastructure/database/unit_of_work.py @@ -0,0 +1,42 @@ +from sqlalchemy.ext.asyncio import AsyncSession, async_sessionmaker +from src.application.abstractions import IUnitOfWork +from src.application.abstractions.repositories import IUserRepository, ISessionRepository +from src.application.contracts import ILogger +from src.infrastructure.database.repositories import UserRepository, SessionRepository + + + +class UnitOfWork(IUnitOfWork): + def __init__(self, session_factory: async_sessionmaker[AsyncSession], logger: ILogger): + self.session_factory = session_factory + self._session: AsyncSession = None + self._user_repository: IUserRepository = None + self._session_repository: ISessionRepository = None + self._logger: ILogger = logger + + async def __aenter__(self): + self._session = self.session_factory() + return self + + async def __aexit__(self, exc_type, exc_val, exc_tb): + if exc_type: + self._logger.error(str(exc_val)) + await self._session.rollback() + self._logger.error(f'Rollback: str{exc_val})') + else: + await self._session.flush() + await self._session.commit() + self._logger.debug('Commit') + await self._session.close() + + @property + def user_repository(self) -> IUserRepository: + if self._user_repository is None: + self._user_repository = UserRepository(session=self._session, logger=self._logger) + return self._user_repository + + @property + def session_repository(self) -> ISessionRepository: + if self._session_repository is None: + self._session_repository = SessionRepository(session=self._session, logger=self._logger) + return self._session_repository diff --git a/src/infrastructure/logger/__init__.py b/src/infrastructure/logger/__init__.py new file mode 100644 index 0000000..a6fee69 --- /dev/null +++ b/src/infrastructure/logger/__init__.py @@ -0,0 +1,28 @@ +from src.application.contracts import ILogger +from src.application.domain.enums import LogFormat +from src.application.domain.enums import LogLevel +from src.infrastructure.config.settings import settings +from src.infrastructure.logger.logger import Logger + +log_levels = { + 'DEBUG': LogLevel.DEBUG, + 'INFO': LogLevel.INFO, + 'WARNING': LogLevel.WARNING, + 'ERROR': LogLevel.ERROR, + 'CRITICAL': LogLevel.CRITICAL, + 'EXCEPTION': LogLevel.EXCEPTION, +} + +log_formats = { + 'JSON': LogFormat.JSON, + 'TEXT': LogFormat.TEXT, +} + +logger = Logger( + min_level=log_levels.get(settings.LOG_LEVEL, LogLevel.INFO), + log_format=log_formats.get(settings.LOG_FORMAT, LogFormat.JSON), +) + + +def get_logger() -> ILogger: + return logger diff --git a/src/infrastructure/logger/logger.py b/src/infrastructure/logger/logger.py new file mode 100644 index 0000000..0fc2c8d --- /dev/null +++ b/src/infrastructure/logger/logger.py @@ -0,0 +1,129 @@ +import traceback +import inspect +import sys +import json +from datetime import datetime +from typing import Callable, Optional, Any +from ulid import ULID +from src.application.contracts import ILogger +from src.application.domain.enums import LogFormat, LogLevel +from src.infrastructure.context_vars import trace_id_var + + +class Logger(ILogger): + _instance = None + __default_format = LogFormat.JSON + + def __new__(cls, *args: Any, **kwargs: Any) -> "Logger": + if cls._instance is None: + cls._instance = super(Logger, cls).__new__(cls) + return cls._instance + + def __init__( + self, + log_format: LogFormat = __default_format, + min_level: LogLevel = LogLevel.INFO, + id_generator: Optional[Callable[[], str]] = lambda: str(ULID()), + instance_id: str = "N/A", + ): + self.log_format = log_format + self.min_level = min_level + self.id_generator = id_generator + self.instance_id = instance_id + + def set_instance_id(self, instance_id: str) -> None: + self.instance_id = instance_id + + def get_instance_id(self) -> str: + return self.instance_id + + def set_format(self, log_format: LogFormat) -> None: + if not isinstance(log_format, LogFormat): + raise ValueError("Log format must be an instance of LogFormat enum") + self.log_format = log_format + + def set_min_level(self, level: LogLevel) -> None: + self.min_level = level + + def new_trace_id(self) -> str: + trace_id = str(ULID()) if self.id_generator is None else self.id_generator() + trace_id_var.set(trace_id) + return trace_id + + def set_trace_id(self, trace_id: str) -> None: + trace_id_var.set(trace_id) + + def get_trace_id(self) -> str: + return trace_id_var.get() + + def clear_trace_id(self) -> None: + trace_id_var.set("N/A") + + def _prepare_log_data(self, level: LogLevel, message: str) -> dict[str, Any]: + current_frame = inspect.currentframe() + if ( + current_frame + and current_frame.f_back + and current_frame.f_back.f_back + and current_frame.f_back.f_back.f_back + ): + frame = current_frame.f_back.f_back.f_back + filename = frame.f_code.co_filename + line_number = frame.f_lineno + else: + filename = "unknown" + line_number = 0 + + log_data = { + "timestamp": datetime.now().isoformat(), + "level": level.name, + "instance_id": self.instance_id, + "file": filename, + "line": line_number, + "trace_id": trace_id_var.get(), + "message": message, + } + + if level == LogLevel.EXCEPTION: + log_data["exception"] = traceback.format_exc() + + return log_data + + def _log(self, level: LogLevel, message: str) -> None: + if level >= self.min_level: + log_data = self._prepare_log_data(level, message) + + if self.log_format == LogFormat.JSON: + log_message = json.dumps(log_data, ensure_ascii=False) + else: + log_message = ( + f"{log_data['timestamp']} - {log_data['level']} - " + f"{log_data['instance_id']} - {log_data['trace_id']} - " + f"{log_data['file']}:{log_data['line']} - " + f"{log_data['message']}" + ) + if "exception" in log_data: + log_message += f"\nTraceback:\n{log_data['exception']}" + + self._write(log_message) + + def _write(self, message: str) -> None: + sys.stdout.write(message + "\n") + + def debug(self, message: str) -> None: + self._log(LogLevel.DEBUG, message) + + def info(self, message: str) -> None: + self._log(LogLevel.INFO, message) + + def warning(self, message: str) -> None: + self._log(LogLevel.WARNING, message) + + def error(self, message: str) -> None: + self._log(LogLevel.ERROR, message) + + def critical(self, message: str) -> None: + self._log(LogLevel.CRITICAL, message) + + def exception(self, message: str) -> None: + self._log(LogLevel.EXCEPTION, message) \ No newline at end of file diff --git a/src/infrastructure/messanger/__init__.py b/src/infrastructure/messanger/__init__.py new file mode 100644 index 0000000..0369f8a --- /dev/null +++ b/src/infrastructure/messanger/__init__.py @@ -0,0 +1 @@ +from src.infrastructure.messanger.rabbit_client import RabbitClient \ No newline at end of file diff --git a/src/infrastructure/messanger/rabbit_client.py b/src/infrastructure/messanger/rabbit_client.py new file mode 100644 index 0000000..d18db3f --- /dev/null +++ b/src/infrastructure/messanger/rabbit_client.py @@ -0,0 +1,72 @@ +from typing import Any, Mapping +from faststream.rabbit import RabbitBroker +from src.application.contracts import IQueueMessanger +from src.infrastructure.config import settings + + +class RabbitClient(IQueueMessanger): + def __init__(self) -> None: + self._broker = RabbitBroker( + settings.RABBIT_URL, + ) + self._connected = False + + async def connect(self) -> None: + if self._connected: + return + await self._broker.connect() + self._connected = True + + async def close(self) -> None: + if not self._connected: + return + await self._broker.close() + self._connected = False + + async def _ensure_connected(self) -> None: + if not self._connected: + await self.connect() + + async def publish_to_queue( + self, + queue: str, + message: Any, + *, + persist: bool | None = None, + headers: Mapping[str, Any] | None = None, + correlation_id: str | None = None, + message_id: str | None = None, + ) -> None: + await self._ensure_connected() + + await self._broker.publish( + message, + queue=queue, + persist=settings.RABBIT_PUBLISH_PERSIST if persist is None else persist, + headers=headers, + correlation_id=correlation_id, + message_id=message_id, + ) + + async def publish( + self, + message: Any, + *, + exchange: str, + routing_key: str, + persist: bool | None = None, + headers: Mapping[str, Any] | None = None, + correlation_id: str | None = None, + message_id: str | None = None, + ) -> None: + await self._ensure_connected() + + await self._broker.publish( + message, + exchange=exchange, + routing_key=routing_key, + persist=settings.RABBIT_PUBLISH_PERSIST if persist is None else persist, + headers=headers, + correlation_id=correlation_id, + message_id=message_id, + ) diff --git a/src/infrastructure/security/__init__.py b/src/infrastructure/security/__init__.py new file mode 100644 index 0000000..6dc434f --- /dev/null +++ b/src/infrastructure/security/__init__.py @@ -0,0 +1,3 @@ +from src.infrastructure.security.jwt import JwtService +from src.infrastructure.security.csrf import CsrfService +from src.infrastructure.security.hash import HashService \ No newline at end of file diff --git a/src/infrastructure/security/csrf.py b/src/infrastructure/security/csrf.py new file mode 100644 index 0000000..1b6d3fd --- /dev/null +++ b/src/infrastructure/security/csrf.py @@ -0,0 +1,81 @@ +from __future__ import annotations +import secrets +from typing import Any, Optional, Mapping +from itsdangerous import URLSafeTimedSerializer, SignatureExpired, BadSignature +from src.application.contracts import ICsrfService +from src.application.domain.exceptions import ApplicationException +from src.infrastructure.config.settings import settings + + +class CsrfService(ICsrfService): + COOKIE_NAME = 'csrf_token' + HEADER_NAME = 'X-CSRF-Token' + SALT = 'csrf' + TTL_SECONDS = 3600 + + def __init__(self) -> None: + self._serializer = URLSafeTimedSerializer( + secret_key=settings.CSRF_SECRET_KEY, + salt=self.SALT, + ) + + @property + def cookie_name(self) -> str: + return self.COOKIE_NAME + + @property + def header_name(self) -> str: + return self.HEADER_NAME + + @property + def ttl_seconds(self) -> int: + return self.TTL_SECONDS + + def issue(self, subject: Optional[str] = None) -> str: + payload = { + 'sub': subject, + 'nonce': secrets.token_urlsafe(32), + } + return self._serializer.dumps(payload) + + def verify(self, token: str, expected_subject: Optional[str] = None) -> dict[str, Any]: + try: + data = self._serializer.loads(token, max_age=self.TTL_SECONDS) + except SignatureExpired: + raise ApplicationException( + status_code=403, + message='CSRF token expired', + ) + except BadSignature: + raise ApplicationException( + status_code=403, + message='CSRF token invalid', + ) + + if expected_subject is not None and data.get('sub') != expected_subject: + raise ApplicationException( + status_code=403, + message='CSRF token subject mismatch', + ) + + return data + + def extract(self, cookies: Mapping[str, str], headers: Mapping[str, str]) -> tuple[Optional[str], Optional[str]]: + cookie_token = cookies.get(self.COOKIE_NAME) + header_token = headers.get(self.HEADER_NAME) + return cookie_token, header_token + + def verify_pair(self, cookie_token: Optional[str], header_token: Optional[str], expected_subject: Optional[str] = None) -> None: + if not cookie_token or not header_token: + raise ApplicationException( + status_code=403, + message='CSRF token missing', + ) + + if not secrets.compare_digest(cookie_token, header_token): + raise ApplicationException( + status_code=403, + message='CSRF token mismatch', + ) + + self.verify(cookie_token, expected_subject=expected_subject) diff --git a/src/infrastructure/security/hash.py b/src/infrastructure/security/hash.py new file mode 100644 index 0000000..94d92b8 --- /dev/null +++ b/src/infrastructure/security/hash.py @@ -0,0 +1,17 @@ +import bcrypt +from src.application.contracts import IHashService, ILogger + + +class HashService(IHashService): + + def __init__(self, logger: ILogger): + self._logger = logger + + async def hash(self, value: str) -> str: + hashed_value = bcrypt.hashpw(value.encode(), bcrypt.gensalt()) + self._logger.info(f'Hash value {hashed_value.decode()}') + return hashed_value.decode() + + async def verify(self, hashed_value: str, plain_value: str) -> bool: + self._logger.info(f'Hash value {hashed_value[:10]}') + return bcrypt.checkpw(plain_value.encode(), hashed_value.encode()) \ No newline at end of file diff --git a/src/infrastructure/security/jwt.py b/src/infrastructure/security/jwt.py new file mode 100644 index 0000000..4274902 --- /dev/null +++ b/src/infrastructure/security/jwt.py @@ -0,0 +1,109 @@ +from __future__ import annotations +from jose import jwt, ExpiredSignatureError, JWTError +from src.application.contracts import ILogger, IJwtService +from src.application.domain.dto import AccessTokenPayload +from src.application.domain.exceptions import ApplicationException +from src.infrastructure.config.settings import settings +from src.infrastructure.vault import JwtKeyStore + + +class JwtService(IJwtService): + def __init__(self, logger: ILogger, key_store: JwtKeyStore) -> None: + self._logger = logger + self._key_store = key_store + + async def decode_access_token(self, token: str) -> AccessTokenPayload: + payload = await self._decode_and_verify(token) + + if payload.get('type') != 'access': + self._logger.warning(f'Access token invalid type received_type={payload.get('type')}') + raise ApplicationException(status_code=401, message='Invalid token type') + + try: + return AccessTokenPayload( + sub=str(payload['sub']), + type='access', + sid=str(payload['sid']), + iat=int(payload['iat']), + nbf=int(payload['nbf']), + exp=int(payload['exp']), + iss=payload.get('iss'), + aud=payload.get('aud'), + ) + except KeyError as exception: + self._logger.warning(f'Access token missing claim error={str(exception)}') + raise ApplicationException(status_code=401, message=f'Missing token claim: {exception}') + + async def _decode_and_verify(self, token: str) -> dict: + kid: str | None = None + try: + header = jwt.get_unverified_header(token) + + kid = header.get('kid') + if not kid: + self._logger.warning(f'JWT header missing kid header={header}') + raise ApplicationException(status_code=401, message='Missing token header: kid') + + received_alg = header.get('alg') + if received_alg != settings.JWT_ALGORITHM: + self._logger.warning(f'JWT invalid algorithm kid={kid} received_alg={received_alg} expected_alg={settings.JWT_ALGORITHM}') + raise ApplicationException(status_code=401, message='Invalid token algorithm') + + public_pem = await self._key_store.get_public_key_for_kid(str(kid)) + + if not public_pem: + self._logger.info(f'JWT kid miss kid={kid} forcing keystore refresh') + await self._key_store.refresh() + public_pem = await self._key_store.get_public_key_for_kid(str(kid)) + + if not public_pem: + self._logger.warning(f'JWT unknown kid kid={kid}') + raise ApplicationException(status_code=401, message='Unknown token kid') + + options = { + 'verify_signature': True, + 'verify_exp': True, + 'verify_nbf': True, + 'verify_iat': True, + 'verify_aud': bool(settings.JWT_AUDIENCE), + 'verify_iss': bool(settings.JWT_ISSUER), + 'require_exp': True, + 'require_iat': True, + 'require_nbf': True, + 'require_sub': True, + 'leeway': 10, + } + + payload = jwt.decode( + token, + public_pem, + algorithms=[settings.JWT_ALGORITHM], + audience=settings.JWT_AUDIENCE or None, + issuer=settings.JWT_ISSUER or None, + options=options, + ) + + if 'sid' not in payload: + self._logger.warning(f'JWT missing sid claim kid={kid}') + raise ApplicationException(status_code=401, message='Missing token claim: sid') + + if 'type' not in payload: + self._logger.warning(f'JWT missing type claim kid={kid}') + raise ApplicationException(status_code=401, message='Missing token claim: type') + + return payload + + except ExpiredSignatureError as exception: + self._logger.info(f'JWT expired kid={kid} error={str(exception)}') + raise ApplicationException(status_code=401, message='Token expired') + + except ApplicationException: + raise + + except JWTError as exception: + self._logger.warning(f'JWT decode failed kid={kid} error={str(exception)}') + raise ApplicationException(status_code=401, message='Invalid token') + + except Exception as exception: + self._logger.error(f'Unexpected JWT decode error kid={kid} error={str(exception)}') + raise ApplicationException(status_code=500, message='JWT decode failed') \ No newline at end of file diff --git a/src/infrastructure/utils/__init__.py b/src/infrastructure/utils/__init__.py new file mode 100644 index 0000000..2f4158c --- /dev/null +++ b/src/infrastructure/utils/__init__.py @@ -0,0 +1 @@ +from src.infrastructure.utils.instance_id import generate_instance_id \ No newline at end of file diff --git a/src/infrastructure/utils/instance_id.py b/src/infrastructure/utils/instance_id.py new file mode 100644 index 0000000..49a571c --- /dev/null +++ b/src/infrastructure/utils/instance_id.py @@ -0,0 +1,14 @@ +from ulid import ULID + + +def generate_instance_id() -> str: + """ + Generate a process-wide instance id in ULID format. + + ULID is 26 chars (Crockford Base32) and lexicographically sortable by time. + """ + + + return str(ULID()) + + diff --git a/src/infrastructure/vault/__init__.py b/src/infrastructure/vault/__init__.py new file mode 100644 index 0000000..5206af7 --- /dev/null +++ b/src/infrastructure/vault/__init__.py @@ -0,0 +1,3 @@ +from src.infrastructure.vault.utils import read_kv2_secret, create_hvac_client +from src.infrastructure.vault.keys import JwtKeyStore +from src.infrastructure.vault.scheduler import start_jwt_keys_scheduler \ No newline at end of file diff --git a/src/infrastructure/vault/keys.py b/src/infrastructure/vault/keys.py new file mode 100644 index 0000000..6e12f76 --- /dev/null +++ b/src/infrastructure/vault/keys.py @@ -0,0 +1,113 @@ +from __future__ import annotations +import asyncio +from datetime import datetime, timezone +from src.application.domain.dto import JwtPublicKeySet, JwtPublicKey +from src.application.domain.exceptions import ApplicationException +from src.infrastructure.vault import create_hvac_client, read_kv2_secret + + +class JwtKeyStore: + + _instance: 'JwtKeyStore | None' = None + + def __new__(cls, *args, **kwargs): + if cls._instance is None: + cls._instance = super().__new__(cls) + return cls._instance + + def __init__( + self, + *, + vault_addr: str, + vault_token: str, + mount_point: str, + kid_path: str = 'jwt/kid', + kids_prefix: str = 'jwt/kids', + timeout_seconds: int = 5, + refresh_ttl_seconds: int = 60, + ): + if getattr(self, '_initialized', False): + return + + self._vault_addr = vault_addr + self._vault_token = vault_token + self._timeout = timeout_seconds + + self._mount = mount_point + self._kid_path = kid_path + self._kids_prefix = kids_prefix + + self._refresh_ttl_seconds = refresh_ttl_seconds + + self._lock = asyncio.Lock() + self._keyset: JwtPublicKeySet | None = None + self._last_refresh_at: datetime | None = None + + self._initialized = True + + @classmethod + def get_instance(cls) -> 'JwtKeyStore': + if cls._instance is None: + raise ApplicationException(status_code=500, message='JwtKeyStore not initialized') + return cls._instance + + def _read_keyset_sync(self) -> JwtPublicKeySet: + client = create_hvac_client(url=self._vault_addr, token=self._vault_token, timeout=self._timeout) + + kids = read_kv2_secret(client=client, mount_point=self._mount, path=self._kid_path) + active_kid = kids.get('active') + previous_kid = kids.get('previous') + + if not active_kid: + raise RuntimeError('Vault jwt/kid secret missing "active"') + + active = self._read_public_key_sync(client, str(active_kid)) + + previous = None + if previous_kid and previous_kid != active_kid: + previous = self._read_public_key_sync(client, str(previous_kid)) + + return JwtPublicKeySet(active=active, previous=previous) + + def _read_public_key_sync(self, client, kid: str) -> JwtPublicKey: + data = read_kv2_secret( + client=client, + mount_point=self._mount, + path=f'{self._kids_prefix}/{kid}', + ) + pub = data.get('public_key') + if not pub: + raise RuntimeError(f'Vault jwt/kids/{kid} missing public_key') + return JwtPublicKey(kid=kid, public_key_pem=pub) + + async def refresh(self) -> JwtPublicKeySet: + keyset = await asyncio.to_thread(self._read_keyset_sync) + async with self._lock: + self._keyset = keyset + self._last_refresh_at = datetime.now(timezone.utc) + return keyset + + async def get_public_key_for_kid(self, kid: str) -> str | None: + ks = await self._get_or_refresh() + return ks.public_keys_by_kid().get(kid) + + async def last_refresh_at(self) -> datetime | None: + async with self._lock: + return self._last_refresh_at + + async def _get_or_refresh(self) -> JwtPublicKeySet: + async with self._lock: + ks = self._keyset + last = self._last_refresh_at + + if ks is None: + return await self.refresh() + + if last is None: + return await self.refresh() + + age = (datetime.now(timezone.utc) - last).total_seconds() + if age >= self._refresh_ttl_seconds: + return await self.refresh() + + return ks \ No newline at end of file diff --git a/src/infrastructure/vault/scheduler.py b/src/infrastructure/vault/scheduler.py new file mode 100644 index 0000000..007818d --- /dev/null +++ b/src/infrastructure/vault/scheduler.py @@ -0,0 +1,23 @@ +from __future__ import annotations +import logging +from apscheduler.schedulers.asyncio import AsyncIOScheduler +from apscheduler.triggers.interval import IntervalTrigger +from src.infrastructure.vault import JwtKeyStore + +logger = logging.getLogger(__name__) + + +def start_jwt_keys_scheduler(store: JwtKeyStore, *, refresh_seconds: int = 3600) -> AsyncIOScheduler: + scheduler = AsyncIOScheduler() + scheduler.add_job( + store.refresh, + trigger=IntervalTrigger(seconds=refresh_seconds), + id="jwt_keys_refresh", + replace_existing=True, + max_instances=1, + coalesce=True, + misfire_grace_time=60, + ) + scheduler.start() + logger.info("JWT keys scheduler started (interval=%s seconds)", refresh_seconds) + return scheduler \ No newline at end of file diff --git a/src/infrastructure/vault/utils.py b/src/infrastructure/vault/utils.py new file mode 100644 index 0000000..27b3ba9 --- /dev/null +++ b/src/infrastructure/vault/utils.py @@ -0,0 +1,17 @@ +from __future__ import annotations +import hvac + + +def create_hvac_client(*, url: str, token: str, timeout: int = 5) -> hvac.Client: + client = hvac.Client(url=url, token=token, timeout=timeout) + if not client.is_authenticated(): + raise RuntimeError("Vault authentication failed. Check VAULT_ADDR / VAULT_TOKEN") + return client + + +def read_kv2_secret(*, client: hvac.Client, mount_point: str, path: str) -> dict: + secret = client.secrets.kv.v2.read_secret_version( + mount_point=mount_point, + path=path, + ) + return secret["data"]["data"] \ No newline at end of file diff --git a/src/main.py b/src/main.py new file mode 100644 index 0000000..de06f5f --- /dev/null +++ b/src/main.py @@ -0,0 +1,123 @@ +from __future__ import annotations +from contextlib import asynccontextmanager +import secrets +from typing import AsyncGenerator +from fastapi import Depends, FastAPI, status +from fastapi.openapi.docs import get_redoc_html, get_swagger_ui_html +from fastapi.responses import HTMLResponse +from fastapi.security import HTTPBasic, HTTPBasicCredentials +from src.application.domain.exceptions import ApplicationException +from src.infrastructure.cache import create_redis_client +from src.infrastructure.config.settings import get_settings +from src.infrastructure.vault import JwtKeyStore, start_jwt_keys_scheduler +from src.infrastructure.utils import generate_instance_id +from src.infrastructure.logger import logger +from src.infrastructure.config import settings +from src.presentation.handlers import application_exception_handler, unhandled_exception_handler +from src.presentation.middleware import TraceIDMiddleware, SecurityHeadersMiddleware +from src.presentation.routing import me_router + +security = HTTPBasic() + + +async def verify_credentials(credentials: HTTPBasicCredentials = Depends(security)) -> HTTPBasicCredentials: + user_ok = secrets.compare_digest(credentials.username, settings.DOCS_USERNAME) + pass_ok = secrets.compare_digest(credentials.password, settings.DOCS_PASSWORD) + if not (user_ok and pass_ok): + raise ApplicationException( + status_code=status.HTTP_401_UNAUTHORIZED, + message='Unauthorized', + headers={'WWW-Authenticate': 'Basic'}, + ) + return credentials + + +@asynccontextmanager +async def lifespan(app: FastAPI) -> AsyncGenerator[None, None]: + + instance_id = generate_instance_id() + logger.set_instance_id(instance_id) + logger.info(f'Users service instance started with id {instance_id}') + + app.state.redis = create_redis_client() + + jwt_store = JwtKeyStore( + vault_addr=settings.VAULT_ADDR, + vault_token=settings.VAULT_TOKEN, + mount_point=settings.VAULT_MOUNT_POINT, + kid_path=settings.VAULT_JWT_KID_PATH, + kids_prefix=settings.VAULT_JWT_KIDS_PREFIX, + ) + + await jwt_store.refresh() + + jwt_scheduler = start_jwt_keys_scheduler(jwt_store, refresh_seconds=settings.JWT_KEYS_REFRESH_SECONDS) + + app.state.jwt_key_store = jwt_store + app.state.jwt_keys_scheduler = jwt_scheduler + yield + await app.state.redis.aclose() + logger.info(f'Users service instance ended with id {instance_id}') + + +app: FastAPI = FastAPI( + redoc_url=None, + docs_url=None, + lifespan=lifespan, + title='Bitforce. Users Service', + version='1.0.0', + description='', + license_info={ + 'name': 'MIT', + 'url': 'https://opensource.org/licenses/MIT', + }, +) + +app.add_exception_handler(ApplicationException, application_exception_handler) +app.add_exception_handler(Exception, unhandled_exception_handler) + +app.include_router(me_router) +# app.include_router(me_devices_router) +# app.include_router(me_deals_router) + + +# Added middleware +app.add_middleware(TraceIDMiddleware, logger=logger) +app.add_middleware( + SecurityHeadersMiddleware, + hsts=True, + hsts_preload=False, + frame_options='DENY', + referrer_policy='strict-origin-when-cross-origin', + content_security_policy="default-src 'self'; frame-ancestors 'none'; base-uri 'self'; object-src 'none'", +) + + +@app.get('/docs', include_in_schema=False) +async def custom_swagger_ui_html(_credentials: HTTPBasicCredentials = Depends(verify_credentials)) -> HTMLResponse: + '''Custom Swagger documentation, optionally protected with basic authentication.''' + return get_swagger_ui_html( + openapi_url=getattr(app, 'openapi_url', '/openapi.json'), + title=getattr(app, 'title', 'FastAPI') + ' - Swagger UI', + oauth2_redirect_url=getattr(app, 'swagger_ui_oauth2_redirect_url', None), + swagger_js_url='https://unpkg.com/swagger-ui-dist@5/swagger-ui-bundle.js', + swagger_css_url='https://unpkg.com/swagger-ui-dist@5/swagger-ui.css', + ) + + +@app.get('/redoc', include_in_schema=False) +async def custom_redoc_html(_credentials: HTTPBasicCredentials = Depends(verify_credentials)) -> HTMLResponse: + '''Custom ReDoc documentation, optionally protected with basic authentication.''' + return get_redoc_html( + openapi_url=getattr(app, 'openapi_url', '/openapi.json'), + title=getattr(app, 'title', 'FastAPI') + ' - ReDoc', + redoc_js_url='https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js', + ) + + +@app.post('/ping') +async def ping() -> dict[str, str]: + return { + 'message': 'pong', + 'status': 'ok', + } diff --git a/src/presentation/decorators/__init__.py b/src/presentation/decorators/__init__.py new file mode 100644 index 0000000..9fa8d95 --- /dev/null +++ b/src/presentation/decorators/__init__.py @@ -0,0 +1,4 @@ +from src.presentation.decorators.csrf import csrf_protect +from src.presentation.decorators.rate_limit import rate_limit, _email_rl_key as email_rl_key +from src.presentation.decorators.auth import require_access_token +from src.presentation.decorators.cache import cached \ No newline at end of file diff --git a/src/presentation/decorators/auth.py b/src/presentation/decorators/auth.py new file mode 100644 index 0000000..ba8b030 --- /dev/null +++ b/src/presentation/decorators/auth.py @@ -0,0 +1,36 @@ +from fastapi import Depends, Request +from fastapi.security.utils import get_authorization_scheme_param +from src.application.contracts import IJwtService +from src.application.domain.exceptions import ApplicationException +from src.application.domain.dto import AccessTokenPayload, AuthContext +from src.presentation.dependencies import get_jwt_service + + +def _extract_access_token(request: Request) -> str | None: + token = request.cookies.get('access_token') + + if token: + return token + + auth = request.headers.get('Authorization') + if auth: + scheme, param = get_authorization_scheme_param(auth) + if scheme.lower() == 'bearer' and param: + return param + + return None + + +async def require_access_token( + request: Request, + jwt_service: IJwtService = Depends(get_jwt_service), +) -> AuthContext: + token = _extract_access_token(request) + if not token: + raise ApplicationException(status_code=401, message='Not authenticated') + + payload: AccessTokenPayload = await jwt_service.decode_access_token(token) + if payload.type != 'access': + raise ApplicationException(status_code=401, message='Invalid token type') + + return AuthContext(user_id=payload.sub, sid=payload.sid, token=payload) diff --git a/src/presentation/decorators/cache.py b/src/presentation/decorators/cache.py new file mode 100644 index 0000000..a7cbdaf --- /dev/null +++ b/src/presentation/decorators/cache.py @@ -0,0 +1,46 @@ +from __future__ import annotations +import functools +from typing import Any, Awaitable, Callable +from fastapi import Request +from fastapi.responses import ORJSONResponse +from src.infrastructure.cache import KeydbCache +from src.infrastructure.logger import get_logger +from src.presentation.dependencies.cache import get_redis + + +def cached(*, prefix: str) -> Callable: + + def decorator(func: Callable[..., Awaitable[Any]]): + @functools.wraps(func) + async def wrapper(*args: Any, **kwargs: Any) -> Any: + logger = get_logger() + + request = kwargs.get('request') + if not isinstance(request, Request): + for a in args: + if isinstance(a, Request): + request = a + break + + auth = kwargs.get('auth') + user_id = getattr(auth, 'user_id', None) if auth else None + + if request is None or user_id is None: + return await func(*args, **kwargs) + + cache_key = f'{prefix}:{user_id}' + + try: + redis = get_redis(request) + cache = KeydbCache(redis) + hit = await cache.get_user(user_id) + if hit is not None: + logger.debug(f'Cache hit key={cache_key}') + return ORJSONResponse(status_code=200, content=hit) + except Exception as e: + logger.warning(f'Cache read failed key={cache_key} error={e}') + + return await func(*args, **kwargs) + + return wrapper + return decorator diff --git a/src/presentation/decorators/csrf.py b/src/presentation/decorators/csrf.py new file mode 100644 index 0000000..768e69e --- /dev/null +++ b/src/presentation/decorators/csrf.py @@ -0,0 +1,61 @@ +from __future__ import annotations +import inspect +from functools import wraps +from typing import Callable, Awaitable, Any, Optional, Annotated +from fastapi import Request, Header +from src.application.domain.exceptions import ApplicationException +from src.infrastructure.security import CsrfService + + +def csrf_protect( + expected_subject_getter: Optional[Callable[[Request], Optional[str]]] = None, +): + def decorator(func: Callable[..., Awaitable[Any]]): + sig = inspect.signature(func) + params = list(sig.parameters.values()) + + has_request = any(p.annotation is Request or p.name == 'request' for p in params) + if not has_request: + raise RuntimeError('csrf_protect requires endpoint to accept `request: Request`') + + has_header = any(p.name == 'x_csrf_token' for p in params) + if not has_header: + params.append( + inspect.Parameter( + name='x_csrf_token', + kind=inspect.Parameter.KEYWORD_ONLY, + default=None, + annotation=Annotated[str | None, Header(alias='X-CSRF-Token')], + ) + ) + + @wraps(func) + async def wrapper(*args, **kwargs): + request: Request | None = kwargs.get('request') + if request is None: + for arg in args: + if isinstance(arg, Request): + request = arg + break + + if request is None: + raise ApplicationException( + status_code=500, + message='Request is required for CSRF protection', + ) + + csrf = CsrfService() + + cookie_token, _ = csrf.extract(request.cookies, request.headers) + header_token = kwargs.get('x_csrf_token') + + expected_subject = expected_subject_getter(request) if expected_subject_getter else None + csrf.verify_pair(cookie_token, header_token, expected_subject) + + kwargs.pop('x_csrf_token', None) + return await func(*args, **kwargs) + + wrapper.__signature__ = sig.replace(parameters=params) + return wrapper + + return decorator diff --git a/src/presentation/decorators/rate_limit.py b/src/presentation/decorators/rate_limit.py new file mode 100644 index 0000000..6ff0094 --- /dev/null +++ b/src/presentation/decorators/rate_limit.py @@ -0,0 +1,171 @@ +from __future__ import annotations +import functools +import inspect +import hashlib +from typing import Any, Awaitable, Callable, Literal, Optional, Protocol, runtime_checkable +from fastapi import Request +from redis.asyncio.client import Redis +from src.application.contracts import ILogger +from src.application.domain.exceptions import ApplicationException +from src.infrastructure.logger import get_logger +from src.presentation.dependencies import get_redis + + +def _find_request(args: tuple[Any, ...], kwargs: dict[str, Any]) -> Request: + req = kwargs.get('request') + if isinstance(req, Request): + return req + for a in args: + if isinstance(a, Request): + return a + raise RuntimeError('rate_limit decorator requires fastapi.Request argument') + + +def _client_ip(request: Request) -> str: + xff = request.headers.get('x-forwarded-for') + if xff: + return xff.split(',')[0].strip() + if request.client: + return request.client.host + return 'unknown' + + +_LUA_INCR_EXPIRE_TTL = ''' +local key = KEYS[1] +local window = tonumber(ARGV[1]) + +local current = redis.call('INCR', key) +if current == 1 then + redis.call('EXPIRE', key, window) +end + +local ttl = redis.call('TTL', key) +return { current, ttl } +''' + + +Scope = Literal['ip', 'device', 'user', 'key'] + + +@runtime_checkable +class KeyBuilder1(Protocol): + def __call__(self, request: Request) -> str: ... + + +@runtime_checkable +class KeyBuilder3(Protocol): + def __call__(self, request: Request, args: tuple[Any, ...], kwargs: dict[str, Any]) -> str: ... + + +KeyBuilder = KeyBuilder1 | KeyBuilder3 + + +def _call_key_builder(builder: KeyBuilder, request: Request, args: tuple[Any, ...], kwargs: dict[str, Any]) -> str: + try: + sig = inspect.signature(builder) + if len(sig.parameters) >= 3: + return builder(request, args, kwargs) + return builder(request) + except Exception as e: + try: + return builder(request, args, kwargs) + except Exception: + raise e + +def _email_rl_key(request: Request, args: tuple[Any, ...], kwargs: dict[str, Any]) -> str: + + body = kwargs.get('body') + if body is None and args: + for a in args: + if hasattr(a, 'email'): + body = a + break + + email = (getattr(body, 'email', '') or '').strip().lower() + if not email: + email = _client_ip(request) + + digest = hashlib.sha256(email.encode('utf-8')).hexdigest()[:24] + return f'email:{digest}' + +def rate_limit( + *, + limit: int, + window_seconds: int, + scope: Scope = 'ip', + key_prefix: str = 'rl', + key_builder: Optional[KeyBuilder] = None, + fail_open: bool = True, +) -> Callable[[Callable[..., Awaitable[Any]]], Callable[..., Awaitable[Any]]]: + + if limit <= 0: + raise ValueError('rate_limit: limit must be > 0') + if window_seconds <= 0: + raise ValueError('rate_limit: window_seconds must be > 0') + if scope == 'key' and not key_builder: + raise ValueError('rate_limit: scope="key" requires key_builder') + + def decorator(func: Callable[..., Awaitable[Any]]): + @functools.wraps(func) + async def wrapper(*args: Any, **kwargs: Any): + request = _find_request(args, kwargs) + logger: ILogger = get_logger() + + if scope == 'ip': + ident = _client_ip(request) + elif scope == 'device': + ident = request.cookies.get('device_id') or _client_ip(request) + elif scope == 'user': + user = getattr(request.state, 'user', None) + user_id = getattr(user, 'id', None) if user else None + ident = str(user_id) if user_id else _client_ip(request) + else: + try: + ident = _call_key_builder(key_builder, request, args, kwargs) # type: ignore[arg-type] + except Exception as e: + logger.error(f'RateLimit key_builder failed error={str(e)}') + raise ApplicationException(500, 'Rate limiter key_builder failed') + + route = request.url.path + method = request.method + redis_key = f'{key_prefix}:{scope}:{method}:{route}:{ident}' + + logger.debug(f'RateLimit check key={redis_key} limit={limit} window={window_seconds}') + + try: + redis: Redis = get_redis(request) + + result = await redis.eval( + _LUA_INCR_EXPIRE_TTL, + 1, + redis_key, + str(window_seconds), + ) + + count = int(result[0]) + ttl_raw = int(result[1]) if result and len(result) > 1 else window_seconds + ttl = window_seconds if ttl_raw < 0 else ttl_raw + + except Exception as e: + logger.error(f'RateLimit redis failure key={redis_key} error={str(e)}') + + if fail_open: + logger.warning(f'RateLimit fail-open activated key={redis_key}') + return await func(*args, **kwargs) + + raise ApplicationException(503, 'Rate limiter unavailable') + + if count > limit: + retry_after = max(ttl, 0) + logger.warning(f'RateLimit exceeded key={redis_key} count={count} limit={limit} retry_after={retry_after}') + raise ApplicationException( + status_code=429, + message='Too Many Requests', + headers={'Retry-After': str(retry_after)}, + ) + + logger.debug(f'RateLimit passed key={redis_key} count={count}') + return await func(*args, **kwargs) + + return wrapper + return decorator \ No newline at end of file diff --git a/src/presentation/dependencies/__init__.py b/src/presentation/dependencies/__init__.py new file mode 100644 index 0000000..615c62b --- /dev/null +++ b/src/presentation/dependencies/__init__.py @@ -0,0 +1,16 @@ +from src.presentation.dependencies.commands import ( + get_get_me_command, + get_set_phone_command, + get_set_crypto_wallet_start_command, + get_set_crypto_wallet_complete_command, + get_update_bank_details_start_command, + get_update_bank_details_complete_command, + get_change_password_start_command, + get_change_password_complete_command, + get_change_email_start_command, + get_change_email_confirm_old_command, + get_change_email_complete_command, +) +from src.presentation.dependencies.security import get_jwt_service +from src.presentation.dependencies.cache import get_redis, get_cache +from src.presentation.dependencies.queue_messanger import get_rabbit diff --git a/src/presentation/dependencies/cache.py b/src/presentation/dependencies/cache.py new file mode 100644 index 0000000..fb4fc7a --- /dev/null +++ b/src/presentation/dependencies/cache.py @@ -0,0 +1,12 @@ +from fastapi import Depends, Request +from redis.asyncio.client import Redis +from src.application.contracts import ICache +from src.infrastructure.cache import KeydbCache + + +def get_redis(request: Request) -> Redis: + return request.app.state.redis + + +def get_cache(redis_client: Redis = Depends(get_redis)) -> ICache: + return KeydbCache(redis_client) diff --git a/src/presentation/dependencies/commands.py b/src/presentation/dependencies/commands.py new file mode 100644 index 0000000..1c139b1 --- /dev/null +++ b/src/presentation/dependencies/commands.py @@ -0,0 +1,161 @@ +from fastapi import Depends +from src.application.abstractions import IUnitOfWork +from src.application.commands import GetMeCommand, SetPhoneCommand, SetCryptoWalletStartCommand, SetCryptoWalletCompleteCommand, UpdateBankDetailsStartCommand, UpdateBankDetailsCompleteCommand, ChangePasswordStartCommand, ChangePasswordCompleteCommand, ChangeEmailStartCommand, ChangeEmailConfirmOldCommand, ChangeEmailCompleteCommand +from src.application.contracts import ILogger, ICache, IQueueMessanger, IHashService +from src.presentation.dependencies.cache import get_cache +from src.presentation.dependencies.logger import get_logger +from src.presentation.dependencies.queue_messanger import get_rabbit +from src.presentation.dependencies.security import get_hash_service +from src.presentation.dependencies.unit_of_work import get_unit_of_work + + +def get_get_me_command( + logger: ILogger = Depends(get_logger), + unit_of_work: IUnitOfWork = Depends(get_unit_of_work), + cache: ICache = Depends(get_cache), +) -> GetMeCommand: + return GetMeCommand(logger=logger, unit_of_work=unit_of_work, cache=cache) + + +def get_set_phone_command( + logger: ILogger = Depends(get_logger), + unit_of_work: IUnitOfWork = Depends(get_unit_of_work), + cache: ICache = Depends(get_cache), +) -> SetPhoneCommand: + return SetPhoneCommand(logger=logger, unit_of_work=unit_of_work, cache=cache) + + +def get_set_crypto_wallet_start_command( + logger: ILogger = Depends(get_logger), + unit_of_work: IUnitOfWork = Depends(get_unit_of_work), + cache: ICache = Depends(get_cache), + messanger: IQueueMessanger = Depends(get_rabbit), + hash_service: IHashService = Depends(get_hash_service), +) -> SetCryptoWalletStartCommand: + return SetCryptoWalletStartCommand( + logger=logger, + unit_of_work=unit_of_work, + cache=cache, + messanger=messanger, + hash_service=hash_service, + ) + + +def get_set_crypto_wallet_complete_command( + logger: ILogger = Depends(get_logger), + unit_of_work: IUnitOfWork = Depends(get_unit_of_work), + cache: ICache = Depends(get_cache), + hash_service: IHashService = Depends(get_hash_service), +) -> SetCryptoWalletCompleteCommand: + return SetCryptoWalletCompleteCommand( + logger=logger, + unit_of_work=unit_of_work, + cache=cache, + hash_service=hash_service, + ) + + +def get_change_password_start_command( + logger: ILogger = Depends(get_logger), + unit_of_work: IUnitOfWork = Depends(get_unit_of_work), + cache: ICache = Depends(get_cache), + messanger: IQueueMessanger = Depends(get_rabbit), + hash_service: IHashService = Depends(get_hash_service), +) -> ChangePasswordStartCommand: + return ChangePasswordStartCommand( + logger=logger, + unit_of_work=unit_of_work, + cache=cache, + messanger=messanger, + hash_service=hash_service, + ) + + +def get_change_password_complete_command( + logger: ILogger = Depends(get_logger), + unit_of_work: IUnitOfWork = Depends(get_unit_of_work), + cache: ICache = Depends(get_cache), + hash_service: IHashService = Depends(get_hash_service), +) -> ChangePasswordCompleteCommand: + return ChangePasswordCompleteCommand( + logger=logger, + unit_of_work=unit_of_work, + cache=cache, + hash_service=hash_service, + ) + + +def get_change_email_start_command( + logger: ILogger = Depends(get_logger), + unit_of_work: IUnitOfWork = Depends(get_unit_of_work), + cache: ICache = Depends(get_cache), + messanger: IQueueMessanger = Depends(get_rabbit), + hash_service: IHashService = Depends(get_hash_service), +) -> ChangeEmailStartCommand: + return ChangeEmailStartCommand( + logger=logger, + unit_of_work=unit_of_work, + cache=cache, + messanger=messanger, + hash_service=hash_service, + ) + + +def get_change_email_confirm_old_command( + logger: ILogger = Depends(get_logger), + unit_of_work: IUnitOfWork = Depends(get_unit_of_work), + cache: ICache = Depends(get_cache), + messanger: IQueueMessanger = Depends(get_rabbit), + hash_service: IHashService = Depends(get_hash_service), +) -> ChangeEmailConfirmOldCommand: + return ChangeEmailConfirmOldCommand( + logger=logger, + unit_of_work=unit_of_work, + cache=cache, + messanger=messanger, + hash_service=hash_service, + ) + + +def get_change_email_complete_command( + logger: ILogger = Depends(get_logger), + unit_of_work: IUnitOfWork = Depends(get_unit_of_work), + cache: ICache = Depends(get_cache), + hash_service: IHashService = Depends(get_hash_service), +) -> ChangeEmailCompleteCommand: + return ChangeEmailCompleteCommand( + logger=logger, + unit_of_work=unit_of_work, + cache=cache, + hash_service=hash_service, + ) + + +def get_update_bank_details_start_command( + logger: ILogger = Depends(get_logger), + unit_of_work: IUnitOfWork = Depends(get_unit_of_work), + cache: ICache = Depends(get_cache), + messanger: IQueueMessanger = Depends(get_rabbit), + hash_service: IHashService = Depends(get_hash_service), +) -> UpdateBankDetailsStartCommand: + return UpdateBankDetailsStartCommand( + logger=logger, + unit_of_work=unit_of_work, + cache=cache, + messanger=messanger, + hash_service=hash_service, + ) + + +def get_update_bank_details_complete_command( + logger: ILogger = Depends(get_logger), + unit_of_work: IUnitOfWork = Depends(get_unit_of_work), + cache: ICache = Depends(get_cache), + hash_service: IHashService = Depends(get_hash_service), +) -> UpdateBankDetailsCompleteCommand: + return UpdateBankDetailsCompleteCommand( + logger=logger, + unit_of_work=unit_of_work, + cache=cache, + hash_service=hash_service, + ) diff --git a/src/presentation/dependencies/logger.py b/src/presentation/dependencies/logger.py new file mode 100644 index 0000000..3c95f84 --- /dev/null +++ b/src/presentation/dependencies/logger.py @@ -0,0 +1,7 @@ +from functools import lru_cache +from src.application.contracts import ILogger +from src.infrastructure.logger import logger + +@lru_cache +def get_logger() -> ILogger: + return logger \ No newline at end of file diff --git a/src/presentation/dependencies/queue_messanger.py b/src/presentation/dependencies/queue_messanger.py new file mode 100644 index 0000000..87a2d3a --- /dev/null +++ b/src/presentation/dependencies/queue_messanger.py @@ -0,0 +1,8 @@ +from functools import lru_cache +from src.application.contracts import IQueueMessanger +from src.infrastructure.messanger import RabbitClient + + +@lru_cache(maxsize=1) +def get_rabbit() -> IQueueMessanger: + return RabbitClient() diff --git a/src/presentation/dependencies/security.py b/src/presentation/dependencies/security.py new file mode 100644 index 0000000..597faf0 --- /dev/null +++ b/src/presentation/dependencies/security.py @@ -0,0 +1,25 @@ +from functools import lru_cache +from fastapi import Depends +from src.application.contracts import IJwtService, ILogger, IHashService +from src.infrastructure.security import JwtService, HashService +from src.infrastructure.vault import JwtKeyStore +from src.presentation.dependencies.logger import get_logger + + +@lru_cache(maxsize=1) +def _hash_service(logger: ILogger) -> IHashService: + return HashService(logger=logger) + + +def get_hash_service(logger: ILogger = Depends(get_logger)) -> IHashService: + return _hash_service(logger) + + +@lru_cache(maxsize=1) +def _jwt_service(logger: ILogger) -> IJwtService: + key_store = JwtKeyStore.get_instance() + return JwtService(logger=logger, key_store=key_store) + + +def get_jwt_service(logger: ILogger = Depends(get_logger)) -> IJwtService: + return _jwt_service(logger) \ No newline at end of file diff --git a/src/presentation/dependencies/unit_of_work.py b/src/presentation/dependencies/unit_of_work.py new file mode 100644 index 0000000..5629bd4 --- /dev/null +++ b/src/presentation/dependencies/unit_of_work.py @@ -0,0 +1,10 @@ +from fastapi import Depends +from src.application.abstractions import IUnitOfWork +from src.application.contracts import ILogger +from src.infrastructure.database import UnitOfWork +from src.infrastructure.database.context import async_session_maker +from src.infrastructure.logger import get_logger + + +def get_unit_of_work(logger: ILogger = Depends(get_logger)) -> IUnitOfWork: + return UnitOfWork(session_factory=async_session_maker, logger=logger) \ No newline at end of file diff --git a/src/presentation/handlers/__init__.py b/src/presentation/handlers/__init__.py new file mode 100644 index 0000000..cb6cbad --- /dev/null +++ b/src/presentation/handlers/__init__.py @@ -0,0 +1,2 @@ +from src.presentation.handlers.unhandled_handler import unhandled_exception_handler +from src.presentation.handlers.application_handler import application_exception_handler \ No newline at end of file diff --git a/src/presentation/handlers/application_handler.py b/src/presentation/handlers/application_handler.py new file mode 100644 index 0000000..aa68716 --- /dev/null +++ b/src/presentation/handlers/application_handler.py @@ -0,0 +1,17 @@ +from fastapi.responses import ORJSONResponse +from fastapi import Request +from src.application.domain.exceptions import ApplicationException + + +async def application_exception_handler(_request: Request, exc: ApplicationException) -> ORJSONResponse: + detail = exc.message + if 500 <= exc.status_code: + detail = "Internal Server Error" + + return ORJSONResponse( + status_code=exc.status_code, + content={"detail": detail}, + headers=dict(exc.headers) if exc.headers else None, + ) + + diff --git a/src/presentation/handlers/unhandled_handler.py b/src/presentation/handlers/unhandled_handler.py new file mode 100644 index 0000000..c6f1d52 --- /dev/null +++ b/src/presentation/handlers/unhandled_handler.py @@ -0,0 +1,12 @@ +from fastapi.responses import ORJSONResponse +from fastapi import Request +from starlette import status +from src.infrastructure.logger import logger + + +async def unhandled_exception_handler(_request: Request, exc: Exception) -> ORJSONResponse: + logger.exception(f'Unhandled exception: {type(exc).__name__}') + return ORJSONResponse( + status_code=status.HTTP_500_INTERNAL_SERVER_ERROR, + content={'detail': 'Internal Server Error'}, + ) \ No newline at end of file diff --git a/src/presentation/middleware/__init__.py b/src/presentation/middleware/__init__.py new file mode 100644 index 0000000..50faccd --- /dev/null +++ b/src/presentation/middleware/__init__.py @@ -0,0 +1,2 @@ +from src.presentation.middleware.trace_id import TraceIDMiddleware +from src.presentation.middleware.security_headers import SecurityHeadersMiddleware \ No newline at end of file diff --git a/src/presentation/middleware/security_headers.py b/src/presentation/middleware/security_headers.py new file mode 100644 index 0000000..7cd0387 --- /dev/null +++ b/src/presentation/middleware/security_headers.py @@ -0,0 +1,51 @@ +from starlette.middleware.base import BaseHTTPMiddleware +from starlette.requests import Request +from starlette.responses import Response + + +class SecurityHeadersMiddleware(BaseHTTPMiddleware): + def __init__( + self, + app, + *, + hsts: bool = True, + hsts_max_age: int = 31536000, # 1 год + hsts_include_subdomains: bool = True, + hsts_preload: bool = False, + frame_options: str = 'DENY', # или 'SAMEORIGIN' + referrer_policy: str = 'strict-origin-when-cross-origin', + content_security_policy: str | None = None, + ): + super().__init__(app) + self.hsts = hsts + self.hsts_max_age = hsts_max_age + self.hsts_include_subdomains = hsts_include_subdomains + self.hsts_preload = hsts_preload + self.frame_options = frame_options + self.referrer_policy = referrer_policy + self.csp = content_security_policy + + async def dispatch(self, request: Request, call_next) -> Response: + response: Response = await call_next(request) + + if request.url.path in ('/docs', '/redoc', '/openapi.json'): + return response + + if self.hsts and request.url.scheme == 'https': + hsts = f'max-age={self.hsts_max_age}' + if self.hsts_include_subdomains: + hsts += '; includeSubDomains' + if self.hsts_preload: + hsts += '; preload' + response.headers['Strict-Transport-Security'] = hsts + + response.headers['X-Content-Type-Options'] = 'nosniff' + + response.headers['X-Frame-Options'] = self.frame_options + + response.headers['Referrer-Policy'] = self.referrer_policy + + if self.csp: + response.headers['Content-Security-Policy'] = self.csp + + return response diff --git a/src/presentation/middleware/trace_id.py b/src/presentation/middleware/trace_id.py new file mode 100644 index 0000000..8abd8e3 --- /dev/null +++ b/src/presentation/middleware/trace_id.py @@ -0,0 +1,135 @@ +from __future__ import annotations +from typing import Optional +from contextvars import Token +from starlette.requests import Request +from starlette.types import ASGIApp, Message, Receive, Scope, Send +from ulid import ULID +from src.application.contracts import ILogger +from src.infrastructure.config import settings +from src.infrastructure.context_vars import trace_id_var + + +class TraceIDMiddleware: + def __init__( + self, + app: ASGIApp, + logger: ILogger, + response_header_name: str = "X-Trace-ID", + attach_response_header: bool = True, + ) -> None: + self.app = app + self.logger = logger + self.response_header_name = response_header_name + self.attach_response_header = attach_response_header + + def _is_excluded(self, path: str) -> bool: + return any(path == p or path.startswith(p.rstrip("/") + "/") for p in settings.EXCLUDED_PATHS) + + async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None: + if scope["type"] != "http": + await self.app(scope, receive, send) + return + + request = Request(scope) + + if self._is_excluded(request.url.path): + await self.app(scope, receive, send) + return + + trace_id = request.headers.get("X-Trace-ID") or request.headers.get("X-Request-ID") + if not trace_id: + trace_id = str(ULID()) + + request.state.trace_id = trace_id + + token: Token = trace_id_var.set(trace_id) + + self.logger.debug(f"Request started: {request.method} {request.url} - TraceID: {trace_id}") + + status_code_holder: dict[str, Optional[int]] = {"status": None} + + async def send_wrapper(message: Message) -> None: + if message["type"] == "http.response.start": + status_code_holder["status"] = int(message["status"]) + + if self.attach_response_header: + headers = list(message.get("headers", [])) + headers.append((self.response_header_name.lower().encode(), trace_id.encode())) + message["headers"] = headers + await send(message) + + try: + await self.app(scope, receive, send_wrapper) + finally: + status = status_code_holder["status"] + status_part = f"{status}" if status is not None else "unknown" + self.logger.debug( + f"Request finished: {request.method} {request.url} - TraceID: {trace_id} - Status: {status_part}" + ) + trace_id_var.reset(token) + + +# from __future__ import annotations +# from typing import Optional +# from starlette.requests import Request +# from starlette.types import ASGIApp, Message, Receive, Scope, Send +# from ulid import ULID +# from src.application.contracts import ILogger +# from src.infrastructure.config.settings import settings +# +# +# class TraceIDMiddleware: +# def __init__( +# self, +# app: ASGIApp, +# logger: ILogger, +# response_header_name: str = 'X-Trace-ID', +# attach_response_header: bool = True, +# ) -> None: +# self.app = app +# self.logger = logger +# self.response_header_name = response_header_name +# self.attach_response_header = attach_response_header +# +# def _is_excluded(self, path: str) -> bool: +# return any(path == p or path.startswith(p.rstrip('/') + '/') for p in settings.EXCLUDED_PATHS) +# +# async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None: +# if scope['type'] != 'http': +# await self.app(scope, receive, send) +# return +# +# request = Request(scope) +# +# if self._is_excluded(request.url.path): +# await self.app(scope, receive, send) +# return +# +# trace_id = request.headers.get('X-Trace-ID') or request.headers.get('X-Request-ID') +# if not trace_id: +# trace_id = str(ULID()) +# +# request.state.trace_id = trace_id +# self.logger.set_trace_id(trace_id) +# +# self.logger.debug(f'Request started: {request.method} {request.url} - TraceID: {trace_id}') +# +# status_code_holder: dict[str, Optional[int]] = {'status': None} +# +# async def send_wrapper(message: Message) -> None: +# if message['type'] == 'http.response.start': +# status_code_holder['status'] = int(message['status']) +# +# if self.attach_response_header: +# headers = list(message.get('headers', [])) +# headers.append((self.response_header_name.lower().encode(), trace_id.encode())) +# message['headers'] = headers +# await send(message) +# +# try: +# await self.app(scope, receive, send_wrapper) +# finally: +# status = status_code_holder['status'] +# status_part = f'{status}' if status is not None else 'unknown' +# self.logger.debug(f'Request finished: {request.method} {request.url} - TraceID: {trace_id} - Status: {status_part}') +# self.logger.clear_trace_id() diff --git a/src/presentation/routing/__init__.py b/src/presentation/routing/__init__.py new file mode 100644 index 0000000..b151a36 --- /dev/null +++ b/src/presentation/routing/__init__.py @@ -0,0 +1,18 @@ +from fastapi import APIRouter +from src.presentation.routing.account import account_router + + +me_router = APIRouter(prefix='/me', tags=['Account']) + +me_router.include_router(account_router) + +# from src.presentation.routing.account_settings import account_settings_router +# me_router.include_router(account_settings_router) + +# from src.presentation.routing.devices import devices_router +# me_devices_router = APIRouter(prefix='/me', tags=['Devices']) +# me_devices_router.include_router(devices_router) + +# from src.presentation.routing.deals import deals_router +# me_deals_router = APIRouter(prefix='/me', tags=['Deals']) +# me_deals_router.include_router(deals_router) diff --git a/src/presentation/routing/account.py b/src/presentation/routing/account.py new file mode 100644 index 0000000..61e056c --- /dev/null +++ b/src/presentation/routing/account.py @@ -0,0 +1,43 @@ +from fastapi import APIRouter, Request, Depends +from fastapi.responses import ORJSONResponse +from starlette import status +from src.application.commands.get_me import GetMeCommand +from src.application.contracts import ILogger +from src.application.domain.dto import AuthContext +from src.presentation.decorators import require_access_token +from src.presentation.dependencies.commands import get_get_me_command +from src.presentation.dependencies.logger import get_logger + +account_router = APIRouter() + +@account_router.get(path='/', response_class=ORJSONResponse, status_code=status.HTTP_200_OK) +async def me( + request: Request, + auth: AuthContext = Depends(require_access_token), + command: GetMeCommand = Depends(get_get_me_command), + logger: ILogger = Depends(get_logger), +): + user = await command(user_id=auth.user_id) + logger.info(f'Get user: {user.id}') + return ORJSONResponse( + status_code=status.HTTP_200_OK, + content={ + 'id': user.id, + 'email': user.email, + 'first_name': user.first_name, + 'middle_name': user.middle_name, + 'last_name': user.last_name, + 'birth_date': str(user.birth_date) if user.birth_date else None, + 'crypto_wallet': user.crypto_wallet, + 'phone': user.phone, + 'bik': user.bik, + 'account_number': user.account_number, + 'card_number': user.card_number, + 'inn': user.inn, + 'kyc_verified': user.kyc_verified, + 'is_deleted': user.is_deleted, + 'created_at': user.created_at.isoformat() if user.created_at else None, + 'updated_at': user.updated_at.isoformat() if user.updated_at else None, + 'kyc_verified_at': user.kyc_verified_at.isoformat() if user.kyc_verified_at else None, + } + ) diff --git a/src/presentation/routing/account_settings.py b/src/presentation/routing/account_settings.py new file mode 100644 index 0000000..38c4d8f --- /dev/null +++ b/src/presentation/routing/account_settings.py @@ -0,0 +1,150 @@ +from fastapi import APIRouter, Request, Depends +from fastapi.responses import ORJSONResponse +from starlette import status +from src.application.commands import SetPhoneCommand, SetCryptoWalletStartCommand, SetCryptoWalletCompleteCommand, UpdateBankDetailsStartCommand, UpdateBankDetailsCompleteCommand, ChangePasswordStartCommand, ChangePasswordCompleteCommand, ChangeEmailStartCommand, ChangeEmailConfirmOldCommand, ChangeEmailCompleteCommand +from src.application.domain.dto import AuthContext +from src.presentation.decorators import require_access_token +from src.presentation.dependencies import ( + get_set_phone_command, + get_set_crypto_wallet_start_command, + get_set_crypto_wallet_complete_command, + get_update_bank_details_start_command, + get_update_bank_details_complete_command, + get_change_password_start_command, + get_change_password_complete_command, + get_change_email_start_command, + get_change_email_confirm_old_command, + get_change_email_complete_command, +) +from src.presentation.schemas import SetPhoneRequest, CryptoWalletConfirmRequest, BankConfirmRequest, ChangePasswordConfirmRequest, ChangeEmailConfirmOldRequest, ChangeEmailCompleteRequest + + +account_settings_router = APIRouter(prefix='/settings') + + +@account_settings_router.patch(path='/phone', response_class=ORJSONResponse, status_code=status.HTTP_200_OK) +async def set_phone( + request: Request, + body: SetPhoneRequest, + auth: AuthContext = Depends(require_access_token), + command: SetPhoneCommand = Depends(get_set_phone_command), +): + user = await command(user_id=auth.user_id, phone=body.phone) + return ORJSONResponse(status_code=status.HTTP_200_OK, content={'phone': user.phone}) + + +@account_settings_router.post(path='/crypto-wallet/start', response_class=ORJSONResponse, status_code=status.HTTP_200_OK) +async def crypto_wallet_start( + request: Request, + auth: AuthContext = Depends(require_access_token), + command: SetCryptoWalletStartCommand = Depends(get_set_crypto_wallet_start_command), +): + result = await command(user_id=auth.user_id) + return {'success': result} + + +@account_settings_router.post(path='/crypto-wallet/complete', response_class=ORJSONResponse, status_code=status.HTTP_200_OK) +async def crypto_wallet_complete( + request: Request, + body: CryptoWalletConfirmRequest, + auth: AuthContext = Depends(require_access_token), + command: SetCryptoWalletCompleteCommand = Depends(get_set_crypto_wallet_complete_command), +): + user = await command( + user_id=auth.user_id, + code=body.code, + wallet_address=body.wallet_address, + ) + return {'crypto_wallet': user.crypto_wallet} + + +@account_settings_router.post(path='/email/start', response_class=ORJSONResponse, status_code=status.HTTP_200_OK) +async def change_email_start( + request: Request, + auth: AuthContext = Depends(require_access_token), + command: ChangeEmailStartCommand = Depends(get_change_email_start_command), +): + result = await command(user_id=auth.user_id) + return {'success': result} + + +@account_settings_router.post(path='/email/confirm-old', response_class=ORJSONResponse, status_code=status.HTTP_200_OK) +async def change_email_confirm_old( + request: Request, + body: ChangeEmailConfirmOldRequest, + auth: AuthContext = Depends(require_access_token), + command: ChangeEmailConfirmOldCommand = Depends(get_change_email_confirm_old_command), +): + result = await command(user_id=auth.user_id, code=body.code, new_email=body.new_email) + return {'success': result} + + +@account_settings_router.post(path='/email/complete', response_class=ORJSONResponse, status_code=status.HTTP_200_OK) +async def change_email_complete( + request: Request, + body: ChangeEmailCompleteRequest, + auth: AuthContext = Depends(require_access_token), + command: ChangeEmailCompleteCommand = Depends(get_change_email_complete_command), +): + result = await command(user_id=auth.user_id, code=body.code) + return {'success': result} + + +@account_settings_router.post(path='/password/start', response_class=ORJSONResponse, status_code=status.HTTP_200_OK) +async def change_password_start( + request: Request, + auth: AuthContext = Depends(require_access_token), + command: ChangePasswordStartCommand = Depends(get_change_password_start_command), +): + result = await command(user_id=auth.user_id) + return {'success': result} + + +@account_settings_router.post(path='/password/complete', response_class=ORJSONResponse, status_code=status.HTTP_200_OK) +async def change_password_complete( + request: Request, + body: ChangePasswordConfirmRequest, + auth: AuthContext = Depends(require_access_token), + command: ChangePasswordCompleteCommand = Depends(get_change_password_complete_command), +): + result = await command( + user_id=auth.user_id, + code=body.code, + new_password=body.new_password, + confirm_password=body.confirm_password, + ) + return {'success': result} + + +@account_settings_router.post(path='/bank/start', response_class=ORJSONResponse, status_code=status.HTTP_200_OK) +async def bank_details_start( + request: Request, + auth: AuthContext = Depends(require_access_token), + command: UpdateBankDetailsStartCommand = Depends(get_update_bank_details_start_command), +): + result = await command(user_id=auth.user_id) + return {'success': result} + + +@account_settings_router.post(path='/bank/complete', response_class=ORJSONResponse, status_code=status.HTTP_200_OK) +async def bank_details_complete( + request: Request, + body: BankConfirmRequest, + auth: AuthContext = Depends(require_access_token), + command: UpdateBankDetailsCompleteCommand = Depends(get_update_bank_details_complete_command), +): + user = await command( + user_id=auth.user_id, + code=body.code, + bik=body.bik, + account_number=body.account_number, + card_number=body.card_number, + ) + return ORJSONResponse( + status_code=status.HTTP_200_OK, + content={ + 'bik': user.bik, + 'account_number': user.account_number, + 'card_number': user.card_number, + }, + ) diff --git a/src/presentation/routing/deals.py b/src/presentation/routing/deals.py new file mode 100644 index 0000000..1a77b6e --- /dev/null +++ b/src/presentation/routing/deals.py @@ -0,0 +1,7 @@ +from fastapi import APIRouter + +deals_router = APIRouter(prefix='/deals') + +@deals_router.get(path='') +async def deals(): + pass diff --git a/src/presentation/routing/devices.py b/src/presentation/routing/devices.py new file mode 100644 index 0000000..b2aa203 --- /dev/null +++ b/src/presentation/routing/devices.py @@ -0,0 +1,11 @@ +from fastapi import APIRouter, Request +from fastapi.responses import ORJSONResponse +from starlette import status + +devices_router = APIRouter(prefix='/devices') + +@devices_router.get(path='/', response_class=ORJSONResponse, status_code=status.HTTP_200_OK) +async def devices( + request: Request, +): + pass diff --git a/src/presentation/schemas/__init__.py b/src/presentation/schemas/__init__.py new file mode 100644 index 0000000..b3a1cc2 --- /dev/null +++ b/src/presentation/schemas/__init__.py @@ -0,0 +1,5 @@ +from src.presentation.schemas.phone import SetPhoneRequest +from src.presentation.schemas.bank import BankUpdateRequest, BankConfirmRequest +from src.presentation.schemas.crypto_wallet import CryptoWalletConfirmRequest +from src.presentation.schemas.password import ChangePasswordConfirmRequest +from src.presentation.schemas.email import ChangeEmailConfirmOldRequest, ChangeEmailCompleteRequest \ No newline at end of file diff --git a/src/presentation/schemas/bank.py b/src/presentation/schemas/bank.py new file mode 100644 index 0000000..04fa5fb --- /dev/null +++ b/src/presentation/schemas/bank.py @@ -0,0 +1,110 @@ +import re +from typing import Self +from pydantic import BaseModel, field_validator, model_validator + + +class BankUpdateRequest(BaseModel): + bik: str | None = None + account_number: str | None = None + card_number: str | None = None + + @model_validator(mode='after') + def at_least_one(self) -> Self: + if not any([self.bik, self.account_number, self.card_number]): + raise ValueError('At least one field is required') + return self + + @field_validator('bik') + @classmethod + def validate_bik(cls, v: str | None) -> str | None: + if v is None: + return None + v = v.strip() + if not re.match(r'^\d{9}$', v): + raise ValueError('BIK must be exactly 9 digits') + return v + + @field_validator('account_number') + @classmethod + def validate_account_number(cls, v: str | None) -> str | None: + if v is None: + return None + v = v.strip() + if not re.match(r'^\d{20}$', v): + raise ValueError('Account number must be exactly 20 digits') + return v + + @field_validator('card_number') + @classmethod + def validate_card_number(cls, v: str | None) -> str | None: + if v is None: + return None + v = re.sub(r'[\s\-]', '', v) + if not re.match(r'^\d{13,19}$', v): + raise ValueError('Card number must be 13-19 digits') + if not cls._luhn_check(v): + raise ValueError('Invalid card number (Luhn check failed)') + return v + + @staticmethod + def _luhn_check(number: str) -> bool: + digits = [int(d) for d in number] + odd_digits = digits[-1::-2] + even_digits = digits[-2::-2] + total = sum(odd_digits) + for d in even_digits: + total += sum(divmod(d * 2, 10)) + return total % 10 == 0 + + +class BankConfirmRequest(BaseModel): + code: str + bik: str | None = None + account_number: str | None = None + card_number: str | None = None + + @model_validator(mode='after') + def at_least_one_field(self) -> Self: + if not any([self.bik, self.account_number, self.card_number]): + raise ValueError('At least one bank field is required') + return self + + @field_validator('code') + @classmethod + def validate_code(cls, v: str) -> str: + v = v.strip() + if not re.match(r'^\d{6}$', v): + raise ValueError('Code must be exactly 6 digits') + return v + + @field_validator('bik') + @classmethod + def validate_bik(cls, v: str | None) -> str | None: + if v is None: + return None + v = v.strip() + if not re.match(r'^\d{9}$', v): + raise ValueError('BIK must be exactly 9 digits') + return v + + @field_validator('account_number') + @classmethod + def validate_account_number(cls, v: str | None) -> str | None: + if v is None: + return None + v = v.strip() + if not re.match(r'^\d{20}$', v): + raise ValueError('Account number must be exactly 20 digits') + return v + + @field_validator('card_number') + @classmethod + def validate_card_number(cls, v: str | None) -> str | None: + if v is None: + return None + v = re.sub(r'[\s\-]', '', v) + if not re.match(r'^\d{13,19}$', v): + raise ValueError('Card number must be 13-19 digits') + if not BankUpdateRequest._luhn_check(v): + raise ValueError('Invalid card number (Luhn check failed)') + return v diff --git a/src/presentation/schemas/crypto_wallet.py b/src/presentation/schemas/crypto_wallet.py new file mode 100644 index 0000000..e50d133 --- /dev/null +++ b/src/presentation/schemas/crypto_wallet.py @@ -0,0 +1,23 @@ +import re +from pydantic import BaseModel, field_validator + + +class CryptoWalletConfirmRequest(BaseModel): + code: str + wallet_address: str + + @field_validator('code') + @classmethod + def validate_code(cls, v: str) -> str: + v = v.strip() + if not re.match(r'^\d{6}$', v): + raise ValueError('Code must be exactly 6 digits') + return v + + @field_validator('wallet_address') + @classmethod + def validate_tron_address(cls, v: str) -> str: + v = v.strip() + if not re.match(r'^T[1-9A-HJ-NP-Za-km-z]{33}$', v): + raise ValueError('Invalid TRON wallet address') + return v diff --git a/src/presentation/schemas/email.py b/src/presentation/schemas/email.py new file mode 100644 index 0000000..30e0874 --- /dev/null +++ b/src/presentation/schemas/email.py @@ -0,0 +1,35 @@ +import re +from pydantic import BaseModel, field_validator + + +class ChangeEmailConfirmOldRequest(BaseModel): + code: str + new_email: str + + @field_validator('code') + @classmethod + def validate_code(cls, v: str) -> str: + v = v.strip() + if not re.match(r'^\d{6}$', v): + raise ValueError('Code must be exactly 6 digits') + return v + + @field_validator('new_email') + @classmethod + def validate_new_email(cls, v: str) -> str: + v = v.strip().lower() + if not re.match(r'^[^@\s]+@[^@\s]+\.[^@\s]+$', v): + raise ValueError('Invalid email address') + return v + + +class ChangeEmailCompleteRequest(BaseModel): + code: str + + @field_validator('code') + @classmethod + def validate_code(cls, v: str) -> str: + v = v.strip() + if not re.match(r'^\d{6}$', v): + raise ValueError('Code must be exactly 6 digits') + return v diff --git a/src/presentation/schemas/password.py b/src/presentation/schemas/password.py new file mode 100644 index 0000000..5e431dc --- /dev/null +++ b/src/presentation/schemas/password.py @@ -0,0 +1,30 @@ +import re +from typing import Self +from pydantic import BaseModel, field_validator, model_validator + + +class ChangePasswordConfirmRequest(BaseModel): + code: str + new_password: str + confirm_password: str + + @model_validator(mode='after') + def passwords_match(self) -> Self: + if self.new_password != self.confirm_password: + raise ValueError('Passwords do not match') + return self + + @field_validator('code') + @classmethod + def validate_code(cls, v: str) -> str: + v = v.strip() + if not re.match(r'^\d{6}$', v): + raise ValueError('Code must be exactly 6 digits') + return v + + @field_validator('new_password') + @classmethod + def validate_new_password(cls, v: str) -> str: + if len(v) < 8: + raise ValueError('Password must be at least 8 characters') + return v diff --git a/src/presentation/schemas/phone.py b/src/presentation/schemas/phone.py new file mode 100644 index 0000000..40b94f7 --- /dev/null +++ b/src/presentation/schemas/phone.py @@ -0,0 +1,17 @@ +import re +from pydantic import BaseModel, field_validator +from src.application.domain.exceptions import ApplicationException + + +class SetPhoneRequest(BaseModel): + phone: str + + @field_validator('phone') + @classmethod + def validate_russian_phone(cls, v: str) -> str: + cleaned = re.sub(r'[\s\-\(\)]', '', v) + pattern = r'^(\+7|8)\d{10}$' + if not re.match(pattern, cleaned): + raise ApplicationException(message='Invalid Russian phone number', status_code=429) + normalized = '+7' + cleaned[-10:] + return normalized \ No newline at end of file diff --git a/uv.lock b/uv.lock new file mode 100644 index 0000000..f6d2a27 --- /dev/null +++ b/uv.lock @@ -0,0 +1,725 @@ +version = 1 +revision = 3 +requires-python = "==3.12.*" + +[[package]] +name = "aio-pika" +version = "9.6.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "aiormq" }, + { name = "yarl" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/0e/3e/8e8513214ed7ceed6bad8b71f7fe196d54ef2277c135bf7960ed715d4227/aio_pika-9.6.1.tar.gz", hash = "sha256:7a130c51a413cfcd04c3322f6a0ab08c38eb9918de1e476f6d34bbf41fc8d2b0", size = 66809, upload-time = "2026-02-23T15:41:52.544Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/2b/24/59a1644995f7a0245588a1761d4b515fc63b7a6038310ead2b07eb44cd8b/aio_pika-9.6.1-py3-none-any.whl", hash = "sha256:0fda50fbbdeb6c5b7399730a2286751074dfe6e52a20119a71aef112d4863fd1", size = 52022, upload-time = "2026-02-23T15:41:51.357Z" }, +] + +[[package]] +name = "aiormq" +version = "6.9.3" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "pamqp" }, + { name = "yarl" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/a2/b0/85cb8066acc2df8166f743bdcd793e7179f473a7db746a543bcd40fdac7b/aiormq-6.9.3.tar.gz", hash = "sha256:39f57d85650267aebefca162a523e9e000db02468d4fceccb3c5399f378ddabe", size = 45672, upload-time = "2026-02-22T21:04:49.745Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/70/9b/be86ea5a73010b437bb5f9511d1fcbb828cdf8eddde0c6f2b38006b9ce92/aiormq-6.9.3-py3-none-any.whl", hash = "sha256:fe2e9f7c99d24dde5f7e1ca8a7da2dc5bab9ae5758fd7599b60d34b6b278926e", size = 27939, upload-time = "2026-02-22T21:04:48.208Z" }, +] + +[[package]] +name = "annotated-doc" +version = "0.0.4" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/57/ba/046ceea27344560984e26a590f90bc7f4a75b06701f653222458922b558c/annotated_doc-0.0.4.tar.gz", hash = "sha256:fbcda96e87e9c92ad167c2e53839e57503ecfda18804ea28102353485033faa4", size = 7288, upload-time = "2025-11-10T22:07:42.062Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/1e/d3/26bf1008eb3d2daa8ef4cacc7f3bfdc11818d111f7e2d0201bc6e3b49d45/annotated_doc-0.0.4-py3-none-any.whl", hash = "sha256:571ac1dc6991c450b25a9c2d84a3705e2ae7a53467b5d111c24fa8baabbed320", size = 5303, upload-time = "2025-11-10T22:07:40.673Z" }, +] + +[[package]] +name = "annotated-types" +version = "0.7.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/ee/67/531ea369ba64dcff5ec9c3402f9f51bf748cec26dde048a2f973a4eea7f5/annotated_types-0.7.0.tar.gz", hash = "sha256:aff07c09a53a08bc8cfccb9c85b05f1aa9a2a6f23728d790723543408344ce89", size = 16081, upload-time = "2024-05-20T21:33:25.928Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/78/b6/6307fbef88d9b5ee7421e68d78a9f162e0da4900bc5f5793f6d3d0e34fb8/annotated_types-0.7.0-py3-none-any.whl", hash = "sha256:1f02e8b43a8fbbc3f3e0d4f0f4bfc8131bcb4eebe8849b8e5c773f3a1c582a53", size = 13643, upload-time = "2024-05-20T21:33:24.1Z" }, +] + +[[package]] +name = "anyio" +version = "4.12.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "idna" }, + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/96/f0/5eb65b2bb0d09ac6776f2eb54adee6abe8228ea05b20a5ad0e4945de8aac/anyio-4.12.1.tar.gz", hash = "sha256:41cfcc3a4c85d3f05c932da7c26d0201ac36f72abd4435ba90d0464a3ffed703", size = 228685, upload-time = "2026-01-06T11:45:21.246Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/38/0e/27be9fdef66e72d64c0cdc3cc2823101b80585f8119b5c112c2e8f5f7dab/anyio-4.12.1-py3-none-any.whl", hash = "sha256:d405828884fc140aa80a3c667b8beed277f1dfedec42ba031bd6ac3db606ab6c", size = 113592, upload-time = "2026-01-06T11:45:19.497Z" }, +] + +[[package]] +name = "apscheduler" +version = "3.11.2" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "tzlocal" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/07/12/3e4389e5920b4c1763390c6d371162f3784f86f85cd6d6c1bfe68eef14e2/apscheduler-3.11.2.tar.gz", hash = "sha256:2a9966b052ec805f020c8c4c3ae6e6a06e24b1bf19f2e11d91d8cca0473eef41", size = 108683, upload-time = "2025-12-22T00:39:34.884Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/9f/64/2e54428beba8d9992aa478bb8f6de9e4ecaa5f8f513bcfd567ed7fb0262d/apscheduler-3.11.2-py3-none-any.whl", hash = "sha256:ce005177f741409db4e4dd40a7431b76feb856b9dd69d57e0da49d6715bfd26d", size = 64439, upload-time = "2025-12-22T00:39:33.303Z" }, +] + +[[package]] +name = "asyncpg" +version = "0.31.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/fe/cc/d18065ce2380d80b1bcce927c24a2642efd38918e33fd724bc4bca904877/asyncpg-0.31.0.tar.gz", hash = "sha256:c989386c83940bfbd787180f2b1519415e2d3d6277a70d9d0f0145ac73500735", size = 993667, upload-time = "2025-11-24T23:27:00.812Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/2a/a6/59d0a146e61d20e18db7396583242e32e0f120693b67a8de43f1557033e2/asyncpg-0.31.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:b44c31e1efc1c15188ef183f287c728e2046abb1d26af4d20858215d50d91fad", size = 662042, upload-time = "2025-11-24T23:25:49.578Z" }, + { url = "https://files.pythonhosted.org/packages/36/01/ffaa189dcb63a2471720615e60185c3f6327716fdc0fc04334436fbb7c65/asyncpg-0.31.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:0c89ccf741c067614c9b5fc7f1fc6f3b61ab05ae4aaa966e6fd6b93097c7d20d", size = 638504, upload-time = "2025-11-24T23:25:51.501Z" }, + { url = "https://files.pythonhosted.org/packages/9f/62/3f699ba45d8bd24c5d65392190d19656d74ff0185f42e19d0bbd973bb371/asyncpg-0.31.0-cp312-cp312-manylinux_2_28_aarch64.whl", hash = "sha256:12b3b2e39dc5470abd5e98c8d3373e4b1d1234d9fbdedf538798b2c13c64460a", size = 3426241, upload-time = "2025-11-24T23:25:53.278Z" }, + { url = "https://files.pythonhosted.org/packages/8c/d1/a867c2150f9c6e7af6462637f613ba67f78a314b00db220cd26ff559d532/asyncpg-0.31.0-cp312-cp312-manylinux_2_28_x86_64.whl", hash = "sha256:aad7a33913fb8bcb5454313377cc330fbb19a0cd5faa7272407d8a0c4257b671", size = 3520321, upload-time = "2025-11-24T23:25:54.982Z" }, + { url = "https://files.pythonhosted.org/packages/7a/1a/cce4c3f246805ecd285a3591222a2611141f1669d002163abef999b60f98/asyncpg-0.31.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:3df118d94f46d85b2e434fd62c84cb66d5834d5a890725fe625f498e72e4d5ec", size = 3316685, upload-time = "2025-11-24T23:25:57.43Z" }, + { url = "https://files.pythonhosted.org/packages/40/ae/0fc961179e78cc579e138fad6eb580448ecae64908f95b8cb8ee2f241f67/asyncpg-0.31.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:bd5b6efff3c17c3202d4b37189969acf8927438a238c6257f66be3c426beba20", size = 3471858, upload-time = "2025-11-24T23:25:59.636Z" }, + { url = "https://files.pythonhosted.org/packages/52/b2/b20e09670be031afa4cbfabd645caece7f85ec62d69c312239de568e058e/asyncpg-0.31.0-cp312-cp312-win32.whl", hash = "sha256:027eaa61361ec735926566f995d959ade4796f6a49d3bde17e5134b9964f9ba8", size = 527852, upload-time = "2025-11-24T23:26:01.084Z" }, + { url = "https://files.pythonhosted.org/packages/b5/f0/f2ed1de154e15b107dc692262395b3c17fc34eafe2a78fc2115931561730/asyncpg-0.31.0-cp312-cp312-win_amd64.whl", hash = "sha256:72d6bdcbc93d608a1158f17932de2321f68b1a967a13e014998db87a72ed3186", size = 597175, upload-time = "2025-11-24T23:26:02.564Z" }, +] + +[[package]] +name = "bcrypt" +version = "5.0.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/d4/36/3329e2518d70ad8e2e5817d5a4cac6bba05a47767ec416c7d020a965f408/bcrypt-5.0.0.tar.gz", hash = "sha256:f748f7c2d6fd375cc93d3fba7ef4a9e3a092421b8dbf34d8d4dc06be9492dfdd", size = 25386, upload-time = "2025-09-25T19:50:47.829Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/84/29/6237f151fbfe295fe3e074ecc6d44228faa1e842a81f6d34a02937ee1736/bcrypt-5.0.0-cp38-abi3-macosx_10_12_universal2.whl", hash = "sha256:fc746432b951e92b58317af8e0ca746efe93e66555f1b40888865ef5bf56446b", size = 494553, upload-time = "2025-09-25T19:49:49.006Z" }, + { url = "https://files.pythonhosted.org/packages/45/b6/4c1205dde5e464ea3bd88e8742e19f899c16fa8916fb8510a851fae985b5/bcrypt-5.0.0-cp38-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:c2388ca94ffee269b6038d48747f4ce8df0ffbea43f31abfa18ac72f0218effb", size = 275009, upload-time = "2025-09-25T19:49:50.581Z" }, + { url = "https://files.pythonhosted.org/packages/3b/71/427945e6ead72ccffe77894b2655b695ccf14ae1866cd977e185d606dd2f/bcrypt-5.0.0-cp38-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:560ddb6ec730386e7b3b26b8b4c88197aaed924430e7b74666a586ac997249ef", size = 278029, upload-time = "2025-09-25T19:49:52.533Z" }, + { url = "https://files.pythonhosted.org/packages/17/72/c344825e3b83c5389a369c8a8e58ffe1480b8a699f46c127c34580c4666b/bcrypt-5.0.0-cp38-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:d79e5c65dcc9af213594d6f7f1fa2c98ad3fc10431e7aa53c176b441943efbdd", size = 275907, upload-time = "2025-09-25T19:49:54.709Z" }, + { url = "https://files.pythonhosted.org/packages/0b/7e/d4e47d2df1641a36d1212e5c0514f5291e1a956a7749f1e595c07a972038/bcrypt-5.0.0-cp38-abi3-manylinux_2_28_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:2b732e7d388fa22d48920baa267ba5d97cca38070b69c0e2d37087b381c681fd", size = 296500, upload-time = "2025-09-25T19:49:56.013Z" }, + { url = "https://files.pythonhosted.org/packages/0f/c3/0ae57a68be2039287ec28bc463b82e4b8dc23f9d12c0be331f4782e19108/bcrypt-5.0.0-cp38-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:0c8e093ea2532601a6f686edbc2c6b2ec24131ff5c52f7610dd64fa4553b5464", size = 278412, upload-time = "2025-09-25T19:49:57.356Z" }, + { url = "https://files.pythonhosted.org/packages/45/2b/77424511adb11e6a99e3a00dcc7745034bee89036ad7d7e255a7e47be7d8/bcrypt-5.0.0-cp38-abi3-manylinux_2_34_aarch64.whl", hash = "sha256:5b1589f4839a0899c146e8892efe320c0fa096568abd9b95593efac50a87cb75", size = 275486, upload-time = "2025-09-25T19:49:59.116Z" }, + { url = "https://files.pythonhosted.org/packages/43/0a/405c753f6158e0f3f14b00b462d8bca31296f7ecfc8fc8bc7919c0c7d73a/bcrypt-5.0.0-cp38-abi3-manylinux_2_34_x86_64.whl", hash = "sha256:89042e61b5e808b67daf24a434d89bab164d4de1746b37a8d173b6b14f3db9ff", size = 277940, upload-time = "2025-09-25T19:50:00.869Z" }, + { url = "https://files.pythonhosted.org/packages/62/83/b3efc285d4aadc1fa83db385ec64dcfa1707e890eb42f03b127d66ac1b7b/bcrypt-5.0.0-cp38-abi3-musllinux_1_1_aarch64.whl", hash = "sha256:e3cf5b2560c7b5a142286f69bde914494b6d8f901aaa71e453078388a50881c4", size = 310776, upload-time = "2025-09-25T19:50:02.393Z" }, + { url = "https://files.pythonhosted.org/packages/95/7d/47ee337dacecde6d234890fe929936cb03ebc4c3a7460854bbd9c97780b8/bcrypt-5.0.0-cp38-abi3-musllinux_1_1_x86_64.whl", hash = "sha256:f632fd56fc4e61564f78b46a2269153122db34988e78b6be8b32d28507b7eaeb", size = 312922, upload-time = "2025-09-25T19:50:04.232Z" }, + { url = "https://files.pythonhosted.org/packages/d6/3a/43d494dfb728f55f4e1cf8fd435d50c16a2d75493225b54c8d06122523c6/bcrypt-5.0.0-cp38-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:801cad5ccb6b87d1b430f183269b94c24f248dddbbc5c1f78b6ed231743e001c", size = 341367, upload-time = "2025-09-25T19:50:05.559Z" }, + { url = "https://files.pythonhosted.org/packages/55/ab/a0727a4547e383e2e22a630e0f908113db37904f58719dc48d4622139b5c/bcrypt-5.0.0-cp38-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:3cf67a804fc66fc217e6914a5635000259fbbbb12e78a99488e4d5ba445a71eb", size = 359187, upload-time = "2025-09-25T19:50:06.916Z" }, + { url = "https://files.pythonhosted.org/packages/1b/bb/461f352fdca663524b4643d8b09e8435b4990f17fbf4fea6bc2a90aa0cc7/bcrypt-5.0.0-cp38-abi3-win32.whl", hash = "sha256:3abeb543874b2c0524ff40c57a4e14e5d3a66ff33fb423529c88f180fd756538", size = 153752, upload-time = "2025-09-25T19:50:08.515Z" }, + { url = "https://files.pythonhosted.org/packages/41/aa/4190e60921927b7056820291f56fc57d00d04757c8b316b2d3c0d1d6da2c/bcrypt-5.0.0-cp38-abi3-win_amd64.whl", hash = "sha256:35a77ec55b541e5e583eb3436ffbbf53b0ffa1fa16ca6782279daf95d146dcd9", size = 150881, upload-time = "2025-09-25T19:50:09.742Z" }, + { url = "https://files.pythonhosted.org/packages/54/12/cd77221719d0b39ac0b55dbd39358db1cd1246e0282e104366ebbfb8266a/bcrypt-5.0.0-cp38-abi3-win_arm64.whl", hash = "sha256:cde08734f12c6a4e28dc6755cd11d3bdfea608d93d958fffbe95a7026ebe4980", size = 144931, upload-time = "2025-09-25T19:50:11.016Z" }, + { url = "https://files.pythonhosted.org/packages/5d/ba/2af136406e1c3839aea9ecadc2f6be2bcd1eff255bd451dd39bcf302c47a/bcrypt-5.0.0-cp39-abi3-macosx_10_12_universal2.whl", hash = "sha256:0c418ca99fd47e9c59a301744d63328f17798b5947b0f791e9af3c1c499c2d0a", size = 495313, upload-time = "2025-09-25T19:50:12.309Z" }, + { url = "https://files.pythonhosted.org/packages/ac/ee/2f4985dbad090ace5ad1f7dd8ff94477fe089b5fab2040bd784a3d5f187b/bcrypt-5.0.0-cp39-abi3-manylinux2014_aarch64.manylinux_2_17_aarch64.whl", hash = "sha256:ddb4e1500f6efdd402218ffe34d040a1196c072e07929b9820f363a1fd1f4191", size = 275290, upload-time = "2025-09-25T19:50:13.673Z" }, + { url = "https://files.pythonhosted.org/packages/e4/6e/b77ade812672d15cf50842e167eead80ac3514f3beacac8902915417f8b7/bcrypt-5.0.0-cp39-abi3-manylinux2014_x86_64.manylinux_2_17_x86_64.whl", hash = "sha256:7aeef54b60ceddb6f30ee3db090351ecf0d40ec6e2abf41430997407a46d2254", size = 278253, upload-time = "2025-09-25T19:50:15.089Z" }, + { url = "https://files.pythonhosted.org/packages/36/c4/ed00ed32f1040f7990dac7115f82273e3c03da1e1a1587a778d8cea496d8/bcrypt-5.0.0-cp39-abi3-manylinux_2_28_aarch64.whl", hash = "sha256:f0ce778135f60799d89c9693b9b398819d15f1921ba15fe719acb3178215a7db", size = 276084, upload-time = "2025-09-25T19:50:16.699Z" }, + { url = "https://files.pythonhosted.org/packages/e7/c4/fa6e16145e145e87f1fa351bbd54b429354fd72145cd3d4e0c5157cf4c70/bcrypt-5.0.0-cp39-abi3-manylinux_2_28_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:a71f70ee269671460b37a449f5ff26982a6f2ba493b3eabdd687b4bf35f875ac", size = 297185, upload-time = "2025-09-25T19:50:18.525Z" }, + { url = "https://files.pythonhosted.org/packages/24/b4/11f8a31d8b67cca3371e046db49baa7c0594d71eb40ac8121e2fc0888db0/bcrypt-5.0.0-cp39-abi3-manylinux_2_28_x86_64.whl", hash = "sha256:f8429e1c410b4073944f03bd778a9e066e7fad723564a52ff91841d278dfc822", size = 278656, upload-time = "2025-09-25T19:50:19.809Z" }, + { url = "https://files.pythonhosted.org/packages/ac/31/79f11865f8078e192847d2cb526e3fa27c200933c982c5b2869720fa5fce/bcrypt-5.0.0-cp39-abi3-manylinux_2_34_aarch64.whl", hash = "sha256:edfcdcedd0d0f05850c52ba3127b1fce70b9f89e0fe5ff16517df7e81fa3cbb8", size = 275662, upload-time = "2025-09-25T19:50:21.567Z" }, + { url = "https://files.pythonhosted.org/packages/d4/8d/5e43d9584b3b3591a6f9b68f755a4da879a59712981ef5ad2a0ac1379f7a/bcrypt-5.0.0-cp39-abi3-manylinux_2_34_x86_64.whl", hash = "sha256:611f0a17aa4a25a69362dcc299fda5c8a3d4f160e2abb3831041feb77393a14a", size = 278240, upload-time = "2025-09-25T19:50:23.305Z" }, + { url = "https://files.pythonhosted.org/packages/89/48/44590e3fc158620f680a978aafe8f87a4c4320da81ed11552f0323aa9a57/bcrypt-5.0.0-cp39-abi3-musllinux_1_1_aarch64.whl", hash = "sha256:db99dca3b1fdc3db87d7c57eac0c82281242d1eabf19dcb8a6b10eb29a2e72d1", size = 311152, upload-time = "2025-09-25T19:50:24.597Z" }, + { url = "https://files.pythonhosted.org/packages/5f/85/e4fbfc46f14f47b0d20493669a625da5827d07e8a88ee460af6cd9768b44/bcrypt-5.0.0-cp39-abi3-musllinux_1_1_x86_64.whl", hash = "sha256:5feebf85a9cefda32966d8171f5db7e3ba964b77fdfe31919622256f80f9cf42", size = 313284, upload-time = "2025-09-25T19:50:26.268Z" }, + { url = "https://files.pythonhosted.org/packages/25/ae/479f81d3f4594456a01ea2f05b132a519eff9ab5768a70430fa1132384b1/bcrypt-5.0.0-cp39-abi3-musllinux_1_2_aarch64.whl", hash = "sha256:3ca8a166b1140436e058298a34d88032ab62f15aae1c598580333dc21d27ef10", size = 341643, upload-time = "2025-09-25T19:50:28.02Z" }, + { url = "https://files.pythonhosted.org/packages/df/d2/36a086dee1473b14276cd6ea7f61aef3b2648710b5d7f1c9e032c29b859f/bcrypt-5.0.0-cp39-abi3-musllinux_1_2_x86_64.whl", hash = "sha256:61afc381250c3182d9078551e3ac3a41da14154fbff647ddf52a769f588c4172", size = 359698, upload-time = "2025-09-25T19:50:31.347Z" }, + { url = "https://files.pythonhosted.org/packages/c0/f6/688d2cd64bfd0b14d805ddb8a565e11ca1fb0fd6817175d58b10052b6d88/bcrypt-5.0.0-cp39-abi3-win32.whl", hash = "sha256:64d7ce196203e468c457c37ec22390f1a61c85c6f0b8160fd752940ccfb3a683", size = 153725, upload-time = "2025-09-25T19:50:34.384Z" }, + { url = "https://files.pythonhosted.org/packages/9f/b9/9d9a641194a730bda138b3dfe53f584d61c58cd5230e37566e83ec2ffa0d/bcrypt-5.0.0-cp39-abi3-win_amd64.whl", hash = "sha256:64ee8434b0da054d830fa8e89e1c8bf30061d539044a39524ff7dec90481e5c2", size = 150912, upload-time = "2025-09-25T19:50:35.69Z" }, + { url = "https://files.pythonhosted.org/packages/27/44/d2ef5e87509158ad2187f4dd0852df80695bb1ee0cfe0a684727b01a69e0/bcrypt-5.0.0-cp39-abi3-win_arm64.whl", hash = "sha256:f2347d3534e76bf50bca5500989d6c1d05ed64b440408057a37673282c654927", size = 144953, upload-time = "2025-09-25T19:50:37.32Z" }, +] + +[[package]] +name = "bit-users" +version = "0.1.0" +source = { virtual = "." } +dependencies = [ + { name = "apscheduler" }, + { name = "asyncpg" }, + { name = "bcrypt" }, + { name = "dotenv" }, + { name = "fastapi" }, + { name = "faststream", extra = ["rabbit"] }, + { name = "granian" }, + { name = "hvac" }, + { name = "itsdangerous" }, + { name = "orjson" }, + { name = "pydantic-settings" }, + { name = "python-jose" }, + { name = "python-ulid" }, + { name = "redis" }, + { name = "sqlalchemy" }, + { name = "uvloop", marker = "sys_platform != 'win32'" }, +] + +[package.metadata] +requires-dist = [ + { name = "apscheduler", specifier = "==3.11.2" }, + { name = "asyncpg", specifier = "==0.31.0" }, + { name = "bcrypt", specifier = "==5.0.0" }, + { name = "dotenv", specifier = "==0.9.9" }, + { name = "fastapi", specifier = "==0.128.7" }, + { name = "faststream", extras = ["rabbit"], specifier = "==0.6.6" }, + { name = "granian", specifier = "==2.6.1" }, + { name = "hvac", specifier = "==2.4.0" }, + { name = "itsdangerous", specifier = "==2.2.0" }, + { name = "orjson", specifier = "==3.11.7" }, + { name = "pydantic-settings", specifier = "==2.12.0" }, + { name = "python-jose", specifier = "==3.5.0" }, + { name = "python-ulid", specifier = "==3.1.0" }, + { name = "redis", specifier = "==7.2.0" }, + { name = "sqlalchemy", specifier = "==2.0.46" }, + { name = "uvloop", marker = "sys_platform != 'win32'", specifier = "==0.22.1" }, +] + +[[package]] +name = "certifi" +version = "2026.2.25" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/af/2d/7bf41579a8986e348fa033a31cdd0e4121114f6bce2457e8876010b092dd/certifi-2026.2.25.tar.gz", hash = "sha256:e887ab5cee78ea814d3472169153c2d12cd43b14bd03329a39a9c6e2e80bfba7", size = 155029, upload-time = "2026-02-25T02:54:17.342Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/9a/3c/c17fb3ca2d9c3acff52e30b309f538586f9f5b9c9cf454f3845fc9af4881/certifi-2026.2.25-py3-none-any.whl", hash = "sha256:027692e4402ad994f1c42e52a4997a9763c646b73e4096e4d5d6db8af1d6f0fa", size = 153684, upload-time = "2026-02-25T02:54:15.766Z" }, +] + +[[package]] +name = "charset-normalizer" +version = "3.4.4" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/13/69/33ddede1939fdd074bce5434295f38fae7136463422fe4fd3e0e89b98062/charset_normalizer-3.4.4.tar.gz", hash = "sha256:94537985111c35f28720e43603b8e7b43a6ecfb2ce1d3058bbe955b73404e21a", size = 129418, upload-time = "2025-10-14T04:42:32.879Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/f3/85/1637cd4af66fa687396e757dec650f28025f2a2f5a5531a3208dc0ec43f2/charset_normalizer-3.4.4-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:0a98e6759f854bd25a58a73fa88833fba3b7c491169f86ce1180c948ab3fd394", size = 208425, upload-time = "2025-10-14T04:40:53.353Z" }, + { url = "https://files.pythonhosted.org/packages/9d/6a/04130023fef2a0d9c62d0bae2649b69f7b7d8d24ea5536feef50551029df/charset_normalizer-3.4.4-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:b5b290ccc2a263e8d185130284f8501e3e36c5e02750fc6b6bdeb2e9e96f1e25", size = 148162, upload-time = "2025-10-14T04:40:54.558Z" }, + { url = "https://files.pythonhosted.org/packages/78/29/62328d79aa60da22c9e0b9a66539feae06ca0f5a4171ac4f7dc285b83688/charset_normalizer-3.4.4-cp312-cp312-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:74bb723680f9f7a6234dcf67aea57e708ec1fbdf5699fb91dfd6f511b0a320ef", size = 144558, upload-time = "2025-10-14T04:40:55.677Z" }, + { url = "https://files.pythonhosted.org/packages/86/bb/b32194a4bf15b88403537c2e120b817c61cd4ecffa9b6876e941c3ee38fe/charset_normalizer-3.4.4-cp312-cp312-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:f1e34719c6ed0b92f418c7c780480b26b5d9c50349e9a9af7d76bf757530350d", size = 161497, upload-time = "2025-10-14T04:40:57.217Z" }, + { url = "https://files.pythonhosted.org/packages/19/89/a54c82b253d5b9b111dc74aca196ba5ccfcca8242d0fb64146d4d3183ff1/charset_normalizer-3.4.4-cp312-cp312-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:2437418e20515acec67d86e12bf70056a33abdacb5cb1655042f6538d6b085a8", size = 159240, upload-time = "2025-10-14T04:40:58.358Z" }, + { url = "https://files.pythonhosted.org/packages/c0/10/d20b513afe03acc89ec33948320a5544d31f21b05368436d580dec4e234d/charset_normalizer-3.4.4-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:11d694519d7f29d6cd09f6ac70028dba10f92f6cdd059096db198c283794ac86", size = 153471, upload-time = "2025-10-14T04:40:59.468Z" }, + { url = "https://files.pythonhosted.org/packages/61/fa/fbf177b55bdd727010f9c0a3c49eefa1d10f960e5f09d1d887bf93c2e698/charset_normalizer-3.4.4-cp312-cp312-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:ac1c4a689edcc530fc9d9aa11f5774b9e2f33f9a0c6a57864e90908f5208d30a", size = 150864, upload-time = "2025-10-14T04:41:00.623Z" }, + { url = "https://files.pythonhosted.org/packages/05/12/9fbc6a4d39c0198adeebbde20b619790e9236557ca59fc40e0e3cebe6f40/charset_normalizer-3.4.4-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:21d142cc6c0ec30d2efee5068ca36c128a30b0f2c53c1c07bd78cb6bc1d3be5f", size = 150647, upload-time = "2025-10-14T04:41:01.754Z" }, + { url = "https://files.pythonhosted.org/packages/ad/1f/6a9a593d52e3e8c5d2b167daf8c6b968808efb57ef4c210acb907c365bc4/charset_normalizer-3.4.4-cp312-cp312-musllinux_1_2_armv7l.whl", hash = "sha256:5dbe56a36425d26d6cfb40ce79c314a2e4dd6211d51d6d2191c00bed34f354cc", size = 145110, upload-time = "2025-10-14T04:41:03.231Z" }, + { url = "https://files.pythonhosted.org/packages/30/42/9a52c609e72471b0fc54386dc63c3781a387bb4fe61c20231a4ebcd58bdd/charset_normalizer-3.4.4-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:5bfbb1b9acf3334612667b61bd3002196fe2a1eb4dd74d247e0f2a4d50ec9bbf", size = 162839, upload-time = "2025-10-14T04:41:04.715Z" }, + { url = "https://files.pythonhosted.org/packages/c4/5b/c0682bbf9f11597073052628ddd38344a3d673fda35a36773f7d19344b23/charset_normalizer-3.4.4-cp312-cp312-musllinux_1_2_riscv64.whl", hash = "sha256:d055ec1e26e441f6187acf818b73564e6e6282709e9bcb5b63f5b23068356a15", size = 150667, upload-time = "2025-10-14T04:41:05.827Z" }, + { url = "https://files.pythonhosted.org/packages/e4/24/a41afeab6f990cf2daf6cb8c67419b63b48cf518e4f56022230840c9bfb2/charset_normalizer-3.4.4-cp312-cp312-musllinux_1_2_s390x.whl", hash = "sha256:af2d8c67d8e573d6de5bc30cdb27e9b95e49115cd9baad5ddbd1a6207aaa82a9", size = 160535, upload-time = "2025-10-14T04:41:06.938Z" }, + { url = "https://files.pythonhosted.org/packages/2a/e5/6a4ce77ed243c4a50a1fecca6aaaab419628c818a49434be428fe24c9957/charset_normalizer-3.4.4-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:780236ac706e66881f3b7f2f32dfe90507a09e67d1d454c762cf642e6e1586e0", size = 154816, upload-time = "2025-10-14T04:41:08.101Z" }, + { url = "https://files.pythonhosted.org/packages/a8/ef/89297262b8092b312d29cdb2517cb1237e51db8ecef2e9af5edbe7b683b1/charset_normalizer-3.4.4-cp312-cp312-win32.whl", hash = "sha256:5833d2c39d8896e4e19b689ffc198f08ea58116bee26dea51e362ecc7cd3ed26", size = 99694, upload-time = "2025-10-14T04:41:09.23Z" }, + { url = "https://files.pythonhosted.org/packages/3d/2d/1e5ed9dd3b3803994c155cd9aacb60c82c331bad84daf75bcb9c91b3295e/charset_normalizer-3.4.4-cp312-cp312-win_amd64.whl", hash = "sha256:a79cfe37875f822425b89a82333404539ae63dbdddf97f84dcbc3d339aae9525", size = 107131, upload-time = "2025-10-14T04:41:10.467Z" }, + { url = "https://files.pythonhosted.org/packages/d0/d9/0ed4c7098a861482a7b6a95603edce4c0d9db2311af23da1fb2b75ec26fc/charset_normalizer-3.4.4-cp312-cp312-win_arm64.whl", hash = "sha256:376bec83a63b8021bb5c8ea75e21c4ccb86e7e45ca4eb81146091b56599b80c3", size = 100390, upload-time = "2025-10-14T04:41:11.915Z" }, + { url = "https://files.pythonhosted.org/packages/0a/4c/925909008ed5a988ccbb72dcc897407e5d6d3bd72410d69e051fc0c14647/charset_normalizer-3.4.4-py3-none-any.whl", hash = "sha256:7a32c560861a02ff789ad905a2fe94e3f840803362c84fecf1851cb4cf3dc37f", size = 53402, upload-time = "2025-10-14T04:42:31.76Z" }, +] + +[[package]] +name = "click" +version = "8.3.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "colorama", marker = "sys_platform == 'win32'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/3d/fa/656b739db8587d7b5dfa22e22ed02566950fbfbcdc20311993483657a5c0/click-8.3.1.tar.gz", hash = "sha256:12ff4785d337a1bb490bb7e9c2b1ee5da3112e94a8622f26a6c77f5d2fc6842a", size = 295065, upload-time = "2025-11-15T20:45:42.706Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/98/78/01c019cdb5d6498122777c1a43056ebb3ebfeef2076d9d026bfe15583b2b/click-8.3.1-py3-none-any.whl", hash = "sha256:981153a64e25f12d547d3426c367a4857371575ee7ad18df2a6183ab0545b2a6", size = 108274, upload-time = "2025-11-15T20:45:41.139Z" }, +] + +[[package]] +name = "colorama" +version = "0.4.6" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/d8/53/6f443c9a4a8358a93a6792e2acffb9d9d5cb0a5cfd8802644b7b1c9a02e4/colorama-0.4.6.tar.gz", hash = "sha256:08695f5cb7ed6e0531a20572697297273c47b8cae5a63ffc6d6ed5c201be6e44", size = 27697, upload-time = "2022-10-25T02:36:22.414Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/d1/d6/3965ed04c63042e047cb6a3e6ed1a63a35087b6a609aa3a15ed8ac56c221/colorama-0.4.6-py2.py3-none-any.whl", hash = "sha256:4f1d9991f5acc0ca119f9d443620b77f9d6b33703e51011c16baf57afb285fc6", size = 25335, upload-time = "2022-10-25T02:36:20.889Z" }, +] + +[[package]] +name = "dotenv" +version = "0.9.9" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "python-dotenv" }, +] +wheels = [ + { url = "https://files.pythonhosted.org/packages/b2/b7/545d2c10c1fc15e48653c91efde329a790f2eecfbbf2bd16003b5db2bab0/dotenv-0.9.9-py2.py3-none-any.whl", hash = "sha256:29cf74a087b31dafdb5a446b6d7e11cbce8ed2741540e2339c69fbef92c94ce9", size = 1892, upload-time = "2025-02-19T22:15:01.647Z" }, +] + +[[package]] +name = "ecdsa" +version = "0.19.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "six" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/c0/1f/924e3caae75f471eae4b26bd13b698f6af2c44279f67af317439c2f4c46a/ecdsa-0.19.1.tar.gz", hash = "sha256:478cba7b62555866fcb3bb3fe985e06decbdb68ef55713c4e5ab98c57d508e61", size = 201793, upload-time = "2025-03-13T11:52:43.25Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/cb/a3/460c57f094a4a165c84a1341c373b0a4f5ec6ac244b998d5021aade89b77/ecdsa-0.19.1-py2.py3-none-any.whl", hash = "sha256:30638e27cf77b7e15c4c4cc1973720149e1033827cfd00661ca5c8cc0cdb24c3", size = 150607, upload-time = "2025-03-13T11:52:41.757Z" }, +] + +[[package]] +name = "fast-depends" +version = "3.0.8" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "anyio" }, + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/f8/6d/787a21ca8043a8fdb737cf28f645e94a46fc30b44a31de54573299156bad/fast_depends-3.0.8.tar.gz", hash = "sha256:896b16f79a512b6ea1df721b0aa1708a192a06f964be6597e01fcf5412559101", size = 18382, upload-time = "2026-03-02T19:54:28.649Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/1d/1d/e4843e4eeb65f51447b8c22d200d12d8f94f27c97e77bb7162515cc8d61f/fast_depends-3.0.8-py3-none-any.whl", hash = "sha256:4c52c8a3907bca46d43e70e4364d6d016872d9a3aae4bc0c1c85e72e0a6a21c7", size = 25507, upload-time = "2026-03-02T19:54:27.594Z" }, +] + +[package.optional-dependencies] +pydantic = [ + { name = "pydantic" }, +] + +[[package]] +name = "fastapi" +version = "0.128.7" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "annotated-doc" }, + { name = "pydantic" }, + { name = "starlette" }, + { name = "typing-extensions" }, + { name = "typing-inspection" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/a0/fc/af386750b3fd8d8828167e4c82b787a8eeca2eca5c5429c9db8bb7c70e04/fastapi-0.128.7.tar.gz", hash = "sha256:783c273416995486c155ad2c0e2b45905dedfaf20b9ef8d9f6a9124670639a24", size = 375325, upload-time = "2026-02-10T12:26:40.968Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/af/1a/f983b45661c79c31be575c570d46c437a5409b67a939c1b3d8d6b3ed7a7f/fastapi-0.128.7-py3-none-any.whl", hash = "sha256:6bd9bd31cb7047465f2d3fa3ba3f33b0870b17d4eaf7cdb36d1576ab060ad662", size = 103630, upload-time = "2026-02-10T12:26:39.414Z" }, +] + +[[package]] +name = "faststream" +version = "0.6.6" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "anyio" }, + { name = "fast-depends", extra = ["pydantic"] }, + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/a6/cc/26deefd97a3d51205554d4fe69ffc2a9144515cda20cb7185be27e11166e/faststream-0.6.6.tar.gz", hash = "sha256:de87502e22db0372131165221728c6993b29d42ba29aaaa0a27d1249803f2ddd", size = 302712, upload-time = "2026-02-03T18:08:35.747Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/ff/17/169728098799d4f5c4978f9b83d2dc41541eee02ec8547149a085acf11dd/faststream-0.6.6-py3-none-any.whl", hash = "sha256:4aca70628b526d8e27771f1f8edf9cd0a80a62f335a2721ddbbc863e6098f269", size = 507654, upload-time = "2026-02-03T18:08:34.347Z" }, +] + +[package.optional-dependencies] +rabbit = [ + { name = "aio-pika" }, +] + +[[package]] +name = "granian" +version = "2.6.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "click" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/aa/22/93016f4f9e9115ba981f51fc17c7c369a34772f11a93043320a2a3d5c6ea/granian-2.6.1.tar.gz", hash = "sha256:d209065b12f18b6d7e78f1c16ff9444e5367dddeb41e3225c2cf024762740590", size = 115480, upload-time = "2026-01-07T11:08:55.927Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/50/d1/9d191ea0b4f01a0d2437600b32a025e687189bae072878ec161f358eb465/granian-2.6.1-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:801bcf7efc3fdd12a08016ed94b1a386480c9a5185eb8e017fd83db1b2d210b4", size = 3070339, upload-time = "2026-01-07T11:07:22.618Z" }, + { url = "https://files.pythonhosted.org/packages/c3/1e/be0ba55a2b21aeadeb8774721964740130fdd3dd7337d8a5ec130a0c48c0/granian-2.6.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:853fb869a50d742576bb4f974f321242a71a4d8eed918939397b317ab32c6a2d", size = 2819049, upload-time = "2026-01-07T11:07:23.877Z" }, + { url = "https://files.pythonhosted.org/packages/78/c7/d8adb472dc71b212281a82d3ea00858809f2844a79b45e63bbb3a09921b7/granian-2.6.1-cp312-cp312-manylinux_2_24_armv7l.whl", hash = "sha256:327a6090496c1deebd9e315f973bdbfc5c927e5574588bba918bfe2127bbd578", size = 3322325, upload-time = "2026-01-07T11:07:25.304Z" }, + { url = "https://files.pythonhosted.org/packages/de/2f/c3ce9e4f19163f35c5c57c45af2ad353abcc6091a44625caec56e065ca4a/granian-2.6.1-cp312-cp312-manylinux_2_24_i686.whl", hash = "sha256:4c91f0eefc34d809773762a9b81c1c48e20ff74c0f1be876d1132d82c0f74609", size = 3136460, upload-time = "2026-01-07T11:07:26.682Z" }, + { url = "https://files.pythonhosted.org/packages/3d/87/91b57eb5407a12bfe779acfa3fbb2be329aec14e6d88acf293fe910c19e5/granian-2.6.1-cp312-cp312-manylinux_2_24_x86_64.whl", hash = "sha256:c5754de57b56597d5998b7bb40aa9d0dc4e1dbeb5aea3309945126ed71b41c6d", size = 3386850, upload-time = "2026-01-07T11:07:27.989Z" }, + { url = "https://files.pythonhosted.org/packages/f0/43/b61a6f3bfc2f35e504e42789776a269cbdc0cdafdb10597bd6534e93ba3d/granian-2.6.1-cp312-cp312-manylinux_2_28_aarch64.whl", hash = "sha256:e849d6467ebe77d0a75eb4175f7cc06b1150dbfce0259932a4270c765b4de6c4", size = 3240693, upload-time = "2026-01-07T11:07:29.52Z" }, + { url = "https://files.pythonhosted.org/packages/d1/1d/c40bd8dd99b855190d67127e0610f082cfbc7898dbd41f1ade015c2041f7/granian-2.6.1-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:5a265867203e30d3c54d9d99783346040681ba2aaec70fcbe63de0e295e7882f", size = 3312703, upload-time = "2026-01-07T11:07:31.128Z" }, + { url = "https://files.pythonhosted.org/packages/a1/ca/589c042afc3287b36dfeed6df56074cc831a94e5217bcbd7c1af20812fe2/granian-2.6.1-cp312-cp312-musllinux_1_1_armv7l.whl", hash = "sha256:03f0a1505e7862183203d7d7c1e2b29349bd63a18858ced49aec4d7aadb98fc8", size = 3483737, upload-time = "2026-01-07T11:07:32.726Z" }, + { url = "https://files.pythonhosted.org/packages/6f/51/72eb037bac01db9623fa5fb128739bfb5679fb90e6da2645c5a3d8a4168d/granian-2.6.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:703ed57ba134ab16f15d49f7d644329db1cb0f7f8114ec3f08fb8039850e308a", size = 3514745, upload-time = "2026-01-07T11:07:34.706Z" }, + { url = "https://files.pythonhosted.org/packages/19/0f/be9d5e97d3775dfc0f98b56a85ad6c73d7b0ac4cfc452558696e061d038d/granian-2.6.1-cp312-cp312-win_amd64.whl", hash = "sha256:4c771949707118116fa78b03511e690cb6c3bd94e9d84db7c2bdfe0250fecc80", size = 2349022, upload-time = "2026-01-07T11:07:36.484Z" }, +] + +[[package]] +name = "greenlet" +version = "3.3.2" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/a3/51/1664f6b78fc6ebbd98019a1fd730e83fa78f2db7058f72b1463d3612b8db/greenlet-3.3.2.tar.gz", hash = "sha256:2eaf067fc6d886931c7962e8c6bede15d2f01965560f3359b27c80bde2d151f2", size = 188267, upload-time = "2026-02-20T20:54:15.531Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/ea/ab/1608e5a7578e62113506740b88066bf09888322a311cff602105e619bd87/greenlet-3.3.2-cp312-cp312-macosx_11_0_universal2.whl", hash = "sha256:ac8d61d4343b799d1e526db579833d72f23759c71e07181c2d2944e429eb09cd", size = 280358, upload-time = "2026-02-20T20:17:43.971Z" }, + { url = "https://files.pythonhosted.org/packages/a5/23/0eae412a4ade4e6623ff7626e38998cb9b11e9ff1ebacaa021e4e108ec15/greenlet-3.3.2-cp312-cp312-manylinux_2_24_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:3ceec72030dae6ac0c8ed7591b96b70410a8be370b6a477b1dbc072856ad02bd", size = 601217, upload-time = "2026-02-20T20:47:31.462Z" }, + { url = "https://files.pythonhosted.org/packages/f8/16/5b1678a9c07098ecb9ab2dd159fafaf12e963293e61ee8d10ecb55273e5e/greenlet-3.3.2-cp312-cp312-manylinux_2_24_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:a2a5be83a45ce6188c045bcc44b0ee037d6a518978de9a5d97438548b953a1ac", size = 611792, upload-time = "2026-02-20T20:55:58.423Z" }, + { url = "https://files.pythonhosted.org/packages/5c/c5/cc09412a29e43406eba18d61c70baa936e299bc27e074e2be3806ed29098/greenlet-3.3.2-cp312-cp312-manylinux_2_24_s390x.manylinux_2_28_s390x.whl", hash = "sha256:ae9e21c84035c490506c17002f5c8ab25f980205c3e61ddb3a2a2a2e6c411fcb", size = 626250, upload-time = "2026-02-20T21:02:46.596Z" }, + { url = "https://files.pythonhosted.org/packages/50/1f/5155f55bd71cabd03765a4aac9ac446be129895271f73872c36ebd4b04b6/greenlet-3.3.2-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:43e99d1749147ac21dde49b99c9abffcbc1e2d55c67501465ef0930d6e78e070", size = 613875, upload-time = "2026-02-20T20:21:01.102Z" }, + { url = "https://files.pythonhosted.org/packages/fc/dd/845f249c3fcd69e32df80cdab059b4be8b766ef5830a3d0aa9d6cad55beb/greenlet-3.3.2-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:4c956a19350e2c37f2c48b336a3afb4bff120b36076d9d7fb68cb44e05d95b79", size = 1571467, upload-time = "2026-02-20T20:49:33.495Z" }, + { url = "https://files.pythonhosted.org/packages/2a/50/2649fe21fcc2b56659a452868e695634722a6655ba245d9f77f5656010bf/greenlet-3.3.2-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:6c6f8ba97d17a1e7d664151284cb3315fc5f8353e75221ed4324f84eb162b395", size = 1640001, upload-time = "2026-02-20T20:21:09.154Z" }, + { url = "https://files.pythonhosted.org/packages/9b/40/cc802e067d02af8b60b6771cea7d57e21ef5e6659912814babb42b864713/greenlet-3.3.2-cp312-cp312-win_amd64.whl", hash = "sha256:34308836d8370bddadb41f5a7ce96879b72e2fdfb4e87729330c6ab52376409f", size = 231081, upload-time = "2026-02-20T20:17:28.121Z" }, + { url = "https://files.pythonhosted.org/packages/58/2e/fe7f36ff1982d6b10a60d5e0740c759259a7d6d2e1dc41da6d96de32fff6/greenlet-3.3.2-cp312-cp312-win_arm64.whl", hash = "sha256:d3a62fa76a32b462a97198e4c9e99afb9ab375115e74e9a83ce180e7a496f643", size = 230331, upload-time = "2026-02-20T20:17:23.34Z" }, +] + +[[package]] +name = "hvac" +version = "2.4.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "requests" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/e2/57/b46c397fb3842cfb02a44609aa834c887f38dd75f290c2fc5a34da4b2fee/hvac-2.4.0.tar.gz", hash = "sha256:e0056ad9064e7923e874e6769015b032580b639e29246f5ab1044f7959c1c7e0", size = 332543, upload-time = "2025-10-30T12:57:47.512Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/55/33/71e45a6bd6875f44a26f99da31c63b6840123e88bedf2c0b1ce429b8be12/hvac-2.4.0-py3-none-any.whl", hash = "sha256:008db5efd8c2f77bd37d2368ea5f713edceae1c65f11fd608393179478649e0f", size = 155921, upload-time = "2025-10-30T12:57:46.253Z" }, +] + +[[package]] +name = "idna" +version = "3.11" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/6f/6d/0703ccc57f3a7233505399edb88de3cbd678da106337b9fcde432b65ed60/idna-3.11.tar.gz", hash = "sha256:795dafcc9c04ed0c1fb032c2aa73654d8e8c5023a7df64a53f39190ada629902", size = 194582, upload-time = "2025-10-12T14:55:20.501Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/0e/61/66938bbb5fc52dbdf84594873d5b51fb1f7c7794e9c0f5bd885f30bc507b/idna-3.11-py3-none-any.whl", hash = "sha256:771a87f49d9defaf64091e6e6fe9c18d4833f140bd19464795bc32d966ca37ea", size = 71008, upload-time = "2025-10-12T14:55:18.883Z" }, +] + +[[package]] +name = "itsdangerous" +version = "2.2.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/9c/cb/8ac0172223afbccb63986cc25049b154ecfb5e85932587206f42317be31d/itsdangerous-2.2.0.tar.gz", hash = "sha256:e0050c0b7da1eea53ffaf149c0cfbb5c6e2e2b69c4bef22c81fa6eb73e5f6173", size = 54410, upload-time = "2024-04-16T21:28:15.614Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/04/96/92447566d16df59b2a776c0fb82dbc4d9e07cd95062562af01e408583fc4/itsdangerous-2.2.0-py3-none-any.whl", hash = "sha256:c6242fc49e35958c8b15141343aa660db5fc54d4f13a1db01a3f5891b98700ef", size = 16234, upload-time = "2024-04-16T21:28:14.499Z" }, +] + +[[package]] +name = "multidict" +version = "6.7.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/1a/c2/c2d94cbe6ac1753f3fc980da97b3d930efe1da3af3c9f5125354436c073d/multidict-6.7.1.tar.gz", hash = "sha256:ec6652a1bee61c53a3e5776b6049172c53b6aaba34f18c9ad04f82712bac623d", size = 102010, upload-time = "2026-01-26T02:46:45.979Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/8d/9c/f20e0e2cf80e4b2e4b1c365bf5fe104ee633c751a724246262db8f1a0b13/multidict-6.7.1-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:a90f75c956e32891a4eda3639ce6dd86e87105271f43d43442a3aedf3cddf172", size = 76893, upload-time = "2026-01-26T02:43:52.754Z" }, + { url = "https://files.pythonhosted.org/packages/fe/cf/18ef143a81610136d3da8193da9d80bfe1cb548a1e2d1c775f26b23d024a/multidict-6.7.1-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:3fccb473e87eaa1382689053e4a4618e7ba7b9b9b8d6adf2027ee474597128cd", size = 45456, upload-time = "2026-01-26T02:43:53.893Z" }, + { url = "https://files.pythonhosted.org/packages/a9/65/1caac9d4cd32e8433908683446eebc953e82d22b03d10d41a5f0fefe991b/multidict-6.7.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:b0fa96985700739c4c7853a43c0b3e169360d6855780021bfc6d0f1ce7c123e7", size = 43872, upload-time = "2026-01-26T02:43:55.041Z" }, + { url = "https://files.pythonhosted.org/packages/cf/3b/d6bd75dc4f3ff7c73766e04e705b00ed6dbbaccf670d9e05a12b006f5a21/multidict-6.7.1-cp312-cp312-manylinux1_i686.manylinux_2_28_i686.manylinux_2_5_i686.whl", hash = "sha256:cb2a55f408c3043e42b40cc8eecd575afa27b7e0b956dfb190de0f8499a57a53", size = 251018, upload-time = "2026-01-26T02:43:56.198Z" }, + { url = "https://files.pythonhosted.org/packages/fd/80/c959c5933adedb9ac15152e4067c702a808ea183a8b64cf8f31af8ad3155/multidict-6.7.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:eb0ce7b2a32d09892b3dd6cc44877a0d02a33241fafca5f25c8b6b62374f8b75", size = 258883, upload-time = "2026-01-26T02:43:57.499Z" }, + { url = "https://files.pythonhosted.org/packages/86/85/7ed40adafea3d4f1c8b916e3b5cc3a8e07dfcdcb9cd72800f4ed3ca1b387/multidict-6.7.1-cp312-cp312-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:c3a32d23520ee37bf327d1e1a656fec76a2edd5c038bf43eddfa0572ec49c60b", size = 242413, upload-time = "2026-01-26T02:43:58.755Z" }, + { url = "https://files.pythonhosted.org/packages/d2/57/b8565ff533e48595503c785f8361ff9a4fde4d67de25c207cd0ba3befd03/multidict-6.7.1-cp312-cp312-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:9c90fed18bffc0189ba814749fdcc102b536e83a9f738a9003e569acd540a733", size = 268404, upload-time = "2026-01-26T02:44:00.216Z" }, + { url = "https://files.pythonhosted.org/packages/e0/50/9810c5c29350f7258180dfdcb2e52783a0632862eb334c4896ac717cebcb/multidict-6.7.1-cp312-cp312-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:da62917e6076f512daccfbbde27f46fed1c98fee202f0559adec8ee0de67f71a", size = 269456, upload-time = "2026-01-26T02:44:02.202Z" }, + { url = "https://files.pythonhosted.org/packages/f3/8d/5e5be3ced1d12966fefb5c4ea3b2a5b480afcea36406559442c6e31d4a48/multidict-6.7.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:bfde23ef6ed9db7eaee6c37dcec08524cb43903c60b285b172b6c094711b3961", size = 256322, upload-time = "2026-01-26T02:44:03.56Z" }, + { url = "https://files.pythonhosted.org/packages/31/6e/d8a26d81ac166a5592782d208dd90dfdc0a7a218adaa52b45a672b46c122/multidict-6.7.1-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:3758692429e4e32f1ba0df23219cd0b4fc0a52f476726fff9337d1a57676a582", size = 253955, upload-time = "2026-01-26T02:44:04.845Z" }, + { url = "https://files.pythonhosted.org/packages/59/4c/7c672c8aad41534ba619bcd4ade7a0dc87ed6b8b5c06149b85d3dd03f0cd/multidict-6.7.1-cp312-cp312-musllinux_1_2_armv7l.whl", hash = "sha256:398c1478926eca669f2fd6a5856b6de9c0acf23a2cb59a14c0ba5844fa38077e", size = 251254, upload-time = "2026-01-26T02:44:06.133Z" }, + { url = "https://files.pythonhosted.org/packages/7b/bd/84c24de512cbafbdbc39439f74e967f19570ce7924e3007174a29c348916/multidict-6.7.1-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:c102791b1c4f3ab36ce4101154549105a53dc828f016356b3e3bcae2e3a039d3", size = 252059, upload-time = "2026-01-26T02:44:07.518Z" }, + { url = "https://files.pythonhosted.org/packages/fa/ba/f5449385510825b73d01c2d4087bf6d2fccc20a2d42ac34df93191d3dd03/multidict-6.7.1-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:a088b62bd733e2ad12c50dad01b7d0166c30287c166e137433d3b410add807a6", size = 263588, upload-time = "2026-01-26T02:44:09.382Z" }, + { url = "https://files.pythonhosted.org/packages/d7/11/afc7c677f68f75c84a69fe37184f0f82fce13ce4b92f49f3db280b7e92b3/multidict-6.7.1-cp312-cp312-musllinux_1_2_s390x.whl", hash = "sha256:3d51ff4785d58d3f6c91bdbffcb5e1f7ddfda557727043aa20d20ec4f65e324a", size = 259642, upload-time = "2026-01-26T02:44:10.73Z" }, + { url = "https://files.pythonhosted.org/packages/2b/17/ebb9644da78c4ab36403739e0e6e0e30ebb135b9caf3440825001a0bddcb/multidict-6.7.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:fc5907494fccf3e7d3f94f95c91d6336b092b5fc83811720fae5e2765890dfba", size = 251377, upload-time = "2026-01-26T02:44:12.042Z" }, + { url = "https://files.pythonhosted.org/packages/ca/a4/840f5b97339e27846c46307f2530a2805d9d537d8b8bd416af031cad7fa0/multidict-6.7.1-cp312-cp312-win32.whl", hash = "sha256:28ca5ce2fd9716631133d0e9a9b9a745ad7f60bac2bccafb56aa380fc0b6c511", size = 41887, upload-time = "2026-01-26T02:44:14.245Z" }, + { url = "https://files.pythonhosted.org/packages/80/31/0b2517913687895f5904325c2069d6a3b78f66cc641a86a2baf75a05dcbb/multidict-6.7.1-cp312-cp312-win_amd64.whl", hash = "sha256:fcee94dfbd638784645b066074b338bc9cc155d4b4bffa4adce1615c5a426c19", size = 46053, upload-time = "2026-01-26T02:44:15.371Z" }, + { url = "https://files.pythonhosted.org/packages/0c/5b/aba28e4ee4006ae4c7df8d327d31025d760ffa992ea23812a601d226e682/multidict-6.7.1-cp312-cp312-win_arm64.whl", hash = "sha256:ba0a9fb644d0c1a2194cf7ffb043bd852cea63a57f66fbd33959f7dae18517bf", size = 43307, upload-time = "2026-01-26T02:44:16.852Z" }, + { url = "https://files.pythonhosted.org/packages/81/08/7036c080d7117f28a4af526d794aab6a84463126db031b007717c1a6676e/multidict-6.7.1-py3-none-any.whl", hash = "sha256:55d97cc6dae627efa6a6e548885712d4864b81110ac76fa4e534c03819fa4a56", size = 12319, upload-time = "2026-01-26T02:46:44.004Z" }, +] + +[[package]] +name = "orjson" +version = "3.11.7" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/53/45/b268004f745ede84e5798b48ee12b05129d19235d0e15267aa57dcdb400b/orjson-3.11.7.tar.gz", hash = "sha256:9b1a67243945819ce55d24a30b59d6a168e86220452d2c96f4d1f093e71c0c49", size = 6144992, upload-time = "2026-02-02T15:38:49.29Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/80/bf/76f4f1665f6983385938f0e2a5d7efa12a58171b8456c252f3bae8a4cf75/orjson-3.11.7-cp312-cp312-macosx_10_15_x86_64.macosx_11_0_arm64.macosx_10_15_universal2.whl", hash = "sha256:bd03ea7606833655048dab1a00734a2875e3e86c276e1d772b2a02556f0d895f", size = 228545, upload-time = "2026-02-02T15:37:46.376Z" }, + { url = "https://files.pythonhosted.org/packages/79/53/6c72c002cb13b5a978a068add59b25a8bdf2800ac1c9c8ecdb26d6d97064/orjson-3.11.7-cp312-cp312-macosx_15_0_arm64.whl", hash = "sha256:89e440ebc74ce8ab5c7bc4ce6757b4a6b1041becb127df818f6997b5c71aa60b", size = 125224, upload-time = "2026-02-02T15:37:47.697Z" }, + { url = "https://files.pythonhosted.org/packages/2c/83/10e48852865e5dd151bdfe652c06f7da484578ed02c5fca938e3632cb0b8/orjson-3.11.7-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:5ede977b5fe5ac91b1dffc0a517ca4542d2ec8a6a4ff7b2652d94f640796342a", size = 128154, upload-time = "2026-02-02T15:37:48.954Z" }, + { url = "https://files.pythonhosted.org/packages/6e/52/a66e22a2b9abaa374b4a081d410edab6d1e30024707b87eab7c734afe28d/orjson-3.11.7-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:b7b1dae39230a393df353827c855a5f176271c23434cfd2db74e0e424e693e10", size = 123548, upload-time = "2026-02-02T15:37:50.187Z" }, + { url = "https://files.pythonhosted.org/packages/de/38/605d371417021359f4910c496f764c48ceb8997605f8c25bf1dfe58c0ebe/orjson-3.11.7-cp312-cp312-manylinux_2_17_i686.manylinux2014_i686.whl", hash = "sha256:ed46f17096e28fb28d2975834836a639af7278aa87c84f68ab08fbe5b8bd75fa", size = 129000, upload-time = "2026-02-02T15:37:51.426Z" }, + { url = "https://files.pythonhosted.org/packages/44/98/af32e842b0ffd2335c89714d48ca4e3917b42f5d6ee5537832e069a4b3ac/orjson-3.11.7-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:3726be79e36e526e3d9c1aceaadbfb4a04ee80a72ab47b3f3c17fefb9812e7b8", size = 141686, upload-time = "2026-02-02T15:37:52.607Z" }, + { url = "https://files.pythonhosted.org/packages/96/0b/fc793858dfa54be6feee940c1463370ece34b3c39c1ca0aa3845f5ba9892/orjson-3.11.7-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:0724e265bc548af1dedebd9cb3d24b4e1c1e685a343be43e87ba922a5c5fff2f", size = 130812, upload-time = "2026-02-02T15:37:53.944Z" }, + { url = "https://files.pythonhosted.org/packages/dc/91/98a52415059db3f374757d0b7f0f16e3b5cd5976c90d1c2b56acaea039e6/orjson-3.11.7-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:e7745312efa9e11c17fbd3cb3097262d079da26930ae9ae7ba28fb738367cbad", size = 133440, upload-time = "2026-02-02T15:37:55.615Z" }, + { url = "https://files.pythonhosted.org/packages/dc/b6/cb540117bda61791f46381f8c26c8f93e802892830a6055748d3bb1925ab/orjson-3.11.7-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:f904c24bdeabd4298f7a977ef14ca2a022ca921ed670b92ecd16ab6f3d01f867", size = 138386, upload-time = "2026-02-02T15:37:56.814Z" }, + { url = "https://files.pythonhosted.org/packages/63/1a/50a3201c334a7f17c231eee5f841342190723794e3b06293f26e7cf87d31/orjson-3.11.7-cp312-cp312-musllinux_1_2_armv7l.whl", hash = "sha256:b9fc4d0f81f394689e0814617aadc4f2ea0e8025f38c226cbf22d3b5ddbf025d", size = 408853, upload-time = "2026-02-02T15:37:58.291Z" }, + { url = "https://files.pythonhosted.org/packages/87/cd/8de1c67d0be44fdc22701e5989c0d015a2adf391498ad42c4dc589cd3013/orjson-3.11.7-cp312-cp312-musllinux_1_2_i686.whl", hash = "sha256:849e38203e5be40b776ed2718e587faf204d184fc9a008ae441f9442320c0cab", size = 144130, upload-time = "2026-02-02T15:38:00.163Z" }, + { url = "https://files.pythonhosted.org/packages/0f/fe/d605d700c35dd55f51710d159fc54516a280923cd1b7e47508982fbb387d/orjson-3.11.7-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:4682d1db3bcebd2b64757e0ddf9e87ae5f00d29d16c5cdf3a62f561d08cc3dd2", size = 134818, upload-time = "2026-02-02T15:38:01.507Z" }, + { url = "https://files.pythonhosted.org/packages/e4/e4/15ecc67edb3ddb3e2f46ae04475f2d294e8b60c1825fbe28a428b93b3fbd/orjson-3.11.7-cp312-cp312-win32.whl", hash = "sha256:f4f7c956b5215d949a1f65334cf9d7612dde38f20a95f2315deef167def91a6f", size = 127923, upload-time = "2026-02-02T15:38:02.75Z" }, + { url = "https://files.pythonhosted.org/packages/34/70/2e0855361f76198a3965273048c8e50a9695d88cd75811a5b46444895845/orjson-3.11.7-cp312-cp312-win_amd64.whl", hash = "sha256:bf742e149121dc5648ba0a08ea0871e87b660467ef168a3a5e53bc1fbd64bb74", size = 125007, upload-time = "2026-02-02T15:38:04.032Z" }, + { url = "https://files.pythonhosted.org/packages/68/40/c2051bd19fc467610fed469dc29e43ac65891571138f476834ca192bc290/orjson-3.11.7-cp312-cp312-win_arm64.whl", hash = "sha256:26c3b9132f783b7d7903bf1efb095fed8d4a3a85ec0d334ee8beff3d7a4749d5", size = 126089, upload-time = "2026-02-02T15:38:05.297Z" }, +] + +[[package]] +name = "pamqp" +version = "3.3.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/fb/62/35bbd3d3021e008606cd0a9532db7850c65741bbf69ac8a3a0d8cfeb7934/pamqp-3.3.0.tar.gz", hash = "sha256:40b8795bd4efcf2b0f8821c1de83d12ca16d5760f4507836267fd7a02b06763b", size = 30993, upload-time = "2024-01-12T20:37:25.085Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/ac/8d/c1e93296e109a320e508e38118cf7d1fc2a4d1c2ec64de78565b3c445eb5/pamqp-3.3.0-py2.py3-none-any.whl", hash = "sha256:c901a684794157ae39b52cbf700db8c9aae7a470f13528b9d7b4e5f7202f8eb0", size = 33848, upload-time = "2024-01-12T20:37:21.359Z" }, +] + +[[package]] +name = "propcache" +version = "0.4.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/9e/da/e9fc233cf63743258bff22b3dfa7ea5baef7b5bc324af47a0ad89b8ffc6f/propcache-0.4.1.tar.gz", hash = "sha256:f48107a8c637e80362555f37ecf49abe20370e557cc4ab374f04ec4423c97c3d", size = 46442, upload-time = "2025-10-08T19:49:02.291Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/a2/0f/f17b1b2b221d5ca28b4b876e8bb046ac40466513960646bda8e1853cdfa2/propcache-0.4.1-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:e153e9cd40cc8945138822807139367f256f89c6810c2634a4f6902b52d3b4e2", size = 80061, upload-time = "2025-10-08T19:46:46.075Z" }, + { url = "https://files.pythonhosted.org/packages/76/47/8ccf75935f51448ba9a16a71b783eb7ef6b9ee60f5d14c7f8a8a79fbeed7/propcache-0.4.1-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:cd547953428f7abb73c5ad82cbb32109566204260d98e41e5dfdc682eb7f8403", size = 46037, upload-time = "2025-10-08T19:46:47.23Z" }, + { url = "https://files.pythonhosted.org/packages/0a/b6/5c9a0e42df4d00bfb4a3cbbe5cf9f54260300c88a0e9af1f47ca5ce17ac0/propcache-0.4.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:f048da1b4f243fc44f205dfd320933a951b8d89e0afd4c7cacc762a8b9165207", size = 47324, upload-time = "2025-10-08T19:46:48.384Z" }, + { url = "https://files.pythonhosted.org/packages/9e/d3/6c7ee328b39a81ee877c962469f1e795f9db87f925251efeb0545e0020d0/propcache-0.4.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:ec17c65562a827bba85e3872ead335f95405ea1674860d96483a02f5c698fa72", size = 225505, upload-time = "2025-10-08T19:46:50.055Z" }, + { url = "https://files.pythonhosted.org/packages/01/5d/1c53f4563490b1d06a684742cc6076ef944bc6457df6051b7d1a877c057b/propcache-0.4.1-cp312-cp312-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:405aac25c6394ef275dee4c709be43745d36674b223ba4eb7144bf4d691b7367", size = 230242, upload-time = "2025-10-08T19:46:51.815Z" }, + { url = "https://files.pythonhosted.org/packages/20/e1/ce4620633b0e2422207c3cb774a0ee61cac13abc6217763a7b9e2e3f4a12/propcache-0.4.1-cp312-cp312-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:0013cb6f8dde4b2a2f66903b8ba740bdfe378c943c4377a200551ceb27f379e4", size = 238474, upload-time = "2025-10-08T19:46:53.208Z" }, + { url = "https://files.pythonhosted.org/packages/46/4b/3aae6835b8e5f44ea6a68348ad90f78134047b503765087be2f9912140ea/propcache-0.4.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:15932ab57837c3368b024473a525e25d316d8353016e7cc0e5ba9eb343fbb1cf", size = 221575, upload-time = "2025-10-08T19:46:54.511Z" }, + { url = "https://files.pythonhosted.org/packages/6e/a5/8a5e8678bcc9d3a1a15b9a29165640d64762d424a16af543f00629c87338/propcache-0.4.1-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:031dce78b9dc099f4c29785d9cf5577a3faf9ebf74ecbd3c856a7b92768c3df3", size = 216736, upload-time = "2025-10-08T19:46:56.212Z" }, + { url = "https://files.pythonhosted.org/packages/f1/63/b7b215eddeac83ca1c6b934f89d09a625aa9ee4ba158338854c87210cc36/propcache-0.4.1-cp312-cp312-musllinux_1_2_armv7l.whl", hash = "sha256:ab08df6c9a035bee56e31af99be621526bd237bea9f32def431c656b29e41778", size = 213019, upload-time = "2025-10-08T19:46:57.595Z" }, + { url = "https://files.pythonhosted.org/packages/57/74/f580099a58c8af587cac7ba19ee7cb418506342fbbe2d4a4401661cca886/propcache-0.4.1-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:4d7af63f9f93fe593afbf104c21b3b15868efb2c21d07d8732c0c4287e66b6a6", size = 220376, upload-time = "2025-10-08T19:46:59.067Z" }, + { url = "https://files.pythonhosted.org/packages/c4/ee/542f1313aff7eaf19c2bb758c5d0560d2683dac001a1c96d0774af799843/propcache-0.4.1-cp312-cp312-musllinux_1_2_s390x.whl", hash = "sha256:cfc27c945f422e8b5071b6e93169679e4eb5bf73bbcbf1ba3ae3a83d2f78ebd9", size = 226988, upload-time = "2025-10-08T19:47:00.544Z" }, + { url = "https://files.pythonhosted.org/packages/8f/18/9c6b015dd9c6930f6ce2229e1f02fb35298b847f2087ea2b436a5bfa7287/propcache-0.4.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:35c3277624a080cc6ec6f847cbbbb5b49affa3598c4535a0a4682a697aaa5c75", size = 215615, upload-time = "2025-10-08T19:47:01.968Z" }, + { url = "https://files.pythonhosted.org/packages/80/9e/e7b85720b98c45a45e1fca6a177024934dc9bc5f4d5dd04207f216fc33ed/propcache-0.4.1-cp312-cp312-win32.whl", hash = "sha256:671538c2262dadb5ba6395e26c1731e1d52534bfe9ae56d0b5573ce539266aa8", size = 38066, upload-time = "2025-10-08T19:47:03.503Z" }, + { url = "https://files.pythonhosted.org/packages/54/09/d19cff2a5aaac632ec8fc03737b223597b1e347416934c1b3a7df079784c/propcache-0.4.1-cp312-cp312-win_amd64.whl", hash = "sha256:cb2d222e72399fcf5890d1d5cc1060857b9b236adff2792ff48ca2dfd46c81db", size = 41655, upload-time = "2025-10-08T19:47:04.973Z" }, + { url = "https://files.pythonhosted.org/packages/68/ab/6b5c191bb5de08036a8c697b265d4ca76148efb10fa162f14af14fb5f076/propcache-0.4.1-cp312-cp312-win_arm64.whl", hash = "sha256:204483131fb222bdaaeeea9f9e6c6ed0cac32731f75dfc1d4a567fc1926477c1", size = 37789, upload-time = "2025-10-08T19:47:06.077Z" }, + { url = "https://files.pythonhosted.org/packages/5b/5a/bc7b4a4ef808fa59a816c17b20c4bef6884daebbdf627ff2a161da67da19/propcache-0.4.1-py3-none-any.whl", hash = "sha256:af2a6052aeb6cf17d3e46ee169099044fd8224cbaf75c76a2ef596e8163e2237", size = 13305, upload-time = "2025-10-08T19:49:00.792Z" }, +] + +[[package]] +name = "pyasn1" +version = "0.6.2" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/fe/b6/6e630dff89739fcd427e3f72b3d905ce0acb85a45d4ec3e2678718a3487f/pyasn1-0.6.2.tar.gz", hash = "sha256:9b59a2b25ba7e4f8197db7686c09fb33e658b98339fadb826e9512629017833b", size = 146586, upload-time = "2026-01-16T18:04:18.534Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/44/b5/a96872e5184f354da9c84ae119971a0a4c221fe9b27a4d94bd43f2596727/pyasn1-0.6.2-py3-none-any.whl", hash = "sha256:1eb26d860996a18e9b6ed05e7aae0e9fc21619fcee6af91cca9bad4fbea224bf", size = 83371, upload-time = "2026-01-16T18:04:17.174Z" }, +] + +[[package]] +name = "pydantic" +version = "2.12.5" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "annotated-types" }, + { name = "pydantic-core" }, + { name = "typing-extensions" }, + { name = "typing-inspection" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/69/44/36f1a6e523abc58ae5f928898e4aca2e0ea509b5aa6f6f392a5d882be928/pydantic-2.12.5.tar.gz", hash = "sha256:4d351024c75c0f085a9febbb665ce8c0c6ec5d30e903bdb6394b7ede26aebb49", size = 821591, upload-time = "2025-11-26T15:11:46.471Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/5a/87/b70ad306ebb6f9b585f114d0ac2137d792b48be34d732d60e597c2f8465a/pydantic-2.12.5-py3-none-any.whl", hash = "sha256:e561593fccf61e8a20fc46dfc2dfe075b8be7d0188df33f221ad1f0139180f9d", size = 463580, upload-time = "2025-11-26T15:11:44.605Z" }, +] + +[[package]] +name = "pydantic-core" +version = "2.41.5" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/71/70/23b021c950c2addd24ec408e9ab05d59b035b39d97cdc1130e1bce647bb6/pydantic_core-2.41.5.tar.gz", hash = "sha256:08daa51ea16ad373ffd5e7606252cc32f07bc72b28284b6bc9c6df804816476e", size = 460952, upload-time = "2025-11-04T13:43:49.098Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/5f/5d/5f6c63eebb5afee93bcaae4ce9a898f3373ca23df3ccaef086d0233a35a7/pydantic_core-2.41.5-cp312-cp312-macosx_10_12_x86_64.whl", hash = "sha256:f41a7489d32336dbf2199c8c0a215390a751c5b014c2c1c5366e817202e9cdf7", size = 2110990, upload-time = "2025-11-04T13:39:58.079Z" }, + { url = "https://files.pythonhosted.org/packages/aa/32/9c2e8ccb57c01111e0fd091f236c7b371c1bccea0fa85247ac55b1e2b6b6/pydantic_core-2.41.5-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:070259a8818988b9a84a449a2a7337c7f430a22acc0859c6b110aa7212a6d9c0", size = 1896003, upload-time = "2025-11-04T13:39:59.956Z" }, + { url = "https://files.pythonhosted.org/packages/68/b8/a01b53cb0e59139fbc9e4fda3e9724ede8de279097179be4ff31f1abb65a/pydantic_core-2.41.5-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:e96cea19e34778f8d59fe40775a7a574d95816eb150850a85a7a4c8f4b94ac69", size = 1919200, upload-time = "2025-11-04T13:40:02.241Z" }, + { url = "https://files.pythonhosted.org/packages/38/de/8c36b5198a29bdaade07b5985e80a233a5ac27137846f3bc2d3b40a47360/pydantic_core-2.41.5-cp312-cp312-manylinux_2_17_armv7l.manylinux2014_armv7l.whl", hash = "sha256:ed2e99c456e3fadd05c991f8f437ef902e00eedf34320ba2b0842bd1c3ca3a75", size = 2052578, upload-time = "2025-11-04T13:40:04.401Z" }, + { url = "https://files.pythonhosted.org/packages/00/b5/0e8e4b5b081eac6cb3dbb7e60a65907549a1ce035a724368c330112adfdd/pydantic_core-2.41.5-cp312-cp312-manylinux_2_17_ppc64le.manylinux2014_ppc64le.whl", hash = "sha256:65840751b72fbfd82c3c640cff9284545342a4f1eb1586ad0636955b261b0b05", size = 2208504, upload-time = "2025-11-04T13:40:06.072Z" }, + { url = "https://files.pythonhosted.org/packages/77/56/87a61aad59c7c5b9dc8caad5a41a5545cba3810c3e828708b3d7404f6cef/pydantic_core-2.41.5-cp312-cp312-manylinux_2_17_s390x.manylinux2014_s390x.whl", hash = "sha256:e536c98a7626a98feb2d3eaf75944ef6f3dbee447e1f841eae16f2f0a72d8ddc", size = 2335816, upload-time = "2025-11-04T13:40:07.835Z" }, + { url = "https://files.pythonhosted.org/packages/0d/76/941cc9f73529988688a665a5c0ecff1112b3d95ab48f81db5f7606f522d3/pydantic_core-2.41.5-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:eceb81a8d74f9267ef4081e246ffd6d129da5d87e37a77c9bde550cb04870c1c", size = 2075366, upload-time = "2025-11-04T13:40:09.804Z" }, + { url = "https://files.pythonhosted.org/packages/d3/43/ebef01f69baa07a482844faaa0a591bad1ef129253ffd0cdaa9d8a7f72d3/pydantic_core-2.41.5-cp312-cp312-manylinux_2_5_i686.manylinux1_i686.whl", hash = "sha256:d38548150c39b74aeeb0ce8ee1d8e82696f4a4e16ddc6de7b1d8823f7de4b9b5", size = 2171698, upload-time = "2025-11-04T13:40:12.004Z" }, + { url = "https://files.pythonhosted.org/packages/b1/87/41f3202e4193e3bacfc2c065fab7706ebe81af46a83d3e27605029c1f5a6/pydantic_core-2.41.5-cp312-cp312-musllinux_1_1_aarch64.whl", hash = "sha256:c23e27686783f60290e36827f9c626e63154b82b116d7fe9adba1fda36da706c", size = 2132603, upload-time = "2025-11-04T13:40:13.868Z" }, + { url = "https://files.pythonhosted.org/packages/49/7d/4c00df99cb12070b6bccdef4a195255e6020a550d572768d92cc54dba91a/pydantic_core-2.41.5-cp312-cp312-musllinux_1_1_armv7l.whl", hash = "sha256:482c982f814460eabe1d3bb0adfdc583387bd4691ef00b90575ca0d2b6fe2294", size = 2329591, upload-time = "2025-11-04T13:40:15.672Z" }, + { url = "https://files.pythonhosted.org/packages/cc/6a/ebf4b1d65d458f3cda6a7335d141305dfa19bdc61140a884d165a8a1bbc7/pydantic_core-2.41.5-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:bfea2a5f0b4d8d43adf9d7b8bf019fb46fdd10a2e5cde477fbcb9d1fa08c68e1", size = 2319068, upload-time = "2025-11-04T13:40:17.532Z" }, + { url = "https://files.pythonhosted.org/packages/49/3b/774f2b5cd4192d5ab75870ce4381fd89cf218af999515baf07e7206753f0/pydantic_core-2.41.5-cp312-cp312-win32.whl", hash = "sha256:b74557b16e390ec12dca509bce9264c3bbd128f8a2c376eaa68003d7f327276d", size = 1985908, upload-time = "2025-11-04T13:40:19.309Z" }, + { url = "https://files.pythonhosted.org/packages/86/45/00173a033c801cacf67c190fef088789394feaf88a98a7035b0e40d53dc9/pydantic_core-2.41.5-cp312-cp312-win_amd64.whl", hash = "sha256:1962293292865bca8e54702b08a4f26da73adc83dd1fcf26fbc875b35d81c815", size = 2020145, upload-time = "2025-11-04T13:40:21.548Z" }, + { url = "https://files.pythonhosted.org/packages/f9/22/91fbc821fa6d261b376a3f73809f907cec5ca6025642c463d3488aad22fb/pydantic_core-2.41.5-cp312-cp312-win_arm64.whl", hash = "sha256:1746d4a3d9a794cacae06a5eaaccb4b8643a131d45fbc9af23e353dc0a5ba5c3", size = 1976179, upload-time = "2025-11-04T13:40:23.393Z" }, + { url = "https://files.pythonhosted.org/packages/09/32/59b0c7e63e277fa7911c2fc70ccfb45ce4b98991e7ef37110663437005af/pydantic_core-2.41.5-graalpy312-graalpy250_312_native-macosx_10_12_x86_64.whl", hash = "sha256:7da7087d756b19037bc2c06edc6c170eeef3c3bafcb8f532ff17d64dc427adfd", size = 2110495, upload-time = "2025-11-04T13:42:49.689Z" }, + { url = "https://files.pythonhosted.org/packages/aa/81/05e400037eaf55ad400bcd318c05bb345b57e708887f07ddb2d20e3f0e98/pydantic_core-2.41.5-graalpy312-graalpy250_312_native-macosx_11_0_arm64.whl", hash = "sha256:aabf5777b5c8ca26f7824cb4a120a740c9588ed58df9b2d196ce92fba42ff8dc", size = 1915388, upload-time = "2025-11-04T13:42:52.215Z" }, + { url = "https://files.pythonhosted.org/packages/6e/0d/e3549b2399f71d56476b77dbf3cf8937cec5cd70536bdc0e374a421d0599/pydantic_core-2.41.5-graalpy312-graalpy250_312_native-manylinux_2_17_aarch64.manylinux2014_aarch64.whl", hash = "sha256:c007fe8a43d43b3969e8469004e9845944f1a80e6acd47c150856bb87f230c56", size = 1942879, upload-time = "2025-11-04T13:42:56.483Z" }, + { url = "https://files.pythonhosted.org/packages/f7/07/34573da085946b6a313d7c42f82f16e8920bfd730665de2d11c0c37a74b5/pydantic_core-2.41.5-graalpy312-graalpy250_312_native-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:76d0819de158cd855d1cbb8fcafdf6f5cf1eb8e470abe056d5d161106e38062b", size = 2139017, upload-time = "2025-11-04T13:42:59.471Z" }, +] + +[[package]] +name = "pydantic-settings" +version = "2.12.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "pydantic" }, + { name = "python-dotenv" }, + { name = "typing-inspection" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/43/4b/ac7e0aae12027748076d72a8764ff1c9d82ca75a7a52622e67ed3f765c54/pydantic_settings-2.12.0.tar.gz", hash = "sha256:005538ef951e3c2a68e1c08b292b5f2e71490def8589d4221b95dab00dafcfd0", size = 194184, upload-time = "2025-11-10T14:25:47.013Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/c1/60/5d4751ba3f4a40a6891f24eec885f51afd78d208498268c734e256fb13c4/pydantic_settings-2.12.0-py3-none-any.whl", hash = "sha256:fddb9fd99a5b18da837b29710391e945b1e30c135477f484084ee513adb93809", size = 51880, upload-time = "2025-11-10T14:25:45.546Z" }, +] + +[[package]] +name = "python-dotenv" +version = "1.2.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/f0/26/19cadc79a718c5edbec86fd4919a6b6d3f681039a2f6d66d14be94e75fb9/python_dotenv-1.2.1.tar.gz", hash = "sha256:42667e897e16ab0d66954af0e60a9caa94f0fd4ecf3aaf6d2d260eec1aa36ad6", size = 44221, upload-time = "2025-10-26T15:12:10.434Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/14/1b/a298b06749107c305e1fe0f814c6c74aea7b2f1e10989cb30f544a1b3253/python_dotenv-1.2.1-py3-none-any.whl", hash = "sha256:b81ee9561e9ca4004139c6cbba3a238c32b03e4894671e181b671e8cb8425d61", size = 21230, upload-time = "2025-10-26T15:12:09.109Z" }, +] + +[[package]] +name = "python-jose" +version = "3.5.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "ecdsa" }, + { name = "pyasn1" }, + { name = "rsa" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/c6/77/3a1c9039db7124eb039772b935f2244fbb73fc8ee65b9acf2375da1c07bf/python_jose-3.5.0.tar.gz", hash = "sha256:fb4eaa44dbeb1c26dcc69e4bd7ec54a1cb8dd64d3b4d81ef08d90ff453f2b01b", size = 92726, upload-time = "2025-05-28T17:31:54.288Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/d9/c3/0bd11992072e6a1c513b16500a5d07f91a24017c5909b02c72c62d7ad024/python_jose-3.5.0-py2.py3-none-any.whl", hash = "sha256:abd1202f23d34dfad2c3d28cb8617b90acf34132c7afd60abd0b0b7d3cb55771", size = 34624, upload-time = "2025-05-28T17:31:52.802Z" }, +] + +[[package]] +name = "python-ulid" +version = "3.1.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/40/7e/0d6c82b5ccc71e7c833aed43d9e8468e1f2ff0be1b3f657a6fcafbb8433d/python_ulid-3.1.0.tar.gz", hash = "sha256:ff0410a598bc5f6b01b602851a3296ede6f91389f913a5d5f8c496003836f636", size = 93175, upload-time = "2025-08-18T16:09:26.305Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/6c/a0/4ed6632b70a52de845df056654162acdebaf97c20e3212c559ac43e7216e/python_ulid-3.1.0-py3-none-any.whl", hash = "sha256:e2cdc979c8c877029b4b7a38a6fba3bc4578e4f109a308419ff4d3ccf0a46619", size = 11577, upload-time = "2025-08-18T16:09:25.047Z" }, +] + +[[package]] +name = "redis" +version = "7.2.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/9f/32/6fac13a11e73e1bc67a2ae821a72bfe4c2d8c4c48f0267e4a952be0f1bae/redis-7.2.0.tar.gz", hash = "sha256:4dd5bf4bd4ae80510267f14185a15cba2a38666b941aff68cccf0256b51c1f26", size = 4901247, upload-time = "2026-02-16T17:16:22.797Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/86/cf/f6180b67f99688d83e15c84c5beda831d1d341e95872d224f87ccafafe61/redis-7.2.0-py3-none-any.whl", hash = "sha256:01f591f8598e483f1842d429e8ae3a820804566f1c73dca1b80e23af9fba0497", size = 394898, upload-time = "2026-02-16T17:16:20.693Z" }, +] + +[[package]] +name = "requests" +version = "2.32.5" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "certifi" }, + { name = "charset-normalizer" }, + { name = "idna" }, + { name = "urllib3" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/c9/74/b3ff8e6c8446842c3f5c837e9c3dfcfe2018ea6ecef224c710c85ef728f4/requests-2.32.5.tar.gz", hash = "sha256:dbba0bac56e100853db0ea71b82b4dfd5fe2bf6d3754a8893c3af500cec7d7cf", size = 134517, upload-time = "2025-08-18T20:46:02.573Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/1e/db/4254e3eabe8020b458f1a747140d32277ec7a271daf1d235b70dc0b4e6e3/requests-2.32.5-py3-none-any.whl", hash = "sha256:2462f94637a34fd532264295e186976db0f5d453d1cdd31473c85a6a161affb6", size = 64738, upload-time = "2025-08-18T20:46:00.542Z" }, +] + +[[package]] +name = "rsa" +version = "4.9.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "pyasn1" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/da/8a/22b7beea3ee0d44b1916c0c1cb0ee3af23b700b6da9f04991899d0c555d4/rsa-4.9.1.tar.gz", hash = "sha256:e7bdbfdb5497da4c07dfd35530e1a902659db6ff241e39d9953cad06ebd0ae75", size = 29034, upload-time = "2025-04-16T09:51:18.218Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/64/8d/0133e4eb4beed9e425d9a98ed6e081a55d195481b7632472be1af08d2f6b/rsa-4.9.1-py3-none-any.whl", hash = "sha256:68635866661c6836b8d39430f97a996acbd61bfa49406748ea243539fe239762", size = 34696, upload-time = "2025-04-16T09:51:17.142Z" }, +] + +[[package]] +name = "six" +version = "1.17.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/94/e7/b2c673351809dca68a0e064b6af791aa332cf192da575fd474ed7d6f16a2/six-1.17.0.tar.gz", hash = "sha256:ff70335d468e7eb6ec65b95b99d3a2836546063f63acc5171de367e834932a81", size = 34031, upload-time = "2024-12-04T17:35:28.174Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/b7/ce/149a00dd41f10bc29e5921b496af8b574d8413afcd5e30dfa0ed46c2cc5e/six-1.17.0-py2.py3-none-any.whl", hash = "sha256:4721f391ed90541fddacab5acf947aa0d3dc7d27b2e1e8eda2be8970586c3274", size = 11050, upload-time = "2024-12-04T17:35:26.475Z" }, +] + +[[package]] +name = "sqlalchemy" +version = "2.0.46" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "greenlet", marker = "platform_machine == 'AMD64' or platform_machine == 'WIN32' or platform_machine == 'aarch64' or platform_machine == 'amd64' or platform_machine == 'ppc64le' or platform_machine == 'win32' or platform_machine == 'x86_64'" }, + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/06/aa/9ce0f3e7a9829ead5c8ce549392f33a12c4555a6c0609bb27d882e9c7ddf/sqlalchemy-2.0.46.tar.gz", hash = "sha256:cf36851ee7219c170bb0793dbc3da3e80c582e04a5437bc601bfe8c85c9216d7", size = 9865393, upload-time = "2026-01-21T18:03:45.119Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/b6/35/d16bfa235c8b7caba3730bba43e20b1e376d2224f407c178fbf59559f23e/sqlalchemy-2.0.46-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:3a9a72b0da8387f15d5810f1facca8f879de9b85af8c645138cba61ea147968c", size = 2153405, upload-time = "2026-01-21T19:05:54.143Z" }, + { url = "https://files.pythonhosted.org/packages/06/6c/3192e24486749862f495ddc6584ed730c0c994a67550ec395d872a2ad650/sqlalchemy-2.0.46-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:2347c3f0efc4de367ba00218e0ae5c4ba2306e47216ef80d6e31761ac97cb0b9", size = 3334702, upload-time = "2026-01-21T18:46:45.384Z" }, + { url = "https://files.pythonhosted.org/packages/ea/a2/b9f33c8d68a3747d972a0bb758c6b63691f8fb8a49014bc3379ba15d4274/sqlalchemy-2.0.46-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:9094c8b3197db12aa6f05c51c05daaad0a92b8c9af5388569847b03b1007fb1b", size = 3347664, upload-time = "2026-01-21T18:40:09.979Z" }, + { url = "https://files.pythonhosted.org/packages/aa/d2/3e59e2a91eaec9db7e8dc6b37b91489b5caeb054f670f32c95bcba98940f/sqlalchemy-2.0.46-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:37fee2164cf21417478b6a906adc1a91d69ae9aba8f9533e67ce882f4bb1de53", size = 3277372, upload-time = "2026-01-21T18:46:47.168Z" }, + { url = "https://files.pythonhosted.org/packages/dd/dd/67bc2e368b524e2192c3927b423798deda72c003e73a1e94c21e74b20a85/sqlalchemy-2.0.46-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:b1e14b2f6965a685c7128bd315e27387205429c2e339eeec55cb75ca4ab0ea2e", size = 3312425, upload-time = "2026-01-21T18:40:11.548Z" }, + { url = "https://files.pythonhosted.org/packages/43/82/0ecd68e172bfe62247e96cb47867c2d68752566811a4e8c9d8f6e7c38a65/sqlalchemy-2.0.46-cp312-cp312-win32.whl", hash = "sha256:412f26bb4ba942d52016edc8d12fb15d91d3cd46b0047ba46e424213ad407bcb", size = 2113155, upload-time = "2026-01-21T18:42:49.748Z" }, + { url = "https://files.pythonhosted.org/packages/bc/2a/2821a45742073fc0331dc132552b30de68ba9563230853437cac54b2b53e/sqlalchemy-2.0.46-cp312-cp312-win_amd64.whl", hash = "sha256:ea3cd46b6713a10216323cda3333514944e510aa691c945334713fca6b5279ff", size = 2140078, upload-time = "2026-01-21T18:42:51.197Z" }, + { url = "https://files.pythonhosted.org/packages/fc/a1/9c4efa03300926601c19c18582531b45aededfb961ab3c3585f1e24f120b/sqlalchemy-2.0.46-py3-none-any.whl", hash = "sha256:f9c11766e7e7c0a2767dda5acb006a118640c9fc0a4104214b96269bfb78399e", size = 1937882, upload-time = "2026-01-21T18:22:10.456Z" }, +] + +[[package]] +name = "starlette" +version = "0.52.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "anyio" }, + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/c4/68/79977123bb7be889ad680d79a40f339082c1978b5cfcf62c2d8d196873ac/starlette-0.52.1.tar.gz", hash = "sha256:834edd1b0a23167694292e94f597773bc3f89f362be6effee198165a35d62933", size = 2653702, upload-time = "2026-01-18T13:34:11.062Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/81/0d/13d1d239a25cbfb19e740db83143e95c772a1fe10202dda4b76792b114dd/starlette-0.52.1-py3-none-any.whl", hash = "sha256:0029d43eb3d273bc4f83a08720b4912ea4b071087a3b48db01b7c839f7954d74", size = 74272, upload-time = "2026-01-18T13:34:09.188Z" }, +] + +[[package]] +name = "typing-extensions" +version = "4.15.0" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/72/94/1a15dd82efb362ac84269196e94cf00f187f7ed21c242792a923cdb1c61f/typing_extensions-4.15.0.tar.gz", hash = "sha256:0cea48d173cc12fa28ecabc3b837ea3cf6f38c6d1136f85cbaaf598984861466", size = 109391, upload-time = "2025-08-25T13:49:26.313Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/18/67/36e9267722cc04a6b9f15c7f3441c2363321a3ea07da7ae0c0707beb2a9c/typing_extensions-4.15.0-py3-none-any.whl", hash = "sha256:f0fa19c6845758ab08074a0cfa8b7aecb71c999ca73d62883bc25cc018c4e548", size = 44614, upload-time = "2025-08-25T13:49:24.86Z" }, +] + +[[package]] +name = "typing-inspection" +version = "0.4.2" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "typing-extensions" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/55/e3/70399cb7dd41c10ac53367ae42139cf4b1ca5f36bb3dc6c9d33acdb43655/typing_inspection-0.4.2.tar.gz", hash = "sha256:ba561c48a67c5958007083d386c3295464928b01faa735ab8547c5692e87f464", size = 75949, upload-time = "2025-10-01T02:14:41.687Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/dc/9b/47798a6c91d8bdb567fe2698fe81e0c6b7cb7ef4d13da4114b41d239f65d/typing_inspection-0.4.2-py3-none-any.whl", hash = "sha256:4ed1cacbdc298c220f1bd249ed5287caa16f34d44ef4e9c3d0cbad5b521545e7", size = 14611, upload-time = "2025-10-01T02:14:40.154Z" }, +] + +[[package]] +name = "tzdata" +version = "2025.3" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/5e/a7/c202b344c5ca7daf398f3b8a477eeb205cf3b6f32e7ec3a6bac0629ca975/tzdata-2025.3.tar.gz", hash = "sha256:de39c2ca5dc7b0344f2eba86f49d614019d29f060fc4ebc8a417896a620b56a7", size = 196772, upload-time = "2025-12-13T17:45:35.667Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/c7/b0/003792df09decd6849a5e39c28b513c06e84436a54440380862b5aeff25d/tzdata-2025.3-py2.py3-none-any.whl", hash = "sha256:06a47e5700f3081aab02b2e513160914ff0694bce9947d6b76ebd6bf57cfc5d1", size = 348521, upload-time = "2025-12-13T17:45:33.889Z" }, +] + +[[package]] +name = "tzlocal" +version = "5.3.1" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "tzdata", marker = "sys_platform == 'win32'" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/8b/2e/c14812d3d4d9cd1773c6be938f89e5735a1f11a9f184ac3639b93cef35d5/tzlocal-5.3.1.tar.gz", hash = "sha256:cceffc7edecefea1f595541dbd6e990cb1ea3d19bf01b2809f362a03dd7921fd", size = 30761, upload-time = "2025-03-05T21:17:41.549Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/c2/14/e2a54fabd4f08cd7af1c07030603c3356b74da07f7cc056e600436edfa17/tzlocal-5.3.1-py3-none-any.whl", hash = "sha256:eb1a66c3ef5847adf7a834f1be0800581b683b5608e74f86ecbcef8ab91bb85d", size = 18026, upload-time = "2025-03-05T21:17:39.857Z" }, +] + +[[package]] +name = "urllib3" +version = "2.6.3" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/c7/24/5f1b3bdffd70275f6661c76461e25f024d5a38a46f04aaca912426a2b1d3/urllib3-2.6.3.tar.gz", hash = "sha256:1b62b6884944a57dbe321509ab94fd4d3b307075e0c2eae991ac71ee15ad38ed", size = 435556, upload-time = "2026-01-07T16:24:43.925Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/39/08/aaaad47bc4e9dc8c725e68f9d04865dbcb2052843ff09c97b08904852d84/urllib3-2.6.3-py3-none-any.whl", hash = "sha256:bf272323e553dfb2e87d9bfd225ca7b0f467b919d7bbd355436d3fd37cb0acd4", size = 131584, upload-time = "2026-01-07T16:24:42.685Z" }, +] + +[[package]] +name = "uvloop" +version = "0.22.1" +source = { registry = "https://pypi.org/simple" } +sdist = { url = "https://files.pythonhosted.org/packages/06/f0/18d39dbd1971d6d62c4629cc7fa67f74821b0dc1f5a77af43719de7936a7/uvloop-0.22.1.tar.gz", hash = "sha256:6c84bae345b9147082b17371e3dd5d42775bddce91f885499017f4607fdaf39f", size = 2443250, upload-time = "2025-10-16T22:17:19.342Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/3d/ff/7f72e8170be527b4977b033239a83a68d5c881cc4775fca255c677f7ac5d/uvloop-0.22.1-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:fe94b4564e865d968414598eea1a6de60adba0c040ba4ed05ac1300de402cd42", size = 1359936, upload-time = "2025-10-16T22:16:29.436Z" }, + { url = "https://files.pythonhosted.org/packages/c3/c6/e5d433f88fd54d81ef4be58b2b7b0cea13c442454a1db703a1eea0db1a59/uvloop-0.22.1-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:51eb9bd88391483410daad430813d982010f9c9c89512321f5b60e2cddbdddd6", size = 752769, upload-time = "2025-10-16T22:16:30.493Z" }, + { url = "https://files.pythonhosted.org/packages/24/68/a6ac446820273e71aa762fa21cdcc09861edd3536ff47c5cd3b7afb10eeb/uvloop-0.22.1-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:700e674a166ca5778255e0e1dc4e9d79ab2acc57b9171b79e65feba7184b3370", size = 4317413, upload-time = "2025-10-16T22:16:31.644Z" }, + { url = "https://files.pythonhosted.org/packages/5f/6f/e62b4dfc7ad6518e7eff2516f680d02a0f6eb62c0c212e152ca708a0085e/uvloop-0.22.1-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:7b5b1ac819a3f946d3b2ee07f09149578ae76066d70b44df3fa990add49a82e4", size = 4426307, upload-time = "2025-10-16T22:16:32.917Z" }, + { url = "https://files.pythonhosted.org/packages/90/60/97362554ac21e20e81bcef1150cb2a7e4ffdaf8ea1e5b2e8bf7a053caa18/uvloop-0.22.1-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:e047cc068570bac9866237739607d1313b9253c3051ad84738cbb095be0537b2", size = 4131970, upload-time = "2025-10-16T22:16:34.015Z" }, + { url = "https://files.pythonhosted.org/packages/99/39/6b3f7d234ba3964c428a6e40006340f53ba37993f46ed6e111c6e9141d18/uvloop-0.22.1-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:512fec6815e2dd45161054592441ef76c830eddaad55c8aa30952e6fe1ed07c0", size = 4296343, upload-time = "2025-10-16T22:16:35.149Z" }, +] + +[[package]] +name = "yarl" +version = "1.23.0" +source = { registry = "https://pypi.org/simple" } +dependencies = [ + { name = "idna" }, + { name = "multidict" }, + { name = "propcache" }, +] +sdist = { url = "https://files.pythonhosted.org/packages/23/6e/beb1beec874a72f23815c1434518bfc4ed2175065173fb138c3705f658d4/yarl-1.23.0.tar.gz", hash = "sha256:53b1ea6ca88ebd4420379c330aea57e258408dd0df9af0992e5de2078dc9f5d5", size = 194676, upload-time = "2026-03-01T22:07:53.373Z" } +wheels = [ + { url = "https://files.pythonhosted.org/packages/88/8a/94615bc31022f711add374097ad4144d569e95ff3c38d39215d07ac153a0/yarl-1.23.0-cp312-cp312-macosx_10_13_universal2.whl", hash = "sha256:1932b6b8bba8d0160a9d1078aae5838a66039e8832d41d2992daa9a3a08f7860", size = 124737, upload-time = "2026-03-01T22:05:12.897Z" }, + { url = "https://files.pythonhosted.org/packages/e3/6f/c6554045d59d64052698add01226bc867b52fe4a12373415d7991fdca95d/yarl-1.23.0-cp312-cp312-macosx_10_13_x86_64.whl", hash = "sha256:411225bae281f114067578891bc75534cfb3d92a3b4dfef7a6ca78ba354e6069", size = 87029, upload-time = "2026-03-01T22:05:14.376Z" }, + { url = "https://files.pythonhosted.org/packages/19/2a/725ecc166d53438bc88f76822ed4b1e3b10756e790bafd7b523fe97c322d/yarl-1.23.0-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:13a563739ae600a631c36ce096615fe307f131344588b0bc0daec108cdb47b25", size = 86310, upload-time = "2026-03-01T22:05:15.71Z" }, + { url = "https://files.pythonhosted.org/packages/99/30/58260ed98e6ff7f90ba84442c1ddd758c9170d70327394a6227b310cd60f/yarl-1.23.0-cp312-cp312-manylinux2014_aarch64.manylinux_2_17_aarch64.manylinux_2_28_aarch64.whl", hash = "sha256:9cbf44c5cb4a7633d078788e1b56387e3d3cf2b8139a3be38040b22d6c3221c8", size = 97587, upload-time = "2026-03-01T22:05:17.384Z" }, + { url = "https://files.pythonhosted.org/packages/76/0a/8b08aac08b50682e65759f7f8dde98ae8168f72487e7357a5d684c581ef9/yarl-1.23.0-cp312-cp312-manylinux2014_armv7l.manylinux_2_17_armv7l.manylinux_2_31_armv7l.whl", hash = "sha256:53ad387048f6f09a8969631e4de3f1bf70c50e93545d64af4f751b2498755072", size = 92528, upload-time = "2026-03-01T22:05:18.804Z" }, + { url = "https://files.pythonhosted.org/packages/52/07/0b7179101fe5f8385ec6c6bb5d0cb9f76bd9fb4a769591ab6fb5cdbfc69a/yarl-1.23.0-cp312-cp312-manylinux2014_ppc64le.manylinux_2_17_ppc64le.manylinux_2_28_ppc64le.whl", hash = "sha256:4a59ba56f340334766f3a4442e0efd0af895fae9e2b204741ef885c446b3a1a8", size = 105339, upload-time = "2026-03-01T22:05:20.235Z" }, + { url = "https://files.pythonhosted.org/packages/d3/8a/36d82869ab5ec829ca8574dfcb92b51286fcfb1e9c7a73659616362dc880/yarl-1.23.0-cp312-cp312-manylinux2014_s390x.manylinux_2_17_s390x.manylinux_2_28_s390x.whl", hash = "sha256:803a3c3ce4acc62eaf01eaca1208dcf0783025ef27572c3336502b9c232005e7", size = 105061, upload-time = "2026-03-01T22:05:22.268Z" }, + { url = "https://files.pythonhosted.org/packages/66/3e/868e5c3364b6cee19ff3e1a122194fa4ce51def02c61023970442162859e/yarl-1.23.0-cp312-cp312-manylinux2014_x86_64.manylinux_2_17_x86_64.manylinux_2_28_x86_64.whl", hash = "sha256:a3d2bff8f37f8d0f96c7ec554d16945050d54462d6e95414babaa18bfafc7f51", size = 100132, upload-time = "2026-03-01T22:05:23.638Z" }, + { url = "https://files.pythonhosted.org/packages/cf/26/9c89acf82f08a52cb52d6d39454f8d18af15f9d386a23795389d1d423823/yarl-1.23.0-cp312-cp312-manylinux_2_31_riscv64.manylinux_2_39_riscv64.whl", hash = "sha256:c75eb09e8d55bceb4367e83496ff8ef2bc7ea6960efb38e978e8073ea59ecb67", size = 99289, upload-time = "2026-03-01T22:05:25.749Z" }, + { url = "https://files.pythonhosted.org/packages/6f/54/5b0db00d2cb056922356104468019c0a132e89c8d3ab67d8ede9f4483d2a/yarl-1.23.0-cp312-cp312-musllinux_1_2_aarch64.whl", hash = "sha256:877b0738624280e34c55680d6054a307aa94f7d52fa0e3034a9cc6e790871da7", size = 96950, upload-time = "2026-03-01T22:05:27.318Z" }, + { url = "https://files.pythonhosted.org/packages/f6/40/10fa93811fd439341fad7e0718a86aca0de9548023bbb403668d6555acab/yarl-1.23.0-cp312-cp312-musllinux_1_2_armv7l.whl", hash = "sha256:b5405bb8f0e783a988172993cfc627e4d9d00432d6bbac65a923041edacf997d", size = 93960, upload-time = "2026-03-01T22:05:28.738Z" }, + { url = "https://files.pythonhosted.org/packages/bc/d2/8ae2e6cd77d0805f4526e30ec43b6f9a3dfc542d401ac4990d178e4bf0cf/yarl-1.23.0-cp312-cp312-musllinux_1_2_ppc64le.whl", hash = "sha256:1c3a3598a832590c5a3ce56ab5576361b5688c12cb1d39429cf5dba30b510760", size = 104703, upload-time = "2026-03-01T22:05:30.438Z" }, + { url = "https://files.pythonhosted.org/packages/2f/0c/b3ceacf82c3fe21183ce35fa2acf5320af003d52bc1fcf5915077681142e/yarl-1.23.0-cp312-cp312-musllinux_1_2_riscv64.whl", hash = "sha256:8419ebd326430d1cbb7efb5292330a2cf39114e82df5cc3d83c9a0d5ebeaf2f2", size = 98325, upload-time = "2026-03-01T22:05:31.835Z" }, + { url = "https://files.pythonhosted.org/packages/9d/e0/12900edd28bdab91a69bd2554b85ad7b151f64e8b521fe16f9ad2f56477a/yarl-1.23.0-cp312-cp312-musllinux_1_2_s390x.whl", hash = "sha256:be61f6fff406ca40e3b1d84716fde398fc08bc63dd96d15f3a14230a0973ed86", size = 105067, upload-time = "2026-03-01T22:05:33.358Z" }, + { url = "https://files.pythonhosted.org/packages/15/61/74bb1182cf79c9bbe4eb6b1f14a57a22d7a0be5e9cedf8e2d5c2086474c3/yarl-1.23.0-cp312-cp312-musllinux_1_2_x86_64.whl", hash = "sha256:3ceb13c5c858d01321b5d9bb65e4cf37a92169ea470b70fec6f236b2c9dd7e34", size = 100285, upload-time = "2026-03-01T22:05:35.4Z" }, + { url = "https://files.pythonhosted.org/packages/69/7f/cd5ef733f2550de6241bd8bd8c3febc78158b9d75f197d9c7baa113436af/yarl-1.23.0-cp312-cp312-win32.whl", hash = "sha256:fffc45637bcd6538de8b85f51e3df3223e4ad89bccbfca0481c08c7fc8b7ed7d", size = 82359, upload-time = "2026-03-01T22:05:36.811Z" }, + { url = "https://files.pythonhosted.org/packages/f5/be/25216a49daeeb7af2bec0db22d5e7df08ed1d7c9f65d78b14f3b74fd72fc/yarl-1.23.0-cp312-cp312-win_amd64.whl", hash = "sha256:f69f57305656a4852f2a7203efc661d8c042e6cc67f7acd97d8667fb448a426e", size = 87674, upload-time = "2026-03-01T22:05:38.171Z" }, + { url = "https://files.pythonhosted.org/packages/d2/35/aeab955d6c425b227d5b7247eafb24f2653fedc32f95373a001af5dfeb9e/yarl-1.23.0-cp312-cp312-win_arm64.whl", hash = "sha256:6e87a6e8735b44816e7db0b2fbc9686932df473c826b0d9743148432e10bb9b9", size = 81879, upload-time = "2026-03-01T22:05:40.006Z" }, + { url = "https://files.pythonhosted.org/packages/69/68/c8739671f5699c7dc470580a4f821ef37c32c4cb0b047ce223a7f115757f/yarl-1.23.0-py3-none-any.whl", hash = "sha256:a2df6afe50dea8ae15fa34c9f824a3ee958d785fd5d089063d960bae1daa0a3f", size = 48288, upload-time = "2026-03-01T22:07:51.388Z" }, +]