users

package
v0.1.22 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2021 License: MIT Imports: 13 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LookupService added in v0.1.18

func LookupService(usr *user.User, opt ...UpdateOption) (services.Service, error)

LookupService finds service.

func SetLogger

func SetLogger(l Logger)

SetLogger sets logger for the package.

func ValidateStatement

func ValidateStatement(st *keys.Statement) error

ValidateStatement returns error if statement is not a valid user statement.

Types

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 LogLevel

type LogLevel int

LogLevel ...

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

func (LogLevel) String

func (l LogLevel) String() string

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 Option

type Option func(*Options)

Option ...

func Client added in v0.1.18

func Client(client http.Client) Option

Client to use.

func Clock

func Clock(clock tsutil.Clock) Option

Clock to use.

func HTTPClient added in v0.1.21

func HTTPClient(nhc *nethttp.Client) Option

HTTPClient to use.

type Options

type Options struct {
	Client http.Client
	Clock  tsutil.Clock
}

Options are options for Users.

type SearchRequest

type SearchRequest struct {
	// Query to search for.
	Query string
	// Limit number of results.
	Limit int
}

SearchRequest ...

type SearchResult

type SearchResult struct {
	KID    keys.ID
	Result *user.Result
	// Field we matched on (if not the user).
	Field string
}

SearchResult ...

type ServiceLookupFn added in v0.1.19

type ServiceLookupFn func(usr *user.User) services.Service

ServiceLookupFn for custom service lookup.

type UpdateOption added in v0.1.18

type UpdateOption func(*UpdateOptions)

UpdateOption ...

func UseService added in v0.1.19

func UseService(service ServiceLookupFn) UpdateOption

UseService option.

type UpdateOptions added in v0.1.18

type UpdateOptions struct {
	// Specify the service to use for the check.
	// For twitter proxy, use services.Proxy.
	Service ServiceLookupFn
}

UpdateOptions ...

type Users

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

Users keeps track of sigchain user links.

func New

func New(ds dstore.Documents, scs *keys.Sigchains, opt ...Option) *Users

New creates Users lookup.

func (*Users) CheckForExisting

func (u *Users) CheckForExisting(ctx context.Context, sc *keys.Sigchain) (keys.ID, error)

CheckForExisting returns key ID of existing user in sigchain different from the specified sigchain.

func (*Users) CheckSigchain

func (u *Users) CheckSigchain(ctx context.Context, sc *keys.Sigchain, opt ...UpdateOption) (*user.Result, error)

CheckSigchain looks for user in a Sigchain and creates a result or updates the current result.

func (*Users) Client added in v0.1.18

func (u *Users) Client() http.Client

Client ...

func (*Users) Expired

func (u *Users) Expired(ctx context.Context, dt time.Duration, maxAge time.Duration) ([]keys.ID, error)

Expired returns KIDs that haven't been checked in a duration.

func (*Users) Find

func (u *Users) Find(ctx context.Context, kid keys.ID) (*user.Result, error)

Find user result for KID. Will also search for related keys.

func (*Users) Get

func (u *Users) Get(ctx context.Context, kid keys.ID) (*user.Result, error)

Get user result for KID. Retrieves cached result. If Update(kid) has not been called or there is no user statement, this will return nil.

func (*Users) KIDs

func (u *Users) KIDs(ctx context.Context) ([]keys.ID, error)

KIDs returns all key ids in the user store.

func (*Users) RequestVerify

func (u *Users) RequestVerify(ctx context.Context, service services.Service, usr *user.User) *user.Result

RequestVerify requests and verifies a user. Doesn't index result.

func (*Users) Search

func (u *Users) Search(ctx context.Context, req *SearchRequest) ([]*SearchResult, error)

Search for users.

func (*Users) Status

func (u *Users) Status(ctx context.Context, st user.Status) ([]keys.ID, error)

Status returns KIDs that match a status.

func (*Users) Update

func (u *Users) Update(ctx context.Context, kid keys.ID, opt ...UpdateOption) (*user.Result, error)

Update index for key.

func (*Users) User

func (u *Users) User(ctx context.Context, user string) (*user.Result, error)

User result for user name@service. Retrieves cached result. If Update(kid) has not been called or there is no user statement, this will return nil.

Jump to

Keyboard shortcuts

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