session

package
v0.2.6 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Manager

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

Manager handles session mapping state

func NewManager

func NewManager(ttl time.Duration, maxSize int) *Manager

NewManager creates a new session manager

func (*Manager) AttachWAL added in v0.1.3

func (m *Manager) AttachWAL(wal *WAL)

AttachWAL binds a WAL instance for persisting newly registered mappings.

func (*Manager) Clear

func (m *Manager) Clear()

Clear removes all mappings

func (*Manager) Close

func (m *Manager) Close()

Close stops the cleanup goroutine

func (*Manager) DeterministicPlaceholdersEnabled added in v0.1.4

func (m *Manager) DeterministicPlaceholdersEnabled() bool

DeterministicPlaceholdersEnabled reports whether deterministic placeholders are currently active.

func (*Manager) GeneratePlaceholder

func (m *Manager) GeneratePlaceholder(original, category, prefix string) string

GeneratePlaceholder creates a placeholder for the given original value (does NOT register it). Uses a truncated HMAC-SHA256(key, original) token: stable mapping for the same original, while reducing dictionary-guessing risk.

func (*Manager) ListMappings

func (m *Manager) ListMappings() []MappingInfo

ListMappings returns all mappings (without original values for privacy)

func (*Manager) Lookup

func (m *Manager) Lookup(placeholder string) (string, bool)

Lookup returns the original value for a placeholder

func (*Manager) LookupReverse

func (m *Manager) LookupReverse(original string) (string, bool)

LookupReverse returns the placeholder for an original value

func (*Manager) Register

func (m *Manager) Register(placeholder, original string)

Register adds a new mapping

func (*Manager) SetDeterministicPlaceholders added in v0.1.4

func (m *Manager) SetDeterministicPlaceholders(enabled bool, key32 []byte) error

SetDeterministicPlaceholders toggles "deterministic placeholders" mode: - enabled=false: use a per-process random key (stable within this process only). - enabled=true: use the provided key32 (should be derived from the CA private key).

func (*Manager) Size

func (m *Manager) Size() int

Size returns the number of mappings

type MappingInfo

type MappingInfo struct {
	Placeholder string
	Category    string
}

MappingInfo represents a mapping entry for listing (without original value)

type WAL

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

WAL handles persistent storage of session mappings

func NewWAL

func NewWAL(path string, key32 []byte) (*WAL, error)

NewWAL creates a new WAL instance

func (*WAL) Append

func (w *WAL) Append(entry WALEntry) error

Append adds a new entry to the WAL

func (*WAL) Close

func (w *WAL) Close() error

Close closes the WAL file

func (*WAL) Delete

func (w *WAL) Delete() error

Delete removes the WAL file

func (*WAL) Load

func (w *WAL) Load() ([]WALEntry, error)

Load reads all entries from the WAL

func (*WAL) RestoreInto

func (w *WAL) RestoreInto(m *Manager) error

RestoreInto loads WAL entries into a session manager

type WALEntry

type WALEntry struct {
	Placeholder string    `json:"placeholder"`
	Original    string    `json:"original"`
	Category    string    `json:"category"`
	CreatedAt   time.Time `json:"created_at"`
}

WAL entry structure

Jump to

Keyboard shortcuts

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