Pixir.Auth.Store (pixir v0.1.0)

Copy Markdown View Source

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).

Summary

Functions

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

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

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

Persist a subscription credential atomically (mode 0600).

Types

credential()

@type credential() :: map()

Functions

clear(opts \\ [])

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

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

load(opts \\ [])

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

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

path(opts \\ [])

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

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

save(cred, opts \\ [])

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

Persist a subscription credential atomically (mode 0600).