store

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Aug 13, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package store is the facade over a password store: it binds the on-disk tree to the crypto backends and the secret format.

A store may hold GPG and age entries side by side. The backend for an existing entry follows its file extension; the backend for a new entry follows the store's configured default.

Index

Constants

This section is empty.

Variables

View Source
var ErrExists = errors.New("store: entry already exists")

ErrExists reports a refusal to overwrite an existing entry.

View Source
var ErrNotFound = errors.New("store: entry not found")

ErrNotFound reports that an entry does not exist.

View Source
var ErrNotInitialised = errors.New("store: not initialised")

ErrNotInitialised reports a store with no recipients file at its root.

Functions

This section is empty.

Types

type Match

type Match struct {
	// Name is the entry name.
	Name string
	// Lines are the matching plaintext lines.
	Lines []string
}

Match is one entry containing lines that satisfied a Grep.

type Options

type Options struct {
	// Dir is the store root.
	Dir string
	// Backends are the crypto implementations to support, in lookup order.
	Backends []crypto.Crypto
	// Default is the backend for new entries; it must be one of Backends.
	Default crypto.Crypto
	// Umask masks created file permissions; zero means pass's 077.
	Umask os.FileMode
}

Options configures a Store.

type Store

type Store struct {
	// contains filtered or unexported fields
}

Store is a password store bound to a directory and its crypto backends.

func New

func New(opts Options) (*Store, error)

New returns a Store from opts.

func (*Store) Copy

func (s *Store) Copy(from, to string) error

Copy duplicates an entry or a subfolder, re-encrypting as Move does.

func (*Store) Dir

func (s *Store) Dir() string

Dir returns the store root.

func (*Store) Exists

func (s *Store) Exists(name string) bool

Exists reports whether an entry called name exists.

func (*Store) Find

func (s *Store) Find(terms []string) ([]string, error)

Find returns the names of entries whose path contains any of the terms, case-insensitively.

func (*Store) Get

func (s *Store) Get(name string) (*secret.Secret, error)

Get decrypts the entry called name.

func (*Store) Grep

func (s *Store) Grep(sub string, match func(string) bool) ([]Match, error)

Grep decrypts every entry under sub and reports those whose plaintext satisfies match.

func (*Store) Init

func (s *Store) Init(sub string, rcp []crypto.Recipient) error

Init writes the recipients file for sub (empty for the store root) using the default backend, creating the store directory if needed.

func (*Store) Initialised

func (s *Store) Initialised() bool

Initialised reports whether the store root carries a recipients file for any configured backend.

func (*Store) IsDir

func (s *Store) IsDir(name string) bool

IsDir reports whether name is a subfolder of the store.

func (*Store) List

func (s *Store) List(sub string) ([]string, error)

List returns the entry names under sub, sorted.

func (*Store) Move

func (s *Store) Move(from, to string) error

Move renames an entry or a subfolder. Entries whose recipients change as a result are re-encrypted, since a move into a differently shared subtree would otherwise leave a secret readable by the wrong people.

func (*Store) Recipients

func (s *Store) Recipients(name string) ([]crypto.Recipient, error)

Recipients returns the recipients governing name for its backend.

func (*Store) Reencrypt

func (s *Store) Reencrypt(sub string, to crypto.Crypto) error

Reencrypt rewrites every entry under sub for its current recipients. It is how a recipient change takes effect, and how migration between backends is carried out when to is non-nil.

func (*Store) Remove

func (s *Store) Remove(name string) error

Remove deletes the entry called name.

func (*Store) RemoveDir

func (s *Store) RemoveDir(name string) error

RemoveDir deletes the subfolder called name and everything under it.

func (*Store) Set

func (s *Store) Set(name string, sec *secret.Secret) error

Set encrypts sec and stores it as name, replacing any existing entry. An existing entry keeps its crypto backend, so writing to a .gpg entry never silently converts it to age.

func (*Store) SetNew

func (s *Store) SetNew(name string, sec *secret.Secret) error

SetNew is Set that refuses to overwrite an existing entry.

Jump to

Keyboard shortcuts

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