Help us shape the future of Go! Take the 2026 Go Developer Survey

appleauth

package
v1.260331.0 Latest Latest
Warning

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

Go to latest
Published: Mar 31, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

View Source
const (
	TwoFactorMethodTrustedDevice = "trusted-device"
	TwoFactorMethodPhone         = "phone"
)

Variables

View Source
var ErrNoTrustedPhoneNumbers = errors.New("no trusted phone numbers available")

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
}

type AuthOptionsResponse

type AuthOptionsResponse struct {
	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 SessionState

type SessionState interface {
	TwoFactorMethod() string
	TwoFactorPhoneID() int
	TwoFactorPhoneMode() string
	TwoFactorDestination() string
	TwoFactorCodeRequested() bool
	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 TwoFactorChallenge

type TwoFactorChallenge struct {
	Method                 string
	Destination            string
	Requested              bool
	PhoneFallbackAvailable bool
}

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 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