Documentation ¶
Index ¶
- func SetLogger(l Logger)
- type Client
- func (c *Client) AdminCheck(ctx context.Context, kid keys.ID, admin *keys.EdX25519Key) error
- func (c *Client) Check(ctx context.Context, key *keys.EdX25519Key) error
- func (c *Client) CreateInvite(ctx context.Context, sender *keys.EdX25519Key, recipient keys.ID) (*api.CreateInviteResponse, error)
- func (c *Client) DecryptMessage(key *keys.EdX25519Key, msg *Message) ([]byte, keys.ID, error)
- func (c *Client) DeleteDisco(ctx context.Context, sender *keys.EdX25519Key, recipient keys.ID) error
- func (c *Client) GetDisco(ctx context.Context, sender keys.ID, recipient *keys.EdX25519Key, ...) (string, error)
- func (c *Client) Invite(ctx context.Context, sender *keys.EdX25519Key, code string) (*api.InviteResponse, error)
- func (c *Client) Messages(ctx context.Context, key *keys.EdX25519Key, from keys.ID, opts *MessagesOpts) ([]*Message, string, error)
- func (c *Client) Now() time.Time
- func (c *Client) PutDisco(ctx context.Context, sender *keys.EdX25519Key, recipient keys.ID, ...) error
- func (c *Client) PutSigchainStatement(ctx context.Context, st *keys.Statement) error
- func (c *Client) SendMessage(ctx context.Context, sender *keys.EdX25519Key, recipient keys.ID, b []byte, ...) (*api.CreateMessageResponse, error)
- func (c *Client) SetHTTPClient(httpClient *http.Client)
- func (c *Client) SetTimeNow(nowFn func() time.Time)
- func (c *Client) Sigchain(ctx context.Context, kid keys.ID) (*api.SigchainResponse, error)
- func (c *Client) URL() *url.URL
- func (c *Client) User(ctx context.Context, kid keys.ID) (*api.UserResponse, error)
- func (c *Client) UserSearch(ctx context.Context, query string, limit int) (*api.UserSearchResponse, error)
- type ContextLogger
- type DiscoType
- type ErrResponse
- type LogLevel
- type Logger
- type Message
- type MessagesOpts
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client ...
func (*Client) AdminCheck ¶
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.
func (*Client) Check ¶
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 ¶
func (c *Client) CreateInvite(ctx context.Context, sender *keys.EdX25519Key, recipient keys.ID) (*api.CreateInviteResponse, error)
CreateInvite writes a sender recipient address (invite).
func (*Client) DecryptMessage ¶
DecryptMessage decrypts a message from Messages.
func (*Client) DeleteDisco ¶
func (c *Client) DeleteDisco(ctx context.Context, sender *keys.EdX25519Key, recipient keys.ID) error
DeleteDisco removes discovery addresses.
func (*Client) GetDisco ¶
func (c *Client) GetDisco(ctx context.Context, sender keys.ID, recipient *keys.EdX25519Key, typ DiscoType) (string, error)
GetDisco gets a discovery address.
func (*Client) Invite ¶
func (c *Client) Invite(ctx context.Context, sender *keys.EdX25519Key, code string) (*api.InviteResponse, error)
Invite looks for an invite with code.
func (*Client) Messages ¶
func (c *Client) Messages(ctx context.Context, key *keys.EdX25519Key, from keys.ID, opts *MessagesOpts) ([]*Message, string, error)
Messages returns encrypted messages. To decrypt a message, use Client#DecryptMessage.
func (*Client) PutDisco ¶
func (c *Client) PutDisco(ctx context.Context, sender *keys.EdX25519Key, recipient keys.ID, typ DiscoType, data string, expire time.Duration) error
PutDisco puts a discovery offer or answer.
func (*Client) PutSigchainStatement ¶
PutSigchainStatement ...
func (*Client) SendMessage ¶
func (c *Client) SendMessage(ctx context.Context, sender *keys.EdX25519Key, recipient keys.ID, b []byte, expire time.Duration) (*api.CreateMessageResponse, error)
SendMessage posts an encrypted expiring message.
func (*Client) SetHTTPClient ¶
SetHTTPClient sets the http.Client to use.
func (*Client) SetTimeNow ¶
SetTimeNow sets the clock Now fn.
func (*Client) Sigchain ¶
Sigchain for KID. If sigchain not found, a nil response is returned.
Example ¶
package main import ( "context" "fmt" "log" "time" "github.com/keys-pub/keys" "github.com/keys-pub/keys/request" "github.com/keys-pub/keys/user" "github.com/keys-pub/keysd/http/client" ) func main() { cl, err := client.New("https://keys.pub") if err != nil { log.Fatal(err) } // Get the keys.Sigchain. kid := keys.ID("kex1ydecaulsg5qty2axyy770cjdvqn3ef2qa85xw87p09ydlvs5lurq53x0p3") resp, err := cl.Sigchain(context.TODO(), kid) if err != nil { log.Fatal(err) } sc, err := resp.Sigchain() if err != nil { log.Fatal(err) } fmt.Printf("%s", sc.Spew()) // Find the user.User in the keys.Sigchain. usr, err := user.FindInSigchain(sc) if err != nil { log.Fatal(err) } fmt.Printf("%+v\n", usr) // Request the User URL and verify it. result := user.RequestVerify(context.TODO(), request.NewHTTPRequestor(), usr, time.Now()) if result.Status != user.StatusOK { log.Fatalf("User check failed: %+v", result) } // Check result status. fmt.Printf("%s\n", result.Status) }
Output: /sigchain/kex1ydecaulsg5qty2axyy770cjdvqn3ef2qa85xw87p09ydlvs5lurq53x0p3/1 {".sig":"Rf39uRlHXTqmOjcqUs5BTssshRdqpaFfmoYYJuA5rNVGgGd/bRG8p8ZebB8K+w9kozMpnuAoa4lko+oPHcabCQ==","data":"eyJrIjoia2V4MXlkZWNhdWxzZzVxdHkyYXh5eTc3MGNqZHZxbjNlZjJxYTg1eHc4N3AwOXlkbHZzNWx1cnE1M3gwcDMiLCJuIjoia2V5cy5wdWIiLCJzcSI6MSwic3IiOiJodHRwcyIsInUiOiJodHRwczovL2tleXMucHViL2tleXNwdWIudHh0In0=","kid":"kex1ydecaulsg5qty2axyy770cjdvqn3ef2qa85xw87p09ydlvs5lurq53x0p3","seq":1,"ts":1588276919715,"type":"user"} keys.pub@https!kex1ydecaulsg5qty2axyy770cjdvqn3ef2qa85xw87p09ydlvs5lurq53x0p3-1#https://keys.pub/keyspub.txt ok
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.
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{}) }
Logger interface used in this package.