# `ExFattureincloud.Webhook`
[🔗](https://github.com/elchemista/ex_fattureincloud/blob/v0.1.0/lib/ex_fattureincloud/webhook.ex#L1)

Webhook verification using the provider's ES256 public key and JWT claims.

`verify/2` requires the target URL as `:audience` and the Fatture in Cloud app ID
as `:application_id`. `:event_id` and `:subject` optionally bind claims to an
event; `verify_event/3` checks both automatically for binary/structured events.
`:public_key` accepts a trusted PEM for key rotation. `:clock_skew` defaults to
30 seconds. The published key is pinned; update it if the provider rotates it.

Authenticate verification GETs before echoing `verification_response/1` with
HTTP 200. Deduplicate POST notifications by their event ID in your application;
provider delivery is at least once and can be out of order. JWT verification
authenticates provider claims; it is not a digest of the HTTP request body.

# `verification_response`

```elixir
@spec verification_response(String.t()) :: map()
```

Body to return with HTTP 200 for an authenticated verification challenge.

# `verify`

```elixir
@spec verify(term(), keyword()) ::
  {:ok, map()} | {:error, :invalid_claims | :invalid_signature}
```

Verifies signature, algorithm, issuer, audience, app ID and token times.

# `verify_event`

```elixir
@spec verify_event(map() | list(), term(), keyword()) ::
  {:ok, map()} | {:error, :invalid_claims | :invalid_signature | :invalid_event}
```

Verifies an event and checks JWT jti/sub against the event ID/subject.

---

*Consult [api-reference.md](api-reference.md) for complete listing*
