adapters

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: May 12, 2026 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package adapters provides concrete implementations of the ports interfaces.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type EncryptedFileStore

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

EncryptedFileStore persists sessions as encrypted files in a directory. Uses AES-256-GCM encryption with a key stored separately.

The encryption format is: nonce (12 bytes) || ciphertext || auth tag (16 bytes) This provides both confidentiality and integrity verification.

File extension is ".enc" to distinguish from plaintext session files.

func NewEncryptedFileStore

func NewEncryptedFileStore(dir string, keyProvider KeyProvider) (*EncryptedFileStore, error)

NewEncryptedFileStore creates an EncryptedFileStore. Creates the directory if needed. The keyProvider will be used to retrieve the encryption key for each operation.

func (*EncryptedFileStore) DeleteSession

func (e *EncryptedFileStore) DeleteSession(_ context.Context, id string) error

DeleteSession removes an encrypted session file.

func (*EncryptedFileStore) ListSessions

func (e *EncryptedFileStore) ListSessions(_ context.Context) ([]string, error)

ListSessions returns all session IDs (files with .enc extension).

func (*EncryptedFileStore) LoadSession

func (e *EncryptedFileStore) LoadSession(_ context.Context, id string) (*ports.SessionData, error)

LoadSession reads and decrypts session data from a file.

func (*EncryptedFileStore) SaveSession

func (e *EncryptedFileStore) SaveSession(_ context.Context, id string, data *ports.SessionData) error

SaveSession encrypts and saves session data to a file.

type EnvKeyProvider

type EnvKeyProvider struct {
	EnvVar string
}

EnvKeyProvider fetches key from environment variable (for dev/testing). This is NOT recommended for production use.

func (*EnvKeyProvider) GetKey

func (e *EnvKeyProvider) GetKey(_ context.Context) ([]byte, error)

GetKey retrieves the encryption key from an environment variable.

type FileStore

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

FileStore persists sessions as JSON files in a directory.

func NewFileStore

func NewFileStore(dir string) (*FileStore, error)

NewFileStore creates a FileStore. Creates the directory if needed.

func (*FileStore) DeleteSession

func (f *FileStore) DeleteSession(_ context.Context, id string) error

func (*FileStore) ListSessions

func (f *FileStore) ListSessions(_ context.Context) ([]string, error)

func (*FileStore) LoadSession

func (f *FileStore) LoadSession(_ context.Context, id string) (*ports.SessionData, error)

func (*FileStore) SaveSession

func (f *FileStore) SaveSession(_ context.Context, id string, data *ports.SessionData) error

type KeyProvider

type KeyProvider interface {
	GetKey(ctx context.Context) ([]byte, error)
}

KeyProvider retrieves the encryption key. Implement this to fetch from keychain, env var, or wherever you store secrets.

type MemoryStore

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

MemoryStore is an in-memory StateStore. Sessions survive for the lifetime of the process but are lost on exit. This is the default when no persistent store is configured.

func NewMemoryStore

func NewMemoryStore() *MemoryStore

NewMemoryStore constructs an empty in-memory store.

func (*MemoryStore) DeleteSession

func (m *MemoryStore) DeleteSession(_ context.Context, id string) error

func (*MemoryStore) ListSessions

func (m *MemoryStore) ListSessions(_ context.Context) ([]string, error)

func (*MemoryStore) LoadSession

func (m *MemoryStore) LoadSession(_ context.Context, id string) (*ports.SessionData, error)

func (*MemoryStore) SaveSession

func (m *MemoryStore) SaveSession(_ context.Context, id string, data *ports.SessionData) error

Jump to

Keyboard shortcuts

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