Documentation ¶
Index ¶
- Constants
- Variables
- func ComputeMessageFlagsByLabels(labels []string) (flag int64)
- func ConstructAddress(headerEmail string, addressEmail string) string
- func ContextWithoutAuthRefresh(parent context.Context) context.Context
- func ContextWithoutRetry(parent context.Context) context.Context
- func CreateTransportWithDialer(dialer TLSDialer) *http.Transport
- func HashMailboxPassword(password []byte, salt string) ([]byte, error)
- func IsSystemLabel(label string) bool
- func LeastUsedColor(colors []string) (color string)
- func SanitizeEmail(email string) string
- type Address
- type AddressList
- type AlgoKey
- type Attachment
- func (a *Attachment) Decrypt(r io.Reader, kr *crypto.KeyRing) (decrypted io.Reader, err error)
- func (a *Attachment) DetachedSign(kr *crypto.KeyRing, att io.Reader) (signed io.Reader, err error)
- func (a *Attachment) Encrypt(kr *crypto.KeyRing, att io.Reader) (encrypted io.Reader, err error)
- func (a *Attachment) MarshalJSON() ([]byte, error)
- func (a *Attachment) UnmarshalJSON(b []byte) error
- type Auth
- type AuthInfo
- type AuthModulus
- type AuthRefresh
- type AuthRefreshHandler
- type AuthReq
- type BasicTLSDialer
- type Boolean
- type Card
- type Client
- type Config
- type ConnectionObserver
- type Contact
- type ContactEmail
- type DraftReq
- type ErrUnprocessableEntity
- type Error
- type Event
- type EventAction
- type EventAddress
- type EventItem
- type EventLabel
- type EventMessage
- type EventMessageUpdated
- type GetAuthInfoReq
- type ImportMetadata
- type ImportMsgReq
- type ImportMsgReqs
- type ImportMsgRes
- type KeySalt
- type Label
- type LabelMessagesReq
- type LabelReq
- type LabelsOperation
- type MailSettings
- type Manager
- type Message
- func (m *Message) Decrypt(kr *crypto.KeyRing) ([]byte, error)
- func (m *Message) Encrypt(encrypter, signer *crypto.KeyRing) (err error)
- func (m *Message) ExtractSignatures(kr *crypto.KeyRing) ([]Signature, error)
- func (m *Message) Has(flag int64) bool
- func (m *Message) HasLabelID(labelID string) bool
- func (m *Message) IsBodyEncrypted() bool
- func (m *Message) IsDraft() bool
- func (m *Message) IsEncrypted() bool
- func (m *Message) IsLegacyMessage() bool
- func (m *Message) MarshalJSON() ([]byte, error)
- func (m *Message) Recipients() []*mail.Address
- func (m *Message) UnmarshalJSON(b []byte) error
- type MessageAddress
- type MessagePackage
- type MessagesActionReq
- type MessagesCount
- type MessagesFilter
- type PMKey
- type PMKeys
- type PackageFlag
- type PasswordMode
- type PinningTLSDialer
- type ProxyTLSDialer
- type PublicKey
- type RecipientType
- type ReportBugReq
- type SendMessageReq
- type Signature
- type SignatureFlag
- type TLSDialer
- type TwoFAInfo
- type TwoFAStatus
- type User
Constants ¶
const ( DisabledAddress = iota EnabledAddress )
Address statuses.
const ( MissingKeys = iota KeysPresent )
Address HasKeys values.
const ( OriginalAddress AliasAddress CustomAddress PremiumAddress )
Address types.
const ( NoSendAddress = iota MainSendAddress SecondarySendAddress )
Address Send values.
const ( DispositionInline = "inline" DispositionAttachment = "attachment" )
const ( CardEncrypted = 1 CardSigned = 2 )
const ( EventRefreshMail = 1 EventRefreshContact = 2 EventRefreshAll = 255 )
Flags for event refresh.
const ( MaxImportMessageRequestLength = 10 MaxImportMessageRequestSize = 25 * 1024 * 1024 // 25 MB total limit )
const ( UseToVerifyFlag = 1 << iota UseToEncryptFlag )
Key flags.
const ( InboxLabel = "0" AllDraftsLabel = "1" AllSentLabel = "2" TrashLabel = "3" SpamLabel = "4" AllMailLabel = "5" ArchiveLabel = "6" SentLabel = "7" DraftLabel = "8" StarredLabel = "10" LabelTypeMailbox = 1 LabelTypeContactGroup = 2 )
System labels.
const ( EmailClientType = iota + 1 VPNClientType )
ClientType is required by API.
const ( DraftActionReply = 0 DraftActionReplyAll = 1 DraftActionForward = 2 )
Draft actions.
const ( InternalPackage = PackageFlag(1) EncryptedOutsidePackage = PackageFlag(2) ClearPackage = PackageFlag(4) PGPInlinePackage = PackageFlag(8) PGPMIMEPackage = PackageFlag(16) ClearMIMEPackage = PackageFlag(32) )
Send message package types.
const ( SignatureNone = SignatureFlag(0) SignatureDetached = SignatureFlag(1) SignatureAttachedArmored = SignatureFlag(2) )
Send signature types.
const ( MessageHeader = "-----BEGIN PGP MESSAGE-----" MessageTail = "-----END PGP MESSAGE-----" MessageHeaderLegacy = "---BEGIN ENCRYPTED MESSAGE---" MessageTailLegacy = "---END ENCRYPTED MESSAGE---" RandomKeyHeader = "---BEGIN ENCRYPTED RANDOM KEY---" RandomKeyTail = "---END ENCRYPTED RANDOM KEY---" )
Header types.
const ( SortByTo = "To" SortByFrom = "From" SortBySubject = "Subject" SortBySize = "Size" SortByTime = "Time" SortByID = "ID" SortDesc = true SortAsc = false )
Sort types.
const ( ActionReply = 0 ActionReplyAll = 1 ActionForward = 2 )
Message actions.
const ( FlagReceived = 1 FlagSent = 2 FlagInternal = 4 FlagE2E = 8 FlagAuto = 16 FlagReplied = 32 FlagRepliedAll = 64 FlagForwarded = 128 FlagAutoreplied = 256 FlagImported = 512 FlagOpened = 1024 FlagReceiptSent = 2048 )
Message flag definitions.
const ( FlagReceiptRequest = 1 << 16 FlagPublicKey = 1 << 17 FlagSign = 1 << 18 )
Draft flags.
const ( FlagSpfFail = 1 << 24 FlagDkimFail = 1 << 25 FlagDmarcFail = 1 << 26 FlagHamManual = 1 << 27 FlagSpamAuto = 1 << 28 FlagSpamManual = 1 << 29 FlagPhishingAuto = 1 << 30 FlagPhishingManual = 1 << 31 )
Spam flags.
const ( FlagMaskGeneral = 4095 FlagMaskDraft = FlagReceiptRequest * 7 FlagMaskSpam = FlagSpfFail * 255 FlagMask = FlagMaskGeneral | FlagMaskDraft | FlagMaskSpam )
Message flag masks.
const ( ContentTypeMultipartMixed = "multipart/mixed" ContentTypeMultipartEncrypted = "multipart/encrypted" ContentTypePlainText = "text/plain" ContentTypeHTML = "text/html" )
Content types.
const ( MessageTypeInbox int = iota MessageTypeDraft MessageTypeSent MessageTypeInboxAndSent )
const ( FreeUserRole = iota PaidMemberRole PaidAdminRole )
Role values.
const ( DeletedUser = 0 DisabledUser = 1 ActiveUser = 2 VPNAdminUser = 3 AdminUser = 4 SuperUser = 5 )
User status.
const ( CurrentUser = iota AvailableUser OverdueUser DelinquentUser NoReceiveUser )
Delinquent values.
const ( PMSignatureDisabled = iota PMSignatureEnabled PMSignatureLocked )
PMSignature values.
const ConversationIDDomain = `protonmail.conversationid`
ConversationIDDomain is used as a placeholder for conversation reference headers to improve compatibility with various clients.
const (
FlagMaskAdd = 4067 + (16777216 * 168)
)
INTERNAL, AUTO are immutable. E2E is immutable except for drafts on send.
const InternalIDDomain = `protonmail.internalid`
InternalIDDomain is used as a placeholder for reference/message ID headers to improve compatibility with various clients.
const TLSReportURI = "https://reports.protonmail.ch/reports/tls"
TLSReportURI is the address where TLS reports should be sent.
Variables ¶
var ( ErrNoConnection = errors.New("no internet connection") ErrUpgradeApplication = errors.New("application upgrade required") ErrBad2FACode = errors.New("incorrect 2FA code") ErrBad2FACodeTryAgain = errors.New("incorrect 2FA code: please try again") )
var ErrNoKeyringAvailable = errors.New("no keyring available")
ErrNoKeyringAvailable represents an error caused by a keyring being nil or having no entities.
var ErrTLSMismatch = errors.New("no TLS fingerprint match found")
ErrTLSMismatch indicates that no TLS fingerprint match could be found.
var LabelColors = []string{
"#7272a7",
"#cf5858",
"#c26cc7",
"#7569d1",
"#69a9d1",
"#5ec7b7",
"#72bb75",
"#c3d261",
"#e6c04c",
"#e6984c",
"#8989ac",
"#cf7e7e",
"#c793ca",
"#9b94d1",
"#a8c4d5",
"#97c9c1",
"#9db99f",
"#c6cd97",
"#e7d292",
"#dfb286",
}
LabelColors provides the RGB values of the available label colors.
var RxInternalReferenceFormat = regexp.MustCompile(`(?U)<(.+)@` + regexp.QuoteMeta(InternalIDDomain) + `>`) //nolint[gochecknoglobals]
RxInternalReferenceFormat is compiled regexp which describes the match for a message ID used in reference headers.
var TrustedAPIPins = []string{
`pin-sha256="drtmcR2kFkM8qJClsuWgUzxgBkePfRCkRpqUesyDmeE="`,
`pin-sha256="YRGlaY0jyJ4Jw2/4M8FIftwbDIQfh8Sdro96CeEel54="`,
`pin-sha256="AfMENBVvOS8MnISprtvyPsjKlPooqh8nMB/pvCrpJpw="`,
`pin-sha256="8joiNBdqaYiQpKskgtkJsqRxF7zN0C0aqfi8DacknnI="`,
`pin-sha256="JMI8yrbc6jB1FYGyyWRLFTmDNgIszrNEMGlgy972e7w="`,
`pin-sha256="Iu44zU84EOCZ9vx/vz67/MRVrxF1IO4i4NIa8ETwiIY="`,
`pin-sha256="EU6TS9MO0L/GsDHvVc9D5fChYLNy5JdGYpJw0ccgetM="`,
`pin-sha256="iKPIHPnDNqdkvOnTClQ8zQAIKG0XavaPkcEo0LBAABA="`,
`pin-sha256="MSlVrBCdL0hKyczvgYVSRNm88RicyY04Q2y5qrBt0xA="`,
`pin-sha256="C2UxW0T1Ckl9s+8cXfjXxlEqwAfPM4HiW2y3UdtBeCw="`,
}
TrustedAPIPins contains trusted public keys of the protonmail API and proxies. NOTE: the proxy pins are the same for all proxy servers, guaranteed by infra team ;).
Functions ¶
func ComputeMessageFlagsByLabels ¶
ComputeMessageFlagsByLabels returns flags based on labels.
func ConstructAddress ¶
func ContextWithoutAuthRefresh ¶ added in v1.8.0
func ContextWithoutRetry ¶ added in v1.8.0
func CreateTransportWithDialer ¶
CreateTransportWithDialer creates an http.Transport that uses the given dialer to make TLS connections.
func HashMailboxPassword ¶
HashMailboxPassword expectects 128bit long salt encoded by standard base64.
func IsSystemLabel ¶
IsSystemLabel checks if a label is a pre-defined system label.
func LeastUsedColor ¶
LeastUsedColor is intended to return color for creating a new inbox or label.
func SanitizeEmail ¶
Types ¶
type Address ¶
type Address struct { ID string DomainID string Email string Send int Receive Boolean Status int Order int `json:",omitempty"` Type int DisplayName string Signature string MemberID string `json:",omitempty"` MemberName string `json:",omitempty"` HasKeys int Keys PMKeys }
Address represents a user's address.
type AddressList ¶
type AddressList []*Address
AddressList is a list of addresses.
func (AddressList) ActiveEmails ¶
func (l AddressList) ActiveEmails() (addresses []string)
ActiveEmails returns only active emails.
func (AddressList) AllEmails ¶
func (l AddressList) AllEmails() (addresses []string)
AllEmails returns all emails.
func (AddressList) ByEmail ¶
func (l AddressList) ByEmail(email string) *Address
ByEmail gets an address by email. Returns nil if no address is found.
func (AddressList) ByID ¶
func (l AddressList) ByID(id string) *Address
ByID returns an address by id. Returns nil if no address is found.
type Attachment ¶
type Attachment struct { ID string `json:",omitempty"` MessageID string `json:",omitempty"` // msg v3 ??? Name string `json:",omitempty"` Size int64 `json:",omitempty"` MIMEType string `json:",omitempty"` ContentID string `json:",omitempty"` Disposition string KeyPackets string `json:",omitempty"` Signature string `json:",omitempty"` Header textproto.MIMEHeader `json:"-"` }
Attachment represents a message attachment.
func (*Attachment) DetachedSign ¶
func (*Attachment) MarshalJSON ¶
func (a *Attachment) MarshalJSON() ([]byte, error)
func (*Attachment) UnmarshalJSON ¶
func (a *Attachment) UnmarshalJSON(b []byte) error
type Auth ¶
type Auth struct { AuthRefresh UserID string ServerProof string PasswordMode PasswordMode TwoFA *TwoFAInfo `json:"2FA,omitempty"` }
func (Auth) HasMailboxPassword ¶
func (Auth) HasTwoFactor ¶
type AuthModulus ¶ added in v1.8.0
type AuthRefresh ¶ added in v1.8.0
type AuthRefreshHandler ¶ added in v1.8.0
type AuthRefreshHandler func(*AuthRefresh)
type BasicTLSDialer ¶
type BasicTLSDialer struct {
// contains filtered or unexported fields
}
BasicTLSDialer implements TLSDialer.
func NewBasicTLSDialer ¶
func NewBasicTLSDialer(cfg Config) *BasicTLSDialer
NewBasicTLSDialer returns a new BasicTLSDialer.
type Boolean ¶ added in v1.8.0
type Boolean bool
func (Boolean) MarshalJSON ¶ added in v1.8.0
func (*Boolean) UnmarshalJSON ¶ added in v1.8.0
type Client ¶
type Client interface { Auth2FA(context.Context, string) error AuthSalt(ctx context.Context) (string, error) AuthDelete(context.Context) error AddAuthRefreshHandler(AuthRefreshHandler) CurrentUser(ctx context.Context) (*User, error) UpdateUser(ctx context.Context) (*User, error) Unlock(ctx context.Context, passphrase []byte) (err error) ReloadKeys(ctx context.Context, passphrase []byte) (err error) IsUnlocked() bool Addresses() AddressList GetAddresses(context.Context) (addresses AddressList, err error) ReorderAddresses(ctx context.Context, addressIDs []string) error GetEvent(ctx context.Context, eventID string) (*Event, error) SendMessage(context.Context, string, *SendMessageReq) (sent, parent *Message, err error) CreateDraft(ctx context.Context, m *Message, parent string, action int) (created *Message, err error) Import(context.Context, ImportMsgReqs) ([]*ImportMsgRes, error) CountMessages(ctx context.Context, addressID string) ([]*MessagesCount, error) ListMessages(ctx context.Context, filter *MessagesFilter) ([]*Message, int, error) GetMessage(ctx context.Context, apiID string) (*Message, error) DeleteMessages(ctx context.Context, apiIDs []string) error LabelMessages(ctx context.Context, apiIDs []string, labelID string) error UnlabelMessages(ctx context.Context, apiIDs []string, labelID string) error MarkMessagesRead(ctx context.Context, apiIDs []string) error MarkMessagesUnread(ctx context.Context, apiIDs []string) error ListLabels(ctx context.Context) ([]*Label, error) CreateLabel(ctx context.Context, label *Label) (*Label, error) UpdateLabel(ctx context.Context, label *Label) (*Label, error) DeleteLabel(ctx context.Context, labelID string) error EmptyFolder(ctx context.Context, labelID string, addressID string) error GetMailSettings(ctx context.Context) (MailSettings, error) GetContactEmailByEmail(context.Context, string, int, int) ([]ContactEmail, error) GetContactByID(context.Context, string) (Contact, error) DecryptAndVerifyCards([]Card) ([]Card, error) GetAttachment(ctx context.Context, id string) (att io.ReadCloser, err error) CreateAttachment(ctx context.Context, att *Attachment, r io.Reader, sig io.Reader) (created *Attachment, err error) KeyRingForAddressID(string) (kr *crypto.KeyRing, err error) GetPublicKeysForEmail(context.Context, string) ([]PublicKey, bool, error) }
Client defines the interface of a PMAPI client.
type Config ¶ added in v1.8.0
type Config struct { // HostURL is the base URL of API. HostURL string // AppVersion sets version to headers of each request. AppVersion string // UserAgent sets user agent to headers of each request. // Used only if GetUserAgent is not set. UserAgent string // GetUserAgent is dynamic version of UserAgent. // Overrides UserAgent. GetUserAgent func() string // UpgradeApplicationHandler is used to notify when there is a force upgrade. UpgradeApplicationHandler func() // TLSIssueHandler is used to notify when there is a TLS issue. TLSIssueHandler func() }
type ConnectionObserver ¶ added in v1.8.0
type ConnectionObserver interface { OnDown() OnUp() }
func NewConnectionObserver ¶ added in v1.8.0
func NewConnectionObserver(onDown, onUp func()) ConnectionObserver
NewConnectionObserver is a helper function to create a new connection observer from two callbacks. It doesn't need to be used; anything which implements the ConnectionObserver interface can be an observer.
type ContactEmail ¶
type DraftReq ¶
type DraftReq struct { Message *Message ParentID string `json:",omitempty"` Action int AttachmentKeyPackets []string }
DraftReq defines paylod for creating drafts.
type ErrUnprocessableEntity ¶
type ErrUnprocessableEntity struct {
// contains filtered or unexported fields
}
func (ErrUnprocessableEntity) Error ¶
func (err ErrUnprocessableEntity) Error() string
type Event ¶
type Event struct { // The current event ID. EventID string // If set to one, all cached data must be fetched again. Refresh int // If set to one, fetch more events. More Boolean // Changes applied to messages. Messages []*EventMessage // Counts of messages per labels. MessageCounts []*MessagesCount // Changes applied to labels. Labels []*EventLabel // Current user status. User User // Changes to addresses. Addresses []*EventAddress // Messages to show to the user. Notices []string }
Event represents changes since the last check.
type EventAction ¶
type EventAction int
EventAction is the action that created a change.
const ( EventDelete EventAction = iota // Item has been deleted. EventCreate // Item has been created. EventUpdate // Item has been updated. EventUpdateFlags // For messages: flags have been updated. )
type EventAddress ¶
EventAddress is an address that has changed.
type EventItem ¶
type EventItem struct { ID string Action EventAction }
EventItem is an item that has changed.
type EventLabel ¶
EventLabel is a label that has changed.
type EventMessage ¶
type EventMessage struct { EventItem // If the message has been created, the new message. Created *Message `json:"-"` // If the message has been updated, the updated fields. Updated *EventMessageUpdated `json:"-"` }
EventMessage is a message that has changed.
func (*EventMessage) MarshalJSON ¶
func (em *EventMessage) MarshalJSON() ([]byte, error)
func (*EventMessage) UnmarshalJSON ¶
func (em *EventMessage) UnmarshalJSON(b []byte) (err error)
type EventMessageUpdated ¶
type EventMessageUpdated struct { ID string Subject *string Unread *Boolean Flags *int64 Sender *mail.Address ToList *[]*mail.Address CCList *[]*mail.Address BCCList *[]*mail.Address Time int64 // Fields only present for EventUpdateFlags. LabelIDs []string LabelIDsAdded []string LabelIDsRemoved []string }
EventMessageUpdated contains changed fields for an updated message.
type GetAuthInfoReq ¶ added in v1.8.0
type GetAuthInfoReq struct {
Username string
}
type ImportMetadata ¶ added in v1.8.0
type ImportMetadata struct { AddressID string Unread Boolean // 0: read, 1: unread. IsReplied Boolean // 1 if the message has been replied. IsRepliedAll Boolean // 1 if the message has been replied to all. IsForwarded Boolean // 1 if the message has been forwarded. Time int64 // The time when the message was received as a Unix time. Flags int64 // The type of the imported message. LabelIDs []string // The labels to apply to the imported message. Must contain at least one system label. }
type ImportMsgReq ¶
type ImportMsgReq struct { Metadata *ImportMetadata // Metadata about the message to import. Message []byte // The raw RFC822 message. }
type ImportMsgReqs ¶ added in v1.8.0
type ImportMsgReqs []*ImportMsgReq
type ImportMsgRes ¶
type Label ¶
type Label struct { ID string Name string Path string Color string Order int `json:",omitempty"` Display int // Not used for now, leave it empty. Exclusive Boolean Type int Notify Boolean }
Label for message.
type LabelMessagesReq ¶
type LabelsOperation ¶
type LabelsOperation int
LabelsOperation is the operation to apply to labels.
const ( KeepLabels LabelsOperation = iota // Do nothing. ReplaceLabels // Replace current labels with new ones. AddLabels // Add new labels to current ones. RemoveLabels // Remove specified labels from current ones. )
type MailSettings ¶
type MailSettings struct { DisplayName string Signature string `json:",omitempty"` Theme string `json:",omitempty"` AutoSaveContacts int AutoWildcardSearch int ComposerMode int MessageButtons int ShowImages int ShowMoved int ViewMode int ViewLayout int SwipeLeft int SwipeRight int AlsoArchive int Hotkeys int PMSignature int ImageProxy int TLS int RightToLeft int AttachPublicKey int Sign int PGPScheme PackageFlag PromptPin int Autocrypt int NumMessagePerPage int DraftMIMEType string ReceiveMIMEType string ShowMIMEType string }
type Manager ¶ added in v1.8.0
type Manager interface { NewClient(string, string, string, time.Time) Client NewClientWithRefresh(context.Context, string, string) (Client, *AuthRefresh, error) NewClientWithLogin(context.Context, string, []byte) (Client, *Auth, error) DownloadAndVerify(kr *crypto.KeyRing, url, sig string) ([]byte, error) ReportBug(context.Context, ReportBugReq) error SendSimpleMetric(context.Context, string, string, string) error SetLogging(logger *logrus.Entry, verbose bool) SetTransport(http.RoundTripper) SetCookieJar(http.CookieJar) SetRetryCount(int) AddConnectionObserver(ConnectionObserver) AllowProxy() DisallowProxy() }
type Message ¶
type Message struct { ID string `json:",omitempty"` Order int64 `json:",omitempty"` ConversationID string `json:",omitempty"` // only filter Subject string Unread Boolean Type int Flags int64 Sender *mail.Address ReplyTo *mail.Address `json:",omitempty"` ReplyTos []*mail.Address `json:",omitempty"` ToList []*mail.Address CCList []*mail.Address BCCList []*mail.Address Time int64 // Unix time Size int64 NumAttachments int ExpirationTime int64 // Unix time SpamScore int AddressID string Body string `json:",omitempty"` Attachments []*Attachment LabelIDs []string ExternalID string Header mail.Header MIMEType string }
Message structure.
func (*Message) ExtractSignatures ¶ added in v1.8.5
func (*Message) HasLabelID ¶
HasLabelID returns whether the message has the `labelID`.
func (*Message) IsBodyEncrypted ¶
func (*Message) IsDraft ¶
IsDraft returns whether the message should be considered to be a draft. A draft is complicated. It might have pmapi.DraftLabel but it might not. The real API definition of IsDraft is that it is neither sent nor received -- we should use that here.
func (*Message) IsEncrypted ¶
func (*Message) IsLegacyMessage ¶
func (*Message) MarshalJSON ¶
func (*Message) Recipients ¶ added in v1.8.10
func (*Message) UnmarshalJSON ¶
type MessageAddress ¶
type MessageAddress struct { Type PackageFlag EncryptedBodyKeyPacket string `json:"BodyKeyPacket,omitempty"` // base64-encoded key packet. Signature SignatureFlag EncryptedAttachmentKeyPackets map[string]string `json:"AttachmentKeyPackets,omitempty"` }
type MessagePackage ¶
type MessagePackage struct { Addresses map[string]*MessageAddress Type PackageFlag MIMEType string EncryptedBody string `json:"Body"` // base64-encoded encrypted data packet. DecryptedBodyKey *AlgoKey `json:"BodyKey,omitempty"` // base64-encoded session key (only if cleartext recipients). DecryptedAttachmentKeys map[string]AlgoKey `json:"AttachmentKeys,omitempty"` // Only include if cleartext & attachments. }
type MessagesActionReq ¶
type MessagesActionReq struct {
IDs []string
}
type MessagesCount ¶
MessagesCount contains message counts for one label.
type MessagesFilter ¶
type MessagesFilter struct { Page int PageSize int Limit int LabelID string Sort string // Time by default (Time, To, From, Subject, Size). Desc *bool Begin int64 // Unix time. End int64 // Unix time. BeginID string EndID string Keyword string To string From string Subject string ConversationID string AddressID string ID []string Attachments *bool Unread *bool ExternalID string // MIME Message-Id (only valid for messages). AutoWildcard *bool }
MessagesFilter contains fields to filter messages.
type PMKey ¶
type PMKey struct { ID string Version int Flags int Fingerprint string PrivateKey *crypto.Key Primary int Token string Active Boolean Signature string }
func (*PMKey) UnmarshalJSON ¶
type PMKeys ¶
type PMKeys []PMKey
func (*PMKeys) UnlockAll ¶
func (keys *PMKeys) UnlockAll(passphrase []byte, userKey *crypto.KeyRing) (kr *crypto.KeyRing, err error)
UnlockAll goes through each key and unlocks it, returning a keyring containing all unlocked keys, or an error if no keys could be unlocked. The passphrase is used to unlock the key unless the key's token and signature are both non-nil, in which case the given userkey is used to deduce the passphrase.
type PackageFlag ¶
type PackageFlag int
PackageFlag for send message package types.
func (*PackageFlag) Has ¶
func (p *PackageFlag) Has(flag PackageFlag) bool
func (*PackageFlag) HasAtLeastOne ¶
func (p *PackageFlag) HasAtLeastOne(flag PackageFlag) bool
func (*PackageFlag) HasNo ¶
func (p *PackageFlag) HasNo(flag PackageFlag) bool
func (*PackageFlag) Is ¶
func (p *PackageFlag) Is(flag PackageFlag) bool
type PasswordMode ¶ added in v1.8.0
type PasswordMode int
const ( OnePasswordMode PasswordMode = iota + 1 TwoPasswordMode )
type PinningTLSDialer ¶
type PinningTLSDialer struct {
// contains filtered or unexported fields
}
PinningTLSDialer wraps a TLSDialer to check fingerprints after connecting and to report errors if the fingerprint check fails.
func NewPinningTLSDialer ¶
func NewPinningTLSDialer(cfg Config, dialer TLSDialer) *PinningTLSDialer
NewPinningTLSDialer constructs a new dialer which only returns tcp connections to servers which present known certificates. If enabled, it reports any invalid certificates it finds.
type ProxyTLSDialer ¶
type ProxyTLSDialer struct {
// contains filtered or unexported fields
}
ProxyTLSDialer wraps a TLSDialer to switch to a proxy if the initial dial fails.
func NewProxyTLSDialer ¶
func NewProxyTLSDialer(cfg Config, dialer TLSDialer) *ProxyTLSDialer
NewProxyTLSDialer constructs a dialer which provides a proxy-managing layer on top of an underlying dialer.
func (*ProxyTLSDialer) AllowProxy ¶ added in v1.8.0
func (d *ProxyTLSDialer) AllowProxy()
AllowProxy allows the dialer to switch to a proxy if need be.
func (*ProxyTLSDialer) DialTLS ¶
func (d *ProxyTLSDialer) DialTLS(network, address string) (net.Conn, error)
DialTLS dials the given network/address. If it fails, it retries using a proxy.
func (*ProxyTLSDialer) DisallowProxy ¶ added in v1.8.0
func (d *ProxyTLSDialer) DisallowProxy()
DisallowProxy prevents the dialer from switching to a proxy if need be.
type RecipientType ¶ added in v1.8.0
type RecipientType int
const ( RecipientTypeInternal RecipientType = iota + 1 RecipientTypeExternal )
type ReportBugReq ¶ added in v1.8.0
type ReportBugReq struct { OS string `json:",omitempty"` OSVersion string `json:",omitempty"` Browser string `json:",omitempty"` BrowserVersion string `json:",omitempty"` BrowserExtensions string `json:",omitempty"` Resolution string `json:",omitempty"` DisplayMode string `json:",omitempty"` Client string `json:",omitempty"` ClientVersion string `json:",omitempty"` ClientType int `json:",omitempty"` Title string `json:",omitempty"` Description string `json:",omitempty"` Username string `json:",omitempty"` Email string `json:",omitempty"` Country string `json:",omitempty"` ISP string `json:",omitempty"` Debug string `json:",omitempty"` Attachments []reportAtt `json:",omitempty"` }
ReportBugReq stores data for report.
func (*ReportBugReq) AddAttachment ¶ added in v1.8.0
func (rep *ReportBugReq) AddAttachment(name, filename string, r io.Reader)
AddAttachment to report.
func (*ReportBugReq) GetMultipartFormData ¶ added in v1.8.0
func (rep *ReportBugReq) GetMultipartFormData() map[string]string
type SendMessageReq ¶
type SendMessageReq struct { ExpirationTime int64 `json:",omitempty"` // Data for encrypted recipients. Packages []*MessagePackage `json:",omitempty"` // contains filtered or unexported fields }
func NewSendMessageReq ¶
func NewSendMessageReq( kr *crypto.KeyRing, mimeBody, plainBody, richBody string, attKeys map[string]*crypto.SessionKey, ) *SendMessageReq
func (*SendMessageReq) AddRecipient ¶
func (req *SendMessageReq) AddRecipient( email string, sendScheme PackageFlag, pubkey *crypto.KeyRing, signature SignatureFlag, contentType string, doEncrypt bool, ) (err error)
func (*SendMessageReq) PreparePackages ¶
func (req *SendMessageReq) PreparePackages()
type SignatureFlag ¶
type SignatureFlag int
SignatureFlag for send signature types.
func (*SignatureFlag) Has ¶
func (p *SignatureFlag) Has(flag SignatureFlag) bool
func (*SignatureFlag) HasNo ¶
func (p *SignatureFlag) HasNo(flag SignatureFlag) bool
func (*SignatureFlag) Is ¶
func (p *SignatureFlag) Is(flag SignatureFlag) bool
type TwoFAInfo ¶ added in v1.8.0
type TwoFAInfo struct {
Enabled TwoFAStatus
}
type TwoFAStatus ¶ added in v1.8.0
type TwoFAStatus int
const ( TwoFADisabled TwoFAStatus = iota TOTPEnabled U2FEnabled TOTPAndU2FEnabled )
type User ¶
type User struct { ID string Name string UsedSpace int64 Currency string Credit int MaxSpace int64 MaxUpload int64 Role int Private int Subscribed int Services int Deliquent int Keys PMKeys VPN struct { Status int ExpirationTime int PlanName string MaxConnect int MaxTier int } }
User holds the user details.
Source Files ¶
- addresses.go
- attachments.go
- auth.go
- boolean.go
- client.go
- client_keys.go
- client_types.go
- config.go
- config_default.go
- contacts.go
- context.go
- dialer_basic.go
- dialer_pinning.go
- dialer_pinning_checker.go
- dialer_pinning_report.go
- dialer_pinning_reporter.go
- dialer_proxy.go
- dialer_proxy_provider.go
- errors.go
- events.go
- import.go
- key.go
- keyring.go
- labels.go
- manager.go
- manager_auth.go
- manager_download.go
- manager_log.go
- manager_metrics.go
- manager_ping.go
- manager_proxy.go
- manager_report.go
- manager_report_types.go
- manager_types.go
- message_send.go
- messages.go
- observer.go
- paging.go
- passwords.go
- pmapi.go
- response.go
- settings.go
- users.go
- utils.go