# `Attesto.RevocationCriteria`
[🔗](https://github.com/XukuLLC/attesto/blob/v2.28.0/lib/attesto/revocation_criteria.ex#L1)

The criteria a store uses to select authorization codes or refresh-token
families for bulk removal: `c:Attesto.CodeStore.delete_unclaimed/1` and
`c:Attesto.RefreshStore.revoke_families/1`.

Criteria are a keyword list with at least one of:

  * `:subject` - the resource owner the grant was issued for.
  * `:client_id` - the client the grant was issued to.
  * `:sid` - the session identifier recorded in the grant's claims.

Every key given must match (they are ANDed), so
`[subject: "u1", client_id: "c1"]` selects only that subject's grants to that
client.

`:sid_claim` names the member of the stored `:claims` object that holds the
session identifier. It defaults to `"sid"` and has an effect only with
`:sid`; an integration that records the session under another key passes
that key.

This module is the one definition of both the validation and the match, so
every store, in memory or SQL, selects the same grants for the same
criteria.

# `criteria`

```elixir
@type criteria() :: [
  subject: String.t(),
  client_id: String.t(),
  sid: String.t(),
  sid_claim: String.t()
]
```

# `t`

```elixir
@type t() :: %{
  subject: String.t() | nil,
  client_id: String.t() | nil,
  sid: String.t() | nil,
  sid_claim: String.t()
}
```

# `match?`

```elixir
@spec match?(t(), map()) :: boolean()
```

Whether a stored grant context matches `criteria` (from `new!/1`).

`data` is the canonical `:data` map of a code or refresh-token record: its
`:subject`, `:client_id` and `:claims`.

# `new!`

```elixir
@spec new!(criteria()) :: t()
```

Validate `criteria` and return them as a map with every key present (`nil`
for a key that was not given).

Raises `ArgumentError` for an empty selection, an unknown key, a repeated
key, or a value that is not a non-empty string. An empty selection is
refused so a caller's bug cannot remove every grant in the store.

---

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