storage

package
v1.8.7 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const DefaultTokenLength = 6

DefaultTokenLength defines what is the default length of the generated token. Most services are using 6 characters.

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	Name   string
	Token  string
	Prefix string
	Length uint
}

Account represents a TOTP account.

type BackendError

type BackendError struct {
	Message string
}

BackendError is an error to tell the user something went wrong processing the backend storage.

func (BackendError) Error

func (e BackendError) Error() string

type Namespace

type Namespace struct {
	Name     string
	Accounts []*Account
}

Namespace represents a Namespace "category".

func (*Namespace) DeleteAccount

func (n *Namespace) DeleteAccount(account *Account)

DeleteAccount removes a specific Account from the Namespace.

func (*Namespace) FindAccount

func (n *Namespace) FindAccount(name string) (*Account, error)

FindAccount returns with an account under a specific Namespace if the account does not exist error is not nil.

type NotFoundError

type NotFoundError struct {
	Type string
	Name string
}

NotFoundError is an error to tell the user the requested entity is not there.

func (NotFoundError) Error

func (e NotFoundError) Error() string

type Storage

type Storage struct {
	File     string `json:"-"`
	Password string `json:"-"`

	Namespaces []*Namespace
}

Storage structure represents the credential storage.

func PrepareStorage

func PrepareStorage() (*Storage, error)

PrepareStorage loads, decrypt and parse the Storage. If the storage file does not exist it creates one.

func (*Storage) Decrypt

func (s *Storage) Decrypt() error

Decrypt tries to decrypt the storage.

func (*Storage) DecryptV1 added in v1.3.0

func (s *Storage) DecryptV1() error

DecryptV1 tries to decrypt the original unsecure SHA1 storage.

func (*Storage) DecryptV2 added in v1.3.0

func (s *Storage) DecryptV2() error

DecryptV2 tries to decrypt the newer age storage.

func (*Storage) DeleteNamespace

func (s *Storage) DeleteNamespace(namespace *Namespace)

DeleteNamespace removes a specific namespace from the Storage.

func (*Storage) FindNamespace

func (s *Storage) FindNamespace(name string) (*Namespace, error)

FindNamespace returns with a namespace if the namespace does not exist error is not nil.

func (*Storage) Save

func (s *Storage) Save() error

Save tries to encrypt and save the storage.

Jump to

Keyboard shortcuts

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