Documentation
¶
Overview ¶
Package aut2fa sends and verifies 2FA codes through the public aut2fa API.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrInvalidResponse = errors.New("aut2fa: invalid API response")
ErrInvalidResponse identifies malformed or incomplete successful responses.
Functions ¶
This section is empty.
Types ¶
type ApiError ¶
type ApiError struct {
Status int
Code string
Detail string
Errors map[string]string
RetryAfter string
}
ApiError preserves an HTTP rejection and its RFC 9457 problem details. RetryAfter is the raw Retry-After header, which may be seconds or an HTTP date.
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client uses one immutable application key and configuration across requests. Create it with New; it can be shared by concurrent goroutines.
func (*Client) Send ¶
func (c *Client) Send(ctx context.Context, params SendParams) (*SendResponse, error)
Send creates a delivery. An idempotency key is sent only as an HTTP header.
type Option ¶
type Option func(*configuration) error
Option configures a Client before it is created.
func WithBaseURL ¶
WithBaseURL sets an absolute HTTP(S) URL, optionally with a path prefix. Credentials, queries and fragments are not accepted.
func WithHTTPClient ¶
WithHTTPClient preserves an injected client's transport and cookie jar. The SDK copies the client and enforces its own timeout and redirect policy. Standard transports are cloned with keep-alives disabled to prevent retries.
func WithTimeout ¶
WithTimeout sets the total request timeout, including reading the response. The duration must be positive; the default is ten seconds.
type SendParams ¶
type SendParams struct {
To string `json:"to"`
Code string `json:"code,omitempty"`
Locale string `json:"locale,omitempty"`
IdempotencyKey string `json:"-"`
}
SendParams carries a destination and optional code, locale and idempotency key. An empty Code lets the API generate a code; an empty Locale uses its default.
type SendResponse ¶
type SendResponse struct {
ID string `json:"id"`
Status string `json:"status"`
Verification string `json:"verification"`
Mode string `json:"mode"`
Channel *string `json:"channel"`
From *string `json:"from"`
ExpiresAt time.Time `json:"expires_at"`
CreatedAt time.Time `json:"created_at"`
SentAt *time.Time `json:"sent_at"`
DeliveredAt *time.Time `json:"delivered_at"`
ReadAt *time.Time `json:"read_at"`
VerifiedAt *time.Time `json:"verified_at"`
FailedAt *time.Time `json:"failed_at"`
FailureReason *string `json:"failure_reason"`
}
SendResponse preserves JSON nulls as nil pointers and timestamps as time.Time. State strings remain open to values added by future API versions.
type VerifyResponse ¶
type VerifyResponse struct {
Valid bool `json:"valid"`
Verification string `json:"verification"`
AttemptsLeft int `json:"attempts_left"`
}
VerifyResponse records one verification attempt, including an invalid code.