api

package module
v0.0.0-...-050e4c4 Latest Latest
Warning

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

Go to latest
Published: May 25, 2021 License: MIT Imports: 8 Imported by: 5

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Decrypt

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

func DecryptKey

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

func DecryptMessage

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

DecryptMessage returning sender public key.

func Encrypt

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

func EncryptKey

func EncryptKey(key *keys.EdX25519Key, to keys.ID) ([]byte, error)

func EncryptMessage

func EncryptMessage(b []byte, channel *keys.EdX25519Key, sender *keys.EdX25519Key) []byte

EncryptMessage does crypto_box_seal(pk+crypto_box(b)).

func NewID

func NewID() string

NewID returns a new random ID (string).

func TeamSign

func TeamSign(team *keys.EdX25519Key, domain string, ts time.Time) (string, error)

Types

type Account

type Account struct {
	KID      keys.ID `json:"kid"`
	Email    string  `json:"email"`
	Username string  `json:"username"`
}

Account ...

type AccountAuth

type AccountAuth struct {
	ID   string `json:"id"`
	Data []byte `json:"data"` // Encrypted auth data
}

type AccountAuthsResponse

type AccountAuthsResponse struct {
	Auths []*AccountAuth `json:"auths"`
}

type AccountCreateRequest

type AccountCreateRequest struct {
	Email           string `json:"email"`
	VerifyEmailCode string `json:"verifyEmailCode"`
}

AccountCreateRequest ...

type AccountRegisterInvite

type AccountRegisterInvite struct {
	Email        string `json:"email,omitempty"`
	RegisterCode string `json:"registerCode,omitempty"`
}

type AccountRegisterInviteRequest

type AccountRegisterInviteRequest struct {
	Email string `json:"email,omitempty"`
}

AccountRegisterInviteRequest ...

type AccountRegisterRequest

type AccountRegisterRequest struct {
	Email        string `json:"email"`
	RegisterCode string `json:"registerCode"`
}

AccountRegisterRequest ...

type AccountResponse

type AccountResponse struct {
	Email    string  `json:"email"`
	KID      keys.ID `json:"kid"`
	Username string  `json:"username"`
}

AccountResponse ...

type AccountUnverified

type AccountUnverified struct {
	ID    string `json:"id"`
	Email string `json:"email"`

	VerifyAttempt     int       `json:"verifyAttempt"`
	VerifyEmailCode   string    `json:"verifyEmailCode"`
	VerifyEmailCodeAt time.Time `json:"verifyEmailCodeAt,omitempty"`
}

type AccountVault

type AccountVault struct {
	Account keys.ID `json:"account"`
	Vault   keys.ID `json:"vault"`
	Token   string  `json:"token"`
	Usage   int64   `json:"usage"`
}

AccountVault ...

type AccountVaultsResponse

type AccountVaultsResponse struct {
	Vaults []*AccountVault `json:"vaults"`
}

AccountVaultsResponse ...

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"`

	Info Encrypted `json:"info,omitempty" msgpack:"info,omitempty"`

	// For team channels
	Team    keys.ID   `json:"team,omitempty" msgpack:"team,omitempty"`
	TeamKey Encrypted `json:"teamKey,omitempty" msgpack:"teamKey,omitempty"`

	// For user channels
	UserKey Encrypted `json:"userKey,omitempty" msgpack:"userKey,omitempty"`
}

type ChannelCreateRequest

type ChannelCreateRequest struct {
	Info Encrypted `json:"info"`

	UserKeys []*UserKey `json:"userKeys,omitempty"`

	Team    keys.ID   `json:"team,omitempty"`
	TeamKey Encrypted `json:"teamKey,omitempty"`
}

type ChannelInfo

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

ChannelInfo for setting channel name or description.

type ChannelToken

type ChannelToken struct {
	Channel keys.ID `json:"channel"`
	Token   string  `json:"token"`
}

type ChannelUsersAddRequest

type ChannelUsersAddRequest struct {
	UserKeys []*UserKey `json:"userKeys,omitempty"`
}

type ChannelUsersRemoveRequest

type ChannelUsersRemoveRequest struct {
	Users []keys.ID `json:"users,omitempty"`
}

type ChannelUsersResponse

type ChannelUsersResponse struct {
	Users []keys.ID `json:"users,omitempty"`
}

type ChannelsResponse

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

type Config

type Config struct {
	RelayURL  string `json:"relayURL"`
	RelayAuth string `json:"relayAuth"`
}

type Data

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

Data for request body.

type Encrypted

type Encrypted []byte

type Error

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

Error ...

type Event

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

	// Index for event (read only).
	Index int64 `json:"idx" msgpack:"idx" firestore:"idx"`
	// Timestamp (read only). The time at which the event was created.
	// Firestore sets this to the document create time.
	Timestamp int64 `json:"ts" msgpack:"ts" firestore:"-"`
}

type Events

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

Events ...

type EventsResponse

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

EventsResponse ...

type Message

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

	// For message text.
	Text string `json:"text,omitempty" msgpack:"text,omitempty" db:"text"`

	// Command encodes other types of messages.
	Command *MessageCommand `json:"cmd,omitempty" msgpack:"cmd,omitempty" db:"cmd"`

	// RemoteIndex is set from the remote events API (untrusted).
	RemoteIndex int64 `json:"ridx,omitempty" msgpack:"ridx,omitempty" db:"ridx"`
	// RemoteTimestamp is set from the remote events API (untrusted).
	RemoteTimestamp int64 `json:"rts,omitempty" msgpack:"rts,omitempty" db:"rts"`
}

Message is encrypted by clients.

func NewMessage

func NewMessage(channel keys.ID, sender keys.ID) *Message

NewMessage creates a new empty message.

func NewMessageForChannelInfo

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

NewMessageForChannelInfo ...

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 MessageCommand

type MessageCommand struct {
	// ChannelInfo sets info.
	ChannelInfo *ChannelInfo `json:"channelInfo,omitempty" msgpack:"channelInfo,omitempty"`
}

MessageCommand encodes other types of messages.

type MesssagesResponse

type MesssagesResponse struct {
	Messages  []*Event `json:"msgs" msgpack:"msgs"`
	Index     int64    `json:"idx" msgpack:"idx"`
	Truncated bool     `json:"truncated,omitempty" msgpack:"trunc,omitempty"`
}

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 SendEmailVerificationResponse

type SendEmailVerificationResponse struct {
	Email string  `json:"email"`
	KID   keys.ID `json:"kid"`
}

SendEmailVerificationResponse ...

type Team

type Team struct {
	ID         keys.ID   `json:"id"`
	CreatedBy  keys.ID   `json:"createdBy"`
	Token      string    `json:"token"`
	Domain     string    `json:"domain,omitempty"`
	VerifiedAt time.Time `json:"verifiedAt,omitempty"`
}

func (Team) Verify

func (o Team) Verify(s string) error

type TeamCreateRequest

type TeamCreateRequest struct {
	Domain string `json:"domain"`
}

TeamCreateRequest ...

type TeamInvite

type TeamInvite struct {
	TeamKey      Encrypted `json:"tk"`
	Email        string    `json:"email,omitempty"`
	RegisterCode string    `json:"registerCode,omitempty"`
	CreatedAt    time.Time `json:"createdAt"`
}

type TeamInviteRequest

type TeamInviteRequest struct {
	TeamKey Encrypted `json:"tk"`
	Email   string    `json:"email,omitempty"`
}

type TeamInviteResponse

type TeamInviteResponse struct {
	TeamKey      Encrypted `json:"tk"`
	RegisterCode string    `json:"registerCode,omitempty"`
}

type TeamStatement

type TeamStatement struct {
	KID       keys.ID `json:"kid"`
	Domain    string  `json:"domain"`
	Timestamp int64   `json:"ts"`
}

type TeamsResponse

type TeamsResponse struct {
	Teams []*Team `json:"teams"`
}

TeamsResponse ...

type User

type User struct {
	KID  keys.ID `json:"kid"`
	Name string  `json:"name"`
}

type UserKey

type UserKey struct {
	User keys.ID   `json:"user"`
	Key  Encrypted `json:"key"`
}

type UsersLookupRequest

type UsersLookupRequest struct {
	KIDs []keys.ID `json:"kids"`
}

type UsersResponse

type UsersResponse struct {
	Users []*User `json:"users"`
	Index int64   `json:"idx"`
}

type Vault

type Vault 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"`

	Usage   int64 `json:"usage,omitempty" msgpack:"usage,omitempty"`
	Deleted bool  `json:"del,omitempty" msgpack:"del,omitempty"`

	Team      keys.ID `json:"team" msgpack:"team"`
	CreatedBy keys.ID `json:"createdBy" msgpack:"createdBy"`
}

Vault ...

type VaultResponse

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

VaultResponse ...

type VaultStatus

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

VaultStatus ...

type VaultToken

type VaultToken struct {
	Vault keys.ID `json:"vault"`
	Token string  `json:"token"`
}

VaultToken ...

type VaultsStatusRequest

type VaultsStatusRequest struct {
	Vaults map[keys.ID]string `json:"vaults,omitempty" msgpack:"vaults,omitempty"`
}

VaultsStatusRequest ...

type VaultsStatusResponse

type VaultsStatusResponse struct {
	Vaults []*VaultStatus `json:"vaults,omitempty" msgpack:"vaults,omitempty"`
}

VaultsStatusResponse ...

Jump to

Keyboard shortcuts

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