appleid

package
v0.0.0-...-3bed8bd Latest Latest
Warning

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

Go to latest
Published: Jan 17, 2024 License: AGPL-3.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

View Source
const (
	UserAgent      = "Mozilla/5.0 (X11; Linux x86_64; rv:120.0) Gecko/20100101 Firefox/120.0"
	Language       = "en-GB"
	AcceptLanguage = Language + ",en-US;q=0.7,en;q=0.3"
	TimeZone       = "GMT+00:00"
	TimeZoneName   = "Europe/London"
)

Constants that depend on the browser and device

View Source
const (
	AppleIDBaseURL = "https://appleid.apple.com"
	APIKey         = "cbf64fd6843ee630b463f358ea0b707b"

	OAuthClientID     = "af1139274f266b22b68c2a3e7ad932cb3c0bbe854e13a79af78dcc73136882c3"
	OAuthRedirectURI  = AppleIDBaseURL
	OAuthResponseType = "code"
	OAuthResponseMode = "web_message"

	HdrValFDClientInfoVersion = "1.1"
	HdrValRequestContext      = "ca"
	HdrValDocumentAccept      = "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,*/*;q=0.8"
)

Static constants

View Source
const (
	HdrAuthAttributes = "X-Apple-Auth-Attributes"
	HdrAuthSessionID  = "X-Apple-ID-Session-Id"
	HdrScnt           = "scnt"
)

Custom header names that are used in multiple places

Variables

View Source
var ErrStandardAdditionalAuthNeeded = &AdditionalAuthenticationNeededError{Type: "STANDARD"}

Functions

This section is empty.

Types

type AdditionalAuthenticateRequest

type AdditionalAuthenticateRequest struct {
	Password string `json:"password"`
}

type AdditionalAuthenticationNeededError

type AdditionalAuthenticationNeededError struct {
	Type                 string `json:"type"`
	FormattedAccountName string `json:"formattedAccountName"`
}

func (*AdditionalAuthenticationNeededError) Error

func (*AdditionalAuthenticationNeededError) Is

type AdditionalBootArgs

type AdditionalBootArgs struct {
	CanRoute2SV bool `json:"canRoute2sv"`
}

type AppSpecificPassword

type AppSpecificPassword struct {
	ID                  int    `json:"id"`
	CreateDatetime      string `json:"createDatetime"`
	LocalizedCreateDate string `json:"localizedCreateDate"`
	CreateDate          string `json:"createDate"`
	Description         string `json:"description"`
}

type AuthMeta

type AuthMeta struct {
	FutureReservedAuthUIModes []string `json:"futureReservedAuthUIModes"`
	SupportedAuthUIModes      []string `json:"supportedAuthUIModes"`
	FEConfiguration           struct {
		PmrpcTimeout            string `json:"pmrpcTimeout"`
		EnableAllowAttribute    bool   `json:"enableAllowAttribute"`
		EnableSwpAuth           bool   `json:"enableSwpAuth"`
		IsEyebrowTextboxEnabled bool   `json:"isEyebrowTextboxEnabled"`
		SkVersion               string `json:"skVersion"`
		PmrpcRetryCount         string `json:"pmrpcRetryCount"`
		JSLogLevel              string `json:"jsLogLevel"`
		AppLoadDelay            string `json:"appLoadDelay"`
		EnablePerformanceLog    bool   `json:"enablePerformanceLog"`
	} `json:"FEConfiguration"`
}

type BootArgs

type BootArgs struct {
	Direct     DirectBootArgs     `json:"direct"`
	Additional AdditionalBootArgs `json:"additional"`
}

type Client

type Client struct {
	HTTP http.Client
	SCNT map[string]string
	SRP  *srp6apple.SRPClient

	AuthID         string
	AuthSessionID  string
	AuthAttributes []byte

	HashcashParams *HashcashParams
	RememberMe     bool
	Username       string
	InitResp       *InitResponse

	SMSRequestedFrom int
	SMSRequestedMode string
}

func NewClient

func NewClient() *Client

func (*Client) CreateAppSpecificPassword

func (cli *Client) CreateAppSpecificPassword(ctx context.Context, description string) (*CreateAppSpecificPasswordResponse, error)

func (*Client) DeleteAppSpecificPasswords

func (cli *Client) DeleteAppSpecificPasswords(ctx context.Context, id int) error

func (*Client) EnterPassword

func (cli *Client) EnterPassword(ctx context.Context, password string) (*TwoFactorInfo, error)

func (*Client) EnterUsername

func (cli *Client) EnterUsername(ctx context.Context, username string, rememberMe bool) error

func (*Client) GetAppSpecificPasswords

func (cli *Client) GetAppSpecificPasswords(ctx context.Context) (GetAppSpecificPasswordsResponse, error)

func (*Client) Prepare

func (cli *Client) Prepare(ctx context.Context) error

func (*Client) RequestSMS2FA

func (cli *Client) RequestSMS2FA(ctx context.Context, pushMode string, phoneNumID int) error

func (*Client) RerequestTrustedDevice2FA

func (cli *Client) RerequestTrustedDevice2FA(ctx context.Context) error

func (*Client) Submit2FA

func (cli *Client) Submit2FA(ctx context.Context, code string) (err error)

func (*Client) SubmitStandardAdditionalAuth

func (cli *Client) SubmitStandardAdditionalAuth(ctx context.Context, password string) error

type CompleteErrorResponse

type CompleteErrorResponse struct {
	ServiceErrors []struct {
		Code              string `json:"code"` // -20101 for wrong password
		Message           string `json:"message"`
		SuppressDismissal bool   `json:"suppressDismissal"`
	} `json:"serviceErrors"`
}

type CompleteRequest

type CompleteRequest struct {
	AccountName string `json:"accountName"`
	RememberMe  bool   `json:"rememberMe"`
	M1          []byte `json:"m1"`
	C           string `json:"c"`
	M2          []byte `json:"m2"`
}

type CompleteResponse

type CompleteResponse struct {
	AuthType string `json:"authType"`
}

type CreateAppSpecificPasswordRequest

type CreateAppSpecificPasswordRequest struct {
	Description string `json:"description"`
}

type CreateAppSpecificPasswordResponse

type CreateAppSpecificPasswordResponse struct {
	AppSpecificPassword
	Password string `json:"password"`
}

type DirectBootArgs

type DirectBootArgs struct {
	// Shared
	ScriptSk7URL string `json:"scriptSk7Url"`

	// Only initial login
	IsPasswordSecondStep             bool           `json:"isPasswordSecondStep"`
	IsFederatedAuthEnabled           bool           `json:"isFederatedAuthEnabled"`
	AccountNameAutoComplete          string         `json:"accountNameAutoComplete"`
	AccountName                      string         `json:"accountName"`
	URLBag                           URLBag         `json:"urlBag"`
	RefererURL                       string         `json:"refererUrl"`
	AuthAttributes                   []byte         `json:"authAttributes"`
	IsRaFF                           bool           `json:"isRaFF"`
	ForgotPassword                   bool           `json:"forgotPassword"`
	SwpAuth                          bool           `json:"swpAuth"`
	TwoFactorAuthEnv                 int            `json:"twoFactorAuthEnv"`
	CountryCode                      string         `json:"countryCode"`
	IsInterstitialFedAuthPageEnabled bool           `json:"isInterstitialFedAuthPageEnabled"`
	TwoFactorAuthAppKey              []byte         `json:"twoFactorAuthAppKey"`
	IsRTL                            string         `json:"isRtl"`
	Hashcash                         HashcashParams `json:"hashcash"`
	WebSRPClientWorkerScriptTag      string         `json:"webSRPClientWorkerScriptTag"`
	IsRaIDP                          bool           `json:"isRaIdp"`
	AcURL                            string         `json:"acUrl"`
	EnableSRPAuth                    bool           `json:"enableSRPAuth"`
	DomainID                         int            `json:"domainId"`
	ShouldSuppressIForgotLink        bool           `json:"shouldSuppressIForgotLink"`
	DisableChromeAutoComplete        bool           `json:"disableChromeAutoComplete"`
	GenerateHashcashScriptTag        string         `json:"generateHashcashScriptTag"`
	IframeID                         string         `json:"iframeId"`
	Meta                             AuthMeta       `json:"meta"`
	EnableFPN                        bool           `json:"enableFpn"`
	EnableSecurityKeyIndividual      bool           `json:"enableSecurityKeyIndividual"`
	ShowSwpAuth                      bool           `json:"showSwpAuth"`

	// Only two-factor
	ScriptURL         string        `json:"scriptUrl"`
	Module            string        `json:"module"`
	IsReact           bool          `json:"isReact"`
	AuthUserType      string        `json:"authUserType"`
	HasTrustedDevices bool          `json:"hasTrustedDevices"`
	TwoSV             TwoSVBootArgs `json:"twoSV"`
	ReferrerQuery     string        `json:"referrerQuery"`
	URLContext        string        `json:"urlContext"`
	Tag               string        `json:"tag"`
	AuthType          string        `json:"authType"`
	AuthInitialRoute  string        `json:"authInitialRoute"`
	AppleIDURL        string        `json:"appleIDUrl"`
}

type FederateRequest

type FederateRequest struct {
	AccountName string `json:"accountName"`
	RememberMe  bool   `json:"rememberMe"`
}

type FederateResponse

type FederateResponse struct {
	ShowFederatedIdPConfirmation bool `json:"showFederatedIdpConfirmation"`
	Federated                    bool `json:"federated"`
}

type GetAppSpecificPasswordsResponse

type GetAppSpecificPasswordsResponse []*AppSpecificPassword

type HashcashParams

type HashcashParams struct {
	GenerationTimeout int    `json:"hashcashGenerationTimeout"`
	Challenge         string `json:"hcChallenge"`
	Bits              int    `json:"hcBits,string"`
	IsStrictTimeout   bool   `json:"isHCstrictTimeout"`
}

func (*HashcashParams) Compute

func (hp *HashcashParams) Compute() string

type InitRequest

type InitRequest struct {
	A           []byte   `json:"a"`
	AccountName string   `json:"accountName"`
	Protocols   []string `json:"protocols"`
}

type InitResponse

type InitResponse struct {
	Iteration int    `json:"iteration"`
	Salt      []byte `json:"salt"`
	Protocol  string `json:"protocol"`
	B         []byte `json:"b"`
	C         string `json:"c"`
}

type PhoneNumberID

type PhoneNumberID struct {
	ID int `json:"id"`
}

type PhoneNumberVerification

type PhoneNumberVerification struct {
	TrustedPhoneNumbers             []TrustedPhoneNumber `json:"trustedPhoneNumbers"`
	PhoneNumber                     TrustedPhoneNumber   `json:"phoneNumber"`
	SecurityCode                    SecurityCodeParams   `json:"securityCode"`
	AuthenticationType              string               `json:"authenticationType"`
	RecoveryURL                     string               `json:"recoveryUrl"`
	CantUsePhoneNumberURL           string               `json:"cantUsePhoneNumberUrl"`
	RecoveryWebURL                  string               `json:"recoveryWebUrl"`
	RepairPhoneNumberURL            string               `json:"repairPhoneNumberUrl"`
	RepairPhoneNumberWebURL         string               `json:"repairPhoneNumberWebUrl"`
	AboutTwoFactorAuthenticationURL string               `json:"aboutTwoFactorAuthenticationUrl"`
	TwoFactorVerificationSupportURL string               `json:"twoFactorVerificationSupportUrl"`
	HasRecoveryKey                  bool                 `json:"hasRecoveryKey"`
	SupportsRecoveryKey             bool                 `json:"supportsRecoveryKey"`
	AutoVerified                    bool                 `json:"autoVerified"`
	ShowAutoVerificationUI          bool                 `json:"showAutoVerificationUI"`
	SupportsCustodianRecovery       bool                 `json:"supportsCustodianRecovery"`
	HideSendSMSCodeOption           bool                 `json:"hideSendSMSCodeOption"`
	SupervisedChangePasswordFlow    bool                 `json:"supervisedChangePasswordFlow"`
	SupportsRecovery                bool                 `json:"supportsRecovery"`
	TrustedPhoneNumber              TrustedPhoneNumber   `json:"trustedPhoneNumber"`
	Hsa2Account                     bool                 `json:"hsa2Account"`
	RestrictedAccount               bool                 `json:"restrictedAccount"`
	ManagedAccount                  bool                 `json:"managedAccount"`
}

type RequestPhoneCodeRequest

type RequestPhoneCodeRequest struct {
	Mode        string        `json:"mode"`
	PhoneNumber PhoneNumberID `json:"phoneNumber"`
}

type RequestSecurityCodeResponse

type RequestSecurityCodeResponse struct{}

type RerequestSecurityCodeResponse

type RerequestSecurityCodeResponse struct {
	TrustedDeviceCount      int                     `json:"trustedDeviceCount"`
	SecurityCode            SecurityCodeParams      `json:"securityCode"`
	PhoneNumberVerification PhoneNumberVerification `json:"phoneNumberVerification"`

	AboutTwoFactorAuthenticationURL string `json:"aboutTwoFactorAuthenticationUrl"`
}

type SecurityCodeParams

type SecurityCodeParams struct {
	Length                int  `json:"length"`
	TooManyCodesSent      bool `json:"tooManyCodesSent"`
	TooManyCodesValidated bool `json:"tooManyCodesValidated"`
	SecurityCodeLocked    bool `json:"securityCodeLocked"`
	SecurityCodeCooldown  bool `json:"securityCodeCooldown"`

	// Only for submit
	Valid bool `json:"valid"`
}

type SecurityCodeWrapper

type SecurityCodeWrapper struct {
	Code string `json:"code"`
}

type SubmitPhoneCodeRequest

type SubmitPhoneCodeRequest struct {
	PhoneNumber  PhoneNumberID       `json:"phoneNumber"`
	SecurityCode SecurityCodeWrapper `json:"securityCode"`
	Mode         string              `json:"mode"`
}

type SubmitPhoneCodeResponse

type SubmitPhoneCodeResponse struct {
	TrustedPhoneNumbers             []TrustedPhoneNumber `json:"trustedPhoneNumbers"`
	PhoneNumber                     TrustedPhoneNumber   `json:"phoneNumber"`
	SecurityCode                    SecurityCodeParams   `json:"securityCode"`
	Mode                            string               `json:"mode"`
	Type                            string               `json:"type"`
	AuthenticationType              string               `json:"authenticationType"`
	RecoveryUrl                     string               `json:"recoveryUrl"`
	CantUsePhoneNumberUrl           string               `json:"cantUsePhoneNumberUrl"`
	RecoveryWebUrl                  string               `json:"recoveryWebUrl"`
	RepairPhoneNumberUrl            string               `json:"repairPhoneNumberUrl"`
	RepairPhoneNumberWebUrl         string               `json:"repairPhoneNumberWebUrl"`
	AboutTwoFactorAuthenticationUrl string               `json:"aboutTwoFactorAuthenticationUrl"`
	AutoVerified                    bool                 `json:"autoVerified"`
	ShowAutoVerificationUI          bool                 `json:"showAutoVerificationUI"`
	SupportsCustodianRecovery       bool                 `json:"supportsCustodianRecovery"`
	HideSendSMSCodeOption           bool                 `json:"hideSendSMSCodeOption"`
	SupervisedChangePasswordFlow    bool                 `json:"supervisedChangePasswordFlow"`
	SupportsRecovery                bool                 `json:"supportsRecovery"`
	TrustedPhoneNumber              TrustedPhoneNumber   `json:"trustedPhoneNumber"`
	Hsa2Account                     bool                 `json:"hsa2Account"`
	RestrictedAccount               bool                 `json:"restrictedAccount"`
	ManagedAccount                  bool                 `json:"managedAccount"`
}

type SubmitSecurityCodeResponse

type SubmitSecurityCodeResponse struct{}

type SubmitTrustedDeviceCodeRequest

type SubmitTrustedDeviceCodeRequest struct {
	SecurityCode SecurityCodeWrapper `json:"securityCode"`
}

type TrustedPhoneNumber

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

type TwoFactorInfo

type TwoFactorInfo struct {
	HasTrustedDevices bool
	PhoneNumberInfo   PhoneNumberVerification
}

type TwoSVBootArgs

type TwoSVBootArgs struct {
	SupportedPushModes      []string                `json:"supportedPushModes"`
	PhoneNumberVerification PhoneNumberVerification `json:"phoneNumberVerification"`
	AuthFactors             []string                `json:"authFactors"`
	SourceReturnURL         string                  `json:"source_returnurl"`
	SourceAppID             int                     `json:"sourceAppId"`
}

type URLBag

type URLBag struct {
	PasswordReset        string `json:"passwordReset"`
	CreateAppleID        string `json:"createAppleID"`
	AppleID              string `json:"appleId"`
	VerificationCodeHelp string `json:"verificationCodeHelp"`
	AccountRecoveryHelp  string `json:"accountRecoveryHelp"`
	CRResetURL           string `json:"crResetUrl"`
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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