libfed

package module
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Mar 12, 2023 License: GPL-3.0 Imports: 13 Imported by: 0

README

libfed

Documentation

Index

Constants

View Source
const (
	// ContextActivityStreams contains the context document for activity streams.
	ContextActivityStreams = "https://www.w3.org/ns/activitystreams"
	// ContextMastodon contains the context document for mastodon.
	ContextMastodon = "http://joinmastodon.org/ns"
	// ContextSecurity contains the context document for security.
	ContextSecurity = "https://w3id.org/security/v1"
)
View Source
const (
	// NodeInfo20Schema the schema url for nodeinfo 2.0.
	NodeInfo20Schema = "http://nodeinfo.diaspora.software/ns/schema/2.0"
	// NodeInfo21Schema the schema url for nodeinfo 2.1.
	NodeInfo21Schema = "http://nodeinfo.diaspora.software/ns/schema/2.1"
)
View Source
const HostMetaWebFingerTemplateRel = "lrdd"

HostMetaWebFingerTemplateRel matches a webfinger link relationship.

Variables

View Source
var (
	// ErrInvalidAccountFormat is returned when a federated account is in an invalid format.
	ErrInvalidAccountFormat = NewError("invalid account format")
	// ErrMissingNodeInfoURI is returned a well known node info document is missing a node info url.
	ErrMissingNodeInfoURI = NewError("missing node info url")
)

Functions

func SplitAccount

func SplitAccount(act string) (username string, domain string, err error)

SplitAccount splits a federated account into a username and domain.

Types

type Activity

type Activity map[string]interface{}

func (Activity) Actor

func (a Activity) Actor() (string, error)

func (Activity) ID

func (a Activity) ID() (string, error)

func (Activity) ObjectID

func (a Activity) ObjectID() (string, error)

func (Activity) ObjectType

func (a Activity) ObjectType() (ActivityType, error)

func (Activity) Type

func (a Activity) Type() (ActivityType, error)

type ActivityType

type ActivityType string
const (
	// TypeAccept is the Accept activity Type.
	TypeAccept ActivityType = "Accept"
	// TypeAdd is the Add activity Type.
	TypeAdd ActivityType = "Add"
	// TypeAnnounce is the Announce activity Type.
	TypeAnnounce ActivityType = "Announce"
	// TypeCreate is the Create activity Type.
	TypeCreate ActivityType = "Create"
	// TypeDelete is the Delete activity Type.
	TypeDelete ActivityType = "Delete"
	// TypeFollow is the Follow activity Type.
	TypeFollow ActivityType = "Follow"
	// TypeMove is the Move activity Type.
	TypeMove ActivityType = "Move"
	// TypeOrderedCollection is the OrderedCollection activity Type.
	TypeOrderedCollection ActivityType = "OrderedCollection"
	// TypeOrderedCollectionPage is the OrderedCollectionPage activity Type.
	TypeOrderedCollectionPage ActivityType = "OrderedCollectionPage"
	// TypeRemove is the Remove activity Type.
	TypeRemove ActivityType = "Remove"
	// TypeUndo is the Undo activity Type.
	TypeUndo ActivityType = "Undo"
	// TypeUpdate is the Update activity Type.
	TypeUpdate ActivityType = "Update"
)

func (ActivityType) String

func (a ActivityType) String() string

type Actor

type Actor struct {
	Context                   interface{}  `json:"@context"`
	Attachment                []Attachment `json:"attachment,omitempty"`
	Device                    string       `json:"device,omitempty"`
	Discoverable              bool         `json:"discoverable"`
	Endpoints                 *Endpoints   `json:"endpoints,omitempty"`
	Featured                  string       `json:"featured,omitempty"`
	FeaturedTags              string       `json:"featuredTags,omitempty"`
	Followers                 string       `json:"followers,omitempty"`
	Following                 string       `json:"following,omitempty"`
	Icon                      *Media       `json:"icon,omitempty"`
	Image                     *Media       `json:"image,omitempty"`
	Inbox                     string       `json:"inbox"`
	ID                        string       `json:"id"`
	ManuallyApprovesFollowers bool         `json:"manuallyApprovesFollowers"`
	Name                      string       `json:"name,omitempty"`
	Outbox                    string       `json:"outbox"`
	PreferredUsername         string       `json:"preferredUsername,omitempty"`
	PublicKey                 *PublicKey   `json:"publicKey,omitempty"`
	Published                 *time.Time   `json:"published,omitempty"`
	Summary                   string       `json:"summary,omitempty"`
	Tags                      []Tag        `json:"tag,omitempty"`
	Type                      ActorType    `json:"type,omitempty"`
	URL                       string       `json:"url,omitempty"`
}

Actor is an actor response.

func FetchActor

func FetchActor(ctx context.Context, t *http.Client, actorURL string) (*Actor, error)

FetchActor retrieves an actor resource from a instance.

func (*Actor) ParsePublicKey

func (a *Actor) ParsePublicKey() (crypto.PublicKey, error)

type ActorType

type ActorType string
const (
	// TypeApplication is the Application actor type.
	TypeApplication ActorType = "Application"
	// TypePerson is the Person actor type.
	TypePerson ActorType = "Person"
	// TypeService is the Service actor type.
	TypeService ActorType = "Service"
)

func (ActorType) String

func (a ActorType) String() string

type Attachment

type Attachment struct {
	Type  string `json:"type"`
	Name  string `json:"name"`
	Value string `json:"value"`
}

type Endpoints

type Endpoints struct {
	SharedInbox string `json:"sharedInbox"`
}

Endpoints represents known activity pub endpoints.

type Error

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

Error represents a fedihelper specific error.

func NewError

func NewError(m string) *Error

NewError wraps a message in a Error object.

func NewErrorf

func NewErrorf(m string, args ...interface{}) *Error

NewErrorf wraps a message in a Error object.

func (*Error) Error

func (e *Error) Error() string

Error returns the error message as a string.

type HostMeta

type HostMeta struct {
	XMLNS string `xml:"xmlns,attr"`
	Links []Link `xml:"Link"`
}

func FetchHostMeta

func FetchHostMeta(ctx context.Context, t *http.Client, domain string, config ...bool) (*HostMeta, error)

func (*HostMeta) WebFingerURI

func (h *HostMeta) WebFingerURI() WebFingerURI
type Link struct {
	Href     string `json:"href,omitempty"`
	Rel      string `json:"rel,omitempty" xml:"rel,attr"`
	Template string `json:"template,omitempty" xml:"template,attr"`
	Type     string `json:"type,omitempty"`
}

Link represents a link.

type Media

type Media struct {
	Type      string `json:"type"`
	MediaType string `json:"mediaType"`
	URL       string `json:"url"`
}

type NodeInfo

type NodeInfo struct {
	Metadata          interface{}      `json:"metadata"`
	OpenRegistrations bool             `json:"openRegistrations"`
	Protocols         []string         `json:"protocols"`
	Services          NodeInfoServices `json:"services"`
	Software          NodeInfoSoftware `json:"software"`
	Usage             NodeInfoUsage    `json:"usage"`
	Version           string           `json:"version"`
}

NodeInfo is a federated node info 2.0 object.

func FetchNodeInfo

func FetchNodeInfo(ctx context.Context, t *http.Client, infoURI *url.URL) (*NodeInfo, error)

FetchNodeInfo retrieves well-known nodei nfo from a federated instance.

func FetchNodeInfoForDomain

func FetchNodeInfoForDomain(ctx context.Context, t *http.Client, domain string, config ...bool) (*NodeInfo, error)

FetchNodeInfoForDomain retrieves well-known nodeinfo from a federated instance.

type NodeInfoServices

type NodeInfoServices struct {
	Inbound  []string `json:"inbound"`
	Outbound []string `json:"outbound"`
}

NodeInfoServices contains the supported services of the node.

type NodeInfoSoftware

type NodeInfoSoftware struct {
	Name    string `json:"name"`
	Version string `json:"version"`
}

NodeInfoSoftware contains the software and version of the node.

type NodeInfoUsage

type NodeInfoUsage struct {
	LocalPosts int64              `json:"localPosts"`
	Users      NodeInfoUsageUsers `json:"users"`
}

NodeInfoUsage contains usage statistics.

type NodeInfoUsageUsers

type NodeInfoUsageUsers struct {
	Total int64 `json:"total"`
}

NodeInfoUsageUsers contains usage statistics about users.

type PublicKey

type PublicKey struct {
	ID           string `json:"id"`
	Owner        string `json:"owner"`
	PublicKeyPEM string `json:"publicKeyPem"`
}

PublicKey represents an actor's public key.

type Software

type Software string
const (
	// SoftwareHometown is the software keyword for Hometown.
	SoftwareHometown Software = "hometown"
	// SoftwareMastodon is the software keyword for Mastodon.
	SoftwareMastodon Software = "mastodon"
	// SoftwarePleroma is the software keyword for Pleroma.
	SoftwarePleroma Software = "pleroma"
)

func (Software) String

func (s Software) String() string

type Tag

type Tag struct {
	ID      string    `json:"id,omitempty"`
	Type    string    `json:"type"`
	Name    string    `json:"name"`
	Updated time.Time `json:"updated,omitempty"`
	Icon    *Media    `json:"icon,omitempty"`
	HRef    string    `json:"href,omitempty"`
}

type WebFinger

type WebFinger struct {
	Aliases []string `json:"aliases,omitempty"`
	Links   []Link   `json:"links,omitempty"`
	Subject string   `json:"subject,omitempty"`
}

WebFinger is a web finger response.

func FetchWebFinger

func FetchWebFinger(ctx context.Context, t *http.Client, username, domain string, hostnames ...string) (*WebFinger, error)

FetchWebFinger retrieves web finger resource from a federated instance.

func (*WebFinger) ActorURI

func (w *WebFinger) ActorURI() (*url.URL, error)

ActorURI an actor uri.

type WebFingerURI

type WebFingerURI string

func (WebFingerURI) FTemplate

func (w WebFingerURI) FTemplate() string

func (WebFingerURI) String

func (w WebFingerURI) String() string

type WellKnownNodeInfo

type WellKnownNodeInfo struct {
	Links []Link `json:"links"`
}

WellKnownNodeInfo is a federated well known node info object.

func FetchWellKnownNodeInfo

func FetchWellKnownNodeInfo(ctx context.Context, t *http.Client, domain string, config ...bool) (*WellKnownNodeInfo, error)

FetchWellKnownNodeInfo retrieves wellknown nodeinfo from a federated instance.

func (*WellKnownNodeInfo) NodeInfoURI

func (w *WellKnownNodeInfo) NodeInfoURI() (*url.URL, error)

Jump to

Keyboard shortcuts

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