Documentation
¶
Overview ¶
Package user defines user statements, store and search.
Index ¶
- Variables
- func NewSigchainStatement(sc *keys.Sigchain, user *User, sk *keys.EdX25519Key, ts time.Time) (*keys.Statement, error)
- func SetLogger(l Logger)
- type ContextLogger
- type LogLevel
- type Logger
- type Result
- type Status
- type User
- func (u User) Bytes() ([]byte, error)
- func (u User) ID() string
- func (u User) MarshalJSON() ([]byte, error)
- func (u *User) Sign(key *keys.EdX25519Key) (string, error)
- func (u User) String() string
- func (u *User) UnmarshalJSON(b []byte) error
- func (u *User) Validate() error
- func (u *User) Verify(msg string) error
Constants ¶
This section is empty.
Variables ¶
var ErrUserAlreadySet = errors.New("user set in sigchain already")
ErrUserAlreadySet is user already set in sigchain.
Functions ¶
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.
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.
type Result ¶
type Result struct { // Err if error occured. // See Status for type of error. Err string `json:"err,omitempty"` // Status for result. StatusOK if ok, otherwise an error type. Status Status `json:"status"` // Timestamp is the when the status was last updated. Timestamp int64 `json:"ts"` // User. User *User `json:"user"` // Statement we found at User.URL. Statement string `json:"statement,omitempty"` // Proxied if result was through a proxy. Proxied bool `json:"proxied,omitempty"` // VerifiedAt is when the status was last OK. VerifiedAt int64 `json:"vts,omitempty"` }
Result describes the status of a User. TODO: Make Err/Status more explicit, it can be confusing.
func (Result) IsTimestampExpired ¶
IsTimestampExpired returns true if result Timestamp is older than dt.
func (Result) IsVerifyExpired ¶
IsVerifyExpired returns true if result VerifiedAt is older than dt.
type Status ¶
type Status string
Status is the status of the user statement.
const ( // StatusOK if user was found and verified. StatusOK Status = "ok" // StatusResourceNotFound if resource (URL) was not found. StatusResourceNotFound Status = "resource-not-found" // StatusContentNotFound if resource was found, but message was missing. StatusContentNotFound Status = "content-not-found" // StatusStatementInvalid if statement was found but was invalid. StatusStatementInvalid Status = "statement-invalid" // StatusContentInvalid if statement was valid, but other data was invalid. StatusContentInvalid Status = "content-invalid" // StatusConnFailure if there was a (possibly) temporary connection failure. // This could be: // - A connection error if not connected to the internet or unable to reach the service. // - A 5xx error on the server. // - A 4xx error except 404 (for example, 429 if rate limited). StatusConnFailure Status = "connection-fail" // StatusFailure is any other failure. StatusFailure Status = "fail" // StatusUnknown is unknown. StatusUnknown Status = "unknown" )
type User ¶
User describes a name on a service with a signed statement at a URL, signed into a sigchain at (KID, seq).
func FindInSigchain ¶
FindInSigchain returns User from a Sigchain. If user is invalid returns nil.
func NewForSigning ¶
NewForSigning returns User for signing (doesn't have remote URL yet). The name is normalized, for example for twitter "@Username" => "username".
func (User) MarshalJSON ¶
MarshalJSON marshals user to JSON.
func (*User) Sign ¶
func (u *User) Sign(key *keys.EdX25519Key) (string, error)
Sign user into an armored message.
func (*User) UnmarshalJSON ¶
UnmarshalJSON unmarshals a user from JSON.