protonsession

package module
v0.1.14 Latest Latest
Warning

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

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

README

Proton Go API Session Wrapper

Introduction

This package provides a basic session management swrapper around the Proton Go API package to enable login to the API via Username and Password or with previously stored Credentials.

This package provides a basic file storage method for storing credentials, this is provided as basic implementation and is not considered secure by any means as the credentials are stored within a text file on the system.

This code is licensed under the MIT license contained in the LICENSE file.

Code and Documentation Copyright © 1994-2025, Stephen Kapp and Reaper Technologies Limited.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrorMissingUID          = errors.New("missing UID")
	ErrorMissingAccessToken  = errors.New("missing access token")
	ErrorMissingRefreshToken = errors.New("missing refresh token")
	ErrKeyNotFound           = errors.New("key not found")
	ErrFileNotFound          = errors.New("file not found")
)

Functions

func Base64Decode

func Base64Decode(str string) ([]byte, error)

func Base64Encode

func Base64Encode(data []byte) string

func SaltKeyPass

func SaltKeyPass(ctx context.Context, client *p.Client, password []byte) ([]byte, error)

Salt the provided keypass. The salted keypass is used to Unlock() the account.

Types

type FileStore

type FileStore struct {
	CacheDir bool
	// contains filtered or unexported fields
}

func NewFileStore

func NewFileStore(filename string, account string) *FileStore

func (*FileStore) Delete

func (fs *FileStore) Delete() error

func (*FileStore) List

func (fs *FileStore) List() ([]string, error)

func (*FileStore) Load

func (fs *FileStore) Load() (*SessionConfig, error)

func (*FileStore) Save

func (fs *FileStore) Save(session *SessionConfig) error

func (*FileStore) Switch

func (fs *FileStore) Switch(account string) error

type Manager

type Manager p.Manager

type Session

type Session struct {
	Client *proton.Client
	Auth   proton.Auth

	MaxWorkers int

	UserKeyRing *crypto.KeyRing
	// contains filtered or unexported fields
}

func SessionFromCredentials

func SessionFromCredentials(ctx context.Context, options []proton.Option, creds *SessionCredentials) (*Session, error)

Create Session from provided Session credentials. Returns a populated session object

func SessionFromLogin

func SessionFromLogin(ctx context.Context, options []proton.Option, username string, password string) (*Session, error)

Create Session using provided Login Information, returns pointer to session object

func SessionFromRefresh

func SessionFromRefresh(ctx context.Context, options []proton.Option, creds *SessionCredentials) (*Session, error)

Create Session using the provided AuthToken and RefreshToken, returns a populated session object

type SessionConfig

type SessionConfig = struct {
	UID           string `json:"uid"`
	AccessToken   string `json:"access_token"`
	RefreshToken  string `json:"refresh_token"`
	SaltedKeyPass string
}

type SessionCredentials

type SessionCredentials struct {
	UID          string `json:"uid"`
	AccessToken  string `json:"access_token"`
	RefreshToken string `json:"refresh_token"`
}

type SessionOptions

type SessionOptions struct {
	MaxWorkers int
}

type SessionStore

type SessionStore interface {
	Load() (*SessionConfig, error)
	Save(session *SessionConfig) error
	Delete() error
	List() ([]string, error)
	Switch(account string) error
}

Jump to

Keyboard shortcuts

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