Documentation
¶
Overview ¶
Package extension reads, verifies, packs and signs node extension packages (format edgeweir-node-extension-v1). The console checks the same rules before it installs a package (apps/console/src/server/lib/extension-package.ts and packages/contract/src/extensions.ts); the node repeats them before it unpacks anything, so that a package never runs on the console's word alone.
Index ¶
- Constants
- Variables
- func Compare(a, b Version) int
- func Pack(files []File) ([]byte, error)
- func SidecarBinary(m *Manifest, goarch string) string
- func Sign(archive []byte, key JWK, iat int64) (string, error)
- func Thumbprint(x string) string
- func ValidListenerMethods(methods []string) bool
- func ValidListenerPort(port int) bool
- type DataLimits
- type Endpoint
- type Field
- type File
- type JWK
- type Listener
- type Manifest
- type Package
- type Payload
- type Range
- type Requires
- type SharedDict
- type Sidecar
- type Version
Constants ¶
const ( ScopeSite = "site" ScopeNode = "node" )
const ( MaxArchiveBytes = 4 << 20 MaxUnpackedBytes = 16 << 20 MaxEntries = 512 MaxFileBytes = 4 << 20 MaxManifestBytes = 64 << 10 MaxPathBytes = 200 // Packages with a sidecar (extension version 1.1). MaxSidecarArchiveBytes = 64 << 20 MaxSidecarUnpackedBytes = 192 << 20 MaxSidecarFileBytes = 96 << 20 )
Limits of a package (docs/reference/extensions.md).
const Format = "edgeweir-node-extension-v1"
Format is the only package format this node reads.
const LuaAPI = 2
LuaAPI is the Lua API version the node provides.
Variables ¶
var ( Hooks = []string{"init", "access", "access_late", "header_filter", "body_filter", "log", "endpoint", "listen"} Capabilities = []string{"verdicts", "request_headers", "request_body", "response_headers", "html_inject", "body_rewrite", "http_client", "timers", "sidecar", "early_hints"} )
Hooks and capabilities (sidecar: Lua API 2).
var SidecarArchs = []string{"linux-amd64", "linux-arm64"}
SidecarArchs are the architectures a sidecar binary may be shipped for (sidecar/<arch>/<binary>).
Functions ¶
func Pack ¶
Pack writes a reproducible package of the files below dir's allowed entries: sorted, mtime 0, uid/gid 0, mode 0644 (directories 0755).
func SidecarBinary ¶
SidecarBinary returns the path of the sidecar binary for this machine's architecture inside an unpacked package ("" without one).
func Thumbprint ¶
Thumbprint is the RFC 7638 JWK thumbprint (the kid).
func ValidListenerMethods ¶ added in v1.8.0
ValidListenerMethods checks the non-empty method set shared by declarations and bindings.
func ValidListenerPort ¶ added in v1.8.0
ValidListenerPort excludes privileged ports and the console's port.
Types ¶
type DataLimits ¶
type DataLimits struct {
MaxBytes int64 `json:"max_bytes"`
MaxItems int `json:"max_items"`
MaxTotalBytes int64 `json:"max_total_bytes"`
}
DataLimits bounds an extension's per-site data items.
type Endpoint ¶
type Endpoint struct {
Path string `json:"path"`
Methods []string `json:"methods"`
MaxBody *int `json:"max_body,omitempty"`
}
Endpoint is served at /.edgeweir/ext/<id>/<path>.
type Field ¶
type Field struct {
Name string `json:"name"`
Type string `json:"type"`
Description json.RawMessage `json:"description,omitempty"`
}
Field is a rule field ext.<id>.<name>.
type File ¶
File is one regular file of a package.
func ReadArchive ¶
ReadArchive parses a package: gzip, then a ustar stream of regular files and directories only.
type JWK ¶
type JWK struct {
Kty string `json:"kty"`
Crv string `json:"crv"`
X string `json:"x"`
D string `json:"d,omitempty"`
}
JWK is an OKP / Ed25519 key; D is set only for private keys.
type Listener ¶ added in v1.8.0
type Listener struct {
Name string `json:"name"`
DefaultPort int `json:"default_port"`
Methods []string `json:"methods"`
MaxBody *int `json:"max_body,omitempty"`
}
Listener is a signed declaration; DefaultPort never opens a listener.
type Manifest ¶
type Manifest struct {
Format string `json:"format"`
ID string `json:"id"`
Version string `json:"version"`
Publisher string `json:"publisher"`
Name map[string]string `json:"name"`
Description map[string]string `json:"description,omitempty"`
License string `json:"license,omitempty"`
Homepage string `json:"homepage,omitempty"`
Requires Requires `json:"requires"`
Scope string `json:"scope,omitempty"`
Hooks []string `json:"hooks"`
Capabilities []string `json:"capabilities,omitempty"`
Config json.RawMessage `json:"config,omitempty"`
Fields []Field `json:"fields,omitempty"`
LogFields []string `json:"log_fields,omitempty"`
Counters []string `json:"counters,omitempty"`
Endpoints []Endpoint `json:"endpoints,omitempty"`
Listeners []Listener `json:"listeners,omitempty"`
// Extension version 1.1 (Lua API 2).
Secret bool `json:"secret,omitempty"`
Sidecar *Sidecar `json:"sidecar,omitempty"`
Data *DataLimits `json:"data,omitempty"`
}
Manifest is manifest.json. Config schemas stay raw: the console validates them; the node only passes configuration through.
func ParseManifest ¶
ParseManifest decodes and validates manifest.json strictly (unknown members are errors).
func ReadManifest ¶
ReadManifest validates the files of a package and returns its manifest.
type Payload ¶
type Payload struct {
Format string `json:"format"`
ID string `json:"id"`
Version string `json:"version"`
Publisher string `json:"publisher"`
SHA256 string `json:"sha256"`
Size int `json:"size"`
IAT int64 `json:"iat"`
}
Payload is the JWS payload of a package signature.
type Range ¶
type Range []comparator
Range is a set of comparators that all have to hold.
func ParseRange ¶
ParseRange parses space-separated comparators (">=1.7.0 <2.0.0").
type Sidecar ¶
type Sidecar struct {
Binary string `json:"binary"`
Args []string `json:"args,omitempty"`
Env map[string]string `json:"env,omitempty"`
MemoryMB int `json:"memory_mb"`
TasksMax int `json:"tasks_max,omitempty"`
CPUPercent int `json:"cpu_percent,omitempty"`
HealthPath string `json:"health_path,omitempty"`
ConnectTimeoutMS int `json:"connect_timeout_ms,omitempty"`
TimeoutS int `json:"timeout_s,omitempty"`
MaxBody *int `json:"max_body,omitempty"`
}
Sidecar is a native helper process the agent runs for the extension.