common

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2023 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrKeyPassOrSaltedKeyPassMustBeNotNil = errors.New("either keyPass or saltedKeyPass must be not nil")
	ErrFailedToUnlockUserKeys             = errors.New("failed to unlock user keys")

	ErrUsernameAndPasswordRequired = errors.New("username and password are required")
	Err2FACodeRequired             = errors.New("this account requires a 2FA code. Can be provided with --protondrive-2fa=000000")
	ErrMailboxPasswordRequired     = errors.New("this account requires a mailbox password")
)

Functions

func Logout

func Logout(ctx context.Context, config *Config, m *proton.Manager, c *proton.Client, userKR *crypto.KeyRing, addrKRs map[string]*crypto.KeyRing) error

Types

type Config

type Config struct {
	/* Constants */
	AppVersion string
	UserAgent  string

	/* Login */
	FirstLoginCredential *FirstLoginCredentialData
	ReusableCredential   *ReusableCredentialData
	UseReusableLogin     bool
	CredentialCacheFile  string // If CredentialCacheFile is empty, no credential will be logged

	/* Setting */
	DestructiveIntegrationTest     bool // CAUTION: the integration test requires a clean proton drive
	EmptyTrashAfterIntegrationTest bool // CAUTION: the integration test will clean up all the data in the trash
	ReplaceExistingDraft           bool // for the file upload replace or keep it as-is option
	EnableCaching                  bool // link node caching
	ConcurrentBlockUploadCount     int
	ConcurrentFileCryptoCount      int

	/* Drive */
	DataFolderName string
}

func NewConfigForIntegrationTests

func NewConfigForIntegrationTests() *Config

func NewConfigWithDefaultValues

func NewConfigWithDefaultValues() *Config

type FirstLoginCredentialData

type FirstLoginCredentialData struct {
	Username        string
	Password        string
	MailboxPassword string
	TwoFA           string
}

type ProtonDriveCredential

type ProtonDriveCredential struct {
	UID           string
	AccessToken   string
	RefreshToken  string
	SaltedKeyPass string
}

func Login

func Login(ctx context.Context, config *Config, authHandler proton.AuthHandler, deAuthHandler proton.Handler) (*proton.Manager, *proton.Client, *ProtonDriveCredential, *crypto.KeyRing, map[string]*crypto.KeyRing, map[string]proton.Address, error)

Log in methods - username and password to log in - UID and refresh token

Keyring decryption The password will be salted, and then used to decrypt the keyring. The salted password needs to be and can be cached, so the keyring can be re-decrypted when needed

type ReusableCredentialData

type ReusableCredentialData struct {
	UID           string
	AccessToken   string
	RefreshToken  string
	SaltedKeyPass string // []byte <-> base64
}

Jump to

Keyboard shortcuts

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