Documentation ¶
Index ¶
Constants ¶
const ( // Path to the capnp schema that ship with Sandstorm, assuming sandstorm // is installed in /opt/sandstorm. SandstormCapnpPath = "/opt/sandstorm/latest/usr/include" )
Variables ¶
var ( // The base32 alphabet used by Sandstorm for app-ids/public keys. SandstormBase32Encoding = base32.NewEncoding("0123456789acdefghjkmnpqrstuvwxyz"). WithPadding(base32.NoPadding) ErrBadKeyLength = errors.New("invalid app id: wrong length") )
var ( ErrKeyNotFound = errors.New("Key not found in keyring") ErrMalformedKey = errors.New("Key is malformed") ErrVerificationFailed = errors.New("signature verification failed") )
var ( ErrArchiveTooLarge = errors.New("spk archive is too large") ErrNoMagicNumber = errors.New("spk file does not start with magic number") )
Functions ¶
func PackInto ¶
Write an .spk into `dest`, using `archive` as the contents and `key` for signing. The archive must already contain the manifest.
func ReadPackageDefinition ¶
func ReadPackageDefinition(file, variable string, extraPaths []string) (spk.PackageDefinition, error)
Read the package definition from a textual pkgdef on disk. The `capnp` executable must be in PATH.
Parameters:
- file: The schema file to read - variable: the name of the variable in the file defining the package definition. - extraPaths: a list of extra directories to search for capnproto schema.
A typical use of this would be:
ReadPackageDefinition("sandstorm-pkgdef.capnp", "pkgdef", []string{SandstormCapnpPath})
Types ¶
type AppID ¶
type AppID [32]byte
An app id/public key
func VerifySignature ¶
VerifySignature checks the signature for validity, and returns the public key and signed message.
func (AppID) MarshalBinary ¶
func (AppID) MarshalText ¶
func (*AppID) UnmarshalBinary ¶
func (*AppID) UnmarshalText ¶
type ExtractedPackageMetadata ¶
type ExtractedPackageMetadata struct { Dir string // Path where the files were extracted AppID AppID // App ID for the package Hash PackageHash // Hash of the package Manifest spk.Manifest // Manifest stored in the package. }
Results of unpacking an spk
func Unpack ¶
func Unpack(tmpDir string, r io.Reader) (ExtractedPackageMetadata, error)
Unpack reads an spk file from r and unpacks its contents to a newly created directory under tmpDir, after verifying the package's signature. Returns information about the package.
This may create other temporary files under tmpDir, which are deleted before the function returns.
type Key ¶
A package signing key
func GenerateKey ¶
Generate a new signing key. It will be the root object of its own message. The argument is a cryptographic random number generator. Defaults to crypto/rand.Reader if nil.
type Keyring ¶
type Keyring struct {
// contains filtered or unexported fields
}
The contents of a sandstorm keyring, typically stored at ~/.sandstorm-keyring or ~/.sandstorm/sandstorm-keyring.
func LoadKeyring ¶
Load the sandstorm keyring from a named file.
type PackageHash ¶
func (PackageHash) ID ¶
func (ph PackageHash) ID() string
ID returns the package ID based on the hash. This string is used in various places: as a directory name, as part of the package's URL in the app market, and others. The value is the first 128 bits, hex-encoded.
TODO(cleanup): have this return a types.ID[something].
type PkgDefParams ¶
type PkgDefParams struct { AppID AppID Key Key // The capnp schema id for the app's sandstorm-pkgdef.capnp SchemaId uint64 // The keyring in which to save the gerated key. // Defaults to ~/.sandstorm/sandstorm-keyring KeyringPath string // Path to save the package definition. Defaults to // `.sandstorm/sandstorm-pkgdef.capnp`. PkgDefPath string }
Parameters for initializing an application's pkgdef.
func NewApp ¶
func NewApp() (*PkgDefParams, error)
Generate the information needed to initialize a new app.
func (*PkgDefParams) Emit ¶
func (p *PkgDefParams) Emit() error
Emit a pkgdef with the given parameters, and save the app's key to the keyring.