HTTP Client for

This documentation is in progress.

Expand ▾ Collapse ▴





This section is empty.


This section is empty.


func SetLogger

func SetLogger(l Logger)

    SetLogger sets logger for the package.


    type ChannelCreated

    type ChannelCreated struct {
    	Channel *api.Channel
    	Message *api.Message

      ChannelCreated ...

      type ChannelInvites

      type ChannelInvites struct {
      	Invites   []*api.ChannelInvite
      	Index     int64
      	Truncated bool

        ChannelInvites ..

        type Client

        type Client struct {
        	// contains filtered or unexported fields

          Client ...

          func New

          func New(urs string) (*Client, error)

            New creates a Client for the Web API.

            func (*Client) AdminCheck

            func (c *Client) AdminCheck(ctx context.Context, check string, admin *keys.EdX25519Key) error

              AdminCheck performs user & sigchain associated with key by an admin. The server periodically checks users and sigchains, but this tells the server to do it right away. If check is a kid, will check that key. If check is "all" (not recommended), it will check all keys.

              func (*Client) ChannelCreate

              func (c *Client) ChannelCreate(ctx context.Context, channel *keys.EdX25519Key, user *keys.EdX25519Key, info *api.ChannelInfo) (*ChannelCreated, error)

                ChannelCreate creates a channel.

                func (*Client) ChannelInvites

                func (c *Client) ChannelInvites(ctx context.Context, recipient *keys.EdX25519Key, opts *MessagesOpts) (*ChannelInvites, error)

                  ChannelInvites lists channel invites from directs.

                  func (*Client) ChannelsStatus

                  func (c *Client) ChannelsStatus(ctx context.Context, channelTokens ...*api.ChannelToken) ([]*api.ChannelStatus, error)

                    ChannelsStatus lists channel status.

                    func (*Client) Check

                    func (c *Client) Check(ctx context.Context, key *keys.EdX25519Key) error

                      Check user & sigchain associated with edx25519 key. The server periodically checks users and sigchains, but this tells the server to do it right away.

                      func (*Client) DirectMessageSend

                      func (c *Client) DirectMessageSend(ctx context.Context, message *api.Message, sender *keys.EdX25519Key, recipient keys.ID) error

                        DirectMessageSend an encrypted message.

                        func (*Client) DirectMessages

                        func (c *Client) DirectMessages(ctx context.Context, key *keys.EdX25519Key, opts *MessagesOpts) (*api.Events, error)

                          DirectMessages returns direct messages. If truncated, there are more results if you call again with the new index. To decrypt to api.Message, use api.DecryptMessageFromEvent.

                          func (*Client) DirectToken

                          func (c *Client) DirectToken(ctx context.Context, recipient *keys.EdX25519Key) (*api.DirectToken, error)

                            DirectToken ...

                            func (*Client) Disco

                            func (c *Client) Disco(ctx context.Context, sender keys.ID, recipient *keys.EdX25519Key, typ DiscoType) (string, error)

                              Disco gets a discovery address.

                              func (*Client) DiscoDelete

                              func (c *Client) DiscoDelete(ctx context.Context, sender *keys.EdX25519Key, recipient keys.ID) error

                                DiscoDelete removes discovery addresses.

                                func (*Client) DiscoSave

                                func (c *Client) DiscoSave(ctx context.Context, sender *keys.EdX25519Key, recipient keys.ID, typ DiscoType, data string, expire time.Duration) error

                                  DiscoSave puts a discovery offer or answer.

                                  func (*Client) Follow

                                  func (c *Client) Follow(ctx context.Context, sender *keys.EdX25519Key, recipient keys.ID) error

                                    Follow recipient, allows direct messages.

                                    func (*Client) FollowedBy

                                    func (c *Client) FollowedBy(ctx context.Context, sender keys.ID, recipient *keys.EdX25519Key) (*api.Follow, error)

                                      FollowedBy looks up follow.

                                      func (*Client) Follows

                                      func (c *Client) Follows(ctx context.Context, key *keys.EdX25519Key) ([]*api.Follow, error)

                                        Follows lists follows.

                                        func (*Client) InviteCode

                                        func (c *Client) InviteCode(ctx context.Context, sender *keys.EdX25519Key, code string) (*api.InviteCodeResponse, error)

                                          InviteCode looks for an invite with code.

                                          func (*Client) InviteCodeCreate

                                          func (c *Client) InviteCodeCreate(ctx context.Context, sender *keys.EdX25519Key, recipient keys.ID) (*api.InviteCodeCreateResponse, error)

                                            InviteCodeCreate creates an invite code.

                                            func (*Client) InviteToChannel

                                            func (c *Client) InviteToChannel(ctx context.Context, invite *api.ChannelInvite, sender *keys.EdX25519Key) error

                                              InviteToChannel sends a direct message containing a channel key.

                                              func (*Client) MessageSend

                                              func (c *Client) MessageSend(ctx context.Context, message *api.Message, sender *keys.EdX25519Key, channel *keys.EdX25519Key) error

                                                MessageSend sends an encrypted message to a channel.

                                                func (*Client) Messages

                                                func (c *Client) Messages(ctx context.Context, channel *keys.EdX25519Key, opts *MessagesOpts) (*api.Events, error)

                                                  Messages returns encrypted messages (as event.Event) and current index from a previous index. If truncated, there are more results if you call again with the new index. To decrypt to api.Event, use api.DecryptMessageFromEvent.

                                                  func (*Client) Request

                                                  func (c *Client) Request(ctx context.Context, req *Request) (*Response, error)

                                                    Request makes a request.

                                                    func (*Client) SetClock

                                                    func (c *Client) SetClock(clock tsutil.Clock)

                                                      SetClock sets the clock Now fn.

                                                      func (*Client) SetHTTPClient

                                                      func (c *Client) SetHTTPClient(httpClient *nethttp.Client)

                                                        SetHTTPClient sets the http.Client to use.

                                                        func (*Client) ShareOpen

                                                        func (c *Client) ShareOpen(ctx context.Context, key *keys.EdX25519Key) ([]byte, error)

                                                          ShareOpen opens a secret.

                                                          func (*Client) ShareSeal

                                                          func (c *Client) ShareSeal(ctx context.Context, key *keys.EdX25519Key, data []byte, expire time.Duration) error

                                                            ShareSeal saves a secret on remote with expire.

                                                            func (*Client) Sigchain

                                                            func (c *Client) Sigchain(ctx context.Context, kid keys.ID) (*api.SigchainResponse, error)

                                                              Sigchain for KID. If sigchain not found, a nil response is returned.

                                                              /sigchain/kex1ydecaulsg5qty2axyy770cjdvqn3ef2qa85xw87p09ydlvs5lurq53x0p3/1 {".sig":"Rf39uRlHXTqmOjcqUs5BTssshRdqpaFfmoYYJuA5rNVGgGd/bRG8p8ZebB8K+w9kozMpnuAoa4lko+oPHcabCQ==","data":"eyJrIjoia2V4MXlkZWNhdWxzZzVxdHkyYXh5eTc3MGNqZHZxbjNlZjJxYTg1eHc4N3AwOXlkbHZzNWx1cnE1M3gwcDMiLCJuIjoia2V5cy5wdWIiLCJzcSI6MSwic3IiOiJodHRwcyIsInUiOiJodHRwczovL2tleXMucHViL2tleXNwdWIudHh0In0=","kid":"kex1ydecaulsg5qty2axyy770cjdvqn3ef2qa85xw87p09ydlvs5lurq53x0p3","seq":1,"ts":1588276919715,"type":"user"}

                                                              func (*Client) SigchainSave

                                                              func (c *Client) SigchainSave(ctx context.Context, st *keys.Statement) error

                                                                SigchainSave ...

                                                                func (*Client) URL

                                                                func (c *Client) URL() *url.URL

                                                                  URL ...

                                                                  func (*Client) Unfollow

                                                                  func (c *Client) Unfollow(ctx context.Context, sender *keys.EdX25519Key, recipient keys.ID) error

                                                                    Unfollow recipient.

                                                                    func (*Client) User

                                                                    func (c *Client) User(ctx context.Context, kid keys.ID) (*api.UserResponse, error)

                                                                      User ...

                                                                      func (*Client) UserSearch

                                                                      func (c *Client) UserSearch(ctx context.Context, query string, limit int) (*api.UserSearchResponse, error)

                                                                        UserSearch ...

                                                                        type ContextLogger

                                                                        type ContextLogger interface {
                                                                        	Debugf(ctx context.Context, format string, args ...interface{})
                                                                        	Infof(ctx context.Context, format string, args ...interface{})
                                                                        	Warningf(ctx context.Context, format string, args ...interface{})
                                                                        	Errorf(ctx context.Context, format string, args ...interface{})

                                                                          ContextLogger interface used in this package with request context.

                                                                          func NewContextLogger

                                                                          func NewContextLogger(lev LogLevel) ContextLogger

                                                                            NewContextLogger ...

                                                                            type DiscoType

                                                                            type DiscoType string

                                                                              DiscoType is the type of discovery address.

                                                                              const (
                                                                              	// Offer initiates.
                                                                              	Offer DiscoType = "offer"
                                                                              	// Answer listens.
                                                                              	Answer DiscoType = "answer"

                                                                              type Error

                                                                              type Error struct {
                                                                              	StatusCode int      `json:"code"`
                                                                              	Message    string   `json:"message"`
                                                                              	URL        *url.URL `json:"url,omitempty"`

                                                                                Error ...

                                                                                func (Error) Error

                                                                                func (e Error) Error() string

                                                                                type LogLevel

                                                                                type LogLevel int

                                                                                  LogLevel ...

                                                                                  const (
                                                                                  	// DebugLevel ...
                                                                                  	DebugLevel LogLevel = 3
                                                                                  	// InfoLevel ...
                                                                                  	InfoLevel LogLevel = 2
                                                                                  	// WarnLevel ...
                                                                                  	WarnLevel LogLevel = 1
                                                                                  	// ErrLevel ...
                                                                                  	ErrLevel LogLevel = 0

                                                                                  type Logger

                                                                                  type Logger interface {
                                                                                  	Debugf(format string, args ...interface{})
                                                                                  	Infof(format string, args ...interface{})
                                                                                  	Warningf(format string, args ...interface{})
                                                                                  	Errorf(format string, args ...interface{})
                                                                                  	Fatalf(format string, args ...interface{})

                                                                                    Logger interface used in this package.

                                                                                    func NewLogger

                                                                                    func NewLogger(lev LogLevel) Logger

                                                                                      NewLogger ...

                                                                                      type MessagesOpts

                                                                                      type MessagesOpts struct {
                                                                                      	// Index to list to/from
                                                                                      	Index int64
                                                                                      	// Order ascending or descending
                                                                                      	Order events.Direction
                                                                                      	// Limit by
                                                                                      	Limit int

                                                                                        MessagesOpts options for Messages.

                                                                                        type Request

                                                                                        type Request struct {
                                                                                        	Method string
                                                                                        	Path   string
                                                                                        	Params url.Values
                                                                                        	// Body        io.Reader
                                                                                        	// ContentHash string
                                                                                        	Body     []byte
                                                                                        	Key      *keys.EdX25519Key
                                                                                        	Headers  []http.Header
                                                                                        	Progress func(n int64)

                                                                                          Request ...

                                                                                          type Response

                                                                                          type Response struct {
                                                                                          	Data      []byte
                                                                                          	CreatedAt time.Time
                                                                                          	UpdatedAt time.Time

                                                                                            Response ...