Nostr.Event.ClientAuth (Nostr Lib v0.2.1) (event) (nip42)

View Source

Client authentication

Defined in NIP 42 https://github.com/nostr-protocol/nips/blob/master/42.md

Summary

Functions

Create a new ClientAuth event for authentication.

Parses a kind 22242 event into a ClientAuth struct with relay and challenge.

Types

t()

@type t() :: %Nostr.Event.ClientAuth{
  challenge: String.t(),
  event: Nostr.Event.t(),
  relay: URI.t()
}

Functions

create(relay, challenge, opts \\ [])

@spec create(relay :: String.t(), challenge :: String.t(), opts :: Keyword.t()) :: t()

Create a new ClientAuth event for authentication.

Arguments:

  • relay - the relay URL to authenticate with
  • challenge - the challenge string received from the relay
  • opts - other optional event arguments (pubkey, created_at, tags)

Example:

iex> auth = Nostr.Event.ClientAuth.create("wss://relay.example.com", "challenge123")
iex> auth.relay
"wss://relay.example.com"
iex> auth.challenge
"challenge123"
iex> auth.event.kind
22242

parse(event)

@spec parse(event :: Nostr.Event.t()) :: t()

Parses a kind 22242 event into a ClientAuth struct with relay and challenge.