Kantoor.Karta.Settings (Kantoor v1.0.0)

Runtime settings for the Karta integration, read from config :kantoor, Kantoor.Karta, ... on every call (so tests and runtime config can change them).

Keys: :inbound_secrets (list of whsec_ strings), :inbound_header ({name, value} or nil), :max_body_bytes, :base_url, :api_key, :req_options (merged into every client request, used by tests), :client (module implementing Kantoor.Karta.Client).

The struct holds the client credentials; its Inspect implementation hides the API key.

Summary

Functions

Client credentials, or {:error, :not_configured}.

Client credentials for one domain: the key stored on that domain when there is one (Kantoor.Karta.Keys), else the instance key. {:error, :not_configured} when neither is there; {:error, :karta_key_unreadable} when a key is stored but will not decrypt (the wrong vault key) — falling back would ask the wrong Karta organisation.

The module implementing the client behaviour.

Credentials with a named key (one the caller just received, not yet stored), for the call that stores it. The base URL is always the instance's.

Optional extra shared header as {lowercase_name, value}.

Configured endpoint secrets (whsec_...), possibly several for rotation.

Maximum accepted size of an inbound push body in bytes.

Every secret a push may be signed with: KARTA_INBOUND_SECRETS and the secrets of the endpoints Kantoor registered itself (stored encrypted, see Kantoor.Vault).

Types

t()

@type t() :: %Kantoor.Karta.Settings{
  api_key: String.t(),
  base_url: String.t(),
  req_options: keyword()
}

Functions

client()

@spec client() :: {:ok, t()} | {:error, :not_configured}

Client credentials, or {:error, :not_configured}.

client(domain)

@spec client(String.t() | nil) ::
  {:ok, t()} | {:error, :not_configured | :karta_key_unreadable}

Client credentials for one domain: the key stored on that domain when there is one (Kantoor.Karta.Keys), else the instance key. {:error, :not_configured} when neither is there; {:error, :karta_key_unreadable} when a key is stored but will not decrypt (the wrong vault key) — falling back would ask the wrong Karta organisation.

client_module()

@spec client_module() :: module()

The module implementing the client behaviour.

client_with_key(key)

@spec client_with_key(String.t() | nil) :: {:ok, t()} | {:error, :not_configured}

Credentials with a named key (one the caller just received, not yet stored), for the call that stores it. The base URL is always the instance's.

inbound_header()

@spec inbound_header() :: {String.t(), String.t()} | nil

Optional extra shared header as {lowercase_name, value}.

inbound_secrets()

@spec inbound_secrets() :: [String.t()]

Configured endpoint secrets (whsec_...), possibly several for rotation.

max_body_bytes()

@spec max_body_bytes() :: pos_integer()

Maximum accepted size of an inbound push body in bytes.

verification_secrets()

@spec verification_secrets() :: [String.t()]

Every secret a push may be signed with: KARTA_INBOUND_SECRETS and the secrets of the endpoints Kantoor registered itself (stored encrypted, see Kantoor.Vault).