services

package
v0.0.0-...-7533b51 Latest Latest
Warning

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

Go to latest
Published: Dec 10, 2023 License: Unlicense Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidSignature    = errors.New("invalid signature")
	ErrDuplicatedSignature = errors.New("signature already exists")
	ErrWrongOwner          = errors.New("a user does not own a signature")
)

Functions

This section is empty.

Types

type ExternalSignature

type ExternalSignature struct {
	ID     string `json:"id"`
	UserID string `json:"user_id"`
}

type SignatureService

type SignatureService interface {
	CreateSignature(context.Context, string, string, []TestAnswer) ([]byte, error)
	VerifySignature(context.Context, string, []byte) (StoredSignature, error)
}

type SignatureSvc

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

func NewSignatureSvc

func NewSignatureSvc(
	repo r.SignatureRepository,
	key string,
) (*SignatureSvc, error)

func (*SignatureSvc) CreateSignature

func (s *SignatureSvc) CreateSignature(
	ctx context.Context,
	requestID string,
	userID string,
	testAnswers []TestAnswer,
) ([]byte, error)

func (*SignatureSvc) VerifySignature

func (s *SignatureSvc) VerifySignature(ctx context.Context, username string, ciphered []byte) (StoredSignature, error)

type StoredSignature

type StoredSignature struct {
	Answers   []string  `json:"answers"`
	Timestamp time.Time `json:"timestamp"`
}

type TestAnswer

type TestAnswer struct {
	Question string
	Answer   string
}

Jump to

Keyboard shortcuts

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