capability

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jun 16, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Capabilities

type Capabilities struct {
	HTTP      []string        `toml:"http"`
	Database  []string        `toml:"database"`
	RateLimit RateLimitConfig `toml:"rate_limit"`
}

Capabilities defines what a plugin is allowed to do. Mirrors the [capabilities] TOML section in a manifest file.

type Manifest

type Manifest struct {
	Name         string       `toml:"name"`
	Version      string       `toml:"version"`
	MaxMemoryMB  int          `toml:"max_memory_mb"`
	Capabilities Capabilities `toml:"capabilities"`
}

Manifest represents a plugin's capability declaration. Placed alongside the .wasm file as <name>.manifest.

func LoadManifest

func LoadManifest(path string) (*Manifest, error)

LoadManifest reads a TOML capability manifest from the given path. Returns nil, nil if the file does not exist (missing manifest = no capabilities).

func (Manifest) HasDBPermission

func (m Manifest) HasDBPermission(perm string) bool

HasDBPermission checks whether the manifest allows a specific db permission.

func (Manifest) HasDatabase

func (m Manifest) HasDatabase() bool

HasDatabase reports whether the manifest declares any database permissions.

func (Manifest) HasHTTP

func (m Manifest) HasHTTP() bool

HasHTTP reports whether the manifest declares any HTTP URL patterns.

func (Manifest) IsHTTPURLAllowed

func (m Manifest) IsHTTPURLAllowed(url string) bool

IsHTTPURLAllowed checks whether url is covered by any declared HTTP pattern. Uses simple prefix matching.

func (Manifest) Validate

func (m Manifest) Validate() error

Validate checks that the manifest has required fields and valid permissions.

type RateLimitConfig

type RateLimitConfig struct {
	RequestsPerMinute int `toml:"requests_per_minute"`
}

RateLimitConfig controls how often a plugin can call host functions.

Jump to

Keyboard shortcuts

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