# Changelog

## v0.8.0

Breaking:

- `ReqDPoP.Key.load!/1`, and so `ReqDPoP.attach/2` and `ReqDPoP.proof/1`,
  refuse a JWK whose own `use` or `key_ops` member does not allow signing
  (RFC 7517 sections 4.2 and 4.3): `use` must be `"sig"` and `key_ops` must be
  a list of strings containing `"sign"`. They raise `ReqDPoP.Error` with reason
  `:invalid_key`. A key with neither member loads as before. Until now a key
  marked `"use": "enc"` or `"key_ops": ["verify"]` signed proofs.
- `ReqDPoP.Key.public_jwk/1` leaves `key_ops` out of the map it returns. The
  member described the private key, so a signing key's public half came back
  marked `"key_ops": ["sign"]`, which a verifier that checks the member
  refuses.

## v0.7.1

Fixes:

- Return `{request, %ReqDPoP.Error{}}` when rescuing any `ReqDPoP.Error` raised
  during the Req request step (including `htu` construction on redirects such as
  a non-UTF-8 `Location`, `:auth` option conflicts, invalid options, and callback
  type errors), so `Req.get/2` returns `{:error, %ReqDPoP.Error{}}` instead of
  raising while `Req.get!/2` continues to raise; `ReqDPoP.Error` raised in the
  response step (for example on an invalid nonce retry) still raises.

## v0.7.0

Added:

- `ReqDPoP.attach/2` accepts `:origin` and `:htu` to sign a target URI other
  than the URL the request is sent to. RFC 9449 section 4.2 defines `htu` as
  the request's target URI, which differs from the connection URL when a
  client reaches a server at an internal address and sends the public
  authority in `Host`. Until now the only way to sign the public URI was
  `ReqDPoP.proof!/1`, which gives up the plugin's nonce retry.
  `:origin` replaces scheme, host and port and keeps the request path. `:htu`
  is a one-argument function of the request that returns the `htu`; a fixed
  string raises `ReqDPoP.Error` with reason `{:invalid_option, :htu}`, because
  it would be signed into every request. Setting both raises with reason
  `{:conflicting_option, :origin}`. The override applies to the origin of the
  first hop, nonce retries included. A redirect hop to another origin signs
  its own URL.

## v0.6.2

Fixes:

- A redirect whose `Location` header is not valid UTF-8 made the plugin raise
  a bare `ErlangError` from JOSE's JSON encoder while signing the next hop's
  proof, and `ReqDPoP.proof/1` raised the same error for such an `htu` instead
  of returning an error tuple. `htu` must now be valid UTF-8: the plugin raises
  `ReqDPoP.Error` with reason `{:invalid_option, :htu}`, as it does for any
  other `htu` it cannot sign, and `proof/1` returns
  `{:error, %ReqDPoP.Error{reason: {:invalid_option, :htu}}}`.

## v0.6.1

Security:

- Raise the JOSE dependency floor to 1.11.13, which fixes CVE-2026-65625
  through CVE-2026-65632. ReqDPoP only signs proofs with the key its caller
  configures, so none of those advisories reaches its own code; the floor
  keeps an application that uses it from resolving an affected JOSE release.

## v0.6.0

Security:

- With Req 0.7 and later, an untrusted cross-origin redirect re-attached
  `Authorization: DPoP <token>` and a fresh proof bound to the redirect target
  after Req had removed the header. Req 0.7 re-runs every request step on a
  redirect, and the plugin read the token back from its own option. The plugin
  now signs per hop and, when Req withholds the token, sends no `DPoP` header
  either. With Req 0.6 the redirect target received the previous hop's proof
  (stale `htu`, reused `jti`) and no token; it now receives neither. Proof-only
  requests follow the same rule: no proof crosses to an untrusted origin.
- `ReqDPoP.Key.load!/1` now requires a complete private signing key: a P-256
  EC key with 32-byte `x`, `y`, and `d`, or an RSA key of at least 2048 bits
  (RFC 7518 section 3.3) with `n`, `e`, and `d`. Before, a partial or
  public-only JWK loaded and then crashed inside JOSE at signing time with the
  decoded private scalar in the stack trace arguments. Hand-built
  `%ReqDPoP.Key{}` structs are re-validated. `inspect/1` of a key shows only
  the algorithm.
- Server nonces are checked against RFC 9449 section 8 syntax (`NQCHAR`,
  at most 1024 bytes, exactly one `DPoP-Nonce` header). Before, a non-UTF-8
  nonce crashed the request with an Erlang JSON error.
- `WWW-Authenticate` parsing reads `error="use_dpop_nonce"` only from the
  `DPoP` challenge's own parameters, not from other schemes or quoted text.
- Nonce challenge bodies are decoded with the caller's own Req options. The
  body is decompressed only when the caller set `compressed: true`, which Req
  documents as opt-in because of decompression bombs, and bodies over 64 KiB
  are not inspected. The section 8 JSON form is recognized only on proof-only
  (token endpoint) requests.
- Server nonces and the nonce retry budget are tracked per origin, and a hop
  that received no proof does not answer a nonce challenge.
- `:max_nonce_retries`, `:retry_on_nonce`, `:access_token`, `:nonce`,
  `:clock`, and `:jti` are validated at `attach/2`. Before,
  `max_nonce_retries: nil` retried without bound.
- Setting Req's `:auth` option together with `:access_token` raises
  `ReqDPoP.Error` instead of silently letting one overwrite the other on
  retried hops.
- The proof `jwk` header carries only the RFC 7638 thumbprint members. Other
  members of a loaded JWK map, such as `kid` or application fields, no longer
  travel in every proof. `ReqDPoP.Key.proof_jwk/1` returns that map.
- A plain-string `:access_token` no longer appears in `inspect/1` output for
  the request, matching Req's redaction of the `Authorization` header.
- `ReqDPoP.Error` for an invalid `:key` no longer embeds the rejected value;
  the reason is `:invalid_key`.
- `mix.exs` declares `{:mint, ">= 1.10.2"}` so consumers resolve past the
  mint releases with open advisories (EEF-CVE-2026-82672, -82728, -82729,
  -91043, -92103, -94194). Development lockfile: mint 1.11.0, finch 0.24.0,
  req 0.7.5.

Fixes:

- Nonce retry recognizes the RFC 9449 section 8 authorization server
  challenge: status `400`, a JSON body of `{"error": "use_dpop_nonce"}`, and a
  `DPoP-Nonce` header, with no `WWW-Authenticate`. Before, only the section 9
  `WWW-Authenticate` form triggered a retry, so token endpoint requests never
  retried against a server that follows the RFC.
- Req's retry and redirect steps get a fresh proof (new `jti`, current `htu`
  and `htm`) instead of a replay of the previous hop's proof. With Req 0.6 the
  plugin queues its step for the re-run, including after transport errors;
  Req 0.7 re-runs every step.
- A streaming (`into:`) challenge response is cancelled before the nonce
  retry, as Req's redirect step does.
- `htu` is the wire form of the target URI: lowercase scheme and host, `/`
  for an empty path, no userinfo, query, or fragment. A relative or non-HTTP
  `htu` raises `ReqDPoP.Error`. Before, `Req.get!(client)` against a bare
  `base_url` signed `https://host` while the request line carried `/`, and
  verifiers that compare paths rejected the proof.
- An empty `:access_token` means proof-only mode: no `Authorization` header and
  no `ath` claim. Before, `ath` was computed over the empty string while the
  header was omitted.
- `:alg` must match the key type. Keys other than P-256 EC and RSA raise
  `ReqDPoP.Error` with reason `:unsupported_key` instead of a raw JOSE error.
- `attach/2` called twice on one request replaces the configuration instead
  of adding a second set of steps.
- CI pins `auth0-api-python`, fails instead of skipping when the Python
  verifier is missing, and runs the suite against Req 0.6 as well as the lock.

## v0.5.3

- Raise the JOSE dependency floor to 1.11.12. This keeps the earlier security,
  package-metadata, and Erlang/OTP 28 EC key fixes while also correctly
  encoding Elixir `nil` as JSON `null` with Erlang/OTP's built-in JSON module.

## v0.5.2

- Raise the Req dependency floor to 0.6.1, the first release patched for
  EEF-CVE-2026-49755 decompression-bomb denial of service.

## v0.5.1

- Correct the README installation snippet now that the package is published on
  Hex.

## v0.5.0

- Initial Req plugin for RFC 9449 DPoP proof generation.
- Adds DPoP proof and optional `Authorization: DPoP ...` headers.
- Computes `ath` for access-token mode.
- Supports proof-only token endpoint requests.
- Retries DPoP nonce challenges with a nonce-bound proof.
- Supports ES256 and RS256 signing keys.
