Documentation
¶
Index ¶
- func Apply(ctx context.Context, db *sql.DB) error
- type Store
- func (s *Store) AppendEvent(ctx context.Context, e paste.Event) error
- func (s *Store) CreateShare(ctx context.Context, share paste.Share, editToken string) error
- func (s *Store) DeleteShare(ctx context.Context, id, editToken string) error
- func (s *Store) GetShare(ctx context.Context, id string) (*paste.Share, error)
- func (s *Store) ListEvents(ctx context.Context, shareID string) ([]paste.Event, error)
- func (s *Store) UpdateSharePlan(ctx context.Context, id string, planBlob, iv []byte, editToken string) error
- func (s *Store) VerifyEditToken(ctx context.Context, id, token string) (bool, error)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is the SQLite-backed paste.Storage implementation.
func New ¶
New wraps an open *sql.DB as a Store. The caller still owns the connection and is responsible for closing it.
func (*Store) AppendEvent ¶
AppendEvent appends a new event row to the share's append-only log. Events are only ever inserted — never updated or deleted — so the entire history is reproducible by replay.
func (*Store) CreateShare ¶
CreateShare inserts a new share row plus its edit token. The token is stored in the same row so the table is the source of truth for both the public ID and the bearer credential needed to mutate it later.
func (*Store) DeleteShare ¶
DeleteShare removes the share (and, via cascade, its event log) after verifying the edit token.
func (*Store) GetShare ¶
GetShare returns the share row by ID. The edit_token column is intentionally excluded from the SELECT — only VerifyEditToken consults it, so untrusted reads can't accidentally leak the token via an error or log.
func (*Store) ListEvents ¶
ListEvents returns every event for the share, ordered by created_at then id so callers can replay state deterministically (Go map iteration is randomized, so the deterministic order has to come from the SQL side).
func (*Store) UpdateSharePlan ¶
func (s *Store) UpdateSharePlan(ctx context.Context, id string, planBlob, iv []byte, editToken string) error
UpdateSharePlan replaces the encrypted plan blob & nonce after verifying the edit token. updated_at is bumped so clients can detect changes.
func (*Store) VerifyEditToken ¶
VerifyEditToken checks token against the stored edit_token for share id. Returns (false, ErrShareNotFound) when the share doesn't exist; (false, nil) when the share exists but the token doesn't match; (true, nil) on success.