keysd: github.com/keys-pub/keysd/http/client Index | Files

package client

import "github.com/keys-pub/keysd/http/client"

Index

Package Files

check.go client.go disco.go invite.go log.go messages.go sigchain.go user.go

func SetLogger Uses

func SetLogger(l Logger)

SetLogger sets logger for the package.

type Client Uses

type Client struct {
    // contains filtered or unexported fields
}

Client ...

func NewClient Uses

func NewClient(urs string, ks *keys.Keystore) (*Client, error)

NewClient creates a Client for an HTTP API.

func (*Client) Check Uses

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) CreateInvite Uses

func (c *Client) CreateInvite(ctx context.Context, sender keys.ID, recipient keys.ID) (*api.CreateInviteResponse, error)

func (*Client) DecryptMessage Uses

func (c *Client) DecryptMessage(key *keys.EdX25519Key, msg *Message) ([]byte, keys.ID, error)

func (*Client) DeleteDisco Uses

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

func (*Client) GetDisco Uses

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

func (*Client) Invite Uses

func (c *Client) Invite(ctx context.Context, sender keys.ID, code string) (*api.InviteResponse, error)

func (*Client) Messages Uses

func (c *Client) Messages(ctx context.Context, kid keys.ID, from keys.ID, opts *MessagesOpts) ([]*Message, string, error)

Messages returns encrypted messages. To decrypt a message, use Client#DecryptMessage.

func (*Client) PutDisco Uses

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

PutDisco puts a discovery offer or answer.

func (*Client) PutSigchainStatement Uses

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

PutSigchainStatement ...

func (*Client) SendMessage Uses

func (c *Client) SendMessage(ctx context.Context, sender keys.ID, recipient keys.ID, b []byte, expire time.Duration) (*api.CreateMessageResponse, error)

SendMessage posts an encrypted expiring message.

func (*Client) SetHTTPClient Uses

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

SetHTTPClient sets the http.Client to use.

func (*Client) SetTimeNow Uses

func (c *Client) SetTimeNow(nowFn func() time.Time)

SetTimeNow sets the clock Now fn.

func (*Client) Sigchain Uses

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.

func (*Client) URL Uses

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

URL ...

func (*Client) User Uses

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

User ...

func (*Client) UserSearch Uses

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

UserSearch ...

type ContextLogger Uses

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 Uses

func NewContextLogger(lev LogLevel) ContextLogger

NewContextLogger ...

type DiscoType Uses

type DiscoType string
const (
    Offer  DiscoType = "offer"
    Answer DiscoType = "answer"
)

type ErrResponse Uses

type ErrResponse struct {
    StatusCode int
    Message    string
    URL        *url.URL
}

ErrResponse ...

func (ErrResponse) Error Uses

func (e ErrResponse) Error() string

type LogLevel Uses

type LogLevel int

LogLevel ...

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

type Logger Uses

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

Logger interface used in this package.

func NewLogger Uses

func NewLogger(lev LogLevel) Logger

NewLogger ...

type Message Uses

type Message struct {
    ID   string
    Data []byte

    CreatedAt time.Time
    UpdatedAt time.Time
}

Message from server.

type MessagesOpts Uses

type MessagesOpts struct {
    // Version to list to/from
    Version string
    // Direction ascending or descending
    Direction keys.Direction
    // Limit by
    Limit int
}

MessagesOpts options for Messages.

Package client imports 20 packages (graph) and is imported by 3 packages. Updated 2020-04-09. Refresh now. Tools for package owners.