Documentation
¶
Overview ¶
Package account coordinates official-service credentials outside relay handshakes.
Index ¶
- Constants
- Variables
- func CommandErrorCode(err error) string
- type Challenge
- type Config
- type Credential
- type FileStore
- type HTTPClient
- type MemoryStore
- type Nickname
- type Node
- type PendingEmail
- type Profile
- type Proof
- type Record
- type RefreshOutcome
- type Service
- func (service *Service) Close()
- func (service *Service) ConfirmProfileEmail(ctx context.Context, accountID, challengeID, code string) error
- func (service *Service) Login(ctx context.Context, username, password string) error
- func (service *Service) NewShareAuthorization(ctx context.Context) *ShareAuthorization
- func (service *Service) ObserveAccount() func()
- func (service *Service) RefreshOnce(ctx context.Context) (RefreshOutcome, error)
- func (service *Service) Register(ctx context.Context) (err error)
- func (service *Service) ReloadSelection(ctx context.Context) error
- func (service *Service) RequestEmail(ctx context.Context, email string) error
- func (service *Service) RequestProfileEmail(ctx context.Context, accountID, address string) error
- func (service *Service) RevokeCredential(ctx context.Context, accountID string, credential [16]byte) error
- func (service *Service) SetNickname(ctx context.Context, accountID, nickname string) error
- func (service *Service) SetPassword(ctx context.Context, accountID, username, password string) error
- func (service *Service) Snapshot() (Snapshot, <-chan struct{})
- func (service *Service) VerifyEmail(ctx context.Context, code string) error
- type ShareAuthorization
- type Snapshot
- type Source
- type State
- type Store
Constants ¶
const ( CacheLoadTimeout = 100 * time.Millisecond RequestTimeout = 8 * time.Second // The authority waits up to 15 seconds for the mail provider to accept delivery. EmailRequestTimeout = 20 * time.Second RefreshInterval = time.Minute TicketRenewalLead = time.Hour PollInterval = 5 * time.Second MinimumRetry = time.Second MaximumRetry = time.Minute TicketMargin = time.Minute )
Variables ¶
var ( // ErrInvalidState reports a corrupt, oversized, or mismatched local account // file that requires manual repair instead of retrying automatically. ErrInvalidState = errors.New("invalid account state") // ErrUnreadableState reports a local account file that cannot be read due // to filesystem permissions or an unexpected file type. ErrUnreadableState = errors.New("account state unreadable") )
var ErrNotConfigured = errors.New("official account service is not configured")
var ErrSuperseded = errors.New("account changed while the operation was in progress")
Functions ¶
func CommandErrorCode ¶ added in v0.1.4
CommandErrorCode lets interactive clients localize a recovery action without parsing authority messages.
Types ¶
type Credential ¶
type FileStore ¶
type FileStore struct{ Path string }
type MemoryStore ¶
type MemoryStore struct {
// contains filtered or unexported fields
}
type PendingEmail ¶ added in v0.1.4
type Record ¶
type Record struct {
Issuer string `json:"issuer"`
SetupSecret string `json:"setup_secret,omitempty"`
Credential *Credential `json:"credential,omitempty"`
Profile Profile `json:"profile,omitzero"`
PendingEmail PendingEmail `json:"pending_email,omitzero"`
Certificate string `json:"certificate,omitempty"`
Ticket string `json:"ticket,omitempty"`
Entitlement serviceauthority.Entitlement `json:"entitlement"`
Denial string `json:"denial,omitempty"`
Proof *Proof `json:"proof,omitempty"`
}
type RefreshOutcome ¶ added in v0.1.4
type RefreshOutcome string
RefreshOutcome describes what a completed attempt achieved for its caller.
const ( RefreshSucceeded RefreshOutcome = "refreshed" RefreshNeedsRegistration RefreshOutcome = "registration_required" RefreshNeedsEmail RefreshOutcome = "email_required" )
type Service ¶
type Service struct {
// contains filtered or unexported fields
}
func (*Service) ConfirmProfileEmail ¶ added in v0.1.4
func (*Service) NewShareAuthorization ¶ added in v0.1.4
func (service *Service) NewShareAuthorization(ctx context.Context) *ShareAuthorization
NewShareAuthorization binds the selected local credential before any official relay attempts registration. Setup and ticket renewal can finish in the background.
func (*Service) ObserveAccount ¶ added in v0.1.4
func (service *Service) ObserveAccount() func()
ObserveAccount maintains the selected account for the lifetime of a visible view.
func (*Service) RefreshOnce ¶ added in v0.1.4
func (service *Service) RefreshOnce(ctx context.Context) (RefreshOutcome, error)
RefreshOnce runs one explicit attempt without activating background maintenance. A usable cached ticket can coexist with an unfinished or failed attempt.
func (*Service) Register ¶ added in v0.1.4
Register runs one user-requested attempt through issuance or an email handoff. The operation lock also keeps a refresh or a double submission from starting a second solve.
func (*Service) ReloadSelection ¶ added in v0.1.4
ReloadSelection publishes the shared local selection to observers independently of authority operations.
func (*Service) RequestEmail ¶
func (*Service) RequestProfileEmail ¶ added in v0.1.4
func (*Service) RevokeCredential ¶
func (*Service) SetNickname ¶ added in v0.1.4
func (*Service) SetPassword ¶
type ShareAuthorization ¶ added in v0.1.4
type ShareAuthorization struct {
// contains filtered or unexported fields
}
ShareAuthorization owns the identity shared by all official relay registrations in one share. Its state and credential references are guarded by Service.mu.
func (*ShareAuthorization) Close ¶ added in v0.1.4
func (share *ShareAuthorization) Close()
func (*ShareAuthorization) Source ¶ added in v0.1.4
func (share *ShareAuthorization) Source(address string) *Source
type Snapshot ¶
type Snapshot struct {
Active bool `json:"active"`
State State `json:"state"`
EmailCodePending bool `json:"email_code_pending,omitempty"`
Account string `json:"account,omitempty"`
Credential string `json:"credential,omitempty"`
Username string `json:"username,omitempty"`
Profile Profile `json:"profile"`
PendingEmail PendingEmail `json:"pending_email,omitzero"`
Allowance serviceauthority.Allowance `json:"allowance"`
RemainingBytes uint64 `json:"remaining_bytes"`
ResetAt time.Time `json:"reset_at,omitzero"`
ValidUntil time.Time `json:"valid_until,omitzero"`
TicketExpires time.Time `json:"ticket_expires,omitzero"`
RetryAt time.Time `json:"retry_at,omitzero"`
RegistrationPermille uint16 `json:"registration_permille,omitempty"`
Reason string `json:"reason,omitempty"`
}
type Source ¶
type Source struct {
// contains filtered or unexported fields
}
func (*Source) ReserveRegistrationAuthorization ¶ added in v0.1.4
func (source *Source) ReserveRegistrationAuthorization() serviceauthority.RegistrationAuthorization
type State ¶
type State string
const ( Pending State = "pending_setup" RegistrationRequired State = "registration_required" Registering State = "registering" EmailRequired State = "email_required" Ready State = "ready" RefreshRequired State = "refresh_required" Refreshing State = "refreshing" StorageError State = "storage_error" Denied State = "denied" )