safe

package
v0.0.0-...-63c5a8c Latest Latest
Warning

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

Go to latest
Published: Sep 8, 2022 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Backup

func Backup(client backends.Client) error

func NewEmptyNote

func NewEmptyNote(name string) note

func NewSafeDTO

func NewSafeDTO(safeBytes []byte) *safeDTO

NewSafeDTO returns a safeDTO from the bytes provided from a Backend. If we cannot decode the bytes we assume the safe uses a very old, legacy format and provide an OpenPGP Config.

Types

type Account

type Account struct {
	Username   string         `json:"username"`
	Password   string         `json:"password"`
	CreatedOn  int64          `json:"createdOn"`
	ModifiedOn int64          `json:"modifiedOn"`
	History    accountHistory `json:"history,omitempty"`
}

func NewAccount

func NewAccount(username, password string) *Account

func (*Account) SyncWith

func (acc *Account) SyncWith(otherAccount *Account, name string) (bool, error)

func (*Account) Update

func (acc *Account) Update(cb func(*Account))

type Safe

type Safe struct {
	Config *config.Config

	Accounts map[string]Account `json:"accounts"`
	Notes    *notesManager
	// contains filtered or unexported fields
}

Safe holds the structure for defining a Safe object

func Load

func Load(password []byte, backendClient backends.Client, cryptoClient crypto.Client, config *config.Config) (*Safe, error)

Load loads, decrypts, and returns an instantiated Safe. In the case that the Safe configuration has changed, the Safe will be upgraded to the latest configuration and saved.

func New

func New(password []byte, backendClient backends.Client, cryptoClient crypto.Client, config *config.Config, accounts map[string]Account, notes map[string]note) (*Safe, error)

New returns a new, initialized Safe

func (*Safe) Add

func (s *Safe) Add(name, username, password string) (*Account, error)

func (*Safe) ChangePassword

func (s *Safe) ChangePassword(p []byte) error

func (*Safe) Edit

func (s *Safe) Edit(name, username, password string) (*Account, error)

func (*Safe) Get

func (s *Safe) Get(name string) (*Account, error)

func (*Safe) Init

func (s *Safe) Init() error

func (*Safe) List

func (s *Safe) List() map[string]Account

func (*Safe) Move

func (s *Safe) Move(name, newName string) error

func (*Safe) Remove

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

func (*Safe) RequireCompatibilityWith

func (s *Safe) RequireCompatibilityWith(version string) error

RequireCompatibilityWith returns an error if the Safe version is incompatible with the provided version

func (*Safe) SyncWith

func (s *Safe) SyncWith(otherSafe *Safe) error

SyncWith syncs the current safe with another safe if they're branching off the same safe, i.e. are not completely different safes. It simply imports non-existing accounts & notes into the current safe and updates existing accounts & notes if the other safe has a more recent version of an account / note. A backup is made when existing accounts / notes are updated.

Jump to

Keyboard shortcuts

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