auth

package
v0.8.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Aug 18, 2025 License: Unlicense Imports: 14 Imported by: 0

Documentation

Overview

Package auth implements NIP-42 authentication.

Index

Constants

This section is empty.

Variables

View Source
var (
	// ChallengeTag is the tag for the challenge in a NIP-42 auth event
	// (prevents relay attacks).
	ChallengeTag = []byte("challenge")
	// RelayTag is the relay tag for a NIP-42 auth event (prevents cross-server
	// attacks).
	RelayTag = []byte("relay")
)

Functions

func CheckPrivilege added in v0.2.1

func CheckPrivilege(authedPubkey []byte, ev *event.E) (privileged bool)

func CreateUnsigned

func CreateUnsigned(pubkey, challenge []byte, relayURL string) (ev *event.E)

CreateUnsigned creates an event which should be sent via an "AUTH" command. If the authentication succeeds, the user will be authenticated as a pubkey.

func GenerateChallenge

func GenerateChallenge() (b []byte)

GenerateChallenge creates a reasonable, 16-byte base64 challenge string

func Validate

func Validate(evt *event.E, challenge []byte, relayURL string) (
	ok bool, err error,
)

Validate checks whether an event is a valid NIP-42 event for a given challenge and relayURL. The result of the validation is encoded in the ok bool.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL