The behaviour for the thing being signed: a contract, a consent form, a
plan of care. Countersign never stores the subject; it stores
subject_type and subject_id and asks this module for everything else.
Summary
Types
What the signer entered on the signing page: at least :signer_name and
:method (:drawn or :typed), and :image (PNG bytes) for a drawn
signature.
Why a PDF is rendered: for the signer to read before signing, or as their signed copy.
Facts about the signer's HTTP request: :ip_address and :user_agent.
Callbacks
The subject's content hash: 64 lowercase hex characters. A request is sent against this hash, and a signature is accepted only while it is unchanged.
Loads the subject, scoped to scope_id. Answers {:error, :not_found} for anything outside the scope.
Writes the signature into the host's own records, inside the sign transaction.
Renders the subject as a PDF for purpose. Answers {:error, :busy} when
the renderer is saturated, which the signing page reports as "try again".
The human label of role on this subject, as the signing page shows it.
Whether the subject still takes signatures (for example, not voided).
Stores a generated document (the signing certificate) against the subject.
Countersign.Workers.Certificate calls it with the request row locked and
pins the answer as certificate_ref. {:error, :busy} or
{:error, :timeout} snoozes the job, {:cancel, reason} ends it for good
(the owner is gone), and any other error retries it.
The human name of the subject's kind ("Plan of Care"), as the signing certificate shows it.
Types
@type input() :: %{ :signer_name => String.t(), :method => :drawn | :typed, optional(:image) => binary(), optional(atom()) => term() }
What the signer entered on the signing page: at least :signer_name and
:method (:drawn or :typed), and :image (PNG bytes) for a drawn
signature.
@type purpose() :: :review | :copy
Why a PDF is rendered: for the signer to read before signing, or as their signed copy.
@type request_meta() :: %{ optional(:ip_address) => String.t(), optional(:user_agent) => String.t() }
Facts about the signer's HTTP request: :ip_address and :user_agent.
@type subject() :: term()
Whatever the host returns from fetch/3; Countersign passes it back untouched.
Callbacks
The subject's content hash: 64 lowercase hex characters. A request is sent against this hash, and a signature is accepted only while it is unchanged.
@callback fetch( Countersign.Host.scope_id(), subject_type :: String.t(), subject_id :: String.t() ) :: {:ok, subject()} | {:error, :not_found}
Loads the subject, scoped to scope_id. Answers {:error, :not_found} for anything outside the scope.
@callback record_signature(subject(), Countersign.Request.t(), input(), request_meta()) :: {:ok, signature_ref :: String.t()} | {:error, :changed} | {:error, :already_signed} | {:error, term()}
Writes the signature into the host's own records, inside the sign transaction.
Answers {:ok, signature_ref} (stored as the request's signature_ref),
{:error, :changed} when the content moved since the send,
{:error, :already_signed} when the role's line is already signed, or
{:error, term} for anything else, which rolls the transaction back.
Renders the subject as a PDF for purpose. Answers {:error, :busy} when
the renderer is saturated, which the signing page reports as "try again".
The human label of role on this subject, as the signing page shows it.
Whether the subject still takes signatures (for example, not voided).
@callback store_document( subject(), :certificate, pdf :: binary(), Countersign.Request.t() ) :: {:ok, document_ref :: String.t()} | {:cancel, term()} | {:error, term()}
Stores a generated document (the signing certificate) against the subject.
Countersign.Workers.Certificate calls it with the request row locked and
pins the answer as certificate_ref. {:error, :busy} or
{:error, :timeout} snoozes the job, {:cancel, reason} ends it for good
(the owner is gone), and any other error retries it.
The human name of the subject's kind ("Plan of Care"), as the signing certificate shows it.