pluginpkg

package
v0.6.18 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 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")
)

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 added in v0.5.0

func (s *FileAssetStore) Close() error

func (*FileAssetStore) DeletePackage

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

func (*FileAssetStore) Durable added in v0.6.0

func (*FileAssetStore) Durable() bool

func (*FileAssetStore) PutOwnedPackage added in v0.5.0

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 added in v0.5.0

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 added in v0.5.0

func (s *MemoryAssetStore) Close() error

func (*MemoryAssetStore) DeletePackage

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

func (*MemoryAssetStore) Durable added in v0.6.0

func (*MemoryAssetStore) Durable() bool

func (*MemoryAssetStore) PutOwnedPackage added in v0.5.0

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 added in v0.5.0

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"`
	PackageHash       string            `json:"package_hash"`
	ManifestHash      string            `json:"manifest_hash"`
	CanonicalManifest string            `json:"canonical_manifest"`
	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 ReadLimits added in v0.5.0

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 added in v0.5.0

func DefaultReadLimits() ReadLimits

func (ReadLimits) WithMaxCompressionRatio added in v0.5.0

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

func (ReadLimits) WithMaxEntryBytes added in v0.5.0

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

func (ReadLimits) WithMaxFiles added in v0.5.0

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

func (ReadLimits) WithMaxPathBytes added in v0.5.0

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

func (ReadLimits) WithMaxUncompressedBytes added in v0.5.0

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