domain

package
v0.0.0-...-3893ded Latest Latest
Warning

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

Go to latest
Published: Mar 9, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// MaxSecretSize is the maximum allowed size for a secret (64 KB).
	MaxSecretSize = 64 * 1024

	// MaxRequestBodySize is the maximum allowed request body size.
	// Set slightly larger than MaxSecretSize to account for JSON overhead.
	MaxRequestBodySize = MaxSecretSize + 1024

	// MaxReadAttempts is the maximum number of incorrect passcode attempts
	// before a secret is automatically deleted.
	MaxReadAttempts = 3

	// DefaultExpiry is the default TTL for secrets when no expiry is specified.
	DefaultExpiry = 24 * time.Hour
)

Variables

View Source
var ExpiryOptions = []string{"1h", "6h", "1d", "3d"}

ExpiryOptions defines the valid expiry duration strings.

Functions

This section is empty.

Types

type ConfigRes

type ConfigRes struct {
	MaxSecretSize int      `json:"max_secret_size"`
	ExpiryOptions []string `json:"expiry_options"`
	DefaultTheme  string   `json:"default_theme,omitempty"`
}

type CreateReq

type CreateReq struct {
	Secret string `json:"secret"`
	Expiry string `json:"expiry"` // one of: 1h, 6h, 1d, 3d
}

type CreateRes

type CreateRes struct {
	ID        string    `json:"id"`
	Passcode  string    `json:"passcode"`
	ExpiresAt time.Time `json:"expires_at"`
	ReadURL   string    `json:"read_url"`
}

type ReadReq

type ReadReq struct {
	Passcode string `json:"passcode"`
}

type ReadRes

type ReadRes struct {
	Secret            string `json:"secret,omitempty"`
	RemainingAttempts *int   `json:"remaining_attempts,omitempty"`
}

type SecretRepository

type SecretRepository interface {
	StoreSecret(ctx context.Context, id string, secret []byte, ttl time.Duration) error
	GetSecret(ctx context.Context, id string) ([]byte, error)
	DelIfMatch(ctx context.Context, id string, old []byte) error
	IncrFailAndMaybeDelete(ctx context.Context, id string) (int64, error)
	DeleteAttempts(ctx context.Context, id string) error
	Ping(ctx context.Context) error
}

func NewRedisRepository

func NewRedisRepository(rdb *redis.Client) SecretRepository

Jump to

Keyboard shortcuts

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