# `Image.Components.Signing.Imgix`
[🔗](https://github.com/elixir-image/image_components/blob/v0.1.1/lib/image/components/signing/imgix.ex#L1)

imgix-flavoured client-side URL signing.

Wire-format-compatible with `Image.Plug.Provider.Imgix.Signing`
on the server side and with imgix's hosted signed URLs.
Sign-only — verification happens at the back-end.

HMAC-SHA256 over `secret <> path-and-query`. Signature appended
as `?s=<hex>` (or `&s=<hex>` if a query is already present).

# `sign`

```elixir
@spec sign(String.t(), [String.t(), ...], keyword()) :: String.t()
```

Signs `path_with_query` with the first key in `keys`.

### Arguments

* `path_with_query` is the imgix request path, optionally with
  an existing query string.

* `keys` is a non-empty list of imgix secret tokens.

### Options

* `:expires_at` — `DateTime` or unix-seconds. Adds an
  `expires=<unix>` parameter; the back-end's verifier rejects
  the URL after that time.

### Returns

* The path with `?s=<hex>` (and optional `?expires=…`) appended.

### Examples

    iex> Image.Components.Signing.Imgix.sign("/cat.jpg?w=200", ["secret"])
    ...> =~ "?w=200&s="
    true

---

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