catalogue

package
v0.3.3 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: GPL-3.0 Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultRefreshInterval = 24 * time.Hour

DefaultRefreshInterval is how often the background loop refreshes the signed index.

Variables

View Source
var ErrSignatureInvalid = errors.New("catalogue: index signature verification failed")

ErrSignatureInvalid is returned when index.json.sig does not verify against index.json and the configured ed25519 public key.

Functions

func ParsePrivateKey

func ParsePrivateKey(raw string) (ed25519.PrivateKey, error)

ParsePrivateKey decodes an ed25519 private key (32-byte seed or 64-byte key) from base64 or hex.

func ParsePublicKey

func ParsePublicKey(raw string) (ed25519.PublicKey, error)

ParsePublicKey decodes an ed25519 public key from base64 (standard or raw) or hex.

func SignDetached

func SignDetached(indexJSON []byte, priv ed25519.PrivateKey) string

SignDetached signs indexJSON with priv and returns the base64-encoded detached signature suitable for index.json.sig.

func VerifyDetached

func VerifyDetached(indexJSON []byte, sigRaw []byte, pub ed25519.PublicKey) error

VerifyDetached verifies a detached signature (base64 or hex) over indexJSON.

Types

type CatalogueItem

type CatalogueItem struct {
	Entry
	LatestVersion    string   `json:"latestVersion,omitempty"`
	ArtifactURL      string   `json:"artifactUrl,omitempty"`
	SHA256           string   `json:"sha256,omitempty"`
	PermissionLines  []string `json:"permissionLines,omitempty"`
	Installed        bool     `json:"installed"`
	InstalledVersion string   `json:"installedVersion,omitempty"`
	UpdateAvailable  bool     `json:"updateAvailable,omitempty"`
}

CatalogueItem is one entry decorated with its latest version and install status for the console's GET /api/plugins/catalogue response.

type Entry

type Entry struct {
	ID           string              `json:"id" yaml:"id"`
	Name         string              `json:"name" yaml:"name"`
	Summary      string              `json:"summary" yaml:"summary"`
	Description  string              `json:"description,omitempty" yaml:"description,omitempty"`
	Kind         string              `json:"kind" yaml:"kind"`
	Category     string              `json:"category,omitempty" yaml:"category,omitempty"`
	Icon         string              `json:"icon,omitempty" yaml:"icon,omitempty"`
	Repo         string              `json:"repo,omitempty" yaml:"repo,omitempty"`
	Homepage     string              `json:"homepage,omitempty" yaml:"homepage,omitempty"`
	Author       string              `json:"author,omitempty" yaml:"author,omitempty"`
	License      string              `json:"license,omitempty" yaml:"license,omitempty"`
	Capabilities []string            `json:"capabilities,omitempty" yaml:"capabilities,omitempty"`
	Permissions  plugins.Permissions `json:"permissions,omitempty" yaml:"permissions,omitempty"`
	Screenshots  []string            `json:"screenshots,omitempty" yaml:"screenshots,omitempty"`
	Versions     []Version           `json:"versions" yaml:"versions"`
	Revoked      bool                `json:"revoked,omitempty" yaml:"revoked,omitempty"`
	Reason       string              `json:"reason,omitempty" yaml:"reason,omitempty"`
}

Entry is one reviewed plugin in the catalogue.

func ParseEntryYAML

func ParseEntryYAML(data []byte) (Entry, error)

ParseEntryYAML parses a single plugin YAML file into an Entry.

func (Entry) FindVersion

func (e Entry) FindVersion(version string) (Version, bool)

FindVersion returns a specific version or the latest when version is empty.

func (Entry) Latest

func (e Entry) Latest() (Version, bool)

Latest returns the highest semantic version for the entry, or the first version when none exist.

func (Entry) Validate

func (e Entry) Validate() error

Validate checks a single catalogue entry.

type Filter

type Filter struct {
	Query          string
	Kind           string
	Category       string
	Capability     string
	IncludeRevoked bool
}

Filter controls search and filtering over catalogue entries.

type Index

type Index struct {
	Schema      int     `json:"schema" yaml:"schema"`
	GeneratedAt string  `json:"generatedAt,omitempty" yaml:"generatedAt,omitempty"`
	Entries     []Entry `json:"entries" yaml:"entries"`
}

Index is the signed catalogue index (index.json).

func LoadEntriesDir

func LoadEntriesDir(dir string) (Index, error)

LoadEntriesDir reads all *.yaml / *.yml files in dir and compiles an Index.

func ParseAndVerify

func ParseAndVerify(indexJSON, sigRaw []byte, pub ed25519.PublicKey) (Index, error)

ParseAndVerify verifies index.json against index.json.sig and parses the index.

func ParseIndex

func ParseIndex(indexJSON []byte) (Index, error)

ParseIndex decodes and validates index.json bytes.

func (Index) Validate

func (idx Index) Validate() error

Validate checks structural and copy rules on the index.

type Options

type Options struct {
	DB        *sql.DB
	Manager   *plugins.Manager
	IndexURL  string
	PublicKey string
	Client    *http.Client
	Log       *slog.Logger
	Now       func() time.Time
}

Options configures the signed plugin catalogue service.

type Service

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

Service fetches, verifies, caches, and serves the signed plugin catalogue, and reconciles installed plugins for revocations and auto-updates.

func New

func New(opts Options) (*Service, error)

New constructs a catalogue service and loads any previously cached index from the database.

func (*Service) Configured

func (s *Service) Configured() bool

Configured reports whether both an index URL and a public key are set.

func (*Service) EnforceCachedRevocations

func (s *Service) EnforceCachedRevocations(ctx context.Context) error

EnforceCachedRevocations applies the last verified index before plugins start. This also closes the gap if Ether stopped after caching an index but before its revocations were applied.

func (*Service) Ingest

func (s *Service) Ingest(ctx context.Context, indexBytes, sigBytes []byte) (Index, error)

Ingest verifies and stores an index and signature directly, then reconciles installed plugins.

func (*Service) Refresh

func (s *Service) Refresh(ctx context.Context) (Index, error)

Refresh fetches index.json and index.json.sig, verifies the detached ed25519 signature, caches the index in the database, and reconciles installed plugins (revocations and auto-updates).

func (*Service) Resolve

func (s *Service) Resolve(ctx context.Context, idOrURL string, version string) (plugins.CatalogueArtifact, error)

Resolve implements plugins.Catalogue.

func (*Service) Run

func (s *Service) Run(ctx context.Context, interval time.Duration)

Run refreshes the catalogue immediately and then on every tick of interval (default 24h) until ctx is cancelled.

func (*Service) Search

func (s *Service) Search(ctx context.Context, f Filter) []CatalogueItem

Search returns entries matching Filter.

func (*Service) ServeHTTP

func (s *Service) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP serves GET /api/plugins/catalogue and POST /api/plugins/catalogue/refresh.

type Version

type Version struct {
	Version     string               `json:"version" yaml:"version"`
	URL         string               `json:"url" yaml:"url"`
	SHA256      string               `json:"sha256" yaml:"sha256"`
	ReleasedAt  string               `json:"releasedAt,omitempty" yaml:"releasedAt,omitempty"`
	MinEther    string               `json:"minEther,omitempty" yaml:"minEther,omitempty"`
	Permissions *plugins.Permissions `json:"permissions,omitempty" yaml:"permissions,omitempty"`
}

Version is a published artifact version of a catalogue entry.

Jump to

Keyboard shortcuts

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