storage

package
v0.0.0-...-0660248 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2021 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrCreateUser = errors.New("failed to add user to db")

ErrCreateUser throw by db when try to insert user

Functions

func FilePath

func FilePath() (string, error)

FilePath returns path for currently used operating system

func VaultExist

func VaultExist(path string) error

VaultExist check if given vault is present in path

Types

type Storage

type Storage struct {
	Email       string            `json:"type"`
	Passwords   map[string][]byte `json:"passwords"`
	TimeCreated time.Time         `json:"timecreated"`
}

Storage contains user email and - names with password

func Load

func Load(vaultData []byte) (Storage, error)

Load unmarshal json to Storage struct

func New

func New(data map[string]interface{}, creationTime time.Time) (Storage, error)

New creates a new Storage object from passed email adress and current encrypted password in database

func (*Storage) Add

func (s *Storage) Add(name, password string) error

Add adds name and password if name doesn't exist

func (*Storage) Change

func (s *Storage) Change(name, password string)

Change edits password for given name

func (*Storage) Get

func (s *Storage) Get(name string) (string, error)

Get gets password if exist from given name

func (*Storage) Remove

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

Remove remove name and password from password manager

func (*Storage) SyncStorage

func (s *Storage) SyncStorage(password []byte, mdb mongoCli.Database, client *mongo.Client) error

SyncStorage syncs storage to server if user have connection , otherwise it's throw error

Jump to

Keyboard shortcuts

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