app

package
v0.0.0-...-4ce15e1 Latest Latest
Warning

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

Go to latest
Published: Mar 15, 2022 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateEntryRequest

type CreateEntryRequest struct {
	Name        string        `json:"name"`
	SenderID    uuid.UUID     `json:"senderId"`
	SendToEmail string        `json:"sendToEmail"`
	Value       string        `json:"value"`
	Secret      string        `json:"secret"`
	Duration    time.Duration `json:"duration"`
}

type CreateEntryResponse

type CreateEntryResponse struct {
	Success bool           `json:"success"`
	Errors  []string       `json:"errors"`
	Entry   *sendkey.Entry `json:"entry"`
}

type CreateUserRequest

type CreateUserRequest struct {
	Email     string `json:"email"`
	Password  string `json:"password"`
	FirstName string `json:"firstName"`
	LastName  string `json:"lastName"`
}

type CreateUserResponse

type CreateUserResponse struct {
	Success bool          `json:"success"`
	Errors  []string      `json:"errors"`
	User    *sendkey.User `json:"user"`
}

type DecryptEntryRequest

type DecryptEntryRequest struct {
	ID     uuid.UUID `json:"id"`
	Nonce  string    `json:"nonce"`
	Secret string    `json:"secret"`
}

type DecryptEntryResponse

type DecryptEntryResponse struct {
	Success bool           `json:"success"`
	Errors  []string       `json:"errors"`
	Expired bool           `json:"expired"`
	Entry   *sendkey.Entry `json:"entry"`
}

type EntryRepository

type EntryRepository interface {
	Find(uuid.UUID) (*sendkey.Entry, error)
	FindByUserID(uuid.UUID) ([]sendkey.Entry, error)
	Create(sendkey.Entry) error
	Delete(uuid.UUID) error
	IncrementInvalidAttempts(uuid.UUID) (int, error)

	CreateClaimedEntry(sendkey.ClaimedEntry) error
	CreateExpiredEntry(sendkey.ExpiredEntry) error
}

type EntryService

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

func NewEntryService

func NewEntryService(er EntryRepository, key []byte, maxAttempts int) *EntryService

The key argument should be the AES key, either 16, 24, or 32 bytes to select AES-128, AES-192, or AES-256. The maxAttempts argument is the number of invalid attempts allowed before an entry is forcefully expired.

func (*EntryService) CreateEntry

func (s *EntryService) CreateEntry(req CreateEntryRequest) (*CreateEntryResponse, error)

func (*EntryService) DecryptEntry

func (*EntryService) FindByUserID

func (s *EntryService) FindByUserID(userID uuid.UUID) ([]sendkey.Entry, error)

func (*EntryService) FindEntry

func (s *EntryService) FindEntry(id uuid.UUID, nonce string) (*sendkey.Entry, error)

func (*EntryService) SendEntry

func (s *EntryService) SendEntry(entry sendkey.Entry) error

type UserLoginRequest

type UserLoginRequest struct {
	Email    string `json:"email"`
	Password string `json:"password"`
}

type UserLoginResponse

type UserLoginResponse struct {
	Success bool          `json:"success"`
	Errors  []string      `json:"errors"`
	User    *sendkey.User `json:"user"`
}

type UserRepository

type UserRepository interface {
	Find(uuid.UUID) (*sendkey.User, error)
	FindByEmail(string) (*sendkey.User, error)
	Create(sendkey.User) error
	Update(sendkey.User) error
	Delete(uuid.UUID) error
}

type UserService

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

func NewUserService

func NewUserService(users UserRepository) *UserService

func (*UserService) CreateUser

func (s *UserService) CreateUser(req CreateUserRequest) (*CreateUserResponse, error)

func (*UserService) FindUser

func (s *UserService) FindUser(id uuid.UUID) (*sendkey.User, error)

func (*UserService) Login

Jump to

Keyboard shortcuts

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