spk

package
v0.0.0-...-e2e80d8 Latest Latest
Warning

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

Go to latest
Published: Jan 11, 2023 License: Apache-2.0 Imports: 16 Imported by: 1

Documentation

Index

Constants

View Source
const (
	// Path to the capnp schema that ship with Sandstorm, assuming sandstorm
	// is installed in /opt/sandstorm.
	SandstormCapnpPath = "/opt/sandstorm/latest/usr/include"
)

Variables

View Source
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")
)
View Source
var (
	ErrKeyNotFound  = errors.New("Key not found in keyring")
	ErrMalformedKey = errors.New("Key is malformed")
)

Functions

func PackInto

func PackInto(dest io.Writer, key Key, archive spk.Archive) error

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 (AppId) MarshalBinary

func (id AppId) MarshalBinary() ([]byte, error)

func (AppId) MarshalText

func (id AppId) MarshalText() (text []byte, err error)

func (AppId) String

func (id AppId) String() string

func (*AppId) UnmarshalBinary

func (id *AppId) UnmarshalBinary(data []byte) error

func (*AppId) UnmarshalText

func (id *AppId) UnmarshalText(text []byte) error

type Key

type Key spk.KeyFile

A package signing key

func GenerateKey

func GenerateKey(r io.Reader) (Key, error)

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.

func (Key) AddToFile

func (k Key) AddToFile(path string) error

Add the key to the keyring in the file at `path`, which is created if it does not already exist.

func (Key) AppId

func (k Key) AppId() (AppId, error)

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

func LoadKeyring(filename string) (Keyring, error)

Load the sandstorm keyring from a named file.

func (Keyring) GetKey

func (k Keyring) GetKey(appId AppId) (Key, error)

Get the key for the given app id from the keyring.

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.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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