Documentation
¶
Index ¶
- Variables
- func CanonicalHost(host string) string
- func GenerateJWTToken(addr hash.Hash, key bmcrypto.PrivKey) (string, error)
- func GetErrorFromResponse(body []byte) error
- func IsJWTTokenExpired(tokenString string) bool
- func ValidateJWTToken(tokenString string, addr hash.Hash, key bmcrypto.PubKey) (*jwt.Token, error)
- type API
- func (api *API) CompleteUpload(t ticket.Ticket) error
- func (api *API) CreateAPIKey(addrHash hash.Hash, key key.APIKeyType) error
- func (api *API) CreateAccount(info vault.AccountInfo, token string) error
- func (api *API) CreateAuthKey(addrHash hash.Hash, key key.AuthKeyType) (string, error)
- func (api *API) CreateWebhook(wh webhook.Type) (*webhook.Type, error)
- func (api *API) Delete(path string) (body []byte, statusCode int, err error)
- func (api *API) DeleteAPIKey(addrHash hash.Hash, ID string) error
- func (api *API) DeleteAuthKey(addrHash hash.Hash, fingerprint string) error
- func (api *API) DeleteMessage(t ticket.Ticket) error
- func (api *API) DeleteWebhook(addrHash hash.Hash, ID string) error
- func (api *API) DisableWebhook(addrHash hash.Hash, ID string) error
- func (api *API) EnableWebhook(addrHash hash.Hash, ID string) error
- func (api *API) GenerateAPIAttachmentReader(addr hash.Hash) func(messageID, attachmentID string) io.Reader
- func (api *API) GenerateAPIBlockReader(addr hash.Hash) func(messageID, blockID string) io.Reader
- func (api *API) Get(path string) (body []byte, statusCode int, err error)
- func (api *API) GetAPIKey(addrHash hash.Hash, ID string) (*key.APIKeyType, error)
- func (api *API) GetAccountTicket(from, to hash.Hash, subscriptionID string) (*ticket.Ticket, error)
- func (api *API) GetAuthKey(addrHash hash.Hash, fingerprint string) (*key.AuthKeyType, error)
- func (api *API) GetJSON(path string, v interface{}) (body []byte, status int, err error)
- func (api *API) GetMailboxList(addr hash.Hash) (*MailboxList, error)
- func (api *API) GetMailboxMessages(addr hash.Hash, box string, since time.Time) (*MailboxMessages, error)
- func (api *API) GetMessage(addr hash.Hash, messageID string) (*Message, error)
- func (api *API) GetMessageAttachment(addr hash.Hash, messageID, attachmentID string) (io.ReadCloser, error)
- func (api *API) GetMessageBlock(addr hash.Hash, messageID, blockID string) (io.ReadCloser, error)
- func (api *API) GetPublicKey(addr hash.Hash) (string, error)
- func (api *API) GetReader(path string) (r io.ReadCloser, statusCode int, err error)
- func (api *API) GetTicket(from, to hash.Hash, subscriptionID string) (*ticket.Ticket, error)
- func (api *API) GetWebhook(addrHash hash.Hash, ID string) (*webhook.Type, error)
- func (api *API) ListAPIKeys(addrHash hash.Hash) ([]key.APIKeyType, error)
- func (api *API) ListAuthKeys(addrHash hash.Hash) ([]key.AuthKeyType, error)
- func (api *API) ListWebhooks(addrHash hash.Hash) ([]webhook.Type, error)
- func (api *API) Post(path string, data []byte) (body []byte, statusCode int, err error)
- func (api *API) PostJSON(path string, data interface{}) (body []byte, statusCode int, err error)
- func (api *API) PostReader(path string, r io.Reader) (body []byte, statusCode int, err error)
- func (api *API) RemoveMessage(addr hash.Hash, messageID string) error
- func (api *API) StoreGetPath(key bmcrypto.KeyPair, addr hash.Hash, path string, recursive bool, ...) (*StoreEntry, error)
- func (api *API) StorePutValue(key bmcrypto.KeyPair, addr hash.Hash, path string, value string) error
- func (api *API) UpdateWebhook(addrHash hash.Hash, ID string, wh webhook.Type) error
- func (api *API) UploadBlock(t ticket.Ticket, blockID string, r io.Reader) error
- func (api *API) UploadCatalog(t ticket.Ticket, encryptedCatalog []byte) error
- func (api *API) UploadHeader(t ticket.Ticket, header *message.Header) error
- func (api *API) ValidateTicket(from, to hash.Hash, subscriptionID string, t *ticket.Ticket) (*ticket.Ticket, error)
- type ClientOpts
- type MailboxList
- type MailboxListBox
- type MailboxMessages
- type MailboxMessagesMessage
- type Message
- type StoreEntry
Constants ¶
This section is empty.
Variables ¶
var ( ErrInvalidSigningMethod = errors.New("invalid signing method") ErrTokenNotValid = errors.New("token not valid") ErrTokenTimeNotValid = errors.New("token time not valid") ErrSubjectNotValid = errors.New("subject not valid") )
Error codes
Functions ¶
func CanonicalHost ¶
CanonicalHost returns a given host in the form of http(s)://<host>:<port>
func GenerateJWTToken ¶
GenerateJWTToken generates a JWT token with the address and singed by the given private key
func GetErrorFromResponse ¶
GetErrorFromResponse will return an error generated from the body
func IsJWTTokenExpired ¶
IsJWTTokenExpired will check if the token is already expired
Types ¶
type API ¶
type API struct {
// contains filtered or unexported fields
}
API is a structure to connect to the server for the given account
func NewAnonymous ¶
NewAnonymous creates a new client that connects anonymously to a BitMaelum server (normally server-to-server communications)
func NewAuthenticated ¶
func NewAuthenticated(addr address.Address, key bmcrypto.PrivKey, host string, f serverErrorFunc) (*API, error)
NewAuthenticated creates a new client that connects to a BitMaelum Server with specific credentials (normally client-to-server communications)
func NewClient ¶
func NewClient(opts ClientOpts) (*API, error)
NewClient creates a new client based on the given options
func (*API) CompleteUpload ¶
CompleteUpload signals the mailserver that all blocks (and headers) have been uploaded and can start processing
func (*API) CreateAPIKey ¶
CreateAPIKey Create a new API key
func (*API) CreateAccount ¶
func (api *API) CreateAccount(info vault.AccountInfo, token string) error
CreateAccount creates new account on server
func (*API) CreateAuthKey ¶
CreateAuthKey will create a new authorized key on the server
func (*API) CreateWebhook ¶
CreateWebhook Create a new API key
func (*API) DeleteAPIKey ¶
DeleteAPIKey deletes a new API key
func (*API) DeleteAuthKey ¶
DeleteAuthKey deletes a new auth key
func (*API) DeleteMessage ¶
DeleteMessage deletes a message and all content
func (*API) DeleteWebhook ¶
DeleteWebhook deletes a webhook
func (*API) DisableWebhook ¶
DisableWebhook will disable a webhook
func (*API) EnableWebhook ¶
EnableWebhook will enable a webhook
func (*API) GenerateAPIAttachmentReader ¶
func (api *API) GenerateAPIAttachmentReader(addr hash.Hash) func(messageID, attachmentID string) io.Reader
GenerateAPIAttachmentReader returns a reader function that will create a reader from the given message and attachment ID.
func (*API) GenerateAPIBlockReader ¶
GenerateAPIBlockReader returns a reader function that will create a reader from the given message and block ID.
func (*API) GetAccountTicket ¶
GetAccountTicket retrieves a ticket that can be used for uploading a message
func (*API) GetAuthKey ¶
GetAuthKey gets a single key
func (*API) GetMailboxList ¶
func (api *API) GetMailboxList(addr hash.Hash) (*MailboxList, error)
GetMailboxList returns a list of mailboxes
func (*API) GetMailboxMessages ¶
func (api *API) GetMailboxMessages(addr hash.Hash, box string, since time.Time) (*MailboxMessages, error)
GetMailboxMessages returns a list of message within a specific mailbox
func (*API) GetMessage ¶
GetMessage retrieves a message header + catalog from a message
func (*API) GetMessageAttachment ¶
func (api *API) GetMessageAttachment(addr hash.Hash, messageID, attachmentID string) (io.ReadCloser, error)
GetMessageAttachment retrieves a message attachment reader
func (*API) GetMessageBlock ¶
GetMessageBlock retrieves a message block
func (*API) GetPublicKey ¶
GetPublicKey gets public key for given address on the mail server
func (*API) GetReader ¶
GetReader returns a io.Reader from the API. It is the same as api.Get(), except this one already has read the whole body.
func (*API) GetWebhook ¶
GetWebhook gets a single webhook
func (*API) ListAPIKeys ¶
ListAPIKeys lists alll API keys
func (*API) ListAuthKeys ¶
ListAuthKeys lists all auth keys
func (*API) ListWebhooks ¶
ListWebhooks lists alll webhooks
func (*API) PostReader ¶
PostReader posts to API through a reader
func (*API) RemoveMessage ¶
RemoveMessage deletes a message on the server
func (*API) StoreGetPath ¶
func (api *API) StoreGetPath(key bmcrypto.KeyPair, addr hash.Hash, path string, recursive bool, since time.Time) (*StoreEntry, error)
StoreGetPath will fetch an entry
func (*API) StorePutValue ¶
func (api *API) StorePutValue(key bmcrypto.KeyPair, addr hash.Hash, path string, value string) error
StorePutValue will store an value to a path
func (*API) UpdateWebhook ¶
UpdateWebhook will update a webhook
func (*API) UploadBlock ¶
UploadBlock uploads a message block or attachment
func (*API) UploadCatalog ¶
UploadCatalog uploads a catalog
func (*API) UploadHeader ¶
UploadHeader uploads a header
type ClientOpts ¶
type ClientOpts struct { Host string AllowInsecure bool Address address.Address Key *bmcrypto.PrivKey JWTToken string Debug bool ErrorFunc serverErrorFunc }
ClientOpts allows you to configure the API client
type MailboxList ¶
type MailboxList struct { Meta struct { Total int `json:"total"` Returned int `json:"returned"` } `json:"meta"` Boxes []MailboxListBox `json:"boxes"` }
MailboxList is a list of mailboxes
type MailboxListBox ¶
type MailboxListBox struct { ID int `json:"id"` Total int `json:"total"` Messages []string `json:"messages"` }
MailboxListBox is a structure that holds a given mailbox and the total messages inside
type MailboxMessages ¶
type MailboxMessages struct { Meta struct { Total int `json:"total"` Returned int `json:"returned"` Offset int `json:"offset"` Limit int `json:"limit"` } `json:"meta"` Messages []MailboxMessagesMessage `json:"messages"` }
MailboxMessages returns a list of mailbox messages
type MailboxMessagesMessage ¶
type MailboxMessagesMessage struct { ID string `json:"id"` Header message.Header `json:"header"` Catalog []byte `json:"catalog"` }
MailboxMessagesMessage is a message (header + catalog) within a mailbox
type Message ¶
type Message struct { ID string `json:"id"` Header message.Header `json:"h"` Catalog []byte `json:"c"` }
Message is a standard structure that returns a message header + catalog
type StoreEntry ¶
type StoreEntry struct { Path hash.Hash `json:"path"` Parent *hash.Hash `json:"parent"` Data string `json:"data"` Timestamp int64 `json:"timestamp"` Children []StoreEntry `json:"children"` }
StoreEntry is the unencrypted store entry with child nodes if needed