event

package
v0.0.0-...-2733076 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2024 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrNoSignerSet = fmt.Errorf("no signer set for builder")
	ErrSignFailure = fmt.Errorf("failed to sign event")
)
View Source
var (
	ErrInvalidSignature = fmt.Errorf("invalid signature")
	ErrInvalidID        = fmt.Errorf("invalid id")
)

Functions

func Validate

func Validate(e Event) error

Types

type Builder

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

func NewBuilder

func NewBuilder(k Kind, c string, privKey []byte) *Builder

func (*Builder) Build

func (b *Builder) Build() (Event, error)

func (*Builder) SetTags

func (b *Builder) SetTags(t Tags)

func (*Builder) SetTimestamp

func (b *Builder) SetTimestamp(t time.Time)

type Event

type Event struct {
	Payload

	ID        ID        `json:"id"`
	PubKey    PubKey    `json:"pubkey"`
	Signature Signature `json:"sig"`
}

func Sign

func Sign(p Payload, key []byte) (Event, error)

type ID

type ID [32]byte

func (ID) MarshalJSON

func (p ID) MarshalJSON() ([]byte, error)

type Kind

type Kind int16

type Payload

type Payload struct {
	Timestamp int64  `json:"created_at"`
	Kind      Kind   `json:"kind"`
	Tags      Tags   `json:"tags"`
	Content   string `json:"content"`
}

type PubKey

type PubKey [32]byte

func (PubKey) MarshalJSON

func (p PubKey) MarshalJSON() ([]byte, error)

type Signature

type Signature [64]byte

func (Signature) MarshalJSON

func (p Signature) MarshalJSON() ([]byte, error)

type Tag

type Tag []string

func (Tag) MarshalJSON

func (p Tag) MarshalJSON() ([]byte, error)

type Tags

type Tags []Tag

func (Tags) MarshalJSON

func (p Tags) MarshalJSON() ([]byte, error)

Jump to

Keyboard shortcuts

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