Documentation
¶
Overview ¶
Package proton implements types for accessing the Proton API.
Index ¶
- Constants
- Variables
- func BuildRFC822(kr *crypto.KeyRing, msg Message, attData map[string][]byte) ([]byte, error)
- func ChunkSized[T any](vals []T, maxLen, maxSize int, getSize func(T) int) [][]T
- func ClientIDFromContext(ctx context.Context) (uint64, bool)
- func DecodeKeyPacket(packet string) []byte
- func EncryptRFC822(kr *crypto.KeyRing, literal []byte) ([]byte, error)
- func InsecureTransport() *http.Transport
- func NewDropConn(c net.Conn, l *Listener) net.Conn
- func NewHangConn(c net.Conn, l *Listener) net.Conn
- func Unlock(user User, addresses []Address, saltedKeyPass []byte, ...) (*crypto.KeyRing, map[string]*crypto.KeyRing, error)
- func WithClient(parent context.Context, clientID uint64) context.Context
- type APIBool
- type APIError
- type Address
- type AddressEvent
- type AddressStatus
- type AddressType
- type Attachment
- type AttachmentAllocator
- type Auth
- type Auth2FAReq
- type AuthHandler
- type AuthInfo
- type AuthInfoReq
- type AuthModulus
- type AuthRefreshReq
- type AuthReq
- type AuthSession
- type AuthVerifier
- type Block
- type BlockToken
- type BlockUploadInfo
- type BlockUploadLink
- type BlockUploadReq
- type Bool
- type Calendar
- type CalendarAttendee
- type CalendarAttendeeStatus
- type CalendarEvent
- type CalendarEventPart
- type CalendarEventType
- type CalendarFlag
- type CalendarKey
- type CalendarKeyFlag
- type CalendarKeys
- type CalendarMember
- type CalendarPassphrase
- type CalendarPassphraseFlag
- type CalendarPermissions
- type CalendarType
- type Card
- func (c *Card) ChangeType(kr *crypto.KeyRing, cardType CardType) error
- func (c *Card) DeleteGroup(kr *crypto.KeyRing, groupKey, groupValue string) error
- func (c Card) Get(kr *crypto.KeyRing, key string) ([]*vcard.Field, error)
- func (c Card) GetGroup(kr *crypto.KeyRing, groupKey, groupValue string) (CardGroup, error)
- func (c *Card) Set(kr *crypto.KeyRing, key, value string) error
- type CardGroup
- type CardType
- type Cards
- type Client
- func (c *Client) AddAuthHandler(handler AuthHandler)
- func (c *Client) AddDeauthHandler(handler Handler)
- func (c *Client) AddPostRequestHook(hook resty.ResponseMiddleware)
- func (c *Client) AddPreRequestHook(hook resty.RequestMiddleware)
- func (c *Client) Auth2FA(ctx context.Context, req Auth2FAReq) error
- func (c *Client) AuthDelete(ctx context.Context) error
- func (c *Client) AuthRevoke(ctx context.Context, authUID string) error
- func (c *Client) AuthRevokeAll(ctx context.Context) error
- func (c *Client) AuthSessions(ctx context.Context) ([]AuthSession, error)
- func (c *Client) Close()
- func (c *Client) CountCalendarEvents(ctx context.Context, calendarID string) (int, error)
- func (c *Client) CountContactEmails(ctx context.Context, email string) (int, error)
- func (c *Client) CountContacts(ctx context.Context) (int, error)
- func (c *Client) CountMessages(ctx context.Context) (int, error)
- func (c *Client) CreateAddressKey(ctx context.Context, req CreateAddressKeyReq) (Key, error)
- func (c *Client) CreateContacts(ctx context.Context, req CreateContactsReq) ([]CreateContactsRes, error)
- func (c *Client) CreateDraft(ctx context.Context, addrKR *crypto.KeyRing, req CreateDraftReq) (Message, error)
- func (c *Client) CreateFile(ctx context.Context, shareID string, req CreateFileReq) (CreateFileRes, error)
- func (c *Client) CreateFolder(ctx context.Context, shareID string, req CreateFolderReq) (CreateFolderRes, error)
- func (c *Client) CreateLabel(ctx context.Context, req CreateLabelReq) (Label, error)
- func (c *Client) CreateLegacyAddressKey(ctx context.Context, req CreateAddressKeyReq) (Key, error)
- func (c *Client) DeleteAddress(ctx context.Context, addressID string) error
- func (c *Client) DeleteAddressKey(ctx context.Context, keyID string, keyList KeyList) error
- func (c *Client) DeleteChildren(ctx context.Context, shareID, linkID string, childIDs ...string) error
- func (c *Client) DeleteContacts(ctx context.Context, req DeleteContactsReq) error
- func (c *Client) DeleteLabel(ctx context.Context, labelID string) error
- func (c *Client) DeleteMessage(ctx context.Context, messageIDs ...string) error
- func (c *Client) DeleteUser(ctx context.Context, password []byte, req DeleteUserReq) error
- func (c *Client) DisableAddress(ctx context.Context, addressID string) error
- func (c *Client) EnableAddress(ctx context.Context, addressID string) error
- func (c *Client) GetAddress(ctx context.Context, addressID string) (Address, error)
- func (c *Client) GetAddresses(ctx context.Context) ([]Address, error)
- func (c *Client) GetAllCalendarEvents(ctx context.Context, calendarID string, filter url.Values) ([]CalendarEvent, error)
- func (c *Client) GetAllContactEmails(ctx context.Context, email string) ([]ContactEmail, error)
- func (c *Client) GetAllContacts(ctx context.Context) ([]Contact, error)
- func (c *Client) GetAllMessageIDs(ctx context.Context, afterID string) ([]string, error)
- func (c *Client) GetAttachment(ctx context.Context, attachmentID string) ([]byte, error)
- func (c *Client) GetAttachmentInto(ctx context.Context, attachmentID string, reader io.ReaderFrom) error
- func (c *Client) GetBlock(ctx context.Context, bareURL, token string) (io.ReadCloser, error)
- func (c *Client) GetCalendar(ctx context.Context, calendarID string) (Calendar, error)
- func (c *Client) GetCalendarEvent(ctx context.Context, calendarID, eventID string) (CalendarEvent, error)
- func (c *Client) GetCalendarEvents(ctx context.Context, calendarID string, page, pageSize int, filter url.Values) ([]CalendarEvent, error)
- func (c *Client) GetCalendarKeys(ctx context.Context, calendarID string) (CalendarKeys, error)
- func (c *Client) GetCalendarMembers(ctx context.Context, calendarID string) ([]CalendarMember, error)
- func (c *Client) GetCalendarPassphrase(ctx context.Context, calendarID string) (CalendarPassphrase, error)
- func (c *Client) GetCalendars(ctx context.Context) ([]Calendar, error)
- func (c *Client) GetContact(ctx context.Context, contactID string) (Contact, error)
- func (c *Client) GetContactEmails(ctx context.Context, email string, page, pageSize int) ([]ContactEmail, error)
- func (c *Client) GetContacts(ctx context.Context, page, pageSize int) ([]Contact, error)
- func (c *Client) GetEvent(ctx context.Context, eventID string) ([]Event, bool, error)
- func (c *Client) GetFullMessage(ctx context.Context, messageID string, scheduler Scheduler, ...) (FullMessage, error)
- func (c *Client) GetGroupedMessageCount(ctx context.Context) ([]MessageGroupCount, error)
- func (c *Client) GetLabel(ctx context.Context, labelID string, labelTypes ...LabelType) (Label, error)
- func (c *Client) GetLabels(ctx context.Context, labelTypes ...LabelType) ([]Label, error)
- func (c *Client) GetLatestEventID(ctx context.Context) (string, error)
- func (c *Client) GetLatestShareEventID(ctx context.Context, shareID string) (string, error)
- func (c *Client) GetLatestVolumeEventID(ctx context.Context, volumeID string) (string, error)
- func (c *Client) GetLink(ctx context.Context, shareID, linkID string) (Link, error)
- func (c *Client) GetMailSettings(ctx context.Context) (MailSettings, error)
- func (c *Client) GetMessage(ctx context.Context, messageID string) (Message, error)
- func (c *Client) GetMessageIDs(ctx context.Context, afterID string, limit int) ([]string, error)
- func (c *Client) GetMessageMetadata(ctx context.Context, filter MessageFilter) ([]MessageMetadata, error)
- func (c *Client) GetMessageMetadataPage(ctx context.Context, page, pageSize int, filter MessageFilter) ([]MessageMetadata, error)
- func (c *Client) GetPublicKeys(ctx context.Context, address string) (PublicKeys, RecipientType, error)
- func (c *Client) GetRevision(ctx context.Context, shareID, linkID, revisionID string, ...) (Revision, error)
- func (c *Client) GetSalts(ctx context.Context) (Salts, error)
- func (c *Client) GetShare(ctx context.Context, shareID string) (Share, error)
- func (c *Client) GetShareEvent(ctx context.Context, shareID, eventID string) (DriveEvent, error)
- func (c *Client) GetUser(ctx context.Context) (User, error)
- func (c *Client) GetUserSettings(ctx context.Context) (UserSettings, error)
- func (c *Client) GetVolume(ctx context.Context, volumeID string) (Volume, error)
- func (c *Client) GetVolumeEvent(ctx context.Context, volumeID, eventID string) (DriveEvent, error)
- func (c *Client) ImportMessages(ctx context.Context, addrKR *crypto.KeyRing, workers, buffer int, ...) (stream.Stream[ImportRes], error)
- func (c *Client) LabelMessages(ctx context.Context, messageIDs []string, labelID string) error
- func (c *Client) ListChildren(ctx context.Context, shareID, linkID string, showAll bool) ([]Link, error)
- func (c *Client) ListRevisions(ctx context.Context, shareID, linkID string) ([]RevisionMetadata, error)
- func (c *Client) ListShares(ctx context.Context, all bool) ([]ShareMetadata, error)
- func (c *Client) ListVolumes(ctx context.Context) ([]Volume, error)
- func (c *Client) MakeAddressKeyPrimary(ctx context.Context, keyID string, keyList KeyList) error
- func (c *Client) MarkMessagesRead(ctx context.Context, messageIDs ...string) error
- func (c *Client) MarkMessagesUnread(ctx context.Context, messageIDs ...string) error
- func (c *Client) NewEventStream(ctx context.Context, period, jitter time.Duration, lastEventID string) <-chan Event
- func (c *Client) OrderAddresses(ctx context.Context, req OrderAddressesReq) error
- func (c *Client) RemoveExpirationTime(ctx context.Context, messageID string) error
- func (c *Client) RequestBlockUpload(ctx context.Context, req BlockUploadReq) ([]BlockUploadLink, error)
- func (c *Client) SendDataEvent(ctx context.Context, req SendStatsReq) error
- func (c *Client) SendDataEventMultiple(ctx context.Context, req SendStatsMultiReq) error
- func (c *Client) SendDraft(ctx context.Context, draftID string, req SendDraftReq) (Message, error)
- func (c *Client) SetAttachPublicKey(ctx context.Context, req SetAttachPublicKeyReq) (MailSettings, error)
- func (c *Client) SetDefaultPGPScheme(ctx context.Context, req SetDefaultPGPSchemeReq) (MailSettings, error)
- func (c *Client) SetDisplayName(ctx context.Context, req SetDisplayNameReq) (MailSettings, error)
- func (c *Client) SetDraftMIMEType(ctx context.Context, req SetDraftMIMETypeReq) (MailSettings, error)
- func (c *Client) SetSignExternalMessages(ctx context.Context, req SetSignExternalMessagesReq) (MailSettings, error)
- func (c *Client) SetSignature(ctx context.Context, req SetSignatureReq) (MailSettings, error)
- func (c *Client) SetUserSettingsCrashReports(ctx context.Context, req SetCrashReportReq) (UserSettings, error)
- func (c *Client) SetUserSettingsTelemetry(ctx context.Context, req SetTelemetryReq) (UserSettings, error)
- func (c *Client) TrashChildren(ctx context.Context, shareID, linkID string, childIDs ...string) error
- func (c *Client) UndoActions(ctx context.Context, tokens ...UndoToken) ([]UndoRes, error)
- func (c *Client) UnlabelMessages(ctx context.Context, messageIDs []string, labelID string) error
- func (c *Client) UpdateContact(ctx context.Context, contactID string, req UpdateContactReq) (Contact, error)
- func (c *Client) UpdateDraft(ctx context.Context, draftID string, addrKR *crypto.KeyRing, ...) (Message, error)
- func (c *Client) UpdateLabel(ctx context.Context, labelID string, req UpdateLabelReq) (Label, error)
- func (c *Client) UpdateRevision(ctx context.Context, shareID, linkID, revisionID string, req UpdateRevisionReq) error
- func (c *Client) UploadAttachment(ctx context.Context, addrKR *crypto.KeyRing, req CreateAttachmentReq) (Attachment, error)
- func (c *Client) UploadBlock(ctx context.Context, bareURL, token string, block io.Reader) error
- type ClientType
- type Code
- type Contact
- type ContactCards
- type ContactEmail
- type ContactMetadata
- type ContactSettings
- type CreateAddressKeyReq
- type CreateAttachmentReq
- type CreateContactsReq
- type CreateContactsRes
- type CreateDraftAction
- type CreateDraftReq
- type CreateFileReq
- type CreateFileRes
- type CreateFolderReq
- type CreateFolderRes
- type CreateLabelReq
- type CreateUserReq
- type DefaultAttachmentAllocator
- type DeleteContactsReq
- type DeleteUserReq
- type Disposition
- type DraftTemplate
- type DriveEvent
- type EncryptionScheme
- type Event
- type EventAction
- type EventItem
- type FIDO2Info
- type FIDO2Req
- type FileProperties
- type FolderProperties
- type FullMessage
- type Future
- type Group
- type Handler
- type Headers
- type ImportMetadata
- type ImportReq
- type ImportRes
- type Key
- type KeyList
- type KeyListEntry
- type KeyState
- type Keys
- type Label
- type LabelEvent
- type LabelMessageRes
- type LabelMessagesReq
- type LabelMessagesRes
- type LabelType
- type Link
- func (l Link) GetHashKey(nodeKR *crypto.KeyRing) ([]byte, error)
- func (l Link) GetKeyRing(parentNodeKR, addrKR *crypto.KeyRing) (*crypto.KeyRing, error)
- func (l Link) GetName(parentNodeKR, addrKR *crypto.KeyRing) (string, error)
- func (l Link) GetSessionKey(nodeKR *crypto.KeyRing) (*crypto.SessionKey, error)
- type LinkEvent
- type LinkEventType
- type LinkState
- type LinkType
- type LinkWalkFunc
- type Listener
- type MailSettings
- type MakeAddressKeyPrimaryReq
- type Manager
- func (m *Manager) AddErrorHandler(code Code, handler Handler)
- func (m *Manager) AddPostRequestHook(hook resty.ResponseMiddleware)
- func (m *Manager) AddPreRequestHook(hook resty.RequestMiddleware)
- func (m *Manager) AddStatusObserver(observer StatusObserver)
- func (m *Manager) AuthInfo(ctx context.Context, req AuthInfoReq) (AuthInfo, error)
- func (m *Manager) AuthModulus(ctx context.Context) (AuthModulus, error)
- func (m *Manager) Close()
- func (m *Manager) CreateUser(ctx context.Context, req CreateUserReq) (User, error)
- func (m *Manager) DownloadAndVerify(ctx context.Context, kr *crypto.KeyRing, url, sig string) ([]byte, error)
- func (m *Manager) GetCaptcha(ctx context.Context, token string) ([]byte, error)
- func (m *Manager) GetDomains(ctx context.Context) ([]string, error)
- func (m *Manager) GetUsernameAvailable(ctx context.Context, username string) error
- func (m *Manager) NewClient(uid, acc, ref string) *Client
- func (m *Manager) NewClientWithLogin(ctx context.Context, username string, password []byte) (*Client, Auth, error)
- func (m *Manager) NewClientWithRefresh(ctx context.Context, uid, ref string) (*Client, Auth, error)
- func (m *Manager) Ping(ctx context.Context) error
- func (m *Manager) Quark(ctx context.Context, command string, args ...string) error
- func (m *Manager) QuarkRes(ctx context.Context, command string, args ...string) ([]byte, error)
- func (m *Manager) ReportBug(ctx context.Context, req ReportBugReq, atts ...ReportBugAttachment) error
- func (m *Manager) SendVerificationCode(ctx context.Context, req SendVerificationCodeReq) error
- type MemberPassphrase
- type Message
- type MessageActionReq
- type MessageEvent
- type MessageExpireActionReq
- type MessageFilter
- type MessageFlag
- func (f MessageFlag) Add(flag MessageFlag) MessageFlag
- func (f MessageFlag) Has(flag MessageFlag) bool
- func (f MessageFlag) HasAll(flags ...MessageFlag) bool
- func (f MessageFlag) HasAny(flags ...MessageFlag) bool
- func (f MessageFlag) Matches(flag MessageFlag) bool
- func (f MessageFlag) Remove(flag MessageFlag) MessageFlag
- func (f MessageFlag) Toggle(flag MessageFlag) MessageFlag
- type MessageGroupCount
- type MessageMetadata
- type MessagePackage
- type MessageRecipient
- type NetCtl
- func (c *NetCtl) Disable()
- func (c *NetCtl) Enable()
- func (c *NetCtl) NewRoundTripper(tlsConfig *tls.Config) http.RoundTripper
- func (c *NetCtl) OnDial(f func(net.Conn))
- func (c *NetCtl) OnRead(fn func([]byte))
- func (c *NetCtl) OnWrite(fn func([]byte))
- func (c *NetCtl) SetCanDial(canDial bool)
- func (c *NetCtl) SetCanRead(canRead bool)
- func (c *NetCtl) SetCanWrite(canWrite bool)
- func (c *NetCtl) SetDialLimit(limit uint64)
- func (c *NetCtl) SetReadLimit(limit uint64)
- func (c *NetCtl) SetReadSpeed(speed int)
- func (c *NetCtl) SetWriteLimit(limit uint64)
- func (c *NetCtl) SetWriteSpeed(speed int)
- type NetError
- type Option
- func WithAppVersion(appVersion string) Option
- func WithCookieJar(jar http.CookieJar) Option
- func WithDebug(debug bool) Option
- func WithHostURL(hostURL string) Option
- func WithLogger(logger resty.Logger) Option
- func WithPanicHandler(panicHandler async.PanicHandler) Option
- func WithRetryCount(retryCount int) Option
- func WithSkipVerifyProofs() Option
- func WithTransport(transport http.RoundTripper) Option
- type OrderAddressesReq
- type ParallelScheduler
- type PasswordMode
- type Pool
- func (pool *Pool[In, Out]) Done()
- func (pool *Pool[In, Out]) NewJob(ctx context.Context, req In) (*job[In, Out], doneFunc, error)
- func (pool *Pool[In, Out]) Process(ctx context.Context, reqs []In, fn func(int, In, Out, error) error) error
- func (pool *Pool[In, Out]) ProcessAll(ctx context.Context, reqs []In) ([]Out, error)
- func (pool *Pool[In, Out]) ProcessOne(ctx context.Context, req In) (Out, error)
- type PublicKey
- type PublicKeys
- type RecipientType
- type RefreshFlag
- type RegisteredKey
- type ReportBugAttachment
- type ReportBugReq
- type Revision
- type RevisionMetadata
- type RevisionState
- type Salt
- type Salts
- type Scheduler
- type SendDraftReq
- type SendPreferences
- type SendStatsMultiReq
- type SendStatsReq
- type SendVerificationCodeReq
- type SequentialScheduler
- type SessionKey
- type SetAttachPublicKeyReq
- type SetCrashReportReq
- type SetDefaultPGPSchemeReq
- type SetDisplayNameReq
- type SetDraftMIMETypeReq
- type SetSignExternalMessagesReq
- type SetSignatureReq
- type SetTelemetryReq
- type SettingsBool
- type Share
- type ShareFlags
- type ShareMetadata
- type ShareState
- type ShareType
- type SignExternalMessages
- type Signature
- type SignatureType
- type Status
- type StatusObserver
- type Ticker
- type TokenDestination
- type TokenType
- type TwoFAInfo
- type TwoFAStatus
- type UndoRes
- type UndoToken
- type UpdateContactReq
- type UpdateDraftReq
- type UpdateLabelReq
- type UpdateRevisionReq
- type User
- type UserSettings
- type UserType
- type Volume
- type VolumeRestoreStatus
- type VolumeShare
- type VolumeState
Examples ¶
Constants ¶
const ( FieldPMScheme = "X-PM-SCHEME" FieldPMSign = "X-PM-SIGN" FieldPMEncrypt = "X-PM-ENCRYPT" FieldPMMIMEType = "X-PM-MIMETYPE" )
const ( InboxLabel = "0" AllDraftsLabel = "1" AllSentLabel = "2" TrashLabel = "3" SpamLabel = "4" AllMailLabel = "5" ArchiveLabel = "6" SentLabel = "7" DraftsLabel = "8" OutboxLabel = "9" StarredLabel = "10" AllScheduledLabel = "12" )
const ( // DefaultHostURL is the default host of the API. DefaultHostURL = "https://mail.proton.me/api" // DefaultAppVersion is the default app version used to communicate with the API. // This must be changed (using the WithAppVersion option) for production use. DefaultAppVersion = "go-proton-api" )
Variables ¶
CharsetReader returns a charset decoder for the given charset. If set, it will be used to decode non-utf8 encoded messages.
var ErrBadHeader = errors.New("bad header")
var ErrImportEncrypt = errors.New("failed to encrypt message")
var ErrImportSizeExceeded = errors.New("message exceeds maximum import size of 30MB")
var ErrInvalidProof = errors.New("unexpected server proof")
var ErrJobCancelled = errors.New("job cancelled by surrounding context")
ErrJobCancelled indicates the job was cancelled.
var ErrNoSuchLabel = errors.New("no such label")
var ErrUndoTokenExpired = errors.New("undo token expired")
Functions ¶
func BuildRFC822 ¶
func ChunkSized ¶
ChunkSized splits a slice into chunks of maximum size and length. It is assumed that the size of each element is less than the maximum size.
func ClientIDFromContext ¶
ClientIDFromContext returns true if this context was marked as originating from a client.
func DecodeKeyPacket ¶
func EncryptRFC822 ¶
EncryptRFC822 encrypts the given message literal as a PGP attachment.
func InsecureTransport ¶
InsecureTransport returns an http.Transport with InsecureSkipVerify set to true.
Types ¶
type APIError ¶
type APIError struct { // Status is the HTTP status code of the response that caused the error. Status int // Code is the error code returned by the API. Code Code // Message is the error message returned by the API. Message string `json:"Error"` // Details contains optional error details which are specific to each request. Details any }
APIError represents an error returned by the API.
func (APIError) DetailsToString ¶
type Address ¶
type Address struct { ID string Email string Send Bool Receive Bool Status AddressStatus Type AddressType Order int DisplayName string Keys Keys }
type AddressEvent ¶
type AddressStatus ¶
type AddressStatus int
const ( AddressStatusDisabled AddressStatus = iota AddressStatusEnabled AddressStatusDeleting )
type AddressType ¶
type AddressType int
const ( AddressTypeOriginal AddressType = iota + 1 AddressTypeAlias AddressTypeCustom AddressTypePremium AddressTypeExternal )
type Attachment ¶
type AttachmentAllocator ¶
type AttachmentAllocator interface { // NewBuffer should return a new byte buffer for use. Note that this function may be called from multiple go-routines. NewBuffer() *bytes.Buffer }
AttachmentAllocator abstract the attachment download buffer creation.
type Auth2FAReq ¶
type AuthHandler ¶
type AuthHandler func(Auth)
AuthHandler is given any new auths that are returned from the API due to an unexpected auth refresh.
type AuthInfoReq ¶
type AuthInfoReq struct {
Username string
}
type AuthModulus ¶
type AuthRefreshReq ¶
type AuthReq ¶
type AuthReq struct { Auth2FAReq `json:",omitempty"` Username string ClientEphemeral string ClientProof string SRPSession string }
type AuthSession ¶
type AuthVerifier ¶
type Block ¶
type Block struct { Index int BareURL string // URL to the block Token string // Token for download URL Hash string // Encrypted block's sha256 hash, in base64 EncSignature string // Encrypted signature of the block SignatureEmail string // Email used to sign the block }
Block is a block of file contents. They are split in 4MB blocks although this number may change in the future. Each block is its own data packet separated from the key packet which is held by the node, which means the sessionKey is the same for every block.
type BlockToken ¶
type BlockUploadInfo ¶
type BlockUploadLink ¶
type BlockUploadReq ¶
type BlockUploadReq struct { AddressID string LinkID string RevisionID string BlockList []BlockUploadInfo }
type Bool ¶
type Bool bool
Bool is a convenience type for boolean values; it converts from APIBool to Go's builtin bool type.
func (Bool) MarshalJSON ¶
func (*Bool) UnmarshalJSON ¶
type Calendar ¶
type Calendar struct { ID string Name string Description string Color string Display Bool Type CalendarType Flags CalendarFlag }
type CalendarAttendee ¶
type CalendarAttendee struct { ID string Token string Status CalendarAttendeeStatus Permissions CalendarPermissions }
type CalendarAttendeeStatus ¶
type CalendarAttendeeStatus int
TODO: What is this?
const ( CalendarAttendeeStatusPending CalendarAttendeeStatus = iota CalendarAttendeeStatusMaybe CalendarAttendeeStatusNo CalendarAttendeeStatusYes )
type CalendarEvent ¶
type CalendarEvent struct { ID string UID string CalendarID string CreateTime int64 LastEditTime int64 StartTime int64 StartTimezone string EndTime int64 EndTimezone string FullDay Bool Author string Permissions CalendarPermissions Attendees []CalendarAttendee CalendarKeyPacket string CalendarEvents []CalendarEventPart AttendeesEvents []CalendarEventPart PersonalEvents []CalendarEventPart }
type CalendarEventPart ¶
type CalendarEventPart struct { MemberID string Type CalendarEventType Data string Signature string Author string }
TODO: Only personal events have MemberID; should we have a different type for that?
type CalendarEventType ¶
type CalendarEventType int
const ( CalendarEventTypeClear CalendarEventType = iota CalendarEventTypeEncrypted CalendarEventTypeSigned )
type CalendarFlag ¶
type CalendarFlag int64
const ( CalendarFlagActive CalendarFlag = 1 << iota CalendarFlagUpdatePassphrase CalendarFlagResetNeeded CalendarFlagIncompleteSetup CalendarFlagLostAccess )
type CalendarKey ¶
type CalendarKey struct { ID string CalendarID string PassphraseID string PrivateKey string Flags CalendarKeyFlag }
type CalendarKeyFlag ¶
type CalendarKeyFlag int64
TODO: What is this?
const ( CalendarKeyFlagActive CalendarKeyFlag = 1 << iota CalendarKeyFlagPrimary )
type CalendarKeys ¶
type CalendarKeys []CalendarKey
type CalendarMember ¶
type CalendarPassphrase ¶
type CalendarPassphrase struct { ID string Flags CalendarPassphraseFlag MemberPassphrases []MemberPassphrase }
TODO: Support invitations.
type CalendarType ¶
type CalendarType int
const ( CalendarTypeNormal CalendarType = iota CalendarTypeSubscribed )
type Card ¶
func (*Card) DeleteGroup ¶
DeleteGroup removes all values in the group defined by the given key/value pair.
type CardGroup ¶
type CardGroup struct { Card // contains filtered or unexported fields }
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client is the proton client.
func (*Client) AddAuthHandler ¶
func (c *Client) AddAuthHandler(handler AuthHandler)
Example ¶
ctx, cancel := context.WithCancel(context.Background()) defer cancel() // Create a new manager. m := proton.New() // Create a new client. c := m.NewClient("...uid...", "...acc...", "...ref...") defer c.Close() // Register an auth handler with the client. // This could be used for example to save the auth to keychain. c.AddAuthHandler(func(auth proton.Auth) { // Do something with auth. }) if _, err := c.GetUser(ctx); err != nil { panic(err) }
Output:
func (*Client) AddDeauthHandler ¶
func (*Client) AddPostRequestHook ¶
func (c *Client) AddPostRequestHook(hook resty.ResponseMiddleware)
func (*Client) AddPreRequestHook ¶
func (c *Client) AddPreRequestHook(hook resty.RequestMiddleware)
func (*Client) AuthSessions ¶
func (c *Client) AuthSessions(ctx context.Context) ([]AuthSession, error)
func (*Client) CountCalendarEvents ¶
func (*Client) CountContactEmails ¶
func (*Client) CreateAddressKey ¶
func (*Client) CreateContacts ¶
func (c *Client) CreateContacts(ctx context.Context, req CreateContactsReq) ([]CreateContactsRes, error)
func (*Client) CreateDraft ¶
func (*Client) CreateFile ¶
func (c *Client) CreateFile(ctx context.Context, shareID string, req CreateFileReq) (CreateFileRes, error)
func (*Client) CreateFolder ¶
func (c *Client) CreateFolder(ctx context.Context, shareID string, req CreateFolderReq) (CreateFolderRes, error)
func (*Client) CreateLabel ¶
func (*Client) CreateLegacyAddressKey ¶
func (*Client) DeleteAddress ¶
func (*Client) DeleteAddressKey ¶
func (*Client) DeleteChildren ¶
func (*Client) DeleteContacts ¶
func (c *Client) DeleteContacts(ctx context.Context, req DeleteContactsReq) error
func (*Client) DeleteLabel ¶
func (*Client) DeleteMessage ¶
func (*Client) DeleteUser ¶
func (*Client) DisableAddress ¶
func (*Client) EnableAddress ¶
func (*Client) GetAddress ¶
func (*Client) GetAllCalendarEvents ¶
func (*Client) GetAllContactEmails ¶
func (*Client) GetAllContacts ¶
func (*Client) GetAllMessageIDs ¶
func (*Client) GetAttachment ¶
func (*Client) GetAttachmentInto ¶
func (*Client) GetCalendar ¶
func (*Client) GetCalendarEvent ¶
func (*Client) GetCalendarEvents ¶
func (c *Client) GetCalendarEvents(ctx context.Context, calendarID string, page, pageSize int, filter url.Values) ([]CalendarEvent, error)
TODO: For now, the query params are partially constant -- should they be configurable?
func (*Client) GetCalendarKeys ¶
func (*Client) GetCalendarMembers ¶
func (*Client) GetCalendarPassphrase ¶
func (*Client) GetCalendars ¶
func (*Client) GetContact ¶
func (*Client) GetContactEmails ¶
func (*Client) GetContacts ¶
func (*Client) GetFullMessage ¶
func (c *Client) GetFullMessage(ctx context.Context, messageID string, scheduler Scheduler, storageProvider AttachmentAllocator) (FullMessage, error)
func (*Client) GetGroupedMessageCount ¶
func (c *Client) GetGroupedMessageCount(ctx context.Context) ([]MessageGroupCount, error)
func (*Client) GetLatestEventID ¶
func (*Client) GetLatestShareEventID ¶
func (*Client) GetLatestVolumeEventID ¶
func (*Client) GetMailSettings ¶
func (c *Client) GetMailSettings(ctx context.Context) (MailSettings, error)
func (*Client) GetMessage ¶
func (*Client) GetMessageIDs ¶
func (*Client) GetMessageMetadata ¶
func (c *Client) GetMessageMetadata(ctx context.Context, filter MessageFilter) ([]MessageMetadata, error)
func (*Client) GetMessageMetadataPage ¶
func (c *Client) GetMessageMetadataPage(ctx context.Context, page, pageSize int, filter MessageFilter) ([]MessageMetadata, error)
func (*Client) GetPublicKeys ¶
func (c *Client) GetPublicKeys(ctx context.Context, address string) (PublicKeys, RecipientType, error)
func (*Client) GetRevision ¶
func (*Client) GetShareEvent ¶
func (*Client) GetUserSettings ¶
func (c *Client) GetUserSettings(ctx context.Context) (UserSettings, error)
func (*Client) GetVolumeEvent ¶
func (*Client) ImportMessages ¶
func (*Client) LabelMessages ¶
func (*Client) ListChildren ¶
func (*Client) ListRevisions ¶
func (*Client) ListShares ¶
func (*Client) MakeAddressKeyPrimary ¶
func (*Client) MarkMessagesRead ¶
func (*Client) MarkMessagesUnread ¶
func (*Client) NewEventStream ¶
func (c *Client) NewEventStream(ctx context.Context, period, jitter time.Duration, lastEventID string) <-chan Event
NewEventStreamer returns a new event stream. It polls the API for new events at random intervals between `period` and `period+jitter`.
Example ¶
m := proton.New() ctx, cancel := context.WithCancel(context.Background()) defer cancel() c, _, err := m.NewClientWithLogin(ctx, "...user...", []byte("...pass...")) if err != nil { panic(err) } defer c.Close() // Get the latest event ID. fromEventID, err := c.GetLatestEventID(context.Background()) if err != nil { panic(err) } // Create a new event streamer. for event := range c.NewEventStream(ctx, 20*time.Second, 20*time.Second, fromEventID) { fmt.Println(event.EventID) }
Output:
func (*Client) OrderAddresses ¶
func (c *Client) OrderAddresses(ctx context.Context, req OrderAddressesReq) error
func (*Client) RemoveExpirationTime ¶
func (*Client) RequestBlockUpload ¶
func (c *Client) RequestBlockUpload(ctx context.Context, req BlockUploadReq) ([]BlockUploadLink, error)
func (*Client) SendDataEvent ¶
func (c *Client) SendDataEvent(ctx context.Context, req SendStatsReq) error
func (*Client) SendDataEventMultiple ¶
func (c *Client) SendDataEventMultiple(ctx context.Context, req SendStatsMultiReq) error
func (*Client) SetAttachPublicKey ¶
func (c *Client) SetAttachPublicKey(ctx context.Context, req SetAttachPublicKeyReq) (MailSettings, error)
func (*Client) SetDefaultPGPScheme ¶
func (c *Client) SetDefaultPGPScheme(ctx context.Context, req SetDefaultPGPSchemeReq) (MailSettings, error)
func (*Client) SetDisplayName ¶
func (c *Client) SetDisplayName(ctx context.Context, req SetDisplayNameReq) (MailSettings, error)
func (*Client) SetDraftMIMEType ¶
func (c *Client) SetDraftMIMEType(ctx context.Context, req SetDraftMIMETypeReq) (MailSettings, error)
func (*Client) SetSignExternalMessages ¶
func (c *Client) SetSignExternalMessages(ctx context.Context, req SetSignExternalMessagesReq) (MailSettings, error)
func (*Client) SetSignature ¶
func (c *Client) SetSignature(ctx context.Context, req SetSignatureReq) (MailSettings, error)
func (*Client) SetUserSettingsCrashReports ¶
func (c *Client) SetUserSettingsCrashReports(ctx context.Context, req SetCrashReportReq) (UserSettings, error)
func (*Client) SetUserSettingsTelemetry ¶
func (c *Client) SetUserSettingsTelemetry(ctx context.Context, req SetTelemetryReq) (UserSettings, error)
func (*Client) TrashChildren ¶
func (*Client) UndoActions ¶
func (*Client) UnlabelMessages ¶
func (*Client) UpdateContact ¶
func (*Client) UpdateDraft ¶
func (*Client) UpdateLabel ¶
func (*Client) UpdateRevision ¶
func (*Client) UploadAttachment ¶
func (c *Client) UploadAttachment(ctx context.Context, addrKR *crypto.KeyRing, req CreateAttachmentReq) (Attachment, error)
type ClientType ¶
type ClientType int
const ( ClientTypeEmail ClientType = iota + 1 ClientTypeVPN ClientTypeCalendar ClientTypeDrive )
type Code ¶
type Code int
const ( SuccessCode Code = 1000 MultiCode Code = 1001 InvalidValue Code = 2001 AppVersionMissingCode Code = 5001 AppVersionBadCode Code = 5003 UsernameInvalid Code = 6003 // Deprecated, but still used. PasswordWrong Code = 8002 HumanVerificationRequired Code = 9001 PaidPlanRequired Code = 10004 AuthRefreshTokenInvalid Code = 10013 )
type ContactCards ¶
type ContactCards struct {
Cards Cards
}
type ContactEmail ¶
type ContactMetadata ¶
type ContactSettings ¶
type CreateAddressKeyReq ¶
type CreateAttachmentReq ¶
type CreateContactsReq ¶
type CreateContactsReq struct { Contacts []ContactCards Overwrite int Labels int }
type CreateContactsRes ¶
type CreateDraftAction ¶
type CreateDraftAction int
const ( ReplyAction CreateDraftAction = iota ReplyAllAction ForwardAction AutoResponseAction ReadReceiptAction )
type CreateDraftReq ¶
type CreateDraftReq struct { Message DraftTemplate AttachmentKeyPackets []string ParentID string `json:",omitempty"` Action CreateDraftAction }
type CreateFileReq ¶
type CreateFileReq struct { ParentLinkID string Name string // Encrypted File Name Hash string // Encrypted content hash MIMEType string // MIME Type ContentKeyPacket string // The block's key packet, encrypted with the node key. ContentKeyPacketSignature string // Unencrypted signature of the content session key, signed with the NodeKey NodeKey string // The private NodeKey, used to decrypt any file/folder content. NodePassphrase string // The passphrase used to unlock the NodeKey, encrypted by the owning Link/Share keyring. NodePassphraseSignature string // The signature of the NodePassphrase SignatureAddress string // Signature email address used to sign passphrase and name }
type CreateFileRes ¶
type CreateFolderReq ¶
type CreateFolderRes ¶
type CreateFolderRes struct {
ID string // Encrypted Link ID
}
type CreateLabelReq ¶
type CreateUserReq ¶
type CreateUserReq struct { Type UserType Username string Domain string Auth AuthVerifier }
type DefaultAttachmentAllocator ¶
type DefaultAttachmentAllocator struct{}
func NewDefaultAttachmentAllocator ¶
func NewDefaultAttachmentAllocator() *DefaultAttachmentAllocator
func (DefaultAttachmentAllocator) NewBuffer ¶
func (DefaultAttachmentAllocator) NewBuffer() *bytes.Buffer
type DeleteContactsReq ¶
type DeleteContactsReq struct {
IDs []string
}
type DeleteUserReq ¶
type Disposition ¶
type Disposition string
const ( InlineDisposition Disposition = "inline" AttachmentDisposition Disposition = "attachment" )
type DraftTemplate ¶
type DriveEvent ¶
type EncryptionScheme ¶
type EncryptionScheme int
const ( InternalScheme EncryptionScheme = 1 << iota EncryptedOutsideScheme ClearScheme PGPInlineScheme PGPMIMEScheme ClearMIMEScheme )
type Event ¶
type Event struct { EventID string Refresh RefreshFlag User *User UserSettings *UserSettings MailSettings *MailSettings Messages []MessageEvent Labels []LabelEvent Addresses []AddressEvent UsedSpace *int }
type EventAction ¶
type EventAction int
const ( EventDelete EventAction = iota EventCreate EventUpdate EventUpdateFlags )
type EventItem ¶
type EventItem struct { ID string Action EventAction }
type FIDO2Info ¶
type FIDO2Info struct { AuthenticationOptions any RegisteredKeys []RegisteredKey }
type FileProperties ¶
type FileProperties struct { ContentKeyPacket string // The block's key packet, encrypted with the node key. ContentKeyPacketSignature string // Signature of the content key packet. Signature of the session key, signed with the NodeKey. ActiveRevision RevisionMetadata // The active revision of the file. }
type FolderProperties ¶
type FolderProperties struct {
NodeHashKey string // HMAC key used to hash the folder's children names.
}
type FullMessage ¶
type Future ¶
type Future[T any] struct { // contains filtered or unexported fields }
type Handler ¶
type Handler func()
Handler is a generic function that can be registered for a certain event (e.g. deauth, API code).
type Headers ¶
func (*Headers) UnmarshalJSON ¶
type ImportMetadata ¶
type ImportMetadata struct { AddressID string LabelIDs []string Unread Bool Flags MessageFlag }
type ImportReq ¶
type ImportReq struct { Metadata ImportMetadata Message []byte }
type Key ¶
type Key struct { ID string PrivateKey []byte Token string Signature string Primary Bool Active Bool Flags KeyState }
func (Key) MarshalJSON ¶
func (*Key) UnmarshalJSON ¶
type KeyList ¶
func NewKeyList ¶
func NewKeyList(signer *crypto.KeyRing, entries []KeyListEntry) (KeyList, error)
type KeyListEntry ¶
type Label ¶
type Label struct { ID string ParentID string Name string Path []string Color string Type LabelType }
func (Label) MarshalJSON ¶
func (*Label) UnmarshalJSON ¶
type LabelEvent ¶
type LabelMessageRes ¶
type LabelMessagesReq ¶
type LabelMessagesRes ¶
type LabelMessagesRes struct { Responses []LabelMessageRes UndoToken UndoToken }
type Link ¶
type Link struct { LinkID string // Encrypted file/folder ID ParentLinkID string // Encrypted parent folder ID (LinkID). Root link has null ParentLinkID. Type LinkType Name string // Encrypted file name Hash string // HMAC of name encrypted with parent hash key Size int64 State LinkState MIMEType string CreateTime int64 // Link creation time ModifyTime int64 // Link modification time (on API, real modify date is stored in XAttr) ExpirationTime int64 // Link expiration time NodeKey string // The private NodeKey, used to decrypt any file/folder content. NodePassphrase string // The passphrase used to unlock the NodeKey, encrypted by the owning Link/Share keyring. NodePassphraseSignature string FileProperties *FileProperties FolderProperties *FolderProperties }
Link holds the tree structure, for the clients, they represent the files and folders of a given volume. They have a ParentLinkID that points to parent folders. Links also hold the file name (encrypted) and a hash of the name for name collisions. Link data is encrypted with its owning Share keyring.
func (Link) GetKeyRing ¶
func (Link) GetSessionKey ¶
type LinkEvent ¶
type LinkEvent struct { EventID string EventType LinkEventType CreateTime int Link Link Data any }
type LinkEventType ¶
type LinkEventType int
const ( LinkEventDelete LinkEventType = iota LinkEventCreate LinkEventUpdate LinkEventUpdateMetadata )
type Listener ¶
Listener wraps a net.Listener. It can be configured to spawn connections that drop all reads or writes.
func NewListener ¶
NewListener returns a new DropListener.
func (*Listener) Done ¶
func (l *Listener) Done() <-chan struct{}
Done returns a channel that is closed when the listener is closed.
func (*Listener) DropAll ¶
func (l *Listener) DropAll()
DropAll closes all connections spawned by this listener.
func (*Listener) SetCanRead ¶
SetCanRead sets whether the connections spawned by this listener can read.
func (*Listener) SetCanWrite ¶
SetCanWrite sets whether the connections spawned by this listener can write.
type MailSettings ¶
type MailSettings struct { DisplayName string Signature string DraftMIMEType rfc822.MIMEType AttachPublicKey Bool Sign SignExternalMessages PGPScheme EncryptionScheme }
type MakeAddressKeyPrimaryReq ¶
type MakeAddressKeyPrimaryReq struct {
SignedKeyList KeyList
}
type Manager ¶
type Manager struct {
// contains filtered or unexported fields
}
func (*Manager) AddErrorHandler ¶
func (*Manager) AddPostRequestHook ¶
func (m *Manager) AddPostRequestHook(hook resty.ResponseMiddleware)
func (*Manager) AddPreRequestHook ¶
func (m *Manager) AddPreRequestHook(hook resty.RequestMiddleware)
func (*Manager) AddStatusObserver ¶
func (m *Manager) AddStatusObserver(observer StatusObserver)
func (*Manager) AuthModulus ¶
func (m *Manager) AuthModulus(ctx context.Context) (AuthModulus, error)
func (*Manager) CreateUser ¶
func (*Manager) DownloadAndVerify ¶
func (*Manager) GetCaptcha ¶
func (*Manager) GetUsernameAvailable ¶
func (*Manager) NewClient ¶
Example ¶
// Create a new manager. m := proton.New() // If auth information is already known, it can be used to create a client straight away. c := m.NewClient("...uid...", "...acc...", "...ref...") defer c.Close() // All API operations must be run within a context. ctx, cancel := context.WithCancel(context.Background()) defer cancel() // Do something with the client. if _, err := c.GetUser(ctx); err != nil { panic(err) }
Output:
func (*Manager) NewClientWithLogin ¶
func (m *Manager) NewClientWithLogin(ctx context.Context, username string, password []byte) (*Client, Auth, error)
Example ¶
// Create a new manager. m := proton.New() // All API operations must be run within a context. ctx, cancel := context.WithCancel(context.Background()) defer cancel() // Clients are created via username/password if auth information isn't already known. c, auth, err := m.NewClientWithLogin(ctx, "...user...", []byte("...pass...")) if err != nil { panic(err) } defer c.Close() // If 2FA is necessary, an additional request is required. if auth.TwoFA.Enabled&proton.HasTOTP != 0 { if err := c.Auth2FA(ctx, proton.Auth2FAReq{TwoFactorCode: "...TOTP..."}); err != nil { panic(err) } } // Do something with the client. if _, err := c.GetUser(ctx); err != nil { panic(err) }
Output:
func (*Manager) NewClientWithRefresh ¶
Example ¶
// Create a new manager. m := proton.New() // All API operations must be run within a context. ctx, cancel := context.WithCancel(context.Background()) defer cancel() // If UID/RefreshToken is already known, it can be used to create a new client straight away. c, _, err := m.NewClientWithRefresh(ctx, "...uid...", "...ref...") if err != nil { panic(err) } defer c.Close() // Do something with the client. if _, err := c.GetUser(ctx); err != nil { panic(err) }
Output:
func (*Manager) QuarkRes ¶
QuarkRes is the same as Quark, but returns the content extracted from the response body.
func (*Manager) ReportBug ¶
func (m *Manager) ReportBug(ctx context.Context, req ReportBugReq, atts ...ReportBugAttachment) error
func (*Manager) SendVerificationCode ¶
func (m *Manager) SendVerificationCode(ctx context.Context, req SendVerificationCodeReq) error
type MemberPassphrase ¶
type Message ¶
type Message struct { MessageMetadata Header string ParsedHeaders Headers Body string MIMEType rfc822.MIMEType Attachments []Attachment }
func (Message) DecryptInto ¶
type MessageActionReq ¶
type MessageActionReq struct {
IDs []string
}
type MessageEvent ¶
type MessageEvent struct { EventItem Message MessageMetadata }
type MessageExpireActionReq ¶
type MessageFilter ¶
type MessageFlag ¶
type MessageFlag int64
const ( MessageFlagReceived MessageFlag = 1 << 0 MessageFlagSent MessageFlag = 1 << 1 MessageFlagInternal MessageFlag = 1 << 2 MessageFlagE2E MessageFlag = 1 << 3 MessageFlagAuto MessageFlag = 1 << 4 MessageFlagReplied MessageFlag = 1 << 5 MessageFlagRepliedAll MessageFlag = 1 << 6 MessageFlagForwarded MessageFlag = 1 << 7 MessageFlagAutoReplied MessageFlag = 1 << 8 MessageFlagImported MessageFlag = 1 << 9 MessageFlagOpened MessageFlag = 1 << 10 MessageFlagReceiptSent MessageFlag = 1 << 11 MessageFlagNotified MessageFlag = 1 << 12 MessageFlagTouched MessageFlag = 1 << 13 MessageFlagReceipt MessageFlag = 1 << 14 MessageFlagReceiptRequest MessageFlag = 1 << 16 MessageFlagPublicKey MessageFlag = 1 << 17 MessageFlagSign MessageFlag = 1 << 18 MessageFlagUnsubscribed MessageFlag = 1 << 19 MessageFlagScheduledSend MessageFlag = 1 << 20 MessageFlagAlias MessageFlag = 1 << 21 MessageFlagDMARCPass MessageFlag = 1 << 23 MessageFlagSPFFail MessageFlag = 1 << 24 MessageFlagDKIMFail MessageFlag = 1 << 25 MessageFlagDMARCFail MessageFlag = 1 << 26 MessageFlagHamManual MessageFlag = 1 << 27 MessageFlagSpamAuto MessageFlag = 1 << 28 MessageFlagSpamManual MessageFlag = 1 << 29 MessageFlagPhishingAuto MessageFlag = 1 << 30 MessageFlagPhishingManual MessageFlag = 1 << 31 )
func (MessageFlag) Add ¶
func (f MessageFlag) Add(flag MessageFlag) MessageFlag
func (MessageFlag) Has ¶
func (f MessageFlag) Has(flag MessageFlag) bool
func (MessageFlag) HasAll ¶
func (f MessageFlag) HasAll(flags ...MessageFlag) bool
func (MessageFlag) HasAny ¶
func (f MessageFlag) HasAny(flags ...MessageFlag) bool
func (MessageFlag) Matches ¶
func (f MessageFlag) Matches(flag MessageFlag) bool
func (MessageFlag) Remove ¶
func (f MessageFlag) Remove(flag MessageFlag) MessageFlag
func (MessageFlag) Toggle ¶
func (f MessageFlag) Toggle(flag MessageFlag) MessageFlag
type MessageGroupCount ¶
type MessageMetadata ¶
type MessageMetadata struct { ID string AddressID string LabelIDs []string ExternalID string Subject string Sender *mail.Address ToList []*mail.Address CCList []*mail.Address BCCList []*mail.Address ReplyTos []*mail.Address Flags MessageFlag Time int64 ExpirationTime *int64 Size int Unread Bool IsReplied Bool IsRepliedAll Bool IsForwarded Bool NumAttachments int }
func (MessageMetadata) IsDraft ¶
func (meta MessageMetadata) IsDraft() bool
func (MessageMetadata) Seen ¶
func (meta MessageMetadata) Seen() bool
func (MessageMetadata) Starred ¶
func (meta MessageMetadata) Starred() bool
type MessagePackage ¶
type MessagePackage struct { Addresses map[string]*MessageRecipient MIMEType rfc822.MIMEType Type EncryptionScheme Body string BodyKey *SessionKey `json:",omitempty"` AttachmentKeys map[string]*SessionKey `json:",omitempty"` }
type MessageRecipient ¶
type MessageRecipient struct { Type EncryptionScheme Signature SignatureType BodyKeyPacket string `json:",omitempty"` AttachmentKeyPackets map[string]string `json:",omitempty"` }
type NetCtl ¶
type NetCtl struct {
// contains filtered or unexported fields
}
ctl can be used to control whether a dialer can dial, and whether the resulting connection can read or write.
func (*NetCtl) Disable ¶
func (c *NetCtl) Disable()
Disable is equivalent to disallowing dial, read and write.
func (*NetCtl) Enable ¶
func (c *NetCtl) Enable()
Enable is equivalent to allowing dial, read and write.
func (*NetCtl) NewRoundTripper ¶
func (c *NetCtl) NewRoundTripper(tlsConfig *tls.Config) http.RoundTripper
NewDialer returns a new dialer controlled by the ctl.
func (*NetCtl) OnDial ¶
OnDial adds a callback that is called with the created connection when a dial is successful.
func (*NetCtl) OnRead ¶
OnRead adds a callback that is called with the read bytes when a read is successful.
func (*NetCtl) OnWrite ¶
OnWrite adds a callback that is called with the written bytes when a write is successful.
func (*NetCtl) SetCanDial ¶
SetCanDial sets whether the dialer can dial.
func (*NetCtl) SetCanRead ¶
SetCanRead sets whether the connection can read.
func (*NetCtl) SetCanWrite ¶
SetCanWrite sets whether the connection can write.
func (*NetCtl) SetDialLimit ¶
SetDialLimit sets the maximum number of times dialers using this controller can dial.
func (*NetCtl) SetReadLimit ¶
SetReadLimit sets the maximum number of bytes that can be read.
func (*NetCtl) SetReadSpeed ¶
SetReadSpeed sets the maximum number of bytes that can be read per second.
func (*NetCtl) SetWriteLimit ¶
SetWriteLimit sets the maximum number of bytes that can be written.
func (*NetCtl) SetWriteSpeed ¶
SetWriteSpeed sets the maximum number of bytes that can be written per second.
type NetError ¶
type NetError struct { // Cause is the underlying error that caused the network error. Cause error // Message is an additional message that describes the network error. Message string }
NetError represents a network error. It is returned when the API is unreachable.
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
Option represents a type that can be used to configure the manager.
func WithAppVersion ¶
func WithCookieJar ¶
func WithHostURL ¶
func WithLogger ¶
func WithLogger(logger resty.Logger) Option
func WithPanicHandler ¶
func WithPanicHandler(panicHandler async.PanicHandler) Option
func WithRetryCount ¶
func WithSkipVerifyProofs ¶
func WithSkipVerifyProofs() Option
func WithTransport ¶
func WithTransport(transport http.RoundTripper) Option
type OrderAddressesReq ¶
type OrderAddressesReq struct {
AddressIDs []string
}
type ParallelScheduler ¶
type ParallelScheduler struct {
// contains filtered or unexported fields
}
func NewParallelScheduler ¶
func NewParallelScheduler(workers int, panicHandler async.PanicHandler) *ParallelScheduler
type PasswordMode ¶
type PasswordMode int
const ( OnePasswordMode PasswordMode = iota + 1 TwoPasswordMode )
type Pool ¶
type Pool[In comparable, Out any] struct { // contains filtered or unexported fields }
Pool is a worker pool that handles input of type In and returns results of type Out.
func NewPool ¶
func NewPool[In comparable, Out any](size int, panicHandler async.PanicHandler, work func(context.Context, In) (Out, error)) *Pool[In, Out]
New returns a new pool.
func (*Pool[In, Out]) NewJob ¶
NewJob submits a job to the pool. It returns a job handle and a DoneFunc. The job handle allows the job result to be obtained. The DoneFunc is used to mark the job as done, which frees up the worker in the pool for reuse.
func (*Pool[In, Out]) Process ¶
func (pool *Pool[In, Out]) Process(ctx context.Context, reqs []In, fn func(int, In, Out, error) error) error
Process submits jobs to the pool. The callback provides access to the result, or an error if one occurred.
func (*Pool[In, Out]) ProcessAll ¶
ProcessAll submits jobs to the pool. All results are returned once available.
type PublicKeys ¶
type PublicKeys []PublicKey
func (PublicKeys) GetKeyRing ¶
func (keys PublicKeys) GetKeyRing() (*crypto.KeyRing, error)
type RecipientType ¶
type RecipientType int
const ( RecipientTypeInternal RecipientType = iota + 1 RecipientTypeExternal )
type RefreshFlag ¶
type RefreshFlag uint8
const ( RefreshMail RefreshFlag = 1 << iota // 1<<0 = 1 RefreshAll RefreshFlag = 1<<iota - 1 // 1<<8 - 1 = 255 )
type RegisteredKey ¶
type ReportBugAttachment ¶
type ReportBugReq ¶
type Revision ¶
type Revision struct { RevisionMetadata Blocks []Block }
Revisions are only for files, they represent “versions” of files. Each file can have 1 active revision and n obsolete revisions.
type RevisionMetadata ¶
type RevisionMetadata struct { ID string // Encrypted Revision ID CreateTime int64 // Unix timestamp of the revision creation time Size int64 // Size of the revision in bytes ManifestSignature string // Signature of the revision manifest, signed with user's address key of the share. SignatureEmail string // Email of the user that signed the revision. State RevisionState // State of revision Thumbnail Bool // Whether the revision has a thumbnail ThumbnailHash string // Hash of the thumbnail }
type RevisionState ¶
type RevisionState int
const ( RevisionStateDraft RevisionState = iota RevisionStateActive RevisionStateObsolete RevisionStateDeleted )
type Scheduler ¶
type Scheduler interface {
Schedule(ctx context.Context, attachmentIDs []string, storageProvider AttachmentAllocator, downloader func(context.Context, string, *bytes.Buffer) error) ([]*bytes.Buffer, error)
}
Scheduler allows the user to specify how the attachment data for the message should be downloaded.
type SendDraftReq ¶
type SendDraftReq struct {
Packages []*MessagePackage
}
func (*SendDraftReq) AddMIMEPackage ¶
func (req *SendDraftReq) AddMIMEPackage( kr *crypto.KeyRing, mimeBody string, prefs map[string]SendPreferences, ) error
func (*SendDraftReq) AddTextPackage ¶
func (req *SendDraftReq) AddTextPackage( kr *crypto.KeyRing, body string, mimeType rfc822.MIMEType, prefs map[string]SendPreferences, attKeys map[string]*crypto.SessionKey, ) error
type SendPreferences ¶
type SendPreferences struct { // Encrypt indicates whether the email should be encrypted or not. // If it's encrypted, we need to know which public key to use. Encrypt bool // PubKey contains an OpenPGP key that can be used for encryption. PubKey *crypto.KeyRing // SignatureType indicates how the email should be signed. SignatureType SignatureType // EncryptionScheme indicates if we should encrypt body and attachments separately and // what MIME format to give the final encrypted email. The two standard PGP // schemes are PGP/MIME and PGP/Inline. However we use a custom scheme for // internal emails (including the so-called encrypted-to-outside emails, // which even though meant for external users, they don't really get out of // our platform). If the email is sent unencrypted, no PGP scheme is needed. EncryptionScheme EncryptionScheme // MIMEType is the MIME type to use for formatting the body of the email // (before encryption/after decryption). The standard possibilities are the // enriched HTML format, text/html, and plain text, text/plain. But it's // also possible to have a multipart/mixed format, which is typically used // for PGP/MIME encrypted emails, where attachments go into the body too. // Because of this, this option is sometimes called MIME format. MIMEType rfc822.MIMEType }
type SendStatsMultiReq ¶
type SendStatsMultiReq struct {
EventInfo []SendStatsReq
}
type SendStatsReq ¶
type SendVerificationCodeReq ¶
type SendVerificationCodeReq struct { Username string Type TokenType Destination TokenDestination }
type SequentialScheduler ¶
type SequentialScheduler struct{}
SequentialScheduler downloads the attachments one by one.
func NewSequentialScheduler ¶
func NewSequentialScheduler() *SequentialScheduler
type SessionKey ¶
type SetAttachPublicKeyReq ¶
type SetAttachPublicKeyReq struct {
AttachPublicKey Bool
}
type SetCrashReportReq ¶
type SetCrashReportReq struct {
CrashReports SettingsBool
}
type SetDefaultPGPSchemeReq ¶
type SetDefaultPGPSchemeReq struct {
PGPScheme EncryptionScheme
}
type SetDisplayNameReq ¶
type SetDisplayNameReq struct {
DisplayName string
}
type SetDraftMIMETypeReq ¶
type SetSignExternalMessagesReq ¶
type SetSignExternalMessagesReq struct {
Sign SignExternalMessages
}
type SetSignatureReq ¶
type SetSignatureReq struct {
Signature string
}
type SetTelemetryReq ¶
type SetTelemetryReq struct {
Telemetry SettingsBool
}
type SettingsBool ¶
type SettingsBool int
const ( SettingDisabled SettingsBool = iota SettingEnabled )
type Share ¶
type Share struct {}
Share is an entry point to a location in the file structure (Volume). It points to a file or folder anywhere in the tree and holds a key called the ShareKey. To access a file or folder in Drive, a user must be a member of a share. The membership information is tied to a specific address, and key. This key then allows the user to decrypt the share key, giving access to the file system rooted at that share.
type ShareMetadata ¶
type ShareMetadata struct {}
type SignExternalMessages ¶
type SignExternalMessages int
const ( SignExternalMessagesDisabled SignExternalMessages = iota SignExternalMessagesEnabled )
type Signature ¶
type Signature struct { Hash string Data *crypto.PGPSignature }
type SignatureType ¶
type SignatureType int
const ( NoSignature SignatureType = iota DetachedSignature AttachedSignature )
type StatusObserver ¶
type StatusObserver func(Status)
type Ticker ¶
type TokenDestination ¶
type TwoFAInfo ¶
type TwoFAInfo struct { Enabled TwoFAStatus FIDO2 FIDO2Info }
type UpdateContactReq ¶
type UpdateContactReq struct {
Cards Cards
}
type UpdateDraftReq ¶
type UpdateDraftReq struct { Message DraftTemplate AttachmentKeyPackets []string }
type UpdateLabelReq ¶
type UpdateRevisionReq ¶
type UpdateRevisionReq struct { BlockList []BlockToken State RevisionState ManifestSignature string SignatureAddress string }
type UserSettings ¶
type UserSettings struct { Telemetry SettingsBool CrashReports SettingsBool }
type Volume ¶
type Volume struct { VolumeID string // Encrypted volume ID CreationTime int64 // Creation time of the volume in Unix time ModifyTime int64 // Last modification time of the volume in Unix time MaxSpace *int64 // Space limit for the volume in bytes, null if unlimited. UsedSpace int64 // Space used by files in the volume in bytes DownloadedBytes int64 // The amount of downloaded data since last reset UploadedBytes int64 // The amount of uploaded data since the last reset State VolumeState // The state of the volume (active, locked, maybe more in the future) RestoreStatus *VolumeRestoreStatus // The status of the restore task. Null if not applicable }
Volume is a Proton Drive volume.
type VolumeRestoreStatus ¶
type VolumeRestoreStatus int
VolumeRestoreStatus is the status of the restore task.
const ( RestoreStatusDone VolumeRestoreStatus = 0 RestoreStatusInProgress VolumeRestoreStatus = 1 RestoreStatusFailed VolumeRestoreStatus = -1 )
type VolumeState ¶
type VolumeState int
VolumeState is the state of a volume.
const ( VolumeStateActive VolumeState = 1 VolumeStateLocked VolumeState = 3 )
Source Files
¶
- address.go
- address_types.go
- attachment.go
- attachment_interfaces.go
- attachment_types.go
- auth.go
- block.go
- block_types.go
- boolean.go
- calendar.go
- calendar_event.go
- calendar_event_types.go
- calendar_types.go
- client.go
- contact.go
- contact_card.go
- contact_types.go
- contexts.go
- core_settings.go
- core_settings_type.go
- data.go
- data_type.go
- event.go
- event_drive.go
- event_drive_types.go
- event_types.go
- future.go
- header_types.go
- internal.go
- job.go
- keyring.go
- keys.go
- keys_types.go
- label.go
- label_types.go
- link.go
- link_file.go
- link_file_types.go
- link_folder.go
- link_folder_types.go
- link_types.go
- mail_settings.go
- mail_settings_types.go
- manager.go
- manager_auth.go
- manager_auth_types.go
- manager_builder.go
- manager_domains.go
- manager_download.go
- manager_ping.go
- manager_report.go
- manager_report_types.go
- manager_status.go
- manager_user.go
- manager_user_types.go
- message.go
- message_build.go
- message_draft_types.go
- message_encrypt.go
- message_import.go
- message_import_types.go
- message_send.go
- message_send_types.go
- message_types.go
- netctl.go
- option.go
- package.go
- paging.go
- pool.go
- response.go
- salt.go
- salt_types.go
- share.go
- share_types.go
- ticker.go
- undo.go
- undo_types.go
- unlock.go
- user.go
- user_types.go
- volume.go
- volume_types.go