spi

package
v1.0.1 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrDuplicateAnchorEvent = errors.New("anchor event already handled")

ErrDuplicateAnchorEvent indicates that the anchor event was already processed by the InboxHandler.

Functions

This section is empty.

Types

type AcceptFollowHandler

type AcceptFollowHandler interface {
	Accept(actor *url.URL) error
}

AcceptFollowHandler handles accepting follow request.

type AcceptList

type AcceptList struct {
	Type string
	URL  []*url.URL
}

AcceptList contains the URIs that are to be accepted by an authorization handler for the given type. Known types are "follow" and "invite-witness".

type ActivityHandler

type ActivityHandler interface {
	ServiceLifecycle

	// HandleActivity handles the ActivityPub activity. An optional source may be added
	// to indicate where the activity was retrieved from.
	HandleActivity(source *url.URL, activity *vocab.ActivityType) error

	// Subscribe allows a client to receive published activities.
	Subscribe() <-chan *vocab.ActivityType
}

ActivityHandler defines the functions of an Activity handler.

type ActorAuth

type ActorAuth interface {
	AuthorizeActor(actor *vocab.ActorType) (bool, error)
}

ActorAuth makes the decision of whether or not a request by the given actor should be accepted.

type AnchorEventAcknowledgementHandler

type AnchorEventAcknowledgementHandler interface {
	AnchorEventAcknowledged(actor, anchorRef *url.URL, additionalAnchorRefs []*url.URL) error
	UndoAnchorEventAcknowledgement(actor, anchorRef *url.URL, additionalAnchorRefs []*url.URL) error
}

AnchorEventAcknowledgementHandler handles notification of a successful anchor event processed from an Oak server, as well as undoing a previously acknowledged anchor event.

type AnchorHandler

type AnchorHandler interface {
	HandleAnchorEvent(actor, anchorEventRef, source *url.URL, anchorEvent *vocab.AnchorEventType) error
}

AnchorHandler handles a new, published anchor event.

type HandlerOpt

type HandlerOpt func(options *Handlers)

HandlerOpt sets a specific handler.

func WithAcceptFollowHandler

func WithAcceptFollowHandler(handler AcceptFollowHandler) HandlerOpt

WithAcceptFollowHandler sets accept follow handler.

func WithAnchorEventAcknowledgementHandler

func WithAnchorEventAcknowledgementHandler(handler AnchorEventAcknowledgementHandler) HandlerOpt

WithAnchorEventAcknowledgementHandler sets the handler for an acknowledgement of a successful anchor event that was processed by another Oak server.

func WithAnchorEventHandler

func WithAnchorEventHandler(handler AnchorHandler) HandlerOpt

WithAnchorEventHandler sets the handler for the published anchor event.

func WithFollowAuth

func WithFollowAuth(handler ActorAuth) HandlerOpt

WithFollowAuth sets the handler that decides whether or not to accept a 'Follow' request.

func WithInviteWitnessAuth

func WithInviteWitnessAuth(handler ActorAuth) HandlerOpt

WithInviteWitnessAuth sets the handler that decides whether or not to accept an 'InviteWitness' request.

func WithProofHandler

func WithProofHandler(handler ProofHandler) HandlerOpt

WithProofHandler sets the proof handler.

func WithUndoFollowHandler

func WithUndoFollowHandler(handler UndoFollowHandler) HandlerOpt

WithUndoFollowHandler sets undo follow handler.

func WithWitness

func WithWitness(handler WitnessHandler) HandlerOpt

WithWitness sets the witness handler.

type Handlers

type Handlers struct {
	AnchorHandler         AnchorHandler
	FollowerAuth          ActorAuth
	WitnessInvitationAuth ActorAuth
	Witness               WitnessHandler
	ProofHandler          ProofHandler
	AnchorAckHandler      AnchorEventAcknowledgementHandler
	AcceptFollowHandler   AcceptFollowHandler
	UndoFollowHandler     UndoFollowHandler
}

Handlers contains handlers for various activity events, including undeliverable activities.

type Inbox

type Inbox interface {
	ServiceLifecycle
}

Inbox defines the functions for an ActivityPub inbox.

type InboxHandler

type InboxHandler interface {
	HandleCreateActivity(source *url.URL, create *vocab.ActivityType, announce bool) error
	HandleAnnounceActivity(source *url.URL, create *vocab.ActivityType) (numProcessed int, err error)
}

InboxHandler defines functions for handling Create and Announce activities.

type Outbox

type Outbox interface {
	ServiceLifecycle

	// Post posts an activity to the outbox and returns the ID of the activity.
	Post(activity *vocab.ActivityType, exclude ...*url.URL) (*url.URL, error)
}

Outbox defines the functions for an ActivityPub outbox.

type ProofHandler

type ProofHandler interface {
	HandleProof(witness *url.URL, anchorID string, endTime time.Time, proof []byte) error
}

ProofHandler handles the given proof for the anchor credential.

type ServiceLifecycle

type ServiceLifecycle interface {
	// Start starts the service.
	Start()
	// Stop stops the service.
	Stop()
	// State returns the state of the service.
	State() lifecycle.State
}

ServiceLifecycle defines the functions of a service lifecycle.

type UndeliverableActivityHandler

type UndeliverableActivityHandler interface {
	HandleUndeliverableActivity(activity *vocab.ActivityType, toURL string)
}

UndeliverableActivityHandler handles undeliverable activities.

type UndoFollowHandler

type UndoFollowHandler interface {
	Undo(actor *url.URL) error
}

UndoFollowHandler reverses follow request.

type WitnessHandler

type WitnessHandler interface {
	Witness(anchorCred []byte) ([]byte, error)
}

WitnessHandler is a handler that witnesses an anchor credential.

Jump to

Keyboard shortcuts

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