Lockspire.Storage.DeviceAuthorizationStore behaviour
(lockspire v1.0.0)
Copy Markdown
Behaviour for storing and managing OAuth 2.0 Device Authorizations.
Summary
Types
@type device_poll_outcome() :: %{ :result => device_poll_result(), optional(:device_authorization) => Lockspire.Domain.DeviceAuthorization.t(), optional(:effective_poll_interval_seconds) => pos_integer(), optional(:next_poll_allowed_at) => DateTime.t() }
@type device_poll_result() ::
:approved_ready
| :client_mismatch
| :consumed
| :denied
| :expired
| :invalid_grant
| :pending
| :slow_down
Callbacks
@callback consume_device_authorization(String.t(), String.t(), DateTime.t()) :: {:ok, Lockspire.Domain.DeviceAuthorization.t()} | {:error, :invalid_state | term()}
@callback fetch_device_authorization_by_device_code_hash(String.t()) :: {:ok, Lockspire.Domain.DeviceAuthorization.t() | nil} | {:error, term()}
@callback fetch_device_authorization_by_user_code_hash(String.t()) :: {:ok, Lockspire.Domain.DeviceAuthorization.t() | nil} | {:error, term()}
@callback fetch_device_authorization_by_verification_handle(String.t()) :: {:ok, Lockspire.Domain.DeviceAuthorization.t() | nil} | {:error, term()}
@callback put_device_authorization(Lockspire.Domain.DeviceAuthorization.t()) :: {:ok, Lockspire.Domain.DeviceAuthorization.t()} | {:error, term()}
@callback record_device_poll(String.t(), String.t(), DateTime.t()) :: {:ok, device_poll_outcome()} | {:error, term()}
@callback transition_device_authorization( String.t(), [Lockspire.Domain.DeviceAuthorization.status()], map() ) :: {:ok, Lockspire.Domain.DeviceAuthorization.t()} | {:error, term()}