# Countersign v0.1.0 - Table of Contents

> Self-hosted e-signatures for Phoenix: no DocuSign, no per-envelope fees.

## Pages

- [Countersign](readme.md)
- [Changelog](changelog.md)
- [Contributing to Countersign](contributing.md)
- [Security policy](security-2.md)

- Guides
  - [Getting started](getting-started.md)
  - [The Host behaviour](host.md)
  - [The Signable behaviour](signable.md)
  - [The Delivery behaviour](delivery.md)
  - [Security model](security-1.md)

## Modules

- Behaviours
  - [Countersign.Delivery](Countersign.Delivery.md): The behaviour that carries a signing link or a signing code to the signer,
by the request's `delivery_channel` (`email` or `sms`; the host decides what
each means).
  - [Countersign.Host](Countersign.Host.md): The behaviour an application implements once to run Countersign.
  - [Countersign.Signable](Countersign.Signable.md): 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.

- Core
  - [Countersign.Certificate](Countersign.Certificate.md): The signing certificate: one page saying who signed what, proven how, and
when, built from the signed request and two labels the host gives
(`c:Countersign.Signable.type_label/1` and
`c:Countersign.Signable.role_label/2`).
  - [Countersign.Certificate.HTML](Countersign.Certificate.HTML.md): The signing certificate's page (`Countersign.Certificate.html/4`): one
self-contained HTML document, its CSS inline, fetching nothing, so a PDF
renderer with no network draws it whole.

  - [Countersign.Code](Countersign.Code.md): A signing code (`signing_codes`): a six-digit one-time code sent to the
address the link went to.
  - [Countersign.Config](Countersign.Config.md): Everything Countersign needs from its host, passed to every call.
  - [Countersign.Disclosure](Countersign.Disclosure.md): The package's default consumer disclosure: what a signer reads and accepts
before an electronic signature, in the spirit of the U.S. ESIGN Act's
consumer consent (15 U.S.C. 7001(c)). It says what will be signed
electronically, that the signer may sign on paper instead, that consent may
be withdrawn before signing, what the signer needs to read the document, how
to get a copy, and that the sender keeps the record.
  - [Countersign.Migrations](Countersign.Migrations.md): Creates and drops Countersign's tables from a host migration, in the
shape of `Oban.Migration`.
  - [Countersign.Request](Countersign.Request.md): A signing request (`signing_requests`): one invitation to one remote signer
to sign one role of one subject.
  - [Countersign.Requests](Countersign.Requests.md): The signing-request lifecycle.
  - [Countersign.Sweep](Countersign.Sweep.md): The daily sweep over pending requests (`Countersign.Workers.Daily` runs
it): one reminder for each request sent long enough ago, then expiry for
each request past its `expires_at`.

- Web
  - [Countersign.Router](Countersign.Router.md): Mounts the signer's link pages in a host's Phoenix router.
  - [Countersign.Web.Admit](Countersign.Web.Admit.md): The gate of the signer's pages past the code: the signing page and its
document, which sign, and the signed copy.
  - [Countersign.Web.DocumentController](Countersign.Web.DocumentController.md): The signer's PDFs, behind `Countersign.Web.Admit`
  - [Countersign.Web.LinkController](Countersign.Web.LinkController.md): The signer's first pages, mounted by `Countersign.Router.countersign_routes/2`:
the landing page, the code request and the code check.
  - [Countersign.Web.LinkHTML](Countersign.Web.LinkHTML.md): The link pages' templates (`Countersign.Web.LinkController`). They render
inside the host's root layout and use only plain HTML with a few class
names (`countersign-*`), so they take the host's styles without needing
its components. Every sentence is fixed here; the sender's name and the
address hint are the only values shown.

  - [Countersign.Web.SigningLive](Countersign.Web.SigningLive.md): The signing page, `<sign_path>/:token/review`, past the code and behind
`Countersign.Web.Admit`.

- Workers
  - [Countersign.Workers.Certificate](Countersign.Workers.Certificate.md): The Oban worker that renders and stores one signed request's certificate
(`Countersign.Certificate`). A host `use`s it and names it as the config's
`:certificate_worker`; `Countersign.Requests.sign/3` then inserts the job in
the sign transaction.
  - [Countersign.Workers.Code](Countersign.Workers.Code.md): The Oban worker that delivers one signing code. A host `use`s it and names
it as the config's `:code_worker`; `Countersign.Requests.request_code/2`
then inserts the job in the transaction that wrote the code.
  - [Countersign.Workers.Daily](Countersign.Workers.Daily.md): The Oban worker that runs the daily sweep (`Countersign.Sweep`): expiry,
then one reminder for each request due one.
  - [Countersign.Workers.Delivery](Countersign.Workers.Delivery.md): The Oban worker that delivers a request's link: the first send, a resend
and the reminder.

- Seal
  - [Countersign.Seal](Countersign.Seal.md): Seals a PDF so it proves by itself that it was not altered, and checks such
a seal.
  - [Countersign.Seal.Cert](Countersign.Seal.Cert.md): The seal's certificates and keys: a self-signed X.509 certificate for an
Ed25519 or SLH-DSA key, what the seal reads from one, and their PEM form.

- Internals
  - [Countersign.Crypto](Countersign.Crypto.md): Encryption and digests under keys derived from the host's
`secret_key_base` (`Countersign.Config`).
  - [Countersign.Hint](Countersign.Hint.md): The masked form of a delivery address, the only form a screen shows:
`m•••@gmail.com` for an email, `•••-•••-0142` for a phone number.

  - [Countersign.Token](Countersign.Token.md): Signing-link tokens: 32 random bytes, URL-safe base64 without padding.

## Mix Tasks

- [mix countersign.gen.migration](Mix.Tasks.Countersign.Gen.Migration.md): Writes a migration that creates Countersign's tables by calling
`Countersign.Migrations.up/1` and `down/1`.
- [mix countersign.gen.seal_keys](Mix.Tasks.Countersign.Gen.SealKeys.md): Writes two self-signed certificates and their PKCS #8 private keys, one
Ed25519 and one SLH-DSA, as PEM files `Countersign.Seal.Cert.from_pem/2`
reads back

