Documentation
¶
Overview ¶
Package sharelink runs one-shot secret exchanges with people who have no account: a drop box they fill in (values land straight in the encrypted variables store) or a share link that shows them existing values once.
Two rules hold the whole design together. Every state change happens on a POST, so link previewers and browser prefetch can't burn a link by looking at it. And every burn is a claim, an UPDATE guarded on the current state, so two concurrent submits can never both go through.
Index ¶
- Variables
- func EncodeFields(fields []repo.SecretLinkField) (string, error)
- func HashToken(raw string) string
- func Mint(ctx context.Context, store repo.Store, l *repo.SecretLink, pass string) (string, error)
- func Open(ctx context.Context, store repo.Store, token string) (*repo.SecretLink, error)
- func Reveal(ctx context.Context, store repo.Store, l *repo.SecretLink) ([]repo.Variable, error)
- func Revoke(ctx context.Context, store repo.Store, id string) error
- func Submit(ctx context.Context, store repo.Store, l *repo.SecretLink, ...) error
- func Unlock(ctx context.Context, store repo.Store, l *repo.SecretLink, pass string) error
Constants ¶
This section is empty.
Variables ¶
var ( // ErrDead covers every reason a link won't open, wrong token, expired, // burned, revoked, locked. The public pages must not tell a stranger which. ErrDead = errors.New("link is no longer available") // ErrPass is returned when the passphrase is missing or wrong; after // repo.MaxLinkAttempts the link locks and ErrDead takes over. ErrPass = errors.New("wrong passphrase") )
Functions ¶
func EncodeFields ¶
func EncodeFields(fields []repo.SecretLinkField) (string, error)
EncodeFields is the writer side of SecretLink.Fields.
func HashToken ¶
HashToken is the one-way mapping from the token in the URL to what we store. Same shape as API keys: the plaintext exists only in the link we hand out.
func Mint ¶
Mint stores a link and returns the token for its URL. The token is returned exactly once, only its hash is persisted, so a lost link can't be recovered.
func Open ¶
Open resolves a token to a live link. It is safe on GET: no state changes here, and a passphrase-protected link reports ErrPass without touching the row, so a prefetch can't spend an attempt.
func Reveal ¶
Reveal burns a share link and reads the values it points at. Values are read live, never copied at mint, so revoking a link leaves nothing to clean up. With a grace window the link stays readable until the window closes rather than dying on the first read.
func Submit ¶
func Submit(ctx context.Context, store repo.Store, l *repo.SecretLink, values map[string]string) error
Submit burns a drop box and writes what was collected, atomically: the claimed burn and the variable writes are one transaction, so a losing double-submit writes nothing and a failed write un-burns the link.
Types ¶
This section is empty.