from enum import Enum from pydantic import BaseModel, Field, field_validator class IdentifierType(str, Enum): email = "email" username = "username" mobile = "mobile" class AuthIdentifierBase(BaseModel): identifierType: IdentifierType identifier: str = Field(min_length=1, max_length=255) @field_validator("identifier") @classmethod def strip_identifier(cls, value: str) -> str: normalized = value.strip() if not normalized: raise ValueError("identifier cannot be empty") return normalized class AuthSignupRequest(AuthIdentifierBase): saltAuth: str = Field(min_length=8) saltEnc: str = Field(min_length=8) authKeyMaterial: str = Field(min_length=8) class AuthLoginBootstrapRequest(AuthIdentifierBase): pass class AuthLoginRequest(AuthIdentifierBase): authKeyMaterial: str = Field(min_length=8) class AuthBootstrapResponse(BaseModel): identifierType: IdentifierType identifier: str saltAuth: str saltEnc: str class AuthTokenResponse(BaseModel): accessToken: str tokenType: str = "bearer" ownerId: str