vocab

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2023 License: Apache-2.0 Imports: 9 Imported by: 4

Documentation

Index

Constants

View Source
const (
	// RelationshipWitness defines the 'witness' relationship of a Link.
	RelationshipWitness = "witness"
)

Variables

View Source
var (
	// PublicIRI indicates that the object is public, i.e. it may be viewed by anyone.
	PublicIRI = MustParseURL("https://www.w3.org/ns/activitystreams#Public")

	// AnchorWitnessTargetIRI indicates that the object/target of the activity is an anchor witness.
	AnchorWitnessTargetIRI = MustParseURL("https://w3id.org/activityanchors#AnchorWitness")
)

Functions

func Marshal added in v0.1.1

func Marshal(o interface{}) ([]byte, error)

Marshal marshals the given object to a JSON representation without escaping characters such as '&', '<' and '>'.

func MarshalJSON

func MarshalJSON(o interface{}, others ...interface{}) ([]byte, error)

MarshalJSON marshals the given objects (merging them into one document) and returns the marshaled JSON result.

func MustParseURL added in v0.1.1

func MustParseURL(raw string) *url.URL

MustParseURL parses the string and returns the URL. This function panics if the string is not a valid URL.

func UnmarshalFromDoc added in v1.0.0

func UnmarshalFromDoc(doc Document, obj interface{}) error

UnmarshalFromDoc unmarshals the given document to the given object.

func UnmarshalJSON

func UnmarshalJSON(b []byte, objects ...interface{}) error

UnmarshalJSON unmarshals the given bytes to the set of provided objects.

Types

type ActivityOptions

type ActivityOptions struct {
	Result *ObjectProperty
	Actor  *url.URL
	Target *ObjectProperty
}

ActivityOptions holds the options for an Activity.

type ActivityType

type ActivityType struct {
	*ObjectType
	// contains filtered or unexported fields
}

ActivityType defines an 'activity'.

func NewAcceptActivity

func NewAcceptActivity(obj *ObjectProperty, opts ...Opt) *ActivityType

NewAcceptActivity returns a new 'Accept' activity.

func NewAnnounceActivity

func NewAnnounceActivity(obj *ObjectProperty, opts ...Opt) *ActivityType

NewAnnounceActivity returns a new 'Announce' activity.

func NewCreateActivity

func NewCreateActivity(obj *ObjectProperty, opts ...Opt) *ActivityType

NewCreateActivity returns a new 'Create' activity.

func NewFollowActivity

func NewFollowActivity(obj *ObjectProperty, opts ...Opt) *ActivityType

NewFollowActivity returns a new 'Follow' activity.

func NewInviteActivity added in v0.1.3

func NewInviteActivity(obj *ObjectProperty, opts ...Opt) *ActivityType

NewInviteActivity returns a new 'InviteWitness' activity.

func NewLikeActivity

func NewLikeActivity(obj *ObjectProperty, opts ...Opt) *ActivityType

NewLikeActivity returns a new 'Like' activity.

func NewOfferActivity

func NewOfferActivity(obj *ObjectProperty, opts ...Opt) *ActivityType

NewOfferActivity returns a new 'Offer' activity.

func NewRejectActivity

func NewRejectActivity(obj *ObjectProperty, opts ...Opt) *ActivityType

NewRejectActivity returns a new 'Reject' activity.

func NewUndoActivity

func NewUndoActivity(obj *ObjectProperty, opts ...Opt) *ActivityType

NewUndoActivity returns a new 'Undo' activity.

func (*ActivityType) Actor

func (t *ActivityType) Actor() *url.URL

Actor returns the actor for the activity.

func (*ActivityType) MarshalJSON

func (t *ActivityType) MarshalJSON() ([]byte, error)

MarshalJSON marshals the activity.

func (*ActivityType) Object

func (t *ActivityType) Object() *ObjectProperty

Object returns the object of the activity.

func (*ActivityType) Result

func (t *ActivityType) Result() *ObjectProperty

Result returns the result.

func (*ActivityType) SetActor

func (t *ActivityType) SetActor(iri *url.URL)

SetActor sets the actor for the activity.

func (*ActivityType) Target

func (t *ActivityType) Target() *ObjectProperty

Target returns the target of the activity.

func (*ActivityType) UnmarshalJSON

func (t *ActivityType) UnmarshalJSON(bytes []byte) error

UnmarshalJSON unmarshals the activity.

type ActorOptions

type ActorOptions struct {
	PublicKey  *PublicKeyType
	Inbox      *url.URL
	Outbox     *url.URL
	Followers  *url.URL
	Following  *url.URL
	Witnesses  *url.URL
	Witnessing *url.URL
	Liked      *url.URL
	Likes      *url.URL
	Shares     *url.URL
}

ActorOptions holds the options for an Activity.

type ActorType

type ActorType struct {
	*ObjectType
	// contains filtered or unexported fields
}

ActorType defines an 'actor'.

func NewService

func NewService(id *url.URL, opts ...Opt) *ActorType

NewService returns a new 'Service' actor type.

func (*ActorType) Followers

func (t *ActorType) Followers() *url.URL

Followers returns the URL of the actor's followers.

func (*ActorType) Following

func (t *ActorType) Following() *url.URL

Following returns the URL of what the actor is following.

func (*ActorType) Inbox

func (t *ActorType) Inbox() *url.URL

Inbox returns the URL of the actor's inbox.

func (*ActorType) Liked

func (t *ActorType) Liked() *url.URL

Liked returns the URL of what the actor has liked.

func (*ActorType) MarshalJSON

func (t *ActorType) MarshalJSON() ([]byte, error)

MarshalJSON mmarshals the object to JSON.

func (*ActorType) Outbox

func (t *ActorType) Outbox() *url.URL

Outbox returns the URL of the actor's outbox.

func (*ActorType) PublicKey

func (t *ActorType) PublicKey() *PublicKeyType

PublicKey returns the actor's public key.

func (*ActorType) UnmarshalJSON

func (t *ActorType) UnmarshalJSON(bytes []byte) error

UnmarshalJSON ummarshals the object from JSON.

func (*ActorType) Witnesses

func (t *ActorType) Witnesses() *url.URL

Witnesses returns the URL of the actor's witnesses.

func (*ActorType) Witnessing

func (t *ActorType) Witnessing() *url.URL

Witnessing returns the URL of what the actor is witnessing.

type AnchorEventOptions added in v1.0.0

type AnchorEventOptions struct {
	AnchorEvent *AnchorEventType
}

AnchorEventOptions holds the options for an AnchorEvent.

type AnchorEventType added in v1.0.0

type AnchorEventType struct {
	*ObjectType
	// contains filtered or unexported fields
}

AnchorEventType defines an "AnchorEvent" type.

func NewAnchorEvent added in v1.0.0

func NewAnchorEvent(obj *ObjectProperty, opts ...Opt) *AnchorEventType

NewAnchorEvent returns a new AnchorEvent type.

func (*AnchorEventType) MarshalJSON added in v1.0.0

func (t *AnchorEventType) MarshalJSON() ([]byte, error)

MarshalJSON marshals the object to JSON.

func (*AnchorEventType) Object added in v1.0.0

func (t *AnchorEventType) Object() *ObjectProperty

Object returns the Object property.

func (*AnchorEventType) UnmarshalJSON added in v1.0.0

func (t *AnchorEventType) UnmarshalJSON(bytes []byte) error

UnmarshalJSON umarshals the object from JSON.

func (*AnchorEventType) Validate added in v1.0.0

func (t *AnchorEventType) Validate() error

Validate validates the anchor event.

type CollectionOptions

type CollectionOptions struct {
	TotalItems int
	First      *url.URL
	Last       *url.URL
	Current    *url.URL
	PartOf     *url.URL
	Next       *url.URL
	Prev       *url.URL
}

CollectionOptions holds the options for a Collection or OrderedCollection.

type CollectionPageType

type CollectionPageType struct {
	*CollectionType
	// contains filtered or unexported fields
}

CollectionPageType defines a "CollectionPage" type.

func NewCollectionPage

func NewCollectionPage(items []*ObjectProperty, opts ...Opt) *CollectionPageType

NewCollectionPage returns a new collection page.

func (*CollectionPageType) MarshalJSON

func (t *CollectionPageType) MarshalJSON() ([]byte, error)

MarshalJSON marshals the collection page.

func (*CollectionPageType) Next

func (t *CollectionPageType) Next() *url.URL

Next return the URL that may be used to retrieve the next page.

func (*CollectionPageType) PartOf

func (t *CollectionPageType) PartOf() *url.URL

PartOf return the URL of the collection of which this page is a part.

func (*CollectionPageType) Prev

func (t *CollectionPageType) Prev() *url.URL

Prev return the URL that may be used to retrieve the previous page.

func (*CollectionPageType) UnmarshalJSON

func (t *CollectionPageType) UnmarshalJSON(bytes []byte) error

UnmarshalJSON unmarshals the collection page.

type CollectionType

type CollectionType struct {
	*ObjectType
	// contains filtered or unexported fields
}

CollectionType defines a "Collection" type.

func NewCollection

func NewCollection(items []*ObjectProperty, opts ...Opt) *CollectionType

NewCollection returns a new collection.

func (*CollectionType) Current

func (t *CollectionType) Current() *url.URL

Current returns the current item.

func (*CollectionType) First

func (t *CollectionType) First() *url.URL

First returns a URL that may be used to retrieve the first item in the collection.

func (*CollectionType) Items

func (t *CollectionType) Items() []*ObjectProperty

Items returns the items in the collection.

func (*CollectionType) Last

func (t *CollectionType) Last() *url.URL

Last returns a URL that may be used to retrieve the last item in the collection.

func (*CollectionType) MarshalJSON

func (t *CollectionType) MarshalJSON() ([]byte, error)

MarshalJSON marshals the object to JSON.

func (*CollectionType) TotalItems

func (t *CollectionType) TotalItems() int

TotalItems returns the total number of items in the collection.

func (*CollectionType) UnmarshalJSON

func (t *CollectionType) UnmarshalJSON(bytes []byte) error

UnmarshalJSON unmarshals the object from JSON.

type Context

type Context = string

Context defines the object context.

const (
	// ContextActivityStreams is the ActivityStreams context.
	ContextActivityStreams Context = "https://www.w3.org/ns/activitystreams"
	// ContextSecurity is the security context.
	ContextSecurity Context = "https://w3id.org/security/v1"
	// ContextCredentials is the verifiable credential context.
	ContextCredentials Context = "https://www.w3.org/2018/credentials/v1" //nolint:gosec
	// ContextActivityAnchors is the Activity Anchors context.
	ContextActivityAnchors Context = "https://w3id.org/activityanchors/v1"
)

type ContextProperty

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

ContextProperty holds one or more contexts.

func NewContextProperty

func NewContextProperty(context ...Context) *ContextProperty

NewContextProperty returns a new 'context' property. Nil is returned if no context was provided.

func (*ContextProperty) Contains

func (p *ContextProperty) Contains(contexts ...Context) bool

Contains returns true if the property contains all of the given contexts.

func (*ContextProperty) ContainsAny

func (p *ContextProperty) ContainsAny(contexts ...Context) bool

ContainsAny returns true if the property contains any of the given contexts.

func (*ContextProperty) Contexts

func (p *ContextProperty) Contexts() []Context

Contexts returns all of the contexts defined in the property.

func (*ContextProperty) MarshalJSON

func (p *ContextProperty) MarshalJSON() ([]byte, error)

MarshalJSON marshals the context property.

func (*ContextProperty) String

func (p *ContextProperty) String() string

String returns the string representation of the context property.

func (*ContextProperty) UnmarshalJSON

func (p *ContextProperty) UnmarshalJSON(bytes []byte) error

UnmarshalJSON unmarshals the context property.

type Document

type Document map[string]interface{}

Document defines a JSON document as a map.

func MarshalToDoc

func MarshalToDoc(obj interface{}) (Document, error)

MarshalToDoc marshals the given object to a Document.

func MustMarshalToDoc added in v1.0.0

func MustMarshalToDoc(obj interface{}) Document

MustMarshalToDoc marshals the given object to a Document.

func MustUnmarshalToDoc

func MustUnmarshalToDoc(raw []byte) Document

MustUnmarshalToDoc unmarshals the given bytes to a Document. If an error occurs then the function panics.

func UnmarshalToDoc

func UnmarshalToDoc(raw []byte) (Document, error)

UnmarshalToDoc unmarshals the given bytes to a Document.

func (Document) MergeWith

func (doc Document) MergeWith(other Document)

MergeWith merges the document with the given document. Any duplicate fields in the given document are ignored.

func (Document) Unmarshal added in v1.0.0

func (doc Document) Unmarshal(obj interface{}) error

Unmarshal unmarshals the document to the given object.

type LinkType added in v1.0.0

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

LinkType defines the ActivityPub 'Link' type.

func NewLink(hRef *url.URL, rel ...string) *LinkType

NewLink creates a new Link type.

func (*LinkType) HRef added in v1.0.0

func (t *LinkType) HRef() *url.URL

HRef return the reference ('href' field).

func (*LinkType) MarshalJSON added in v1.0.0

func (t *LinkType) MarshalJSON() ([]byte, error)

MarshalJSON marshals the link type to JSON.

func (*LinkType) Rel added in v1.0.0

func (t *LinkType) Rel() Relationship

Rel returns the relationship ('rel' field).

func (*LinkType) Type added in v1.0.0

func (t *LinkType) Type() *TypeProperty

Type always returns the "Link" type.

func (*LinkType) UnmarshalJSON added in v1.0.0

func (t *LinkType) UnmarshalJSON(bytes []byte) error

UnmarshalJSON umarshals the link type from JSON.

type MediaType added in v1.0.0

type MediaType = string

MediaType defines a type of encoding for content embedded within a document.

const (
	// JSONMediaType indicates that the content is plain JSON string.
	JSONMediaType MediaType = "application/json"
	// GzipMediaType indicates that the content is compressed with gzip and base64-encoded.
	GzipMediaType MediaType = "application/gzip"
)

type ObjectProperty

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

ObjectProperty defines an 'object' property. The property may be a simple IRI or an embedded object such as 'Collection', 'OrderedCollection', 'Activity', etc.

func NewObjectProperty

func NewObjectProperty(opts ...Opt) *ObjectProperty

NewObjectProperty returns a new 'object' property with the given options.

func (*ObjectProperty) Activity

func (p *ObjectProperty) Activity() *ActivityType

Activity returns the activity or nil if the activity is not set.

func (*ObjectProperty) AnchorEvent added in v1.0.0

func (p *ObjectProperty) AnchorEvent() *AnchorEventType

AnchorEvent returns the anchor event or nil if the anchor event is not set.

func (*ObjectProperty) Collection

func (p *ObjectProperty) Collection() *CollectionType

Collection returns the collection or nil if the collection is not set.

func (*ObjectProperty) Document added in v1.0.0

func (p *ObjectProperty) Document() Document

Document returns a document or nil if no document was set.

func (*ObjectProperty) IRI

func (p *ObjectProperty) IRI() *url.URL

IRI returns the IRI or nil if the IRI is not set.

func (*ObjectProperty) MarshalJSON

func (p *ObjectProperty) MarshalJSON() ([]byte, error)

MarshalJSON marshals the 'object' property.

func (*ObjectProperty) Object

func (p *ObjectProperty) Object() *ObjectType

Object returns the object or nil if the object is not set.

func (*ObjectProperty) OrderedCollection

func (p *ObjectProperty) OrderedCollection() *OrderedCollectionType

OrderedCollection returns the ordered collection or nil if the ordered collection is not set.

func (*ObjectProperty) Type

func (p *ObjectProperty) Type() *TypeProperty

Type returns the type of the object property. If the property is an IRI then nil is returned.

func (*ObjectProperty) UnmarshalJSON

func (p *ObjectProperty) UnmarshalJSON(bytes []byte) error

UnmarshalJSON unmarshals the 'object' property.

type ObjectPropertyOptions

type ObjectPropertyOptions struct {
	Iri               *url.URL
	Object            *ObjectType
	Collection        *CollectionType
	OrderedCollection *OrderedCollectionType
	Activity          *ActivityType
	Document          Document
}

ObjectPropertyOptions holds options for an 'object' property.

type ObjectType

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

ObjectType defines an 'object'.

func NewObject

func NewObject(opts ...Opt) *ObjectType

NewObject returns a new 'object'.

func NewObjectWithDocument

func NewObjectWithDocument(doc Document, opts ...Opt) (*ObjectType, error)

NewObjectWithDocument returns a new object initialized with the given document.

func (*ObjectType) Attachment added in v0.1.3

func (t *ObjectType) Attachment() []*ObjectProperty

Attachment returns the 'attachment' field.

func (*ObjectType) AttributedTo added in v1.0.0

func (t *ObjectType) AttributedTo() *URLProperty

AttributedTo returns the 'attributedTo' field.

func (*ObjectType) CID

func (t *ObjectType) CID() string

CID returns the object's content ID.

func (*ObjectType) Context

func (t *ObjectType) Context() *ContextProperty

Context returns the context property.

func (*ObjectType) EndTime

func (t *ObjectType) EndTime() *time.Time

EndTime returns the end time.

func (*ObjectType) Generator added in v1.0.0

func (t *ObjectType) Generator() string

Generator returns the 'generator' field.

func (*ObjectType) ID

func (t *ObjectType) ID() *URLProperty

ID returns the object's ID.

func (*ObjectType) InReplyTo added in v0.1.3

func (t *ObjectType) InReplyTo() *URLProperty

InReplyTo returns the 'inReplyTo' field.

func (*ObjectType) MarshalJSON

func (t *ObjectType) MarshalJSON() ([]byte, error)

MarshalJSON marshals the object.

func (*ObjectType) Published

func (t *ObjectType) Published() *time.Time

Published returns the time when the object was published.

func (*ObjectType) SetID

func (t *ObjectType) SetID(id *url.URL)

SetID sets the object's ID.

func (*ObjectType) StartTime

func (t *ObjectType) StartTime() *time.Time

StartTime returns the start time.

func (*ObjectType) Tag added in v1.0.0

func (t *ObjectType) Tag() []*TagProperty

Tag returns the 'tag' field.

func (*ObjectType) To

func (t *ObjectType) To() Urls

To returns a set of URLs to which the object should be sent.

func (*ObjectType) Type

func (t *ObjectType) Type() *TypeProperty

Type returns the type of the object.

func (*ObjectType) URL added in v0.1.3

func (t *ObjectType) URL() Urls

URL returns the object's URLs.

func (*ObjectType) UnmarshalJSON

func (t *ObjectType) UnmarshalJSON(bytes []byte) error

UnmarshalJSON unmarshals the object.

func (*ObjectType) Value

func (t *ObjectType) Value(key string) (interface{}, bool)

Value returns the value of a property.

type Opt

type Opt func(opts *Options)

Opt is an for an object, activity, etc.

func WithActivity

func WithActivity(activity *ActivityType) Opt

WithActivity sets the 'object' property to an embedded activity.

func WithActor

func WithActor(actor *url.URL) Opt

WithActor sets the 'actor' property on the activity.

func WithAnchorEvent added in v1.0.0

func WithAnchorEvent(anchorEvt *AnchorEventType) Opt

WithAnchorEvent sets the 'object' property.

func WithAttachment added in v0.1.3

func WithAttachment(obj ...*ObjectProperty) Opt

WithAttachment sets the 'attachment' property on the object.

func WithCollection

func WithCollection(coll *CollectionType) Opt

WithCollection sets the 'object' property to an embedded collection.

func WithContext

func WithContext(context ...Context) Opt

WithContext sets the 'context' property on the object.

func WithCurrent

func WithCurrent(current *url.URL) Opt

WithCurrent sets the 'current' property on the collection or ordered collection.

func WithDocument added in v1.0.0

func WithDocument(doc Document) Opt

WithDocument sets a raw document.

func WithEndTime

func WithEndTime(t *time.Time) Opt

WithEndTime sets the 'endTime' property on the object.

func WithFirst

func WithFirst(first *url.URL) Opt

WithFirst sets the 'first' property on the collection or ordered collection.

func WithFollowers

func WithFollowers(followers *url.URL) Opt

WithFollowers sets the 'followers' property on the actor.

func WithFollowing

func WithFollowing(following *url.URL) Opt

WithFollowing sets the 'following' property on the actor.

func WithID

func WithID(id *url.URL) Opt

WithID sets the 'id' property on the object.

func WithIRI

func WithIRI(iri *url.URL) Opt

WithIRI sets the 'object' property to an IRI.

func WithInReplyTo added in v0.1.3

func WithInReplyTo(id *url.URL) Opt

WithInReplyTo sets the 'inReplyTo' property on the object.

func WithInbox

func WithInbox(inbox *url.URL) Opt

WithInbox sets the 'inbox' property on the actor.

func WithLast

func WithLast(last *url.URL) Opt

WithLast sets the 'last' property on the collection or ordered collection.

func WithLiked

func WithLiked(liked *url.URL) Opt

WithLiked sets the 'liked' property on the actor.

func WithLikes added in v0.1.2

func WithLikes(likes *url.URL) Opt

WithLikes sets the 'likes' property on the actor.

func WithLink(link *LinkType) Opt

WithLink sets the 'link' property on the object.

func WithNext

func WithNext(next *url.URL) Opt

WithNext sets the 'next' property on a collection page or ordered collection page.

func WithObject

func WithObject(obj *ObjectType) Opt

WithObject sets the 'object' property to an embedded object.

func WithOrderedCollection

func WithOrderedCollection(coll *OrderedCollectionType) Opt

WithOrderedCollection sets the 'object' property to an embedded ordered collection.

func WithOutbox

func WithOutbox(outbox *url.URL) Opt

WithOutbox sets the 'outbox' property on the actor.

func WithOwner

func WithOwner(owner *url.URL) Opt

WithOwner sets the 'owner' property on the public key.

func WithPartOf

func WithPartOf(partOf *url.URL) Opt

WithPartOf sets the 'partOf' property on a collection page or ordered collection page.

func WithPrev

func WithPrev(prev *url.URL) Opt

WithPrev sets the 'prev' property on a collection page or ordered collection page.

func WithPublicKey

func WithPublicKey(publicKey *PublicKeyType) Opt

WithPublicKey sets the 'publicKey' property on the actor.

func WithPublicKeyPem

func WithPublicKeyPem(pem string) Opt

WithPublicKeyPem sets the 'publicKeyPem' property on the public key.

func WithPublishedTime

func WithPublishedTime(t *time.Time) Opt

WithPublishedTime sets the 'publishedTime' property on the object.

func WithResult

func WithResult(result *ObjectProperty) Opt

WithResult sets the 'result' property on the activity.

func WithShares added in v0.1.2

func WithShares(shares *url.URL) Opt

WithShares sets the 'shares' property on the actor.

func WithStartTime

func WithStartTime(t *time.Time) Opt

WithStartTime sets the 'startTime' property on the object.

func WithTag added in v1.0.0

func WithTag(tag *TagProperty) Opt

WithTag sets the 'tag' property on the object.

func WithTarget

func WithTarget(target *ObjectProperty) Opt

WithTarget sets the 'target' property on the activity.

func WithTo

func WithTo(to ...*url.URL) Opt

WithTo sets the "to" property on the object.

func WithTotalItems

func WithTotalItems(totalItems int) Opt

WithTotalItems sets the 'totalItems' property on the collection or ordered collection.

func WithType

func WithType(t ...Type) Opt

WithType sets tye 'type' property on the object.

func WithURL added in v0.1.3

func WithURL(u ...*url.URL) Opt

WithURL sets the 'url' property on the object.

func WithWitnesses

func WithWitnesses(witnesses *url.URL) Opt

WithWitnesses sets the 'witnesses' property on the actor.

func WithWitnessing

func WithWitnessing(witnessing *url.URL) Opt

WithWitnessing sets the 'witnessing' property on the actor.

type Options

type Options struct {
	Context      []Context
	ID           *url.URL
	URL          []*url.URL
	To           []*url.URL
	Published    *time.Time
	StartTime    *time.Time
	EndTime      *time.Time
	Types        []Type
	CID          string
	InReplyTo    *url.URL
	Attachment   []*ObjectProperty
	AttributedTo *url.URL
	Generator    string
	Tag          []*TagProperty
	Link         *LinkType

	ObjectPropertyOptions
	CollectionOptions
	ActivityOptions
	ActorOptions
	PublicKeyOptions
	AnchorEventOptions
}

Options holds all of the options for building an ActivityPub object.

func NewOptions

func NewOptions(opts ...Opt) *Options

NewOptions returns an Options struct which is populated with the provided options.

type OrderedCollectionPageType

type OrderedCollectionPageType struct {
	*OrderedCollectionType
	// contains filtered or unexported fields
}

OrderedCollectionPageType defines a "OrderedCollectionPage" type.

func NewOrderedCollectionPage

func NewOrderedCollectionPage(items []*ObjectProperty, opts ...Opt) *OrderedCollectionPageType

NewOrderedCollectionPage returns a new ordered collection page.

func (*OrderedCollectionPageType) MarshalJSON

func (t *OrderedCollectionPageType) MarshalJSON() ([]byte, error)

MarshalJSON marshals the collection page.

func (*OrderedCollectionPageType) Next

func (t *OrderedCollectionPageType) Next() *url.URL

Next return the URL that may be used to retrieve the next page.

func (*OrderedCollectionPageType) PartOf

func (t *OrderedCollectionPageType) PartOf() *url.URL

PartOf return the URL of the collection of which this page is a part.

func (*OrderedCollectionPageType) Prev

func (t *OrderedCollectionPageType) Prev() *url.URL

Prev return the URL that may be used to retrieve the previous page.

func (*OrderedCollectionPageType) UnmarshalJSON

func (t *OrderedCollectionPageType) UnmarshalJSON(bytes []byte) error

UnmarshalJSON unmarshals the collection page.

type OrderedCollectionType

type OrderedCollectionType struct {
	*CollectionType
	// contains filtered or unexported fields
}

OrderedCollectionType defines an "OrderedCollection" type.

func NewOrderedCollection

func NewOrderedCollection(items []*ObjectProperty, opts ...Opt) *OrderedCollectionType

NewOrderedCollection returns a new ordered collection.

func (*OrderedCollectionType) Items

func (t *OrderedCollectionType) Items() []*ObjectProperty

Items returns the items in the ordered collection.

func (*OrderedCollectionType) MarshalJSON

func (t *OrderedCollectionType) MarshalJSON() ([]byte, error)

MarshalJSON marshals the ordered collection.

func (*OrderedCollectionType) UnmarshalJSON

func (t *OrderedCollectionType) UnmarshalJSON(bytes []byte) error

UnmarshalJSON unmarshals the ordered collection.

type PublicKeyOptions

type PublicKeyOptions struct {
	Owner        *url.URL
	PublicKeyPem string
}

PublicKeyOptions holds the options for a Public Key.

type PublicKeyType

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

PublicKeyType defines a public key object.

func NewPublicKey

func NewPublicKey(opts ...Opt) *PublicKeyType

NewPublicKey returns a new public key object.

func (*PublicKeyType) ID

func (t *PublicKeyType) ID() *url.URL

ID returns the public key ID.

func (*PublicKeyType) MarshalJSON added in v1.0.0

func (t *PublicKeyType) MarshalJSON() ([]byte, error)

MarshalJSON marshals the object to JSON.

func (*PublicKeyType) Owner

func (t *PublicKeyType) Owner() *url.URL

Owner returns the owner of the key.

func (*PublicKeyType) PublicKeyPem

func (t *PublicKeyType) PublicKeyPem() string

PublicKeyPem returns the public key in PEM format.

func (*PublicKeyType) UnmarshalJSON added in v1.0.0

func (t *PublicKeyType) UnmarshalJSON(bytes []byte) error

UnmarshalJSON unmarshals the object from JSON.

type Relationship added in v1.0.0

type Relationship []string

Relationship holds the relationship of the Link.

func (Relationship) Is added in v1.0.0

func (r Relationship) Is(relationship string) bool

Is return true if the given relationship is contained.

type TagProperty added in v1.0.0

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

TagProperty defines the 'tag' property.

func NewTagProperty added in v1.0.0

func NewTagProperty(opts ...Opt) *TagProperty

NewTagProperty returns a new Tag property.

func (p *TagProperty) Link() *LinkType

Link returns the link of the tag property. Nil is returned if the tag is not a Link type.

func (*TagProperty) MarshalJSON added in v1.0.0

func (p *TagProperty) MarshalJSON() ([]byte, error)

MarshalJSON marshals the 'tag' property.

func (*TagProperty) Object added in v1.0.0

func (p *TagProperty) Object() *ObjectType

Object returns the object of the tag property. Nil is returned if the tag is not an Object type.

func (*TagProperty) Type added in v1.0.0

func (p *TagProperty) Type() *TypeProperty

Type returns the type of the tag property.

func (*TagProperty) UnmarshalJSON added in v1.0.0

func (p *TagProperty) UnmarshalJSON(bytes []byte) error

UnmarshalJSON unmarshals the 'tag' property.

type Type

type Type string

Type indicates the type of the object.

const (
	// TypeCollection specifies the 'Collection' object type.
	TypeCollection Type = "Collection"
	// TypeOrderedCollection specifies the 'OrderedCollection' object type.
	TypeOrderedCollection Type = "OrderedCollection"
	// TypeCollectionPage specifies the 'CollectionPage' object type.
	TypeCollectionPage Type = "CollectionPage"
	// TypeOrderedCollectionPage specifies the 'OrderedCollectionPage' object type.
	TypeOrderedCollectionPage Type = "OrderedCollectionPage"

	// TypeService specifies the 'Service' actor type.
	TypeService Type = "Service"
	// TypeCreate specifies the 'Create' activity type.
	TypeCreate Type = "Create"
	// TypeAnnounce specifies the 'Announce' activity type.
	TypeAnnounce Type = "Announce"
	// TypeFollow specifies the 'Follow' activity type.
	TypeFollow Type = "Follow"
	// TypeAccept specifies the 'Accept' activity type.
	TypeAccept Type = "Accept"
	// TypeReject specifies the 'Reject' activity type.
	TypeReject Type = "Reject"
	// TypeLike specifies the 'Like' activity type.
	TypeLike Type = "Like"
	// TypeInvite specifies the 'Invite' activity type.
	TypeInvite Type = "Invite"

	// TypeLink specifies the 'Link' object type.
	TypeLink Type = "Link"

	// TypeVerifiableCredential specifies the "VerifiableCredential" object type.
	TypeVerifiableCredential Type = "VerifiableCredential" //nolint:gosec

	// TypeAnchorEvent specifies the "AnchorEvent" object type.
	TypeAnchorEvent Type = "AnchorEvent"

	// TypeAnchorReceipt specifies the "AnchorReceipt" object type.
	TypeAnchorReceipt Type = "AnchorReceipt"
	// TypeOffer specifies the "Offer" activity type.
	TypeOffer Type = "Offer"
	// TypeUndo specifies the "Undo" activity type.
	TypeUndo Type = "Undo"
)

type TypeProperty

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

TypeProperty defines a 'type' property on an abject which can hold one or more types.

func NewTypeProperty

func NewTypeProperty(t ...Type) *TypeProperty

NewTypeProperty returns a new 'type' property. Nil is returned if no types were provided.

func (*TypeProperty) Is

func (p *TypeProperty) Is(types ...Type) bool

Is returns true if the property has all of the given types.

func (*TypeProperty) IsActivity added in v1.0.0

func (p *TypeProperty) IsActivity() bool

IsActivity returns true if the type is an ActivityPub Activity.

func (*TypeProperty) IsAny

func (p *TypeProperty) IsAny(types ...Type) bool

IsAny returns true if the property has any of the given types.

func (*TypeProperty) MarshalJSON

func (p *TypeProperty) MarshalJSON() ([]byte, error)

MarshalJSON marshals the type property.

func (*TypeProperty) String

func (p *TypeProperty) String() string

String returns the string representation of the type property.

func (*TypeProperty) Types

func (p *TypeProperty) Types() []Type

Types returns all types.

func (*TypeProperty) UnmarshalJSON

func (p *TypeProperty) UnmarshalJSON(bytes []byte) error

UnmarshalJSON unmarshals the type property.

type URLCollectionProperty

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

URLCollectionProperty contains a collection of URLs.

func NewURLCollectionProperty

func NewURLCollectionProperty(urls ...*url.URL) *URLCollectionProperty

NewURLCollectionProperty returns a new URL collection property. Nil is returned if no URLs were provided.

func (*URLCollectionProperty) MarshalJSON

func (p *URLCollectionProperty) MarshalJSON() ([]byte, error)

MarshalJSON marshals the URL collection.

func (*URLCollectionProperty) URLs

func (p *URLCollectionProperty) URLs() []*url.URL

URLs returns the URLs.

func (*URLCollectionProperty) UnmarshalJSON

func (p *URLCollectionProperty) UnmarshalJSON(bytes []byte) error

UnmarshalJSON unmarshals the URL collection.

type URLProperty

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

URLProperty holds a URL.

func NewURLProperty

func NewURLProperty(u *url.URL) *URLProperty

NewURLProperty returns a new URL property with the given URL. Nil is returned if the provided URL is nil.

func (*URLProperty) MarshalJSON

func (p *URLProperty) MarshalJSON() ([]byte, error)

MarshalJSON marshals the URL property.

func (*URLProperty) String

func (p *URLProperty) String() string

String returns the string representation of the URL.

func (*URLProperty) URL

func (p *URLProperty) URL() *url.URL

URL returns the contained URL.

func (*URLProperty) UnmarshalJSON

func (p *URLProperty) UnmarshalJSON(bytes []byte) error

UnmarshalJSON unmarshals the URL property.

type Urls added in v0.1.1

type Urls []*url.URL

Urls holds a collection of URLs.

func (Urls) Contains added in v0.1.1

func (u Urls) Contains(values ...fmt.Stringer) bool

Contains returns true if the collection of URLs contains the given URLs.

func (Urls) Equals added in v1.0.0

func (u Urls) Equals(urls Urls) bool

Equals returns true if the given collection of URLs is the same as this one. (Order does not matter.)

func (Urls) String added in v1.0.0

func (u Urls) String() string

String returns the string representation of the URL array.

Jump to

Keyboard shortcuts

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