nip43

package
v0.49.0 Latest Latest
Warning

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

Go to latest
Published: Jan 14, 2026 License: Unlicense Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	KindMemberList   = 13534 // Membership list published by relay
	KindAddUser      = 8000  // Add user event published by relay
	KindRemoveUser   = 8001  // Remove user event published by relay
	KindJoinRequest  = 28934 // Join request sent by user
	KindInviteReq    = 28935 // Invite request (ephemeral)
	KindLeaveRequest = 28936 // Leave request sent by user
)

Event kinds defined by NIP-43

Variables

This section is empty.

Functions

func BuildAddUserEvent

func BuildAddUserEvent(relaySecretKey []byte, userPubkey []byte) (*event.E, error)

BuildAddUserEvent creates a kind 8000 add user event

func BuildInviteEvent

func BuildInviteEvent(relaySecretKey []byte, inviteCode string) (*event.E, error)

BuildInviteEvent creates a kind 28935 invite event (ephemeral)

func BuildMemberListEvent

func BuildMemberListEvent(relaySecretKey []byte, members [][]byte) (*event.E, error)

BuildMemberListEvent creates a kind 13534 membership list event relaySecretKey: the relay's identity secret key (32 bytes) members: list of member pubkeys (32 bytes each)

func BuildRemoveUserEvent

func BuildRemoveUserEvent(relaySecretKey []byte, userPubkey []byte) (*event.E, error)

BuildRemoveUserEvent creates a kind 8001 remove user event

func ValidateJoinRequest

func ValidateJoinRequest(ev *event.E) (inviteCode string, valid bool, reason string)

ValidateJoinRequest validates a kind 28934 join request event

func ValidateLeaveRequest

func ValidateLeaveRequest(ev *event.E) (valid bool, reason string)

ValidateLeaveRequest validates a kind 28936 leave request event

Types

type InviteCode

type InviteCode struct {
	Code      string
	ExpiresAt time.Time
	UsedBy    []byte // pubkey that used this code, nil if unused
	CreatedAt time.Time
}

InviteCode represents a claim/invite code for relay access

type InviteManager

type InviteManager struct {
	// contains filtered or unexported fields
}

InviteManager manages invite codes for NIP-43

func NewInviteManager

func NewInviteManager(expiryDuration time.Duration) *InviteManager

NewInviteManager creates a new invite code manager

func (*InviteManager) CleanupExpired

func (im *InviteManager) CleanupExpired()

CleanupExpired removes expired invite codes

func (*InviteManager) GenerateCode

func (im *InviteManager) GenerateCode() (code string, err error)

GenerateCode creates a new invite code

func (*InviteManager) ValidateAndConsume

func (im *InviteManager) ValidateAndConsume(code string, pubkey []byte) (valid bool, reason string)

ValidateAndConsume validates an invite code and marks it as used by the given pubkey

Source Files

  • types.go

Jump to

Keyboard shortcuts

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