""" Auth-field normalizers — applied to the raw incoming message *before* the auth check runs. Protocol fields (pubkey, sig, …) are still present here. Add one entry per breaking auth-field change: ("X.Y.Z", transformer_fn) Entries must stay in ascending version order. The registry is intentionally empty: the first public release was 0.14.1, so no legacy-client shim has ever been needed. This module is the seam — add a tuple here (and a unit test for it) the day a breaking auth-field change ships. """ from __future__ import annotations from typing import Callable from browser_cli.version_manager import parse_version # ── registry ────────────────────────────────────────────────────────────────── _AUTH_COMPAT: list[tuple[str, Callable[[dict], dict]]] = [] def adapt_auth(msg: dict, client_version: str) -> dict: """Apply all auth normalizers needed to bring msg up to the current format.""" if not _AUTH_COMPAT: return msg cv = parse_version(client_version) for version, fn in _AUTH_COMPAT: if cv < parse_version(version): msg = fn(msg) return msg