aeat.adapters.outbound.aeat.auth._authenticator_types module¶
Boundary records and browser protocols for live AEAT authentication.
The concrete auth providers return AeatSession when AEAT access is
available and AeatLoginAssertion when that access is probed. Both
records are strict, frozen, and secret-free; provider-specific details live in
the discriminated unions of CertificateSessionDetail,
ClaveMovilSessionDetail,
CertificateLoginAssertionDetail, and
ClaveMovilLoginAssertionDetail
owned by adapters.outbound.aeat.auth._providers.
The browser protocols mirror the subset of
adapters.outbound.aeat.browser.BrowserSession that auth providers
need, so tests and adapter callers can satisfy the same structural contract
without importing Playwright directly.
- class AeatLoginAssertion(**data)[source]¶
Bases:
BaseModelStructured outcome of a single live AEAT verification attempt.
Certificate and Cl@ve providers use the same envelope while storing their provider-specific signals in
CertificateLoginAssertionDetailorClaveMovilLoginAssertionDetail. Negative probes are returned as records withis_valid=Falseso callers can decide whether to reauthenticate, surface a diagnostic, or stop.- Parameters:
target_url (str)
is_valid (bool)
provider_kind (AuthProviderKind)
identity_nif (str | None)
status_code (int)
elapsed_ms (int)
attempted_at (datetime)
error_message (str | None)
assertion_detail (CertificateLoginAssertionDetail | ClaveMovilLoginAssertionDetail | ClavePermanenteLoginAssertionDetail)
- target_url: str¶
- is_valid: bool¶
- provider_kind: AuthProviderKind¶
- identity_nif: str | None¶
- status_code: int¶
- elapsed_ms: int¶
- attempted_at: datetime¶
- error_message: str | None¶
- assertion_detail: AuthLoginAssertionDetail¶
- property handshake_success: bool | None¶
Return the certificate handshake signal when this is certificate auth.
- class AeatSession(**data)[source]¶
Bases:
BaseModelAuthenticated live AEAT session record without secret material.
storage_state_pathis the logical persisted-session key used by downstream Sede readers to reopen encrypted browser state.provider_detailcarries eitherCertificateSessionDetailorClaveMovilSessionDetail: certificate sessions expose thumbprint/subject/handshake data, while Cl@ve sessions expose DNI/NIE and landing metadata.- Parameters:
provider_kind (AuthProviderKind)
authenticated_at (datetime)
idle_deadline (datetime)
storage_state_path (Path | None)
identity_nif (str)
provider_detail (CertificateSessionDetail | ClaveMovilSessionDetail | ClavePermanenteSessionDetail)
- provider_kind: AuthProviderKind¶
- authenticated_at: datetime¶
- idle_deadline: datetime¶
- storage_state_path: Path | None¶
- identity_nif: str¶
- provider_detail: AuthSessionDetail¶
- property certificate_thumbprint: str | None¶
Return the certificate thumbprint for certificate-backed sessions.
- property certificate_subject: str | None¶
Return the certificate subject for certificate-backed sessions.
- property handshake: HandshakeResult | None¶
Return the certificate
HandshakeResultwhen available.
- class BrowserPageLike(*args, **kwargs)[source]¶
Bases:
ProtocolMinimal Playwright page surface consumed by auth verification flows.
- async goto(url, *, timeout=None)[source]¶
Navigate to
urland return the observedBrowserResponseLike, if any.- Return type:
- Parameters:
- class BrowserResponseLike(*args, **kwargs)[source]¶
Bases:
ProtocolMinimal response surface needed to classify an AEAT probe.
- class BrowserContextLike(*args, **kwargs)[source]¶
Bases:
ProtocolMinimal Playwright context surface used by auth providers.
- async new_page()[source]¶
Create a
BrowserPageLikefor a live verification or selector flow.- Return type:
- class BrowserSessionProfileLike(*args, **kwargs)[source]¶
Bases:
ProtocolMinimal profile surface a browser session exposes to resume state.
Mirrors the single field auth reads off
adapters.outbound.aeat.browser.Profile: the filesystem path of the Playwright storage-state JSON a resumed session loads cookies from.
- class BrowserSessionLike(*args, **kwargs)[source]¶
Bases:
ProtocolBrowser-session factory surface used by certificate and Cl@ve auth.
The signature mirrors
adapters.outbound.aeat.browser.BrowserSession.create_context(): certificate auth may pass a context provisioner, while resume paths pass either a storage-state path or an in-memory storage-state mapping.profileexposes the session’s resume path soAeatAuthenticator._resolve_storage_state_path()can read it as a declared member rather than duck-typing viagetattr; it isNonefor lightweight test doubles that rely on the settings fallback. Aclose()coroutine is intentionally not mandated here — real sessions own a Chromium process while doubles may not, so teardown probes for it (seeAeatAuthenticator._close_browser_session()).- property profile: BrowserSessionProfileLike | None¶
Optional
BrowserSessionProfileLikecarrying this session’s resumestorage_state_path.
- async create_context(*, provisioner=None, storage_state_path=None, storage_state=None)[source]¶
Create a
BrowserContextLikewith optional auth provider state.
- class CertificateHealthCheck(*args, **kwargs)[source]¶
Bases:
ProtocolCallable shape used to evaluate a loaded certificate’s health.
- class BrowserSessionFactory(*args, **kwargs)[source]¶
Bases:
ProtocolAsync factory for objects satisfying
BrowserSessionLike.