httpauth

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: 16 Imported by: 0

Documentation

Overview

Package httpauth provides helpers and encoders for nostr NIP-98 HTTP authentication header messages and a new JWT authentication message and delegation event kind 13004 that enables time limited expiring delegations of authentication (as with NIP-42 auth) for the HTTP API.

Index

Constants

View Source
const (
	HeaderKey   = "Authorization"
	NIP98Prefix = "Nostr"
)

Variables

View Source
var ErrMissingKey = fmt.Errorf(
	"'%s' key missing from request header", HeaderKey,
)

Functions

func AddNIP98Header

func AddNIP98Header(
	r *http.Request, ur *url.URL, method, hash string,
	sign signer.I, expiry int64,
) (err error)

AddNIP98Header creates a NIP-98 http auth event and adds the standard header to a provided http.Request.

func CheckAuth

func CheckAuth(r *http.Request, tolerance ...time.Duration) (
	valid bool,
	pubkey []byte, err error,
)

CheckAuth verifies a received http.Request has got a valid authentication event in it, with an optional specification for tolerance of before and after, and provides the public key that should be verified to be authorized to access the resource associated with the request.

func CreateNIP98Blob added in v0.4.0

func CreateNIP98Blob(
	ur, method, hash string, expiry int64, sign signer.I,
) (blob string, err error)

func MakeNIP98Event

func MakeNIP98Event(u, method, hash string, expiry int64) (ev *event.E)

MakeNIP98Event creates a new NIP-98 event. If expiry is given, method is ignored; otherwise either option is the same.

Types

This section is empty.

Jump to

Keyboard shortcuts

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