icloud

package
v0.0.0-...-2a2380d Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2024 License: MIT Imports: 16 Imported by: 1

Documentation

Index

Constants

View Source
const (
	ProtocolVersion = "QH5B2"
	OAuthClientID   = "d39ba9916b7251055b22c7f910e2ea796ee65e98b2ddecea8f5dde8d9d1a815d"
)
View Source
const (
	HdrContentType       = "Content-Type"
	HdrXRequestedWith    = "X-Requested-With"
	HdrXAppleWidgetKey   = "X-Apple-Widget-Key"
	HdrAccept            = "Accept"
	HdrXAppleIDSessionID = "X-Apple-ID-Session-Id"
	HdrScnt              = "scnt"
)

Variables

View Source
var (
	ErrIncorrectUsernamePassword = errors.New("incorrect username or password")
	ErrRequiredPrivacyAck        = errors.New("sign in to https://appleid.apple.com and acknowledge the Apple ID and Privacy agreement")
	ErrUnexpectedSigninResponse  = errors.New("unexpected sign in response")
	ErrNotImplemented            = errors.New("not implemented")
	ErrSeverErrorOrInvalidCreds  = errors.New("apple server error or invalid credentials")
)

Functions

This section is empty.

Types

type AuthCompleteReq

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

type AuthInitReq

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

type AuthInitResp

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

type BIMI

type BIMI struct {
	Status string `json:"status"`
}

type Client

type Client struct {
	HttpClient tls_client.HttpClient

	OtpChannel chan string

	Username string
	Password string
	// contains filtered or unexported fields
}

func NewClient

func NewClient(username, password string, sniff bool) (*Client, error)

* NewClient intializes a new http client and returns a new icloud client

func (*Client) DeactivateHME

func (c *Client) DeactivateHME(anonymousId string) (bool, error)

* DeactivateHME() Deactivates an HME from the user's account, using the given anonymousId. Can be reactivated later

func (*Client) DeleteHME

func (c *Client) DeleteHME(anonymousId string) (bool, error)

* DeleteHME() Deletes an HME from the user's account, using the given anonymousId. Can not be recovered later

func (*Client) DeleteMail

func (c *Client) DeleteMail(uid string) (bool, error)

* DeleteMail() deletes an email from the user's inbox using the uid

func (*Client) DraftMail

func (c *Client) DraftMail(fromEmail, toEmail, subject, textBody, body string) (string, error)

* DraftMail() drafts and saves an email to the user's draft folder. fromName is the name of the sender, fromEmail is the email of the sender, toName is the name of the recipient, toEmail is the email of the recipient, subject is the subject of the email, textBody is the text body of the email, body is the full html body of the email

func (*Client) GetMessage

func (c *Client) GetMessage(uid string) (Message, error)

* GetMessage() retrieves the message from the user's inbox using the uid, and returns the full body html of the email

func (*Client) GetMessageMetadata

func (c *Client) GetMessageMetadata(threadId string) (MessageMetadata, error)

* GetMessage() retrieves the message metadata from the user's inbox using the threadId

func (*Client) Login

func (c *Client) Login() error

* Login() logs in to iCloud and authenticates the user to access any iCloud web app/service

func (*Client) ReactivateHME

func (c *Client) ReactivateHME(anonymousId string) (bool, error)

* ReactivateHME() Reactivates an HME for a user's account, using the given anonymousId

func (*Client) ReserveHME

func (c *Client) ReserveHME(label, note string) (string, error)

* ReserveHME() Generates a new HME and reserves it, if successful it returns the email to user

func (*Client) RetrieveHMEList

func (c *Client) RetrieveHMEList() ([]HmeEmail, error)

* RetrieveHMEList() Retrieves a list of HMEs from the user's account

func (*Client) RetrieveMailInbox

func (c *Client) RetrieveMailInbox(maxResults, beforeTs int) (MailInboxResp, error)

* RetrieveMailInbox() retrieves the user's inbox from their iCloud account, maxResults is the maximum number of emails to retrieve, beforeTs is the timestamp to retrieve emails before

func (*Client) SendDraft

func (c *Client) SendDraft(uid string) (bool, error)

* SendDraft() sends an email from the user's draft folder using the uid

type HMEListResp

type HMEListResp struct {
	Success   bool   `json:"success"`
	Timestamp int    `json:"timestamp"`
	Result    Result `json:"result"`
}

type HmeEmail

type HmeEmail struct {
	Origin          string `json:"origin"`
	AnonymousID     string `json:"anonymousId"`
	Domain          string `json:"domain"`
	ForwardToEmail  string `json:"forwardToEmail"`
	Hme             string `json:"hme"`
	Label           string `json:"label"`
	Note            string `json:"note"`
	CreateTimestamp int64  `json:"createTimestamp"`
	IsActive        bool   `json:"isActive"`
	RecipientMailID string `json:"recipientMailId"`
	OriginAppName   string `json:"originAppName,omitempty"`
	AppBundleID     string `json:"appBundleId,omitempty"`
}

type MailDraftReq

type MailDraftReq struct {
	Jsonrpc string `json:"jsonrpc"`
	Method  string `json:"method"`
	Params  Params `json:"params"`
}

type MailInboxResp

type MailInboxResp struct {
	TotalThreadsReturned int            `json:"totalThreadsReturned"`
	ThreadList           []Thread       `json:"threadList"`
	SessionHeaders       SessionHeaders `json:"sessionHeaders"`
	Events               []any          `json:"events"`
}

type Message

type Message struct {
	GUID           string         `json:"guid"`
	LongHeader     string         `json:"longHeader"`
	To             []string       `json:"to"`
	From           []string       `json:"from"`
	Cc             []string       `json:"cc"`
	Bcc            []string       `json:"bcc"`
	ContentType    string         `json:"contentType"`
	Bimi           BIMI           `json:"bimi"`
	Smime          SMIME          `json:"smime"`
	Parts          []MsgPart      `json:"parts"`
	SessionHeaders SessionHeaders `json:"sessionHeaders"`
	Events         []any          `json:"events"`
}

type MessageMetadata

type MessageMetadata struct {
	UID       string   `json:"uid"`
	Date      int64    `json:"date"`
	Size      int      `json:"size"`
	Folder    string   `json:"folder"`
	Modseq    int64    `json:"modseq"`
	Flags     []any    `json:"flags"`
	SentDate  string   `json:"sentDate"`
	Subject   string   `json:"subject"`
	From      []string `json:"from"`
	To        []string `json:"to"`
	Cc        []any    `json:"cc"`
	Bcc       []any    `json:"bcc"`
	Bimi      BIMI     `json:"bimi"`
	Smime     SMIME    `json:"smime"`
	MessageID string   `json:"messageId"`
	Parts     []Part   `json:"parts"`
}

type MsgPart

type MsgPart struct {
	GUID    string `json:"guid"`
	Content string `json:"content"`
}

type Params

type Params struct {
	From               string `json:"from"`
	To                 string `json:"to"`
	Subject            string `json:"subject"`
	TextBody           string `json:"textBody"`
	Body               string `json:"body"`
	Attachments        []any  `json:"attachments"`
	WebmailClientBuild string `json:"webmailClientBuild"`
}

type Part

type Part struct {
	JSONType    string `json:"jsonType"`
	ContentType string `json:"contentType"`
	Params      string `json:"params"`
	Encoding    string `json:"encoding"`
	Size        int    `json:"size"`
	PartID      string `json:"partId"`
	Lines       int    `json:"lines"`
	IsAttach    bool   `json:"isAttach"`
}

type PhoneNumberID

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

type Result

type Result struct {
	ForwardToEmails   []string   `json:"forwardToEmails"`
	HmeEmails         []HmeEmail `json:"hmeEmails"`
	SelectedForwardTo string     `json:"selectedForwardTo"`
}

type SMIME

type SMIME struct {
	Status string `json:"status"`
}

type SecurityCode

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

type ServiceError

type ServiceError struct {
	Code    string `json:"code,omitempty"`
	Title   string `json:"title,omitempty"`
	Message string `json:"message,omitempty"`
}

ServiceError represents a Apple service error.

type SessionHeaders

type SessionHeaders struct {
	Folder       string `json:"folder"`
	Modseq       int64  `json:"modseq"`
	Threadmodseq int64  `json:"threadmodseq"`
	Condstore    int    `json:"condstore"`
	Qresync      int    `json:"qresync"`
	Threadmode   int    `json:"threadmode"`
}

type Thread

type Thread struct {
	JSONType           string   `json:"jsonType"`
	ThreadID           string   `json:"threadId"`
	Timestamp          int64    `json:"timestamp"`
	Count              int      `json:"count"`
	FolderMessageCount int      `json:"folderMessageCount"`
	Flags              []string `json:"flags"`
	Senders            []string `json:"senders"`
	Subject            string   `json:"subject"`
	Preview            string   `json:"preview"`
	Modseq             int64    `json:"modseq"`
}

type TwoFactorCodeFromPhoneRequest

type TwoFactorCodeFromPhoneRequest struct {
	SecurityCode *SecurityCode  `json:"securityCode,omitempty"`
	PhoneNumber  *PhoneNumberID `json:"phoneNumber,omitempty"`
	Mode         string         `json:"mode,omitempty"`
}

Jump to

Keyboard shortcuts

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