package store

import (
	"crypto/ecdsa"
	"crypto/x509"
	"fmt"

	"gitea.benny.dog/torjus/ezshare/pb"
)

var ErrNoSuchItem = fmt.Errorf("no such item")

type FileStore interface {
	GetFile(id string) (*pb.File, error)
	StoreFile(file *pb.File) (string, error)
	DeleteFile(id string) error
	ListFiles() ([]*pb.ListFilesResponse_ListFileInfo, error)
}

type CertificateStore interface {
	GetCertificate(serial string) (*x509.Certificate, error)
	StoreCertificate(cert *x509.Certificate) error
	GetKey(id string) (*ecdsa.PrivateKey, error)
	StoreKey(id string, key *ecdsa.PrivateKey) error
	ListCertificates() ([]string, error)
	Revoke(serial string) error
	IsRevoked(serial string) (bool, error)
}

type UserStore interface {
	StoreUser(user *pb.User) error
	GetUser(id string) (*pb.User, error)
	GetUserByUsername(username string) (*pb.User, error)
	ListUsers() ([]string, error)
}