pluginstore

package
v8.0.55 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

View Source
const (
	RequestKindRegistry = "registry"
	RequestKindMetadata = "metadata"
	RequestKindArtifact = "artifact"

	AuthTypeNone        = "none"
	AuthTypeBearer      = "bearer"
	AuthTypeBasic       = "basic"
	AuthTypeHeader      = "header"
	AuthTypeGitHubToken = "github-token"
)
View Source
const (
	DefaultRegistryURL = "https://raw.githubusercontent.com/router-for-me/CLIProxyAPI-Plugins-Store/main/registry.json"
	DefaultSourceID    = "official"
	DefaultSourceName  = "Official"
	SchemaVersion      = 1
	SchemaVersionV2    = 2

	InstallTypeGitHubRelease = "github-release"
	InstallTypeDirect        = "direct"
)
View Source
const PluginSyncSchemaVersion = 1

Variables

View Source
var ErrLoadedPluginLocked = errors.New("loaded plugin library cannot be overwritten while the server is running")

ErrLoadedPluginLocked is returned when an install would overwrite a plugin library that is loaded by the running process on Windows.

Functions

func ArchiveName

func ArchiveName(id, version, goos, goarch string) string

func AuthConfigured

func AuthConfigured(auth []AuthConfig, requestURL string, kind string) bool

func ClearResolvedAuthConfigs

func ClearResolvedAuthConfigs(auth []ResolvedAuthConfig)

func GitHubRepositoryParts

func GitHubRepositoryParts(repository string) (string, string, error)

func NormalizePluginLocales added in v8.0.51

func NormalizePluginLocales(locales map[string]PluginLocale) map[string]PluginLocale

func ParseChecksums

func ParseChecksums(data []byte) (map[string]string, error)

func PluginAuthConfigured

func PluginAuthConfigured(source Source, plugin Plugin, auth []AuthConfig) bool

func PluginInstallType

func PluginInstallType(plugin Plugin) string

func ReleaseVersion

func ReleaseVersion(release Release) (string, error)

ReleaseVersion derives the plugin version from the release tag, stripping a leading "v"/"V" and validating the result.

func SelectReleaseAssets

func SelectReleaseAssets(release Release, id, version, goos, goarch string) (ReleaseAsset, ReleaseAsset, error)

func SourceID

func SourceID(registryURL string) string

func SourceName

func SourceName(registryURL string) string

func UpdateAvailable

func UpdateAvailable(installed, latest string) bool

UpdateAvailable reports whether latest should be offered as an upgrade over installed. A leading "v"/"V" is ignored on both sides. Versions are compared numerically when both are dotted release numbers, so an installed version newer than the registry one is not reported as an update; otherwise any difference counts as an update.

func ValidateArtifact

func ValidateArtifact(artifact Artifact) error

func ValidateInstallPlan

func ValidateInstallPlan(plan InstallPlan) error

func ValidatePlugin

func ValidatePlugin(plugin Plugin) error

func ValidatePluginVersions

func ValidatePluginVersions(plugin Plugin) error

func ValidateRegistry

func ValidateRegistry(registry Registry) error

func ValidateResolvedAuthConfig

func ValidateResolvedAuthConfig(item ResolvedAuthConfig) error

func VerifyArtifactChecksum

func VerifyArtifactChecksum(artifact Artifact, data []byte) error

func VerifyChecksum

func VerifyChecksum(name string, data []byte, checksums map[string]string) error

Types

type Artifact

type Artifact struct {
	GOOS   string `yaml:"goos,omitempty" json:"goos,omitempty"`
	GOARCH string `yaml:"goarch,omitempty" json:"goarch,omitempty"`
	URL    string `yaml:"url,omitempty" json:"url,omitempty"`
	SHA256 string `yaml:"sha256,omitempty" json:"sha256,omitempty"`
	Size   int64  `yaml:"size,omitempty" json:"size,omitempty"`
}

func PluginArtifacts

func PluginArtifacts(plugin Plugin) []Artifact

func SelectArtifact

func SelectArtifact(plan InstallPlan, goos string, goarch string) (Artifact, error)

type AuthConfig

type AuthConfig struct {
	Match          string   `yaml:"match,omitempty" json:"match,omitempty"`
	ApplyTo        []string `yaml:"apply-to,omitempty" json:"apply_to,omitempty"`
	Type           string   `yaml:"type,omitempty" json:"type,omitempty"`
	TokenEnv       string   `yaml:"token-env,omitempty" json:"token_env,omitempty"`
	UsernameEnv    string   `yaml:"username-env,omitempty" json:"username_env,omitempty"`
	PasswordEnv    string   `yaml:"password-env,omitempty" json:"password_env,omitempty"`
	HeaderName     string   `yaml:"header-name,omitempty" json:"header_name,omitempty"`
	HeaderValueEnv string   `yaml:"header-value-env,omitempty" json:"header_value_env,omitempty"`
	AllowInsecure  bool     `yaml:"allow-insecure,omitempty" json:"allow_insecure,omitempty"`
}

func NormalizeAuthConfigs

func NormalizeAuthConfigs(auth []AuthConfig) []AuthConfig

type Client

type Client struct {
	HTTPClient HTTPDoer
	// NetworkScope distinguishes request state for different proxy/egress configurations.
	NetworkScope          string
	RateLimiter           *GitHubRateLimiter
	RegistryURL           string
	UserAgent             string
	Auth                  []AuthConfig
	ResolvedAuth          []ResolvedAuthConfig
	ResolvedAuthExpiresAt time.Time
	// contains filtered or unexported fields
}

func (Client) DownloadArtifact

func (c Client) DownloadArtifact(ctx context.Context, artifact Artifact) ([]byte, error)

func (Client) DownloadAsset

func (c Client) DownloadAsset(ctx context.Context, asset ReleaseAsset) ([]byte, error)

func (Client) FetchLatestRelease

func (c Client) FetchLatestRelease(ctx context.Context, plugin Plugin) (Release, error)

FetchLatestRelease returns the latest published release of the plugin's GitHub repository, mirroring the WebUI panel update check.

func (Client) FetchRegistry

func (c Client) FetchRegistry(ctx context.Context) (Registry, error)

func (Client) FetchReleaseByTag

func (c Client) FetchReleaseByTag(ctx context.Context, plugin Plugin, tag string) (Release, error)

FetchReleaseByTag returns a published release by its exact GitHub tag.

func (Client) Install

func (c Client) Install(ctx context.Context, plugin Plugin, options InstallOptions) (InstallResult, error)

func (Client) InstallDirect

func (c Client) InstallDirect(ctx context.Context, plugin Plugin, plan InstallPlan, options InstallOptions) (InstallResult, error)

func (Client) InstallManifest

func (c Client) InstallManifest(ctx context.Context, manifest Manifest, options InstallOptions) (InstallResult, error)

func (Client) InstallVersion

func (c Client) InstallVersion(ctx context.Context, plugin Plugin, releaseTag string, version string, options InstallOptions) (InstallResult, error)

InstallVersion installs a plugin artifact from a fixed release tag/version.

func (Client) LatestReleaseCacheKey

func (c Client) LatestReleaseCacheKey(plugin Plugin) (string, error)

LatestReleaseCacheKey identifies a repository under the effective credentials and network scope, without retaining credential material in the key.

func (Client) PrepareLatestRelease

func (c Client) PrepareLatestRelease(plugin Plugin) (Client, string, error)

PrepareLatestRelease binds the cache identity and initial release request to the same credential snapshot, even when environment values change in a queue.

type GitHubRateLimiter

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

GitHubRateLimiter shares cooldowns across repositories, release metadata and API asset downloads. Its zero value is ready for use. Clients without an explicit limiter share the process-wide default.

type HTTPDoer

type HTTPDoer = httpfetch.Doer

HTTPDoer abstracts the HTTP client used to execute requests.

type InstallOptions

type InstallOptions struct {
	PluginsDir string
	GOOS       string
	GOARCH     string
	// PluginLoaded reports whether the plugin's dynamic library is currently
	// loaded by the running host. Windows installs are rejected only when they
	// would overwrite an existing target file while it returns true.
	PluginLoaded func() bool
	// BeforeWrite runs after the archive has been downloaded and verified, but
	// before an existing target plugin file is replaced.
	BeforeWrite func() error
}

type InstallPlan

type InstallPlan struct {
	Type      string     `yaml:"type,omitempty" json:"type,omitempty"`
	Artifacts []Artifact `yaml:"artifacts,omitempty" json:"artifacts,omitempty"`
}

func NormalizeInstallPlan

func NormalizeInstallPlan(plan InstallPlan) InstallPlan

type InstallResult

type InstallResult struct {
	ID          string `json:"id"`
	Version     string `json:"version"`
	ReleaseTag  string `json:"release_tag,omitempty"`
	InstallType string `json:"install_type,omitempty"`
	Path        string `json:"path"`
	Overwritten bool   `json:"overwritten"`
	Skipped     bool   `json:"skipped"`
}

func InstallArchive

func InstallArchive(archiveData []byte, plugin Plugin, options InstallOptions) (InstallResult, error)

type Manifest

type Manifest struct {
	SchemaVersion int                     `yaml:"schema-version,omitempty" json:"schema_version,omitempty"`
	ID            string                  `yaml:"id,omitempty" json:"id,omitempty"`
	Name          string                  `yaml:"name,omitempty" json:"name,omitempty"`
	Description   string                  `yaml:"description,omitempty" json:"description,omitempty"`
	Author        string                  `yaml:"author,omitempty" json:"author,omitempty"`
	Version       string                  `yaml:"version,omitempty" json:"version,omitempty"`
	ReleaseTag    string                  `yaml:"release-tag,omitempty" json:"release_tag,omitempty"`
	Repository    string                  `yaml:"repository,omitempty" json:"repository,omitempty"`
	Homepage      string                  `yaml:"homepage,omitempty" json:"homepage,omitempty"`
	License       string                  `yaml:"license,omitempty" json:"license,omitempty"`
	Tags          []string                `yaml:"tags,omitempty" json:"tags,omitempty"`
	Locales       map[string]PluginLocale `yaml:"locales,omitempty" json:"locales,omitempty"`
	SourceID      string                  `yaml:"source-id,omitempty" json:"source_id,omitempty"`
	SourceName    string                  `yaml:"source-name,omitempty" json:"source_name,omitempty"`
	SourceURL     string                  `yaml:"source-url,omitempty" json:"source_url,omitempty"`
	Install       InstallPlan             `yaml:"install,omitempty" json:"install,omitempty"`
}

func ManifestFromPlugin

func ManifestFromPlugin(source Source, plugin Plugin) (Manifest, error)

func ManifestFromRelease

func ManifestFromRelease(source Source, plugin Plugin, release Release) (Manifest, error)

func (Manifest) InstallType

func (m Manifest) InstallType() string

func (Manifest) Plugin

func (m Manifest) Plugin() Plugin

func (Manifest) Validate

func (m Manifest) Validate() error

type Platform

type Platform struct {
	GOOS   string `json:"goos"`
	GOARCH string `json:"goarch"`
}

func PluginPlatforms

func PluginPlatforms(plugin Plugin) []Platform

type Plugin

type Plugin struct {
	ID           string                  `json:"id"`
	Name         string                  `json:"name"`
	Description  string                  `json:"description"`
	Author       string                  `json:"author"`
	Version      string                  `json:"version"`
	Versions     []Version               `json:"versions,omitempty"`
	Repository   string                  `json:"repository,omitempty"`
	Homepage     string                  `json:"homepage,omitempty"`
	License      string                  `json:"license,omitempty"`
	Tags         []string                `json:"tags,omitempty"`
	Locales      map[string]PluginLocale `json:"locales,omitempty"`
	Install      InstallPlan             `json:"install,omitempty"`
	AuthRequired bool                    `json:"auth_required,omitempty"`
}

type PluginLocale added in v8.0.51

type PluginLocale struct {
	Name        string   `yaml:"name,omitempty" json:"name,omitempty"`
	Description string   `yaml:"description,omitempty" json:"description,omitempty"`
	Author      string   `yaml:"author,omitempty" json:"author,omitempty"`
	Homepage    string   `yaml:"homepage,omitempty" json:"homepage,omitempty"`
	License     string   `yaml:"license,omitempty" json:"license,omitempty"`
	Tags        []string `yaml:"tags,omitempty" json:"tags,omitempty"`
}

type PluginSyncItem

type PluginSyncItem struct {
	Manifest Manifest             `json:"manifest"`
	Auth     []ResolvedAuthConfig `json:"auth,omitempty"`
}

func (*PluginSyncItem) Clear

func (i *PluginSyncItem) Clear()

type PluginSyncRequest

type PluginSyncRequest struct {
	SchemaVersion     int               `json:"schema_version"`
	GOOS              string            `json:"goos"`
	GOARCH            string            `json:"goarch"`
	InstalledVersions map[string]string `json:"installed_versions,omitempty"`
}

func (*PluginSyncRequest) Clear

func (r *PluginSyncRequest) Clear()

type PluginSyncResponse

type PluginSyncResponse struct {
	SchemaVersion int              `json:"schema_version"`
	ExpiresAt     time.Time        `json:"expires_at"`
	Items         []PluginSyncItem `json:"items"`
}

func (*PluginSyncResponse) Clear

func (r *PluginSyncResponse) Clear()

func (*PluginSyncResponse) Validate

func (r *PluginSyncResponse) Validate(now time.Time) error

type RateLimitError

type RateLimitError struct {
	StatusCode int
	RetryAt    time.Time
}

RateLimitError reports a GitHub API cooldown without exposing response bodies or credentials. RetryAt is also populated for requests blocked locally.

func (*RateLimitError) Error

func (err *RateLimitError) Error() string

func (*RateLimitError) RetryAfterSeconds

func (err *RateLimitError) RetryAfterSeconds(now time.Time) int64

RetryAfterSeconds rounds up so clients never retry before the reset time.

type Registry

type Registry struct {
	SchemaVersion int      `json:"schema_version"`
	Plugins       []Plugin `json:"plugins"`
}

func ParseRegistry

func ParseRegistry(data []byte) (Registry, error)

func (Registry) PluginByID

func (r Registry) PluginByID(id string) (Plugin, bool)

type Release

type Release struct {
	TagName string         `json:"tag_name"`
	Assets  []ReleaseAsset `json:"assets"`
}

type ReleaseAsset

type ReleaseAsset struct {
	APIURL             string `json:"url"`
	Name               string `json:"name"`
	BrowserDownloadURL string `json:"browser_download_url"`
}

type ResolvedAuthConfig

type ResolvedAuthConfig struct {
	Match       string   `yaml:"match,omitempty" json:"match,omitempty"`
	ApplyTo     []string `yaml:"apply-to,omitempty" json:"apply_to,omitempty"`
	Type        string   `yaml:"type,omitempty" json:"type,omitempty"`
	Token       Secret   `yaml:"token,omitempty" json:"token,omitempty"`
	Username    Secret   `yaml:"username,omitempty" json:"username,omitempty"`
	Password    Secret   `yaml:"password,omitempty" json:"password,omitempty"`
	HeaderName  string   `yaml:"header-name,omitempty" json:"header_name,omitempty"`
	HeaderValue Secret   `yaml:"header-value,omitempty" json:"header_value,omitempty"`
}

func ResolvedAuthForRequest

func ResolvedAuthForRequest(auth []ResolvedAuthConfig, requestURL string, kind string) (ResolvedAuthConfig, bool)

func (*ResolvedAuthConfig) Clear

func (c *ResolvedAuthConfig) Clear()

type Secret

type Secret []byte

Secret holds short-lived credential material that can be overwritten after use.

func (*Secret) Clear

func (s *Secret) Clear()

Clear overwrites the secret and releases its backing slice reference.

type Source

type Source struct {
	ID   string `json:"id"`
	Name string `json:"name"`
	URL  string `json:"url"`
}

func DefaultSource

func DefaultSource() Source

func NormalizeSources

func NormalizeSources(registryURLs []string) ([]Source, error)

type Version

type Version struct {
	Version string      `json:"version"`
	Install InstallPlan `json:"install,omitempty"`
}

Jump to

Keyboard shortcuts

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