Documentation
¶
Index ¶
- Constants
- func BuildAddUserEvent(relaySecretKey []byte, userPubkey []byte) (*event.E, error)
- func BuildInviteEvent(relaySecretKey []byte, inviteCode string) (*event.E, error)
- func BuildMemberListEvent(relaySecretKey []byte, members [][]byte) (*event.E, error)
- func BuildRemoveUserEvent(relaySecretKey []byte, userPubkey []byte) (*event.E, error)
- func ValidateJoinRequest(ev *event.E) (inviteCode string, valid bool, reason string)
- func ValidateLeaveRequest(ev *event.E) (valid bool, reason string)
- type InviteCode
- type InviteManager
Constants ¶
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 ¶
BuildAddUserEvent creates a kind 8000 add user event
func BuildInviteEvent ¶
BuildInviteEvent creates a kind 28935 invite event (ephemeral)
func BuildMemberListEvent ¶
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 ¶
BuildRemoveUserEvent creates a kind 8001 remove user event
func ValidateJoinRequest ¶
ValidateJoinRequest validates a kind 28934 join 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
Source Files
¶
- types.go