Documentation ¶
Index ¶
- Constants
- type Account
- type Activity
- type ActivityType
- type Actor
- type ActorType
- type CreateAccountHandler
- type Endpoints
- type Error
- type FediHelper
- func (f *FediHelper) FetchActor(ctx context.Context, actorIRI *url.URL) (*Actor, error)
- func (f *FediHelper) FetchHostMeta(ctx context.Context, domain string) (*HostMeta, error)
- func (f *FediHelper) FetchWebFinger(ctx context.Context, wfURI WebfingerURI, username, domain string) (*WebFinger, error)
- func (f *FediHelper) FetchWellknownWebFinger(ctx context.Context, serverHostname, username, domain string) (*WebFinger, error)
- func (f *FediHelper) GenerateFediAccountFromUsername(ctx context.Context, username string, instance Instance, account Account) error
- func (f *FediHelper) GenerateFediInstanceFromDomain(ctx context.Context, domain string, instance Instance) error
- func (f *FediHelper) GetLoginURL(ctx context.Context, redirectURI *url.URL, instance Instance) (*url.URL, error)
- func (f *FediHelper) GetNodeInfo20(ctx context.Context, domain string, infoURI *url.URL) (*NodeInfoV2, error)
- func (f *FediHelper) GetWellknownNodeInfo(ctx context.Context, domain string) (*WellKnownNodeInfo, error)
- func (f *FediHelper) Helper(s SoftwareName) Helper
- func (f *FediHelper) SetCreateAccountHandler(handler CreateAccountHandler)
- func (f *FediHelper) SetGetAccountHandler(handler GetAccountHandler)
- func (f *FediHelper) SetNewAccountHandler(handler NewAccountHandler)
- func (*FediHelper) WebfingerURIFromHostMeta(hostMeta *HostMeta) (string, error)
- type GetAccountHandler
- type Helper
- type HostMeta
- type HttpClient
- type Instance
- type KV
- type Link
- type NewAccountHandler
- type NodeInfoV2
- type PublicKey
- type Services
- type Software
- type SoftwareName
- type Transport
- type Usage
- type UsageUsers
- type WebFinger
- type WebfingerURI
- type WellKnownNodeInfo
Constants ¶
const ( // ContextActivityStreams contains the context document for activity streams ContextActivityStreams = "https://www.w3.org/ns/activitystreams" // HostMetaWebFingerTemplateRel matches a webfinger link relationship. HostMetaWebFingerTemplateRel = "lrdd" // NodeInfo20Schema the schema url for nodeinfo 2.0. NodeInfo20Schema = "http://nodeinfo.diaspora.software/ns/schema/2.0" // SoftwareMastodon is the software keyword for Mastodon. SoftwareMastodon SoftwareName = "mastodon" // TypeAccept is the Accept activity Type TypeAccept ActivityType = "Accept" // 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" // TypeUndo is the Undo activity Type TypeUndo ActivityType = "Undo" // TypeUpdate is the Update activity Type TypeUpdate ActivityType = "Update" // TypeApplication is the Application actor type TypeApplication ActorType = "Application" // TypePerson is the Person actor type TypePerson ActorType = "Person" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Account ¶
type Account interface { GetActorURI() (actorURI string) GetDisplayName() (displayName string) GetID() (id int64) GetInstance() (instance Instance) GetLastFinger() (lastFinger time.Time) GetUsername() (username string) SetActorURI(actorURI string) SetDisplayName(displayName string) SetInstance(instance Instance) SetLastFinger(lastFinger time.Time) SetUsername(username string) }
type Activity ¶
type Activity map[string]interface{}
func (Activity) ObjectType ¶
func (a Activity) ObjectType() (ActivityType, error)
func (Activity) Type ¶
func (a Activity) Type() (ActivityType, error)
type ActivityType ¶
type ActivityType string
func (ActivityType) String ¶
func (a ActivityType) String() string
type Actor ¶
type Actor struct { Context interface{} `json:"@context"` Endpoints Endpoints `json:"endpoints"` Followers string `json:"followers"` Following string `json:"following"` Inbox string `json:"inbox"` Name string `json:"name"` Type ActorType `json:"type"` ID string `json:"id"` PublicKey PublicKey `json:"publicKey"` Summary string `json:"summary"` PreferredUsername string `json:"preferredUsername"` URL string `json:"url"` }
Actor is an actor response.
func (*Actor) MakeInstance ¶
type CreateAccountHandler ¶
type Error ¶
type Error struct {
// contains filtered or unexported fields
}
Error represents a fedihelper specific error.
type FediHelper ¶
type FediHelper struct { CreateAccountHandler CreateAccountHandler GetAccountHandler GetAccountHandler NewAccountHandler NewAccountHandler // contains filtered or unexported fields }
FediHelper is a module for working with federated social instances.
func (*FediHelper) FetchActor ¶
func (*FediHelper) FetchHostMeta ¶
func (*FediHelper) FetchWebFinger ¶
func (f *FediHelper) FetchWebFinger(ctx context.Context, wfURI WebfingerURI, username, domain string) (*WebFinger, error)
FetchWebFinger retrieves web finger resource from a federated instance.
func (*FediHelper) FetchWellknownWebFinger ¶
func (f *FediHelper) FetchWellknownWebFinger(ctx context.Context, serverHostname, username, domain string) (*WebFinger, error)
FetchWellknownWebFinger retrieves wellknown web finger resource from a federated instance.
func (*FediHelper) GenerateFediAccountFromUsername ¶
func (f *FediHelper) GenerateFediAccountFromUsername(ctx context.Context, username string, instance Instance, account Account) error
GenerateFediAccountFromUsername creates an Account object by querying the apis of the federated instance.
func (*FediHelper) GenerateFediInstanceFromDomain ¶
func (f *FediHelper) GenerateFediInstanceFromDomain(ctx context.Context, domain string, instance Instance) error
GenerateFediInstanceFromDomain created a Instance object by querying the apis of the federated instance.
func (*FediHelper) GetLoginURL ¶
func (f *FediHelper) GetLoginURL(ctx context.Context, redirectURI *url.URL, instance Instance) (*url.URL, error)
GetLoginURL retrieves an oauth url for a federated instance.
func (*FediHelper) GetNodeInfo20 ¶
func (f *FediHelper) GetNodeInfo20(ctx context.Context, domain string, infoURI *url.URL) (*NodeInfoV2, error)
GetNodeInfo20 retrieves wellknown nodeinfo from a federated instance.
func (*FediHelper) GetWellknownNodeInfo ¶
func (f *FediHelper) GetWellknownNodeInfo(ctx context.Context, domain string) (*WellKnownNodeInfo, error)
GetWellknownNodeInfo retrieves wellknown nodeinfo from a federated instance.
func (*FediHelper) Helper ¶
func (f *FediHelper) Helper(s SoftwareName) Helper
Helper returns a helper for a given software package.
func (*FediHelper) SetCreateAccountHandler ¶
func (f *FediHelper) SetCreateAccountHandler(handler CreateAccountHandler)
func (*FediHelper) SetGetAccountHandler ¶
func (f *FediHelper) SetGetAccountHandler(handler GetAccountHandler)
func (*FediHelper) SetNewAccountHandler ¶
func (f *FediHelper) SetNewAccountHandler(handler NewAccountHandler)
func (*FediHelper) WebfingerURIFromHostMeta ¶
func (*FediHelper) WebfingerURIFromHostMeta(hostMeta *HostMeta) (string, error)
type GetAccountHandler ¶
type Helper ¶
type Helper interface { GetAccessToken(ctx context.Context, redirectURI *url.URL, instance Instance, code string) (accessToken string, err error) GetCurrentAccount(ctx context.Context, instance Instance, accessToken string) (user Account, err error) GetSoftware() SoftwareName RegisterApp(ctx context.Context, redirectURI *url.URL, instance Instance) (clientID string, clientSecret string, err error) SetFedi(f *FediHelper) MakeLoginURI(ctx context.Context, redirectURI *url.URL, instance Instance) (loginURI *url.URL, err error) }
Helper interacts with a federated social instance.
type HostMeta ¶
func (*HostMeta) WebfingerURI ¶
func (h *HostMeta) WebfingerURI() WebfingerURI
type HttpClient ¶
type HttpClient interface { pub.HttpClient Transport() (transport http.RoundTripper) }
type Instance ¶
type Instance interface { GetActorURI() (actorURI string) GetDomain() (domain string) GetID() (id int64) GetServerHostname() (hostname string) GetSoftware() (software string) SetActorURI(actorURI string) SetDomain(domain string) SetInboxURI(inboxURI string) SetServerHostname(hostname string) SetSoftware(software string) }
type KV ¶
type KV interface { DeleteAccessToken(ctx context.Context, accountID int64) (err error) GetAccessToken(ctx context.Context, accountID int64) (accessToken string, err error) SetAccessToken(ctx context.Context, accountID int64, accessToken string) (err error) DeleteActor(ctx context.Context, actorURI string) (err error) GetActor(ctx context.Context, actorURI string) (actor []byte, err error) SetActor(ctx context.Context, actorURI string, actor []byte, expire time.Duration) (err error) DeleteHostMeta(ctx context.Context, domain string) (err error) GetHostMeta(ctx context.Context, domain string) (hostmeta []byte, err error) SetHostMeta(ctx context.Context, domain string, hostmeta []byte, expire time.Duration) (err error) DeleteInstanceOAuth(ctx context.Context, instanceID int64) (err error) GetInstanceOAuth(ctx context.Context, instanceID int64) (clientID string, clientSecret string, err error) SetInstanceOAuth(ctx context.Context, instanceID int64, clientID string, clientSecret string) (err error) DeleteFediNodeInfo(ctx context.Context, domain string) (err error) GetFediNodeInfo(ctx context.Context, domain string) (nodeinfo []byte, err error) SetFediNodeInfo(ctx context.Context, domain string, nodeinfo []byte, expire time.Duration) (err error) }
type Link ¶
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 NewAccountHandler ¶
type NodeInfoV2 ¶
type NodeInfoV2 struct { Metadata map[string]interface{} `json:"metadata"` OpenRegistrations bool `json:"openRegistrations"` Protocols []string `json:"protocols"` Services Services `json:"services"` Software Software `json:"software"` Usage Usage `json:"usage"` Version string `json:"version"` }
NodeInfoV2 is a federated node info 2.0 object.
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 SoftwareName ¶
type SoftwareName string
func (SoftwareName) String ¶
func (s SoftwareName) String() string
type Transport ¶
type Transport struct {
// contains filtered or unexported fields
}
Transport handled signing outgoing requests to federated instances
func NewTransport ¶
func NewTransport(clock pub.Clock, client HttpClient, pubKeyID string, privkey crypto.PrivateKey) (*Transport, error)
NewTransport creates a new Transport module
func (*Transport) Client ¶
func (t *Transport) Client() HttpClient
func (*Transport) InstanceGet ¶
type Usage ¶
type Usage struct { LocalPosts int64 `json:"localPosts"` Users UsageUsers `json:"users"` }
Usage contains usage statistics
type UsageUsers ¶
type UsageUsers struct {
Total int64 `json:"total"`
}
UsageUsers contains usage statistics about users
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.
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.