store

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 8, 2025 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ManifestPath = ".gostore.json"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type AddParams

type AddParams struct {
	SecretIndex

	Data []byte
}

type CloneParams

type CloneParams struct {
	CommonParams

	ID string

	StorageType storage.Type
	Remote      string
}

type CommonParams

type CommonParams struct {
	StorePath maybe.Maybe[string]
	StoreID   maybe.Maybe[string]
}

type CopyParams

type CopyParams struct {
	Src string
	Dst string
}

type DataProvider

type DataProvider interface {
	CurrentStorePath(ctx context.Context) (maybe.Maybe[string], error)
	StorePath(ctx context.Context, storeID string) (maybe.Maybe[string], error)
}

type GetParams

type GetParams struct {
	SecretIndex
}

type IdentityProvider

type IdentityProvider interface {
	IdentityByRecipient(ctx context.Context, recipient encryption.Recipient) (maybe.Maybe[encryption.Identity], error)
}

type InitParams

type InitParams struct {
	CommonParams

	Recipients []encryption.Recipient
	Encryption encryption.Encryption

	StorageType maybe.Maybe[storage.Type]
	Remote      maybe.Maybe[string]
}

type InitRes

type InitRes struct {
	StorePath         string
	GeneratedIdentity maybe.Maybe[encryption.Identity]
}

type ListParams

type ListParams struct {
	Path string
}

type Manifest

type Manifest struct {
	StorageType storage.Type
	Encryption  encryption.Encryption
	Recipients  []encryption.Recipient
	Unpacked    bool
}

type ManifestSerializer

type ManifestSerializer interface {
	Serialize(m Manifest) ([]byte, error)
	Deserialize(data []byte) (Manifest, error)
}

type MoveParams

type MoveParams struct {
	Src string
	Dst string
}

type RawSecret

type RawSecret struct {
	Data    maybe.Maybe[[]byte]
	Payload maybe.Maybe[map[string][]byte]
}

RawSecret - raw secret one of

type RemoveParams

type RemoveParams struct {
	Path string
	Key  maybe.Maybe[string]
}

type Secret

type Secret struct {
	// Payload is json object with encrypted values
	Payload map[string][]byte
}

type SecretData

type SecretData struct {
	Name    string
	Payload []byte

	Default bool // means that secret data stored in default field
}

type SecretIndex

type SecretIndex struct {
	Path string
	Key  maybe.Maybe[string]
}

func (SecretIndex) String

func (q SecretIndex) String() string

type SecretSerializer

type SecretSerializer interface {
	Serialize(secret Secret) ([]byte, error)
	Deserialize([]byte) (Secret, error)

	RawSerialize(secret RawSecret) ([]byte, error)
	RawDeserialize(data []byte) (RawSecret, error)
}

type Service

type Service interface {
	Add(ctx context.Context, params AddParams) error

	Copy(ctx context.Context, params CopyParams) error
	Move(ctx context.Context, params MoveParams) error

	Get(ctx context.Context, params GetParams) ([]SecretData, error)
	List(ctx context.Context, params ListParams) (storage.Tree, error)

	Remove(ctx context.Context, params RemoveParams) error

	Unpack(ctx context.Context) error
	Pack(ctx context.Context) error

	Sync(ctx context.Context) error
	Rollback(ctx context.Context) error
}

func NewStoreService

func NewStoreService(
	storeID maybe.Maybe[string],
	storageManager storage.Manager,
	encryptionManager encryption.Manager,
	manifestSerializer ManifestSerializer,
	secretSerializer SecretSerializer,
	dataProvider DataProvider,
	identityProvider IdentityProvider,
) Service

type WriteManifestParams

type WriteManifestParams struct {
	Recipients  []encryption.Recipient
	Encryption  encryption.Encryption
	StorageType storage.Type
}

Jump to

Keyboard shortcuts

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