# Changelog

All notable changes to this project are recorded here. The format follows
[Keep a Changelog](https://keepachangelog.com/en/1.1.0/), and the project
follows [Semantic Versioning](https://semver.org/); breaking changes are
allowed in 0.x and are marked **Breaking**.

## Unreleased

## 0.1.0 - 2026-12-05

The first release on Hex.

### Added

- HexDocs guides: Getting started, one page per behaviour (`Countersign.Host`,
  `Countersign.Signable`, `Countersign.Delivery`) and the security model.
- `Countersign.Config` `:client_ip_session_key`: the session key under which the
  host's plug keeps the signer's client IP. The signing page records that IP,
  and the socket's peer only when the session holds none, so a page served
  behind a proxy records the signer and not the proxy.
- `Countersign.Seal`: `seal/3` adds an Ed25519 and an SLH-DSA PAdES
  signature (`ETSI.CAdES.detached`) to a PDF as two incremental updates;
  `verify/1` checks them. `Countersign.Seal.Cert` makes and reads the
  self-signed certificates and PKCS #8 keys, and
  `mix countersign.gen.seal_keys` writes them.
- The behaviours `Countersign.Host`, `Countersign.Signable` and
  `Countersign.Delivery`.
- `Countersign.Config`, validated by `Countersign.Config.new!/1`.
- The schemas `Countersign.Request` (`signing_requests`) and
  `Countersign.Code` (`signing_codes`), created by the idempotent, versioned
  `Countersign.Migrations` (version 1), and `mix countersign.gen.migration`.
- `Countersign.Token`, `Countersign.Hint` and `Countersign.Crypto`.
- `Countersign.Requests`: `send/3`, `open/2`, `request_code/2`,
  `verify_code/3`, `consent/3`, `sign/3`, `deliver_link/3`, `link_url/2`,
  `verification_seconds/0`. A verified code lets the signer consent and
  sign for 30 minutes; a permanent delivery failure fails the request and
  frees its role; a superseded request is audited and notified.
- `Countersign.Config` `:sign_path` (default `"/sign"`), where the host
  mounts the signing page.
- The sender's side of `Countersign.Requests`: `send/4` takes
  `:before_insert` and `:after_insert` hooks run in its transaction after
  the subject lock; `resend/3` (a new token, at most 5 sends by default,
  `:before_resend`/`:after_resend` hooks, a changed subject supersedes);
  `revoke/4`; `supersede/4` (`:all`, `:stale`, `{:filled, roles, except_id}`;
  audited in the caller's transaction, notified after commit through
  `notify_superseded/2`);
  `get_by_token/2`, `list/3` and `count/2`. The host event set gains
  `:resend`.
- `Countersign.Workers.Delivery` and `Countersign.Workers.Daily`, Oban
  workers a host `use`s. A delivery job carries the request id, scope and
  `send_count` (no token), drops itself once the request is resent, ended or
  past `expires_at`, snoozes while the scope is switched off, and fails the
  request on its last attempt. The daily job runs `Countersign.Sweep`:
  expiry, then one reminder per request, paged per scope.
- `Requests.fail/3` is public.
- The signer's first pages: `Countersign.Web.LinkController` (landing, code
  request, code check) with its templates `Countersign.Web.LinkHTML`, mounted
  by `Countersign.Router.countersign_routes/2`, which declares the two POST
  routes that carry the code with `log: false`. A verified code puts the
  request id and the time in the session under the config's new
  `:session_key`.
- `Requests.landing/2` opens a live request or a signed one still inside its
  30-day copy window (`Request.copyable?/2`); `request_code/2` and
  `verify_code/3` accept both. `request_code/2` now also refuses while the
  scope is switched off (`:disabled`) and when the delivery says the address
  can no longer be reached (`{:unreachable, reason}`).
- `Countersign.Workers.Code`, an Oban worker a host `use`s and names as the
  config's `:code_worker`: `request_code/2` then queues the code's delivery
  in the transaction that wrote it, and `Requests.deliver_code/3` sends it.
- `Requests.code_attempts_left/2`.
- The signing page: `Countersign.Web.SigningLive` at `<sign_path>/:token/review`
  (consent to the disclosure, the document, a drawn or typed signature,
  decline, sign on paper instead, the signed page with its copy), and
  `Countersign.Web.DocumentController`'s `<sign_path>/:token/document` and
  `<sign_path>/:token/copy` PDFs (each render a `:view` audit naming its
  purpose), all behind `Countersign.Web.Admit`, a
  gate on the session's verified code (30 minutes), the scope's switch and
  the request's state. `countersign_routes/2` mounts them, the LiveView in
  `live_session :countersign`.
- `Countersign.Disclosure`, the default consumer disclosure, and the
  config's `:signature_pad` (`{module, function}`), the function component
  a host renders to capture a drawn signature.
- `Requests.decline/4` (`:declined` or `:paper_requested`, a reason of at
  most 1000 characters; like `sign/3` it needs the URL's `:token` and a
  switched-on scope), `Requests.review/2` (the subject, checked against
  the request, or the request superseded) and `Requests.copy_subject/2`.
- The demo app in `examples/demo`.
- The signing certificate: `Countersign.Certificate` (`facts/3`, `html/4`,
  `render/3`, the page `Countersign.Certificate.HTML`) and the worker
  template `Countersign.Workers.Certificate`, which `Requests.sign/3`
  enqueues in the sign transaction when the config names a
  `:certificate_worker`; it renders through `Host.html_to_pdf/1`, stores
  through `Signable.store_document/4` with the request row locked, and pins
  `certificate_ref` once. Its text wraps between words (`overflow-wrap:
  anywhere`, with `word-wrap: break-word` for older PDF engines); only ids
  and hashes in `code` break at any character.
- `Countersign.Migrations` version 2: `signing_requests.resent_times`,
  `verified_times` (every resend and every code verification) and
  `sign_method` (`:drawn` or `:typed`). A host that ran version 1 adds a
  migration calling `up(version: 2)` and `down(version: 2)`;
  `mix countersign.gen.migration` writes the current version.

### Changed

- **Breaking:** `Requests.sign/3` takes `:token`, the token of the URL the
  signing page was opened on, and signs only when it hashes to the row's
  `token_hash`; it signs nothing while the scope is switched off
  (`{:error, :disabled}`, the request stays pending); a subject no longer
  found or signable supersedes the request, and so does a role already signed
  (`{:error, :already_signed}`), which used to roll back.
- `Config`'s `:disclosure` defaults to `Countersign.Disclosure.default/0`;
  `nil` still turns consent off.
- `Host.reminder_days/1` may answer `0`, which sends no reminder.
- **Breaking:** `Countersign.Signable` gains `type_label/1`, the subject's
  kind as the certificate names it, and `store_document/4` may answer
  `{:cancel, reason}` for a failure no retry fixes.
- `Requests.open/2` looks the token up whatever its shape, so a malformed
  token costs the same as an unknown one.
