icloud

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 7, 2021 License: MIT Imports: 21 Imported by: 0

Documentation

Index

Constants

View Source
const (
	AuthEndpoint  = "https://idmsa.apple.com/appleauth/auth"
	HomeEndpoint  = "https://www.icloud.com"
	SetupEndpoint = "https://setup.icloud.com/setup/ws/1"
	DefUserAgent  = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/74.0.3729.169 Safari/537.36"
)

API endpoints

Variables

View Source
var (
	ErrServiceNotActive  = NewErr("icloud service not activated")
	ErrLoginFailed       = NewErr("icloud login failed")
	Err2SARequired       = NewErr("2-step authentication required for account")
	ErrNoStoredPassword  = NewErr("no stored icloud password available")
	ErrNoDevices         = NewErr("no icloud device")
	ErrWrongVerification = NewErr("wrong verification code")
	ErrNotFound          = NewErr("path not found")
	ErrNotDir            = NewErr("path is not a directory")
	ErrNotFile           = NewErr("path is not a file")
)
View Source
var Debug = false

Functions

func Marshal

func Marshal(v interface{}) []byte

func ReadLine

func ReadLine(prompt string) string

Types

type Client

type Client struct {
	Client *http.Client
	// contains filtered or unexported fields
}

Client is iCloud API client

func NewClient

func NewClient(appleID, password, dataRoot, userAgent string) (*Client, error)

New returns API client

func NewClientWithOptions

func NewClientWithOptions(client *http.Client, appleID, password, userAgent, sessPath string, verify, withFamily bool) (*Client, error)

NewClientWithOptions returns client with extra options

func (*Client) Authenticate

func (c *Client) Authenticate(force_refresh bool, service string) (err error)

Authenticate handles authentication, and persists cookies so that subsequent logins will not cause additional e-mails from Apple.

func (*Client) IsTrustedSession

func (c *Client) IsTrustedSession() bool

IsTrustedSession returns true if current session is trusted.

func (*Client) Requires2FA

func (c *Client) Requires2FA() bool

Requires2FA returns true if 2-factor authentication is required.

func (*Client) Requires2SA

func (c *Client) Requires2SA() bool

Requires2SA returns true if 2-step authentication is required.

func (*Client) SendVerificationCode

func (c *Client) SendVerificationCode(dev *api.Device) error

SendVerificationCode makes iCloud send verification code to a device

func (*Client) TrustSession

func (c *Client) TrustSession() error

TrustSession requests session trust to avoid user log in going forward.

func (*Client) TrustedDevices

func (c *Client) TrustedDevices() ([]api.Device, error)

TrustedDevices returns slice of trusted devices

func (*Client) Validate2FACode

func (c *Client) Validate2FACode(code string) error

Validate2FACode verifies a code received via Apple's 2FA system (HSA2).

func (*Client) ValidateVerificationCode

func (c *Client) ValidateVerificationCode(dev *api.Device, code string) error

ValidateVerificationCode received on a device

type DriveNode

type DriveNode struct {
	// contains filtered or unexported fields
}

DriveNode ...

func (*DriveNode) Changed

func (n *DriveNode) Changed() time.Time

Changed time of node

func (*DriveNode) Children

func (n *DriveNode) Children() ([]*DriveNode, error)

Children of node

func (*DriveNode) Delete

func (n *DriveNode) Delete() error

Delete an iCloud Drive item

func (*DriveNode) Dir

func (n *DriveNode) Dir() ([]string, error)

func (*DriveNode) Download

func (n *DriveNode) Download(path string) error

Download node into local file

func (*DriveNode) Get

func (n *DriveNode) Get(name string) (*DriveNode, error)

func (*DriveNode) IsDir

func (n *DriveNode) IsDir() bool

IsDir returns true if node is a folder, false if it's a file

func (*DriveNode) LastOpened

func (n *DriveNode) LastOpened() time.Time

LastOpened time of node

func (*DriveNode) Mkdir

func (n *DriveNode) Mkdir(folder string) error

Mkdir creates new directory

func (*DriveNode) Modified

func (n *DriveNode) Modified() time.Time

Modified time of node

func (*DriveNode) Name

func (n *DriveNode) Name() string

Name of node

func (*DriveNode) Open

func (n *DriveNode) Open() (io.ReadCloser, error)

Open file for reading

func (*DriveNode) PutStream

func (n *DriveNode) PutStream(in io.Reader, path string, size int64, mtime time.Time) error

PutStream uploads a file stream to a folder

func (*DriveNode) Rename

func (n *DriveNode) Rename(newName string) error

Rename a node

func (*DriveNode) Size

func (n *DriveNode) Size() int64

Size of node

func (*DriveNode) Stale added in v0.0.2

func (n *DriveNode) Stale()

Stale forces node refresh

func (*DriveNode) Type

func (n *DriveNode) Type() string

Type of node

func (*DriveNode) Upload

func (n *DriveNode) Upload(path string) error

Upload new file to a folder

type DriveService

type DriveService struct {
	// contains filtered or unexported fields
}

DriveService describes the Drive iCloud service

func NewDrive

func NewDrive(c *Client) (d *DriveService, err error)

NewDrive returns new Drive service

func (*DriveService) Root

func (d *DriveService) Root() (*DriveNode, error)

Root returns root folder

type ErrAPI

type ErrAPI struct {
	ErrApple
	Code  int
	Retry bool
}

ErrAPI is subclass of API related iCloud errors

func NewErrAPI

func NewErrAPI(code int, status string, reason string, retry bool) ErrAPI

NewErrAPIResponse returns new API related iCloud error

type ErrApple

type ErrApple error

func NewErr

func NewErr(msg string) ErrApple

NewErr returns generic Apple iCloud error

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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