Help us shape the future of Go! Take the 2026 Go Developer Survey

links

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Oct 2, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Overview

Package links serves report pages and sensitive-data forms over the bot's own HTTP listener (stage 24), so answers arrive as links, not walls of text. Security by design: every link is HMAC-signed, binds the sender it was minted for, and expires; a per-chat PIN (sent alongside the link) is the second factor - another sender opening the link does not have it; submitted form values land in the vault and never touch a log line; the server binds wherever the channel adapter already listens (localhost by default).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Record

type Record struct {
	ID       string    `json:"id"`
	Kind     string    `json:"kind"` // report | form
	Sender   string    `json:"sender"`
	PINHash  string    `json:"pin_hash"`
	Expires  time.Time `json:"expires"`
	Title    string    `json:"title"`
	VaultKey string    `json:"vault_key,omitempty"`
}

Record is one minted link. Reports carry a content file; forms carry a vault key and a label.

type Service

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

Service mints and serves links.

func Open

func Open(secretPath, baseURL, storeDir, vaultDir string, logf func(string, ...any)) (*Service, error)

Open loads (or creates) the signing secret and the store. baseURL is the public base the bot's links are reached on.

func (*Service) Handler

func (s *Service) Handler() http.Handler

Handler serves the /l/ routes; mount it on the channel listener.

func (*Service) MintForm

func (s *Service) MintForm(sender, title, vaultKey string) (link, pin string, err error)

MintForm creates a sensitive-data form landing in vaultKey and returns the link and its PIN for sender.

func (*Service) MintReport

func (s *Service) MintReport(sender, title, content string) (link, pin string, err error)

MintReport stores title/content as an HTML page and returns the link and its PIN for sender.

func (*Service) MintReportHTML

func (s *Service) MintReportHTML(sender, title, page string) (link, pin string, err error)

MintReportHTML is MintReport for runner-generated reports: the page is trusted HTML built by the bot itself (tables, embedded charts), never model- or user-supplied markup. Same signing, PIN and expiry machinery; the model-facing make_report_link tool keeps the escaped plain-text path.

func (*Service) SetNow

func (s *Service) SetNow(f func() time.Time)

SetNow overrides the clock (tests).

Jump to

Keyboard shortcuts

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