types

package
v0.0.0-...-0aeaaa6 Latest Latest
Warning

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

Go to latest
Published: Oct 15, 2025 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// Possible handshake types
	HANDSHAKE_TYPE_PERSONAL      = "personal"
	HANDSHAKE_TYPE_SIGNUP        = "signup"
	HANDSHAKE_TYPE_SERVER        = "server"
	HANDSHAKE_TYPE_USER_SPECIFIC = "user"

	// Possible handshake statuses
	HANDSHAKE_STATUS_ACCEPTED = "accepted"
	HANDSHAKE_STATUS_REVOKED  = "revoked"
	HANDSHAKE_STATUS_NOTFOUND = "notfound"
	HANDSHAKE_STATUS_REQUEST  = "request"

	// Possbile handshake signup sub types
	HANDSHAKE_SIGNUP_SUBTYPE_TRANSACTIONAL = "transactional"
	HANDSHAKE_SIGNUP_SUBTYPE_PRODUCT       = "product"
	HANDSHAKE_SIGNUP_SUBTYPE_SECURITY      = "security"
	HANDSHAKE_SIGNUP_SUBTYPE_PROMOTION     = "promotion"
	HANDSHAKE_SIGNUP_SUBTYPE_NEWSLETTER    = "newsletter"
	HANDSHAKE_SIGNUP_SUBTYPE_REQUEST       = "request"
	HANDSHAKE_SIGNUP_SUBTYPE_OTHER         = "other"

	// Possible handshake levels
	HANDSHAKE_LEVEL_NONE         = "none"
	HANDSHAKE_LEVEL_RECAPTCHAV3  = "recaptchaV3"
	HANDSHAKE_LEVEL_POH          = "poh"      // proof of humanity
	HANDSHAKE_LEVEL_FACE_TO_FACE = "personal" // face to face created handshake

	// Possible signatures schemes
	HANDSHAKE_SIGNATURE_SCHEME_EdDSA_X25519 = "EdDSA_X25519"
)
View Source
const (
	EmailLookupHashScheme_SC_N32768_R8_P1_L32_B64 = "SC_N32768_R8_P1_L32_B64"
	Signature_Scheme_EdDSA_X25519                 = "EdDSA_X25519"
)

*** * Mailio Transfer Protocol for Handshakes ***

Variables

View Source
var (
	// ErrInvalidEmail is returned when the email is invalid
	ErrInvalidEmail = errors.New("invalid email address")
	// ErrInternal (for unahandled exceptions)
	ErrInternal = errors.New("internal errior")
	// ErrConflict is returned when the resource conflicts (e.g. update of old revision)
	ErrConflict = errors.New("conflict")
	// ErrNotFound is returned when a resource is not found.
	ErrNotFound = errors.New("not found")
	// ErrTimeout is returned when a timeout occurs.
	ErrTimeout = errors.New("timeout")
	// ErrInvalidFormat is returned when a resource is not in the expected format.
	ErrInvalidFormat = errors.New("invalid format")
	// operation not authorized
	ErrUnauthorized = errors.New("unauthorized")
	// ErrNotAuthorized - authorization failed
	ErrNotAuthorized = errors.New("not authorized")
	// ErrUserExists - user already exists
	ErrUserExists = errors.New("user exists")
	// ErrUnimoplemented - unimplemented
	ErrUnimplemented = errors.New("unimplemented")
	// ErrBadRequest - bad request (or invalid input data)
	ErrBadRequest = errors.New("bad request")
	// ErrQuotaExceeded - quota exceeded
	ErrQuotaExceeded = errors.New("quota exceeded")
	// expired trial
	ErrTrialExpired = errors.New("trial has expired")
	// ErrRateLimitExceeded - rate limit exceeded
	ErrRateLimitExceeded = errors.New("rate limit exceeded")
	// ErrInvalidPublicKey - invalid public key
	ErrInvalidPublicKey = errors.New("invalid public key")
	// ErrInvalidSignature - invalid signature
	ErrSignatureInvalid = errors.New("signature invalid")
	// ErrInvalidPrivateKey - invalid private key
	ErrInvalidPrivateKey = errors.New("invalid private key")
	// ErrContinue defines something went wrong but code exection should continue
	ErrContinue = errors.New("continue")
	// ErrDomainNotFound - domain not found
	ErrDomainNotFound = errors.New("domain not found")

	// HANDSHAKE ERRORS
	// If handshake has been revoked
	ErrHandshakeRevoked = errors.New("handshake revoked")

	// Mailio Errors
	// ErrInvalidMailioAddress - invalid mailio address`
	ErrInvalidMailioAddress = errors.New("invalid mailio address")

	// ErrMxRecordCheckFailed - ony any error checking MX records
	ErrMxRecordCheckFailed = errors.New("mx record check failed")

	// ErrTooManyRequests - too many requests
	ErrTooManyRequests = errors.New("too many requests")

	// ErrNoRecipient - no recipient
	ErrNoRecipient = errors.New("no recipient")

	// ErrInvaidRecipient - invalid recipient
	ErrInvaidRecipient = errors.New("invalid recipient")

	// ErrInvalidSender - invalid sender
	ErrInvalidSender = errors.New("invalid sender")

	// ErrMessageTooLarge - message too large
	ErrMessageTooLarge = errors.New("message too large")

	// ErrTooManyAttachments - too many attachments
	ErrTooManyAttachments = errors.New("too many attachments")

	// ErrTooManyRecipients - too many recipients
	ErrTooManyRecipients = errors.New("too many recipients")

	// ErrBadRequestMissingSubjectOrBody - missing subject or body
	ErrBadRequestMissingSubjectOrBody = errors.New("missing subject or body")

	// ErrRecordExists - record exists
	ErrRecordExists = errors.New("record exists")
)
View Source
var (
	DIDCommIntentMessage           = "message"           // ordinary message
	DIDCommIntentHandshake         = "handshake"         // handshake message
	DIDCommIntentHandshakeRequest  = "handshake_request" // handshake request message
	DIDCommIntentHandshakeResponse = "handsake_response" // handshake response message
	DIDCommIntentDelivery          = "delivery"          // delivery message (acknowledgement, failure, etc.)
	SMPTIntentMessage              = "smtpmessage"       // ordinary smtp message

	MailioFolderInbox     = "inbox"
	MailioFolderGoodReads = "goodreads"
	MailioFolderOther     = "other"
	MailioFolderSent      = "sent"
	MailioFolderDraft     = "draft"
	MailioFolderArchive   = "archive"
	MailioFolderTrash     = "trash"
	MailioFolderSpam      = "spam"
	MailioFolderHandshake = "handshake"
)
View Source
var (

	// System status codes
	ClassCodeSuccess     = 2 // The message has been delivered successfully
	ClassCodeTempFailure = 4 // The message has been temporarily failed
	ClassCodePermFailure = 5 // The message has been permanently failed

	// Subject codes
	SubjectCodeAccepted   = 0 // Accepted code indicates message has been accepted for delivery
	SubjectCodeAdressing  = 1 // Addressing status code The address status reports on the originator or destination address.  It may include address syntax or validity.  These errors can generally be corrected by the sender and retried.
	SubjectCodeMailbox    = 2 // Mailbox status code Mailbox status indicates that something having to do with the mailbox has caused this DSN.  Mailbox issues are assumed to be under the general control of the recipient.
	SubjectCodeMailSystem = 3 // Mail system status code Mail system status indicates that something having to do with the system has caused this DSN. System issues are assumed to be under the general control of the administrator.
	SubjectCodeNetwork    = 4 // Network and routing status code The networking or routing codes report status about the delivery system itself. These system components include any necessary infrastructure such as directory and routing services.
	SubjectCodeDelivery   = 5 // Mail delivery protocol status code The mail delivery protocol status codes report failures involving the message delivery protocol.  These failures include the full range of problems resulting from implementation errors or an unreliable connection.
	SubjectMessageContent = 6 // Message content or media status code The message content or media status codes report failures involving the content of the message.  These codes report failures due to translation, transcoding, or otherwise unsupported message media.
	SubjectSecurity       = 7 // Security or policy status code The security or policy status codes report failures involving policies such as per-recipient or per-host filtering and cryptographic operations.  Security and policy status issues are assumed to be under the control of either or both the sender and recipient.
	SubjectHandshake      = 8 // Message handshake status code. The message handshake status codes report failures involving the handshake of the message. This code can also report the placement of the message in the recipients mailbox folder.

)

Errors that start with a 4 are temporary failures. No action is needed, the sender will try again. Errors that start with 5 are permanent failures and action is required to fix the problem. The error codes are adapted and re-modeled based on RFC3463 https://www.rfc-editor.org/rfc/rfc3463

View Source
var (
	QueueTypeDIDCommSend     = "message:send"
	QueueTypeDIDCommRecv     = "message:receive"
	QueueTypeSMTPCommSend    = "smtp:send"
	QueueTypeSMTPCommReceive = "smtp:receive"
)
View Source
var DENIED_EXTENSIONS = map[string]string{"ade": "ade", "adp": "adp", "apk": "apk", "appx": "appx", "appxbundle": "appxbundle", "bat": "bat", "cab": "cab", "chm": "chm", "cmd": "cmd", "com": "com", "cpl": "cpl", "dll": "dll", "dmg": "dmg", "ex": "ex", "ex_": "ex_", "exe": "exe", "hta": "hta", "ins": "ins", "isp": "isp", "iso": "iso", "jar": "jar", "js": "js", "jse": "jse", "lib": "lib", "lnk": "lnk", "mde": "mde", "msc": "msc", "msi": "msi", "msix": "msix", "msixbundle": "msixbundle", "msp": "msp", "mst": "mst", "nsh": "nsh", "pif": "pif", "ps1": "ps1", "scr": "scr", "sct": "sct", "shb": "shb", "sys": "sys", "vb": "vb", "vbe": "vbe", "vbs": "vbs", "vxd": "vxd", "wsc": "wsc", "wsf": "wsf", "wsh": "wsh"}

Functions

func NewDIDCommReceiveTask

func NewDIDCommReceiveTask(message *Task) (*asynq.Task, error)

func NewDIDCommSendTask

func NewDIDCommSendTask(message *Task) (*asynq.Task, error)

func NewSmtpCommReceiveTask

func NewSmtpCommReceiveTask(message *SmtpTask) (*asynq.Task, error)

func NewSmtpCommSendTask

func NewSmtpCommSendTask(message *SmtpTask) (*asynq.Task, error)

Types

type ArrayOfStrings

type ArrayOfStrings struct {
	Values []string `json:"values" validate:"required,min=1"`
}

type BaseDocument

type BaseDocument struct {

	// Rev is the revision number returned
	// _Rev    string `json:"_rev,omitempty"`
	Rev string `json:"_rev,omitempty"`
	ID  string `json:"_id,omitempty"`
	// _ID     string `json:"_id,omitempty"`
	OK      bool `json:"ok,omitempty"`
	Deleted bool `json:"_deleted,omitempty"`
}

Document represents a single document returned by Get

type CommonSignature

type CommonSignature struct {
	SignatureBase64   string `json:"signatureBase64" validate:"required,base64"`
	CborPayloadBase64 string `json:"cborPayloadBase64" validate:"required,base64"`
	SenderDomain      string `json:"senderDomain" validate:"required"` // origin of the request (where DNS is published with Mailio public key)
}

type Contact

type Contact struct {
	BaseDocument `json:",inline"`
	HandshakeID  string      `json:"handshakeId,omitempty"`            // handshake ID reference
	OwnerAddress string      `json:"ownerAddress" validate:"required"` // Mailio address of the owner of this data
	ContactInfo  ContactInfo `json:"contactInfo"`
}

type ContactInfo

type ContactInfo struct {
	FirstName       string           `json:"firstName,omitempty"`
	LastName        string           `json:"lastName,omitempty"`
	Email           string           `json:"email" validate:"email"`
	Phone           string           `json:"phone,omitempty"`
	PictureBase64   string           `json:"picture,omitempty"`
	JobTitle        string           `json:"jobTitle,omitempty"`
	Company         string           `json:"company,omitempty"`
	PhysicalAddress *PhysicalAddress `json:"address,omitempty"`
	WebsiteURL      string           `json:"websiteUrl,omitempty"`
	Notes           string           `json:"notes,omitempty"`
}

ContactInfo is a struct that represents a contact

type CouchDBCountDistinctFromResponse

type CouchDBCountDistinctFromResponse struct {
	Rows []*CouchDBCountDistinctFromRow `json:"rows"`
}

type CouchDBCountDistinctFromRow

type CouchDBCountDistinctFromRow struct {
	Key   []string `json:"key"`
	Value int      `json:"value"`
}

type CouchDBCountResponse

type CouchDBCountResponse struct {
	Rows []*CouchDBCountRow `json:"rows"`
}

type CouchDBCountRow

type CouchDBCountRow struct {
	Key   string `json:"key"`
	Value int    `json:"value"`
}

type CouchDBError

type CouchDBError struct {
	Error  string `json:"error"`
	Reason string `json:"reason"`
}

type CouchDBResponse

type CouchDBResponse struct {
	ID  string `json:"id,omitempty"`
	Rev string `json:"rev,omitempty"`
	OK  bool   `json:"ok,omitempty"`
}

type DIDCommApiResponse

type DIDCommApiResponse struct {
	SmtpID         string           `json:"smtpId"`
	DIDCommID      string           `json:"didCommId"`
	Type           string           `json:"type,omitempty"`
	MTPStatusCodes []*MTPStatusCode `json:"mtpStatusCodes,omitempty"`
}

type DIDCommMessage

type DIDCommMessage struct {
	Type string `` // a valid message type URI (MUST be: application/didcomm-encrypted+json or application/didcomm-signed+json or application/mailio-smtp+json)
	/* 252-byte string literal not displayed */
	ID              string              `json:"id,omitempty"`                                                                             // globally unique message identifier UUID (RFC 4122) recommended
	From            string              `json:"from" validate:"required"`                                                                 // sender DID required because all mailio messages are encrypted
	To              []string            `json:"to,omitempty"`                                                                             // in format: did:web:mail.io:0xabc -> recipient DIDs
	ToEmails        []*ToEmail          `json:"toEmails,omitempty"`                                                                       // recipient email addresses (email and hash as alternative to To field with DID addresses)
	Thid            string              `json:"thid,omitempty"`                                                                           // thread identifier. Uniquely identifies the thread that the message belongs to. If not included, the id property of the message MUST be treated as the value of the thid.
	Pthid           string              `json:"pthid,omitempty"`                                                                          // parent thread identifier. Uniquely identifies the parent thread that the message belongs to. If not included, the message is the first message in the thread.
	ExpiresTime     int64               `json:"expiresTime,omitempty"`                                                                    // sender will abort the protocol if it doesn't get a response by this time (UTC milliseconds since epoch)
	CreatedTime     int64               `json:"createdTime,omitempty"`                                                                    // time of message creation in UTC milliseconds since epoch
	Next            string              `json:"next,omitempty"`                                                                           // in case forward message
	FromPrior       string              `json:"fromPrior,omitempty"`                                                                      // A DID is rotated by sending a message of any type to the recipient to be notified of the rotation
	Intent          string              `json:"intent,omitempty" validate:"omitempty,oneof=message handshake delivery handshake_request"` // the intent of the message (if empty, ordinary message
	EncryptedBody   *EncryptedBody      `json:"body,omitempty"`                                                                           // the body attribute contains all the data and structure defined uniquely for the schema associated with the type attribute. It MUST be a JSON object conforming to RFC 7159                              // the encrypted message body
	Attachments     []*MailioAttachment `json:"attachments,omitempty"`                                                                    // attachments to the message                                                // MTP status message
	PlainBodyBase64 string              `json:"plainBodyBase64,omitempty" validate:"omitempty,base64"`                                    // the plain text message body, base64 encoded (optional)
}

type DIDCommMessageInput

type DIDCommMessageInput struct {
	DIDCommMessage    DIDCommMessage `json:"didCommMessage" validate:"required"`
	DeleteAttachments []string       `json:"deleteAttachments,omitempty"` // The IDs of attachments to be deleted (the decision is left to client to make: if only encrypted then plaint attachment should be deleted, if both types of recipients then no attachments shhould be deleted, ... ).
}

type DIDCommRequest

type DIDCommRequest struct {
	SignatureScheme string          `json:"signatureScheme" validate:"required,oneof=EdDSA_X25519"`
	Timestamp       int64           `json:"timestamp" validate:"required"`
	DIDCommMessage  *DIDCommMessage `json:"didCommMessage" validate:"required"`
}

type DIDCommSignedRequest

type DIDCommSignedRequest struct {
	DIDCommRequest    *DIDCommRequest `json:"didCommRequest" validate:"required"`
	CborPayloadBase64 string          `json:"cborPayloadBase64" validate:"required,base64"` // the payload that was signed, which is base64 encoded.
	SignatureBase64   string          `json:"signatureBase64" validate:"required,base64"`   // the signature of the payload, which is base64 encoded.
	SenderDomain      string          `json:"senderDomain" validate:"required"`             // origin of the request (where DNS is published with Mailio public key)
}

DIDCommSignedMessage is a struct that represents a signed message according to JWS standard with CBOR payload

type DIDDocumentSignedRequest

type DIDDocumentSignedRequest struct {
	DIDLookupRequest  DIDLookupRequest `json:"didLookupRequest" validate:"required"`
	SignatureBase64   string           `json:"signatureBase64" validate:"required,base64"`
	CborPayloadBase64 string           `json:"cborPayloadBase64" validate:"required,base64"`
	SenderDomain      string           `json:"senderDomain" validate:"required"` // origin of the request (where DNS is published with Mailio public key)
}

type DIDDocumentSignedResponse

type DIDDocumentSignedResponse struct {
	DIDLookupResponse DIDLookupResponse `json:"didLookupResponse" validate:"required"`
	SignatureBase64   string            `json:"signatureBase64" validate:"required,base64"`
	CborPayloadBase64 string            `json:"cborPayloadBase64" validate:"required,base64"`
}

type DIDLookup

type DIDLookup struct {
	EmailHash             string         `json:"emailHash" validate:"required"`   // scrypt hash of the email address
	Email                 string         `json:"email" validate:"required"`       // email address
	SupportsMailio        bool           `json:"supportsMailio,omitempty"`        // if the recipient supports Mailio (derived from domain resolving)
	SupportsStandardEmail bool           `json:"supportsStandardEmail,omitempty"` // if the recipient supports standard email (derrived from domain resolving)
	DIDDocument           *did.Document  `json:"didDocument,omitempty"`
	MTPStatusCode         *MTPStatusCode `json:"mtpStatusCode,omitempty"`
}

DIDLookup from scrypted email address

type DIDLookupRequest

type DIDLookupRequest struct {
	SenderAddress string       `json:"senderAddress" validate:"required"` // intended senders Mailio address
	LookupHeader  LookupHeader `json:"lookupHeader" validate:"required"`
	DIDLookups    []*DIDLookup `json:"didLookups" validate:"required"`
}

type DIDLookupResponse

type DIDLookupResponse struct {
	LookupHeader    LookupHeader `json:"lookupHeader" validate:"required"`
	FoundLookups    []*DIDLookup `json:"foundLookups,omitempty"`
	NotFoundLookups []*DIDLookup `json:"notFoundLookups,omitempty"`
}

type DesignDocument

type DesignDocument struct {
	BaseDocument
	Language string                 `json:"language"`
	Views    map[string]MapFunction `json:"views"`
}

type DeviceKeyTransfer

type DeviceKeyTransfer struct {
	BaseDocument            `json:",inline"`
	Address                 string `json:"address"`
	Email                   string `json:"email"`
	EncryptedSharedPassword string `json:"encryptedSharedPassword"`
	SmartKeyEncrypted       string `json:"smartKeyEncrypted,omitempty"`
	PasswordShare           string `json:"passwordShare,omitempty"`
	Created                 int64  `json:"created,omitempty"`
}

type DeviceKeyTransferInput

type DeviceKeyTransferInput struct {
	EncryptedSharedPassword string `json:"encryptedSharedPassword" validate:"required"`
	Email                   string `json:"email" validate:"required"`
}

type DeviceKeyTransferOutput

type DeviceKeyTransferOutput struct {
	Nonce string `json:"nonce" validate:"required"`
}

type DidDocument

type DidDocument struct {
	BaseDocument `json:",inline"`
	DID          *did.Document `json:"did"`
}

type Discovery

type Discovery struct {
	// The domain name to query.
	Domain string `json:"domain"`
	// Ipsv4 addresses of the requested domain
	Ips []string `json:"ips"`
	// Flag telling if server  at domain supports mailio protocol
	IsMailio bool `json:"isMailio"`
	// MailioDIDDomain is the domain that supports mailio protocol
	MailioDIDDomain string `json:"mailioDIDDomain"`
	// Mailio base64 public key (if Mailio flag is true)
	PublicKey string `json:"publicKey,omitempty"`
	// The type of the public key (ed25519 support only at the moment)
	PublicKeyType string `json:"publicKeyType,omitempty"`
}

DnsDiscovery is a Discovery that scans for DNS records.

type Domain

type Domain struct {
	BaseDocument           `json:",inline"`
	Name                   string `json:"name"`
	SupportsMailio         bool   `json:"supportsMailio"`            // domain can be both (mailio and smtp)
	MailioDIDDomain        string `json:"mailioDIDDomain,omitempty"` // mailio domain (if supportsMailio)
	SupportsStandardEmails bool   `json:"supportsStandardEmail"`     // domain can be both (mailio and smtp)
	MailioPublicKey        string `json:"mailioPublicKey,omitempty"`
	Timestamp              int64  `json:"timestamp"`
	MxCheckError           string `json:"mxCheckError,omitempty"`
	MailioCheckError       string `json:"mailioCheckError,omitempty"`
}

caching types of domains (smtp or/and mailio supported)

type EmailStatistics

type EmailStatistics struct {
	BaseDocument `json:",inline"`
	Recipient    string `json:"recipient"`
	Sender       string `json:"sender"`
	Count        int64  `json:"count"`
	Hyperloglog  string `json:"hyperloglog,omitempty"`
}

type EmailStatisticsOutput

type EmailStatisticsOutput struct {
	Received  int64 `json:"received"`
	Sent      int64 `json:"sent"`
	Interest  int64 `json:"interest"`
	SentByDay int64 `json:"sentByDay"`
}

type EmailToMailioMapping

type EmailToMailioMapping struct {
	BaseDocument
	EncryptedEmail string `json:"encryptedEmail"`
	MailioAddress  string `json:"address"`
}

type EncryptedAttachmentData

type EncryptedAttachmentData struct {
	Hash   string   `json:"hash,omitempty"`                  // the hash of the attachment
	Base64 string   `json:"base64,omitempty"`                // the base64 encoded attachment
	Links  []string `json:"links" validate:"required,min=1"` // the links to the attachment
}

EncryptedAttachmentData JWE encrypted attachment data

type EncryptedBody

type EncryptedBody struct {
	Aad        string      `json:"aad" validate:"required"`              // additional authenticated data
	Ciphertext string      `json:"ciphertext" validate:"required"`       // the encrypted message
	IV         string      `json:"iv" validate:"required"`               // the initialization vector (nonce)
	Recipients []Recipient `json:"recipients" validate:"required,min=1"` // the recipients of the message (at least one)
	Tag        string      `json:"tag" validate:"required"`              // integrity check on the encrypted message
	Protected  string      `json:"protected" validate:"required"`        // the protected header
}

EncryptedMailioBody is a struct that represents an encrypted message according to JWE standard

type Environment

type Environment struct {
	RedisClient     *redis.Client
	TaskClient      *asynq.Client
	Cron            *cron.Cron
	S3Uploader      *manager.Uploader
	S3Downloader    *manager.Downloader
	S3PresignClient *s3.PresignClient
	S3Client        *s3.Client
	WebAuthN        *webauthn.WebAuthn
}

func NewEnvironment

func NewEnvironment(redisClient *redis.Client) *Environment

func (*Environment) AddS3Downloader

func (env *Environment) AddS3Downloader(downloader *manager.Downloader)

func (*Environment) AddS3Uploader

func (env *Environment) AddS3Uploader(uploader *manager.Uploader)

func (*Environment) Close

func (env *Environment) Close()

type Epk

type Epk struct {
	X   string `json:"x,omitempty"`   // The X coordinate for the elliptic curve point
	Crv string `json:"crv,omitempty"` // The curve parameter used for the key
	Kty string `json:"kty,omitempty"` // Key Type, indicating the type of key used, such as an elliptic curve key ("OKP" for Octet Key Pair).
}

Ephemeral Public Key

type Handshake

type Handshake struct {
	Content           HandshakeContent `json:"content"`
	SignatureBase64   string           `json:"signatureBase64"`
	CborPayloadBase64 string           `json:"cborPayloadBase64"` // payload in cbor format of handshake Content
}

* Basic handshake structure which can be passed onto clients

type HandshakeContent

type HandshakeContent struct {
	HandshakeID          string                `json:"handshakeId,omitempty"`     // handshake ID
	OriginServer         OriginServer          `json:"originServer,omitempty"`    // origin server
	SignupSubType        *int                  `json:"signupSubType,omitempty"`   // handshake signup sub type
	SignupRules          *HandshakeSignupRules `json:"signupRules,omitempty"`     // handshake signup rules
	Status               string                `json:"status"`                    // handshake status
	Level                string                `json:"level"`                     // handshake level
	OwnerPublicKeyBase64 string                `json:"ownerPublicKey"`            // owner public key of the owner of the handshake
	OwnerAddressHex      string                `json:"ownerAddress"`              // mailio address of the owner of the handshake
	SenderMetadata       *SenderMetadata       `json:"senderMetadata,omitempty"`  // sender meta data (either Mailio address or sha512 email address )
	SignatureBase64      string                `json:"signatureBase64,omitempty"` // owners signature of the handshake
	Type                 string                `json:"type,omitempty"`            // handshake type
	SignatureScheme      string                `json:"signatureScheme"`           // handshake signature scheme
	Created              float64               `json:"created"`                   // timestamp of the handshake
}

Handshake is a struct that represents a handshake between two Mailio users or a Mailio user and a Mailio server

type HandshakeLink struct {
	Link string `json:"link"`
}

type HandshakeLookup

type HandshakeLookup struct {
	ID          string       `json:"id,omitempty"`
	Address     string       `json:"address,omitempty"`
	EmailHash   string       `json:"emailHash,omitempty"`       // scrypt hash of the email address
	Email       string       `json:"email" validate:"required"` // email address
	OriginSever OriginServer `json:"originServer" validate:"required"`
}

type HandshakeLookupResponse

type HandshakeLookupResponse struct {
	Found    []*HandshakeContent `json:"found,omitempty"`
	NotFound []*HandshakeLookup  `json:"notFound,omitempty"`
}

type HandshakeRequest

type HandshakeRequest struct {
	HandshakeHeader              LookupHeader      `json:"lookupHeader" validate:"required"`
	HandshakeLookups             []HandshakeLookup `json:"handshakeLookups" validate:"required"`
	ReturnDefaultServerHandshake bool              `json:"returnDefaultServerHandshake"`      // default false
	SenderAddress                string            `json:"senderAddress" validate:"required"` // intended senders Mailio address
}

type HandshakeResponse

type HandshakeResponse struct {
	HandshakeHeader LookupHeader        `json:"lookupHeader" validate:"required"`
	Handshakes      []*HandshakeContent `json:"handshakes" validate:"required"`
}

type HandshakeSignedRequest

type HandshakeSignedRequest struct {
	HandshakeRequest  HandshakeRequest `json:"handshakeRequest" validate:"required"`
	SignatureBase64   string           `json:"signatureBase64" validate:"required,base64"`
	CborPayloadBase64 string           `json:"cborPayloadBase64" validate:"required,base64"`
	SenderDomain      string           `json:"senderDomain" validate:"required"` // origin of the request (where DNS is published with Mailio public key)
}

type HandshakeSignedResponse

type HandshakeSignedResponse struct {
	HandshakeResponse HandshakeResponse `json:"handshakeResponse" validate:"required"`
	SignatureBase64   string            `json:"signatureBase64" validate:"required,base64"`
	CborPayloadBase64 string            `json:"cborPayloadBase64" validate:"required,base64"`
}

type HandshakeSignupRules

type HandshakeSignupRules struct {
	FrequencyMinutes int `json:"frequencyMinutes,omitempty"` // optional
}
type Header struct {
	Kid string `json:"kid" validate:"required"` //  (Key ID): A hint indicating which key was used to encrypt the
	Epk *Epk   `json:"epk,omitempty"`           // (Ephemeral Public Key): A temporary public key that was used in conjunction with the recipient's public key to encrypt the encrypted_key
}

type Index

type Index struct {
	DesignDoc  string      `json:"ddoc,omitempty"`
	Name       string      `json:"name"`
	Type       string      `json:"type"`
	Definition interface{} `json:"def"`
}

Index is a MonboDB-style index definition.

type InputDID

type InputDID struct {
	DID string `json:"did" validate:"required"`
}

for DID resolution

type InputDIDLookup

type InputDIDLookup struct {
	Lookups []*DIDLookup `json:"lookups" validate:"min=1"`
}

type InputHandshakeLookup

type InputHandshakeLookup struct {
	Lookups []HandshakeLookup `json:"lookups" validate:"min=1"`
}

type InputLogin

type InputLogin struct {
	Email                         string `json:"email" validate:"required,email"`
	MailioAddress                 string `json:"mailioAddress" validate:"required"`
	Nonce                         string `json:"nonce" validate:"required"`
	Ed25519SigningPublicKeyBase64 string `json:"ed25519SigningPublicKeyBase64" validate:"required"` // public key of the private key used to sign the nonce
	SignatureBase64               string `json:"signatureBase64" validate:"required"`               // signature of Nonce string
}

for login

type InputRegister

type InputRegister struct {
	InputLogin
	DatabasePassword      string `json:"databasePassword" validate:"required"`      // this is a password for couchdbs private user database
	X25519PublicKeyBase64 string `json:"x25519PublicKeyBase64" validate:"required"` // public encryption key
}

for register

type InputWebDIDLookup

type InputWebDIDLookup struct {
	DIDs []string `json:"dids" validate:"required,min=1"`
}

type InterestInput

type InterestInput struct {
	Sender    string `json:"sender" validate:"required"`
	MessageId string `json:"messageId" validate:"required"`
}

type InterestOuput

type InterestOuput struct {
	MessageId string `json:"messageId,omitempty"`
}

type JwsToken

type JwsToken struct {
	Token string `json:"token"`
}

type JwsTokenWithSmartKey

type JwsTokenWithSmartKey struct {
	JwsToken                string        `json:"jwsToken" validate:"required"`
	EncryptedSmartKeyBase64 string        `json:"encryptedSmartKeyBase64" validate:"required"`
	SmartKeyPasswordPart    string        `json:"smartKeyPasswordPart" validate:"required"`
	Email                   string        `json:"email" validate:"required"`
	DidDocument             *did.Document `json:"didDocument" validate:"required"`
}

type KeyValue

type KeyValue struct {
	Key   string `json:"key"`
	Value string `json:"value"`
}

type LookupHeader

type LookupHeader struct {
	SignatureScheme       string `json:"signatureScheme" validate:"required,oneof=EdDSA_X25519"`
	EmailLookupHashScheme string `json:"emailLookupHashScheme,omitempty"`
	Timestamp             int64  `json:"timestamp" validate:"required"`
}

type MTPStatusCode

type MTPStatusCode struct {
	Class       int    `json:"class" validate:"required,oneof=2 4 5"`   // Represents the class of the status code (2, 4, 5)
	Subject     int    `json:"subject" validate:"required,min=0,max=8"` // Represents the subject category of the status code
	Detail      int    `json:"detail" validate:"required"`              // Represents the detail of the status code
	Description string `json:"description,omitempty"`                   // Human-readable message or description (optional)
	Address     string `json:"address,omitempty"`                       // Address of the recipient or sender
	Timestamp   int64  `json:"timestamp,omitempty"`                     // Unix timestamp in milliseconds
}

Mailio Transfer Protocol (MTP) status codes e.g. for succesfull delivery 2.0.0

func NewMTPStatusCode

func NewMTPStatusCode(clazz int, subject int, detail int, description string, opts ...MTPStatusCodeOption) *MTPStatusCode

type MTPStatusCodeOption

type MTPStatusCodeOption func(*MTPStatusCode)

func WithRecAddress

func WithRecAddress(address string) MTPStatusCodeOption

type MailioAttachment

type MailioAttachment struct {
	ID   string                   `json:"id" validate:"required"`   // a globally unique identifier for the attachment
	Data *EncryptedAttachmentData `json:"data" validate:"required"` // the encrypted message body
}

EncryptedMailioAttachment is a struct that represents an encrypted attachment according to JWE standard

type MailioMessage

type MailioMessage struct {
	BaseDocument   `json:",inline"`
	ID             string          `json:"id" validate:"required"`                                                          // globally unique message identifier UUID (RFC 4122) recommended
	From           string          `json:"from" validate:"required"`                                                        // either the sender's DID or the sender's email address
	DIDCommMessage *DIDCommMessage `json:"didCommMessage,omitempty"`                                                        // the DIDComm message
	Folder         string          `json:"folder" validate:"required"`                                                      // the folder where the message is stored
	Created        int64           `json:"created" validate:"required"`                                                     // time of message creation in UTC milliseconds since epoch
	Modified       int64           `json:"modified,omitempty"`                                                              // time of message modification in UTC milliseconds since epoch
	IsAutomated    bool            `json:"isAutomated,omitempty"`                                                           // true if the message is automated
	IsForwarded    bool            `json:"isForwarded,omitempty"`                                                           // true if the message is forwarded
	IsReplied      bool            `json:"isReplied,omitempty"`                                                             // true if the message is replied
	IsRead         bool            `json:"isRead,omitempty"`                                                                // true if the message is read
	SecurityStatus string          `json:"securityStatus,omitempty" validate:"omitempty,oneof=clean malware spam phishing"` // the security status of the message (optional)
}

MailioMessage is a struct that is meant to be stored in the database

type MailioSocial

type MailioSocial struct {
	Twitter   string `json:"twitter,omitempty"`
	GitHub    string `json:"github,omitempty"`
	LinkedIn  string `json:"linkedin,omitempty"`
	Facebook  string `json:"facebook,omitempty"`
	Instagram string `json:"instagram,omitempty"`
	TikTok    string `json:"tiktok,omitempty"`
	Snapchat  string `json:"snapchat,omitempty"`
	WhatsApp  string `json:"whatsapp,omitempty"`
	Telegram  string `json:"telegram,omitempty"`
	Signal    string `json:"signal,omitempty"`
	Discord   string `json:"discord,omitempty"`
	Slack     string `json:"slack,omitempty"`
	Skype     string `json:"skype,omitempty"`
	Zoom      string `json:"zoom,omitempty"`
	Clubhouse string `json:"clubhouse,omitempty"`
	Other     string `json:"other,omitempty"`
}

type MapFunction

type MapFunction struct {
	Map    string `json:"map"`
	Reduce string `json:"reduce,omitempty"`
}

type MessageDelivery

type MessageDelivery struct {
	BaseDocument  `json:",inline"`
	MessageID     string         `json:"messageId"`
	MTPStatusCode *MTPStatusCode `json:"code"`
	Created       int64          `json:"created"`
}

type Nonce

type Nonce struct {
	BaseDocument `json:",inline"`
	Nonce        string `json:"nonce"`
	Created      int64  `json:"created"`
}

type NonceResponse

type NonceResponse struct {
	Nonce string `json:"nonce"`
}

When responding a nonce string as a signature challenge

type OK

type OK struct {
	IsOK bool `json:"ok"`
}

type OriginServer

type OriginServer struct {
	Domain string `json:"domain" validate:"required"` // required
	IP     string `json:"ip,omitempty"`               // optional
}

type OutputBasicUserInfo

type OutputBasicUserInfo struct {
	Address     string        `json:"address"`
	TotalDisk   int64         `json:"totalDisk,omitempty"`
	UsedDisk    int64         `json:"usedDisk,omitempty"`
	DisplayName string        `json:"displayName,omitempty"`
	Picture     string        `json:"picture,omitempty"`
	Phone       string        `json:"phone,omitempty"`
	JobTitle    string        `json:"jobTitle,omitempty"`    // job title of the requester
	Company     string        `json:"company,omitempty"`     // company of the requester
	Description string        `json:"description,omitempty"` // description of the request
	Social      *MailioSocial `json:"social,omitempty"`      // social media links of the requester
	Created     int64         `json:"created,omitempty"`     // creation time
	WhatToShare string        `json:"whatToShare,omitempty"` // what the user wants to share from their personal data
}

type OutputDIDLookup

type OutputDIDLookup struct {
	Found    []*DIDLookup `json:"found,omitempty"`
	NotFound []*DIDLookup `json:"notFound,omitempty"`
}

type OutputUserAddress

type OutputUserAddress struct {
	Address string `json:"address"`
}

type PagingResults

type PagingResults struct {
	Docs     []interface{} `json:"docs"`
	Bookmark string        `json:"bookmark,omitempty"`
}

type PhysicalAddress

type PhysicalAddress struct {
	Street      string `json:"street,omitempty"`
	StreetLine2 string `json:"streetLine2,omitempty"`
	Country     string `json:"country,omitempty"`
	City        string `json:"city,omitempty"`
	State       string `json:"state,omitempty"`
	ZipCode     string `json:"zipCode,omitempty"`
	PoBox       string `json:"poBox,omitempty"`
	Label       string `json:"label,omitempty"`
}

PhysicalAddress is a struct that represents a physical address

type PlainBodyDelivery

type PlainBodyDelivery struct {
	StatusCodes []*MTPStatusCode `json:"statusCodes" validate:"required,min=1"` // MTP status messages
}

Delivery message (successfull or failed)

type PresignedUrl

type PresignedUrl struct {
	Url string `json:"url"`
}

type Recipient

type Recipient struct {
	EncryptedKey string `json:"encrypted_key" validate:"required"` // Tthe key used to encrypt the ciphertext, encrypted with the recipient's public key
	Header       Header `json:"header" validate:"required"`        // encryption parameters specific to each recipient
}

Recipient is a struct that represents a recipient of an encrypted message

type SenderMetadata

type SenderMetadata struct {
	EmailHash string `json:"emailHash,omitempty"` // scrypt hash of the email address
	Address   string `json:"address,omitempty"`   // mailio address
}

One of the emailHash or address MUST be present

type ServerKeys

type ServerKeys struct {
	Type       string `json:"type"`
	PublicKey  string `json:"publicKey"`
	PrivateKey string `json:"privateKey"`
	Created    int64  `json:"created"`
}

type SmartKey

type SmartKey struct {
	BaseDocument            `json:",inline"`
	Address                 string `json:"address" validate:"required"`                 // mailio address
	PrimaryEd25519PublicKey string `json:"primaryEd25519PublicKey" validate:"required"` // primary Ed25519 public key (associated with address)
	PrimaryX25519PublicKey  string `json:"primaryX25519PublicKey" validate:"required"`  // primary X25519 public key (associated with address)
	PreRotatedMailioKey     string `json:"preRotatedMailioKey" validate:"required"`     // aes encrypyted mailio key
	PasswordShare           string `json:"passwordShare" validate:"required"`           // a single share of a Shamir secret (2 out of 3 required for decryption)
	Email                   string `json:"email" validate:"required"`                   // email address
	SmartKeyEncrypted       string `json:"smartKeyEncrypted" validate:"required"`       // encrypted smart key
	Created                 int64  `json:"created"`                                     // created timestamp
}

RotationKey is a struct that represents a rotation key

type SmartKeyPayload

type SmartKeyPayload struct {
	SmartKeyEncrypted       string `json:"smartKeyEncrypted" validate:"required"`       // encrypted pre-Shamir secret sharing
	PreRotatedMailioKey     string `json:"preRotatedMailioKey" validate:"required"`     // encypted pre-Shamir secret sharing
	Address                 string `json:"address" validate:"required"`                 // mailio address
	PasswordShare           string `json:"passwordShare" validate:"required"`           // a single share of a Shamir secret (2 out of 3 required for decryption)
	DatabasePassword        string `json:"databasePassword" validate:"required"`        // CoachDB password
	Email                   string `json:"email" validate:"required"`                   // email address
	PrimaryEd25519PublicKey string `json:"primaryEd25519PublicKey" validate:"required"` // primary Ed25519 public key (associated with address)
	PrimaryX25519PublicKey  string `json:"primaryX25519PublicKey" validate:"required"`  // primary X25519 public key (associated with address)
	ChallengeSignature      string `json:"challengeSignature" validate:"required"`      // signature of the challenge with the primary private key (held by client only)
	Challenge               string `json:"challenge" validate:"required"`               // challenge
}

type SmtpEmailInput

type SmtpEmailInput struct {
	From              string                `json:"from"`                // The email address of the original sender.
	ReplyTo           []*string             `json:"replyTo,omitempty"`   // The email address to which bounces (undeliverable notifications) are to be forwarded.
	To                []string              `json:"to"`                  // The email addresses of the recipients.
	Cc                []*string             `json:"cc,omitempty"`        // The email addresses of the CC recipients.
	Bcc               []*string             `json:"bcc,omitempty"`       // The email addresses of the BCC recipients.
	MessageId         *string               `json:"messageId,omitempty"` // message id
	Subject           *string               `json:"subject,omitempty"`
	BodyText          *string               `json:"bodyText,omitempty"` // The text version of the email.
	BodyHTML          *string               `json:"bodyHtml,omitempty"` // The HTML version of the email.
	Timestamp         int64                 `json:"timestamp"`          // The time the email was sent.
	Attachments       []*abi.SmtpAttachment `json:"attachments,omitempty"`
	DeleteAttachments []string              `json:"deleteAttachments,omitempty"` // The IDs of attachments to be deleted (the decision is left to client to make: if only encrypted then plaint attachment should be deleted, if both types of recipients then no attachments shhould be deleted, ... ).
}

type SmtpTask

type SmtpTask struct {
	Mail    *SmtpEmailInput `json:"mail" validate:"required"`
	Address string          `json:"address,omitempty"` // sender/receiver mailio address

}

type Task

type Task struct {
	Address             string               `json:"address,omitempty"`           // Authenticated user address
	DIDCommMessageInput *DIDCommMessageInput `json:"message" validate:"required"` // the message to be processed
}

Task is a queue process for incoming and outgoing DIDComm messages

type ToEmail

type ToEmail struct {
	Email     string `json:"email" validate:"required,email"` // recipient email address
	EmailHash string `json:"emailHash" validate:"required"`   // recipient email address hash
}

type UploadPhotoInput

type UploadPhotoInput struct {
	PhotoBase64 string `json:"photoBase64" validate:"required"`
}

type User

type User struct {
	Email          string `json:"email" validate:"required,email"`
	EncryptedEmail string `json:"encryptedEmail" validate:"required"` // base64 scrypt encrypted email
	MailioAddress  string `json:"mailioAddress" validate:"required"`
	Created        int64  `json:"created" validate:"required"`
	Modified       int64  `json:"modified,omitempty"`
}

type UserDomain

type UserDomain struct {
	Name string `json:"name"`
	Type string `json:"type" oneOf:"smtp mailio"`
}

user domain (which domain user is associated with)

type UserProfile

type UserProfile struct {
	BaseDocument `json:",inline"` // Address is the user's id
	Enabled      bool             `json:"enabled"`
	DiskSpace    int64            `json:"diskSpace,omitempty"`
	Domain       string           `json:"domain" validate:"required"`
	Modified     int64            `json:"modified,omitempty"`
	Created      int64            `json:"created,omitempty"`
	DisplayName  string           `json:"displayName,omitempty"` // display name of the user
	Phone        string           `json:"phone,omitempty"`       // phone number of the requester
	Picture      string           `json:"picture,omitempty"`     // avatar of the requester (base64 or link to the image)
	JobTitle     string           `json:"jobTitle,omitempty"`    // job title of the requester
	Company      string           `json:"company,omitempty"`     // company of the requester
	Description  string           `json:"description,omitempty"` // description of the requester
	Social       *MailioSocial    `json:"social,omitempty"`      // social media links of the requester
	WhatToShare  string           `json:"whatToShare,omitempty"` // what the user wants to share from their personal data
}

type UserProfileStats

type UserProfileStats struct {
	DocCount      int64 `json:"docCount,omitempty"`      // A count of the documents
	DocDelCount   int64 `json:"docDelCount,omitempty"`   // number of deleted documents
	ActiveSize    int64 `json:"activeSize,omitempty"`    // The size of live data inside the database, in bytes.
	ExternalSize  int64 `json:"externalSize,omitempty"`  // The uncompressed size of database contents in bytes.
	FileSize      int64 `json:"fileSize,omitempty"`      // The size of the database file on disk in bytes. Views indexes are not included in the calculation.
	CloudFileSize int64 `json:"cloudFileSize,omitempty"` // The size of the files uploaded to cloud storage in bytes
}

type VCValidationResponse

type VCValidationResponse struct {
	Valid     bool   `json:"valid"`
	RequestId string `json:"requestId,omitempty"`
}

type VerifiableCredentialDocument

type VerifiableCredentialDocument struct {
	BaseDocument `json:",inline"`
	VC           *did.VerifiableCredential `json:"vc"`
}

type WebAuhnUser

type WebAuhnUser struct {
	ID          []byte
	Name        string
	DisplayName string
	Credentials []webauthn.Credential
	Icon        string
}

func MapWebAuthnUserFromDB

func MapWebAuthnUserFromDB(user WebAuthnUserDB) *WebAuhnUser

func (*WebAuhnUser) WebAuthnCredentials

func (u *WebAuhnUser) WebAuthnCredentials() []webauthn.Credential

Implementing the WebAuthnCredentials method

func (*WebAuhnUser) WebAuthnDisplayName

func (u *WebAuhnUser) WebAuthnDisplayName() string

Implementing the WebAuthnDisplayName method

func (*WebAuhnUser) WebAuthnID

func (u *WebAuhnUser) WebAuthnID() []byte

Implementing the WebAuthnID method

func (*WebAuhnUser) WebAuthnIcon

func (u *WebAuhnUser) WebAuthnIcon() string

Implementing the WebAuthnIcon method

func (*WebAuhnUser) WebAuthnName

func (u *WebAuhnUser) WebAuthnName() string

Implementing the WebAuthnName method

type WebAuthnUserDB

type WebAuthnUserDB struct {
	BaseDocument `json:",inline"`
	Address      string                `json:"id"`          // maps to WebAuthNUser ID
	Name         string                `json:"name"`        // maps to WebAuthNUser Name
	DisplayName  string                `json:"displayName"` // maps to WebAuthNUser DisplayName
	Credentials  []webauthn.Credential `json:"credentials"` // maps to WebAuthNUser Credentials
	Icon         string                `json:"icon"`        // maps to WebAuthNUser Icon
}

func MapWebAuthnUserToDB

func MapWebAuthnUserToDB(user WebAuhnUser) WebAuthnUserDB

type WebauthRegistrationVerify

type WebauthRegistrationVerify struct {
	AttestationResponse *WebauthnAttestationResponseJSON `json:"attestationResponse" validate:"required"`
	SmartKeyPayload     *SmartKeyPayload                 `json:"smartKeyPayload" validate:"required"`
}

type WebauthnAttestationResponse

type WebauthnAttestationResponse struct {
	AttestationObject  string   `json:"attestationObject"`
	ClientDataJSON     string   `json:"clientDataJSON"`
	Transports         []string `json:"transports"`
	PublicKeyAlgorithm int      `json:"publicKeyAlgorithm"`
	PublicKey          string   `json:"publicKey"`
	AuthenticatorData  string   `json:"authenticatorData"`
}

type WebauthnAttestationResponseJSON

type WebauthnAttestationResponseJSON struct {
	ID                      string                      `json:"id"`
	RawID                   string                      `json:"rawId"`
	Type                    string                      `json:"type"`
	ClientExtensionResults  map[string]interface{}      `json:"clientExtensionResults,omitempty"`
	AuthenticatorAttachment string                      `json:"authenticatorAttachment"`
	Response                WebauthnAttestationResponse `json:"response"`
}

WebauthnAttestationResponseJSON is the JSON response from the Webauthn API

Jump to

Keyboard shortcuts

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