Documentation ¶
Index ¶
- type AddressUpdate
- type BridgePassProvider
- type FixedBridgePassProvider
- type IdentityProvider
- type KeyPassProvider
- type Service
- func (s *Service) CheckAuth(ctx context.Context, email string, password []byte) (string, error)
- func (s *Service) GetAPIUser(ctx context.Context) (proton.User, error)
- func (s *Service) GetAddresses(ctx context.Context) (map[string]proton.Address, error)
- func (s *Service) HandleAddressEvents(ctx context.Context, addressEvents []proton.AddressEvent) error
- func (s *Service) HandleRefreshEvent(ctx context.Context, _ proton.RefreshFlag) error
- func (s *Service) HandleUsedSpaceEvent(ctx context.Context, newSpace int64) error
- func (s *Service) HandleUserEvent(ctx context.Context, user *proton.User) error
- func (s *Service) Resync(ctx context.Context) error
- func (s *Service) Start(ctx context.Context, group *orderedtasks.OrderedCancelGroup)
- type State
- func (s *State) CheckAuth(email string, password []byte, bridgePassProvider BridgePassProvider) (string, error)
- func (s *State) Clone() *State
- func (s *State) GetAddr(email string) (proton.Address, error)
- func (s *State) GetAddrByID(id string) (proton.Address, bool)
- func (s *State) GetPrimaryAddr() (proton.Address, error)
- func (s *State) OnAddressCreated(event proton.AddressEvent) AddressUpdate
- func (s *State) OnAddressDeleted(event proton.AddressEvent) (proton.Address, AddressUpdate)
- func (s *State) OnAddressEvents(events []proton.AddressEvent)
- func (s *State) OnAddressUpdated(event proton.AddressEvent) (proton.Address, AddressUpdate)
- func (s *State) OnRefreshEvent(ctx context.Context) error
- func (s *State) OnUserEvent(user proton.User)
- func (s *State) OnUserSpaceChanged(value uint64) bool
- func (s *State) WithAddrKR(addrID string, keyPass []byte, fn func(userKR, addrKR *crypto.KeyRing) error) error
- func (s *State) WithAddrKRs(keyPass []byte, fn func(*crypto.KeyRing, map[string]*crypto.KeyRing) error) error
- type Telemetry
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AddressUpdate ¶
type AddressUpdate int
const ( AddressUpdateNoop AddressUpdate = iota AddressUpdateCreated AddressUpdateEnabled AddressUpdateDisabled AddressUpdateUpdated AddressUpdateDeleted )
type BridgePassProvider ¶
type BridgePassProvider interface {
BridgePass() []byte
}
type FixedBridgePassProvider ¶
type FixedBridgePassProvider struct {
// contains filtered or unexported fields
}
func NewFixedBridgePassProvider ¶
func NewFixedBridgePassProvider(pass []byte) *FixedBridgePassProvider
func (FixedBridgePassProvider) BridgePass ¶
func (f FixedBridgePassProvider) BridgePass() []byte
type IdentityProvider ¶
type KeyPassProvider ¶
type KeyPassProvider interface {
KeyPass() []byte
}
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
Service contains all the data required to establish the user identity. This includes all the user's information as well as mail addresses and keys.
func NewService ¶
func NewService( service userevents.Subscribable, eventPublisher events.EventPublisher, state *State, bridgePassProvider BridgePassProvider, telemetry Telemetry, ) *Service
func (*Service) GetAddresses ¶
func (*Service) HandleAddressEvents ¶
func (*Service) HandleRefreshEvent ¶
func (*Service) HandleUsedSpaceEvent ¶
func (*Service) HandleUserEvent ¶
func (*Service) Start ¶
func (s *Service) Start(ctx context.Context, group *orderedtasks.OrderedCancelGroup)
type State ¶
type State struct { AddressesSorted []proton.Address Addresses map[string]proton.Address User proton.User // contains filtered or unexported fields }
State holds all the required user identity state. The idea of this type is that it can be replicated across all services to avoid lock contention. The only requirement is that the service with the respective events.
func NewState ¶
func NewState( user proton.User, addresses []proton.Address, provider IdentityProvider, ) *State
func NewStateFromProvider ¶
func NewStateFromProvider(ctx context.Context, provider IdentityProvider) (*State, error)
func (*State) CheckAuth ¶
func (s *State) CheckAuth(email string, password []byte, bridgePassProvider BridgePassProvider) (string, error)
CheckAuth returns whether the given email and password can be used to authenticate over IMAP or SMTP with this user. It returns the address ID of the authenticated address.
func (*State) GetAddrByID ¶
GetAddrByID returns the address for the given addressID.
func (*State) GetPrimaryAddr ¶
GetPrimaryAddr returns the primary address for this user.
func (*State) OnAddressCreated ¶
func (s *State) OnAddressCreated(event proton.AddressEvent) AddressUpdate
func (*State) OnAddressDeleted ¶
func (s *State) OnAddressDeleted(event proton.AddressEvent) (proton.Address, AddressUpdate)
func (*State) OnAddressEvents ¶
func (s *State) OnAddressEvents(events []proton.AddressEvent)
func (*State) OnAddressUpdated ¶
func (s *State) OnAddressUpdated(event proton.AddressEvent) (proton.Address, AddressUpdate)
func (*State) OnUserEvent ¶
func (s *State) OnUserEvent(user proton.User)