paw

package
v0.23.0 Latest Latest
Warning

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

Go to latest
Published: Mar 10, 2024 License: MPL-2.0 Imports: 28 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ENV_HOME    = "PAW_HOME"    // The env var name can be used to override the Paw HOME directory
	ENV_SESSION = "PAW_SESSION" // The env var name can be used to specify a Paw session ID
)
View Source
const (
	RandomPasswordDefaultLength     = 16
	RandomPasswordMinLength         = 8
	RandomPasswordMaxLength         = 120
	RandomPasswordDefaultFormat     = LowercaseFormat | DigitsFormat | SymbolsFormat | UppercaseFormat
	PinPasswordDefaultLength        = 4
	PinPasswordMinLength            = 3
	PinPasswordMaxLength            = 10
	PinPasswordDefaultFormat        = DigitsFormat
	PassphrasePasswordDefaultLength = 4
	PassphrasePasswordMinLength     = 3
	PassphrasePasswordMaxLength     = 12
)
View Source
const (
	TOTPHashDefault     = SHA1
	TOTPDigitsDefault   = otp.DefaultDigits
	TOTPIntervalDefault = otp.DefaultInterval
)
View Source
const (
	ID            = "dev.lucor.paw"
	ServicePrefix = "paw/"
)

Variables

View Source
var (
	// BuildVersion allow to set the version at link time
	BuildVersion string
)
View Source
var (
	ErrCallbackRequired = errors.New("callback required")
)

Functions

func ServiceVersion added in v0.21.0

func ServiceVersion() string

ServiceVersion returns the Paw's service version

func Version

func Version() string

Version returns the Paw's version

Types

type Autofill added in v0.23.0

type Autofill struct {
	*url.URL   `json:"url,omitempty"`
	AllowHTTP  bool              `json:"allow_http,omitempty"`
	MatchType  MatchTypeAutofill `json:"match_type,omitempty"`
	TLDPlusOne string            `json:"tld_plus_one,omitempty"`
}

type ByString

type ByString []*Metadata

ByID implements sort.Interface Metadata on the ID value.

func (ByString) Len

func (s ByString) Len() int

func (ByString) Less

func (s ByString) Less(i, j int) bool

func (ByString) Swap

func (s ByString) Swap(i, j int)

type Config added in v0.19.0

type Config struct {
	TOTP     TOTPConfig     `json:"totp,omitempty"`
	Password PasswordConfig `json:"password,omitempty"`
}

type ConfigStorage added in v0.19.0

type ConfigStorage interface {
	LoadConfig() (*Config, error)
	StoreConfig(s *Config) error
}

type ConfigStorageMock added in v0.23.0

type ConfigStorageMock struct {
	OnLoadConfig  func() (*Config, error)
	OnStoreConfig func(s *Config) error
}

func (*ConfigStorageMock) LoadConfig added in v0.23.0

func (c *ConfigStorageMock) LoadConfig() (*Config, error)

LoadConfig implements ConfigStorage.

func (*ConfigStorageMock) StoreConfig added in v0.23.0

func (c *ConfigStorageMock) StoreConfig(s *Config) error

StoreConfig implements ConfigStorage.

type Favicon added in v0.15.0

type Favicon struct {
	Host string `json:"host,omitempty"`
	Data []byte `json:"data,omitempty"`
}

Favicon represents a login favicon and it is a bundled fyne.resource compiled into the application

func NewFavicon added in v0.15.0

func NewFavicon(host string, data []byte) *Favicon

func (*Favicon) Content added in v0.15.0

func (f *Favicon) Content() []byte

Content returns the bytes of the favicon resource encoded as PNG

func (*Favicon) Name added in v0.15.0

func (f *Favicon) Name() string

Name returns the unique name of this resource, usually matching the host name it was downloaded from.

type Format

type Format int

Format represents the format for a rule

const (
	// LowercaseFormat specify a format with all lowercase chars
	LowercaseFormat Format = 1 << iota
	// LowercaseFormat specify a format with all uppercase chars
	UppercaseFormat
	// DigitsFormat specify a format with all digits chars
	DigitsFormat
	// DigitsFormat specify a format with all symbols chars
	SymbolsFormat
)

type FyneStorage added in v0.18.0

type FyneStorage struct {
	fyne.Storage
}

func (*FyneStorage) CreateVault added in v0.18.0

func (s *FyneStorage) CreateVault(name string, key *Key) (*Vault, error)

CreateVault encrypts and stores an empty vault into the underlying storage.

func (*FyneStorage) CreateVaultKey added in v0.18.0

func (s *FyneStorage) CreateVaultKey(name string, password string) (*Key, error)

CreateVault encrypts and stores an empty vault into the underlying storage.

func (*FyneStorage) DeleteItem added in v0.18.0

func (s *FyneStorage) DeleteItem(vault *Vault, item Item) error

DeleteItem delete the item from the specified vaultName

func (*FyneStorage) DeleteVault added in v0.18.0

func (s *FyneStorage) DeleteVault(name string) error

DeleteVault delete the specified vault

func (*FyneStorage) LoadConfig added in v0.19.0

func (s *FyneStorage) LoadConfig() (*Config, error)

LoadConfig load the configuration from the underlying storage

func (*FyneStorage) LoadItem added in v0.18.0

func (s *FyneStorage) LoadItem(vault *Vault, itemMetadata *Metadata) (Item, error)

LoadItem returns a item from the vault decrypting from the underlying storage

func (*FyneStorage) LoadVault added in v0.18.0

func (s *FyneStorage) LoadVault(name string, key *Key) (*Vault, error)

LoadVault returns a vault decrypting from the underlying storage

func (*FyneStorage) LoadVaultKey added in v0.18.0

func (s *FyneStorage) LoadVaultKey(name string, password string) (*Key, error)

LoadVaultIdentity returns a vault decrypting from the underlying storage

func (*FyneStorage) LockFilePath added in v0.22.0

func (s *FyneStorage) LockFilePath() string

LockFilePath return the lock file path

func (*FyneStorage) LogFilePath added in v0.23.0

func (s *FyneStorage) LogFilePath() string

LogFilePath return the log file path

func (*FyneStorage) Root added in v0.18.0

func (s *FyneStorage) Root() string

func (*FyneStorage) SocketAgentPath added in v0.20.0

func (s *FyneStorage) SocketAgentPath() string

SocketAgentPath return the socket agent path

func (*FyneStorage) StoreConfig added in v0.19.0

func (s *FyneStorage) StoreConfig(config *Config) error

StoreConfig store the configuration into the underlying storage

func (*FyneStorage) StoreItem added in v0.18.0

func (s *FyneStorage) StoreItem(vault *Vault, item Item) error

StoreItem encrypts and encrypts and stores the item into the specified vault

func (*FyneStorage) StoreVault added in v0.18.0

func (s *FyneStorage) StoreVault(vault *Vault) error

StoreVault encrypts and stores the vault into the underlying storage

func (*FyneStorage) Vaults added in v0.18.0

func (s *FyneStorage) Vaults() ([]string, error)

Vaults returns the list of vault names from the storage

type Imported added in v0.12.0

type Imported struct {
	Items []Item
}

func (*Imported) UnmarshalJSON added in v0.12.0

func (i *Imported) UnmarshalJSON(data []byte) error

type Item

type Item interface {
	// ID returns the identity ID
	ID() string

	GetMetadata() *Metadata

	fmt.Stringer
}

Item wraps all methods allow to generate a password with paw

func NewItem added in v0.15.0

func NewItem(name string, itemType ItemType) (Item, error)

type ItemStorage added in v0.15.0

type ItemStorage interface {
	// DeleteItem delete the item from the specified vaultName
	DeleteItem(vault *Vault, item Item) error
	// LoadItem returns a item from the vault decrypting from the underlying storage
	LoadItem(vault *Vault, itemMetadata *Metadata) (Item, error)
	// StoreItem encrypts and encrypts and stores the item into the specified vault
	StoreItem(vault *Vault, item Item) error
}

type ItemStorageMock added in v0.23.0

type ItemStorageMock struct {
	// DeleteItem delete the item from the specified vaultName
	OnDeleteItem func(vault *Vault, item Item) error
	// LoadItem returns a item from the vault decrypting from the underlying storage
	OnLoadItem func(vault *Vault, itemMetadata *Metadata) (Item, error)
	// StoreItem encrypts and encrypts and stores the item into the specified vault
	OnStoreItem func(vault *Vault, item Item) error
}

func (*ItemStorageMock) DeleteItem added in v0.23.0

func (c *ItemStorageMock) DeleteItem(vault *Vault, item Item) error

DeleteItem implements ItemStorage.

func (*ItemStorageMock) LoadItem added in v0.23.0

func (c *ItemStorageMock) LoadItem(vault *Vault, itemMetadata *Metadata) (Item, error)

LoadItem implements ItemStorage.

func (*ItemStorageMock) StoreItem added in v0.23.0

func (c *ItemStorageMock) StoreItem(vault *Vault, item Item) error

StoreItem implements ItemStorage.

type ItemType

type ItemType int

ItemType represents the Item type

const (
	// MetadataItemType is the Metadata Item type
	MetadataItemType ItemType = 1 << iota
	// NoteItemType is the Note Item type
	NoteItemType
	// PasswordItemType is the Password Item type
	PasswordItemType
	// LoginItemType is the Website Item type
	LoginItemType
	// SSHKeyItemType is the SSH Key Item type
	SSHKeyItemType
)

func ItemTypeFromString added in v0.15.0

func ItemTypeFromString(v string) (ItemType, error)

ItemTypeFromString returns the item type from a string

func (ItemType) Label added in v0.22.2

func (it ItemType) Label() string

Label returns the item type label used in the UI

func (ItemType) String

func (it ItemType) String() string

String returns the item type string representation

type Key

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

func LoadKey added in v0.14.0

func LoadKey(password string, r io.Reader) (key *Key, err error)

LoadKey decrypts an age secret key from the reader r using the provided password

func MakeKey added in v0.14.0

func MakeKey(password string, w io.Writer) (key *Key, err error)

MakeKey generates an age secret key. The key is encrypted to w and protect using the provided password

func MakeOneTimeKey added in v0.15.0

func MakeOneTimeKey() (key *Key, err error)

MakeOneTimeKey generates a one time age secret key. The key can be used to generate random passwords

func (*Key) Decrypt

func (k *Key) Decrypt(src io.Reader) (io.Reader, error)

Decrypt decrypts the message

func (*Key) Encrypt

func (k *Key) Encrypt(dst io.Writer) (io.WriteCloser, error)

Encrypt a message

func (*Key) MarshalJSON added in v0.20.0

func (k *Key) MarshalJSON() ([]byte, error)

func (*Key) Passphrase added in v0.15.0

func (k *Key) Passphrase(numWords int) (string, error)

func (*Key) Secret

func (k *Key) Secret(seeder Seeder) (string, error)

Secret derives a secret from the seeder

func (*Key) String

func (k *Key) String() string

func (*Key) UnmarshalJSON added in v0.20.0

func (k *Key) UnmarshalJSON(data []byte) error

type LogStorage added in v0.23.0

type LogStorage interface {
	LogFilePath() string
}

type Login added in v0.13.0

type Login struct {
	*Password `json:"password,omitempty"`
	*TOTP     `json:"totp,omitempty"`
	*Note     `json:"note,omitempty"`
	*Metadata `json:"metadata,omitempty"`

	Username string `json:"username,omitempty"`
	URL      string `json:"url,omitempty"`
}

func NewLogin added in v0.13.0

func NewLogin() *Login

func (*Login) Subtitle added in v0.23.0

func (l *Login) Subtitle() string

Subtitle implements MetadataSubtitler.

type MatchTypeAutofill added in v0.23.0

type MatchTypeAutofill int
const (
	// DisabledAutofill disable the autofill feature
	DisabledAutofill MatchTypeAutofill = 0
	// ExactMatchAutofill match the exact URL along with the path (i.e. https://www.example.com/login but not https://www.example.com/login/1)
	ExactMatchAutofill MatchTypeAutofill = 2
	// DomainMatchAutofill match the domain only (i.e. https://example.com and https://example.com/login)
	DomainMatchAutofill MatchTypeAutofill = 4
	// SubdomainMatchAutofill match the subdomain only (i.e. https://www.example.com/login or https://www.example.com/auth but not https://dev.example.com/login)
	SubdomainMatchAutofill MatchTypeAutofill = 8
)

type Metadata

type Metadata struct {
	// Name reprents the item name
	Name string `json:"name,omitempty"`
	// Subtitle represents the item subtitle
	Subtitle string `json:"subtitle,omitempty"`
	// Type represents the item type
	Type ItemType `json:"type,omitempty"`
	// Modified holds the modification date
	Modified time.Time `json:"modified,omitempty"`
	// Created holds the creation date
	Created time.Time `json:"created,omitempty"`
	// Icon
	Favicon *Favicon `json:"favicon,omitempty"`
	// Autofill
	Autofill *Autofill `json:"autofill,omitempty"`
}

Item represents the basic paw identity

func (*Metadata) GetMetadata

func (m *Metadata) GetMetadata() *Metadata

func (*Metadata) ID

func (m *Metadata) ID() string

func (*Metadata) IsEmpty added in v0.16.0

func (m *Metadata) IsEmpty() bool

func (*Metadata) String

func (m *Metadata) String() string

type MetadataSubtitler added in v0.23.0

type MetadataSubtitler interface {
	Subtitle() string
}

MetadataSubtitler is the interface to implement to provide a subtitle to an item

type Note

type Note struct {
	Value     string `json:"value,omitempty"`
	*Metadata `json:"metadata,omitempty"`
}

func NewNote

func NewNote() *Note

type OSStorage added in v0.15.0

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

func (*OSStorage) CreateVault added in v0.15.0

func (s *OSStorage) CreateVault(name string, key *Key) (*Vault, error)

CreateVault encrypts and stores an empty vault into the underlying storage.

func (*OSStorage) CreateVaultKey added in v0.15.0

func (s *OSStorage) CreateVaultKey(name string, password string) (*Key, error)

CreateVault encrypts and stores an empty vault into the underlying storage.

func (*OSStorage) DeleteItem added in v0.15.0

func (s *OSStorage) DeleteItem(vault *Vault, item Item) error

DeleteItem delete the item from the specified vaultName

func (*OSStorage) DeleteVault added in v0.15.0

func (s *OSStorage) DeleteVault(name string) error

DeleteVault delete the specified vault

func (*OSStorage) LoadConfig added in v0.19.0

func (s *OSStorage) LoadConfig() (*Config, error)

LoadConfig load the configuration from the underlying storage

func (*OSStorage) LoadItem added in v0.15.0

func (s *OSStorage) LoadItem(vault *Vault, itemMetadata *Metadata) (Item, error)

LoadItem returns a item from the vault decrypting from the underlying storage

func (*OSStorage) LoadVault added in v0.15.0

func (s *OSStorage) LoadVault(name string, key *Key) (*Vault, error)

LoadVault returns a vault decrypting from the underlying storage

func (*OSStorage) LoadVaultKey added in v0.15.0

func (s *OSStorage) LoadVaultKey(name string, password string) (*Key, error)

LoadVaultIdentity returns a vault decrypting from the underlying storage

func (*OSStorage) LockFilePath added in v0.22.0

func (s *OSStorage) LockFilePath() string

LockFilePath return the lock file path

func (*OSStorage) LogFilePath added in v0.23.0

func (s *OSStorage) LogFilePath() string

LogFilePath return the log file path

func (*OSStorage) Root added in v0.15.0

func (s *OSStorage) Root() string

func (*OSStorage) SocketAgentPath added in v0.20.0

func (s *OSStorage) SocketAgentPath() string

SocketAgentPath return the socket agent path

func (*OSStorage) StoreConfig added in v0.19.0

func (s *OSStorage) StoreConfig(config *Config) error

StoreConfig store the configuration into the underlying storage

func (*OSStorage) StoreItem added in v0.15.0

func (s *OSStorage) StoreItem(vault *Vault, item Item) error

StoreItem encrypts and encrypts and stores the item into the specified vault

func (*OSStorage) StoreVault added in v0.15.0

func (s *OSStorage) StoreVault(vault *Vault) error

StoreVault encrypts and stores the vault into the underlying storage

func (*OSStorage) Vaults added in v0.15.0

func (s *OSStorage) Vaults() ([]string, error)

Vaults returns the list of vault names from the storage

type PassphrasePasswordConfig added in v0.19.0

type PassphrasePasswordConfig struct {
	DefaultLength int `json:"default_length,omitempty"`
	MaxLength     int `json:"max_length,omitempty"`
	MinLength     int `json:"min_length,omitempty"`
}

type Password

type Password struct {
	Value  string       `json:"value,omitempty"`
	Format Format       `json:"format,omitempty"`
	Length int          `json:"length,omitempty"`
	Mode   PasswordMode `json:"mode,omitempty"`

	*Metadata `json:"metadata,omitempty"`
	*Note     `json:"note,omitempty"`
}

func NewCustomPassword added in v0.15.0

func NewCustomPassword() *Password

func NewPassphrasePassword added in v0.15.0

func NewPassphrasePassword() *Password

func NewPassword

func NewPassword() *Password

func NewPinPassword added in v0.15.0

func NewPinPassword() *Password

func NewRandomPassword added in v0.15.0

func NewRandomPassword() *Password

func (*Password) Info added in v0.11.0

func (p *Password) Info() []byte

func (*Password) Len added in v0.11.0

func (p *Password) Len() int

func (*Password) Pwgen added in v0.15.0

func (p *Password) Pwgen(key *Key) (string, error)

func (*Password) Salt added in v0.11.0

func (p *Password) Salt() []byte

func (*Password) Template added in v0.11.0

func (p *Password) Template() (string, error)

type PasswordConfig added in v0.19.0

type PasswordConfig struct {
	Passphrase PassphrasePasswordConfig `json:"passphrase,omitempty"`
	Pin        PinPasswordConfig        `json:"pin,omitempty"`
	Random     RandomPasswordConfig     `json:"random,omitempty"`
}

type PasswordMode

type PasswordMode uint32
const (
	CustomPassword     PasswordMode = 0
	RandomPassword     PasswordMode = 1
	PassphrasePassword PasswordMode = 2
	PinPassword        PasswordMode = 3
	StatelessPassword  PasswordMode = 4
)

func (PasswordMode) String

func (pm PasswordMode) String() string

type PinPasswordConfig added in v0.19.0

type PinPasswordConfig struct {
	DefaultLength int `json:"default_length,omitempty"`
	MaxLength     int `json:"max_length,omitempty"`
	MinLength     int `json:"min_length,omitempty"`
}

type RandomPasswordConfig added in v0.19.0

type RandomPasswordConfig struct {
	DefaultLength int    `json:"default_length,omitempty"`
	DefaultFormat Format `json:"default_format,omitempty"`
	MaxLength     int    `json:"max_length,omitempty"`
	MinLength     int    `json:"min_length,omitempty"`
}

type Rule

type Rule struct {
	Length int
	Tpl    []byte
	Filter []byte
}

Rule defines the policy for password generation

func NewRule

func NewRule(length int, format Format) (*Rule, error)

NewRule defines a policy for password generation specifying the lenght and the desired format

func (*Rule) Len

func (r *Rule) Len() int

Len returns the desired password length

func (*Rule) Template

func (r *Rule) Template() (string, error)

Encode encodes the password policy as a byte template

func (*Rule) WithFilter

func (r *Rule) WithFilter(filter []byte)

WithFilter filters characters from the password

type Ruler

type Ruler interface {
	Template() (string, error)
	Len() int
}

type SSHKey added in v0.17.0

type SSHKey struct {
	*Metadata `json:"metadata,omitempty"`
	*Note     `json:"note,omitempty"`

	AddToAgent  bool      `json:"add_to_agent,omitempty"`
	Comment     string    `json:"comment,omitempty"`
	Fingerprint string    `json:"fingerprint,omitempty"`
	Passphrase  *Password `json:"passphrase,omitempty"`
	PrivateKey  string    `json:"private_key,omitempty"`
	PublicKey   string    `json:"public_key,omitempty"`
}

func NewSSHKey added in v0.17.0

func NewSSHKey() *SSHKey

func (*SSHKey) Subtitle added in v0.23.0

func (i *SSHKey) Subtitle() string

Subtitle implements MetadataSubtitler.

type SecretMaker

type SecretMaker interface {
	Secret(seeder Seeder) (string, error)
}

type Seeder

type Seeder interface {
	Ruler
	// Salt returns the salt used to generate the secret
	Salt() []byte
	// Info holds the info used to generate the secret
	Info() []byte
}

type Storage added in v0.11.0

type Storage interface {
	Root() string
	ConfigStorage
	VaultStorage
	ItemStorage
	LogStorage
	SocketAgentPath() string
	LockFilePath() string
}

func NewFyneStorage added in v0.18.0

func NewFyneStorage(s fyne.Storage) (Storage, error)

NewFyneStorage returns an Fyne Storage implementation

func NewOSStorage added in v0.15.0

func NewOSStorage() (Storage, error)

NewOSStorage returns an OS Storage implementation rooted at os.UserConfigDir()

func NewOSStorageRooted added in v0.15.0

func NewOSStorageRooted(root string) (Storage, error)

NewOSStorageRooted returns an OS Storage implementation rooted at root

type StorageMock added in v0.23.0

type StorageMock struct {
	ConfigStorageMock
	VaultStorageMock
	ItemStorageMock
	OnSocketAgentPath func() string
}

func (*StorageMock) LockFilePath added in v0.23.0

func (*StorageMock) LockFilePath() string

LockFilePath implements Storage.

func (*StorageMock) LogFilePath added in v0.23.0

func (*StorageMock) LogFilePath() string

LogFilePath implements Storage.

func (*StorageMock) Root added in v0.23.0

func (c *StorageMock) Root() string

Root implements Storage.

func (*StorageMock) SocketAgentPath added in v0.23.0

func (c *StorageMock) SocketAgentPath() string

SocketAgentPath implements Storage.

type TOTP added in v0.10.0

type TOTP struct {
	Digits   int      `json:"digits,omitempty"`
	Hash     TOTPHash `json:"hash,omitempty"`
	Interval int      `json:"interval,omitempty"`
	Secret   string   `json:"secret,omitempty"`
}

func NewDefaultTOTP added in v0.10.0

func NewDefaultTOTP() *TOTP

func (*TOTP) Hasher added in v0.22.0

func (t *TOTP) Hasher() func() hash.Hash

Hasher returns the hash function for the TOTP

type TOTPConfig added in v0.19.0

type TOTPConfig struct {
	Digits   int      `json:"digits,omitempty"`
	Hash     TOTPHash `json:"hash,omitempty"`
	Interval int      `json:"interval,omitempty"`
}

type TOTPHash added in v0.10.0

type TOTPHash string
const (
	SHA1   TOTPHash = "SHA1"
	SHA256 TOTPHash = "SHA256"
	SHA512 TOTPHash = "SHA512"
)

type Vault

type Vault struct {
	Name string
	// Items represents the list of the item IDs available into the vault grouped by ItemType
	ItemMetadata map[ItemType]map[string]*Metadata //map[ItemType]map[<ID>]
	// Version represents the specification version
	Version string
	// Created represents the creation date
	Created time.Time
	// Modified represents the modification date
	Modified time.Time
	// contains filtered or unexported fields
}

func NewVault

func NewVault(key *Key, name string) *Vault

func (*Vault) AddItem added in v0.11.0

func (v *Vault) AddItem(item Item) error

func (*Vault) DeleteItem

func (v *Vault) DeleteItem(item Item)

func (*Vault) FilterItemMetadata added in v0.11.0

func (v *Vault) FilterItemMetadata(opts *VaultFilterOptions) []*Metadata

func (*Vault) HasItem added in v0.11.0

func (v *Vault) HasItem(item Item) bool

func (*Vault) Key

func (v *Vault) Key() *Key

func (*Vault) Range added in v0.14.0

func (v *Vault) Range(f func(id string, meta *Metadata) bool)

Range calls f sequentially for each key and value present in the vault. If f returns false, range stops the iteration.

func (*Vault) Size added in v0.14.0

func (v *Vault) Size() int

Size return the total number of items into the vault

func (*Vault) SizeByType added in v0.14.0

func (v *Vault) SizeByType(itemType ItemType) int

type VaultFilterOptions

type VaultFilterOptions struct {
	Name     string
	ItemType ItemType
}

type VaultStorage added in v0.15.0

type VaultStorage interface {
	// CreateVault encrypts and stores an empty vault into the underlying storage.
	CreateVault(name string, key *Key) (*Vault, error)
	// LoadVaultKey creates and stores a Key used to encrypt and decrypt the vault data
	// The file containing the key is encrypted using the provided password
	CreateVaultKey(name string, password string) (*Key, error)
	// DeleteVault delete the specified vault
	DeleteVault(name string) error
	// LoadVault returns a vault decrypting from the underlying storage
	LoadVault(name string, key *Key) (*Vault, error)
	// LoadVaultKey returns the Key used to encrypt and decrypt the vault data
	LoadVaultKey(name string, password string) (*Key, error)
	// StoreVault encrypts and stores the vault into the underlying storage
	StoreVault(vault *Vault) error
	// Vaults returns the list of vault names from the storage
	Vaults() ([]string, error)
}

type VaultStorageMock added in v0.23.0

type VaultStorageMock struct {
	// CreateVault encrypts and stores an empty vault into the underlying storage.
	OnCreateVault func(name string, key *Key) (*Vault, error)
	// LoadVaultKey creates and stores a Key used to encrypt and decrypt the vault data
	// The file containing the key is encrypted using the provided password
	OnCreateVaultKey func(name string, password string) (*Key, error)
	// DeleteVault delete the specified vault
	OnDeleteVault func(name string) error
	// LoadVault returns a vault decrypting from the underlying storage
	OnLoadVault func(name string, key *Key) (*Vault, error)
	// LoadVaultKey returns the Key used to encrypt and decrypt the vault data
	OnLoadVaultKey func(name string, password string) (*Key, error)
	// StoreVault encrypts and stores the vault into the underlying storage
	OnStoreVault func(vault *Vault) error
	// Vaults returns the list of vault names from the storage
	OnVaults func() ([]string, error)
}

func (*VaultStorageMock) CreateVault added in v0.23.0

func (c *VaultStorageMock) CreateVault(name string, key *Key) (*Vault, error)

CreateVault implements VaultStorage.

func (*VaultStorageMock) CreateVaultKey added in v0.23.0

func (c *VaultStorageMock) CreateVaultKey(name string, password string) (*Key, error)

CreateVaultKey implements VaultStorage.

func (*VaultStorageMock) DeleteVault added in v0.23.0

func (c *VaultStorageMock) DeleteVault(name string) error

DeleteVault implements VaultStorage.

func (*VaultStorageMock) LoadVault added in v0.23.0

func (c *VaultStorageMock) LoadVault(name string, key *Key) (*Vault, error)

LoadVault implements VaultStorage.

func (*VaultStorageMock) LoadVaultKey added in v0.23.0

func (c *VaultStorageMock) LoadVaultKey(name string, password string) (*Key, error)

LoadVaultKey implements VaultStorage.

func (*VaultStorageMock) StoreVault added in v0.23.0

func (c *VaultStorageMock) StoreVault(vault *Vault) error

StoreVault implements VaultStorage.

func (*VaultStorageMock) Vaults added in v0.23.0

func (c *VaultStorageMock) Vaults() ([]string, error)

Vaults implements VaultStorage.

Jump to

Keyboard shortcuts

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