rmi-backend/app/domains/auth/schemas.py
cryptorugmunch 0a8c73d99b feat(domains): consolidate bulletin, intelligence, markets, admin, referral, mcp + mypy gate
- Make app/domains/auth/ and app/core/redis.py mypy-clean under strict.
- Add mypy-gate.ini and Makefile mypy-gate target; promote typecheck-gate in CI.
- Consolidate domains into app/domains/: bulletin, admin, intelligence, markets.
- Extract referral domain incl. DeFi partner DEX ref links; keep Telegram bot wired.
- Move app/mcp/ package and app/api/v1/mcp/router into app/domains/mcp/.
- Archive dead app/mcp_router.py.
2026-07-07 16:43:49 +07:00

106 lines
2.1 KiB
Python

"""Pydantic schemas for auth domain.
Phase 3B of AUDIT-2026-Q3.md.
"""
from __future__ import annotations
from typing import Any
from pydantic import BaseModel, Field
class EmailLoginRequest(BaseModel):
email: str
password: str
class EmailRegisterRequest(BaseModel):
email: str
password: str
display_name: str
wallet_address: str | None = None
wallet_chain: str | None = None
class WalletNonceRequest(BaseModel):
address: str
chain: str
class WalletVerifyRequest(BaseModel):
address: str
chain: str
nonce: str
signature: str
message: str
class NonceResponse(BaseModel):
nonce: str
timestamp: str
message: str | None = None
class WalletAuthResponse(BaseModel):
access_token: str
refresh_token: str
user: dict[str, Any]
class UserResponse(BaseModel):
id: str
email: str
display_name: str
wallet_address: str | None
wallet_chain: str | None
tier: str
role: str
created_at: str
xp: int = 0
level: int = 1
badges: list[str] = []
class GoogleAuthResponse(BaseModel):
url: str
class TelegramAuthRequest(BaseModel):
id: int
first_name: str | None = None
last_name: str | None = None
username: str | None = None
photo_url: str | None = None
auth_date: int
hash: str
# ── 2FA Models ──
class TwoFASetupResponse(BaseModel):
secret: str
qr_code: str # base64 data URI
uri: str # otpauth:// URI
backup_codes: list[str] # plaintext - shown once
class TwoFAEnableRequest(BaseModel):
code: str = Field(..., min_length=6, max_length=6, pattern=r"^\d{6}$")
class TwoFAVerifyRequest(BaseModel):
code: str = Field(..., min_length=6, max_length=6, pattern=r"^\d{6}$")
class TwoFALoginRequest(BaseModel):
email: str
password: str
code: str = Field(..., min_length=6, max_length=10) # 6 digits or backup code XXXX-XXXX
class TwoFAStatusResponse(BaseModel):
enabled: bool
method: str = "totp" # future: u2f, webauthn
created_at: str | None = None
last_used: str | None = None