Countersign.Certificate (Countersign v0.1.0)

Copy Markdown View Source

The signing certificate: one page saying who signed what, proven how, and when, built from the signed request and two labels the host gives (Countersign.Signable.type_label/1 and Countersign.Signable.role_label/2).

It holds the agency, the subject's kind and id, the content hash the signature was taken against, the signer's name as signed, role and relationship, the delivery channel and the address hint, the first send and every resend, every code verification, the consent version and the disclosure's hash, the time of signing, the method, the signer's IP address and user agent, and the host's signature reference. It holds no address, no signature image and nothing of the subject's content.

html/4 builds a self-contained page (its CSS inline, nothing fetched); render/3 turns it into a PDF through Countersign.Host.html_to_pdf/1. Countersign.Workers.Certificate renders and stores it.

Options

  • :time_zone - a time zone name; each time is then shown in it as well as in UTC. Shifting needs the host's time zone database (Calendar.put_time_zone_database/1). Default: UTC only.

Summary

Types

The facts the page shows.

Functions

The facts of a signed request on subject.

The certificate of a signed request on subject, as a self-contained HTML page.

The certificate of a signed request as a PDF: the subject fetched in the request's scope, the page built by html/4 and rendered by the host. Answers {:error, :not_found} when the subject is gone and the host's error when rendering fails.

As render/3, for a subject the caller has already fetched.

Types

facts()

@type facts() :: %{
  agency: String.t(),
  type_label: String.t(),
  subject_id: String.t(),
  content_sha256: String.t(),
  signer_name: String.t(),
  role_label: String.t(),
  relationship: String.t() | nil,
  delivery_channel: atom(),
  to_hint: String.t(),
  sent_at: DateTime.t(),
  resent_times: [DateTime.t()],
  unrecorded_resends: non_neg_integer(),
  last_sent_at: DateTime.t() | nil,
  verified_times: [DateTime.t()],
  consent_version: pos_integer() | nil,
  consent_sha256: String.t() | nil,
  signed_at: DateTime.t(),
  sign_method: :drawn | :typed | nil,
  sign_ip: String.t() | nil,
  sign_user_agent: String.t() | nil,
  signature_ref: String.t()
}

The facts the page shows.

Functions

facts(config, request, subject)

The facts of a signed request on subject.

html(config, request, subject, opts \\ [])

The certificate of a signed request on subject, as a self-contained HTML page.

render(config, request, opts \\ [])

@spec render(Countersign.Config.t(), Countersign.Request.t(), keyword()) ::
  {:ok, binary()} | {:error, :not_found | term()}

The certificate of a signed request as a PDF: the subject fetched in the request's scope, the page built by html/4 and rendered by the host. Answers {:error, :not_found} when the subject is gone and the host's error when rendering fails.

render(config, request, subject, opts)

@spec render(
  Countersign.Config.t(),
  Countersign.Request.t(),
  Countersign.Signable.subject(),
  keyword()
) ::
  {:ok, binary()} | {:error, term()}

As render/3, for a subject the caller has already fetched.