Help us shape the future of Go! Take the 2026 Go Developer Survey

pluginpkg

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2026 License: MIT Imports: 27 Imported by: 0

Documentation

Index

Constants

View Source
const OpaqueSurfaceDocumentSchemaVersion = "redevplugin.opaque_surface_document.v1"
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")
)

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 {
	PutPackage(ctx context.Context, pkg Package) error
	ReadAsset(ctx context.Context, packageHash string, assetPath string) (Asset, error)
	DeletePackage(ctx context.Context, packageHash string) 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) DeletePackage

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

func (*FileAssetStore) PutPackage

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

func (*FileAssetStore) ReadAsset

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

type MemoryAssetStore

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

func NewMemoryAssetStore

func NewMemoryAssetStore() *MemoryAssetStore

func (*MemoryAssetStore) DeletePackage

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

func (*MemoryAssetStore) PutPackage

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

func (*MemoryAssetStore) ReadAsset

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

type OpaqueSurfaceAsset

type OpaqueSurfaceAsset struct {
	BindingID   string `json:"binding_id"`
	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             map[string][]byte `json:"-"`
	SignatureFiles    map[string][]byte `json:"-"`
}

func BuildFromDir

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

func Read

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

func ReadFile

func ReadFile(ctx context.Context, filename string, opts ReadOptions) (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 ReadOptions

type ReadOptions struct {
	MaxUncompressedBytes int64 `json:"max_uncompressed_bytes"`
	MaxFiles             int   `json:"max_files"`
	MaxEntryBytes        int64 `json:"max_entry_bytes"`
	MaxPathBytes         int   `json:"max_path_bytes"`
	MaxCompressionRatio  int64 `json:"max_compression_ratio"`
}

func DefaultReadOptions

func DefaultReadOptions() ReadOptions

type Reader

type Reader interface {
	ReadPackage(ctx context.Context, r io.Reader, opts ReadOptions) (Package, 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"
)

type Writer

type Writer interface {
	WritePackage(ctx context.Context, w io.Writer, pkg Package) error
}

Jump to

Keyboard shortcuts

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