Bring the application, own tests, Dockerfile, toolchain, compose stack, migrations, secret generator, restart hook, evidence scripts and CI job from the lab 2 solution commit 8cddb09 unchanged, merge the lab 2 Makefile targets into the lab 3 skeleton Makefile without touching its targets, and append the lab 2 solution variables to the skeleton .env.example. The package version follows the contract version 1.3.0. This is the starting point of the lab 3 cycle: lint, own tests and the offline skeleton check pass before any lab 3 change. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
49 lines
1.2 KiB
Python
49 lines
1.2 KiB
Python
from datetime import datetime
|
|
from typing import Protocol, runtime_checkable
|
|
from uuid import UUID
|
|
|
|
from messenger.identity.domain.models import Session, User
|
|
from messenger.shared.application.ports import UnitOfWork
|
|
|
|
|
|
@runtime_checkable
|
|
class UserRepository(Protocol):
|
|
async def add(self, user: User) -> None: ...
|
|
|
|
|
|
@runtime_checkable
|
|
class SessionRepository(Protocol):
|
|
async def add(self, session: Session) -> None: ...
|
|
|
|
async def remove(self, token_hash: bytes) -> None: ...
|
|
|
|
|
|
@runtime_checkable
|
|
class IdentityUnitOfWork(UnitOfWork, Protocol):
|
|
@property
|
|
def users(self) -> UserRepository: ...
|
|
|
|
@property
|
|
def sessions(self) -> SessionRepository: ...
|
|
|
|
|
|
@runtime_checkable
|
|
class UserDirectory(Protocol):
|
|
async def find(self, user_id: UUID) -> User | None: ...
|
|
|
|
async def find_by_username(self, username: str) -> User | None: ...
|
|
|
|
|
|
@runtime_checkable
|
|
class SessionDirectory(Protocol):
|
|
async def find(self, token_hash: bytes, now: datetime) -> Session | None: ...
|
|
|
|
async def invalidate(self, session: Session) -> None: ...
|
|
|
|
|
|
@runtime_checkable
|
|
class PasswordHasher(Protocol):
|
|
async def hash(self, password: str) -> str: ...
|
|
|
|
async def verify(self, password_hash: str | None, password: str) -> bool: ...
|