Documentation
¶
Overview ¶
Package linktoken signs the tokens embedded in emails: open pixel, click redirect, one-click unsubscribe (RFC 8058), preference center, view online and double opt-in confirmation links. Tokens are compact, unforgeable (HMAC-SHA256 truncated to 128 bits) and carry no personal data in clear.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalid = errors.New("linktoken: invalid token")
ErrInvalid is returned for malformed or forged tokens.
var ErrSignature = fmt.Errorf("%w: the signature doesn't match", ErrInvalid)
ErrSignature is returned for a well-formed token of the wanted kind whose signature doesn't match: signed with an earlier instance key, or forged. It is also ErrInvalid.
Functions ¶
Types ¶
type Claims ¶
type Claims struct {
Kind Kind
WorkspaceID uuid.UUID
MessageID uuid.UUID // uuid.Nil when not tied to a message
ContactID uuid.UUID
// Link is the index of the link in campaign_links for Click tokens.
Link uint32
}
Claims identify the message (or contact, for links outside a message).
type Kind ¶
type Kind byte
Kind is what a token is for; a token for one purpose never works for another.
const ( Open Kind = 1 Click Kind = 2 Unsubscribe Kind = 3 Preferences Kind = 4 ViewOnline Kind = 5 Confirm Kind = 6 // Polls and surveys (design expansion, X11: 110–119, numbered after // the workstream so parallel kinds never collide). Link is the poll's // or the survey's number. A poll link without a message and a contact // is the web archive's: its answers count apart, as non-contacts'. A // test link's MessageID names the test address (poll_test_recipients). Poll Kind = 110 Survey Kind = 111 PollTest Kind = 112 SurveyTest Kind = 113 // Grow (design expansion, X15: 150–159): a referrer's hub, the // recommendations page and a reward's download. Their Link holds the // day they were issued (IssueDay), so they expire. ReferralHub Kind = 150 Recommendations Kind = 151 RewardDownload Kind = 152 // Review 2026-10 (R05: 200–209): the hidden link of tracked emails, // which only machines follow (bot clicks, review AN-2). Honeypot Kind = 200 )
Token kinds.
type Signer ¶
type Signer struct {
// contains filtered or unexported fields
}
Signer signs and verifies tokens with a key derived from the instance key.