modules

package
v0.134.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: Apache-2.0 Imports: 15 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package modules is the slot for private modules (ADR-076): a signed admin key that names which modules may run, a folder of static files installed from this machine, and the checks that decide whether one is shown.

The slot holds no module. A module is somebody's own code, installed by them from a local folder; the public build carries only the way to verify a key and host what it names, so patching the check out unlocks nothing.

Index

Constants

View Source
const (
	ManifestFile = "module.json"
	Entry        = "index.html"
)

ManifestFile names a module and sits at the top of its folder, beside the Entry page the screen hosts.

View Source
const KeyPrefix = "CRA1."

KeyPrefix starts every admin key: CRA1.<payload>.<sig>, where payload is base64url of the claims' JSON and sig is base64url of an Ed25519 signature over the ASCII bytes of the payload part.

View Source
const PublicKey = "M6U1zOTAnYbdEaukyaZUQ1VGOfZPdQT+Ol0OCACP504="

PublicKey is the raw Ed25519 key admin keys are verified with. Its private half never touches this repository.

Variables

This section is empty.

Functions

func LooksLikeKey

func LooksLikeKey(s string) bool

LooksLikeKey reports whether s is meant as an admin key, so a field that takes both kinds of key can send it the right way.

func Remove

func Remove(root, id string) error

Remove deletes an installed module's files. Its documents stay in the database, so installing it again finds them.

func Root

func Root(dataDir string) string

Root is where installed modules live inside Caprock's data directory.

func ValidID

func ValidID(id string) bool

ValidID reports whether id can name a module: lower-case letters, digits and dashes, a letter first, at most 32. It is a path segment in a URL and a folder name, so nothing that could mean anything else is allowed.

Types

type Grant

type Grant struct {
	Subject  string   `json:"subject"`
	Modules  []string `json:"modules"`
	IssuedAt string   `json:"issued_at,omitempty"`
}

Grant is what a verified admin key allows: who it was issued to and which modules may be installed and opened.

func ParseKey

func ParseKey(key string) (Grant, error)

ParseKey verifies an admin key against the embedded public key.

func ParseKeyWith

func ParseKeyWith(key string, pub ed25519.PublicKey) (Grant, error)

ParseKeyWith verifies an admin key against pub: the embedded key in the build, a key pair of their own in tests.

func (Grant) Allows

func (g Grant) Allows(id string) bool

Allows reports whether the key names module id.

type Manifest

type Manifest struct {
	ID      string `json:"id"`
	Name    string `json:"name"`
	Version string `json:"version,omitempty"`
}

Manifest is module.json.

func Find

func Find(root, id string) (Manifest, string, bool)

Find returns the installed module id, if it is installed.

func Install

func Install(src, root string, g Grant) (Manifest, error)

Install copies the built module in src into root/<id>, replacing an older copy whole. The key must name the module: it decides who may install one. Only regular files and folders are copied; a link is refused, so nothing outside the module's folder is ever served as part of it.

func Installed

func Installed(root string) []Manifest

Installed returns the modules installed under root, by id. A folder whose manifest is missing, unreadable or names another id is not a module.

func ReadManifest

func ReadManifest(dir string) (Manifest, error)

ReadManifest reads and checks the module in dir.

Jump to

Keyboard shortcuts

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