auth

package
v0.3.0-vainstr Latest Latest
Warning

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

Go to latest
Published: Jul 29, 2025 License: Unlicense Imports: 14 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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