67 lines
1.4 KiB
Python
67 lines
1.4 KiB
Python
|
|
from __future__ import annotations
|
||
|
|
|
||
|
|
from uuid import UUID
|
||
|
|
|
||
|
|
from pydantic import BaseModel, ConfigDict, Field
|
||
|
|
|
||
|
|
SUPABASE_PASSWORD_MIN_LENGTH = 6
|
||
|
|
SUPABASE_PHONE_PATTERN = r"^\+[1-9]\d{7,14}$"
|
||
|
|
|
||
|
|
|
||
|
|
class OtpSendRequest(BaseModel):
|
||
|
|
model_config = ConfigDict(extra="forbid")
|
||
|
|
|
||
|
|
phone: str = Field(pattern=SUPABASE_PHONE_PATTERN)
|
||
|
|
|
||
|
|
|
||
|
|
class PhoneSessionCreateRequest(BaseModel):
|
||
|
|
model_config = ConfigDict(extra="forbid")
|
||
|
|
|
||
|
|
phone: str = Field(pattern=SUPABASE_PHONE_PATTERN)
|
||
|
|
token: str = Field(pattern=r"^\d{6}$")
|
||
|
|
|
||
|
|
|
||
|
|
class SessionRefreshRequest(BaseModel):
|
||
|
|
refresh_token: str = Field(min_length=1)
|
||
|
|
|
||
|
|
|
||
|
|
class SessionDeleteRequest(BaseModel):
|
||
|
|
refresh_token: str = Field(min_length=1)
|
||
|
|
|
||
|
|
|
||
|
|
class AuthUser(BaseModel):
|
||
|
|
id: str
|
||
|
|
phone: str = Field(pattern=SUPABASE_PHONE_PATTERN)
|
||
|
|
|
||
|
|
|
||
|
|
class SessionResponse(BaseModel):
|
||
|
|
access_token: str
|
||
|
|
refresh_token: str
|
||
|
|
expires_in: int
|
||
|
|
token_type: str
|
||
|
|
user: AuthUser
|
||
|
|
|
||
|
|
|
||
|
|
class UserByPhoneResponse(BaseModel):
|
||
|
|
id: str
|
||
|
|
phone: str = Field(pattern=SUPABASE_PHONE_PATTERN)
|
||
|
|
created_at: str
|
||
|
|
phone_confirmed_at: str | None = None
|
||
|
|
|
||
|
|
|
||
|
|
class UserByIdResponse(BaseModel):
|
||
|
|
id: str
|
||
|
|
phone: str | None = None
|
||
|
|
created_at: str
|
||
|
|
phone_confirmed_at: str | None = None
|
||
|
|
|
||
|
|
|
||
|
|
class OtpSendResponse(BaseModel):
|
||
|
|
phone: str = Field(pattern=SUPABASE_PHONE_PATTERN)
|
||
|
|
|
||
|
|
|
||
|
|
class RegistrationBootstrapRequest(BaseModel):
|
||
|
|
model_config = ConfigDict(extra="forbid")
|
||
|
|
|
||
|
|
user_id: UUID
|