# `AshVault.Macaroon.KeyWindow`
[🔗](https://github.com/jakeschurch/ash_vault/blob/main/lib/ash_vault/macaroon/ttl.ex#L36)

Behaviour for a dynamic `accepted_key_versions`: how many recent `:mac` key versions a
scope accepts, decided at verify time.

    accepted_key_versions MyApp.Macaroons.WindowByTenant
    accepted_key_versions {MyApp.Macaroons.WindowByTenant, default: 1}
    accepted_key_versions {MyApp.Macaroons, :window, []}   # MFA, called with scope first

A module (optionally with opts) or an MFA, never an inline function: the window is a
security boundary evaluated for every verification, and belongs in named, testable code.

`c:accepted_key_versions/2` receives the token's scope and returns a positive integer
or `:all`. Anything else — or a raise — **fails closed to `1`**: only the current key
version is accepted.

# `accepted_key_versions`

```elixir
@callback accepted_key_versions(scope :: binary(), opts :: keyword()) ::
  pos_integer() | :all
```

The number of recent `:mac` key versions `scope` accepts, or `:all`.

---

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