Documentation
¶
Index ¶
- Constants
- Variables
- func ParsePrivateKey(raw string) (ed25519.PrivateKey, error)
- func ParsePublicKey(raw string) (ed25519.PublicKey, error)
- func SignDetached(indexJSON []byte, priv ed25519.PrivateKey) string
- func VerifyDetached(indexJSON []byte, sigRaw []byte, pub ed25519.PublicKey) error
- type CatalogueItem
- type Entry
- type Filter
- type Index
- type Options
- type Service
- func (s *Service) Configured() bool
- func (s *Service) EnforceCachedRevocations(ctx context.Context) error
- func (s *Service) Ingest(ctx context.Context, indexBytes, sigBytes []byte) (Index, error)
- func (s *Service) Refresh(ctx context.Context) (Index, error)
- func (s *Service) Resolve(ctx context.Context, idOrURL string, version string) (plugins.CatalogueArtifact, error)
- func (s *Service) Run(ctx context.Context, interval time.Duration)
- func (s *Service) Search(ctx context.Context, f Filter) []CatalogueItem
- func (s *Service) ServeHTTP(w http.ResponseWriter, r *http.Request)
- type Version
Constants ¶
const DefaultRefreshInterval = 24 * time.Hour
DefaultRefreshInterval is how often the background loop refreshes the signed index.
Variables ¶
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 ¶
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.
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 ¶
ParseEntryYAML parses a single plugin YAML file into an Entry.
func (Entry) FindVersion ¶
FindVersion returns a specific version or the latest when version is empty.
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 ¶
LoadEntriesDir reads all *.yaml / *.yml files in dir and compiles an Index.
func ParseAndVerify ¶
ParseAndVerify verifies index.json against index.json.sig and parses the index.
func ParseIndex ¶
ParseIndex decodes and validates index.json bytes.
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 ¶
New constructs a catalogue service and loads any previously cached index from the database.
func (*Service) Configured ¶
Configured reports whether both an index URL and a public key are set.
func (*Service) EnforceCachedRevocations ¶
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 ¶
Ingest verifies and stores an index and signature directly, then reconciles installed plugins.
func (*Service) Refresh ¶
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 ¶
Run refreshes the catalogue immediately and then on every tick of interval (default 24h) until ctx is cancelled.
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.