pluginpkg

package
v2.0.7 Latest Latest
Warning

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

Go to latest
Published: Aug 16, 2026 License: MIT Imports: 38 Imported by: 0

Documentation

Index

Constants

View Source
const OpaqueSurfaceDocumentSchemaVersion = "redevplugin.opaque_surface_document.v3"
View Source
const PackageSignatureAlgorithmEd25519 = "ed25519"
View Source
const PackageSignaturePath = "signatures/package.sig"
View Source
const PackageSignatureSchemaVersion = "redevplugin.package_signature.v1"

Variables

View Source
var (
	ErrPackageAssetNotFound = errors.New("package asset not found")
	ErrInvalidAssetPath     = errors.New("package asset path is invalid")
	ErrAssetStoreClosed     = errors.New("package asset store is closed")
)
View Source
var ErrPresentationIconUnavailable = errors.New("presentation icon is unavailable")

Functions

func WritePackage

func WritePackage(ctx context.Context, w io.Writer, pkg Package) error

Types

type Asset

type Asset struct {
	Entry   Entry  `json:"entry"`
	Content []byte `json:"-"`
}

type AssetStore

type AssetStore interface {
	Durable() bool
	// PutOwnedPackage takes ownership of pkg.Files and pkg.SignatureFiles when
	// the call begins, including when the operation returns an error. Callers
	// must not retain aliases to transferred byte slices.
	PutOwnedPackage(ctx context.Context, pkg *Package) error
	ReadPackageMetadata(ctx context.Context, packageHash string) ([]Entry, error)
	ReadAsset(ctx context.Context, packageHash string, assetPath string) (Asset, error)
	DeletePackage(ctx context.Context, packageHash string) error
	Close() error
}

type Entry

type Entry struct {
	Path        string `json:"path"`
	Size        int64  `json:"size"`
	SHA256      string `json:"sha256"`
	Mode        string `json:"mode"`
	ContentType string `json:"content_type,omitempty"`
}

type FileAssetStore

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

func NewFileAssetStore

func NewFileAssetStore(root string) (*FileAssetStore, error)

func (*FileAssetStore) Close

func (s *FileAssetStore) Close() error

func (*FileAssetStore) DeletePackage

func (s *FileAssetStore) DeletePackage(_ context.Context, packageHash string) error

func (*FileAssetStore) Durable

func (*FileAssetStore) Durable() bool

func (*FileAssetStore) PutOwnedPackage

func (s *FileAssetStore) PutOwnedPackage(ctx context.Context, pkg *Package) error

func (*FileAssetStore) ReadAsset

func (s *FileAssetStore) ReadAsset(ctx context.Context, packageHash string, assetPath string) (Asset, error)

func (*FileAssetStore) ReadPackageMetadata

func (s *FileAssetStore) ReadPackageMetadata(ctx context.Context, packageHash string) ([]Entry, error)

type MemoryAssetStore

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

func NewMemoryAssetStore

func NewMemoryAssetStore() *MemoryAssetStore

func (*MemoryAssetStore) Close

func (s *MemoryAssetStore) Close() error

func (*MemoryAssetStore) DeletePackage

func (s *MemoryAssetStore) DeletePackage(_ context.Context, packageHash string) error

func (*MemoryAssetStore) Durable

func (*MemoryAssetStore) Durable() bool

func (*MemoryAssetStore) PutOwnedPackage

func (s *MemoryAssetStore) PutOwnedPackage(_ context.Context, pkg *Package) error

func (*MemoryAssetStore) ReadAsset

func (s *MemoryAssetStore) ReadAsset(_ context.Context, packageHash string, assetPath string) (Asset, error)

func (*MemoryAssetStore) ReadPackageMetadata

func (s *MemoryAssetStore) ReadPackageMetadata(_ context.Context, packageHash string) ([]Entry, error)

type OpaqueSurfaceAsset

type OpaqueSurfaceAsset struct {
	BindingID   string   `json:"binding_id"`
	LogicalIDs  []string `json:"logical_ids"`
	Path        string   `json:"path"`
	SHA256      string   `json:"sha256"`
	Size        int64    `json:"size"`
	ContentType string   `json:"content_type"`
}

type OpaqueSurfaceAssetReader

type OpaqueSurfaceAssetReader func(assetPath string) (Asset, error)

type OpaqueSurfaceDocument

type OpaqueSurfaceDocument struct {
	SchemaVersion string               `json:"schema_version"`
	EntryPath     string               `json:"entry_path"`
	EntrySHA256   string               `json:"entry_sha256"`
	Title         string               `json:"title,omitempty"`
	Language      string               `json:"language,omitempty"`
	Direction     string               `json:"direction,omitempty"`
	BodyHTML      string               `json:"body_html"`
	Styles        []OpaqueSurfaceStyle `json:"styles"`
	Worker        OpaqueSurfaceWorker  `json:"worker"`
	Assets        []OpaqueSurfaceAsset `json:"assets"`
	CriticalBytes int64                `json:"critical_bytes"`
}

func BuildOpaqueSurfaceDocument

func BuildOpaqueSurfaceDocument(entryPath string, readAsset OpaqueSurfaceAssetReader) (OpaqueSurfaceDocument, error)

type OpaqueSurfaceStyle

type OpaqueSurfaceStyle struct {
	Path    string `json:"path"`
	SHA256  string `json:"sha256"`
	Content string `json:"content"`
}

type OpaqueSurfaceWorker

type OpaqueSurfaceWorker struct {
	Path    string                  `json:"path"`
	SHA256  string                  `json:"sha256"`
	Type    OpaqueSurfaceWorkerType `json:"type"`
	Content string                  `json:"content"`
}

type OpaqueSurfaceWorkerType

type OpaqueSurfaceWorkerType string
const OpaqueSurfaceWorkerClassic OpaqueSurfaceWorkerType = "classic"

type Package

type Package struct {
	Manifest               manifest.Manifest `json:"manifest"`
	ManifestModel          manifest.Model    `json:"-"`
	ManifestSource         string            `json:"manifest_source,omitempty"`
	PackageHash            string            `json:"package_hash"`
	ManifestHash           string            `json:"manifest_hash"`
	CanonicalManifest      string            `json:"canonical_manifest"`
	CanonicalManifestBytes []byte            `json:"-"`
	Entries                []Entry           `json:"entries"`
	EntriesHash            string            `json:"entries_hash"`
	PackageSignature       *PackageSignature `json:"package_signature,omitempty"`
	// Files and SignatureFiles are owned materialized bytes. Borrowing APIs do
	// not mutate them; AssetStore.PutOwnedPackage transfers and clears them.
	Files          map[string][]byte `json:"-"`
	SignatureFiles map[string][]byte `json:"-"`
}

func BuildFromDir

func BuildFromDir(ctx context.Context, srcDir string, w io.Writer, limits ReadLimits) (Package, error)

func Read

func Read(ctx context.Context, r io.ReaderAt, size int64, limits ReadLimits) (Package, error)

func ReadFile

func ReadFile(ctx context.Context, filename string, limits ReadLimits) (Package, error)

type PackageSignature

type PackageSignature struct {
	SchemaVersion string `json:"schema_version"`
	Algorithm     string `json:"algorithm"`
	KeyID         string `json:"key_id"`
	PublisherID   string `json:"publisher_id,omitempty"`
	PluginID      string `json:"plugin_id,omitempty"`
	PackageHash   string `json:"package_hash"`
	ManifestHash  string `json:"manifest_hash"`
	EntriesHash   string `json:"entries_hash"`
	Signature     string `json:"signature"`
	SignedAt      string `json:"signed_at,omitempty"`
}

type PresentationIconAsset

type PresentationIconAsset struct {
	Path      string `json:"path"`
	MediaType string `json:"media_type"`
	Width     int    `json:"width"`
	Height    int    `json:"height"`
	SHA256    string `json:"sha256"`
	Size      int64  `json:"size"`
}

PresentationIconAsset is the Host-validated descriptor for the package-local image declared by presentation.icon. The content is returned separately so callers cannot confuse a descriptor with unverified package bytes.

func ReadPresentationIcon

func ReadPresentationIcon(pkg Package) (PresentationIconAsset, []byte, error)

ReadPresentationIcon returns a cloned raster image only after reapplying the package-local path, format, size, and dimensions checks used at package read.

type ReadLimits

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

ReadLimits is an immutable set of resource limits for package archives.

Limits deliberately have no zero-value semantics: callers must start with DefaultReadLimits and use a validated With... method. This prevents a missing option from silently disabling ZIP decompression guards.

func DefaultReadLimits

func DefaultReadLimits() ReadLimits

func (ReadLimits) WithMaxCompressionRatio

func (l ReadLimits) WithMaxCompressionRatio(value int64) (ReadLimits, error)

func (ReadLimits) WithMaxEntryBytes

func (l ReadLimits) WithMaxEntryBytes(value int64) (ReadLimits, error)

func (ReadLimits) WithMaxFiles

func (l ReadLimits) WithMaxFiles(value int) (ReadLimits, error)

func (ReadLimits) WithMaxPathBytes

func (l ReadLimits) WithMaxPathBytes(value int) (ReadLimits, error)

func (ReadLimits) WithMaxUncompressedBytes

func (l ReadLimits) WithMaxUncompressedBytes(value int64) (ReadLimits, error)

type ValidationError

type ValidationError struct {
	Code    ValidationErrorCode
	Reason  string
	Path    string
	Pointer string
	Message string
	Cause   error
}

func (*ValidationError) Details

func (e *ValidationError) Details() map[string]any

func (*ValidationError) Error

func (e *ValidationError) Error() string

func (*ValidationError) Unwrap

func (e *ValidationError) Unwrap() error

type ValidationErrorCode

type ValidationErrorCode string
const (
	ValidationCodeManifestInvalid      ValidationErrorCode = "PLUGIN_MANIFEST_INVALID"
	ValidationCodePackageInvalid       ValidationErrorCode = "PLUGIN_PACKAGE_INVALID"
	ValidationCodePackageTooLarge      ValidationErrorCode = "PLUGIN_PACKAGE_TOO_LARGE"
	ValidationCodePackagePathForbidden ValidationErrorCode = "PLUGIN_PACKAGE_PATH_FORBIDDEN"
)

Jump to

Keyboard shortcuts

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