"""The five bodies this package accepts. Small on purpose. A ceremony's `credential` is passed through as an opaque dict — it is the browser's `PublicKeyCredential` serialised by `toJSON()`, and its shape is the WebAuthn spec's business rather than ours. Restating it as a model here would be a second, staler copy of a structure the library already parses and validates properly. """ from __future__ import annotations from typing import Any from pydantic import BaseModel, Field class LoginBody(BaseModel): """The whole login form. No username field, because there is no username — asking for one would be theatre, and a wrong guess at it would be an error message about something that does not exist.""" #: Bounded, because it is the one field an unauthenticated stranger can #: send: scrypt is memory-hard by design and a megabyte of "password" is a #: megabyte this process hashes before saying no. password: str = Field(max_length=1000) #: Where the middleware was sending them before it asked. Sanitised on the #: way back out — see `_safe_next` in `auth/router.py`. next: str = "/" class PasswordBody(BaseModel): """Changing it. `current` is required even though the caller is signed in; `auth/router.py` says why.""" current: str = Field(max_length=1000) new: str = Field(max_length=1000) class PasskeyBody(BaseModel): """A finished registration ceremony, on its way to be checked.""" credential: dict[str, Any] #: What to call it in the list. Suggested by the browser, editable after. label: str = "" class PasskeyLoginBody(BaseModel): """A finished authentication ceremony. Same reasoning as above.""" credential: dict[str, Any] class LabelBody(BaseModel): """Renaming a passkey.""" label: str