Configurator allowing authentication with a shared secret.
Summary
Functions
Generate headers for Shared Secret Auth.
Extract a server-time hint from a Slipstream disconnect reason.
Functions
@spec headers(NervesHubLink.Configurator.Config.t(), DateTime.t() | nil) :: [ {String.t(), String.t()} ]
Generate headers for Shared Secret Auth.
Accepts an optional server_time hint — a DateTime previously
observed on a server response. When the hint is ahead of the device
clock it's used as signed_at; otherwise the device clock wins. This
is how a device with a wrong local clock (no RTC, NTP not yet synced)
can still produce a signature the server accepts on retry.
@spec server_time_hint(term()) :: DateTime.t() | nil
Extract a server-time hint from a Slipstream disconnect reason.
Slipstream surfaces Mint's WebSocket upgrade failures as
{:error, {:upgrade_failure, %{reason: %UpgradeFailureError{headers: ...}}}}.
When that's the shape we get, parse the server's RFC 9110 Date
header (e.g. Sun, 06 Nov 1994 08:49:37 GMT) into a DateTime and
return it. Returns nil for any other reason shape, or if the Date
header is missing or malformed.