Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decrypt

func Decrypt(b []byte, v interface{}, key *keys.EdX25519Key) (*keys.X25519PublicKey, error)

Decrypt value, returning sender public key.

func Encrypt

func Encrypt(i interface{}, sender *keys.EdX25519Key, recipient keys.ID) ([]byte, error)

Encrypt does crypto_box_seal(pk+crypto_box(msgpack(i))).

func NewID

func NewID() string

NewID returns a new random ID (string).

Types

type BatchRequest

type BatchRequest struct {
	ID      string            `json:"id"`
	Method  string            `json:"method"`
	URL     string            `json:"url"`
	Headers map[string]string `json:"headers"`
}

BatchRequest ...

func NewBatchRequest

func NewBatchRequest(id string, method string, urs string, contentHash string, now time.Time, key *keys.EdX25519Key) (*BatchRequest, error)

NewBatchRequest returns batch request.

type BatchRequests

type BatchRequests struct {
	Requests []*BatchRequest `json:"requests"`
}

BatchRequests ...

type BatchResponse

type BatchResponse struct {
	ID     string      `json:"id"`
	Status int         `json:"status"`
	Body   interface{} `json:"body"`
}

BatchResponse ..

func (*BatchResponse) As

func (r *BatchResponse) As(v interface{}) error

As unmarshals into value.

func (*BatchResponse) Error

func (r *BatchResponse) Error() *Error

type BatchResponses

type BatchResponses struct {
	Responses []*BatchResponse `json:"responses"`
}

BatchResponses ...

type Channel

type Channel struct {
	ID keys.ID `json:"id" msgpack:"id"`

	Index     int64  `json:"idx,omitempty" msgpack:"idx,omitempty"`
	Timestamp int64  `json:"ts,omitempty" msgpack:"ts,omitempty"`
	Token     string `json:"token,omitempty" msgpack:"token,omitempty"`
}

Channel ...

type ChannelCreateRequest

type ChannelCreateRequest struct {
	// Message to post on create.
	Message []byte `json:"msg,omitempty" msgpack:"msg,omitempty"`
}

ChannelCreateRequest ...

type ChannelCreateResponse

type ChannelCreateResponse struct {
	Channel *Channel `json:"channel,omitempty" msgpack:"channel,omitempty"`
}

ChannelCreateResponse ...

type ChannelInfo

type ChannelInfo struct {
	Name        string `json:"name,omitempty" msgpack:"name,omitempty"`
	Description string `json:"desc,omitempty" msgpack:"desc,omitempty"`
}

ChannelInfo for setting channel name or description.

type ChannelInvite

type ChannelInvite struct {
	Channel   keys.ID      `json:"channel" msgpack:"channel"`
	Recipient keys.ID      `json:"recipient" msgpack:"recipient"`
	Sender    keys.ID      `json:"sender" msgpack:"sender"`
	Key       *api.Key     `json:"key" msgpack:"key"`
	Token     string       `json:"token" msgpack:"token"`
	Info      *ChannelInfo `json:"info,omitempty" msgpack:"info,omitempty"`
}

ChannelInvite if invited to a channel.

type ChannelJoin

type ChannelJoin struct {
	User keys.ID `json:"user" msgpack:"user"`
}

ChannelJoin is a user joined a channel (invite was accepted) (notification).

type ChannelLeave

type ChannelLeave struct {
	User keys.ID `json:"user" msgpack:"user"`
}

ChannelLeave if a user left the channel (notification).

type ChannelStatus

type ChannelStatus struct {
	ID        keys.ID `json:"id" msgpack:"id"`
	Index     int64   `json:"idx" msgpack:"idx"`
	Timestamp int64   `json:"ts" msgpack:"ts"`
}

ChannelStatus ...

type ChannelToken

type ChannelToken struct {
	Channel keys.ID
	Token   string
}

ChannelToken ...

type ChannelsStatusRequest

type ChannelsStatusRequest struct {
	Channels map[keys.ID]string `json:"channels,omitempty" msgpack:"channels,omitempty"`
}

ChannelsStatusRequest ...

type ChannelsStatusResponse

type ChannelsStatusResponse struct {
	Channels []*ChannelStatus `json:"channels,omitempty" msgpack:"channels,omitempty"`
}

ChannelsStatusResponse ...

type Data

type Data struct {
	Data []byte `json:"data" msgpack:"dat"`
}

Data for request body.

type DirectToken

type DirectToken struct {
	User  keys.ID `json:"user" msgpack:"user"`
	Token string  `json:"token" msgpack:"token"`
}

DirectToken ...

type Error

type Error struct {
	Message string `json:"message,omitempty"`
	Status  int    `json:"status,omitempty"`
}

Error ...

type Events

type Events struct {
	Events    []*events.Event `json:"events"`
	Index     int64           `json:"idx"`
	Truncated bool            `json:"truncated,omitempty"`
}

Events ...

func (Events) Decrypt

func (e Events) Decrypt(key *keys.EdX25519Key) ([]*Message, error)

Decrypt events into messages.

type EventsResponse

type EventsResponse struct {
	Events []*events.Event `json:"events" msgpack:"events"`
	Index  int64           `json:"idx" msgpack:"idx"`
}

EventsResponse ...

type Follow

type Follow struct {
	Sender    keys.ID `json:"sender" msgpack:"sender"`
	Recipient keys.ID `json:"recipient" msgpack:"recipient"`
}

Follow user.

type FollowResponse

type FollowResponse struct {
	Follow *Follow `json:"follow" msgpack:"follow"`
}

FollowResponse ...

type FollowsResponse

type FollowsResponse struct {
	Follows []*Follow `json:"follows" msgpack:"follows"`
}

FollowsResponse ...

type InviteCodeCreateResponse

type InviteCodeCreateResponse struct {
	Code string `json:"code"`
}

InviteCodeCreateResponse ...

type InviteCodeResponse

type InviteCodeResponse struct {
	Sender    keys.ID `json:"sender"`
	Recipient keys.ID `json:"recipient"`
}

InviteCodeResponse ...

type Message

type Message struct {
	ID        string  `json:"id,omitempty" msgpack:"id,omitempty"`
	Prev      string  `json:"prev,omitempty" msgpack:"prev,omitempty"`
	Timestamp int64   `json:"ts,omitempty" msgpack:"ts,omitempty"`
	Sender    keys.ID `json:"sender" msgpack:"sender"`

	// For message text (optional).
	Text string `json:"text,omitempty" msgpack:"text,omitempty"`

	// ChannelInfo sets info.
	ChannelInfo *ChannelInfo `json:"channelInfo,omitempty" msgpack:"channelInfo,omitempty"`

	// ChannelInvites to invite to a new channel.
	ChannelInvites []*ChannelInvite `json:"channelInvites,omitempty" msgpack:"channelInvites,omitempty"`

	// RemoteIndex is set from the remote events API (untrusted).
	RemoteIndex int64 `json:"-" msgpack:"-"`
	// RemoteTimestamp is set from the remote events API (untrusted).
	RemoteTimestamp int64 `json:"-" msgpack:"-"`
}

Message is encrypted by clients.

func DecryptMessage

func DecryptMessage(b []byte, key *keys.EdX25519Key) (*Message, error)

DecryptMessage decrypts message.

func DecryptMessageFromEvent

func DecryptMessageFromEvent(event *events.Event, key *keys.EdX25519Key) (*Message, error)

DecryptMessageFromEvent decrypts a remote Event from Messages.

func NewMessage

func NewMessage(sender keys.ID) *Message

NewMessage creates a new empty message.

func NewMessageForChannelInfo

func NewMessageForChannelInfo(sender keys.ID, info *ChannelInfo) *Message

NewMessageForChannelInfo ...

func NewMessageForChannelInvites

func NewMessageForChannelInvites(sender keys.ID, invites []*ChannelInvite) *Message

NewMessageForChannelInvites ...

func (*Message) Encrypt

func (m *Message) Encrypt(sender *keys.EdX25519Key, recipient keys.ID) ([]byte, error)

Encrypt message.

func (*Message) WithPrev

func (m *Message) WithPrev(prev string) *Message

WithPrev ...

func (*Message) WithText

func (m *Message) WithText(text string) *Message

WithText ...

func (*Message) WithTimestamp

func (m *Message) WithTimestamp(ts int64) *Message

WithTimestamp ...

type Metadata

type Metadata struct {
	CreatedAt time.Time `json:"createdAt"`
	UpdatedAt time.Time `json:"updatedAt"`
}

Metadata ...

type Response

type Response struct {
	Error *Error `json:"error,omitempty"`
}

Response ...

type SigchainResponse

type SigchainResponse struct {
	KID        keys.ID             `json:"kid"`
	Metadata   map[string]Metadata `json:"md,omitempty"`
	Statements []*keys.Statement   `json:"statements"`
}

SigchainResponse is the response format for a Sigchain request.

func (SigchainResponse) MetadataFor

func (r SigchainResponse) MetadataFor(st *keys.Statement) Metadata

MetadataFor returns metadata for Signed.

func (SigchainResponse) Sigchain

func (r SigchainResponse) Sigchain() (*keys.Sigchain, error)

Sigchain from response.

type User

type User struct {
	ID         string      `json:"id,omitempty"`
	Name       string      `json:"name,omitempty"`
	KID        keys.ID     `json:"kid,omitempty"`
	Seq        int         `json:"seq,omitempty"`
	Service    string      `json:"service,omitempty"`
	URL        string      `json:"url,omitempty"`
	Status     user.Status `json:"status,omitempty"`
	Statement  string      `json:"statement,omitempty"`
	VerifiedAt int64       `json:"verifiedAt,omitempty"`
	Timestamp  int64       `json:"ts,omitempty"`
	MatchField string      `json:"mf,omitempty"`
	Err        string      `json:"err,omitempty"`
}

User ...

func UserFromResult

func UserFromResult(result *user.Result) *User

UserFromResult returns User from user.Result.

func UserFromSearchResult

func UserFromSearchResult(sr *users.SearchResult) *User

UserFromSearchResult returns User from user.SearchResult.

type UserResponse

type UserResponse struct {
	User *User `json:"user"`
}

UserResponse ...

type UserSearchResponse

type UserSearchResponse struct {
	Users []*User `json:"users"`
}

UserSearchResponse ...

type VaultResponse

type VaultResponse struct {
	Vault     []*events.Event `json:"vault"`
	Index     int64           `json:"idx"`
	Truncated bool            `json:"truncated,omitempty"`
}

VaultResponse ...