verae-mcp-timestamping-serv.../internal/tools/email_username.go
George Lambert 3ec1f0516b
Some checks failed
test-and-deploy / test (push) Failing after 12m55s
test-and-deploy / deploy-138 (push) Has been cancelled
feat(mcp): optional receipt_format on stamp/verify (text/PDF/JSON/MD/CSV/TSV)
Add receipt_format to stamp and verify. Omitted → text; receipt|PDF-Receipt → PDF;
JSON-Receipt → JSON; MD|MD-Receipt; CSV|CSV-Receipt; TSV|TSV-Receipt.

Stamp always returns receipts[] and adds artifacts[] in the chosen format.
Stdio writes ~/.verae/receipts (0600); public MCP returns content_text/content_base64 only.
Verify accepts inline receipt or receipt_path (stdio), parses id, and re-emits an artifact.

Vendors pdfcert (+ slim statuslang, gofpdf) for CERT-01 PDF. Also lands welcome tool
and email-username helpers already wired into register/public paths.
2026-10-20 16:02:20 -04:00

20 lines
479 B
Go

package tools
import (
"fmt"
"strings"
)
// requireEmailUsername enforces that Verae usernames are email addresses.
func requireEmailUsername(username string) error {
s := strings.TrimSpace(username)
at := strings.IndexByte(s, '@')
if at <= 0 || at >= len(s)-1 {
return fmt.Errorf("username must be an email address")
}
dot := strings.LastIndexByte(s, '.')
if dot <= at+1 || dot >= len(s)-1 {
return fmt.Errorf("username must be an email address")
}
return nil
}