email

package
v0.4.1 Latest Latest
Warning

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

Go to latest
Published: Sep 11, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package email defines the provider-independent email boundary of Auth-All. The application owns delivery. Auth-All supplies intent and required data.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Normalize

func Normalize(address string) string

Normalize returns the canonical form Auth-All uses to look up an address. The form trims surrounding space and lowercases the address. Auth-All does not apply provider-specific rules such as removing dots, because those rules differ per provider and can merge distinct accounts.

func Valid

func Valid(address string) bool

Valid reports whether the address is a single parsable email address.

Types

type Intent

type Intent string

Intent identifies why Auth-All asks the application to send a message.

const (
	IntentVerifyEmail   Intent = "verify-email"
	IntentResetPassword Intent = "reset-password"
	IntentMagicLink     Intent = "magic-link"
	// IntentEmailChange asks the application to send a confirmation to the new
	// address of a user. The message carries the token.
	IntentEmailChange Intent = "email-change"
	// IntentEmailChangeNotice asks the application to tell the old address of a
	// user that somebody asked for a change. The message carries no token and
	// no link, so the old address cannot complete the change.
	IntentEmailChangeNotice Intent = "email-change-notice"
	// IntentDeleteAccount asks the application to send a confirmation of an
	// account delete. A user with no password credential needs it.
	IntentDeleteAccount Intent = "delete-account"
)

Required v1 intents.

type Message

type Message struct {
	// Intent describes the purpose of the message.
	Intent Intent
	// To is the destination email address.
	To string
	// UserID is the target user. It is empty when no user exists yet.
	UserID string
	// Token is the one-time token in plaintext. It exists only here and in the
	// delivered message. Auth-All stores only its hash.
	Token string
	// URL is the ready-to-use action link.
	URL string
	// ExpiresAt is the token expiry.
	ExpiresAt time.Time
	// Data carries additional intent-specific values.
	Data map[string]string
}

Message is the data Auth-All supplies for one message.

type Sender

type Sender interface {
	Send(ctx context.Context, message Message) error
}

Sender delivers a message. The application can send directly or enqueue the work. Auth-All does not require synchronous delivery.

type SenderFunc

type SenderFunc func(ctx context.Context, message Message) error

SenderFunc adapts a function to the Sender interface.

func (SenderFunc) Send

func (f SenderFunc) Send(ctx context.Context, m Message) error

Send implements Sender.

Jump to

Keyboard shortcuts

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