appleauth

package
v1.261110.0 Latest Latest
Warning

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

Go to latest
Published: Nov 10, 2026 License: MIT Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	TwoFactorMethodTrustedDevice = "trusted-device"
	TwoFactorMethodPhone         = "phone"
	TwoFactorMethodSecurityKey   = "security-key"
)
View Source
const TwoFactorDeliverySMS = "sms"

TwoFactorDeliverySMS asks Apple to text the verification code to a trusted phone number even when trusted devices could receive it.

Variables

View Source
var ErrNoTrustedPhoneNumbers = errors.New("no trusted phone numbers available")
View Source
var ErrTwoFactorCodeRejected = errors.New("two-factor code rejected")

ErrTwoFactorCodeRejected reports a verification code Apple refused.

Functions

func DoTwoFactorJSONRequest

func DoTwoFactorJSONRequest(ctx context.Context, client *http.Client, headers http.Header, stage, method, requestURL string, payload any, marshalPayload func(any) ([]byte, error), setModifiedCookieHeader func(*http.Request), log RequestLogger) (int, []byte, error)

func ExtractServiceErrorCodes

func ExtractServiceErrorCodes(respBody []byte) []string

func IsAppleAccountActionRequiredSigninComplete

func IsAppleAccountActionRequiredSigninComplete(status int, respBody []byte) bool

func SubmitTwoFactorCode

func SubmitTwoFactorCode(ctx context.Context, session SessionState, code string, getAuthOptions func(context.Context) (*AuthOptions, error), requestPhoneCode func(context.Context, int, string) error, submitTrustedDeviceCode func(context.Context, string) error, submitPhoneCode func(context.Context, string, int, string) error, finalize func(context.Context) error) error

Types

type AuthOptions

type AuthOptions struct {
	NoTrustedDevices    bool
	TrustedPhoneNumbers []TrustedPhoneNumber
	SecurityKey         *SecurityKeyChallenge
}

type AuthOptionsResponse

type AuthOptionsResponse struct {
	FSAChallenge        json.RawMessage      `json:"fsaChallenge"`
	NoTrustedDevices    bool                 `json:"noTrustedDevices"`
	TrustedDevices      []map[string]any     `json:"trustedDevices"`
	TrustedPhoneNumbers []TrustedPhoneNumber `json:"trustedPhoneNumbers"`
	SecurityCode        struct {
		Length int `json:"length"`
	} `json:"securityCode"`
}

func (*AuthOptionsResponse) AuthOptions

func (opts *AuthOptionsResponse) AuthOptions() *AuthOptions

type MarshalPayloadError

type MarshalPayloadError struct {
	Err error
}

func (*MarshalPayloadError) Error

func (e *MarshalPayloadError) Error() string

func (*MarshalPayloadError) Unwrap

func (e *MarshalPayloadError) Unwrap() error

type PhoneCodeRequestedError

type PhoneCodeRequestedError struct {
	Destination string
	Err         error
}

func (*PhoneCodeRequestedError) Error

func (e *PhoneCodeRequestedError) Error() string

func (*PhoneCodeRequestedError) Unwrap

func (e *PhoneCodeRequestedError) Unwrap() error

type RequestLogger

type RequestLogger func(stage string, req *http.Request, resp *http.Response, body []byte, err error)

type SecurityKeyChallenge

type SecurityKeyChallenge struct {
	Challenge          string `json:"challenge"`
	AllowedCredentials string `json:"allowedCredentials"`
}

SecurityKeyChallenge is Apple's FSA challenge returned by the web sign-in service. AllowedCredentials is a comma-separated list of credential IDs.

type SessionState

type SessionState interface {
	TwoFactorMethod() string
	TwoFactorPhoneID() int
	TwoFactorPhoneMode() string
	TwoFactorDestination() string
	TwoFactorCodeRequested() bool
	TwoFactorPreference() TwoFactorPreference
	SetPreparedTwoFactorState(method string, phoneID int, phoneMode, destination string, requested bool)
	SetTwoFactorCodeRequested(requested bool)
}

type TrustedPhoneNumber

type TrustedPhoneNumber struct {
	ID                 int    `json:"id"`
	PushMode           string `json:"pushMode"`
	NumberWithDialCode string `json:"numberWithDialCode"`
}

type TrustedPhoneSelectionError

type TrustedPhoneSelectionError struct {
	RequestedID int
	Phones      []TrustedPhoneNumber
}

TrustedPhoneSelectionError reports that the requested trusted phone number could not be resolved. RequestedID is zero when several numbers matched.

func (*TrustedPhoneSelectionError) Error

type TwoFactorChallenge

type TwoFactorChallenge struct {
	Method                 string
	Destination            string
	Requested              bool
	PhoneFallbackAvailable bool
	SecurityKey            *SecurityKeyChallenge
}

func EnsureTwoFactorCodeRequested

func EnsureTwoFactorCodeRequested(ctx context.Context, session SessionState, getAuthOptions func(context.Context) (*AuthOptions, error), requestPhoneCode func(context.Context, int, string) error) (*TwoFactorChallenge, error)

func PrepareTwoFactorChallenge

func PrepareTwoFactorChallenge(ctx context.Context, session SessionState, getAuthOptions func(context.Context) (*AuthOptions, error)) (*TwoFactorChallenge, error)

func (*TwoFactorChallenge) IsPhoneMethod

func (c *TwoFactorChallenge) IsPhoneMethod() bool

IsPhoneMethod reports whether the challenge uses Apple phone-code delivery.

type TwoFactorPreference

type TwoFactorPreference struct {
	Delivery string
	// PhoneID selects a trusted phone number; zero means the only one.
	PhoneID int
}

TwoFactorPreference is the caller's requested verification delivery. The zero value keeps Apple's default: trusted devices first, phone fallback after.

type UnsupportedTwoFactorMethodError

type UnsupportedTwoFactorMethodError struct {
	Method string
}

func (*UnsupportedTwoFactorMethodError) Error

Jump to

Keyboard shortcuts

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