Add ReceiverAuthState to manage receiver auth context

Introduced the ReceiverAuthState class to encapsulate and manage the authentication state for receivers within an envelope. This class tracks the current authentication response and envelope key, provides methods to update or clear the state, and exposes a Changed event to notify UI components of state transitions, enabling reactive UI updates during the authentication flow.
This commit is contained in:
2026-05-13 22:44:37 +02:00
parent dab573d6d7
commit 4ce9b77a71

View File

@@ -0,0 +1,34 @@
using EnvelopeGenerator.ReceiverUI.Web.Client.Api.Models;
namespace EnvelopeGenerator.ReceiverUI.Web.Client.Services;
/// <summary>
/// Holds the current receiver authentication context for the active envelope.
/// Scoped per circuit (Interactive Server) or per browser tab (Interactive WASM).
///
/// Pages observe <see cref="Changed"/> to re-render when the underlying
/// auth response transitions (e.g. requires_access_code -> requires_tfa
/// -> show_document).
/// </summary>
public class ReceiverAuthState
{
private ReceiverAuthResponse? _current;
public string? EnvelopeKey { get; private set; }
public ReceiverAuthResponse? Current => _current;
public event Action? Changed;
public void Set(string envelopeKey, ReceiverAuthResponse? response)
{
EnvelopeKey = envelopeKey;
_current = response;
Changed?.Invoke();
}
public void Clear()
{
EnvelopeKey = null;
_current = null;
Changed?.Invoke();
}
}