dao

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2017 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	DB     *buntdb.DB
	DBSalt = make([]byte, 64)
)

Functions

func DBError added in v0.2.0

func DBError(err error) error

DBError ...

func EntryIDFromKey added in v0.2.0

func EntryIDFromKey(key string) uuid.UUID

EntryIDFromKey returns entry' ID from key

func EntryKey

func EntryKey(id string) string

EntryKey returns the entry's db key

func InitIndex

func InitIndex()

InitIndex ...

func Open

func Open(path string) error

Open open db

func SecretKey

func SecretKey(id string) string

SecretKey returns the secret's db key

func ShareIDFromKey added in v0.2.0

func ShareIDFromKey(key string) uuid.UUID

ShareIDFromKey returns share' ID from key

func ShareKey

func ShareKey(id string) string

ShareKey returns the share's db key

func TeamIDFromKey added in v0.2.0

func TeamIDFromKey(key string) uuid.UUID

TeamIDFromKey returns team' ID from key

func TeamKey

func TeamKey(id string) string

TeamKey returns the team's db key

func UserKey

func UserKey(name string) string

UserKey returns the user's db key

Types

type Entry

type Entry struct {
	OwnerID   string    `json:"ownerId"`
	OwnerType string    `json:"ownerType"`
	Name      string    `json:"name"`
	Category  string    `json:"category"`
	Priority  int       `json:"priority"`
	Secrets   []string  `json:"secrets"`
	Shares    []string  `json:"shares"`
	IsDeleted bool      `json:"isDeleted"`
	Created   time.Time `json:"created"`
	Updated   time.Time `json:"updated"`
}

Entry represents entry info

func EntryFrom

func EntryFrom(str string) (*Entry, error)

EntryFrom parse JSON string and returns a Entry intance.

func (*Entry) HasSecret added in v0.2.0

func (e *Entry) HasSecret(secretID string) bool

HasSecret returns whether the secret is in the Entry.Secrets

func (*Entry) RemoveSecret added in v0.2.0

func (e *Entry) RemoveSecret(secretID string) bool

RemoveSecret remove the secret from the Entry.Secrets

func (*Entry) Result

func (e *Entry) Result(ID uuid.UUID, secrets []*SecretResult, shares []*ShareResult) *EntryResult

Result returns EntryResult intance

func (*Entry) String

func (e *Entry) String() string

String returns JSON string with full entry info

func (*Entry) Summary

func (e *Entry) Summary(ID uuid.UUID) *EntrySum

Summary returns EntrySum intance

type EntryResult

type EntryResult struct {
	ID        uuid.UUID       `json:"uuid"`
	OwnerID   string          `json:"ownerId"`
	OwnerType string          `json:"ownerType"`
	Name      string          `json:"name"`
	Category  string          `json:"category"`
	Priority  int             `json:"priority"`
	Secrets   []*SecretResult `json:"secrets"`
	Shares    []*ShareResult  `json:"shares"`
	Created   time.Time       `json:"created"`
	Updated   time.Time       `json:"updated"`
}

EntryResult represents desensitized entry

func (*EntryResult) String

func (e *EntryResult) String() string

String returns JSON string with desensitized entry info

type EntrySum

type EntrySum struct {
	ID       uuid.UUID `json:"uuid"`
	Name     string    `json:"name"`
	Category string    `json:"category"`
	Priority int       `json:"priority"`
	Created  time.Time `json:"created"`
	Updated  time.Time `json:"updated"`
}

EntrySum represents desensitized entry

func (*EntrySum) String

func (e *EntrySum) String() string

String returns JSON string with desensitized entry info

type Secret

type Secret struct {
	Name    string    `json:"name"`
	URL     string    `json:"url"`
	Pass    string    `json:"password"`
	Note    string    `json:"note"`
	Created time.Time `json:"created"`
	Updated time.Time `json:"updated"`
}

Secret represents secret info

func SecretFrom

func SecretFrom(str string) (*Secret, error)

SecretFrom parse JSON string and returns a Secret intance.

func (*Secret) Result

func (s *Secret) Result(id uuid.UUID) *SecretResult

Result returns EntryResult intance

func (*Secret) String

func (s *Secret) String() string

String returns JSON string with full secret info

type SecretResult

type SecretResult struct {
	ID      uuid.UUID `json:"uuid"`
	Name    string    `json:"name"`
	URL     string    `json:"url"`
	Pass    string    `json:"password"`
	Note    string    `json:"note"`
	Created time.Time `json:"created"`
	Updated time.Time `json:"updated"`
}

SecretResult represents secret info

func (*SecretResult) String

func (s *SecretResult) String() string

String returns JSON string with full secret info

type Share

type Share struct {
	Name    string    `json:"name"`
	Salt    string    `json:"salt"`
	ToUser  string    `json:"toUser"`
	TTL     int       `json:"ttl"`
	Expire  time.Time `json:"expire"`
	Created time.Time `json:"created"`
	Updated time.Time `json:"updated"`
}

Share represents share info

func ShareFrom

func ShareFrom(str string) (*Share, error)

ShareFrom parse JSON string and returns a Share intance.

func (*Share) Result

func (s *Share) Result(ID uuid.UUID) *ShareResult

Result returns ShareResult intance

func (*Share) String

func (s *Share) String() string

String returns JSON string with full share info

type ShareResult

type ShareResult struct {
	ID      uuid.UUID `json:"uuid"`
	Name    string    `json:"name"`
	ToUser  string    `json:"toUser"`
	TTL     int       `json:"ttl"`
	Expire  time.Time `json:"expire"`
	Created time.Time `json:"created"`
	Updated time.Time `json:"updated"`
}

ShareResult represents desensitized share

type StringSlice added in v0.2.0

type StringSlice []string

StringSlice ...

func (StringSlice) Add added in v0.2.0

func (s StringSlice) Add(str string) ([]string, bool)

Add adds the str to the slice.

func (StringSlice) Has added in v0.2.0

func (s StringSlice) Has(str string) bool

Has returns whether the str is in the slice.

func (StringSlice) Remove added in v0.2.0

func (s StringSlice) Remove(str string) ([]string, bool)

Remove remove the str from the slice.

type Team

type Team struct {
	Name      string    `json:"name"`
	Pass      string    `json:"pass"`
	IsFrozen  bool      `json:"isFrozen"`
	IsDeleted bool      `json:"isDeleted"`
	OwnerID   string    `json:"ownerID"`
	Members   []string  `json:"members"`
	Created   time.Time `json:"created"`
	Updated   time.Time `json:"updated"`
}

Team represents team info

func TeamFrom

func TeamFrom(str string) (*Team, error)

TeamFrom parse JSON string and returns a Team intance.

func (*Team) AddMember added in v0.2.0

func (t *Team) AddMember(userID string) bool

AddMember adds the user to team's members

func (*Team) HasMember added in v0.2.0

func (t *Team) HasMember(userID string) bool

HasMember returns whether the user is team's member

func (*Team) RemoveMember added in v0.2.0

func (t *Team) RemoveMember(userID string) bool

RemoveMember removes the user from team's members

func (*Team) Result

func (t *Team) Result(ID uuid.UUID) *TeamResult

Result returns TeamResult intance

func (*Team) String

func (t *Team) String() string

String returns JSON string with full team info

type TeamResult

type TeamResult struct {
	ID       uuid.UUID `json:"uuid"`
	Name     string    `json:"name"`
	IsFrozen bool      `json:"isFrozen"`
	OwnerID  string    `json:"ownerID"`
	Members  []string  `json:"members"`
	Created  time.Time `json:"created"`
	Updated  time.Time `json:"updated"`
}

TeamResult represents desensitized team

func (*TeamResult) String

func (t *TeamResult) String() string

String returns JSON string with desensitized team info

type User

type User struct {
	ID        string    `json:"id"`
	Pass      string    `json:"pass"` // encrypt
	IsBlocked bool      `json:"isBlocked"`
	Attempt   int       `json:"attempt"` // login attempts
	Created   time.Time `json:"created"`
	Updated   time.Time `json:"updated"`
}

User represents user info

func UserFrom

func UserFrom(str string) (*User, error)

UserFrom parse JSON string and returns a User intance.

func (*User) Result

func (u *User) Result() *UserResult

Result returns UserResult intance

func (*User) String

func (u *User) String() string

String returns JSON string with full user info

type UserResult

type UserResult struct {
	ID      string    `json:"id"`
	Created time.Time `json:"created"`
	Updated time.Time `json:"updated"`
}

UserResult represents desensitized user

func (*UserResult) String

func (u *UserResult) String() string

String returns JSON string with desensitized user info

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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