# `Pixir.Auth.Store`
[🔗](https://github.com/Ranvier-Technologies/pixir/blob/main/lib/pixir/auth/store.ex#L1)

Persistence for the subscription **Credential** at `~/.pixir/auth.json` (ADR 0002).

Only subscription credentials are written — an `OPENAI_API_KEY` lives in the
environment and is never persisted. Writes are atomic (temp + rename) and the file
is mode `0600`. The on-disk shape is a flat JSON object with string keys; `load/1`
returns the in-memory credential map (atom keys).

# `credential`

```elixir
@type credential() :: map()
```

# `clear`

```elixir
@spec clear(keyword()) :: :ok
```

Delete the stored credential (logout). Missing file is success.

# `load`

```elixir
@spec load(keyword()) :: {:ok, credential()} | {:error, :not_found | map()}
```

Load the stored subscription credential, if any. Accepts `:path` (testing).

# `path`

```elixir
@spec path(keyword()) :: String.t()
```

Path to auth.json. Accepts `:path` override (testing).

# `save`

```elixir
@spec save(
  credential(),
  keyword()
) :: :ok | {:error, map()}
```

Persist a subscription credential atomically (mode 0600).

---

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