Documentation
¶
Index ¶
- func SetLogger(l Logger)
- type Client
- func (c *Client) AdminCheck(ctx context.Context, check string, admin *keys.EdX25519Key) error
- func (c *Client) Check(ctx context.Context, key *keys.EdX25519Key) error
- func (c *Client) Disco(ctx context.Context, sender keys.ID, recipient *keys.EdX25519Key, ...) (string, error)
- func (c *Client) DiscoDelete(ctx context.Context, sender *keys.EdX25519Key, recipient keys.ID) error
- func (c *Client) DiscoSave(ctx context.Context, sender *keys.EdX25519Key, recipient keys.ID, ...) error
- func (c *Client) HTTPClient() *nethttp.Client
- func (c *Client) InviteCode(ctx context.Context, sender *keys.EdX25519Key, code string) (*api.InviteCodeResponse, error)
- func (c *Client) InviteCodeCreate(ctx context.Context, sender *keys.EdX25519Key, recipient keys.ID) (*api.InviteCodeCreateResponse, error)
- func (c *Client) Request(ctx context.Context, req *Request) (*Response, error)
- func (c *Client) SetClock(clock tsutil.Clock)
- func (c *Client) SetHTTPClient(httpClient *nethttp.Client)
- func (c *Client) ShareOpen(ctx context.Context, key *keys.EdX25519Key) ([]byte, error)
- func (c *Client) ShareSeal(ctx context.Context, key *keys.EdX25519Key, data []byte, expire time.Duration) error
- func (c *Client) Sigchain(ctx context.Context, kid keys.ID) (*api.SigchainResponse, error)
- func (c *Client) SigchainSave(ctx context.Context, st *keys.Statement) 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 Error
- type LogLevel
- type Logger
- type Request
- type Response
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. If check is a kid, will check that key. If check is "all" (not recommended), it will check all keys.
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) 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) 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) SetHTTPClient ¶
SetHTTPClient sets the http.Client to use.
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 ¶
Sigchain for KID. If sigchain not found, a nil response is returned.
Example ¶
package main
import (
"context"
"fmt"
"log"
"github.com/keys-pub/keys"
"github.com/keys-pub/keys-ext/http/client"
"github.com/keys-pub/keys/http"
"github.com/keys-pub/keys/user"
"github.com/keys-pub/keys/user/services"
)
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)
// Verify the user.
result := services.Verify(context.TODO(), services.HTTPS, http.NewClient(), usr)
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) SigchainSave ¶
SigchainSave ...
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 Error ¶
type Error struct {
StatusCode int `json:"code"`
Message string `json:"message"`
URL *url.URL `json:"url,omitempty"`
}
Error ...
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.