Documentation
¶
Index ¶
- Constants
- func CheckIfMailioServer(domain string) (*types.Discovery, error)
- func GetHandshakeByID(userRepo repository.Repository, handshakeOwnerAddress string, ...) (*types.Handshake, error)
- func GetHandshakeByMailioAddress(userRepo repository.Repository, handshakeOwnerAddress string, ...) (*types.Handshake, error)
- func RemoveExpiredDocuments(repo repository.Repository, designDoc string, viewName string, ...) error
- type DomainService
- type MalwareService
- type MessageDeliveryService
- type MtpService
- func (mtp *MtpService) FetchDIDDocuments(userMailioAddress string, didLookups []*types.DIDLookup) (found []*types.DIDLookup, notFound []*types.DIDLookup, err error)
- func (mtp *MtpService) FetchRemoteDIDByEmailHash(userMailioAddress string, lookups map[string][]*types.DIDLookup) (found []*types.DIDLookup, notFound []*types.DIDLookup, err error)
- func (mtp *MtpService) GetLocalDIDDocumentsByEmailHash(localLookups []*types.DIDLookup) (found []*types.DIDLookup, notFound []*types.DIDLookup, err error)
- func (mtp *MtpService) GetServerDIDDocument(domain string) (*did.Document, error)
- func (mtp *MtpService) LocalHandshakeLookup(senderAddress string, lookups []types.HandshakeLookup) (found []*types.HandshakeContent, notFound []*types.HandshakeLookup, ...)
- func (mtp *MtpService) LookupHandshakes(senderAddress string, inputLookups []types.HandshakeLookup) ([]*types.HandshakeContent, []*types.HandshakeLookup, error)
- func (mtp *MtpService) ResolveDomain(domain string, forceDiscovery bool) (*types.Domain, error)
- type NonceService
- func (ns *NonceService) CreateCustomNonce(nonceSizeInBytes int) (*types.Nonce, error)
- func (ns *NonceService) CreateNonce() (*types.Nonce, error)
- func (ns *NonceService) DeleteNonce(nonce string) error
- func (ns *NonceService) GetNonce(nonce string) (*types.Nonce, error)
- func (ns *NonceService) RemoveExpiredNonces()
- type S3Service
- type SelfSovereignService
- func (ssi *SelfSovereignService) FetchDIDByWebDID(fromDID did.DID) (*did.Document, error)
- func (ssi *SelfSovereignService) FetchRemoteDID(remoteDid *did.DID) (*did.Document, error)
- func (ssi *SelfSovereignService) GetAuthorizedAppVCByAddress(address string, issuerDID string) (*did.VerifiableCredential, error)
- func (ssi *SelfSovereignService) GetDIDDocument(mailioAddress string) (*did.Document, error)
- func (ssi *SelfSovereignService) GetVCByID(ID string) (*did.VerifiableCredential, error)
- func (ssi *SelfSovereignService) ListSubjectVCs(address string, limit int, bookmark string) ([]*did.VerifiableCredential, error)
- func (ssi *SelfSovereignService) SaveDID(did *did.Document) (*did.Document, error)
- func (ssi *SelfSovereignService) SaveVC(vc *did.VerifiableCredential) (*did.VerifiableCredential, error)
- func (ssi *SelfSovereignService) StoreRegistrationSSI(mk *did.MailioKey) error
- type SmartKeyService
- func (rks *SmartKeyService) DeleteDeviceKeyTransfer(id string) error
- func (rks *SmartKeyService) DeleteSmartKey(address string) error
- func (rks *SmartKeyService) GetDeviceKeyTransfer(id string) (*types.DeviceKeyTransfer, error)
- func (rks *SmartKeyService) GetSmartKey(address string) (*types.SmartKey, error)
- func (rks *SmartKeyService) SaveDeviceKeyTransfer(transfer *types.DeviceKeyTransfer) error
- func (rks *SmartKeyService) SaveSmartKey(rotationKey *types.SmartKey) error
- type StatisticsService
- func (s *StatisticsService) FlushEmailInterests()
- func (s *StatisticsService) FlushEmailStatistics()
- func (s *StatisticsService) FlushSentEmailStatistics()
- func (s *StatisticsService) GetEmailInterest(ctx context.Context, sender string, recipient string) (int64, error)
- func (s *StatisticsService) GetEmailSentByDay(ctx context.Context, sender string, day int64) (int64, error)
- func (s *StatisticsService) GetEmailStatistics(ctx context.Context, sender string, recipient string) (int64, error)
- func (s *StatisticsService) ProcessEmailInterest(sender string, recipient string, messageId string) error
- func (s *StatisticsService) ProcessEmailStatistics(sender string, recipient string) error
- func (s *StatisticsService) ProcessEmailsSentStatistics(sender string) error
- type UserProfileService
- func (s *UserProfileService) Delete(address string) error
- func (s *UserProfileService) DeleteFromCache(address string) error
- func (s *UserProfileService) Get(address string) (*types.UserProfile, error)
- func (s *UserProfileService) GetFromCache(address string) *types.UserProfile
- func (s *UserProfileService) Save(address string, profile *types.UserProfile) (*types.UserProfile, error)
- func (s *UserProfileService) SaveToCache(address string, profile *types.UserProfile) error
- func (s *UserProfileService) Stats(address string) (*types.UserProfileStats, error)
- type UserService
- func (us *UserService) CreateDatabase(user *types.User, databasePassword string) error
- func (us *UserService) CreateUser(user *types.User, mk *did.MailioKey, databasePassword string) (*types.User, error)
- func (us *UserService) DeleteExpiredTransferKeys()
- func (us *UserService) FindUserByScryptEmail(scryptEmail string) (*types.EmailToMailioMapping, error)
- func (us *UserService) MapEmailToMailioAddress(user *types.User) (*types.EmailToMailioMapping, error)
- func (us *UserService) SaveMessage(userAddress string, mailioMessage *types.MailioMessage) (*types.MailioMessage, error)
- type WebAuthnService
Constants ¶
const ( AGE_OF_NON_MAILIO_DOMAINS_BEFORE_REFRESH = 24 * 60 * 60 * 60 * 1000 // 60 days AGE_OF_MAILIO_DOMAINS_BEFORE_REFRESH = 24 * 60 * 60 * 1000 // 1 day )
Variables ¶
This section is empty.
Functions ¶
func GetHandshakeByID ¶
func GetHandshakeByID(userRepo repository.Repository, handshakeOwnerAddress string, handshakeID string) (*types.Handshake, error)
*
- GetByID returns a handshake by ID of a specific mailio user from local database
func GetHandshakeByMailioAddress ¶
func GetHandshakeByMailioAddress(userRepo repository.Repository, handshakeOwnerAddress string, senderAddress string) (*types.Handshake, error)
func RemoveExpiredDocuments ¶
func RemoveExpiredDocuments(repo repository.Repository, designDoc string, viewName string, ttlMinutes int64) error
*
- RemoveExpiredDocuments removes expired documents from the database
- @param repo the repository
- @param designDoc the design document
- @param viewName the view name
- @param ttl the time to live in milliseconds
- @param bulkDeleteEndpoint the bulk delete endpoint
Types ¶
type DomainService ¶
type DomainService struct {
// contains filtered or unexported fields
}
func NewDomainService ¶
func NewDomainService(dbSelector *repository.CouchDBSelector) *DomainService
func (*DomainService) GetDomain ¶
func (ds *DomainService) GetDomain(domain string) (*types.Domain, error)
GetDomain retrieves domain information by domain name (e.g., example.com).
The method performs the following steps: 1. Checks the local database for the domain. If found, it returns the domain. 2. If not found in the local database, it performs an MX record lookup:
- If MX records are found, the domain is stored in the database and returned.
- If MX records are not found, it proceeds to check if the domain is a Mailio server:
- The check includes querying a list of subdomain prefixes.
- If confirmed as a Mailio server, the domain is stored in the database and returned.
Returns an error if the domain cannot be found or stored.
func (*DomainService) ResolveDomain ¶
type MalwareService ¶
type MalwareService struct {
// contains filtered or unexported fields
}
func NewMalwareService ¶
func NewMalwareService() *MalwareService
NewMalwareService loads the malware list from the abuse.ch website
func (*MalwareService) IsMalware ¶
func (ms *MalwareService) IsMalware(md5 string) bool
IsMalware checks if the given md5 is in the malware list
func (*MalwareService) LoadInMemoryMalwareList ¶
func (ms *MalwareService) LoadInMemoryMalwareList() error
LoadInMemoryMalwareList loads the malware list from the abuse.ch website
type MessageDeliveryService ¶
type MessageDeliveryService struct {
// contains filtered or unexported fields
}
func NewMessageDeliveryService ¶
func NewMessageDeliveryService(dbSelector repository.DBSelector) *MessageDeliveryService
func (*MessageDeliveryService) Save ¶
func (mds *MessageDeliveryService) Save(messageDelivery *types.MessageDelivery) error
func (*MessageDeliveryService) SaveBulkMtpStatusCodes ¶
func (mds *MessageDeliveryService) SaveBulkMtpStatusCodes(messageID string, statusCodes []*types.MTPStatusCode)
save bulk message deliveries
type MtpService ¶
type MtpService struct {
// contains filtered or unexported fields
}
func NewMtpService ¶
func NewMtpService(dbSelector repository.DBSelector, env *types.Environment) *MtpService
func (*MtpService) FetchDIDDocuments ¶
func (mtp *MtpService) FetchDIDDocuments(userMailioAddress string, didLookups []*types.DIDLookup) (found []*types.DIDLookup, notFound []*types.DIDLookup, err error)
FetchDIDDocuments fetches DID documents for a list of email addresses FetchDIDDocuments separates local and remote domains and fetches DID documents accordingly Returns a list of found DID documents and a list of not found email addresses Errors:
ErrInvalidEmail when email address is not valid ErrBadRequest when remote server returns code >= 400
func (*MtpService) FetchRemoteDIDByEmailHash ¶
func (mtp *MtpService) FetchRemoteDIDByEmailHash(userMailioAddress string, lookups map[string][]*types.DIDLookup) (found []*types.DIDLookup, notFound []*types.DIDLookup, err error)
FetchRemoteDID fetches DID documents for a list of email addresses with corresponding email hashes Returns a list of found DID documents and a list of not found email addresses userMailioAddress string requesting user lookups map[string][]*types.DIDLookup email domain to list of lookups notFound array is filled out when remote server returns code >= 400
func (*MtpService) GetLocalDIDDocumentsByEmailHash ¶
func (mtp *MtpService) GetLocalDIDDocumentsByEmailHash(localLookups []*types.DIDLookup) (found []*types.DIDLookup, notFound []*types.DIDLookup, err error)
GetLocalDIDDocuments fetches DID documents for a list of email addresses with corresponding email hashes
func (*MtpService) GetServerDIDDocument ¶
func (mtp *MtpService) GetServerDIDDocument(domain string) (*did.Document, error)
GetServerDIDDocument retrieves the server DID document from the domain
func (*MtpService) LocalHandshakeLookup ¶
func (mtp *MtpService) LocalHandshakeLookup(senderAddress string, lookups []types.HandshakeLookup) (found []*types.HandshakeContent, notFound []*types.HandshakeLookup, outputErr error)
Handshake lookup method for Mailio Transfer Protocol returns list of handshakes based on the lookup criteria
func (*MtpService) LookupHandshakes ¶
func (mtp *MtpService) LookupHandshakes(senderAddress string, inputLookups []types.HandshakeLookup) ([]*types.HandshakeContent, []*types.HandshakeLookup, error)
Lookup handshakes locally and if not found then request from remote servers
func (*MtpService) ResolveDomain ¶
Resolve domain from the domain repository
type NonceService ¶
type NonceService struct {
// contains filtered or unexported fields
}
func NewNonceService ¶
func NewNonceService(dbSelector repository.DBSelector) *NonceService
func (*NonceService) CreateCustomNonce ¶
func (ns *NonceService) CreateCustomNonce(nonceSizeInBytes int) (*types.Nonce, error)
function creates a new nonce and stores it in the database with the time of creation
func (*NonceService) CreateNonce ¶
func (ns *NonceService) CreateNonce() (*types.Nonce, error)
function creates a new nonce and stores it in the database with the time of creation
func (*NonceService) DeleteNonce ¶
func (ns *NonceService) DeleteNonce(nonce string) error
Delte nonce by nonce id (which is nonce itself)
func (*NonceService) GetNonce ¶
func (ns *NonceService) GetNonce(nonce string) (*types.Nonce, error)
Returns nonce by nonce id (wich is nonce itself) from database
func (*NonceService) RemoveExpiredNonces ¶
func (ns *NonceService) RemoveExpiredNonces()
RemoveExpiredNonces loops and bulk deletes nonces until total_rows == 0
type S3Service ¶
type S3Service struct {
// contains filtered or unexported fields
}
func NewS3Service ¶
func NewS3Service(env *types.Environment) *S3Service
func (*S3Service) DeleteAttachment ¶
Delete attachment at specific bucket and path
func (*S3Service) DownloadAttachment ¶
download attachment from s3
type SelfSovereignService ¶
type SelfSovereignService struct {
// contains filtered or unexported fields
}
func NewSelfSovereignService ¶
func NewSelfSovereignService(dbSelector repository.DBSelector, env *types.Environment) *SelfSovereignService
Self Sovereign Service operates over Mailios DID and VC documents
func (*SelfSovereignService) FetchDIDByWebDID ¶
cacheSenderDIDDocument caches the sender DID document (if not already cached)
func (*SelfSovereignService) FetchRemoteDID ¶
FetchRemoteDID parses the WEB did and fetched DID document from the remote server FetchRemoteDID doesn't resolve domains since it expects already resolved domain Returns the DID document for the given web mailio address - ErrInvalidFormat when DID address not valid - ErrBadRequest when remote server returns code >= 400 - ErrConflict when rate limit of remote server exceeded - ErrNotFound when DID address not found
func (*SelfSovereignService) GetAuthorizedAppVCByAddress ¶
func (ssi *SelfSovereignService) GetAuthorizedAppVCByAddress(address string, issuerDID string) (*did.VerifiableCredential, error)
func (*SelfSovereignService) GetDIDDocument ¶
func (ssi *SelfSovereignService) GetDIDDocument(mailioAddress string) (*did.Document, error)
*
- Get the DID document for the given mailio address from local database
- @param mailioAddress
- @return DID document
func (*SelfSovereignService) GetVCByID ¶
func (ssi *SelfSovereignService) GetVCByID(ID string) (*did.VerifiableCredential, error)
Returns the DID document for the given mailio address
func (*SelfSovereignService) ListSubjectVCs ¶
func (ssi *SelfSovereignService) ListSubjectVCs(address string, limit int, bookmark string) ([]*did.VerifiableCredential, error)
List all VCs from a specific subject (where subject is a mailio DID)
func (*SelfSovereignService) SaveVC ¶
func (ssi *SelfSovereignService) SaveVC(vc *did.VerifiableCredential) (*did.VerifiableCredential, error)
Stores the Verifiable Credential in the database
func (*SelfSovereignService) StoreRegistrationSSI ¶
func (ssi *SelfSovereignService) StoreRegistrationSSI(mk *did.MailioKey) error
Stores the users DID document and signs a VC with servers private key that proves ownership of the email address
type SmartKeyService ¶
type SmartKeyService struct {
// contains filtered or unexported fields
}
func NewSmartKeyService ¶
func NewSmartKeyService(dbSelector repository.DBSelector) *SmartKeyService
func (*SmartKeyService) DeleteDeviceKeyTransfer ¶
func (rks *SmartKeyService) DeleteDeviceKeyTransfer(id string) error
delete the key on demand
func (*SmartKeyService) DeleteSmartKey ¶
func (rks *SmartKeyService) DeleteSmartKey(address string) error
func (*SmartKeyService) GetDeviceKeyTransfer ¶
func (rks *SmartKeyService) GetDeviceKeyTransfer(id string) (*types.DeviceKeyTransfer, error)
*
- GetDeviceKeyTransfer gets a device key transfer from the database
func (*SmartKeyService) GetSmartKey ¶
func (rks *SmartKeyService) GetSmartKey(address string) (*types.SmartKey, error)
GetRotationKey gets a rotation key from the database
func (*SmartKeyService) SaveDeviceKeyTransfer ¶
func (rks *SmartKeyService) SaveDeviceKeyTransfer(transfer *types.DeviceKeyTransfer) error
*
- Device Key Transfer is used for transfering a shared password between devices
func (*SmartKeyService) SaveSmartKey ¶
func (rks *SmartKeyService) SaveSmartKey(rotationKey *types.SmartKey) error
SaveRotationKey saves a new rotation key to the database
type StatisticsService ¶
type StatisticsService struct {
// contains filtered or unexported fields
}
stores user information (such as: user enabled, subscription details, etc) it's for the backend usage, and doesn't expose any API
func NewStatisticsService ¶
func NewStatisticsService(dbSelector *repository.CouchDBSelector, env *types.Environment) *StatisticsService
func (*StatisticsService) FlushEmailInterests ¶
func (s *StatisticsService) FlushEmailInterests()
*
- FlushEmailInterests flushes the email interests to the database
- it's a background job that runs every 5 minutes
func (*StatisticsService) FlushEmailStatistics ¶
func (s *StatisticsService) FlushEmailStatistics()
*
- PeriodicallyStoreEmailStatistics stores the email statistics in the database
- it's a background job that runs every 5 minutes
func (*StatisticsService) FlushSentEmailStatistics ¶
func (s *StatisticsService) FlushSentEmailStatistics()
*
- FlushSentEmailStatistics flushes the sent email statistics to the database
- it's a background job that runs every 12 hours
func (*StatisticsService) GetEmailInterest ¶
func (s *StatisticsService) GetEmailInterest(ctx context.Context, sender string, recipient string) (int64, error)
*
- GetEmailInterest returns the number of unique emails recipient showed some interested in
- Interest can be that user read an email, stored into archived folder, clicked a link, etc (client defines what the interest might be)
- @param sender string
- @param recipient string
func (*StatisticsService) GetEmailSentByDay ¶
func (s *StatisticsService) GetEmailSentByDay(ctx context.Context, sender string, day int64) (int64, error)
*
- GetEmailSentByDay returns the number of emails sent by a sender on a given day
- @param sender string
- @param day int64
func (*StatisticsService) GetEmailStatistics ¶
func (s *StatisticsService) GetEmailStatistics(ctx context.Context, sender string, recipient string) (int64, error)
*
- GetEmailStatistics returns the number of emails sent by a sender to a recipient
- It works in both ways (local user to outside user and vice versa)
- @param sender string
- @param recipient string
func (*StatisticsService) ProcessEmailInterest ¶
func (s *StatisticsService) ProcessEmailInterest(sender string, recipient string, messageId string) error
*
- ProcessEmailInterest counts the number of unique emails recipient showed some interested in
- Interest can be that user read an email, stored into archived folder, etc (client defines what the interest might be)
- @param sender string
- @param recipient string
func (*StatisticsService) ProcessEmailStatistics ¶
func (s *StatisticsService) ProcessEmailStatistics(sender string, recipient string) error
*
- processEmail count for each sender:recipient number of received/sent emails (dependent on sender, recipient pair)
- uses redis as short term cache (about 15 minutes)
- @param sender string - the one who is sending an email
- @param recipient string - the one who is receiving an email
func (*StatisticsService) ProcessEmailsSentStatistics ¶
func (s *StatisticsService) ProcessEmailsSentStatistics(sender string) error
*
- ProcessEmailsSentStatistics processes the email sent statistics by day
- @param sender string
type UserProfileService ¶
type UserProfileService struct {
// contains filtered or unexported fields
}
stores user information (such as: user enabled, subscription details, etc) it's for the backend usage, and doesn't expose any API
func NewUserProfileService ¶
func NewUserProfileService(dbSelector *repository.CouchDBSelector, env *types.Environment) *UserProfileService
func (*UserProfileService) Delete ¶
func (s *UserProfileService) Delete(address string) error
func (*UserProfileService) DeleteFromCache ¶
func (s *UserProfileService) DeleteFromCache(address string) error
func (*UserProfileService) Get ¶
func (s *UserProfileService) Get(address string) (*types.UserProfile, error)
address is used as the user's _id
func (*UserProfileService) GetFromCache ¶
func (s *UserProfileService) GetFromCache(address string) *types.UserProfile
func (*UserProfileService) Save ¶
func (s *UserProfileService) Save(address string, profile *types.UserProfile) (*types.UserProfile, error)
address is used as the user's _id
func (*UserProfileService) SaveToCache ¶
func (s *UserProfileService) SaveToCache(address string, profile *types.UserProfile) error
func (*UserProfileService) Stats ¶
func (s *UserProfileService) Stats(address string) (*types.UserProfileStats, error)
get users database stats (used when checking if user has disk space available)
type UserService ¶
type UserService struct {
// contains filtered or unexported fields
}
func NewUserService ¶
func NewUserService(repoSelector *repository.CouchDBSelector, env *types.Environment) *UserService
func (*UserService) CreateDatabase ¶
func (us *UserService) CreateDatabase(user *types.User, databasePassword string) error
CreateDatabase creates a new database for the user with the given email and password. It returns an error (if any).
func (*UserService) CreateUser ¶
func (us *UserService) CreateUser(user *types.User, mk *did.MailioKey, databasePassword string) (*types.User, error)
CreateUser creates a new user with the given email and password. It returns a pointer to an InputEmailPassword struct and an error (if any).
func (*UserService) DeleteExpiredTransferKeys ¶
func (us *UserService) DeleteExpiredTransferKeys()
*
- Deletes expired transfer keys every 5 minutes or so
func (*UserService) FindUserByScryptEmail ¶
func (us *UserService) FindUserByScryptEmail(scryptEmail string) (*types.EmailToMailioMapping, error)
finding user by email address (email address must be encrypted with scrypt)
func (*UserService) MapEmailToMailioAddress ¶
func (us *UserService) MapEmailToMailioAddress(user *types.User) (*types.EmailToMailioMapping, error)
Maps encrypted email to mailio address so outside users can request per user email if they know it
func (*UserService) SaveMessage ¶
func (us *UserService) SaveMessage(userAddress string, mailioMessage *types.MailioMessage) (*types.MailioMessage, error)
Stores mailio message to users database
type WebAuthnService ¶
type WebAuthnService struct {
// contains filtered or unexported fields
}
func NewWebAuthnService ¶
func NewWebAuthnService(repoSelector *repository.CouchDBSelector, env *types.Environment) *WebAuthnService
func (*WebAuthnService) GetUser ¶
func (s *WebAuthnService) GetUser(address string) (*types.WebAuhnUser, error)
GetUser gets a user from the database
func (*WebAuthnService) GetUserByEmail ¶
func (s *WebAuthnService) GetUserByEmail(email string) (*types.WebAuthnUserDB, error)
*
- GetUserByEmail gets a user from the database by email (querying the field: name)
func (*WebAuthnService) SaveUser ¶
func (s *WebAuthnService) SaveUser(user *types.WebAuhnUser) error
SaveUser saves a new user to the database or overrides existing user