Versions in this module Expand all Collapse all v0 v0.1.1 Nov 12, 2026 v0.1.0 Oct 14, 2026 Changes in this version + const DefaultCodeTTL + const DefaultMaxAttempts + const EndpointAdd + const EndpointChange + const EndpointConfirmChange + const EndpointList + const EndpointMakePrimary + const EndpointRemove + const EndpointResend + const EndpointSendCode + const EndpointSignIn + const EndpointVerify + const KindPhone + const MaxDigits + const MinDigits + const PluginName + const PurposeChangeCode + const PurposeSignInCode + const PurposeVerifyCode + const TableAliasIdentity + var ErrCodeInvalid = auth.ErrCodeInvalid + var ErrCodeNoLogin = errors.New("phone: SignInWithCode needs Login()") + var ErrGenerateWithVerifier = errors.New(...) + var ErrHasNumber = auth.NewError("phone.has_number", http.StatusConflict, ...) + var ErrNoSMS = errors.New("phone: no SMS sender; pass phone.WithSMS") + var IdentityIsPrimary = sqlb.Col[bool](TableIdentity, auth.ColIdentityIsPrimary) + var IdentityKind = sqlb.Col[auth.IdentifierKindName](TableIdentity, auth.ColIdentityKind) + var IdentityUserID = sqlb.Col[string](TableIdentity, auth.ColIdentityUserID) + var IdentityValue = sqlb.Col[string](TableIdentity, auth.ColIdentityValue) + var IdentityValueRaw = sqlb.Col[string](TableIdentity, auth.ColIdentityValueRaw) + var IdentityVerifiedAt = sqlb.Col[*time.Time](TableIdentity, auth.ColIdentityVerifiedAt) + var TableIdentity = sqlb.Table + func DefaultTemplate(m auth.Message) string + func Normalize(raw string) (string, error) + func Of(a *auth.Auth, userID string, dst *Data) (sqlb.Query, error) + func UserBindings(dst *Data) []sqlb.Binding + func UserJoin() sqlb.Join + func Validate(v string) error + type ChangeResult struct + Phone string + type CodeFor struct + Phone string + Purpose auth.Purpose + type CodeGenerator func(ctx context.Context, in CodeFor) (string, error) + type CodeRequest struct + Code string + Phone string + func (r CodeRequest) RateIdentifier() string + type Data struct + IsPrimary bool + Number string + NumberRaw string + VerifiedAt *time.Time + func (d *Data) Exists() bool + func (d *Data) Verified() bool + type ListResult struct + Numbers []Number + type MetadataSender interface + SendWithMetadata func(ctx context.Context, to, text string, metadata map[string]string) error + type Number struct + Phone string + Primary bool + Verified bool + type NumberRequest struct + Phone string + func (r NumberRequest) RateIdentifier() string + type Option func(*Plugin) + func AllowPrefixes(prefixes ...string) Option + func Contact() Option + func GenerateCode(fn CodeGenerator) Option + func LimitRange(digits, limit int, window time.Duration) Option + func Login() Option + func Multiple() Option + func Recover() Option + func RequireVerified() Option + func ResendOnSignIn() Option + func ScopedByTenant() Option + func SignInWithCode() Option + func Templates(fn func(m auth.Message) string) Option + func TemplatesByLocale(byLocale map[string]func(m auth.Message) string) Option + func WithCodeTTL(d time.Duration) Option + func WithMaxAttempts(n int) Option + func WithNormalizer(fn func(raw string) (string, error)) Option + func WithSMS(s SMSSender) Option + func WithValidator(fn func(normalized string) error) Option + func WithVerifier(v Verifier) Option + type Plugin struct + func New(opts ...Option) *Plugin + func (p *Plugin) Add(ctx context.Context, number string) error + func (p *Plugin) Change(ctx context.Context, number string) error + func (p *Plugin) ConfirmChange(ctx context.Context, number, code string) (ChangeResult, error) + func (p *Plugin) DataHooks() auth.DataHooks + func (p *Plugin) Deliver(ctx context.Context, to auth.Identity, m auth.Message) error + func (p *Plugin) Identifiers() []auth.IdentifierKind + func (p *Plugin) Init(a *auth.Auth) error + func (p *Plugin) List(ctx context.Context) ([]Number, error) + func (p *Plugin) MakePrimary(ctx context.Context, number string) error + func (p *Plugin) Name() string + func (p *Plugin) Operations() []auth.Operation + func (p *Plugin) OptionErr() error + func (p *Plugin) RateLimits() []auth.RateRule + func (p *Plugin) Remove(ctx context.Context, number string) error + func (p *Plugin) Resend(ctx context.Context, number string) error + func (p *Plugin) SendCode(ctx context.Context, number string) error + func (p *Plugin) SendVerification(ctx context.Context, to auth.Identity) error + func (p *Plugin) SignIn(ctx context.Context, number, code string) (SignInResult, error) + func (p *Plugin) SignInWith(ctx context.Context, in SignInRequest) (SignInResult, error) + func (p *Plugin) SignsIn() bool + func (p *Plugin) Tables() []sqlb.Table + func (p *Plugin) Validate(*auth.Config) error + func (p *Plugin) Verify(ctx context.Context, number, code string) error + type SMSFunc func(ctx context.Context, to, text string) error + func (f SMSFunc) Send(ctx context.Context, to, text string) error + type SMSSender interface + Send func(ctx context.Context, to, text string) error + type SignInRequest struct + Code string + Fields auth.Fields + Phone string + func (r *SignInRequest) UnmarshalJSON(data []byte) error + func (r SignInRequest) RateIdentifier() string + type SignInResult struct + Created bool + SecondFactorRequired bool + Token auth.Token + User auth.UserView + type Verifier interface + Check func(ctx context.Context, number, code string) error + Send func(ctx context.Context, number string) error