# `WardrikTriggers.Webhook`

Verifies webhook requests against a trigger's secret.

  * `:shared` - the request presents the secret as `Authorization: Bearer SECRET`, or as
    `:path_secret`.
  * `:standard` - the request is signed as [Standard Webhooks](https://www.standardwebhooks.com/)
    specifies. A signature more than five minutes old fails.

# `request`

```elixir
@type request() :: %{
  :body =&gt; String.t(),
  :headers =&gt; %{required(String.t()) =&gt; String.t()},
  optional(:path_secret) =&gt; String.t() | nil
}
```

A request: its raw `body`, its `headers` with lowercase names, and an optional `path_secret`.

# `id`

```elixir
@spec id(request()) :: String.t()
```

Returns the request's id: its `Idempotency-Key`, its `webhook-id`, or a SHA-256 of its body.

# `prompt`

```elixir
@spec prompt(String.t(), request()) :: String.t()
```

Appends the first 32768 characters of the request's body to `prompt`.

# `verify`

```elixir
@spec verify(:shared | :standard, String.t(), request(), DateTime.t()) ::
  :ok | {:error, String.t()}
```

Returns `:ok` if `request` verifies with `secret`, or `{:error, reason}`.

---

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