Parrhesia.API.Auth
(parrhesia v0.12.0)
Copy Markdown
Public helpers for event validation and NIP-98 HTTP authentication.
This module is intended for callers that need a programmatic API surface:
validate_event/1returns validator reason atoms.compute_event_id/1computes the canonical Nostr event id.validate_nip98/3andvalidate_nip98/4turn anAuthorizationheader into a shared auth context that can be reused by the rest of the API surface.
For transport-facing validation messages, see Parrhesia.Protocol.validate_event/1.
Summary
Functions
Computes the canonical Nostr event id for an event payload.
Validates a Nostr event and returns validator-friendly error atoms.
Validates a NIP-98 Authorization header using default options.
Validates a NIP-98 Authorization header and returns a shared auth context.
Functions
Computes the canonical Nostr event id for an event payload.
The event does not need to be persisted first. This is useful when building or signing events locally.
Validates a Nostr event and returns validator-friendly error atoms.
This is the low-level validation entrypoint used by the API surface. Unlike
Parrhesia.Protocol.validate_event/1, it preserves the raw validator reason so callers
can branch on it directly.
@spec validate_nip98(String.t() | nil, String.t(), String.t()) :: {:ok, Parrhesia.API.Auth.Context.t()} | {:error, term()}
Validates a NIP-98 Authorization header using default options.
@spec validate_nip98(String.t() | nil, String.t(), String.t(), keyword()) :: {:ok, Parrhesia.API.Auth.Context.t()} | {:error, term()}
Validates a NIP-98 Authorization header and returns a shared auth context.
The returned Parrhesia.API.Auth.Context includes:
- the decoded auth event
- the authenticated pubkey
- a
Parrhesia.API.RequestContextwithcaller: :http
Supported options are forwarded to Parrhesia.Auth.Nip98.validate_authorization_header/4,
including :max_age_seconds and :replay_cache.