unsubscribe

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2026 License: Apache-2.0 Imports: 9 Imported by: 0

Documentation

Overview

Package unsubscribe derives opaque, stable identifiers for managed unsubscribe scopes and their database lookup keys.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Derive

func Derive(secret, userID, agentID, recipient string) (string, error)

Derive returns a deterministic opaque token bound to one user, sending agent, and recipient. Email identifiers use the same lowercase, trimmed lookup form used elsewhere in the service.

func Hash

func Hash(token string) []byte

Hash returns the fixed-width key used to resolve a token without storing the bearer token itself.

func ValidToken

func ValidToken(token string) bool

ValidToken reports whether token has the public wire format emitted by Derive. It validates shape only; authority still requires resolving Hash.

Types

type Issuer

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

Issuer derives and stores a recipient-scoped bearer token before returning the absolute public unsubscribe URL. It is safe to call repeatedly.

func NewIssuer

func NewIssuer(secret, apiURL string, production bool, store TokenStore) (*Issuer, error)

func (*Issuer) Issue

func (i *Issuer) Issue(ctx context.Context, userID, agentID, recipient string) (string, error)

func (*Issuer) Ready

func (i *Issuer) Ready() error

Ready validates the issuer's immutable wiring without deriving or storing a recipient token. Callers use it before persisting a review hold, while Issue remains deferred until the final recipient set is approved.

type TokenStore

type TokenStore interface {
	PutUnsubscribeToken(ctx context.Context, tokenHash []byte, userID, agentID, address string) error
}

Jump to

Keyboard shortcuts

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