capabilities

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Apr 2, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package capabilities defines the public definitions for tlog UCAN capabilities.

Package capabilities defines the public types for tlog UCAN capabilities.

Index

Constants

View Source
const (
	AbilityCreate = "tlog/create"
	AbilityAppend = "tlog/append"
	AbilityRead   = "tlog/read"
	AbilityRevoke = "tlog/revoke" // Changed from tlog/admin/revoke
)

Capability ability constants

Variables

View Source
var (
	// TlogCreate is the capability parser for tlog/create
	TlogCreate = validator.NewCapability(
		AbilityCreate,
		schema.DIDString(),
		schema.Struct[CreateCaveats](createCaveatsType(), nil),
		nil,
	)

	// TlogAppend is the capability parser for tlog/append
	TlogAppend = validator.NewCapability(
		AbilityAppend,
		schema.DIDString(),
		schema.Struct[AppendCaveats](appendCaveatsType(), nil),
		nil,
	)

	// TlogRead is the capability parser for tlog/read
	TlogRead = validator.NewCapability(
		AbilityRead,
		schema.DIDString(),
		schema.Struct[ReadCaveats](readCaveatsType(), nil),
		nil,
	)

	// TlogRevoke is the capability parser for tlog/revoke
	TlogRevoke = validator.NewCapability(
		AbilityRevoke,
		schema.DIDString(),
		schema.Struct[RevokeCaveats](revokeCaveatsType(), nil),
		nil,
	)
)

Capability parsers

Functions

This section is empty.

Types

type AppendCaveats

type AppendCaveats struct {
	// Data is the base64-encoded data to append
	Data string `json:"data"`

	// IndexCID is the expected current head CID for optimistic concurrency (optional)
	IndexCID *string `json:"index_cid,omitempty"`

	// Delegation is the base64-encoded UCAN delegation (required)
	Delegation string `json:"delegation"`
}

AppendCaveats represents the caveats for tlog/append capability

func (AppendCaveats) ToIPLD

func (c AppendCaveats) ToIPLD() (ipld.Node, error)

ToIPLD converts AppendCaveats to an IPLD node

type AppendFailure

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

AppendFailure is the failure result for tlog/append

func NewAppendFailure

func NewAppendFailure(name, message string) AppendFailure

NewAppendFailure creates a new AppendFailure

func (AppendFailure) Error

func (f AppendFailure) Error() string

func (AppendFailure) Name

func (f AppendFailure) Name() string

func (AppendFailure) ToIPLD

func (f AppendFailure) ToIPLD() (ipld.Node, error)

type AppendSuccess

type AppendSuccess struct {
	Index      int64  `json:"index"`
	TreeSize   uint64 `json:"tree_size"`              // New tree size
	Checkpoint string `json:"checkpoint,omitempty"`   // base64-encoded signed checkpoint note
	HeadCID    string `json:"head_cid,omitempty"`     // pre-computed CID of the head CAR
	RevHeadCID string `json:"rev_head_cid,omitempty"` // head CID of the revocations log (empty if no revocations)
}

AppendSuccess is the success result for tlog/append

func (AppendSuccess) ToIPLD

func (s AppendSuccess) ToIPLD() (ipld.Node, error)

ToIPLD converts AppendSuccess to an IPLD node

type CreateCaveats

type CreateCaveats struct {
	// Delegation is the base64-encoded UCAN delegation granting write access to the space
	Delegation string `json:"delegation"`
}

CreateCaveats represents the caveats for tlog/create capability

func (CreateCaveats) ToIPLD

func (c CreateCaveats) ToIPLD() (ipld.Node, error)

ToIPLD converts CreateCaveats to an IPLD node

type CreateFailure

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

CreateFailure is the failure result for tlog/create

func NewCreateFailure

func NewCreateFailure(name, message string) CreateFailure

NewCreateFailure creates a new CreateFailure

func (CreateFailure) Error

func (f CreateFailure) Error() string

func (CreateFailure) Name

func (f CreateFailure) Name() string

func (CreateFailure) ToIPLD

func (f CreateFailure) ToIPLD() (ipld.Node, error)

type CreateSuccess

type CreateSuccess struct {
	LogID    string `json:"logId"`
	IndexCID string `json:"index_cid"` // Initial head CID
	TreeSize uint64 `json:"tree_size"` // Initial tree size (0)
}

CreateSuccess is the success result for tlog/create

func (CreateSuccess) ToIPLD

func (s CreateSuccess) ToIPLD() (ipld.Node, error)

ToIPLD converts CreateSuccess to an IPLD node

type ReadCaveats

type ReadCaveats struct {
	// Offset is the starting index (optional)
	Offset *int64
	// Limit is the maximum number of entries to return (optional)
	Limit *int64
}

ReadCaveats represents the caveats for tlog/read capability

func (ReadCaveats) ToIPLD

func (c ReadCaveats) ToIPLD() (ipld.Node, error)

ToIPLD converts ReadCaveats to an IPLD node

type ReadFailure

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

ReadFailure is the failure result for tlog/read

func NewReadFailure

func NewReadFailure(name, message string) ReadFailure

NewReadFailure creates a new ReadFailure

func (ReadFailure) Error

func (f ReadFailure) Error() string

func (ReadFailure) Name

func (f ReadFailure) Name() string

func (ReadFailure) ToIPLD

func (f ReadFailure) ToIPLD() (ipld.Node, error)

type ReadSuccess

type ReadSuccess struct {
	Entries []string `json:"entries"`
	Total   int64    `json:"total"`
}

ReadSuccess is the success result for tlog/read

func (ReadSuccess) ToIPLD

func (s ReadSuccess) ToIPLD() (ipld.Node, error)

ToIPLD converts ReadSuccess to an IPLD node

type RevokeCaveats

type RevokeCaveats struct {
	// Cid is the CID of the delegation to revoke.
	// The delegation must be stored in the space (uploaded by the client).
	Cid string `json:"cid"`

	// Delegation grants access to the space for fetching the delegation
	// and writing to the revocation log (base64-encoded)
	Delegation string `json:"delegation"`
}

RevokeCaveats represents the caveats for tlog/revoke capability

func (RevokeCaveats) ToIPLD

func (c RevokeCaveats) ToIPLD() (ipld.Node, error)

ToIPLD converts RevokeCaveats to an IPLD node

type RevokeFailure

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

RevokeFailure is the failure result for tlog/revoke

func NewRevokeFailure

func NewRevokeFailure(name, message string) RevokeFailure

NewRevokeFailure creates a new RevokeFailure

func (RevokeFailure) Error

func (f RevokeFailure) Error() string

func (RevokeFailure) Name

func (f RevokeFailure) Name() string

func (RevokeFailure) ToIPLD

func (f RevokeFailure) ToIPLD() (ipld.Node, error)

type RevokeSuccess

type RevokeSuccess struct {
	Revoked bool `json:"revoked"`
}

RevokeSuccess is the success result for tlog/revoke

func (RevokeSuccess) ToIPLD

func (s RevokeSuccess) ToIPLD() (ipld.Node, error)

ToIPLD converts RevokeSuccess to an IPLD node

Jump to

Keyboard shortcuts

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