cadrumo.adapters.outbound.aeat.auth.clave_movil_support module¶
Shared support surface for the ClaveMovilAuthProvider.
The helpers here keep the live Cl@ve Movil page driver small: they build the
RemoteStateGuardPolicy used for allowed browser actions, classify the
configured DNI/NIE identity, redact diagnostic URL fields, and attach the
closed ClaveMovilFailureMode taxonomy to provider errors.
- mint_diagnostic_id(captured_at)[source]¶
Return a collision-resistant, operator-safe Cl@ve diagnostic identifier.
- auth_browser_action_policy(settings)[source]¶
Build the remote-state guard policy for Cl@ve Movil browser actions.
The page-flow mixin uses the returned
RemoteStateGuardPolicybefore continuing through AEAT’s own-name representation gate.- Return type:
- Parameters:
settings (Settings)
- exception ClaveMovilConfigurationError(message=None, *, context=None, translated_message=None)[source]¶
Bases:
AuthConfigurationErrorConfiguration fault for the
ClaveMovilAuthProvider.Raised before or during form driving when required local Cl@ve Movil settings, such as DNI/NIE identity or non-QR contrast fields, are missing or malformed. It subclasses
AuthConfigurationErrorso callers can treat it as a local configuration error rather than a live AEAT timeout.- Parameters:
- Return type:
None
- property live_iva_failure_mode: LiveIvaAcquisitionFailureMode¶
Expose the application-level mode at the outbound boundary.
- code¶
- exception ClaveMovilApprovalTimeoutError(message=None, *, failure_mode=None, context=None, translated_message=None)[source]¶
Bases:
AuthErrorLive Cl@ve Movil timeout carrying provider failure diagnostics.
ClaveMovilAuthProviderand its page-flow mixin raise thisAuthErrorwhen AEAT browser state never reaches the expected selector, wait state, or post-auth landing page.failure_modeis stored both on the exception and incontextas aClaveMovilFailureModevalue; timeout contexts may also include a diagnostic id and operator phone state reporting options.- Parameters:
- Return type:
None
- property live_iva_failure_mode: LiveIvaAcquisitionFailureMode¶
Translate the provider taxonomy into the live application contract.
- code¶
- class ClaveMovilFailureMode(*values)[source]¶
Bases:
StrEnumClosed failure taxonomy for
ClaveMovilApprovalTimeoutError.- INITIAL_NAVIGATION_TIMEOUT¶
- PENDING_PETITION_BLOCKED¶
- PUSH_WAIT_STATE_NOT_REACHED¶
- AUTH_COMPLETION_TIMEOUT¶
- APPROVAL_TIMEOUT¶
- classify_identity(raw)[source]¶
Return the configured Cl@ve identity kind as
DNIorNIE.Classification is the domain’s, through
validate_runtime_identity(), which settles the shape and the checksum together. This function only maps the resulting document to the name Cl@ve uses and refuses what the flow does not serve: a CIF-style organization identifier is intentionally rejected, because Cl@ve Movil authenticates a natural person.It used to carry its own two regexes for the shape and call the checksum separately, and the copy was incomplete: it had no branch for a
K/L/MNIF, the number a natural person holds when they have no DNI or NIE. A checksum-valid identifier was refused with a message telling its holder it was not valid – not a policy, since nothing stated it, but a gap in a hand-written pattern. Reading the kind from the domain removes the gap and the copy in the same move.If AEAT is found to bar a prefixed NIF from Cl@ve Movil specifically, the exclusion belongs in
_CLAVE_KIND_BY_DOCUMENTas a decision someone made, with the evidence beside it.rawis operator-entered configuration text, so a mistyped identifier is refused here rather than surfacing later as an opaque rejection from the live AEAT portal.
- class ClaveIdentityProbeAdapter(*args, **kwargs)[source]¶
Bases:
ClaveIdentityProbePortTranslate the concrete Cl@ve classifier for application probes.
- extract_verification_code_from_html(html)[source]¶
Extract the AEAT Cl@ve Movil verification code from rendered HTML.
- url_diagnostic(value)[source]¶
Return redacted URL components for auth diagnostic contexts.
The returned mapping keeps host, path, and query-key names only, so
ClaveMovilApprovalTimeoutErrorcontexts can explain where the browser was without persisting query values.
- diagnostic_fingerprint(value)[source]¶
Return a short stable fingerprint for values stored in diagnostics.
- render_progress_banner(*, verification_code, timeout_seconds, used_non_qr_fallback)[source]¶
Log the operator-facing progress banner for a fresh Cl@ve attempt.
Always records the banner to the runtime log. When an operator progress sink is armed for the current context (see
operator_progress_sink()), the same banner is additionally handed to that sink so a headless operator sees the verification code during the wait rather than having to read the log file.