storage

package
v0.0.0-...-0ebda42 Latest Latest
Warning

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

Go to latest
Published: May 28, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var NoUserId = errors.New("no user id provided")
View Source
var PermissionDenied = errors.New("you dont have permission to do this")

Functions

func Decrypt

func Decrypt(ciphertext []byte) ([]byte, error)

Decrypt data from cyphered format to bytes

func Encrypt

func Encrypt(plain []byte) ([]byte, error)

Encrypt slice of bytes into hashed format using cipher

func InitCrypto

func InitCrypto() error

Types

type Entry

type Entry struct {
	ID        uuid.UUID      `db:"id"`
	UserId    string         `db:"user_id"`
	Title     string         `db:"title"`
	Username  string         `db:"username"`
	Password  []byte         `db:"password"`
	Notes     sql.NullString `db:"notes"`
	Tags      pq.StringArray `db:"tags"`
	Folder    sql.NullString `db:"folder"`
	Domain    sql.NullString `db:"domain"`
	CreatedAt time.Time      `db:"created_at"`
	UpdatedAt time.Time      `db:"updated_at"`
}

type Store

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

func NewStore

func NewStore(db *sqlx.DB) *Store

func (*Store) Create

func (s *Store) Create(ctx context.Context, e *Entry) (sql.Result, error)

func (*Store) Delete

func (s *Store) Delete(ctx context.Context, id uuid.UUID) (bool, error)

func (*Store) Get

func (s *Store) Get(ctx context.Context, id uuid.UUID) (*Entry, error)

func (*Store) List

func (s *Store) List(ctx context.Context, domain string, folder string, tags []string) ([]Entry, error)

type User

type User struct {
	ID        uuid.UUID `db:"id"`
	Email     string    `db:"email"`
	Username  string    `db:"username"`
	Password  []byte    `db:"password"`
	CreatedAt time.Time `db:"created_at"`
	UpdatedAt time.Time `db:"updated_at"`
}

type UserStore

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

func NewUserStore

func NewUserStore(db *sqlx.DB) *UserStore

func (*UserStore) CreateUser

func (s *UserStore) CreateUser(ctx context.Context, e *User) (sql.Result, error)

func (*UserStore) DeleteUser

func (s *UserStore) DeleteUser(ctx context.Context, id uuid.UUID) (bool, error)

func (*UserStore) GetByUsername deprecated

func (s *UserStore) GetByUsername(ctx context.Context, username string) (*User, error)

Deprecated: GetByUsername: should be reworked to use user id instead

Jump to

Keyboard shortcuts

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